@tomorrowevening/hermes 0.0.101 → 0.0.103
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hermes.cjs.js +14 -14
- package/dist/hermes.es.js +1188 -1155
- package/package.json +1 -1
- package/types/core/remote/RemoteThree.d.ts +2 -1
- package/types/core/types.d.ts +1 -1
- package/types/editor/global.d.ts +2 -1
- package/types/editor/tools/splineEditor/Spline.d.ts +1 -1
- package/types/editor/tools/splineEditor/index.d.ts +2 -0
- package/types/editor/sidePanel/CustomAccordion.d.ts +0 -6
package/dist/hermes.cjs.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),w=require("react"),es=require("framer-motion"),li=()=>{},Hs=()=>{};function dt(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function ts(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function xe(s,e,t){return Math.min(e,Math.max(s,t))}function ii(s,e,t){return(t-s)/(e-s)}function Rt(s,e,t){return s*(1-t)+e*t}function Bs(s,e){const t=s-e;return Math.sqrt(t*t)}function is(){return Math.round(Math.random()*1e6).toString()}function ss(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function si(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),i=Math.round(s.b*255),n=d=>{const h=d.toString(16);return h.length===1?"0"+h:h},a=n(e),r=n(t),l=n(i);return"#"+a+r+l}function Xe(s,e=1){return Number(s.toFixed(e))}exports.totalThreeObjects=0;const ni=()=>{exports.totalThreeObjects=0},Dt=s=>{if(!s)return;let e=s.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),s.parent!==null&&s.parent.uuid.length>0&&(e=`${s.parent.uuid}.${e}`),s.uuid=e,s.isMesh!==void 0){const t=s;if(Array.isArray(t.material))t.material.forEach((i,n)=>{i.uuid=`${e}.material.${n}`});else{const i=t.material;i.uuid=`${e}.material`}}s.children.forEach(t=>Dt(t))},Vs=s=>{s?.dispose()},ns=s=>{s&&(Array.isArray(s)?s.forEach(e=>e.dispose()):s.dispose())},Oe=s=>{if(s){for(;s.children.length>0;){const e=s.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Oe(e)}if(s.parent&&s.parent.remove(s),s.isMesh){const e=s;e.geometry?.dispose(),ns(e.material)}s.dispose!==void 0&&s.dispose()}};class ht{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 t=e.repeat.clone(),i=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 n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/n.width,r=this.renderToCanvas(e);this.context.drawImage(r,0,0,n.width*a,n.height*a)}}return e.repeat.copy(t),e.offset.copy(i),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new o.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new o.Scene,this.material=new o.MeshBasicMaterial;const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new o.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new o.Float32BufferAttribute([0,0,2,0,0,2],2));const i=new o.Mesh(t,this.material);this.scene.add(i)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,i=e.colorSpace;this.renderer.outputColorSpace=o.LinearSRGBColorSpace,e.colorSpace=o.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=i}return this.renderer.domElement}}class Ys{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,i=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=i,i?(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,t){this.components.set(e,t)}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")}}var R=(s=>(s.CUSTOM="ToolEvents::custom",s.SELECT_DROPDOWN="ToolEvents::selectDropdown",s.DRAG_UPDATE="ToolEvents::dragUpdate",s.ADD_SCENE="ToolEvents::addScene",s.REFRESH_SCENE="ToolEvents::refreshScene",s.REMOVE_SCENE="ToolEvents::removeScene",s.SET_SCENE="ToolEvents::setScene",s.GET_OBJECT="ToolEvents::getObject",s.SET_OBJECT="ToolEvents::setObject",s.UPDATE_OBJECT="ToolEvents::updateObject",s.CREATE_TEXTURE="ToolEvents::createTexture",s.REQUEST_METHOD="ToolEvents::requestMethod",s.ADD_CAMERA="ToolEvents::addCamera",s.REMOVE_CAMERA="ToolEvents::removeCamera",s.ADD_GROUP="ToolEvents::addGroup",s.REMOVE_GROUP="ToolEvents::removeGroup",s))(R||{});const D=new o.EventDispatcher;class It{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,i){}handleEditor(e,t,i){}}class Gs extends It{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,i){switch(i.event){case"selectComponent":D.dispatchEvent({type:R.SELECT_DROPDOWN,value:i.data});break;case"draggableListUpdate":D.dispatchEvent({type:R.DRAG_UPDATE,value:i.data});break}}}function Zs(s,e,t){if(s.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let d=l.address.sheetId,h="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":h="setSheet",p={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":h="setSheetObject",d+=`_${l.address.objectKey}`,p={id:d,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}s.send({event:h,target:"app",data:p})})});let i=-1;const n=()=>{if(e.activeSheet!==void 0&&i!==e.activeSheet.sequence.position){i=e.activeSheet.sequence.position;const r=e.activeSheet;s.send({event:"updateTimeline",target:"app",data:{position:i,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else t.ui.hide()}function Ws(){const s=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=s?.children[1];e.style.justifyContent="left";const t=e.children[1];t.style.transform="translateX(10px)",t.removeChild(t.children[0]),t.removeChild(t.children[0]);const i=s?.children[3];i.style.top="0",i.style.right="300px"}class ci extends It{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,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const i=this.getSheetInstance(e,t);let n=this.sheets.get(i);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(i,n)),n}playSheet(e,t,i){return this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}}),new Promise(n=>{const a=t!==void 0?{...t}:{};a.rafDriver=ci.rafDriver,this.sheet(e,i)?.sequence.play(a).then(r=>n(r))})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,i)=>{i.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,i,n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.sheet(e,a);if(r===void 0)return;const d=`${this.getSheetInstance(e,a)}_${t}`;let h=this.sheetObjects.get(d);h!==void 0?h=r.object(t,{...i,...h.value},{reconfigure:!0}):h=r.object(t,i),this.sheetObjects.set(d,h),this.sheetObjectCBs.set(d,n!==void 0?n:li);const p=h.onValuesChange(f=>{if(this.app.editor){for(const y in f){const x=f[y];typeof x=="object"&&ss(x)&&(f[y]={r:x.r,g:x.g,b:x.b,a:x.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:d,values:f}})}const g=this.sheetObjectCBs.get(d);g!==void 0&&g(f)});return this.sheetObjectUnsubscribe.set(d,p),h}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,i=e.address.objectKey;this.sheets.get(t)?.detachObject(i);const a=`${t}_${i}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e,t,i){const n=t;let a;switch(i.event){case"setSheet":a=n.sheets.get(i.data.sheet),a!==void 0&&(n.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=n.sheetObjects.get(`${i.data.sheet}_${i.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=n.sheets.get(i.data.sheet),a!==void 0&&a.sequence.pause(),a=n.sheetObjectCBs.get(i.data.sheetObject),a!==void 0&&a(i.data.values);break;case"updateTimeline":a=n.sheets.get(i.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=i.data.position);break}}handleEditor(e,t,i){if(e.editor){const n=t;switch(i.event){case"playSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.play(i.data.value);break;case"pauseSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.pause();break}}}handleEditorApp(e,t){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let d=l.address.sheetId,h="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":h="setSheet",p={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":h="setSheetObject",d+=`_${l.address.objectKey}`,p={id:d,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:h,target:"app",data:p})})});let i=-1;const n=()=>{if(t.activeSheet!==void 0&&i!==t.activeSheet.sequence.position){i=t.activeSheet.sequence.position;const r=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:i,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else this.studio?.ui.hide()}}function Xs(s){if(s.name==="cameras")return"camera";if(s.name==="interactive")return"interactive";if(s.name==="lights")return"light";if(s.name==="ui")return"ui";if(s.name==="utils")return"utils";const e=s.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function We(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(We(t))}),e}function Qs(s){const e={};for(const t in s){const i=s[t].value;e[t]={value:i},i===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:i!==void 0&&i.isTexture&&(e[t].value={src:i.image.src,offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]})}return e}function $s(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function ze(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||$s(t))continue;const i=typeof s[t],n=s[t];switch(i){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:ht.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=Qs(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.clearcoat!==void 0&&(e.clearcoat=s.clearcoat),s.iridescence!==void 0&&(e.iridescence=s.iridescence),s.dispersion!==void 0&&(e.dispersion=s.dispersion),s.sheen!==void 0&&(e.sheen=s.sheen),s.transmission!==void 0&&(e.transmission=s.transmission),s.transmission!==void 0&&(e.transmission=s.transmission),e}function Yt(s){s.updateMatrix();const e={name:s.name,type:s.type,uuid:s.uuid,visible:s.visible,matrix:s.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};s.animations.forEach(i=>{e.animations.push({name:i.name,duration:i.duration,blendMode:i.blendMode})});const t=s.type.toLowerCase();if(t.search("mesh")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(ze(a))}),e.material=n}else e.material=ze(i.material)}else if(t.search("points")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(ze(a))}),e.material=n}else e.material=ze(i.material)}else if(t.search("line")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(ze(a))}),e.material=n}else e.material=ze(i.material)}else t.search("camera")>-1?s.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:s.fov,zoom:s.zoom,near:s.near,far:s.far,focus:s.focus,aspect:s.aspect,filmGauge:s.filmGauge,filmOffset:s.filmOffset}:s.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:s.zoom,near:s.near,far:s.far,left:s.left,right:s.right,top:s.top,bottom:s.bottom}):t.search("light")>-1&&(e.lightInfo={color:s.color,intensity:s.intensity,decay:s.decay,distance:s.distance,angle:s.angle,penumbra:s.penumbra,groundColor:s.groundColor,width:s.width,height:s.height});return e}function qs(s,e){const t=e.split(".");switch(t.length){case 1:return s[t[0]];case 2:return s[t[0]][t[1]];case 3:return s[t[0]][t[1]][t[2]];case 4:return s[t[0]][t[1]][t[2]][t[3]];case 5:return s[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return s[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function Ks(s,e){for(const t in e)s[t]=e[t]}function q(s,e,t){if(s===void 0)return;const i=e.split("."),n=i.length;if(typeof t!="object")switch(n){case 1:s[i[0]]=t;break;case 2:s[i[0]][i[1]]=t;break;case 3:s[i[0]][i[1]][i[2]]=t;break;case 4:s[i[0]][i[1]][i[2]][i[3]]=t;break;case 5:s[i[0]][i[1]][i[2]][i[3]][i[4]]=t;break}else{let r;switch(n){case 1:r=s[i[0]];break;case 2:r=s[i[0]][i[1]];break;case 3:r=s[i[0]][i[1]][i[2]];break;case 4:r=s[i[0]][i[1]][i[2]][i[3]];break;case 5:r=s[i[0]][i[1]][i[2]][i[3]][i[4]];break}r!=null&&Ks(r,t)}}function rs(s){return new Promise((e,t)=>{const i=new Image;i.onload=()=>{const n=new o.Texture(i);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},i.onerror=t,i.src=s})}class Js extends It{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Oe(e)}),this.scenes.clear(),this.scene&&Oe(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(ht.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(ht.renderer=this.renderer);const t=Yt(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,i,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:i,subitem:n}})}updateObject(e,t,i){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:i}})}createTexture(e,t,i){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:i}})}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,t,i){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:i})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;ni(),Dt(e);const t=We(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const i=We(t);this.app.send({event:"refreshScene",target:"app",data:i})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=We(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((i,n)=>{e.search(n)>-1&&(t=i)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(ht.renderer=this.renderer),ni(),Dt(e);const t=We(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Yt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Yt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,i){const n=t;switch(i.event){case"getObject":D.dispatchEvent({type:R.GET_OBJECT,value:i.data});break;case"updateObject":D.dispatchEvent({type:R.UPDATE_OBJECT,value:i.data});break;case"createTexture":D.dispatchEvent({type:R.CREATE_TEXTURE,value:i.data});break;case"requestMethod":D.dispatchEvent({type:R.REQUEST_METHOD,value:i.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:We(n.scenes.get(i.data.name))});break}if(i.event==="updateGroup"){const a=JSON.parse(i.data);n.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,t,i){switch(i.event){case"setObject":D.dispatchEvent({type:R.SET_OBJECT,value:i.data});break;case"addScene":D.dispatchEvent({type:R.ADD_SCENE,value:i.data});break;case"refreshScene":D.dispatchEvent({type:R.REFRESH_SCENE,value:i.data});break;case"removeScene":D.dispatchEvent({type:R.REMOVE_SCENE,value:i.data});break;case"setScene":D.dispatchEvent({type:R.SET_SCENE,value:i.data});break;case"addCamera":D.dispatchEvent({type:R.ADD_CAMERA,value:i.data});break;case"removeCamera":D.dispatchEvent({type:R.REMOVE_CAMERA,value:i.data});break;case"addGroup":D.dispatchEvent({type:R.ADD_GROUP,value:i.data});break;case"removeGroup":D.dispatchEvent({type:R.REMOVE_GROUP,value:i.data});break}}addRT(e,t){const i=new o.WebGLRenderTarget(32,32,t);i.texture.name=e,this.renderTargets.set(e,i)}resize(e,t){const i=this.dpr;this.renderTargets.forEach(n=>{n.setSize(e*i,t*i)}),this.renderer?.setSize(e,t)}set dpr(e){this.renderer?.setPixelRatio(xe(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}var ri={exports:{}},qe={};/**
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),w=require("react"),ts=require("framer-motion"),hi=()=>{},Bs=()=>{};function dt(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function is(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function Oe(s,e,t){return Math.min(e,Math.max(s,t))}function si(s,e,t){return(t-s)/(e-s)}function Dt(s,e,t){return s*(1-t)+e*t}function Vs(s,e){const t=s-e;return Math.sqrt(t*t)}function ss(){return Math.round(Math.random()*1e6).toString()}function ns(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function ni(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),i=Math.round(s.b*255),n=h=>{const d=h.toString(16);return d.length===1?"0"+d:d},a=n(e),r=n(t),l=n(i);return"#"+a+r+l}function pe(s,e=1){return Number(s.toFixed(e))}exports.totalThreeObjects=0;const ri=()=>{exports.totalThreeObjects=0},At=s=>{if(!s)return;let e=s.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),s.parent!==null&&s.parent.uuid.length>0&&(e=`${s.parent.uuid}.${e}`),s.uuid=e,s.isMesh!==void 0){const t=s;if(Array.isArray(t.material))t.material.forEach((i,n)=>{i.uuid=`${e}.material.${n}`});else{const i=t.material;i.uuid=`${e}.material`}}s.children.forEach(t=>At(t))},Ys=s=>{s?.dispose()},rs=s=>{s&&(Array.isArray(s)?s.forEach(e=>e.dispose()):s.dispose())},Te=s=>{if(s){for(;s.children.length>0;){const e=s.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Te(e)}if(s.parent&&s.parent.remove(s),s.isMesh){const e=s;e.geometry?.dispose(),rs(e.material)}s.dispose!==void 0&&s.dispose()}};class ht{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 t=e.repeat.clone(),i=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 n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/n.width,r=this.renderToCanvas(e);this.context.drawImage(r,0,0,n.width*a,n.height*a)}}return e.repeat.copy(t),e.offset.copy(i),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new o.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new o.Scene,this.material=new o.MeshBasicMaterial;const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new o.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new o.Float32BufferAttribute([0,0,2,0,0,2],2));const i=new o.Mesh(t,this.material);this.scene.add(i)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,i=e.colorSpace;this.renderer.outputColorSpace=o.LinearSRGBColorSpace,e.colorSpace=o.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=i}return this.renderer.domElement}}class Gs{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,i=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=i,i?(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,t){this.components.set(e,t)}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")}}var R=(s=>(s.CUSTOM="ToolEvents::custom",s.SELECT_DROPDOWN="ToolEvents::selectDropdown",s.DRAG_UPDATE="ToolEvents::dragUpdate",s.ADD_SCENE="ToolEvents::addScene",s.REFRESH_SCENE="ToolEvents::refreshScene",s.REMOVE_SCENE="ToolEvents::removeScene",s.SET_SCENE="ToolEvents::setScene",s.GET_OBJECT="ToolEvents::getObject",s.SET_OBJECT="ToolEvents::setObject",s.UPDATE_OBJECT="ToolEvents::updateObject",s.CREATE_TEXTURE="ToolEvents::createTexture",s.REQUEST_METHOD="ToolEvents::requestMethod",s.ADD_CAMERA="ToolEvents::addCamera",s.REMOVE_CAMERA="ToolEvents::removeCamera",s.ADD_GROUP="ToolEvents::addGroup",s.REMOVE_GROUP="ToolEvents::removeGroup",s.ADD_SPLINE="ToolEvents::addSpline",s))(R||{});const D=new o.EventDispatcher;class Lt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,i){}handleEditor(e,t,i){}}class Zs extends Lt{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,i){switch(i.event){case"selectComponent":D.dispatchEvent({type:R.SELECT_DROPDOWN,value:i.data});break;case"draggableListUpdate":D.dispatchEvent({type:R.DRAG_UPDATE,value:i.data});break}}}function Ws(s,e,t){if(s.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,d="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":d="setSheet",p={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}s.send({event:d,target:"app",data:p})})});let i=-1;const n=()=>{if(e.activeSheet!==void 0&&i!==e.activeSheet.sequence.position){i=e.activeSheet.sequence.position;const r=e.activeSheet;s.send({event:"updateTimeline",target:"app",data:{position:i,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else t.ui.hide()}function Xs(){const s=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=s?.children[1];e.style.justifyContent="left";const t=e.children[1];t.style.transform="translateX(10px)",t.removeChild(t.children[0]),t.removeChild(t.children[0]);const i=s?.children[3];i.style.top="0",i.style.right="300px"}class di extends Lt{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,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const i=this.getSheetInstance(e,t);let n=this.sheets.get(i);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(i,n)),n}playSheet(e,t,i){return this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}}),new Promise(n=>{const a=t!==void 0?{...t}:{};a.rafDriver=di.rafDriver,this.sheet(e,i)?.sequence.play(a).then(r=>n(r))})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,i)=>{i.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,i,n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.sheet(e,a);if(r===void 0)return;const h=`${this.getSheetInstance(e,a)}_${t}`;let d=this.sheetObjects.get(h);d!==void 0?d=r.object(t,{...i,...d.value},{reconfigure:!0}):d=r.object(t,i),this.sheetObjects.set(h,d),this.sheetObjectCBs.set(h,n!==void 0?n:hi);const p=d.onValuesChange(m=>{if(this.app.editor){for(const y in m){const x=m[y];typeof x=="object"&&ns(x)&&(m[y]={r:x.r,g:x.g,b:x.b,a:x.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:m}})}const g=this.sheetObjectCBs.get(h);g!==void 0&&g(m)});return this.sheetObjectUnsubscribe.set(h,p),d}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,i=e.address.objectKey;this.sheets.get(t)?.detachObject(i);const a=`${t}_${i}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e,t,i){const n=t;let a;switch(i.event){case"setSheet":a=n.sheets.get(i.data.sheet),a!==void 0&&(n.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=n.sheetObjects.get(`${i.data.sheet}_${i.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=n.sheets.get(i.data.sheet),a!==void 0&&a.sequence.pause(),a=n.sheetObjectCBs.get(i.data.sheetObject),a!==void 0&&a(i.data.values);break;case"updateTimeline":a=n.sheets.get(i.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=i.data.position);break}}handleEditor(e,t,i){if(e.editor){const n=t;switch(i.event){case"playSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.play(i.data.value);break;case"pauseSheet":n.sheet(i.data.sheet,i.data.instance)?.sequence.pause();break}}}handleEditorApp(e,t){if(e.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,d="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":d="setSheet",p={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":d="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:d,target:"app",data:p})})});let i=-1;const n=()=>{if(t.activeSheet!==void 0&&i!==t.activeSheet.sequence.position){i=t.activeSheet.sequence.position;const r=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:i,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else this.studio?.ui.hide()}}function Qs(s){if(s.name==="cameras")return"camera";if(s.name==="interactive")return"interactive";if(s.name==="lights")return"light";if(s.name==="ui")return"ui";if(s.name==="utils")return"utils";const e=s.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function Xe(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(Xe(t))}),e}function $s(s){const e={};for(const t in s){const i=s[t].value;e[t]={value:i},i===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:i!==void 0&&i.isTexture&&(e[t].value={src:i.image.src,offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]})}return e}function qs(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function He(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||qs(t))continue;const i=typeof s[t],n=s[t];switch(i){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:ht.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=$s(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.clearcoat!==void 0&&(e.clearcoat=s.clearcoat),s.iridescence!==void 0&&(e.iridescence=s.iridescence),s.dispersion!==void 0&&(e.dispersion=s.dispersion),s.sheen!==void 0&&(e.sheen=s.sheen),s.transmission!==void 0&&(e.transmission=s.transmission),s.transmission!==void 0&&(e.transmission=s.transmission),e}function Gt(s){s.updateMatrix();const e={name:s.name,type:s.type,uuid:s.uuid,visible:s.visible,matrix:s.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};s.animations.forEach(i=>{e.animations.push({name:i.name,duration:i.duration,blendMode:i.blendMode})});const t=s.type.toLowerCase();if(t.search("mesh")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(i.material)}else if(t.search("points")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(i.material)}else if(t.search("line")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(i.material)}else t.search("camera")>-1?s.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:s.fov,zoom:s.zoom,near:s.near,far:s.far,focus:s.focus,aspect:s.aspect,filmGauge:s.filmGauge,filmOffset:s.filmOffset}:s.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:s.zoom,near:s.near,far:s.far,left:s.left,right:s.right,top:s.top,bottom:s.bottom}):t.search("light")>-1&&(e.lightInfo={color:s.color,intensity:s.intensity,decay:s.decay,distance:s.distance,angle:s.angle,penumbra:s.penumbra,groundColor:s.groundColor,width:s.width,height:s.height});return e}function Ks(s,e){const t=e.split(".");switch(t.length){case 1:return s[t[0]];case 2:return s[t[0]][t[1]];case 3:return s[t[0]][t[1]][t[2]];case 4:return s[t[0]][t[1]][t[2]][t[3]];case 5:return s[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return s[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function Js(s,e){for(const t in e)s[t]=e[t]}function q(s,e,t){if(s===void 0)return;const i=e.split("."),n=i.length;if(typeof t!="object")switch(n){case 1:s[i[0]]=t;break;case 2:s[i[0]][i[1]]=t;break;case 3:s[i[0]][i[1]][i[2]]=t;break;case 4:s[i[0]][i[1]][i[2]][i[3]]=t;break;case 5:s[i[0]][i[1]][i[2]][i[3]][i[4]]=t;break}else{let r;switch(n){case 1:r=s[i[0]];break;case 2:r=s[i[0]][i[1]];break;case 3:r=s[i[0]][i[1]][i[2]];break;case 4:r=s[i[0]][i[1]][i[2]][i[3]];break;case 5:r=s[i[0]][i[1]][i[2]][i[3]][i[4]];break}r!=null&&Js(r,t)}}function as(s){return new Promise((e,t)=>{const i=new Image;i.onload=()=>{const n=new o.Texture(i);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},i.onerror=t,i.src=s})}class en extends Lt{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Te(e)}),this.scenes.clear(),this.scene&&Te(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(ht.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(ht.renderer=this.renderer);const t=Gt(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,i,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:i,subitem:n}})}updateObject(e,t,i){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:i}})}createTexture(e,t,i){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:i}})}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,t,i){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:i})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;ri(),At(e);const t=Xe(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const i=Xe(t);this.app.send({event:"refreshScene",target:"app",data:i})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=Xe(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((i,n)=>{e.search(n)>-1&&(t=i)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(ht.renderer=this.renderer),ri(),At(e);const t=Xe(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,i){const n=t;switch(i.event){case"getObject":D.dispatchEvent({type:R.GET_OBJECT,value:i.data});break;case"updateObject":D.dispatchEvent({type:R.UPDATE_OBJECT,value:i.data});break;case"createTexture":D.dispatchEvent({type:R.CREATE_TEXTURE,value:i.data});break;case"requestMethod":D.dispatchEvent({type:R.REQUEST_METHOD,value:i.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:Xe(n.scenes.get(i.data.name))});break}if(i.event==="updateGroup"){const a=JSON.parse(i.data);n.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,t,i){switch(i.event){case"setObject":D.dispatchEvent({type:R.SET_OBJECT,value:i.data});break;case"addScene":D.dispatchEvent({type:R.ADD_SCENE,value:i.data});break;case"refreshScene":D.dispatchEvent({type:R.REFRESH_SCENE,value:i.data});break;case"removeScene":D.dispatchEvent({type:R.REMOVE_SCENE,value:i.data});break;case"setScene":D.dispatchEvent({type:R.SET_SCENE,value:i.data});break;case"addCamera":D.dispatchEvent({type:R.ADD_CAMERA,value:i.data});break;case"removeCamera":D.dispatchEvent({type:R.REMOVE_CAMERA,value:i.data});break;case"addGroup":D.dispatchEvent({type:R.ADD_GROUP,value:i.data});break;case"removeGroup":D.dispatchEvent({type:R.REMOVE_GROUP,value:i.data});break;case"addSpline":D.dispatchEvent({type:R.ADD_SPLINE,value:i.data});break}}addRT(e,t){const i=new o.WebGLRenderTarget(32,32,t);i.texture.name=e,this.renderTargets.set(e,i)}resize(e,t){const i=this.dpr;this.renderTargets.forEach(n=>{n.setSize(e*i,t*i)}),this.renderer?.setSize(e,t)}set dpr(e){this.renderer?.setPixelRatio(Oe(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}var ai={exports:{}},qe={};/**
|
2
2
|
* @license React
|
3
3
|
* react-jsx-runtime.production.min.js
|
4
4
|
*
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var
|
9
|
+
*/var Pi;function tn(){if(Pi)return qe;Pi=1;var s=w,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,n=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function r(l,h,d){var p,m={},g=null,y=null;d!==void 0&&(g=""+d),h.key!==void 0&&(g=""+h.key),h.ref!==void 0&&(y=h.ref);for(p in h)i.call(h,p)&&!a.hasOwnProperty(p)&&(m[p]=h[p]);if(l&&l.defaultProps)for(p in h=l.defaultProps,h)m[p]===void 0&&(m[p]=h[p]);return{$$typeof:e,type:l,key:g,ref:y,props:m,_owner:n.current}}return qe.Fragment=t,qe.jsx=r,qe.jsxs=r,qe}var Ke={};/**
|
10
10
|
* @license React
|
11
11
|
* react-jsx-runtime.development.js
|
12
12
|
*
|
@@ -14,25 +14,25 @@
|
|
14
14
|
*
|
15
15
|
* This source code is licensed under the MIT license found in the
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
17
|
-
*/var
|
18
|
-
`+
|
17
|
+
*/var Ri;function sn(){return Ri||(Ri=1,process.env.NODE_ENV!=="production"&&function(){var s=w,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),x=Symbol.iterator,M="@@iterator";function T(c){if(c===null||typeof c!="object")return null;var b=x&&c[x]||c[M];return typeof b=="function"?b:null}var _=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(c){{for(var b=arguments.length,S=new Array(b>1?b-1:0),I=1;I<b;I++)S[I-1]=arguments[I];C("error",c,S)}}function C(c,b,S){{var I=_.ReactDebugCurrentFrame,N=I.getStackAddendum();N!==""&&(b+="%s",S=S.concat([N]));var B=S.map(function(U){return String(U)});B.unshift("Warning: "+b),Function.prototype.apply.call(console[c],console,B)}}var E=!1,P=!1,O=!1,j=!1,W=!1,he;he=Symbol.for("react.module.reference");function Se(c){return!!(typeof c=="string"||typeof c=="function"||c===i||c===a||W||c===n||c===d||c===p||j||c===y||E||P||O||typeof c=="object"&&c!==null&&(c.$$typeof===g||c.$$typeof===m||c.$$typeof===r||c.$$typeof===l||c.$$typeof===h||c.$$typeof===he||c.getModuleId!==void 0))}function Qe(c,b,S){var I=c.displayName;if(I)return I;var N=b.displayName||b.name||"";return N!==""?S+"("+N+")":S}function Fe(c){return c.displayName||"Context"}function ce(c){if(c==null)return null;if(typeof c.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case i:return"Fragment";case t:return"Portal";case a:return"Profiler";case n:return"StrictMode";case d:return"Suspense";case p:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case l:var b=c;return Fe(b)+".Consumer";case r:var S=c;return Fe(S._context)+".Provider";case h:return Qe(c,c.render,"ForwardRef");case m:var I=c.displayName||null;return I!==null?I:ce(c.type)||"Memo";case g:{var N=c,B=N._payload,U=N._init;try{return ce(U(B))}catch{return null}}}return null}var J=Object.assign,X=0,Me,ne,Ee,te,Pe,Re,De;function pt(){}pt.__reactDisabledLog=!0;function mt(){{if(X===0){Me=console.log,ne=console.info,Ee=console.warn,te=console.error,Pe=console.group,Re=console.groupCollapsed,De=console.groupEnd;var c={configurable:!0,enumerable:!0,value:pt,writable:!0};Object.defineProperties(console,{info:c,log:c,warn:c,error:c,group:c,groupCollapsed:c,groupEnd:c})}X++}}function ys(){{if(X--,X===0){var c={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},c,{value:Me}),info:J({},c,{value:ne}),warn:J({},c,{value:Ee}),error:J({},c,{value:te}),group:J({},c,{value:Pe}),groupCollapsed:J({},c,{value:Re}),groupEnd:J({},c,{value:De})})}X<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var jt=_.ReactCurrentDispatcher,Ft;function ft(c,b,S){{if(Ft===void 0)try{throw Error()}catch(N){var I=N.stack.trim().match(/\n( *(at )?)/);Ft=I&&I[1]||""}return`
|
18
|
+
`+Ft+c}}var Nt=!1,_t;{var vs=typeof WeakMap=="function"?WeakMap:Map;_t=new vs}function fi(c,b){if(!c||Nt)return"";{var S=_t.get(c);if(S!==void 0)return S}var I;Nt=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var B;B=jt.current,jt.current=null,mt();try{if(b){var U=function(){throw Error()};if(Object.defineProperty(U.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(U,[])}catch(Ce){I=Ce}Reflect.construct(c,[],U)}else{try{U.call()}catch(Ce){I=Ce}c.call(U.prototype)}}else{try{throw Error()}catch(Ce){I=Ce}c()}}catch(Ce){if(Ce&&I&&typeof Ce.stack=="string"){for(var k=Ce.stack.split(`
|
19
19
|
`),se=I.stack.split(`
|
20
20
|
`),Q=k.length-1,K=se.length-1;Q>=1&&K>=0&&k[Q]!==se[K];)K--;for(;Q>=1&&K>=0;Q--,K--)if(k[Q]!==se[K]){if(Q!==1||K!==1)do if(Q--,K--,K<0||k[Q]!==se[K]){var de=`
|
21
|
-
`+k[Q].replace(" at new "," at ");return c.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",c.displayName)),typeof c=="function"&&_t.set(c,de),de}while(Q>=1&&K>=0);break}}}finally{
|
21
|
+
`+k[Q].replace(" at new "," at ");return c.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",c.displayName)),typeof c=="function"&&_t.set(c,de),de}while(Q>=1&&K>=0);break}}}finally{Nt=!1,jt.current=B,ys(),Error.prepareStackTrace=N}var ze=c?c.displayName||c.name:"",Mi=ze?ft(ze):"";return typeof c=="function"&&_t.set(c,Mi),Mi}function bs(c,b,S){return fi(c,!1)}function Es(c){var b=c.prototype;return!!(b&&b.isReactComponent)}function gt(c,b,S){if(c==null)return"";if(typeof c=="function")return fi(c,Es(c));if(typeof c=="string")return ft(c);switch(c){case d:return ft("Suspense");case p:return ft("SuspenseList")}if(typeof c=="object")switch(c.$$typeof){case h:return bs(c.render);case m:return gt(c.type,b,S);case g:{var I=c,N=I._payload,B=I._init;try{return gt(B(N),b,S)}catch{}}}return""}var yt=Object.prototype.hasOwnProperty,_i={},gi=_.ReactDebugCurrentFrame;function vt(c){if(c){var b=c._owner,S=gt(c.type,c._source,b?b.type:null);gi.setExtraStackFrame(S)}else gi.setExtraStackFrame(null)}function Cs(c,b,S,I,N){{var B=Function.call.bind(yt);for(var U in c)if(B(c,U)){var k=void 0;try{if(typeof c[U]!="function"){var se=Error((I||"React class")+": "+S+" type `"+U+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[U]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw se.name="Invariant Violation",se}k=c[U](b,U,I,S,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){k=Q}k&&!(k instanceof Error)&&(vt(N),v("%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).",I||"React class",S,U,typeof k),vt(null)),k instanceof Error&&!(k.message in _i)&&(_i[k.message]=!0,vt(N),v("Failed %s type: %s",S,k.message),vt(null))}}}var Ss=Array.isArray;function zt(c){return Ss(c)}function ws(c){{var b=typeof Symbol=="function"&&Symbol.toStringTag,S=b&&c[Symbol.toStringTag]||c.constructor.name||"Object";return S}}function xs(c){try{return yi(c),!1}catch{return!0}}function yi(c){return""+c}function vi(c){if(xs(c))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ws(c)),yi(c)}var $e=_.ReactCurrentOwner,Os={key:!0,ref:!0,__self:!0,__source:!0},bi,Ei,Ht;Ht={};function Ts(c){if(yt.call(c,"ref")){var b=Object.getOwnPropertyDescriptor(c,"ref").get;if(b&&b.isReactWarning)return!1}return c.ref!==void 0}function Ms(c){if(yt.call(c,"key")){var b=Object.getOwnPropertyDescriptor(c,"key").get;if(b&&b.isReactWarning)return!1}return c.key!==void 0}function Ps(c,b){if(typeof c.ref=="string"&&$e.current&&b&&$e.current.stateNode!==b){var S=ce($e.current.type);Ht[S]||(v('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',ce($e.current.type),c.ref),Ht[S]=!0)}}function Rs(c,b){{var S=function(){bi||(bi=!0,v("%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))};S.isReactWarning=!0,Object.defineProperty(c,"key",{get:S,configurable:!0})}}function Ds(c,b){{var S=function(){Ei||(Ei=!0,v("%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))};S.isReactWarning=!0,Object.defineProperty(c,"ref",{get:S,configurable:!0})}}var As=function(c,b,S,I,N,B,U){var k={$$typeof:e,type:c,key:b,ref:S,props:U,_owner:B};return k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(k,"_self",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function Is(c,b,S,I,N){{var B,U={},k=null,se=null;S!==void 0&&(vi(S),k=""+S),Ms(b)&&(vi(b.key),k=""+b.key),Ts(b)&&(se=b.ref,Ps(b,N));for(B in b)yt.call(b,B)&&!Os.hasOwnProperty(B)&&(U[B]=b[B]);if(c&&c.defaultProps){var Q=c.defaultProps;for(B in Q)U[B]===void 0&&(U[B]=Q[B])}if(k||se){var K=typeof c=="function"?c.displayName||c.name||"Unknown":c;k&&Rs(U,K),se&&Ds(U,K)}return As(c,k,se,N,I,$e.current,U)}}var Bt=_.ReactCurrentOwner,Ci=_.ReactDebugCurrentFrame;function Ne(c){if(c){var b=c._owner,S=gt(c.type,c._source,b?b.type:null);Ci.setExtraStackFrame(S)}else Ci.setExtraStackFrame(null)}var Vt;Vt=!1;function Yt(c){return typeof c=="object"&&c!==null&&c.$$typeof===e}function Si(){{if(Bt.current){var c=ce(Bt.current.type);if(c)return`
|
22
22
|
|
23
|
-
Check the render method of \``+c+"`."}return""}}function
|
23
|
+
Check the render method of \``+c+"`."}return""}}function Ls(c){{if(c!==void 0){var b=c.fileName.replace(/^.*[\\\/]/,""),S=c.lineNumber;return`
|
24
24
|
|
25
|
-
Check your code at `+b+":"+S+"."}return""}}var
|
25
|
+
Check your code at `+b+":"+S+"."}return""}}var wi={};function ks(c){{var b=Si();if(!b){var S=typeof c=="string"?c:c.displayName||c.name;S&&(b=`
|
26
26
|
|
27
|
-
Check the top-level render call using <`+S+">.")}return b}}function
|
27
|
+
Check the top-level render call using <`+S+">.")}return b}}function xi(c,b){{if(!c._store||c._store.validated||c.key!=null)return;c._store.validated=!0;var S=ks(b);if(wi[S])return;wi[S]=!0;var I="";c&&c._owner&&c._owner!==Bt.current&&(I=" It was passed a child from "+ce(c._owner.type)+"."),Ne(c),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',S,I),Ne(null)}}function Oi(c,b){{if(typeof c!="object")return;if(zt(c))for(var S=0;S<c.length;S++){var I=c[S];Yt(I)&&xi(I,b)}else if(Yt(c))c._store&&(c._store.validated=!0);else if(c){var N=T(c);if(typeof N=="function"&&N!==c.entries)for(var B=N.call(c),U;!(U=B.next()).done;)Yt(U.value)&&xi(U.value,b)}}}function Us(c){{var b=c.type;if(b==null||typeof b=="string")return;var S;if(typeof b=="function")S=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===h||b.$$typeof===m))S=b.propTypes;else return;if(S){var I=ce(b);Cs(S,c.props,"prop",I,c)}else if(b.PropTypes!==void 0&&!Vt){Vt=!0;var N=ce(b);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function js(c){{for(var b=Object.keys(c.props),S=0;S<b.length;S++){var I=b[S];if(I!=="children"&&I!=="key"){Ne(c),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",I),Ne(null);break}}c.ref!==null&&(Ne(c),v("Invalid attribute `ref` supplied to `React.Fragment`."),Ne(null))}}function Ti(c,b,S,I,N,B){{var U=Se(c);if(!U){var k="";(c===void 0||typeof c=="object"&&c!==null&&Object.keys(c).length===0)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var se=Ls(N);se?k+=se:k+=Si();var Q;c===null?Q="null":zt(c)?Q="array":c!==void 0&&c.$$typeof===e?(Q="<"+(ce(c.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof c,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,k)}var K=Is(c,b,S,N,B);if(K==null)return K;if(U){var de=b.children;if(de!==void 0)if(I)if(zt(de)){for(var ze=0;ze<de.length;ze++)Oi(de[ze],c);Object.freeze&&Object.freeze(de)}else v("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 Oi(de,c)}return c===i?js(K):Us(K),K}}function Fs(c,b,S){return Ti(c,b,S,!0)}function Ns(c,b,S){return Ti(c,b,S,!1)}var zs=Ns,Hs=Fs;Ke.Fragment=i,Ke.jsx=zs,Ke.jsxs=Hs}()),Ke}process.env.NODE_ENV==="production"?ai.exports=tn():ai.exports=sn();var u=ai.exports;function ui(s){return s.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:s.title}}):u.jsx("button",{children:s.title})}const nn=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),rn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
|
28
28
|
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
|
29
|
-
C11,8.22,10.74,8,10.43,8z`})});function as(s){return u.jsx(es.Reorder.Item,{value:s.title,children:u.jsxs("div",{children:[nn,u.jsx("span",{children:s.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{s.onDelete(s.index)},children:sn})]})},s.title)}function os(s){const[e,t]=w.useState(!1),[i,n]=w.useState(s.options),a=h=>{s.onDragComplete(h),n(h)},r=h=>{const p=[...i];p.splice(h,1),a(p)},l=[];i.forEach((h,p)=>{l.push(u.jsx(as,{index:p,title:h,onDelete:r},h))});let d="dropdown draggable";return s.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(hi,{title:s.title}),u.jsx(es.Reorder.Group,{axis:"y",values:i,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function ls(s){const[e,t]=w.useState(!1),i=[];s.options.map((a,r)=>{s.onSelect!==void 0&&(a.onSelect=s.onSelect),i.push(u.jsx(cs,{option:a},r))});let n="dropdown";return s.subdropdown&&(n+=" subdropdown"),u.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(hi,{title:s.title}),u.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:i})]})}function cs(s){const{option:e}=s,[t,i]=w.useState("");let n;switch(e.type){case"draggable":n=u.jsx(os,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=u.jsx(ls,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=u.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?i(e.title):i(""))},children:e.title});break}return u.jsx("li",{className:t===e.title?"selected":"",children:n},is())}function rn(s,e,t){function i(a){switch(e.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":D.dispatchEvent({type:R.CUSTOM,value:a.data});break}}function n(a){switch(t.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":D.dispatchEvent({type:R.CUSTOM,value:a.data});break}}s.listen=a=>{a.target==="editor"?n(a):i(a)}}function ut(s){const[e,t]=w.useState(s.open!==void 0?s.open:!0),i=!e||s.children===void 0,n=()=>{D.dispatchEvent({type:R.REMOVE_SCENE,value:s.scene})};return u.jsxs("div",{className:`accordion ${i?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;s.onToggle!==void 0&&s.onToggle(a),t(a)},children:[u.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:dt(s.label)})]}),s.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:s.onRefresh}),u.jsx("button",{className:"remove",onClick:n})]}):null,s.button,u.jsx("div",{className:e?"open":"",children:u.jsx("div",{children:s.children})},Math.random())]})}function di(s){const e=w.useRef(null),[t,i]=w.useState(!1),n=s.child!==void 0&&s.child.children.length>0,a=[];return s.child!==void 0&&s.child.children.length>0&&s.child.children.map((r,l)=>{a.push(u.jsx(di,{child:r,three:s.three},l))}),w.useEffect(()=>{if(s.child){const r=s.three.getScene(s.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),u.jsx(u.Fragment,{children:s.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[n?u.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{i(!t)}}):null,u.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{s.child!==void 0&&(s.three.getObject(s.child.uuid),t||i(!0))},children:s.child.name.length>0?`${s.child.name} (${s.child.type})`:`${s.child.type}::${s.child.uuid}`}),u.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(s.child){const r=s.three.getScene(s.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.child.uuid);if(l!==void 0){const d="visible",h=!l.visible;e.current.style.opacity=h?"1":"0.25",s.three.updateObject(s.child.uuid,d,h),q(l,d,h)}}}}}),u.jsx("div",{className:`icon ${Xs(s.child)}`})]}),u.jsx("div",{className:t?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function ai(s){const e=[];return s.child?.children.map((t,i)=>{e.push(u.jsx(di,{child:t,scene:s.scene,three:s.three},i))}),u.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function an(s){const[e,t]=w.useState(s.defaultValue);return w.useEffect(()=>{let i=!1,n=-1,a=0,r=s.defaultValue;const l=g=>{i=!0,a=Number(s.input.current?.value),n=g.clientX,document.addEventListener("mouseup",h,!1),document.addEventListener("mousemove",d,!1),document.addEventListener("contextmenu",h,!1)},d=g=>{if(!i)return;const y=s.step!==void 0?s.step:1,x=(g.clientX-n)*y;r=Number((a+x).toFixed(4)),s.min!==void 0&&(r=Math.max(r,s.min)),s.max!==void 0&&(r=Math.min(r,s.max)),s.onChange!==void 0&&s.onChange(r),t(r)},h=()=>{i=!1,document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",d),document.removeEventListener("contextmenu",h)},p=g=>{const y=Number(g.target.value);t(y)},f=g=>{const y=Number(g.target.value);s.onChange!==void 0&&s.onChange(y),t(y)};return s.input.current?.addEventListener("input",p),s.label.current?.addEventListener("mousedown",l,!1),s.sliderRef!==void 0&&s.sliderRef.current?.addEventListener("input",f),()=>{s.input.current?.removeEventListener("input",p),s.label.current?.removeEventListener("mousedown",l),s.sliderRef!==void 0&&s.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",d),document.removeEventListener("contextmenu",h)}},[]),e}function Ue(s){const e=w.useRef(null),t=w.useRef(null),i=an({label:s.labelRef,input:e,sliderRef:t,defaultValue:s.value,min:s.min,max:s.max,step:s.step,onChange:n=>{s.onChange!==void 0&&s.onChange(s.prop,n)}});return u.jsxs(u.Fragment,{children:[s.type==="number"&&u.jsx("input",{alt:s.alt,className:s.className,ref:e,type:"number",value:i,min:s.min,max:s.max,step:s.step,disabled:s.disabled,onChange:n=>{const a=Number(n.target.value);s.onChange!==void 0&&s.onChange(s.prop,a)}}),s.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:i.toString(),disabled:s.disabled,ref:e,className:"min",onChange:n=>{const a=Number(n.target.value);s.onChange!==void 0&&s.onChange(s.prop,a)}}),u.jsx("input",{disabled:s.disabled,type:"range",value:i,min:s.min,max:s.max,step:s.step,ref:t,onChange:li})]})]})}function on(s){const e=w.useRef(null),t=w.useRef(null),i=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l,d]=w.useState(s.value),[h,p]=w.useState({min:Math.min(s.min,Math.min(s.value.x,s.value.y)),max:Math.max(s.max,Math.max(s.value.x,s.value.y))}),[f,g]=w.useState(!1);function y(){f||(window.addEventListener("mousemove",M),window.addEventListener("mouseup",x),window.addEventListener("mouseup",x),g(!0))}function x(){window.removeEventListener("mousemove",M),window.removeEventListener("mouseup",x),g(!1)}function M(E){const P=a.current.getBoundingClientRect(),O=xe(0,99,E.clientX-P.left)/99,j=xe(0,99,E.clientY-P.top)/99,W=Xe(Rt(h.min,h.max,O),3),he=Xe(Rt(h.min,h.max,j),3);s.onChange({target:{value:{x:W,y:he}}}),d({x:W,y:he})}function T(E){let P=l.x,O=l.y;E.target===e.current?P=Number(E.target.value):O=Number(E.target.value),d({x:P,y:O})}function _(){const E=Number(i.current.value);p({min:E,max:h.max}),(l.x<E||l.y<E)&&d({x:xe(E,h.max,l.x),y:xe(E,h.max,l.y)})}function v(){const E=Number(n.current.value);p({min:h.min,max:E}),(l.x>E||l.y>E)&&d({x:xe(h.min,E,l.x),y:xe(h.min,E,l.y)})}w.useEffect(()=>{const E=ii(h.min,h.max,l.x),P=ii(h.min,h.max,l.y);r.current.style.left=`${E*100}%`,r.current.style.top=`${P*100}%`},[h,l]);const C=s.step!==void 0?s.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"X:"}),u.jsx("input",{ref:e,type:"number",value:l.x,min:h.min,max:h.max,step:C,onChange:T})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:t,type:"number",value:l.y,min:h.min,max:h.max,step:C,onChange:T})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:i,type:"number",value:h.min,step:C,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:n,type:"number",value:h.max,step:C,onChange:v})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:x,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:r})]})]})}function Pi(s){const e=s.value.x!==void 0&&s.value.y!==void 0&&s.value.z!==void 0,t=s.value.isEuler!==void 0,i=s.value.elements!==void 0,n=s.step!==void 0?s.step:.01,a=[];if(e){const r=w.useMemo(()=>s.value,[]),l=(h,p)=>{r[h]=p,s.onChange({target:{value:r}})};["x","y","z"].forEach(h=>{const p=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:p,children:h.toUpperCase()}),u.jsx(Ue,{value:r[h],type:"number",prop:h,step:n,labelRef:p,onChange:l})]},h))})}else if(t){const r=w.useMemo(()=>s.value,[]),l=(h,p)=>{r[h]=p,s.onChange({target:{value:r}})};["_x","_y","_z"].forEach(h=>{const p=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:p,children:h.substring(1).toUpperCase()}),u.jsx(Ue,{value:r[h],type:"number",prop:h,step:n,labelRef:p,onChange:l})]},h))})}else if(i){const r=w.useMemo(()=>s.value,[]),l=(d,h)=>{const p=Number(d);r.elements[p]=h,s.onChange({target:{value:r}})};for(let d=0;d<9;d++){const h=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:d+1}),u.jsx(Ue,{value:r.elements[d],type:"number",prop:d.toString(),step:n,labelRef:h,onChange:l})]},d.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function ln(s){const e=s.value.x!==void 0,t=s.step!==void 0?s.step:.01,i=[];if(e){const n=w.useMemo(()=>s.value,[]),a=(l,d)=>{n[l]=d,s.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const d=w.useRef(null);i.push(u.jsxs("div",{children:[u.jsx("label",{ref:d,children:l.toUpperCase()}),u.jsx(Ue,{value:n.x,type:"number",prop:l,step:t,labelRef:d,onChange:a})]},l))})}else{const n=w.useMemo(()=>s.value,[]),a=(r,l)=>{const d=Number(r);n.elements[d]=l,s.onChange({target:{value:n}})};for(let r=0;r<16;r++){const l=w.useRef(null);i.push(u.jsxs("div",{children:[u.jsx("label",{ref:l,children:r+1}),u.jsx(Ue,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return u.jsx("div",{className:"grid4",children:i})}function cn(s){return!(s==="defaultAttributeValues"||s==="forceSinglePass"||s==="linecap"||s==="linejoin"||s==="linewidth"||s==="normalMapType"||s==="precision"||s==="shadowSide"||s==="uniformsGroups"||s==="uniformsNeedUpdate"||s==="userData"||s==="version"||s==="wireframeLinecap"||s==="wireframeLinejoin"||s==="wireframeLinewidth"||s.slice(0,4)==="clip"||s.slice(0,7)==="polygon"||s.slice(0,7)==="stencil"||s.slice(0,2)==="is")}function hn(s){switch(s){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 s}function Lt(s){switch(s){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 s}function hs(s){const e=s.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 dn(){const s=document.createElement("input");return s.type="file",new Promise((e,t)=>{s.addEventListener("change",function(){if(s.files===null)t();else{const i=s.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(i)}}),s.click()})}const un=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],pn=[{title:"No Blending",value:o.NoBlending},{title:"Normal",value:o.NormalBlending},{title:"Additive",value:o.AdditiveBlending},{title:"Subtractive",value:o.SubtractiveBlending},{title:"Multiply",value:o.MultiplyBlending},{title:"Custom",value:o.CustomBlending}],mn=[{title:"Add",value:o.AddEquation},{title:"Subtract",value:o.SubtractEquation},{title:"Reverse Subtract",value:o.ReverseSubtractEquation},{title:"Min",value:o.MinEquation},{title:"Max",value:o.MaxEquation}],fn=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:o.SrcAlphaSaturateFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}],_n=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function Je(s,e){s.needsUpdate=!0,s.type="option",s.options=e}function gn(s,e,t,i){return{type:"boolean",title:Lt(s),prop:s,value:e,needsUpdate:!0,onChange:(n,a)=>{i.updateObject(t.uuid,`material.${s}`,a),i.updateObject(t.uuid,"material.needsUpdate",!0);const r=i.getScene(t.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",t.uuid);q(l,`material.${s}`,a)}}}}function yn(s,e,t,i){const n={type:"number",title:Lt(s),prop:s,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{i.updateObject(t.uuid,`material.${s}`,r),i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);q(d,`material.${s}`,r)}}};switch(s){case"blending":Je(n,pn);break;case"blendDst":Je(n,_n);break;case"blendEquation":Je(n,mn);break;case"blendSrc":Je(n,fn);break;case"side":Je(n,un);break}return hs(s)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function vn(s,e,t,i){const n={type:"string",title:Lt(s),prop:s,value:e,needsUpdate:!0,onChange:(r,l)=>{i.updateObject(t.uuid,`material.${s}`,l),i.updateObject(t.uuid,"material.needsUpdate",!0);const d=i.getScene(t.uuid);if(d!==null){const h=d.getObjectByProperty("uuid",t.uuid);q(h,`material.${s}`,l)}},onKeyDown:r=>{}};return(s==="vertexShader"||s==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(r,l)=>{n.latest=l,i.updateObject(t.uuid,`material.${s}`,l);const d=i.getScene(t.uuid);if(d!==null){const h=d.getObjectByProperty("uuid",t.uuid);q(h,`material.${s}`,l)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);q(d,"material.needsUpdate",!0)}}}),n}function bn(s){return s.x!==void 0&&s.y!==void 0&&s.z===void 0}function En(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w===void 0}function Cn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w!==void 0}function oi(s){s.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function ot(s,e,t,i,n="",a=!1){const r=Lt(s).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${s}`:s,d=typeof e;if(d==="boolean"||d==="string")return{title:r,prop:l,type:d,value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(d==="number"){const h={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(p,f)=>{i.updateObject(t.uuid,`material.${l}`,f);const g=i.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,f)}}};return hs(r)&&(h.type="range",h.min=0,h.max=1),h}else{if(e.isColor)return{title:r,prop:l,type:"color",value:e,disabled:a,onChange:(h,p)=>{const f=new o.Color(p);i.updateObject(t.uuid,`material.${l}`,f);const g=i.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,f)}}};if(Array.isArray(e)){const h=[];for(const p in e){const f=e[p],g=`[${p.toString()}]`;if(f.value!==void 0){const y=ot(`${g}.value`,f.value,t,i,l,a);y!==void 0&&h.push(y)}else{const y=ot(g,f,t,i,l,a);y!==void 0&&h.push(y)}}if(h.length>0)return oi(h),{title:r,items:h}}else{if(bn(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(En(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(Cn(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(h,p)=>{const f=hn(s),g=n.length>0?`${n}.${f}`:f;i.createTexture(t.uuid,`material.${g}`,p);const y=i.getScene(t.uuid);if(y!==null){const x=y.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const M=T=>{const _=x.material,v=g.split(".");switch(v.length){case 1:_[v[0]]=T;break;case 2:_[v[0]][v[1]]=T;break;case 3:_[v[0]][v[1]][v[2]]=T;break;case 4:_[v[0]][v[1]][v[2]][v[3]]=T;break;case 5:_[v[0]][v[1]][v[2]][v[3]][v[4]]=T;break}_.needsUpdate=!0};p.src.length>0?rs(p.src).then(T=>{T.offset.set(p.offset[0],p.offset[1]),T.repeat.set(p.repeat[0],p.repeat[1]),M(T)}):M(null)}}}};if(e.elements!==void 0)return{title:r,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(h,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const f=i.getScene(t.uuid);if(f!==null){const g=f.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};{const h=[],p=s==="defines"||s==="extensions";try{for(const f in e){const g=e[f];if(g!==void 0)if(g.value!==void 0){const y=ot(`${f}.value`,g.value,t,i,l,p);y!==void 0&&h.push(y)}else{const y=ot(f,g,t,i,l,p);y!==void 0&&h.push(y)}}}catch{console.log("Issue cycling through material object:",s,e)}if(h.length>0)return oi(h),{title:r,items:h}}}}}function Ri(s,e,t){const i=[];for(const n in s){if(!cn(n))continue;const a=typeof s[n],r=s[n];if(a==="boolean")i.push(gn(n,r,e,t));else if(a==="number")i.push(yn(n,r,e,t));else if(a==="string")i.push(vn(n,r,e,t));else if(a==="object"){const l=ot(n,r,e,t);l!==void 0&&i.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return oi(i),i.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const a=n.getObjectByProperty("uuid",e.uuid);q(a,"material.needsUpdate",!0)}}}),i}function Sn(s,e){const t=s.material;if(Array.isArray(t)){const i=[],n=t.length;for(let a=0;a<n;a++)i.push(u.jsx(me,{title:`Material ${a}`,items:Ri(t[a],s,e)},`Material ${a}`));return u.jsx(u.Fragment,{children:i})}else return u.jsx(me,{title:"Material",items:Ri(t,s,e)})}const Di="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 wn(s){const e=s.step!==void 0?s.step:.01,t=w.useRef(null),i=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l]=w.useState(s.value),[d,h]=w.useState(s.value.offset[0]),[p,f]=w.useState(s.value.offset[1]),[g,y]=w.useState(s.value.repeat[0]),[x,M]=w.useState(s.value.repeat[1]);function T(v,C,E,P,O){if(s.onChange!==void 0){const j=s.prop!==void 0?s.prop:s.title;s.onChange(j,{src:v,offset:[C,E],repeat:[P,O]})}}function _(v){const C=t.current.src,E=v.target.value;switch(v.target){case i.current:h(E),T(C,E,p,g,x);break;case n.current:f(E),T(C,d,E,g,x);break;case a.current:y(E),T(C,d,p,E,x);break;case r.current:M(E),T(C,d,p,g,E);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:s.title,ref:t,onClick:()=>{dn().then(v=>{t.current.src=v,T(v,d,p,g,x)})},src:l.src.length>0?l.src:Di}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:i,type:"number",value:d,step:e,onChange:_}),u.jsx("input",{ref:n,type:"number",value:p,step:e,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:g,step:e,onChange:_}),u.jsx("input",{ref:r,type:"number",value:x,step:e,onChange:_})]}),u.jsx("button",{onClick:()=>{T("",d,p,g,x),t.current.src=Di},children:"Clear"})]})]})}function Mt(s){let e=s.value;e!==void 0&&(e.isColor!==void 0?e=si(s.value):s.type==="color"&&(e=si(new o.Color(s.value))));const[t,i]=w.useState(e),n=w.useRef(null),a=h=>{let p=h.target.value;if(s.type==="boolean")p=h.target.checked;else if(s.type==="option"&&(typeof s.value=="number"?p=Number(p):typeof s.value=="boolean"?p=!!p:typeof s.value=="object"&&(p=JSON.parse(p)),s.options!==void 0)){const f=s.options.length;for(let g=0;g<f&&s.options[g].value!==p;g++);}i(p),s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,p)},r={};s.disabled&&(r.opacity=.8);const l=s.type==="string"&&(t.length>100||t.search(`
|
30
|
-
`)>-1),d=l||s.type==="image"||s.type==="vector2";return u.jsxs("div",{className:`field ${d?"block":""}`,style:r,children:[s.type!=="button"&&u.jsx("label",{ref:n,children:dt(s.title)},"fieldLabel"),s.type==="string"&&!l&&u.jsx("input",{type:"text",disabled:s.disabled,onChange:a,value:t}),s.type==="string"&&l&&u.jsx("textarea",{cols:50,rows:10,disabled:s.disabled!==void 0?s.disabled:!0,onChange:a,onKeyDown:h=>{s.onKeyDown!==void 0&&s.onKeyDown(h)},value:t}),s.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:s.disabled,onChange:a,checked:t}),s.type==="number"&&u.jsx(Ue,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="range"&&u.jsx(Ue,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:s.disabled,className:"color"}),u.jsx("input",{type:"color",value:t,onChange:a,disabled:s.disabled})]}),s.type==="button"&&u.jsx("button",{disabled:s.disabled,onClick:()=>{s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,!0)},children:s.title}),s.type==="image"&&u.jsx(wn,{title:s.title,prop:s.prop,value:s.value,onChange:s.onChange}),s.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:a,disabled:s.disabled,defaultValue:s.value,children:s.options?.map((h,p)=>u.jsx("option",{value:h.value,children:dt(h.title)},p))})}),s.type==="vector2"&&u.jsx(on,{step:s.step,value:t,min:0,max:1,onChange:a}),s.type==="grid3"&&u.jsx(Pi,{step:s.step,value:t,onChange:a}),s.type==="grid4"&&u.jsx(ln,{step:s.step,value:t,onChange:a}),s.type==="euler"&&u.jsx(Pi,{step:s.step,value:t,onChange:a})]})}function xn(s){return"items"in s}class me extends w.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const i=w.createRef(),n=u.jsx(me,{ref:i,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),i}removeGroup(e){const t=this.subgroupNames.length;for(let i=0;i<t;i++){const n=this.subgroupNames[i];if(e===n){this.subgroupNames.splice(i,1),this.subgroupElements.splice(i,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(xn(t))e.push(u.jsx(me,{title:dt(t.title),items:t.items},Math.random()));else{const i=this.valueOverrides.get(t.title),n=i!==void 0?i:t.value;e.push(u.jsx(Mt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),u.jsx(ut,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class $ extends w.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},$.instance=this,D.addEventListener(R.ADD_GROUP,this.addGroup),D.addEventListener(R.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){D.removeEventListener(R.ADD_GROUP,this.addGroup),D.removeEventListener(R.REMOVE_GROUP,this.removeGroup)}render(){return u.jsx("div",{className:"customGroups",children:$.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),i=[];t.items.forEach(n=>{i.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),$.groups.push(u.jsx(me,{title:t.title,items:i},Math.random())),$.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,i=$.groupTitles.length;for(let n=0;n<i;n++)if(t===$.groupTitles[n]){$.groups.splice(n,1),$.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const i=w.createRef(),n=u.jsx(me,{ref:i,title:e.title,items:t},Math.random());return $.groups.push(n),$.groupsRefs.push(i),$.groupTitles.push(e.title),i}static removeEditorGroup(e){const t=$.groupTitles.length;console.log("removeEditorGroup:",e,$.groupTitles);for(let i=0;i<t;i++)if(e===$.groupTitles[i]){console.log("remove group:",e),$.groups.splice(i,1),$.groupTitles.splice(i,1),$.instance.setState({lastUpdate:Date.now()});return}}}function Ai(s){switch(s){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 s}function On(s,e){const t=[];if(s.perspectiveCameraInfo!==void 0)for(const i in s.perspectiveCameraInfo)t.push({title:Ai(i),prop:i,type:"number",step:.01,value:s.perspectiveCameraInfo[i],onChange:(n,a)=>{e.updateObject(s.uuid,n,a),e.requestMethod(s.uuid,"updateProjectionMatrix");const r=e.getScene(s.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.uuid);l!==void 0&&(q(l,n,a),l.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const i in s.orthographicCameraInfo)t.push({title:Ai(i),prop:i,type:"number",step:.01,value:s.perspectiveCameraInfo[i],onChange:(n,a)=>{e.updateObject(s.uuid,n,a),e.requestMethod(s.uuid,"updateProjectionMatrix");const r=e.getScene(s.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.uuid);l!==void 0&&(q(l,n,a),l.updateProjectionMatrix())}}});return u.jsx(me,{title:"Camera",items:t})}class Tn extends o.Line{constructor(e,t){const i=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],n=new o.BufferGeometry;n.setAttribute("position",new o.Float32BufferAttribute(i,3)),n.computeBoundingSphere();const a=new o.LineBasicMaterial({fog:!1});super(n,a),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(r,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.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,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),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 Ii={type:"change"},ui={type:"start"},ds={type:"end"},bt=new o.Ray,Li=new o.Plane,Mn=Math.cos(70*o.MathUtils.DEG2RAD),ee=new o.Vector3,re=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Gt=1e-6;class Pn extends o.Controls{constructor(e,t=null){super(e,t),this.state=H.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.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:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Dn.bind(this),this._onPointerDown=Rn.bind(this),this._onPointerUp=An.bind(this),this._onContextMenu=Nn.bind(this),this._onMouseWheel=kn.bind(this),this._onKeyDown=Un.bind(this),this._onTouchStart=jn.bind(this),this._onTouchMove=Fn.bind(this),this._onMouseDown=In.bind(this),this._onMouseMove=Ln.bind(this),this._interceptControlDown=zn.bind(this),this._interceptControlUp=Hn.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ii),this.update(),this.state=H.NONE}update(e=null){const t=this.object.position;ee.copy(t).sub(this.target),ee.applyQuaternion(this._quat),this._spherical.setFromVector3(ee),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=re:i>Math.PI&&(i-=re),n<-Math.PI?n+=re:n>Math.PI&&(n-=re),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(ee.setFromSpherical(this._spherical),ee.applyQuaternion(this._quatInverse),t.copy(this.target).add(ee),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const l=ee.length();r=this._clampDistance(l*this._scale);const d=l-r;this.object.position.addScaledVector(this._dollyDirection,d),this.object.updateMatrixWorld(),a=!!d}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const d=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=d!==this.object.zoom;const h=new o.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),r=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(bt.origin.copy(this.object.position),bt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(bt.direction))<Mn?this.object.lookAt(this.target):(Li.setFromNormalAndCoplanarPoint(this.object.up,this.target),bt.intersectPlane(Li,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Gt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Gt||this._lastTargetPosition.distanceToSquared(this.target)>Gt?(this.dispatchEvent(Ii),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?re/60*this.autoRotateSpeed*e:re/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ee.setFromMatrixColumn(t,0),ee.multiplyScalar(-e),this._panOffset.add(ee)}_panUp(e,t){this.screenSpacePanning===!0?ee.setFromMatrixColumn(t,1):(ee.setFromMatrixColumn(t,0),ee.crossVectors(this.object.up,ee)),ee.multiplyScalar(e),this._panOffset.add(ee)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ee.copy(n).sub(this.target);let a=ee.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/i.clientHeight,this.object.matrix),this._panUp(2*t*a/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=e-i.left,a=t-i.top,r=i.width,l=i.height;this._mouse.x=n/r*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(re*this._rotateDelta.x/t.clientHeight),this._rotateUp(re*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(re*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-re*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(re*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-re*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(i*i+n*n);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),a=.5*(e.pageY+i.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(re*this._rotateDelta.x/t.clientHeight),this._rotateUp(re*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(r,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new o.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Rn(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function Dn(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function An(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ds),this.state=H.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function In(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case o.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=H.DOLLY;break;case o.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=H.ROTATE}break;case o.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(ui)}function Ln(s){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function kn(s){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(s.preventDefault(),this.dispatchEvent(ui),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(ds))}function Un(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function jn(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=H.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=H.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(ui)}function Fn(s){switch(this._trackPointer(s),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=H.NONE}}function Nn(s){this.enabled!==!1&&s.preventDefault()}function zn(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Hn(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Bn=Math.PI/180;function He(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Be(s,e,t){return(1-t)*s+t*e}function ki(s){return s*Bn}/*!
|
29
|
+
C11,8.22,10.74,8,10.43,8z`})});function os(s){return u.jsx(ts.Reorder.Item,{value:s.title,children:u.jsxs("div",{children:[rn,u.jsx("span",{children:s.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{s.onDelete(s.index)},children:nn})]})},s.title)}function ls(s){const[e,t]=w.useState(!1),[i,n]=w.useState(s.options),a=d=>{s.onDragComplete(d),n(d)},r=d=>{const p=[...i];p.splice(d,1),a(p)},l=[];i.forEach((d,p)=>{l.push(u.jsx(os,{index:p,title:d,onDelete:r},d))});let h="dropdown draggable";return s.subdropdown&&(h+=" subdropdown"),u.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(ui,{title:s.title}),u.jsx(ts.Reorder.Group,{axis:"y",values:i,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function cs(s){const[e,t]=w.useState(!1),i=[];s.options.map((a,r)=>{s.onSelect!==void 0&&(a.onSelect=s.onSelect),i.push(u.jsx(hs,{option:a},r))});let n="dropdown";return s.subdropdown&&(n+=" subdropdown"),u.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(ui,{title:s.title}),u.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:i})]})}function hs(s){const{option:e}=s,[t,i]=w.useState("");let n;switch(e.type){case"draggable":n=u.jsx(ls,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=u.jsx(cs,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=u.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?i(e.title):i(""))},children:e.title});break}return u.jsx("li",{className:t===e.title?"selected":"",children:n},ss())}function an(s,e,t){function i(a){switch(e.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":D.dispatchEvent({type:R.CUSTOM,value:a.data});break}}function n(a){switch(t.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":D.dispatchEvent({type:R.CUSTOM,value:a.data});break}}s.listen=a=>{a.target==="editor"?n(a):i(a)}}function ut(s){const[e,t]=w.useState(s.open!==void 0?s.open:!0),i=!e||s.children===void 0,n=()=>{D.dispatchEvent({type:R.REMOVE_SCENE,value:s.scene})};return u.jsxs("div",{className:`accordion ${i?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;s.onToggle!==void 0&&s.onToggle(a),t(a)},children:[u.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:dt(s.label)})]}),s.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:s.onRefresh}),u.jsx("button",{className:"remove",onClick:n})]}):null,s.button,u.jsx("div",{className:e?"open":"",children:u.jsx("div",{children:s.children})},Math.random())]})}function pi(s){const e=w.useRef(null),[t,i]=w.useState(!1),n=s.child!==void 0&&s.child.children.length>0,a=[];return s.child!==void 0&&s.child.children.length>0&&s.child.children.map((r,l)=>{a.push(u.jsx(pi,{child:r,three:s.three},l))}),w.useEffect(()=>{if(s.child){const r=s.three.getScene(s.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),u.jsx(u.Fragment,{children:s.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[n?u.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{i(!t)}}):null,u.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{s.child!==void 0&&(s.three.getObject(s.child.uuid),t||i(!0))},children:s.child.name.length>0?`${s.child.name} (${s.child.type})`:`${s.child.type}::${s.child.uuid}`}),u.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(s.child){const r=s.three.getScene(s.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.child.uuid);if(l!==void 0){const h="visible",d=!l.visible;e.current.style.opacity=d?"1":"0.25",s.three.updateObject(s.child.uuid,h,d),q(l,h,d)}}}}}),u.jsx("div",{className:`icon ${Qs(s.child)}`})]}),u.jsx("div",{className:t?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function oi(s){const e=[];return s.child?.children.map((t,i)=>{e.push(u.jsx(pi,{child:t,scene:s.scene,three:s.three},i))}),u.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function on(s){const[e,t]=w.useState(s.defaultValue);return w.useEffect(()=>{let i=!1,n=-1,a=0,r=s.defaultValue;const l=g=>{i=!0,a=Number(s.input.current?.value),n=g.clientX,document.addEventListener("mouseup",d,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",d,!1)},h=g=>{if(!i)return;const y=s.step!==void 0?s.step:1,x=(g.clientX-n)*y;r=Number((a+x).toFixed(4)),s.min!==void 0&&(r=Math.max(r,s.min)),s.max!==void 0&&(r=Math.min(r,s.max)),s.onChange!==void 0&&s.onChange(r),t(r)},d=()=>{i=!1,document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",d)},p=g=>{const y=Number(g.target.value);t(y)},m=g=>{const y=Number(g.target.value);s.onChange!==void 0&&s.onChange(y),t(y)};return s.input.current?.addEventListener("input",p),s.label.current?.addEventListener("mousedown",l,!1),s.sliderRef!==void 0&&s.sliderRef.current?.addEventListener("input",m),()=>{s.input.current?.removeEventListener("input",p),s.label.current?.removeEventListener("mousedown",l),s.sliderRef!==void 0&&s.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",d)}},[]),e}function je(s){const e=w.useRef(null),t=w.useRef(null),i=on({label:s.labelRef,input:e,sliderRef:t,defaultValue:s.value,min:s.min,max:s.max,step:s.step,onChange:n=>{s.onChange!==void 0&&s.onChange(s.prop,n)}});return u.jsxs(u.Fragment,{children:[s.type==="number"&&u.jsx("input",{alt:s.alt,className:s.className,ref:e,type:"number",value:i,min:s.min,max:s.max,step:s.step,disabled:s.disabled,onChange:n=>{const a=Number(n.target.value);s.onChange!==void 0&&s.onChange(s.prop,a)}}),s.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:i.toString(),disabled:s.disabled,ref:e,className:"min",onChange:n=>{const a=Number(n.target.value);s.onChange!==void 0&&s.onChange(s.prop,a)}}),u.jsx("input",{disabled:s.disabled,type:"range",value:i,min:s.min,max:s.max,step:s.step,ref:t,onChange:hi})]})]})}function ln(s){const e=w.useRef(null),t=w.useRef(null),i=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l,h]=w.useState(s.value),[d,p]=w.useState({min:Math.min(s.min,Math.min(s.value.x,s.value.y)),max:Math.max(s.max,Math.max(s.value.x,s.value.y))}),[m,g]=w.useState(!1);function y(){m||(window.addEventListener("mousemove",M),window.addEventListener("mouseup",x),window.addEventListener("mouseup",x),g(!0))}function x(){window.removeEventListener("mousemove",M),window.removeEventListener("mouseup",x),g(!1)}function M(E){const P=a.current.getBoundingClientRect(),O=Oe(0,99,E.clientX-P.left)/99,j=Oe(0,99,E.clientY-P.top)/99,W=pe(Dt(d.min,d.max,O),3),he=pe(Dt(d.min,d.max,j),3);s.onChange({target:{value:{x:W,y:he}}}),h({x:W,y:he})}function T(E){let P=l.x,O=l.y;E.target===e.current?P=Number(E.target.value):O=Number(E.target.value),h({x:P,y:O})}function _(){const E=Number(i.current.value);p({min:E,max:d.max}),(l.x<E||l.y<E)&&h({x:Oe(E,d.max,l.x),y:Oe(E,d.max,l.y)})}function v(){const E=Number(n.current.value);p({min:d.min,max:E}),(l.x>E||l.y>E)&&h({x:Oe(d.min,E,l.x),y:Oe(d.min,E,l.y)})}w.useEffect(()=>{const E=si(d.min,d.max,l.x),P=si(d.min,d.max,l.y);r.current.style.left=`${E*100}%`,r.current.style.top=`${P*100}%`},[d,l]);const C=s.step!==void 0?s.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"X:"}),u.jsx("input",{ref:e,type:"number",value:l.x,min:d.min,max:d.max,step:C,onChange:T})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:t,type:"number",value:l.y,min:d.min,max:d.max,step:C,onChange:T})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:i,type:"number",value:d.min,step:C,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:n,type:"number",value:d.max,step:C,onChange:v})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:x,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:r})]})]})}const cn=Math.PI/180,hn=180/Math.PI;function Be(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Ve(s,e,t){return(1-t)*s+t*e}function li(s){return s*cn}function dn(s){return s*hn}function Di(s){const e=s.value.x!==void 0&&s.value.y!==void 0&&s.value.z!==void 0,t=s.value.isEuler!==void 0,i=s.value.elements!==void 0,n=s.step!==void 0?s.step:.01,a=[];if(t){const r=w.useMemo(()=>s.value,[]);["_x","_y","_z"].forEach(h=>{const d=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:d,children:h.substring(1).toUpperCase()}),u.jsx(je,{value:dn(r[h]),type:"number",prop:h,step:.1,labelRef:d,onChange:(p,m)=>{r[p]=li(m),s.onChange({target:{value:r}})}})]},h))})}else if(e){const r=w.useMemo(()=>s.value,[]),l=(d,p)=>{r[d]=p,s.onChange({target:{value:r}})};["x","y","z"].forEach(d=>{const p=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:p,children:d.toUpperCase()}),u.jsx(je,{value:r[d],type:"number",prop:d,step:n,labelRef:p,onChange:l})]},d))})}else if(i){const r=w.useMemo(()=>s.value,[]),l=(h,d)=>{const p=Number(h);r.elements[p]=d,s.onChange({target:{value:r}})};for(let h=0;h<9;h++){const d=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:d,children:h+1}),u.jsx(je,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:d,onChange:l})]},h.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function un(s){const e=s.value.x!==void 0,t=s.step!==void 0?s.step:.01,i=[];if(e){const n=w.useMemo(()=>s.value,[]),a=(l,h)=>{n[l]=h,s.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=w.useRef(null);i.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:l.toUpperCase()}),u.jsx(je,{value:n.x,type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=w.useMemo(()=>s.value,[]),a=(r,l)=>{const h=Number(r);n.elements[h]=l,s.onChange({target:{value:n}})};for(let r=0;r<16;r++){const l=w.useRef(null);i.push(u.jsxs("div",{children:[u.jsx("label",{ref:l,children:r+1}),u.jsx(je,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return u.jsx("div",{className:"grid4",children:i})}function pn(s){return!(s==="defaultAttributeValues"||s==="forceSinglePass"||s==="linecap"||s==="linejoin"||s==="linewidth"||s==="normalMapType"||s==="precision"||s==="shadowSide"||s==="uniformsGroups"||s==="uniformsNeedUpdate"||s==="userData"||s==="version"||s==="wireframeLinecap"||s==="wireframeLinejoin"||s==="wireframeLinewidth"||s.slice(0,4)==="clip"||s.slice(0,7)==="polygon"||s.slice(0,7)==="stencil"||s.slice(0,2)==="is")}function mn(s){switch(s){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 s}function kt(s){switch(s){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 s}function ds(s){const e=s.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 fn(){const s=document.createElement("input");return s.type="file",new Promise((e,t)=>{s.addEventListener("change",function(){if(s.files===null)t();else{const i=s.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(i)}}),s.click()})}const _n=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],gn=[{title:"No Blending",value:o.NoBlending},{title:"Normal",value:o.NormalBlending},{title:"Additive",value:o.AdditiveBlending},{title:"Subtractive",value:o.SubtractiveBlending},{title:"Multiply",value:o.MultiplyBlending},{title:"Custom",value:o.CustomBlending}],yn=[{title:"Add",value:o.AddEquation},{title:"Subtract",value:o.SubtractEquation},{title:"Reverse Subtract",value:o.ReverseSubtractEquation},{title:"Min",value:o.MinEquation},{title:"Max",value:o.MaxEquation}],vn=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:o.SrcAlphaSaturateFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}],bn=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function Je(s,e){s.needsUpdate=!0,s.type="option",s.options=e}function En(s,e,t,i){return{type:"boolean",title:kt(s),prop:s,value:e,needsUpdate:!0,onChange:(n,a)=>{i.updateObject(t.uuid,`material.${s}`,a),i.updateObject(t.uuid,"material.needsUpdate",!0);const r=i.getScene(t.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",t.uuid);q(l,`material.${s}`,a)}}}}function Cn(s,e,t,i){const n={type:"number",title:kt(s),prop:s,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{i.updateObject(t.uuid,`material.${s}`,r),i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);q(h,`material.${s}`,r)}}};switch(s){case"blending":Je(n,gn);break;case"blendDst":Je(n,bn);break;case"blendEquation":Je(n,yn);break;case"blendSrc":Je(n,vn);break;case"side":Je(n,_n);break}return ds(s)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function Sn(s,e,t,i){const n={type:"string",title:kt(s),prop:s,value:e,needsUpdate:!0,onChange:(r,l)=>{i.updateObject(t.uuid,`material.${s}`,l),i.updateObject(t.uuid,"material.needsUpdate",!0);const h=i.getScene(t.uuid);if(h!==null){const d=h.getObjectByProperty("uuid",t.uuid);q(d,`material.${s}`,l)}},onKeyDown:r=>{}};return(s==="vertexShader"||s==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(r,l)=>{n.latest=l,i.updateObject(t.uuid,`material.${s}`,l);const h=i.getScene(t.uuid);if(h!==null){const d=h.getObjectByProperty("uuid",t.uuid);q(d,`material.${s}`,l)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){i.updateObject(t.uuid,"material.needsUpdate",!0);const l=i.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);q(h,"material.needsUpdate",!0)}}}),n}function wn(s){return s.x!==void 0&&s.y!==void 0&&s.z===void 0}function xn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w===void 0}function On(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w!==void 0}function ci(s){s.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function ot(s,e,t,i,n="",a=!1){const r=kt(s).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${s}`:s,h=typeof e;if(h==="boolean"||h==="string")return{title:r,prop:l,type:h,value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(h==="number"){const d={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(p,m)=>{i.updateObject(t.uuid,`material.${l}`,m);const g=i.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,m)}}};return ds(r)&&(d.type="range",d.min=0,d.max=1),d}else{if(e.isColor)return{title:r,prop:l,type:"color",value:e,disabled:a,onChange:(d,p)=>{const m=new o.Color(p);i.updateObject(t.uuid,`material.${l}`,m);const g=i.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,m)}}};if(Array.isArray(e)){const d=[];for(const p in e){const m=e[p],g=`[${p.toString()}]`;if(m.value!==void 0){const y=ot(`${g}.value`,m.value,t,i,l,a);y!==void 0&&d.push(y)}else{const y=ot(g,m,t,i,l,a);y!==void 0&&d.push(y)}}if(d.length>0)return ci(d),{title:r,items:d}}else{if(wn(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(xn(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(On(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(d,p)=>{const m=mn(s),g=n.length>0?`${n}.${m}`:m;i.createTexture(t.uuid,`material.${g}`,p);const y=i.getScene(t.uuid);if(y!==null){const x=y.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const M=T=>{const _=x.material,v=g.split(".");switch(v.length){case 1:_[v[0]]=T;break;case 2:_[v[0]][v[1]]=T;break;case 3:_[v[0]][v[1]][v[2]]=T;break;case 4:_[v[0]][v[1]][v[2]][v[3]]=T;break;case 5:_[v[0]][v[1]][v[2]][v[3]][v[4]]=T;break}_.needsUpdate=!0};p.src.length>0?as(p.src).then(T=>{T.offset.set(p.offset[0],p.offset[1]),T.repeat.set(p.repeat[0],p.repeat[1]),M(T)}):M(null)}}}};if(e.elements!==void 0)return{title:r,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(d,p)=>{i.updateObject(t.uuid,`material.${l}`,p);const m=i.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);q(g,`material.${l}`,p)}}};{const d=[],p=s==="defines"||s==="extensions";try{for(const m in e){const g=e[m];if(g!==void 0)if(g.value!==void 0){const y=ot(`${m}.value`,g.value,t,i,l,p);y!==void 0&&d.push(y)}else{const y=ot(m,g,t,i,l,p);y!==void 0&&d.push(y)}}}catch{console.log("Issue cycling through material object:",s,e)}if(d.length>0)return ci(d),{title:r,items:d}}}}}function Ai(s,e,t){const i=[];for(const n in s){if(!pn(n))continue;const a=typeof s[n],r=s[n];if(a==="boolean")i.push(En(n,r,e,t));else if(a==="number")i.push(Cn(n,r,e,t));else if(a==="string")i.push(Sn(n,r,e,t));else if(a==="object"){const l=ot(n,r,e,t);l!==void 0&&i.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return ci(i),i.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const a=n.getObjectByProperty("uuid",e.uuid);q(a,"material.needsUpdate",!0)}}}),i}function Tn(s,e){const t=s.material;if(Array.isArray(t)){const i=[],n=t.length;for(let a=0;a<n;a++)i.push(u.jsx(fe,{title:`Material ${a}`,items:Ai(t[a],s,e)},`Material ${a}`));return u.jsx(u.Fragment,{children:i})}else return u.jsx(fe,{title:"Material",items:Ai(t,s,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 Mn(s){const e=s.step!==void 0?s.step:.01,t=w.useRef(null),i=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l]=w.useState(s.value),[h,d]=w.useState(s.value.offset[0]),[p,m]=w.useState(s.value.offset[1]),[g,y]=w.useState(s.value.repeat[0]),[x,M]=w.useState(s.value.repeat[1]);function T(v,C,E,P,O){if(s.onChange!==void 0){const j=s.prop!==void 0?s.prop:s.title;s.onChange(j,{src:v,offset:[C,E],repeat:[P,O]})}}function _(v){const C=t.current.src,E=v.target.value;switch(v.target){case i.current:d(E),T(C,E,p,g,x);break;case n.current:m(E),T(C,h,E,g,x);break;case a.current:y(E),T(C,h,p,E,x);break;case r.current:M(E),T(C,h,p,g,E);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:s.title,ref:t,onClick:()=>{fn().then(v=>{t.current.src=v,T(v,h,p,g,x)})},src:l.src.length>0?l.src:Ii}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:_}),u.jsx("input",{ref:n,type:"number",value:p,step:e,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:g,step:e,onChange:_}),u.jsx("input",{ref:r,type:"number",value:x,step:e,onChange:_})]}),u.jsx("button",{onClick:()=>{T("",h,p,g,x),t.current.src=Ii},children:"Clear"})]})]})}function Pt(s){let e=s.value;e!==void 0&&(e.isColor!==void 0?e=ni(s.value):s.type==="color"&&(e=ni(new o.Color(s.value))));const[t,i]=w.useState(e),n=w.useRef(null),a=d=>{let p=d.target.value;if(s.type==="boolean")p=d.target.checked;else if(s.type==="option"&&(typeof s.value=="number"?p=Number(p):typeof s.value=="boolean"?p=!!p:typeof s.value=="object"&&(p=JSON.parse(p)),s.options!==void 0)){const m=s.options.length;for(let g=0;g<m&&s.options[g].value!==p;g++);}i(p),s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,p)},r={};s.disabled&&(r.opacity=.8);const l=s.type==="string"&&(t.length>100||t.search(`
|
30
|
+
`)>-1),h=l||s.type==="image"||s.type==="vector2";return u.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[s.type!=="button"&&u.jsx("label",{ref:n,children:dt(s.title)},"fieldLabel"),s.type==="string"&&!l&&u.jsx("input",{type:"text",disabled:s.disabled,onChange:a,value:t}),s.type==="string"&&l&&u.jsx("textarea",{cols:50,rows:10,disabled:s.disabled!==void 0?s.disabled:!0,onChange:a,onKeyDown:d=>{s.onKeyDown!==void 0&&s.onKeyDown(d)},value:t}),s.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:s.disabled,onChange:a,checked:t}),s.type==="number"&&u.jsx(je,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="range"&&u.jsx(je,{value:t,type:s.type,prop:s.prop!==void 0?s.prop:s.title,min:s.min,max:s.max,step:s.step,disabled:s.disabled,labelRef:n,onChange:s.onChange}),s.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:s.disabled,className:"color"}),u.jsx("input",{type:"color",value:t,onChange:a,disabled:s.disabled})]}),s.type==="button"&&u.jsx("button",{disabled:s.disabled,onClick:()=>{s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,!0)},children:s.title}),s.type==="image"&&u.jsx(Mn,{title:s.title,prop:s.prop,value:s.value,onChange:s.onChange}),s.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:a,disabled:s.disabled,defaultValue:s.value,children:s.options?.map((d,p)=>u.jsx("option",{value:d.value,children:dt(d.title)},p))})}),s.type==="vector2"&&u.jsx(ln,{step:s.step,value:t,min:0,max:1,onChange:a}),s.type==="grid3"&&u.jsx(Di,{step:s.step,value:t,onChange:a}),s.type==="grid4"&&u.jsx(un,{step:s.step,value:t,onChange:a}),s.type==="euler"&&u.jsx(Di,{step:s.step,value:t,onChange:a})]})}function Pn(s){return"items"in s}class fe extends w.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const i=w.createRef(),n=u.jsx(fe,{ref:i,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),i}removeGroup(e){const t=this.subgroupNames.length;for(let i=0;i<t;i++){const n=this.subgroupNames[i];if(e===n){this.subgroupNames.splice(i,1),this.subgroupElements.splice(i,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(Pn(t))e.push(u.jsx(fe,{title:dt(t.title),items:t.items},Math.random()));else{const i=this.valueOverrides.get(t.title),n=i!==void 0?i:t.value;e.push(u.jsx(Pt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),u.jsx(ut,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class $ extends w.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},$.instance=this,D.addEventListener(R.ADD_GROUP,this.addGroup),D.addEventListener(R.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){D.removeEventListener(R.ADD_GROUP,this.addGroup),D.removeEventListener(R.REMOVE_GROUP,this.removeGroup)}render(){return u.jsx("div",{className:"customGroups",children:$.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),i=[];t.items.forEach(n=>{i.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),$.groups.push(u.jsx(fe,{title:t.title,items:i},Math.random())),$.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,i=$.groupTitles.length;for(let n=0;n<i;n++)if(t===$.groupTitles[n]){$.groups.splice(n,1),$.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const i=w.createRef(),n=u.jsx(fe,{ref:i,title:e.title,items:t},Math.random());return $.groups.push(n),$.groupsRefs.push(i),$.groupTitles.push(e.title),i}static removeEditorGroup(e){const t=$.groupTitles.length;console.log("removeEditorGroup:",e,$.groupTitles);for(let i=0;i<t;i++)if(e===$.groupTitles[i]){console.log("remove group:",e),$.groups.splice(i,1),$.groupTitles.splice(i,1),$.instance.setState({lastUpdate:Date.now()});return}}}function Li(s){switch(s){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 s}function Rn(s,e){const t=[];if(s.perspectiveCameraInfo!==void 0)for(const i in s.perspectiveCameraInfo)t.push({title:Li(i),prop:i,type:"number",step:.01,value:s.perspectiveCameraInfo[i],onChange:(n,a)=>{e.updateObject(s.uuid,n,a),e.requestMethod(s.uuid,"updateProjectionMatrix");const r=e.getScene(s.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.uuid);l!==void 0&&(q(l,n,a),l.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const i in s.orthographicCameraInfo)t.push({title:Li(i),prop:i,type:"number",step:.01,value:s.perspectiveCameraInfo[i],onChange:(n,a)=>{e.updateObject(s.uuid,n,a),e.requestMethod(s.uuid,"updateProjectionMatrix");const r=e.getScene(s.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",s.uuid);l!==void 0&&(q(l,n,a),l.updateProjectionMatrix())}}});return u.jsx(fe,{title:"Camera",items:t})}class Dn extends o.Line{constructor(e,t){const i=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],n=new o.BufferGeometry;n.setAttribute("position",new o.Float32BufferAttribute(i,3)),n.computeBoundingSphere();const a=new o.LineBasicMaterial({fog:!1});super(n,a),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(r,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.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,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),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 ki={type:"change"},mi={type:"start"},us={type:"end"},bt=new o.Ray,Ui=new o.Plane,An=Math.cos(70*o.MathUtils.DEG2RAD),ee=new o.Vector3,re=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Zt=1e-6;class In extends o.Controls{constructor(e,t=null){super(e,t),this.state=H.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.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:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=kn.bind(this),this._onPointerDown=Ln.bind(this),this._onPointerUp=Un.bind(this),this._onContextMenu=Vn.bind(this),this._onMouseWheel=Nn.bind(this),this._onKeyDown=zn.bind(this),this._onTouchStart=Hn.bind(this),this._onTouchMove=Bn.bind(this),this._onMouseDown=jn.bind(this),this._onMouseMove=Fn.bind(this),this._interceptControlDown=Yn.bind(this),this._interceptControlUp=Gn.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ki),this.update(),this.state=H.NONE}update(e=null){const t=this.object.position;ee.copy(t).sub(this.target),ee.applyQuaternion(this._quat),this._spherical.setFromVector3(ee),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=re:i>Math.PI&&(i-=re),n<-Math.PI?n+=re:n>Math.PI&&(n-=re),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(ee.setFromSpherical(this._spherical),ee.applyQuaternion(this._quatInverse),t.copy(this.target).add(ee),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const l=ee.length();r=this._clampDistance(l*this._scale);const h=l-r;this.object.position.addScaledVector(this._dollyDirection,h),this.object.updateMatrixWorld(),a=!!h}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const h=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=h!==this.object.zoom;const d=new o.Vector3(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(l),this.object.updateMatrixWorld(),r=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(bt.origin.copy(this.object.position),bt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(bt.direction))<An?this.object.lookAt(this.target):(Ui.setFromNormalAndCoplanarPoint(this.object.up,this.target),bt.intersectPlane(Ui,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Zt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Zt||this._lastTargetPosition.distanceToSquared(this.target)>Zt?(this.dispatchEvent(ki),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?re/60*this.autoRotateSpeed*e:re/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ee.setFromMatrixColumn(t,0),ee.multiplyScalar(-e),this._panOffset.add(ee)}_panUp(e,t){this.screenSpacePanning===!0?ee.setFromMatrixColumn(t,1):(ee.setFromMatrixColumn(t,0),ee.crossVectors(this.object.up,ee)),ee.multiplyScalar(e),this._panOffset.add(ee)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ee.copy(n).sub(this.target);let a=ee.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/i.clientHeight,this.object.matrix),this._panUp(2*t*a/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=e-i.left,a=t-i.top,r=i.width,l=i.height;this._mouse.x=n/r*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(re*this._rotateDelta.x/t.clientHeight),this._rotateUp(re*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(re*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-re*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(re*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-re*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(i*i+n*n);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),a=.5*(e.pageY+i.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(re*this._rotateDelta.x/t.clientHeight),this._rotateUp(re*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(r,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new o.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Ln(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function kn(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Un(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(us),this.state=H.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function jn(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case o.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=H.DOLLY;break;case o.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=H.ROTATE}break;case o.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(mi)}function Fn(s){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Nn(s){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(s.preventDefault(),this.dispatchEvent(mi),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(us))}function zn(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function Hn(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=H.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=H.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(mi)}function Bn(s){switch(this._trackPointer(s),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=H.NONE}}function Vn(s){this.enabled!==!1&&s.preventDefault()}function Yn(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Gn(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
|
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 Z={LEFT:1,RIGHT:2,MIDDLE:4},m=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}),Ve={NONE:0,IN:1,OUT:-1};function De(s){return s.isPerspectiveCamera}function we(s){return s.isOrthographicCamera}const Ye=Math.PI*2,Ui=Math.PI/2,us=1e-5,et=Math.PI/180;function pe(s,e,t){return Math.max(e,Math.min(t,s))}function Y(s,e=us){return Math.abs(s)<e}function z(s,e,t=us){return Y(s-e,t)}function ji(s,e){return Math.round(s/e)*e}function tt(s){return isFinite(s)?s:s<0?-Number.MAX_VALUE:Number.MAX_VALUE}function it(s){return Math.abs(s)<Number.MAX_VALUE?s:s*(1/0)}function Et(s,e,t,i,n=1/0,a){i=Math.max(1e-4,i);const r=2/i,l=r*a,d=1/(1+l+.48*l*l+.235*l*l*l);let h=s-e;const p=e,f=n*i;h=pe(h,-f,f),e=s-h;const g=(t.value+r*h)*a;t.value=(t.value-r*g)*d;let y=e+(h+g)*d;return p-s>0==y>p&&(y=p,t.value=(y-p)/a),y}function Fi(s,e,t,i,n=1/0,a,r){i=Math.max(1e-4,i);const l=2/i,d=l*a,h=1/(1+d+.48*d*d+.235*d*d*d);let p=e.x,f=e.y,g=e.z,y=s.x-p,x=s.y-f,M=s.z-g;const T=p,_=f,v=g,C=n*i,E=C*C,P=y*y+x*x+M*M;if(P>E){const X=Math.sqrt(P);y=y/X*C,x=x/X*C,M=M/X*C}p=s.x-y,f=s.y-x,g=s.z-M;const O=(t.x+l*y)*a,j=(t.y+l*x)*a,W=(t.z+l*M)*a;t.x=(t.x-l*O)*h,t.y=(t.y-l*j)*h,t.z=(t.z-l*W)*h,r.x=p+(y+O)*h,r.y=f+(x+j)*h,r.z=g+(M+W)*h;const he=T-s.x,Ce=_-s.y,Qe=v-s.z,je=r.x-T,ce=r.y-_,J=r.z-v;return he*je+Ce*ce+Qe*J>0&&(r.x=T,r.y=_,r.z=v,t.x=(r.x-T)/a,t.y=(r.y-_)/a,t.z=(r.z-v)/a),r}function Zt(s,e){e.set(0,0),s.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=s.length,e.y/=s.length}function Wt(s,e){return we(s)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Vn{constructor(){this._listeners={}}addEventListener(e,t){const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const i=this._listeners[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let a=0,r=n.length;a<r;a++)n[a].call(this,e)}}}var Xt;const Yn="2.9.0",Ct=1/8,Gn=/Mac/.test((Xt=globalThis?.navigator)===null||Xt===void 0?void 0:Xt.platform);let A,Ni,St,Qt,ae,L,F,Ge,st,fe,_e,Ae,zi,Hi,ue,nt,Ze,Bi,$t,Vi,qt,Kt,wt;class ye extends Vn{static install(e){A=e.THREE,Ni=Object.freeze(new A.Vector3(0,0,0)),St=Object.freeze(new A.Vector3(0,1,0)),Qt=Object.freeze(new A.Vector3(0,0,1)),ae=new A.Vector2,L=new A.Vector3,F=new A.Vector3,Ge=new A.Vector3,st=new A.Vector3,fe=new A.Vector3,_e=new A.Vector3,Ae=new A.Vector3,zi=new A.Vector3,Hi=new A.Vector3,ue=new A.Spherical,nt=new A.Spherical,Ze=new A.Box3,Bi=new A.Box3,$t=new A.Sphere,Vi=new A.Quaternion,qt=new A.Quaternion,Kt=new A.Matrix4,wt=new A.Raycaster}static get ACTION(){return m}constructor(e,t){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=m.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=Ve.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new A.Vector3,this._focalOffsetVelocity=new A.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,v,C)=>{let E,P;if(De(this._camera)){const O=L.copy(this._camera.position).sub(this._target),j=this._camera.getEffectiveFOV()*et,W=O.length()*Math.tan(j*.5);E=this.truckSpeed*_*W/this._elementRect.height,P=this.truckSpeed*v*W/this._elementRect.height}else if(we(this._camera)){const O=this._camera;E=_*(O.right-O.left)/O.zoom/this._elementRect.width,P=v*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(C?this.setFocalOffset(this._focalOffsetEnd.x+E,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(E,0,!0),this.forward(-P,!0)):C?this.setFocalOffset(this._focalOffsetEnd.x+E,this._focalOffsetEnd.y+P,this._focalOffsetEnd.z,!0):this.truck(E,P,!0)},this._rotateInternal=(_,v)=>{const C=Ye*this.azimuthRotateSpeed*_/this._elementRect.height,E=Ye*this.polarRotateSpeed*v/this._elementRect.height;this.rotate(C,E,!0)},this._dollyInternal=(_,v,C)=>{const E=Math.pow(.95,-_*this.dollySpeed),P=this._sphericalEnd.radius,O=this._sphericalEnd.radius*E,j=pe(O,this.minDistance,this.maxDistance),W=j-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(W,!0),this._dollyToNoClamp(j,!0)):this._dollyToNoClamp(j,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:j)-P,this._dollyControlCoord.set(v,C)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,v,C)=>{const E=Math.pow(.95,_*this.dollySpeed),P=this._zoom,O=this._zoom*E;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-P,this._dollyControlCoord.set(v,C))},typeof A>"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 A.Quaternion().setFromUnitVectors(this._camera.up,St),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=m.NONE,this._target=new A.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new A.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new A.Spherical().setFromVector3(L.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 A.Vector3,new A.Vector3,new A.Vector3,new A.Vector3],this._updateNearPlaneCorners(),this._boundary=new A.Box3(new A.Vector3(-1/0,-1/0,-1/0),new A.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 A.Vector2,this.mouseButtons={left:m.ROTATE,middle:m.DOLLY,right:m.TRUCK,wheel:De(this._camera)?m.DOLLY:we(this._camera)?m.ZOOM:m.NONE},this.touches={one:m.TOUCH_ROTATE,two:De(this._camera)?m.TOUCH_DOLLY_TRUCK:we(this._camera)?m.TOUCH_ZOOM_TRUCK:m.NONE,three:m.TOUCH_TRUCK};const i=new A.Vector2,n=new A.Vector2,a=new A.Vector2,r=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),P=_.clientX/E.width,O=_.clientY/E.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const v=_.pointerType!=="mouse"?null:(_.buttons&Z.LEFT)===Z.LEFT?Z.LEFT:(_.buttons&Z.MIDDLE)===Z.MIDDLE?Z.MIDDLE:(_.buttons&Z.RIGHT)===Z.RIGHT?Z.RIGHT:null;if(v!==null){const E=this._findPointerByMouseButton(v);E&&this._disposePointer(E)}if((_.buttons&Z.LEFT)===Z.LEFT&&this._lockedPointer)return;const C={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:v};this._activePointers.push(C),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,g(_)},l=_=>{_.cancelable&&_.preventDefault();const v=_.pointerId,C=this._lockedPointer||this._findPointerById(v);if(C){if(C.clientX=_.clientX,C.clientY=_.clientY,C.deltaX=_.movementX,C.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Z.LEFT)===Z.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Z.MIDDLE)===Z.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Z.RIGHT)===Z.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},d=_=>{const v=this._findPointerById(_.pointerId);if(!(v&&v===this._lockedPointer)){if(v&&this._disposePointer(v),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=m.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=m.NONE;x()}};let h=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===m.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),j=_.clientX/O.width,W=_.clientY/O.height;if(j<this._interactiveArea.left||j>this._interactiveArea.right||W<this._interactiveArea.top||W>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===m.ROTATE||this.mouseButtons.wheel===m.TRUCK){const O=performance.now();h-O<1e3&&this._getClientRect(this._elementRect),h=O}const v=Gn?-1:-3,C=_.deltaMode===1?_.deltaY/v:_.deltaY/(v*10),E=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,P=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case m.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case m.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case m.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case m.DOLLY:{this._dollyInternal(-C,E,P),this._isUserControllingDolly=!0;break}case m.ZOOM:{this._zoomInternal(-C,E,P),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ye.ACTION.NONE){const v=_ instanceof PointerEvent?_.pointerId:0,C=this._findPointerById(v);C&&this._disposePointer(C),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d);return}_.preventDefault()}},g=_=>{if(!this._enabled)return;if(Zt(this._activePointers,ae),this._getClientRect(this._elementRect),i.copy(ae),n.copy(ae),this._activePointers.length>=2){const C=ae.x-this._activePointers[1].clientX,E=ae.y-this._activePointers[1].clientY,P=Math.sqrt(C*C+E*E);a.set(0,P);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,j=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(O,j)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Z.LEFT)===Z.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Z.MIDDLE)===Z.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Z.RIGHT)===Z.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&m.ROTATE)===m.ROTATE||(this._state&m.TOUCH_ROTATE)===m.TOUCH_ROTATE||(this._state&m.TOUCH_DOLLY_ROTATE)===m.TOUCH_DOLLY_ROTATE||(this._state&m.TOUCH_ZOOM_ROTATE)===m.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&m.TRUCK)===m.TRUCK||(this._state&m.TOUCH_TRUCK)===m.TOUCH_TRUCK||(this._state&m.TOUCH_DOLLY_TRUCK)===m.TOUCH_DOLLY_TRUCK||(this._state&m.TOUCH_ZOOM_TRUCK)===m.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&m.DOLLY)===m.DOLLY||(this._state&m.TOUCH_DOLLY)===m.TOUCH_DOLLY||(this._state&m.TOUCH_DOLLY_TRUCK)===m.TOUCH_DOLLY_TRUCK||(this._state&m.TOUCH_DOLLY_OFFSET)===m.TOUCH_DOLLY_OFFSET||(this._state&m.TOUCH_DOLLY_ROTATE)===m.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&m.ZOOM)===m.ZOOM||(this._state&m.TOUCH_ZOOM)===m.TOUCH_ZOOM||(this._state&m.TOUCH_ZOOM_TRUCK)===m.TOUCH_ZOOM_TRUCK||(this._state&m.TOUCH_ZOOM_OFFSET)===m.TOUCH_ZOOM_OFFSET||(this._state&m.TOUCH_ZOOM_ROTATE)===m.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&m.OFFSET)===m.OFFSET||(this._state&m.TOUCH_OFFSET)===m.TOUCH_OFFSET||(this._state&m.TOUCH_DOLLY_OFFSET)===m.TOUCH_DOLLY_OFFSET||(this._state&m.TOUCH_ZOOM_OFFSET)===m.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,Zt(this._activePointers,ae);const v=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,C=v?-v.deltaX:n.x-ae.x,E=v?-v.deltaY:n.y-ae.y;if(n.copy(ae),((this._state&m.ROTATE)===m.ROTATE||(this._state&m.TOUCH_ROTATE)===m.TOUCH_ROTATE||(this._state&m.TOUCH_DOLLY_ROTATE)===m.TOUCH_DOLLY_ROTATE||(this._state&m.TOUCH_ZOOM_ROTATE)===m.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(C,E),this._isUserControllingRotate=!0),(this._state&m.DOLLY)===m.DOLLY||(this._state&m.ZOOM)===m.ZOOM){const P=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,O=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,j=this.dollyDragInverted?-1:1;(this._state&m.DOLLY)===m.DOLLY?(this._dollyInternal(j*E*Ct,P,O),this._isUserControllingDolly=!0):(this._zoomInternal(j*E*Ct,P,O),this._isUserControllingZoom=!0)}if((this._state&m.TOUCH_DOLLY)===m.TOUCH_DOLLY||(this._state&m.TOUCH_ZOOM)===m.TOUCH_ZOOM||(this._state&m.TOUCH_DOLLY_TRUCK)===m.TOUCH_DOLLY_TRUCK||(this._state&m.TOUCH_ZOOM_TRUCK)===m.TOUCH_ZOOM_TRUCK||(this._state&m.TOUCH_DOLLY_OFFSET)===m.TOUCH_DOLLY_OFFSET||(this._state&m.TOUCH_ZOOM_OFFSET)===m.TOUCH_ZOOM_OFFSET||(this._state&m.TOUCH_DOLLY_ROTATE)===m.TOUCH_DOLLY_ROTATE||(this._state&m.TOUCH_ZOOM_ROTATE)===m.TOUCH_ZOOM_ROTATE){const P=ae.x-this._activePointers[1].clientX,O=ae.y-this._activePointers[1].clientY,j=Math.sqrt(P*P+O*O),W=a.y-j;a.set(0,j);const he=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,Ce=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&m.TOUCH_DOLLY)===m.TOUCH_DOLLY||(this._state&m.TOUCH_DOLLY_ROTATE)===m.TOUCH_DOLLY_ROTATE||(this._state&m.TOUCH_DOLLY_TRUCK)===m.TOUCH_DOLLY_TRUCK||(this._state&m.TOUCH_DOLLY_OFFSET)===m.TOUCH_DOLLY_OFFSET?(this._dollyInternal(W*Ct,he,Ce),this._isUserControllingDolly=!0):(this._zoomInternal(W*Ct,he,Ce),this._isUserControllingZoom=!0)}((this._state&m.TRUCK)===m.TRUCK||(this._state&m.TOUCH_TRUCK)===m.TOUCH_TRUCK||(this._state&m.TOUCH_DOLLY_TRUCK)===m.TOUCH_DOLLY_TRUCK||(this._state&m.TOUCH_ZOOM_TRUCK)===m.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(C,E,!1),this._isUserControllingTruck=!0),((this._state&m.OFFSET)===m.OFFSET||(this._state&m.TOUCH_OFFSET)===m.TOUCH_OFFSET||(this._state&m.TOUCH_DOLLY_OFFSET)===m.TOUCH_DOLLY_OFFSET||(this._state&m.TOUCH_ZOOM_OFFSET)===m.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(C,E,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},x=()=>{Zt(this._activePointers,ae),n.copy(ae),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",l,{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",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",M),this._domElement.ownerDocument.addEventListener("pointerlockerror",T),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),g())},this.unlockPointer=()=>{var _,v,C;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(v=this._domElement)===null||v===void 0||v.ownerDocument.removeEventListener("pointerlockchange",M),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockerror",T),this.cancel()};const M=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},T=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",M),this._domElement.ownerDocument.removeEventListener("pointerlockerror",T))},this.cancel=()=>{this._state!==m.NONE&&(this._state=m.NONE,this._activePointers.length=0,x())},t&&this.connect(t),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=pe(e.width,0,1),this._interactiveArea.height=pe(e.height,0,1),this._interactiveArea.x=pe(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=pe(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const n=pe(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=pe(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!i||z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ve.NONE,this._changedDolly=0,this._dollyToNoClamp(pe(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),l=z(r,this._spherical.radius);if(!(i>e)&&l)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(st).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=pe(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||z(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),fe.setFromMatrixColumn(this._camera.matrix,0),_e.setFromMatrixColumn(this._camera.matrix,1),fe.multiplyScalar(e),_e.multiplyScalar(-t);const n=L.copy(fe).add(_e),a=F.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,i)}forward(e,t=!1){L.setFromMatrixColumn(this._camera.matrix,0),L.crossVectors(this._camera.up,L),L.multiplyScalar(e);const i=F.copy(this._targetEnd).add(L);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return L.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+L.x,this._targetEnd.y+L.y,this._targetEnd.z+L.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;const a=L.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const r=!n||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,n=!1){const l=L.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(l.x,l.y,l.z,n)}fitToBox(e,t,{cover:i=!1,paddingLeft:n=0,paddingRight:a=0,paddingBottom:r=0,paddingTop:l=0}={}){const d=[],h=e.isBox3?Ze.copy(e):Ze.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=ji(this._sphericalEnd.theta,Ui),f=ji(this._sphericalEnd.phi,Ui);d.push(this.rotateTo(p,f,t));const g=L.setFromSpherical(this._sphericalEnd).normalize(),y=Vi.setFromUnitVectors(g,Qt),x=z(Math.abs(g.y),1);x&&y.multiply(qt.setFromAxisAngle(St,p)),y.multiply(this._yAxisUpSpaceInverse);const M=Bi.makeEmpty();F.copy(h.min).applyQuaternion(y),M.expandByPoint(F),F.copy(h.min).setX(h.max.x).applyQuaternion(y),M.expandByPoint(F),F.copy(h.min).setY(h.max.y).applyQuaternion(y),M.expandByPoint(F),F.copy(h.max).setZ(h.min.z).applyQuaternion(y),M.expandByPoint(F),F.copy(h.min).setZ(h.max.z).applyQuaternion(y),M.expandByPoint(F),F.copy(h.max).setY(h.min.y).applyQuaternion(y),M.expandByPoint(F),F.copy(h.max).setX(h.min.x).applyQuaternion(y),M.expandByPoint(F),F.copy(h.max).applyQuaternion(y),M.expandByPoint(F),M.min.x-=n,M.min.y-=r,M.max.x+=a,M.max.y+=l,y.setFromUnitVectors(Qt,g),x&&y.premultiply(qt.invert()),y.premultiply(this._yAxisUpSpace);const T=M.getSize(L),_=M.getCenter(F).applyQuaternion(y);if(De(this._camera)){const v=this.getDistanceToFitBox(T.x,T.y,T.z,i);d.push(this.moveTo(_.x,_.y,_.z,t)),d.push(this.dollyTo(v,t)),d.push(this.setFocalOffset(0,0,0,t))}else if(we(this._camera)){const v=this._camera,C=v.right-v.left,E=v.top-v.bottom,P=i?Math.max(C/T.x,E/T.y):Math.min(C/T.x,E/T.y);d.push(this.moveTo(_.x,_.y,_.z,t)),d.push(this.zoomTo(P,t)),d.push(this.setFocalOffset(0,0,0,t))}return Promise.all(d)}fitToSphere(e,t){const i=[],a="isObject3D"in e?ye.createBoundingSphere(e,$t):$t.copy(e);if(i.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),De(this._camera)){const r=this.getDistanceToFitSphere(a.radius);i.push(this.dollyTo(r,t))}else if(we(this._camera)){const r=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,d=2*a.radius,h=Math.min(r/d,l/d);i.push(this.zoomTo(h,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,n,a,r,l=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ve.NONE,this._changedDolly=0;const d=F.set(n,a,r),h=L.set(e,t,i);this._targetEnd.copy(d),this._sphericalEnd.setFromVector3(h.sub(d).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!l||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,i,n,a,r,l,d,h,p,f,g,y,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ve.NONE,this._changedDolly=0;const M=L.set(n,a,r),T=F.set(e,t,i);ue.setFromVector3(T.sub(M).applyQuaternion(this._yAxisUpSpace));const _=Ge.set(p,f,g),v=F.set(l,d,h);nt.setFromVector3(v.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(M.lerp(_,y));const C=nt.theta-ue.theta,E=nt.phi-ue.phi,P=nt.radius-ue.radius;this._sphericalEnd.set(ue.radius+P*y,ue.phi+E*y,ue.theta+C*y),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!x||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(O)}setPosition(e,t,i,n=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,i,n=!1){const a=this.getPosition(L),r=this.setLookAt(a.x,a.y,a.z,e,t,i,n);return this._sphericalEnd.phi=pe(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,i,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const a=!n||z(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&z(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&z(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),fe.setFromMatrixColumn(this._camera.matrixWorldInverse,0),_e.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ae.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=L.set(e,t,i),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);fe.multiplyScalar(r.x),_e.multiplyScalar(r.y),Ae.multiplyScalar(r.z),L.copy(fe).add(_e).add(Ae),L.z=L.z+a,this.dollyTo(a,!1),this.setFocalOffset(-L.x,L.y,-L.z,!1),this.moveTo(e,t,i,!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,t,i,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new A.Vector4,typeof e=="number"?this._viewport.set(e,t,i,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,n=!1){if(Wt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*et,l=this._camera.aspect;return((n?a>l:a<l)?t:e/l)*.5/Math.tan(r*.5)+i*.5}getDistanceToFitSphere(e){if(Wt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*et,i=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:i;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new A.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ye,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ye),this._spherical.theta+=Ye*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ye)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!z(this._camera.up.x,this._cameraUp0.x)||!z(this._camera.up.y,this._cameraUp0.y)||!z(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(L);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[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(t)}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,St),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=L.subVectors(this._target,this._camera.position).normalize(),t=F.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(L);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,a=zi.subVectors(this._targetEnd,this._target),r=Hi.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(Y(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Et(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Y(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Et(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Y(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Et(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Y(a.x)&&Y(a.y)&&Y(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Fi(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Y(r.x)&&Y(r.y)&&Y(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Fi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Y(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Et(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(De(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,g=this._camera,y=this._getCameraDirection(st),x=L.copy(y).cross(g.up).normalize();x.lengthSq()===0&&(x.x=1);const M=F.crossVectors(x,y),T=this._sphericalEnd.radius*Math.tan(g.getEffectiveFOV()*et*.5),v=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,C=Ge.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*T*g.aspect)).add(M.multiplyScalar(this._dollyControlCoord.y*T)),E=L.copy(this._targetEnd).lerp(C,v),P=this._lastDollyDirection===Ve.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===Ve.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(P||O)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const W=F.copy(y).multiplyScalar(-f);E.add(W)}this._boundary.clampPoint(E,E);const j=F.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(j),this._changedDolly-=f,Y(this._changedDolly)&&(this._changedDolly=0)}else if(we(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,g=this._camera,y=L.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(g.near+g.far)/(g.near-g.far)).unproject(g),x=F.set(0,0,-1).applyQuaternion(g.quaternion),M=Ge.copy(y).add(x.multiplyScalar(-y.dot(g.up))),_=-(this._zoom-f-this._zoom)/this._zoom,v=this._getCameraDirection(st),C=this._targetEnd.dot(v),E=L.copy(this._targetEnd).lerp(M,_),P=E.dot(v),O=v.multiplyScalar(P-C);E.sub(O),this._boundary.clampPoint(E,E);const j=F.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(j),this._changedZoom-=f,Y(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),(!Y(this._focalOffset.x)||!Y(this._focalOffset.y)||!Y(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),fe.setFromMatrixColumn(this._camera.matrix,0),_e.setFromMatrixColumn(this._camera.matrix,1),Ae.setFromMatrixColumn(this._camera.matrix,2),fe.multiplyScalar(this._focalOffset.x),_e.multiplyScalar(-this._focalOffset.y),Ae.multiplyScalar(this._focalOffset.z),L.copy(fe).add(_e).add(Ae),this._camera.position.add(L)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),L.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Y(t,this.restThreshold)&&Y(i,this.restThreshold)&&Y(n,this.restThreshold)&&Y(a.x,this.restThreshold)&&Y(a.y,this.restThreshold)&&Y(a.z,this.restThreshold)&&Y(r.x,this.restThreshold)&&Y(r.y,this.restThreshold)&&Y(r.z,this.restThreshold)&&Y(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:tt(this.maxDistance),minZoom:this.minZoom,maxZoom:tt(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:tt(this.maxPolarAngle),minAzimuthAngle:tt(this.minAzimuthAngle),maxAzimuthAngle:tt(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:L.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,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=it(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=it(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=it(i.maxPolarAngle),this.minAzimuthAngle=it(i.minAzimuthAngle),this.maxAzimuthAngle=it(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this.verticalDragToForward=i.verticalDragToForward,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),ue.setFromVector3(L.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ue.theta,ue.phi,t),this.dollyTo(ue.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Yn),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(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const n=t.lengthSq();if(n===0)return e;const a=F.copy(t).add(e),l=this._boundary.clampPoint(a,Ge).sub(a),d=l.lengthSq();if(d===0)return e.add(t);if(d===n)return e;if(i===0)return e.add(t).add(l);{const h=1+i*d/t.dot(l);return e.add(F.copy(t).multiplyScalar(h)).add(l.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(De(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*et,n=Math.tan(i*.5)*t,a=n*e.aspect;this._nearPlaneCorners[0].set(-a,-n,0),this._nearPlaneCorners[1].set(a,-n,0),this._nearPlaneCorners[2].set(a,n,0),this._nearPlaneCorners[3].set(-a,n,0)}else if(we(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,n=e.right*t,a=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(i,a,0),this._nearPlaneCorners[1].set(n,a,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(i,r,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Wt(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(st);Kt.lookAt(Ni,i,this._camera.up);for(let n=0;n<4;n++){const a=F.copy(this._nearPlaneCorners[n]);a.applyMatrix4(Kt);const r=Ge.addVectors(this._target,a);wt.set(r,i),wt.far=this._spherical.radius+1;const l=wt.intersectObjects(this.colliderMeshes);l.length!==0&&l[0].distance<e&&(e=l[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_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,t=new A.Sphere){const i=t,n=i.center;Ze.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&Ze.expandByObject(r)}),Ze.getCenter(n);let a=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const l=r,d=l.geometry.clone();d.applyMatrix4(l.matrixWorld);const p=d.attributes.position;for(let f=0,g=p.count;f<g;f++)L.fromBufferAttribute(p,f),a=Math.max(a,n.distanceToSquared(L))}),i.radius=Math.sqrt(a),i}}const At=s=>{const[e,t]=w.useState(s.options[s.index]),i=()=>{s.onToggle(!s.open)},n=a=>{a!==e&&(s.onSelect(a),t(a)),s.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${s.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:i,children:`${s.title}: ${e}`}),s.open&&u.jsx("ul",{className:"dropdown-menu",children:s.options.map(a=>u.jsx("li",{onClick:()=>n(a),children:a},a))})]})},Ie=w.forwardRef(function(e,t){const i=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=w.useState("Renderer"),[r,l]=w.useState(!1),[d,h]=w.useState(!1),[p,f]=w.useState(!1);return u.jsxs("div",{className:`CameraWindow ${e.name}`,children:[u.jsx("div",{ref:t,className:"clickable",onClick:()=>{p&&f(!1)}}),u.jsxs("div",{className:"options",children:[e.camera!==null&&u.jsx(At,{title:"Camera",index:e.options.indexOf(e.camera.name),open:p,options:e.options,onSelect:e.onSelectCamera,onToggle:g=>{f(g)},up:!0}),u.jsx(At,{title:"Mode",index:i.indexOf(n),open:d,options:i,onSelect:g=>{if(g===n)return;const y=g;e.onSelectRenderMode(y),a(y)},onToggle:g=>{r&&l(!1),h(g)},up:!0})]})]})});class Zn extends o.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},glslVersion:o.GLSL3,side:o.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 o.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 Z={LEFT:1,RIGHT:2,MIDDLE:4},f=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}),Ye={NONE:0,IN:1,OUT:-1};function Ae(s){return s.isPerspectiveCamera}function xe(s){return s.isOrthographicCamera}const Ge=Math.PI*2,ji=Math.PI/2,ps=1e-5,et=Math.PI/180;function me(s,e,t){return Math.max(e,Math.min(t,s))}function Y(s,e=ps){return Math.abs(s)<e}function z(s,e,t=ps){return Y(s-e,t)}function Fi(s,e){return Math.round(s/e)*e}function tt(s){return isFinite(s)?s:s<0?-Number.MAX_VALUE:Number.MAX_VALUE}function it(s){return Math.abs(s)<Number.MAX_VALUE?s:s*(1/0)}function Et(s,e,t,i,n=1/0,a){i=Math.max(1e-4,i);const r=2/i,l=r*a,h=1/(1+l+.48*l*l+.235*l*l*l);let d=s-e;const p=e,m=n*i;d=me(d,-m,m),e=s-d;const g=(t.value+r*d)*a;t.value=(t.value-r*g)*h;let y=e+(d+g)*h;return p-s>0==y>p&&(y=p,t.value=(y-p)/a),y}function Ni(s,e,t,i,n=1/0,a,r){i=Math.max(1e-4,i);const l=2/i,h=l*a,d=1/(1+h+.48*h*h+.235*h*h*h);let p=e.x,m=e.y,g=e.z,y=s.x-p,x=s.y-m,M=s.z-g;const T=p,_=m,v=g,C=n*i,E=C*C,P=y*y+x*x+M*M;if(P>E){const X=Math.sqrt(P);y=y/X*C,x=x/X*C,M=M/X*C}p=s.x-y,m=s.y-x,g=s.z-M;const O=(t.x+l*y)*a,j=(t.y+l*x)*a,W=(t.z+l*M)*a;t.x=(t.x-l*O)*d,t.y=(t.y-l*j)*d,t.z=(t.z-l*W)*d,r.x=p+(y+O)*d,r.y=m+(x+j)*d,r.z=g+(M+W)*d;const he=T-s.x,Se=_-s.y,Qe=v-s.z,Fe=r.x-T,ce=r.y-_,J=r.z-v;return he*Fe+Se*ce+Qe*J>0&&(r.x=T,r.y=_,r.z=v,t.x=(r.x-T)/a,t.y=(r.y-_)/a,t.z=(r.z-v)/a),r}function Wt(s,e){e.set(0,0),s.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=s.length,e.y/=s.length}function Xt(s,e){return xe(s)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Zn{constructor(){this._listeners={}}addEventListener(e,t){const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const i=this._listeners[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let a=0,r=n.length;a<r;a++)n[a].call(this,e)}}}var Qt;const Wn="2.9.0",Ct=1/8,Xn=/Mac/.test((Qt=globalThis?.navigator)===null||Qt===void 0?void 0:Qt.platform);let A,zi,St,$t,ae,L,F,Ze,st,_e,ge,Ie,Hi,Bi,ue,nt,We,Vi,qt,Yi,Kt,Jt,wt;class ve extends Zn{static install(e){A=e.THREE,zi=Object.freeze(new A.Vector3(0,0,0)),St=Object.freeze(new A.Vector3(0,1,0)),$t=Object.freeze(new A.Vector3(0,0,1)),ae=new A.Vector2,L=new A.Vector3,F=new A.Vector3,Ze=new A.Vector3,st=new A.Vector3,_e=new A.Vector3,ge=new A.Vector3,Ie=new A.Vector3,Hi=new A.Vector3,Bi=new A.Vector3,ue=new A.Spherical,nt=new A.Spherical,We=new A.Box3,Vi=new A.Box3,qt=new A.Sphere,Yi=new A.Quaternion,Kt=new A.Quaternion,Jt=new A.Matrix4,wt=new A.Raycaster}static get ACTION(){return f}constructor(e,t){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=f.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=Ye.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new A.Vector3,this._focalOffsetVelocity=new A.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,v,C)=>{let E,P;if(Ae(this._camera)){const O=L.copy(this._camera.position).sub(this._target),j=this._camera.getEffectiveFOV()*et,W=O.length()*Math.tan(j*.5);E=this.truckSpeed*_*W/this._elementRect.height,P=this.truckSpeed*v*W/this._elementRect.height}else if(xe(this._camera)){const O=this._camera;E=_*(O.right-O.left)/O.zoom/this._elementRect.width,P=v*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(C?this.setFocalOffset(this._focalOffsetEnd.x+E,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(E,0,!0),this.forward(-P,!0)):C?this.setFocalOffset(this._focalOffsetEnd.x+E,this._focalOffsetEnd.y+P,this._focalOffsetEnd.z,!0):this.truck(E,P,!0)},this._rotateInternal=(_,v)=>{const C=Ge*this.azimuthRotateSpeed*_/this._elementRect.height,E=Ge*this.polarRotateSpeed*v/this._elementRect.height;this.rotate(C,E,!0)},this._dollyInternal=(_,v,C)=>{const E=Math.pow(.95,-_*this.dollySpeed),P=this._sphericalEnd.radius,O=this._sphericalEnd.radius*E,j=me(O,this.minDistance,this.maxDistance),W=j-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(W,!0),this._dollyToNoClamp(j,!0)):this._dollyToNoClamp(j,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:j)-P,this._dollyControlCoord.set(v,C)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,v,C)=>{const E=Math.pow(.95,_*this.dollySpeed),P=this._zoom,O=this._zoom*E;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-P,this._dollyControlCoord.set(v,C))},typeof A>"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 A.Quaternion().setFromUnitVectors(this._camera.up,St),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=f.NONE,this._target=new A.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new A.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new A.Spherical().setFromVector3(L.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 A.Vector3,new A.Vector3,new A.Vector3,new A.Vector3],this._updateNearPlaneCorners(),this._boundary=new A.Box3(new A.Vector3(-1/0,-1/0,-1/0),new A.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 A.Vector2,this.mouseButtons={left:f.ROTATE,middle:f.DOLLY,right:f.TRUCK,wheel:Ae(this._camera)?f.DOLLY:xe(this._camera)?f.ZOOM:f.NONE},this.touches={one:f.TOUCH_ROTATE,two:Ae(this._camera)?f.TOUCH_DOLLY_TRUCK:xe(this._camera)?f.TOUCH_ZOOM_TRUCK:f.NONE,three:f.TOUCH_TRUCK};const i=new A.Vector2,n=new A.Vector2,a=new A.Vector2,r=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),P=_.clientX/E.width,O=_.clientY/E.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const v=_.pointerType!=="mouse"?null:(_.buttons&Z.LEFT)===Z.LEFT?Z.LEFT:(_.buttons&Z.MIDDLE)===Z.MIDDLE?Z.MIDDLE:(_.buttons&Z.RIGHT)===Z.RIGHT?Z.RIGHT:null;if(v!==null){const E=this._findPointerByMouseButton(v);E&&this._disposePointer(E)}if((_.buttons&Z.LEFT)===Z.LEFT&&this._lockedPointer)return;const C={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:v};this._activePointers.push(C),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,g(_)},l=_=>{_.cancelable&&_.preventDefault();const v=_.pointerId,C=this._lockedPointer||this._findPointerById(v);if(C){if(C.clientX=_.clientX,C.clientY=_.clientY,C.deltaX=_.movementX,C.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Z.LEFT)===Z.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Z.MIDDLE)===Z.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Z.RIGHT)===Z.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},h=_=>{const v=this._findPointerById(_.pointerId);if(!(v&&v===this._lockedPointer)){if(v&&this._disposePointer(v),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=f.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=f.NONE;x()}};let d=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===f.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),j=_.clientX/O.width,W=_.clientY/O.height;if(j<this._interactiveArea.left||j>this._interactiveArea.right||W<this._interactiveArea.top||W>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===f.ROTATE||this.mouseButtons.wheel===f.TRUCK){const O=performance.now();d-O<1e3&&this._getClientRect(this._elementRect),d=O}const v=Xn?-1:-3,C=_.deltaMode===1?_.deltaY/v:_.deltaY/(v*10),E=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,P=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case f.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case f.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case f.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case f.DOLLY:{this._dollyInternal(-C,E,P),this._isUserControllingDolly=!0;break}case f.ZOOM:{this._zoomInternal(-C,E,P),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ve.ACTION.NONE){const v=_ instanceof PointerEvent?_.pointerId:0,C=this._findPointerById(v);C&&this._disposePointer(C),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}_.preventDefault()}},g=_=>{if(!this._enabled)return;if(Wt(this._activePointers,ae),this._getClientRect(this._elementRect),i.copy(ae),n.copy(ae),this._activePointers.length>=2){const C=ae.x-this._activePointers[1].clientX,E=ae.y-this._activePointers[1].clientY,P=Math.sqrt(C*C+E*E);a.set(0,P);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,j=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(O,j)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Z.LEFT)===Z.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Z.MIDDLE)===Z.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Z.RIGHT)===Z.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&f.ROTATE)===f.ROTATE||(this._state&f.TOUCH_ROTATE)===f.TOUCH_ROTATE||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.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&f.TRUCK)===f.TRUCK||(this._state&f.TOUCH_TRUCK)===f.TOUCH_TRUCK||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&f.DOLLY)===f.DOLLY||(this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&f.ZOOM)===f.ZOOM||(this._state&f.TOUCH_ZOOM)===f.TOUCH_ZOOM||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&f.OFFSET)===f.OFFSET||(this._state&f.TOUCH_OFFSET)===f.TOUCH_OFFSET||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.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,Wt(this._activePointers,ae);const v=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,C=v?-v.deltaX:n.x-ae.x,E=v?-v.deltaY:n.y-ae.y;if(n.copy(ae),((this._state&f.ROTATE)===f.ROTATE||(this._state&f.TOUCH_ROTATE)===f.TOUCH_ROTATE||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(C,E),this._isUserControllingRotate=!0),(this._state&f.DOLLY)===f.DOLLY||(this._state&f.ZOOM)===f.ZOOM){const P=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,O=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,j=this.dollyDragInverted?-1:1;(this._state&f.DOLLY)===f.DOLLY?(this._dollyInternal(j*E*Ct,P,O),this._isUserControllingDolly=!0):(this._zoomInternal(j*E*Ct,P,O),this._isUserControllingZoom=!0)}if((this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_ZOOM)===f.TOUCH_ZOOM||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE){const P=ae.x-this._activePointers[1].clientX,O=ae.y-this._activePointers[1].clientY,j=Math.sqrt(P*P+O*O),W=a.y-j;a.set(0,j);const he=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,Se=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET?(this._dollyInternal(W*Ct,he,Se),this._isUserControllingDolly=!0):(this._zoomInternal(W*Ct,he,Se),this._isUserControllingZoom=!0)}((this._state&f.TRUCK)===f.TRUCK||(this._state&f.TOUCH_TRUCK)===f.TOUCH_TRUCK||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(C,E,!1),this._isUserControllingTruck=!0),((this._state&f.OFFSET)===f.OFFSET||(this._state&f.TOUCH_OFFSET)===f.TOUCH_OFFSET||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(C,E,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},x=()=>{Wt(this._activePointers,ae),n.copy(ae),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",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",M),this._domElement.ownerDocument.addEventListener("pointerlockerror",T),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),g())},this.unlockPointer=()=>{var _,v,C;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(v=this._domElement)===null||v===void 0||v.ownerDocument.removeEventListener("pointerlockchange",M),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockerror",T),this.cancel()};const M=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},T=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",M),this._domElement.ownerDocument.removeEventListener("pointerlockerror",T))},this.cancel=()=>{this._state!==f.NONE&&(this._state=f.NONE,this._activePointers.length=0,x())},t&&this.connect(t),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=me(e.width,0,1),this._interactiveArea.height=me(e.height,0,1),this._interactiveArea.x=me(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=me(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const n=me(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=me(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!i||z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0,this._dollyToNoClamp(me(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),l=z(r,this._spherical.radius);if(!(i>e)&&l)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(st).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=me(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||z(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),_e.setFromMatrixColumn(this._camera.matrix,0),ge.setFromMatrixColumn(this._camera.matrix,1),_e.multiplyScalar(e),ge.multiplyScalar(-t);const n=L.copy(_e).add(ge),a=F.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,i)}forward(e,t=!1){L.setFromMatrixColumn(this._camera.matrix,0),L.crossVectors(this._camera.up,L),L.multiplyScalar(e);const i=F.copy(this._targetEnd).add(L);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return L.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+L.x,this._targetEnd.y+L.y,this._targetEnd.z+L.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;const a=L.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const r=!n||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,n=!1){const l=L.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(l.x,l.y,l.z,n)}fitToBox(e,t,{cover:i=!1,paddingLeft:n=0,paddingRight:a=0,paddingBottom:r=0,paddingTop:l=0}={}){const h=[],d=e.isBox3?We.copy(e):We.setFromObject(e);d.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Fi(this._sphericalEnd.theta,ji),m=Fi(this._sphericalEnd.phi,ji);h.push(this.rotateTo(p,m,t));const g=L.setFromSpherical(this._sphericalEnd).normalize(),y=Yi.setFromUnitVectors(g,$t),x=z(Math.abs(g.y),1);x&&y.multiply(Kt.setFromAxisAngle(St,p)),y.multiply(this._yAxisUpSpaceInverse);const M=Vi.makeEmpty();F.copy(d.min).applyQuaternion(y),M.expandByPoint(F),F.copy(d.min).setX(d.max.x).applyQuaternion(y),M.expandByPoint(F),F.copy(d.min).setY(d.max.y).applyQuaternion(y),M.expandByPoint(F),F.copy(d.max).setZ(d.min.z).applyQuaternion(y),M.expandByPoint(F),F.copy(d.min).setZ(d.max.z).applyQuaternion(y),M.expandByPoint(F),F.copy(d.max).setY(d.min.y).applyQuaternion(y),M.expandByPoint(F),F.copy(d.max).setX(d.min.x).applyQuaternion(y),M.expandByPoint(F),F.copy(d.max).applyQuaternion(y),M.expandByPoint(F),M.min.x-=n,M.min.y-=r,M.max.x+=a,M.max.y+=l,y.setFromUnitVectors($t,g),x&&y.premultiply(Kt.invert()),y.premultiply(this._yAxisUpSpace);const T=M.getSize(L),_=M.getCenter(F).applyQuaternion(y);if(Ae(this._camera)){const v=this.getDistanceToFitBox(T.x,T.y,T.z,i);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.dollyTo(v,t)),h.push(this.setFocalOffset(0,0,0,t))}else if(xe(this._camera)){const v=this._camera,C=v.right-v.left,E=v.top-v.bottom,P=i?Math.max(C/T.x,E/T.y):Math.min(C/T.x,E/T.y);h.push(this.moveTo(_.x,_.y,_.z,t)),h.push(this.zoomTo(P,t)),h.push(this.setFocalOffset(0,0,0,t))}return Promise.all(h)}fitToSphere(e,t){const i=[],a="isObject3D"in e?ve.createBoundingSphere(e,qt):qt.copy(e);if(i.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),Ae(this._camera)){const r=this.getDistanceToFitSphere(a.radius);i.push(this.dollyTo(r,t))}else if(xe(this._camera)){const r=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,h=2*a.radius,d=Math.min(r/h,l/h);i.push(this.zoomTo(d,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,n,a,r,l=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const h=F.set(n,a,r),d=L.set(e,t,i);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(d.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!l||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,i,n,a,r,l,h,d,p,m,g,y,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const M=L.set(n,a,r),T=F.set(e,t,i);ue.setFromVector3(T.sub(M).applyQuaternion(this._yAxisUpSpace));const _=Ze.set(p,m,g),v=F.set(l,h,d);nt.setFromVector3(v.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(M.lerp(_,y));const C=nt.theta-ue.theta,E=nt.phi-ue.phi,P=nt.radius-ue.radius;this._sphericalEnd.set(ue.radius+P*y,ue.phi+E*y,ue.theta+C*y),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!x||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(O)}setPosition(e,t,i,n=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,i,n=!1){const a=this.getPosition(L),r=this.setLookAt(a.x,a.y,a.z,e,t,i,n);return this._sphericalEnd.phi=me(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,i,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const a=!n||z(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&z(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&z(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),_e.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ge.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ie.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=L.set(e,t,i),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);_e.multiplyScalar(r.x),ge.multiplyScalar(r.y),Ie.multiplyScalar(r.z),L.copy(_e).add(ge).add(Ie),L.z=L.z+a,this.dollyTo(a,!1),this.setFocalOffset(-L.x,L.y,-L.z,!1),this.moveTo(e,t,i,!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,t,i,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new A.Vector4,typeof e=="number"?this._viewport.set(e,t,i,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,n=!1){if(Xt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*et,l=this._camera.aspect;return((n?a>l:a<l)?t:e/l)*.5/Math.tan(r*.5)+i*.5}getDistanceToFitSphere(e){if(Xt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*et,i=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:i;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new A.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new A.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ge,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ge),this._spherical.theta+=Ge*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ge)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!z(this._camera.up.x,this._cameraUp0.x)||!z(this._camera.up.y,this._cameraUp0.y)||!z(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(L);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[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(t)}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,St),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=L.subVectors(this._target,this._camera.position).normalize(),t=F.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(L);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,a=Hi.subVectors(this._targetEnd,this._target),r=Bi.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(Y(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Et(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(Y(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Et(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(Y(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Et(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(Y(a.x)&&Y(a.y)&&Y(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Ni(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Y(r.x)&&Y(r.y)&&Y(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Ni(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Y(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Et(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Ae(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,g=this._camera,y=this._getCameraDirection(st),x=L.copy(y).cross(g.up).normalize();x.lengthSq()===0&&(x.x=1);const M=F.crossVectors(x,y),T=this._sphericalEnd.radius*Math.tan(g.getEffectiveFOV()*et*.5),v=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,C=Ze.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*T*g.aspect)).add(M.multiplyScalar(this._dollyControlCoord.y*T)),E=L.copy(this._targetEnd).lerp(C,v),P=this._lastDollyDirection===Ye.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===Ye.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(P||O)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const W=F.copy(y).multiplyScalar(-m);E.add(W)}this._boundary.clampPoint(E,E);const j=F.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(j),this._changedDolly-=m,Y(this._changedDolly)&&(this._changedDolly=0)}else if(xe(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,g=this._camera,y=L.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(g.near+g.far)/(g.near-g.far)).unproject(g),x=F.set(0,0,-1).applyQuaternion(g.quaternion),M=Ze.copy(y).add(x.multiplyScalar(-y.dot(g.up))),_=-(this._zoom-m-this._zoom)/this._zoom,v=this._getCameraDirection(st),C=this._targetEnd.dot(v),E=L.copy(this._targetEnd).lerp(M,_),P=E.dot(v),O=v.multiplyScalar(P-C);E.sub(O),this._boundary.clampPoint(E,E);const j=F.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(j),this._changedZoom-=m,Y(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const h=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,h),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Y(this._focalOffset.x)||!Y(this._focalOffset.y)||!Y(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),_e.setFromMatrixColumn(this._camera.matrix,0),ge.setFromMatrixColumn(this._camera.matrix,1),Ie.setFromMatrixColumn(this._camera.matrix,2),_e.multiplyScalar(this._focalOffset.x),ge.multiplyScalar(-this._focalOffset.y),Ie.multiplyScalar(this._focalOffset.z),L.copy(_e).add(ge).add(Ie),this._camera.position.add(L)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),L.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Y(t,this.restThreshold)&&Y(i,this.restThreshold)&&Y(n,this.restThreshold)&&Y(a.x,this.restThreshold)&&Y(a.y,this.restThreshold)&&Y(a.z,this.restThreshold)&&Y(r.x,this.restThreshold)&&Y(r.y,this.restThreshold)&&Y(r.z,this.restThreshold)&&Y(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:tt(this.maxDistance),minZoom:this.minZoom,maxZoom:tt(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:tt(this.maxPolarAngle),minAzimuthAngle:tt(this.minAzimuthAngle),maxAzimuthAngle:tt(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:L.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,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=it(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=it(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=it(i.maxPolarAngle),this.minAzimuthAngle=it(i.minAzimuthAngle),this.maxAzimuthAngle=it(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this.verticalDragToForward=i.verticalDragToForward,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),ue.setFromVector3(L.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ue.theta,ue.phi,t),this.dollyTo(ue.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Wn),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(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const n=t.lengthSq();if(n===0)return e;const a=F.copy(t).add(e),l=this._boundary.clampPoint(a,Ze).sub(a),h=l.lengthSq();if(h===0)return e.add(t);if(h===n)return e;if(i===0)return e.add(t).add(l);{const d=1+i*h/t.dot(l);return e.add(F.copy(t).multiplyScalar(d)).add(l.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ae(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*et,n=Math.tan(i*.5)*t,a=n*e.aspect;this._nearPlaneCorners[0].set(-a,-n,0),this._nearPlaneCorners[1].set(a,-n,0),this._nearPlaneCorners[2].set(a,n,0),this._nearPlaneCorners[3].set(-a,n,0)}else if(xe(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,n=e.right*t,a=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(i,a,0),this._nearPlaneCorners[1].set(n,a,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(i,r,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Xt(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(st);Jt.lookAt(zi,i,this._camera.up);for(let n=0;n<4;n++){const a=F.copy(this._nearPlaneCorners[n]);a.applyMatrix4(Jt);const r=Ze.addVectors(this._target,a);wt.set(r,i),wt.far=this._spherical.radius+1;const l=wt.intersectObjects(this.colliderMeshes);l.length!==0&&l[0].distance<e&&(e=l[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_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,t=new A.Sphere){const i=t,n=i.center;We.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&We.expandByObject(r)}),We.getCenter(n);let a=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const l=r,h=l.geometry.clone();h.applyMatrix4(l.matrixWorld);const p=h.attributes.position;for(let m=0,g=p.count;m<g;m++)L.fromBufferAttribute(p,m),a=Math.max(a,n.distanceToSquared(L))}),i.radius=Math.sqrt(a),i}}const It=s=>{const[e,t]=w.useState(s.options[s.index]),i=()=>{s.onToggle(!s.open)},n=a=>{a!==e&&(s.onSelect(a),t(a)),s.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${s.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:i,children:`${s.title}: ${e}`}),s.open&&u.jsx("ul",{className:"dropdown-menu",children:s.options.map(a=>u.jsx("li",{onClick:()=>n(a),children:a},a))})]})},Le=w.forwardRef(function(e,t){const i=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=w.useState("Renderer"),[r,l]=w.useState(!1),[h,d]=w.useState(!1),[p,m]=w.useState(!1);return u.jsxs("div",{className:`CameraWindow ${e.name}`,children:[u.jsx("div",{ref:t,className:"clickable",onClick:()=>{p&&m(!1)}}),u.jsxs("div",{className:"options",children:[e.camera!==null&&u.jsx(It,{title:"Camera",index:e.options.indexOf(e.camera.name),open:p,options:e.options,onSelect:e.onSelectCamera,onToggle:g=>{m(g)},up:!0}),u.jsx(It,{title:"Mode",index:i.indexOf(n),open:h,options:i,onSelect:g=>{if(g===n)return;const y=g;e.onSelectRenderMode(y),a(y)},onToggle:g=>{r&&l(!1),d(g)},up:!0})]})]})});class Qn extends o.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},glslVersion:o.GLSL3,side:o.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 o.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
|
36
36
|
uniform float uDistance;
|
37
37
|
|
38
38
|
void main() {
|
@@ -108,7 +108,7 @@ C11,8.22,10.74,8,10.43,8z`})});function as(s){return u.jsx(es.Reorder.Item,{valu
|
|
108
108
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
109
109
|
|
110
110
|
if (fragColor.a <= 0.0) discard;
|
111
|
-
}`,name:"InfiniteGrid",depthWrite:!1})}}class
|
111
|
+
}`,name:"InfiniteGrid",depthWrite:!1})}}class $n extends o.Mesh{gridMaterial;constructor(){const e=new Qn;super(new o.PlaneGeometry(2,2),e),this.gridMaterial=e,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const qn=`#include <common>
|
112
112
|
#include <batching_pars_vertex>
|
113
113
|
#include <uv_pars_vertex>
|
114
114
|
#include <color_pars_vertex>
|
@@ -138,7 +138,7 @@ void main() {
|
|
138
138
|
#include <logdepthbuf_vertex>
|
139
139
|
#include <clipping_planes_vertex>
|
140
140
|
#include <worldpos_vertex>
|
141
|
-
}`,
|
141
|
+
}`,Kn=`
|
142
142
|
#include <common>
|
143
143
|
#include <uv_pars_fragment>
|
144
144
|
#include <clipping_planes_pars_fragment>
|
@@ -146,4 +146,4 @@ void main() {
|
|
146
146
|
void main() {
|
147
147
|
#include <clipping_planes_fragment>
|
148
148
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
149
|
-
}`;class $n extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Xn,fragmentShader:Qn})}}const Le=new o.Raycaster,ie=new o.Vector3,Se=new o.Vector3,G=new o.Quaternion,Yi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},Jt={type:"change"},Gi={type:"mouseDown",mode:null},Zi={type:"mouseUp",mode:null},Wi={type:"objectChange"};class qn extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new sr(this);this._root=i;const n=new nr;this._gizmo=n,i.add(n);const a=new rr;this._plane=a,i.add(a);const r=this;function l(C,E){let P=E;Object.defineProperty(r,C,{get:function(){return P!==void 0?P:E},set:function(O){P!==O&&(P=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(Jt))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const d=new o.Vector3,h=new o.Vector3,p=new o.Quaternion,f=new o.Quaternion,g=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,M=new o.Vector3,T=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",d),l("worldPositionStart",h),l("worldQuaternion",p),l("worldQuaternionStart",f),l("cameraPosition",g),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",M),l("rotationAxis",T),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=Kn.bind(this),this._onPointerDown=er.bind(this),this._onPointerHover=Jn.bind(this),this._onPointerMove=tr.bind(this),this._onPointerUp=ir.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Le.setFromCamera(e,this.camera);const t=ei(this._gizmo.picker[this.mode],Le);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Le.setFromCamera(e,this.camera);const t=ei(this._plane,Le,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Gi.mode=this.mode,this.dispatchEvent(Gi)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let a=this.space;if(i==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Le.setFromCamera(e,this.camera);const r=ei(this._plane,Le,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(ie.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(ie.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Se.set(l,l,l)}else ie.copy(this.pointStart),Se.copy(this.pointEnd),ie.applyQuaternion(this._worldQuaternionInv),Se.applyQuaternion(this._worldQuaternionInv),Se.divide(ie),t.search("X")===-1&&(Se.x=1),t.search("Y")===-1&&(Se.y=1),t.search("Z")===-1&&(Se.z=1);n.scale.copy(this._scaleStart).multiply(Se),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(ie.setFromMatrixPosition(this.camera.matrixWorld));let d=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ie.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Yi[t]),ie.copy(Yi[t]),a==="local"&&ie.applyQuaternion(this.worldQuaternion),ie.cross(this.eye),ie.length()===0?d=!0:this.rotationAngle=this._offset.dot(ie.normalize())*l),(t==="E"||d)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Jt),this.dispatchEvent(Wi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Zi.mode=this.mode,this.dispatchEvent(Zi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Jt),this.dispatchEvent(Wi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Le}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Kn(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function Jn(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function er(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function tr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function ir(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ei(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const xt=new o.Euler,V=new o.Vector3(0,1,0),Xi=new o.Vector3(0,0,0),Qi=new o.Matrix4,Ot=new o.Quaternion,Pt=new o.Quaternion,ge=new o.Vector3,$i=new o.Matrix4,lt=new o.Vector3(1,0,0),ke=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class sr extends o.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}}class nr extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const a=e.clone();a.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const l=e.clone();l.color.setHex(255);const d=e.clone();d.color.setHex(16711680),d.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const f=e.clone();f.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const M=new o.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Te){const ne=new o.TorusGeometry(X,.0075,3,64,Te*Math.PI*2);return ne.rotateY(Math.PI/2),ne.rotateX(Math.PI/2),ne}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const P={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(M,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(v,r)]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),f.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),i)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),g),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Ce={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),i)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),i)]]},Qe={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(T,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),f.clone())]]},je={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Te=new o.Object3D;for(const ne in X)for(let be=X[ne].length;be--;){const te=X[ne][be][0].clone(),Me=X[ne][be][1],Pe=X[ne][be][2],Re=X[ne][be][3],pt=X[ne][be][4];te.name=ne,te.tag=pt,Me&&te.position.set(Me[0],Me[1],Me[2]),Pe&&te.rotation.set(Pe[0],Pe[1],Pe[2]),Re&&te.scale.set(Re[0],Re[1],Re[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Te.add(te)}return Te}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(P)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(Ce)),this.add(this.picker.scale=J(je)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Pt;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(ke).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),V.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Qi.lookAt(Xi,V,ke)),r.quaternion.multiply(G),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),ie.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ie.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ie),r.visible=this.dragging):(r.quaternion.copy(i),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(V.copy(ke).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(V.copy(ke).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(i),V.copy(this.eye).applyQuaternion(G.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Qi.lookAt(this.eye,Xi,ke)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-V.y,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(ke,Math.atan2(V.x,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(V.y,V.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(d){return r.name===d}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class rr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:Pt),rt.copy(ke).applyQuaternion(t==="local"?this.worldQuaternion:Pt),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:Pt),V.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":V.copy(this.eye).cross(Tt),ge.copy(Tt).cross(V);break;case"Y":V.copy(this.eye).cross(rt),ge.copy(rt).cross(V);break;case"Z":V.copy(this.eye).cross(at),ge.copy(at).cross(V);break;case"XY":ge.copy(at);break;case"YZ":ge.copy(Tt);break;case"XZ":V.copy(at),ge.copy(rt);break;case"XYZ":case"E":ge.set(0,0,0);break}break;case"rotate":default:ge.set(0,0,0)}ge.length()===0?this.quaternion.copy(this.cameraQuaternion):($i.lookAt(ie.set(0,0,0),ge,V),this.quaternion.setFromRotationMatrix($i)),super.updateMatrixWorld(e)}}class le extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;groups=[];clear(){for(const e of this.controls.values()){e.detach(),e.dispose();const t=e.getHelper();t.parent?.remove(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const i=document.querySelector(".clickable");t=new qn(this.activeCamera,i),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:le.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:le.DRAG_END})}),t.addEventListener("dragging-changed",a=>{ve.instance?.toggleOrbitControls(a.value)});const n=`Controls: ${e}`;this.groups.push(n),this.three.addGroup({title:n,items:[{type:"boolean",prop:"enabled",value:t.enabled},{type:"boolean",prop:"visible",value:!0},{type:"button",prop:"Reset"},{type:"option",prop:"Mode",options:[{title:"Translate",value:"translate"},{title:"Rotate",value:"rotate"},{title:"Scale",value:"scale"}]},{type:"option",prop:"Space",options:[{title:"World",value:"world"},{title:"Local",value:"local"}]}],onUpdate:(a,r)=>{if(t!==void 0)switch(a){case"enabled":t.enabled=r;break;case"visible":t.getHelper().visible=r;break;case"Reset":t.reset();break;case"Mode":t.setMode(r);break;case"Space":t.setSpace(r);break}}})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),Oe(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(i=>{i.camera!==e&&(i.camera=e,e.getWorldPosition(i.cameraPosition),e.getWorldQuaternion(i.cameraQuaternion)),i.domElement!==t&&(i.disconnect(),i.domElement=t,i.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),i=this.visibility.get(t.name);i!==void 0&&(t.visible=i)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}static get instance(){return le._instance||(le._instance=new le),le._instance}}const ar=new o.BoxGeometry,ti=new o.Vector2;class or extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const i=new o.Color(Be(.5,1,Math.random()),Be(.5,1,Math.random()),Be(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:i}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=i,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:i})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),le.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([Xe(t.position.x,3),Xe(t.position.y,3),Xe(t.position.z,3)])}),ts({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let i=0;i<t;i++)this.addPoint(e[i],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const i=this.draggable.children.length,n=new o.Mesh(ar,this.draggedMat);return n.name=`point_${i}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const i=this.addPoint(t);this._transform?.attach(i),this.group.current?.setField("Current Point",i.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}Oe(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!ve.instance)return;const i=ve.instance.currentWindow.current.getBoundingClientRect();ti.x=(e.clientX-i.x)/i.width*2-1,ti.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ti,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=le.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),ve.instance?.scene.add(this._transform.getHelper());const i=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(n,a)=>{switch(n){case"Closed":this.closed=a,this.updateSpline();break;case"Visible":this.visible=a;break;case"Color":this.lineMaterial.color.setStyle(a),this.draggedMat.color.setStyle(a);break;case"Curve":this.curveType=a,this.updateSpline();break;case"Draggable Scale":this.draggableScale=a;break;case"Subdivide":this.subdivide=a,this.updateSpline();break;case"Tension":this.tension=a,this.updateSpline();break;case"New Pt Offset":this.offset=a;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(a));break;case"Show Position":this.curvePos.visible=a;break;case"Show Points":this.draggable.visible=a;break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":Oe(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let qi=0;class lr extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e}initDebug(){this.group=$.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){$.removeEditorGroup(this.name)}createSpline=(e=[])=>{const t=`Spline ${qi+1}`,i=new or(t,this._camera);return i.draggableScale=this.defaultScale,i.addPoints(e),i.hideTransform(),this.group?.current!==null&&i.initDebug(this.group.current),this.add(i),qi++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCurve=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const Ki=["Single","Side by Side","Stacked","Quad"];class ve extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new Wn;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new $n;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.canvasRef=w.createRef(),this.containerRef=w.createRef(),this.tlWindow=w.createRef(),this.trWindow=w.createRef(),this.blWindow=w.createRef(),this.brWindow=w.createRef();const t=e.three.app.appID,i=localStorage,n=i.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},i.setItem(`${t}_mode`,this.state.mode),i.setItem(`${t}_tlCam`,i.getItem(`${t}_tlCam`)!==null?i.getItem(`${t}_tlCam`):"Debug"),i.setItem(`${t}_trCam`,i.getItem(`${t}_trCam`)!==null?i.getItem(`${t}_trCam`):"Orthographic"),i.setItem(`${t}_blCam`,i.getItem(`${t}_blCam`)!==null?i.getItem(`${t}_blCam`):"Front"),i.setItem(`${t}_brCam`,i.getItem(`${t}_brCam`)!==null?i.getItem(`${t}_brCam`):"Top"),i.setItem(`${t}_tlRender`,i.getItem(`${t}_tlRender`)!==null?i.getItem(`${t}_tlRender`):"Renderer"),i.setItem(`${t}_trRender`,i.getItem(`${t}_trRender`)!==null?i.getItem(`${t}_trRender`):"Renderer"),i.setItem(`${t}_blRender`,i.getItem(`${t}_blRender`)!==null?i.getItem(`${t}_blRender`):"Renderer"),i.setItem(`${t}_brRender`,i.getItem(`${t}_brRender`)!==null?i.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ye.install({THREE:a}),this.setupScene(),this.setupTools(),ve.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),le.instance.three=this.props.three,le.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,i){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,i)=>{e.push(i)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Ie,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Ie,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Ie,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Ie,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Ie,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Ie,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.blCam),this.blCam=i,localStorage.setItem(`${this.appID}_blCam`,i.name),this.createControls(i,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Ie,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.brCam),this.brCam=i,localStorage.setItem(`${this.appID}_brCam`,i.name),this.createControls(i,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(At,{title:"View",index:Ki.indexOf(this.state.mode),options:Ki,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),u.jsx(At,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.axisHelper.name="axisHelper",this.helpersContainer.add(this.axisHelper),this.interactionHelper.name="interactionHelper",this.helpersContainer.add(this.interactionHelper),this.interactionHelper.visible=!1;const e=(n,a)=>{const r=new o.OrthographicCamera(-100,100,100,-100,50,5e3);return r.name=n,r.position.copy(a),r.lookAt(0,0,0),this.cameras.set(n,r),r};e("Top",new o.Vector3(0,1e3,0)),e("Bottom",new o.Vector3(0,-1e3,0)),e("Left",new o.Vector3(-1e3,0,0)),e("Right",new o.Vector3(1e3,0,0)),e("Front",new o.Vector3(0,0,1e3)),e("Back",new o.Vector3(0,0,-1e3)),e("Orthographic",new o.Vector3(1e3,1e3,1e3)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const t=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(t.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new lr(this.currentCamera),this.splineEditor.initDebug(),this.scene.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.controls.forEach(e=>{e.update()}),this.cameraHelpers.forEach(e=>{e.update()}),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),D.addEventListener(R.SET_SCENE,this.sceneUpdate),D.addEventListener(R.ADD_CAMERA,this.addCamera),D.addEventListener(R.REMOVE_CAMERA,this.removeCamera),D.addEventListener(R.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),D.removeEventListener(R.SET_SCENE,this.sceneUpdate),D.removeEventListener(R.ADD_CAMERA,this.addCamera),D.removeEventListener(R.REMOVE_CAMERA,this.removeCamera),D.removeEventListener(R.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let i=this.width,n=this.height;switch(this.state.mode){case"Side by Side":i=e,n=this.height;break;case"Stacked":i=this.width,n=t;break;case"Quad":i=e,n=t;break}const a=i/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=i/-2,r.right=i/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof o.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix(),this.cameraHelpers.get(r.name)?.update())})};sceneUpdate=e=>{this.helpersContainer.add(this.axisHelper),this.clearLightHelpers(),this.scene.remove(this.currentScene),Oe(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const i=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(i),this.currentScene=i,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0&&this.cameras.set(t.name,i),i instanceof o.PerspectiveCamera){const n=new o.CameraHelper(i);this.cameraHelpers.set(i.name,n),this.scene.add(n)}this.setState({lastUpdate:Date.now()})};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const i=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=He(i,0,t.x,-1,1),this.pointer.y=He(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=He(i,0,a,-1,1):this.pointer.x=He(i,a,t.x,-1,1)},d=()=>{n<r?this.pointer.y=He(n,0,r,1,-1):this.pointer.y=He(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),d();break;case"Side by Side":l();break;case"Stacked":d(),d();break}if(this.updateCamera(i,n,a,r),this.state.interactionMode==="Orbit")return;const h=this.raycaster.intersectObjects(this.currentScene.children);h.length>0&&this.interactionHelper.position.copy(h[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const i=this.raycaster.intersectObjects(this.currentScene.children);i.length>0&&(this.props.three.getObject(i[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(this.clearControls(),this.cameraControls=new ye(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(ki(45),ki(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break}}};onSetSelectedItem=e=>{this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),le.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=le.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform))};onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),kt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Tn(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const i=this.controls.get(e.name);if(i!==void 0&&i.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new Pn(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const i=this.controls.get(e.name);i!==void 0&&(i.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const i=this.cameraHelpers.get(t);i!==void 0&&(this.scene.remove(i),i.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,i,n)=>{switch(this.state.mode){case"Quad":t<n?e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<i?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),le.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const i=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,i),e.object.position.lerp(e.position0,i),e.object.zoom=Rt(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.scene.overrideMaterial=e,this.renderer?.setViewport(0,0,this.width,this.height),this.renderer?.setScissor(0,0,this.width,this.height),this.renderer?.render(this.scene,this.tlCam)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.scene.overrideMaterial=e,this.state.mode==="Side by Side")this.renderer?.setViewport(0,0,i,this.height),this.renderer?.setScissor(0,0,i,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(i,0,i,this.height),this.renderer?.setScissor(i,0,i,this.height),this.renderer?.render(this.scene,this.trCam);else{const a=this.height-n;this.renderer?.setViewport(0,a,this.width,n),this.renderer?.setScissor(0,a,this.width,n),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(0,0,this.width,n),this.renderer?.setScissor(0,0,this.width,n),this.renderer?.render(this.scene,this.trCam)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),r=Math.floor(this.height/2);let l=0,d=0;d=this.height-r,l=0,this.scene.overrideMaterial=e,this.renderer?.setViewport(l,d,a,r),this.renderer?.setScissor(l,d,a,r),this.renderer?.render(this.scene,this.tlCam),l=a,this.scene.overrideMaterial=t,this.renderer?.setViewport(l,d,a,r),this.renderer?.setScissor(l,d,a,r),this.renderer?.render(this.scene,this.trCam),d=0,l=0,this.scene.overrideMaterial=i,this.renderer?.setViewport(l,d,a,r),this.renderer?.setScissor(l,d,a,r),this.renderer?.render(this.scene,this.blCam),l=a,this.scene.overrideMaterial=n,this.renderer?.setViewport(l,d,a,r),this.renderer?.setScissor(l,d,a,r),this.renderer?.render(this.scene,this.brCam)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}}class kt extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e),this.state={lastUpdated:0,expanded:!1},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),kt.instance=this}update(){if(ve.instance){const e=ve.instance.selectedItem;if(e===void 0)return;this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(me,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"grid3",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e}},this.state.lastUpdated)}updateTransform=(e,t)=>{const i=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,i);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);q(a,e,i)}}}function Ji(s){switch(s){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 s}function cr(s,e){const t=[];if(s.lightInfo!==void 0)for(const i in s.lightInfo){const n=s.lightInfo[i];n!==void 0&&(n.isColor!==void 0?t.push({title:Ji(i),prop:i,type:"color",value:n,onChange:(a,r)=>{const l=new o.Color(r);e.updateObject(s.uuid,a,l);const d=e.getScene(s.uuid);if(d!==null){const h=d.getObjectByProperty("uuid",s.uuid);q(h,a,l)}}}):t.push({title:Ji(i),prop:i,type:typeof n,value:n,step:typeof n=="number"?.01:void 0,onChange:(a,r)=>{e.updateObject(s.uuid,a,r);const l=e.getScene(s.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",s.uuid);q(d,a,r)}}}))}return u.jsx(me,{title:"Light",items:t})}function hr(s,e){const t=[],i=[];let n=0;s.animations.forEach(r=>{n=Math.max(n,r.duration),r.duration>0&&i.push({title:r.name,items:[{title:"Duration",type:"number",value:r.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),t.push({title:"Animations",items:i});const a=e.getScene(s.uuid);if(a!==null){const r=a.getObjectByProperty("uuid",s.uuid);let l=!1;if(r!==void 0){const d=r.mixer;if(l=d!==void 0,l){const h=[{title:"Time Scale",type:"range",value:d.timeScale,step:.01,min:-1,max:2,onChange:(p,f)=>{d.timeScale=f,e.updateObject(s.uuid,"mixer.timeScale",f)}}];h.push({title:"Stop All",type:"button",onChange:()=>{d.stopAllAction(),e.requestMethod(s.uuid,"stopAllAction",void 0,"mixer")}}),t.push({title:"Mixer",items:h})}}}return u.jsx(me,{title:"Animation",items:t})}const ps={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 oe={...ps};function ms(s){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(d){oe={...d.value},t(Date.now())}function l(){oe={...ps},t(Date.now())}return D.addEventListener(R.SET_SCENE,l),D.addEventListener(R.SET_OBJECT,r),()=>{D.removeEventListener(R.SET_SCENE,l),D.removeEventListener(R.SET_OBJECT,r)}},[]);const i=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return u.jsx(ut,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:s.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Mt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(Mt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(Mt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(kt,{object:oe,three:s.three}),n?hr(oe,s.three):null,i.search("camera")>-1?On(oe,s.three):null,i.search("light")>-1?cr(oe,s.three):null,a?Sn(oe,s.three):null]})]})},e)},"Inspector")}function fs(s){const[e]=w.useState([]),[t]=w.useState([]),[i,n]=w.useState(0),a=d=>{const h=d.value;e.push(h),t.push(u.jsx(ut,{label:`Scene: ${h.name}`,scene:h,open:!0,onRefresh:()=>{s.three.refreshScene(h.name)},children:u.jsx(ai,{child:h,scene:h,three:s.three})},Math.random())),n(Date.now())},r=d=>{const h=d.value;for(let p=0;p<e.length;p++)if(h.uuid===e[p].uuid){e[p]=h,t[p]=u.jsx(ut,{label:`Scene: ${h.name}`,scene:h,open:!0,onRefresh:()=>{s.three.refreshScene(h.name)},children:u.jsx(ai,{child:h,scene:h,three:s.three})},Math.random()),n(Date.now());return}},l=d=>{const h=d.value;for(let p=0;p<e.length;p++)if(h.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.useEffect(()=>(D.addEventListener(R.ADD_SCENE,a),D.addEventListener(R.REFRESH_SCENE,r),D.addEventListener(R.REMOVE_SCENE,l),()=>{D.removeEventListener(R.ADD_SCENE,a),D.removeEventListener(R.REFRESH_SCENE,r),D.removeEventListener(R.REMOVE_SCENE,l)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},i),u.jsx(ms,{three:s.three}),u.jsx($,{three:s.three})]})}function dr(s){return w.useEffect(()=>{function e(l){let d=null;return s.three.scenes.forEach(h=>{l.search(h.uuid)>-1&&(d=h)}),d}const t=l=>{const d=l.value,p=e(d)?.getObjectByProperty("uuid",d);p!==void 0&&s.three.setObject(p)},i=(l,d,h)=>{const f=e(l)?.getObjectByProperty("uuid",l);f!==void 0&&q(f,d,h)},n=l=>{const d=l.value,{key:h,value:p,uuid:f}=d;i(f,h,p)},a=l=>{const d=l.value,p=e(d.uuid)?.getObjectByProperty("uuid",d.uuid);if(p!==void 0){const f=g=>{const y=d.key.split(".");switch(y.length){case 1:p[y[0]]=g;break;case 2:p[y[0]][y[1]]=g;break;case 3:p[y[0]][y[1]][y[2]]=g;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=g;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=g;break}p.material.needsUpdate=!0};d.value.src.length>0?rs(d.value.src).then(g=>{g.offset.set(d.value.offset[0],d.value.offset[1]),g.repeat.set(d.value.repeat[0],d.value.repeat[1]),f(g)}):f(null)}},r=l=>{const{key:d,uuid:h,value:p,subitem:f}=l.value,y=e(h)?.getObjectByProperty("uuid",h);if(y!==void 0)try{f!==void 0?qs(y,f)[d](p):y[d](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(d),console.log(p)}};return D.addEventListener(R.GET_OBJECT,t),D.addEventListener(R.UPDATE_OBJECT,n),D.addEventListener(R.CREATE_TEXTURE,a),D.addEventListener(R.REQUEST_METHOD,r),()=>{D.removeEventListener(R.GET_OBJECT,t),D.removeEventListener(R.UPDATE_OBJECT,n),D.removeEventListener(R.CREATE_TEXTURE,a),D.removeEventListener(R.REQUEST_METHOD,r)}},[]),null}function _s(s){return u.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[u.jsx("div",{className:"header",children:s.header}),s.children,u.jsx("div",{className:"footer",children:s.footer})]})}function ur(s){return u.jsx(_s,{children:u.jsxs(u.Fragment,{children:[u.jsx(ve,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),u.jsx(fs,{three:s.three})]})})}exports.Accordion=ut;exports.Application=Ys;exports.BaseRemote=It;exports.ChildObject=di;exports.ContainerObject=ai;exports.Draggable=os;exports.DraggableItem=as;exports.Dropdown=ls;exports.DropdownItem=cs;exports.Editor=_s;exports.ExportTexture=ht;exports.Inspector=ms;exports.MultiView=ve;exports.NavButton=hi;exports.RemoteComponents=Gs;exports.RemoteController=rn;exports.RemoteTheatre=ci;exports.RemoteThree=Js;exports.SceneInspector=dr;exports.SidePanel=fs;exports.ThreeEditor=ur;exports.ToolEvents=R;exports.capitalize=dt;exports.clamp=xe;exports.colorToHex=si;exports.copyToClipboard=ts;exports.customizeTheatreElements=Ws;exports.debugDispatcher=D;exports.defaultTheatreCallback=Hs;exports.dispose=Oe;exports.disposeMaterial=ns;exports.disposeTexture=Vs;exports.distance=Bs;exports.hierarchyUUID=Dt;exports.isColor=ss;exports.mix=Rt;exports.noop=li;exports.normalize=ii;exports.randomID=is;exports.resetThreeObjects=ni;exports.round=Xe;exports.theatreEditorApp=Zs;
|
149
|
+
}`;class Jn extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:qn,fragmentShader:Kn})}}const ke=new o.Raycaster,ie=new o.Vector3,we=new o.Vector3,G=new o.Quaternion,Gi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ei={type:"change"},Zi={type:"mouseDown",mode:null},Wi={type:"mouseUp",mode:null},Xi={type:"objectChange"};class er extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new ar(this);this._root=i;const n=new or;this._gizmo=n,i.add(n);const a=new lr;this._plane=a,i.add(a);const r=this;function l(C,E){let P=E;Object.defineProperty(r,C,{get:function(){return P!==void 0?P:E},set:function(O){P!==O&&(P=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(ei))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,d=new o.Vector3,p=new o.Quaternion,m=new o.Quaternion,g=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,M=new o.Vector3,T=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",h),l("worldPositionStart",d),l("worldQuaternion",p),l("worldQuaternionStart",m),l("cameraPosition",g),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",M),l("rotationAxis",T),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=tr.bind(this),this._onPointerDown=sr.bind(this),this._onPointerHover=ir.bind(this),this._onPointerMove=nr.bind(this),this._onPointerUp=rr.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&ke.setFromCamera(e,this.camera);const t=ti(this._gizmo.picker[this.mode],ke);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&ke.setFromCamera(e,this.camera);const t=ti(this._plane,ke,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Zi.mode=this.mode,this.dispatchEvent(Zi)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let a=this.space;if(i==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&ke.setFromCamera(e,this.camera);const r=ti(this._plane,ke,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(ie.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(ie.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),we.set(l,l,l)}else ie.copy(this.pointStart),we.copy(this.pointEnd),ie.applyQuaternion(this._worldQuaternionInv),we.applyQuaternion(this._worldQuaternionInv),we.divide(ie),t.search("X")===-1&&(we.x=1),t.search("Y")===-1&&(we.y=1),t.search("Z")===-1&&(we.z=1);n.scale.copy(this._scaleStart).multiply(we),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(ie.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ie.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Gi[t]),ie.copy(Gi[t]),a==="local"&&ie.applyQuaternion(this.worldQuaternion),ie.cross(this.eye),ie.length()===0?h=!0:this.rotationAngle=this._offset.dot(ie.normalize())*l),(t==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ei),this.dispatchEvent(Xi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Wi.mode=this.mode,this.dispatchEvent(Wi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ei),this.dispatchEvent(Xi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ke}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function tr(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function ir(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function sr(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function nr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function rr(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ti(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const xt=new o.Euler,V=new o.Vector3(0,1,0),Qi=new o.Vector3(0,0,0),$i=new o.Matrix4,Ot=new o.Quaternion,Rt=new o.Quaternion,ye=new o.Vector3,qi=new o.Matrix4,lt=new o.Vector3(1,0,0),Ue=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class ar extends o.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}}class or extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const a=e.clone();a.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const l=e.clone();l.color.setHex(255);const h=e.clone();h.color.setHex(16711680),h.opacity=.5;const d=e.clone();d.color.setHex(65280),d.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const m=e.clone();m.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const M=new o.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Me){const ne=new o.TorusGeometry(X,.0075,3,64,Me*Math.PI*2);return ne.rotateY(Math.PI/2),ne.rotateX(Math.PI/2),ne}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const P={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(M,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(v,r)]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),i)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),g),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Se={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),i)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),i)]]},Qe={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(T,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},Fe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Me=new o.Object3D;for(const ne in X)for(let Ee=X[ne].length;Ee--;){const te=X[ne][Ee][0].clone(),Pe=X[ne][Ee][1],Re=X[ne][Ee][2],De=X[ne][Ee][3],pt=X[ne][Ee][4];te.name=ne,te.tag=pt,Pe&&te.position.set(Pe[0],Pe[1],Pe[2]),Re&&te.rotation.set(Re[0],Re[1],Re[2]),De&&te.scale.set(De[0],De[1],De[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Me.add(te)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(P)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(Se)),this.add(this.picker.scale=J(Fe)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Rt;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),V.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix($i.lookAt(Qi,V,Ue)),r.quaternion.multiply(G),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),ie.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ie.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ie),r.visible=this.dragging):(r.quaternion.copy(i),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(i),V.copy(this.eye).applyQuaternion(G.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix($i.lookAt(this.eye,Qi,Ue)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-V.y,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(Ue,Math.atan2(V.x,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(V.y,V.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class lr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:Rt),rt.copy(Ue).applyQuaternion(t==="local"?this.worldQuaternion:Rt),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:Rt),V.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":V.copy(this.eye).cross(Tt),ye.copy(Tt).cross(V);break;case"Y":V.copy(this.eye).cross(rt),ye.copy(rt).cross(V);break;case"Z":V.copy(this.eye).cross(at),ye.copy(at).cross(V);break;case"XY":ye.copy(at);break;case"YZ":ye.copy(Tt);break;case"XZ":V.copy(at),ye.copy(rt);break;case"XYZ":case"E":ye.set(0,0,0);break}break;case"rotate":default:ye.set(0,0,0)}ye.length()===0?this.quaternion.copy(this.cameraQuaternion):(qi.lookAt(ie.set(0,0,0),ye,V),this.quaternion.setFromRotationMatrix(qi)),super.updateMatrixWorld(e)}}class le extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;groups=[];clear(){for(const e of this.controls.values()){e.detach(),e.dispose();const t=e.getHelper();t.parent?.remove(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const i=document.querySelector(".clickable");t=new er(this.activeCamera,i),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:le.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:le.DRAG_END})}),t.addEventListener("dragging-changed",a=>{be.instance?.toggleOrbitControls(a.value)});const n=`Controls: ${e}`;this.groups.push(n),this.three.addGroup({title:n,items:[{type:"boolean",prop:"enabled",value:t.enabled},{type:"boolean",prop:"visible",value:!0},{type:"button",prop:"Reset"},{type:"option",prop:"Mode",options:[{title:"Translate",value:"translate"},{title:"Rotate",value:"rotate"},{title:"Scale",value:"scale"}]},{type:"option",prop:"Space",options:[{title:"World",value:"world"},{title:"Local",value:"local"}]}],onUpdate:(a,r)=>{if(t!==void 0)switch(a){case"enabled":t.enabled=r;break;case"visible":t.getHelper().visible=r;break;case"Reset":t.reset();break;case"Mode":t.setMode(r);break;case"Space":t.setSpace(r);break}}})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),Te(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(i=>{i.camera!==e&&(i.camera=e,e.getWorldPosition(i.cameraPosition),e.getWorldQuaternion(i.cameraQuaternion)),i.domElement!==t&&(i.disconnect(),i.domElement=t,i.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),i=this.visibility.get(t.name);i!==void 0&&(t.visible=i)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}static get instance(){return le._instance||(le._instance=new le),le._instance}}const cr=new o.BoxGeometry,ii=new o.Vector2;class Ki extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const i=new o.Color(Ve(.5,1,Math.random()),Ve(.5,1,Math.random()),Ve(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:i}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=i,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:i})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),le.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([pe(t.position.x,3),pe(t.position.y,3),pe(t.position.z,3)])}),is({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let i=0;i<t;i++)this.addPoint(e[i],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const i=this.draggable.children.length,n=new o.Mesh(cr,this.draggedMat);return n.name=`point_${i}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const i=this.addPoint(t);this._transform?.attach(i),this.group.current?.setField("Current Point",i.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}Te(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!be.instance||this._transform&&!this._transform.getHelper().visible)return;const i=be.instance.currentWindow.current.getBoundingClientRect();ii.x=(e.clientX-i.x)/i.width*2-1,ii.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ii,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=le.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),be.instance?.scene.add(this._transform.getHelper());const i=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(n,a)=>{switch(n){case"Closed":this.closed=a,this.updateSpline();break;case"Visible":this.visible=a;break;case"Color":this.lineMaterial.color.setStyle(a),this.draggedMat.color.setStyle(a);break;case"Curve":this.curveType=a,this.updateSpline();break;case"Draggable Scale":this.draggableScale=a;break;case"Subdivide":this.subdivide=a,this.updateSpline();break;case"Tension":this.tension=a,this.updateSpline();break;case"New Pt Offset":this.offset=a;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(a));break;case"Show Position":this.curvePos.visible=a;break;case"Show Points":this.draggable.visible=a;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":Te(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Mt=0;class hr extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,D.addEventListener(R.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=$.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){D.removeEventListener(R.ADD_SPLINE,this.onAddSpline),$.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Mt+1}`,i=new Ki(t,this._camera);return i.addPoints(e),this.addSpline(i),Mt++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCurve=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),i=`Spline ${Mt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],0))});const a=new Ki(i,this.camera);a.addPoints(n),this.addSpline(a),Mt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const Ji=["Single","Side by Side","Stacked","Quad"];class be extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new $n;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new Jn;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.canvasRef=w.createRef(),this.containerRef=w.createRef(),this.tlWindow=w.createRef(),this.trWindow=w.createRef(),this.blWindow=w.createRef(),this.brWindow=w.createRef();const t=e.three.app.appID,i=localStorage,n=i.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},i.setItem(`${t}_mode`,this.state.mode),i.setItem(`${t}_tlCam`,i.getItem(`${t}_tlCam`)!==null?i.getItem(`${t}_tlCam`):"Debug"),i.setItem(`${t}_trCam`,i.getItem(`${t}_trCam`)!==null?i.getItem(`${t}_trCam`):"Orthographic"),i.setItem(`${t}_blCam`,i.getItem(`${t}_blCam`)!==null?i.getItem(`${t}_blCam`):"Front"),i.setItem(`${t}_brCam`,i.getItem(`${t}_brCam`)!==null?i.getItem(`${t}_brCam`):"Top"),i.setItem(`${t}_tlRender`,i.getItem(`${t}_tlRender`)!==null?i.getItem(`${t}_tlRender`):"Renderer"),i.setItem(`${t}_trRender`,i.getItem(`${t}_trRender`)!==null?i.getItem(`${t}_trRender`):"Renderer"),i.setItem(`${t}_blRender`,i.getItem(`${t}_blRender`)!==null?i.getItem(`${t}_blRender`):"Renderer"),i.setItem(`${t}_brRender`,i.getItem(`${t}_brRender`)!==null?i.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ve.install({THREE:a}),this.setupScene(),this.setupTools(),be.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),le.instance.three=this.props.three,le.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,i){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,i)=>{e.push(i)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Le,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.blCam),this.blCam=i,localStorage.setItem(`${this.appID}_blCam`,i.name),this.createControls(i,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Le,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.brCam),this.brCam=i,localStorage.setItem(`${this.appID}_brCam`,i.name),this.createControls(i,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(It,{title:"View",index:Ji.indexOf(this.state.mode),options:Ji,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),u.jsx(It,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.axisHelper.name="axisHelper",this.helpersContainer.add(this.axisHelper),this.interactionHelper.name="interactionHelper",this.helpersContainer.add(this.interactionHelper),this.interactionHelper.visible=!1;const e=(n,a)=>{const r=new o.OrthographicCamera(-100,100,100,-100,50,5e3);return r.name=n,r.position.copy(a),r.lookAt(0,0,0),this.cameras.set(n,r),r};e("Top",new o.Vector3(0,1e3,0)),e("Bottom",new o.Vector3(0,-1e3,0)),e("Left",new o.Vector3(-1e3,0,0)),e("Right",new o.Vector3(1e3,0,0)),e("Front",new o.Vector3(0,0,1e3)),e("Back",new o.Vector3(0,0,-1e3)),e("Orthographic",new o.Vector3(1e3,1e3,1e3)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const t=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(t.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new hr(this.currentCamera),this.splineEditor.initDebug(),this.scene.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.controls.forEach(e=>{e.update()}),this.cameraHelpers.forEach(e=>{e.update()}),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),D.addEventListener(R.SET_SCENE,this.sceneUpdate),D.addEventListener(R.ADD_CAMERA,this.addCamera),D.addEventListener(R.REMOVE_CAMERA,this.removeCamera),D.addEventListener(R.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),D.removeEventListener(R.SET_SCENE,this.sceneUpdate),D.removeEventListener(R.ADD_CAMERA,this.addCamera),D.removeEventListener(R.REMOVE_CAMERA,this.removeCamera),D.removeEventListener(R.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let i=this.width,n=this.height;switch(this.state.mode){case"Side by Side":i=e,n=this.height;break;case"Stacked":i=this.width,n=t;break;case"Quad":i=e,n=t;break}const a=i/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=i/-2,r.right=i/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof o.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix(),this.cameraHelpers.get(r.name)?.update())})};sceneUpdate=e=>{this.helpersContainer.add(this.axisHelper),this.clearLightHelpers(),this.scene.remove(this.currentScene),Te(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const i=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(i),this.currentScene=i,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0&&this.cameras.set(t.name,i),i instanceof o.PerspectiveCamera){const n=new o.CameraHelper(i);this.cameraHelpers.set(i.name,n),this.scene.add(n)}this.setState({lastUpdate:Date.now()})};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const i=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Be(i,0,t.x,-1,1),this.pointer.y=Be(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=Be(i,0,a,-1,1):this.pointer.x=Be(i,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Be(n,0,r,1,-1):this.pointer.y=Be(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),h();break;case"Side by Side":l();break;case"Stacked":h(),h();break}if(this.updateCamera(i,n,a,r),this.state.interactionMode==="Orbit")return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const i=this.raycaster.intersectObjects(this.currentScene.children);i.length>0&&(this.props.three.getObject(i[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(li(45),li(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break}}};onSetSelectedItem=e=>{this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),le.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=le.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform))};onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Ut.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Dn(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const i=this.controls.get(e.name);if(i!==void 0&&i.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new In(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const i=this.controls.get(e.name);i!==void 0&&(i.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const i=this.cameraHelpers.get(t);i!==void 0&&(this.scene.remove(i),i.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,i,n)=>{switch(this.state.mode){case"Quad":t<n?e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<i?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),le.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const i=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,i),e.object.position.lerp(e.position0,i),e.object.zoom=Dt(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.scene.overrideMaterial=e,this.renderer?.setViewport(0,0,this.width,this.height),this.renderer?.setScissor(0,0,this.width,this.height),this.renderer?.render(this.scene,this.tlCam)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.scene.overrideMaterial=e,this.state.mode==="Side by Side")this.renderer?.setViewport(0,0,i,this.height),this.renderer?.setScissor(0,0,i,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(i,0,i,this.height),this.renderer?.setScissor(i,0,i,this.height),this.renderer?.render(this.scene,this.trCam);else{const a=this.height-n;this.renderer?.setViewport(0,a,this.width,n),this.renderer?.setScissor(0,a,this.width,n),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(0,0,this.width,n),this.renderer?.setScissor(0,0,this.width,n),this.renderer?.render(this.scene,this.trCam)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),r=Math.floor(this.height/2);let l=0,h=0;h=this.height-r,l=0,this.scene.overrideMaterial=e,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.tlCam),l=a,this.scene.overrideMaterial=t,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.trCam),h=0,l=0,this.scene.overrideMaterial=i,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.blCam),l=a,this.scene.overrideMaterial=n,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.brCam)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}}class Ut extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e),this.state={lastUpdated:0,expanded:!1},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Ut.instance=this}update(){if(be.instance){const e=be.instance.selectedItem;if(e===void 0)return;this.position.x=pe(e.position.x,3),this.position.y=pe(e.position.y,3),this.position.z=pe(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=pe(e.scale.x,3),this.scale.y=pe(e.scale.y,3),this.scale.z=pe(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(fe,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e}},this.state.lastUpdated)}updateTransform=(e,t)=>{const i=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,i);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);q(a,e,i)}}}function es(s){switch(s){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 s}function dr(s,e){const t=[];if(s.lightInfo!==void 0)for(const i in s.lightInfo){const n=s.lightInfo[i];n!==void 0&&(n.isColor!==void 0?t.push({title:es(i),prop:i,type:"color",value:n,onChange:(a,r)=>{const l=new o.Color(r);e.updateObject(s.uuid,a,l);const h=e.getScene(s.uuid);if(h!==null){const d=h.getObjectByProperty("uuid",s.uuid);q(d,a,l)}}}):t.push({title:es(i),prop:i,type:typeof n,value:n,step:typeof n=="number"?.01:void 0,onChange:(a,r)=>{e.updateObject(s.uuid,a,r);const l=e.getScene(s.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",s.uuid);q(h,a,r)}}}))}return u.jsx(fe,{title:"Light",items:t})}function ur(s,e){const t=[],i=[];let n=0;s.animations.forEach(r=>{n=Math.max(n,r.duration),r.duration>0&&i.push({title:r.name,items:[{title:"Duration",type:"number",value:r.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),t.push({title:"Animations",items:i});const a=e.getScene(s.uuid);if(a!==null){const r=a.getObjectByProperty("uuid",s.uuid);let l=!1;if(r!==void 0){const h=r.mixer;if(l=h!==void 0,l){const d=[{title:"Time Scale",type:"range",value:h.timeScale,step:.01,min:-1,max:2,onChange:(p,m)=>{h.timeScale=m,e.updateObject(s.uuid,"mixer.timeScale",m)}}];d.push({title:"Stop All",type:"button",onChange:()=>{h.stopAllAction(),e.requestMethod(s.uuid,"stopAllAction",void 0,"mixer")}}),t.push({title:"Mixer",items:d})}}}return u.jsx(fe,{title:"Animation",items:t})}const ms={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 oe={...ms};function fs(s){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(h){oe={...h.value},t(Date.now())}function l(){oe={...ms},t(Date.now())}return D.addEventListener(R.SET_SCENE,l),D.addEventListener(R.SET_OBJECT,r),()=>{D.removeEventListener(R.SET_SCENE,l),D.removeEventListener(R.SET_OBJECT,r)}},[]);const i=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return u.jsx(ut,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:s.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Pt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(Pt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(Pt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(Ut,{object:oe,three:s.three}),n?ur(oe,s.three):null,i.search("camera")>-1?Rn(oe,s.three):null,i.search("light")>-1?dr(oe,s.three):null,a?Tn(oe,s.three):null]})]})},e)},"Inspector")}function _s(s){const[e]=w.useState([]),[t]=w.useState([]),[i,n]=w.useState(0),a=h=>{const d=h.value;e.push(d),t.push(u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random())),n(Date.now())},r=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e[p]=d,t[p]=u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random()),n(Date.now());return}},l=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.useEffect(()=>(D.addEventListener(R.ADD_SCENE,a),D.addEventListener(R.REFRESH_SCENE,r),D.addEventListener(R.REMOVE_SCENE,l),()=>{D.removeEventListener(R.ADD_SCENE,a),D.removeEventListener(R.REFRESH_SCENE,r),D.removeEventListener(R.REMOVE_SCENE,l)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},i),u.jsx(fs,{three:s.three}),u.jsx($,{three:s.three})]})}function pr(s){return w.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(d=>{l.search(d.uuid)>-1&&(h=d)}),h}const t=l=>{const h=l.value,p=e(h)?.getObjectByProperty("uuid",h);p!==void 0&&s.three.setObject(p)},i=(l,h,d)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&q(m,h,d)},n=l=>{const h=l.value,{key:d,value:p,uuid:m}=h;i(m,d,p)},a=l=>{const h=l.value,p=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(p!==void 0){const m=g=>{const y=h.key.split(".");switch(y.length){case 1:p[y[0]]=g;break;case 2:p[y[0]][y[1]]=g;break;case 3:p[y[0]][y[1]][y[2]]=g;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=g;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=g;break}p.material.needsUpdate=!0};h.value.src.length>0?as(h.value.src).then(g=>{g.offset.set(h.value.offset[0],h.value.offset[1]),g.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(g)}):m(null)}},r=l=>{const{key:h,uuid:d,value:p,subitem:m}=l.value,y=e(d)?.getObjectByProperty("uuid",d);if(y!==void 0)try{m!==void 0?Ks(y,m)[h](p):y[h](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(p)}};return D.addEventListener(R.GET_OBJECT,t),D.addEventListener(R.UPDATE_OBJECT,n),D.addEventListener(R.CREATE_TEXTURE,a),D.addEventListener(R.REQUEST_METHOD,r),()=>{D.removeEventListener(R.GET_OBJECT,t),D.removeEventListener(R.UPDATE_OBJECT,n),D.removeEventListener(R.CREATE_TEXTURE,a),D.removeEventListener(R.REQUEST_METHOD,r)}},[]),null}function gs(s){return u.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[u.jsx("div",{className:"header",children:s.header}),s.children,u.jsx("div",{className:"footer",children:s.footer})]})}function mr(s){return u.jsx(gs,{children:u.jsxs(u.Fragment,{children:[u.jsx(be,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),u.jsx(_s,{three:s.three})]})})}exports.Accordion=ut;exports.Application=Gs;exports.BaseRemote=Lt;exports.ChildObject=pi;exports.ContainerObject=oi;exports.Draggable=ls;exports.DraggableItem=os;exports.Dropdown=cs;exports.DropdownItem=hs;exports.Editor=gs;exports.ExportTexture=ht;exports.Inspector=fs;exports.MultiView=be;exports.NavButton=ui;exports.RemoteComponents=Zs;exports.RemoteController=an;exports.RemoteTheatre=di;exports.RemoteThree=en;exports.SceneInspector=pr;exports.SidePanel=_s;exports.ThreeEditor=mr;exports.ToolEvents=R;exports.capitalize=dt;exports.clamp=Oe;exports.colorToHex=ni;exports.copyToClipboard=is;exports.customizeTheatreElements=Xs;exports.debugDispatcher=D;exports.defaultTheatreCallback=Bs;exports.dispose=Te;exports.disposeMaterial=rs;exports.disposeTexture=Ys;exports.distance=Vs;exports.hierarchyUUID=At;exports.isColor=ns;exports.mix=Dt;exports.noop=hi;exports.normalize=si;exports.randomID=ss;exports.resetThreeObjects=ri;exports.round=pe;exports.theatreEditorApp=Ws;
|