@tomorrowevening/hermes 0.0.117 → 0.0.119

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,166 +1,166 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),x=require("react"),cs=require("framer-motion"),fi=()=>{},Ks=()=>{};function _t(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function hs(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function ds(){return Math.round(Math.random()*1e6).toString()}function us(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function ai(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),i=Math.round(s.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=n(e),r=n(t),l=n(i);return"#"+a+r+l}const $s=s=>{s?.dispose()},ps=s=>{s&&(Array.isArray(s)?s.forEach(e=>e.dispose()):s.dispose())},Ae=s=>{if(s){for(;s.children.length>0;){const e=s.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Ae(e)}if(s.parent&&s.parent.remove(s),s.isMesh){const e=s;e.geometry?.dispose(),ps(e.material)}s.dispose!==void 0&&s.dispose()}};exports.totalThreeObjects=0;const oi=()=>{exports.totalThreeObjects=0},Ut=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=>Ut(t))};class gt{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}}function Zt(s,e,t,i){return new(t||(t=Promise))(function(n,a){function r(c){try{h(i.next(c))}catch(u){a(u)}}function l(c){try{h(i.throw(c))}catch(u){a(u)}}function h(c){var u;c.done?n(c.value):(u=c.value,u instanceof t?u:new t(function(m){m(u)})).then(r,l)}h((i=i.apply(s,e||[])).next())})}const Js=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function Ii(s){return s=s.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const ms=typeof window>"u",Me=(()=>{if(ms)return;const{userAgent:s,platform:e,maxTouchPoints:t}=window.navigator,i=/(iphone|ipod|ipad)/i.test(s),n=e==="iPad"||e==="MacIntel"&&t>0&&!window.MSStream;return{isIpad:n,isMobile:/android/i.test(s)||i||n,isSafari12:/Version\/12.+Safari/.test(s),isFirefox:/Firefox/.test(s)}})();function en(s,e,t){if(!t)return[e];const i=function(c){const u=`
2
- precision highp float;
3
- attribute vec3 aPosition;
4
- varying float vvv;
5
- void main() {
6
- vvv = 0.31622776601683794;
7
- gl_Position = vec4(aPosition, 1.0);
8
- }
9
- `,m=`
10
- precision highp float;
11
- varying float vvv;
12
- void main() {
13
- vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;
14
- enc = fract(enc);
15
- enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
16
- gl_FragColor = enc;
17
- }
18
- `,f=c.createShader(35633),_=c.createShader(35632),w=c.createProgram();if(!(_&&f&&w))return;c.shaderSource(f,u),c.shaderSource(_,m),c.compileShader(f),c.compileShader(_),c.attachShader(w,f),c.attachShader(w,_),c.linkProgram(w),c.detachShader(w,f),c.detachShader(w,_),c.deleteShader(f),c.deleteShader(_),c.useProgram(w);const T=c.createBuffer();c.bindBuffer(34962,T),c.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const A=c.getAttribLocation(w,"aPosition");c.vertexAttribPointer(A,3,5126,!1,0,0),c.enableVertexAttribArray(A),c.clearColor(1,1,1,1),c.clear(16384),c.viewport(0,0,1,1),c.drawArrays(4,0,3);const g=new Uint8Array(4);return c.readPixels(0,0,1,1,6408,5121,g),c.deleteProgram(w),c.deleteBuffer(T),g.join("")}(s),n="801621810",a="8016218135",r="80162181161",l=Me?.isIpad?[["a7",r,12],["a8",a,15],["a8x",a,15],["a9",a,15],["a9x",a,15],["a10",a,15],["a10x",a,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",r,12],["a8",a,12],["a9",a,15],["a10",a,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let h;return i==="80162181255"?h=l.filter(([,,c])=>c>=14):(h=l.filter(([,c])=>c===i),h.length||(h=l)),h.map(([c])=>`apple ${c} gpu`)}class Li extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const Wt=[],Ui=[];function tn(s,e){if(s===e)return 0;const t=s;s.length>e.length&&(s=e,e=t);let i=s.length,n=e.length;for(;i>0&&s.charCodeAt(~-i)===e.charCodeAt(~-n);)i--,n--;let a,r=0;for(;r<i&&s.charCodeAt(r)===e.charCodeAt(r);)r++;if(i-=r,n-=r,i===0)return n;let l,h,c=0,u=0,m=0;for(;u<i;)Ui[u]=s.charCodeAt(r+u),Wt[u]=++u;for(;m<n;)for(a=e.charCodeAt(r+m),l=m++,c=m,u=0;u<i;u++)h=a===Ui[u]?l:l+1,l=Wt[u],c=Wt[u]=l>c?h>c?c+1:h:h>l?l+1:h;return c}function sn(s){return s!=null}const nn=({mobileTiers:s=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:i,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:a="https://unpkg.com/detect-gpu@5.0.57/dist/benchmarks"}={})=>Zt(void 0,void 0,void 0,function*(){const r={};if(ms)return{tier:0,type:"SSR"};const{isIpad:l=!!Me?.isIpad,isMobile:h=!!Me?.isMobile,screenSize:c=window.screen,loadBenchmarks:u=S=>Zt(void 0,void 0,void 0,function*(){const O=yield fetch(`${a}/${S}`).then(I=>I.json());if(parseInt(O.shift().split(".")[0],10)<4)throw new Li("Detect GPU benchmark data is out of date. Please update to version 4x");return O})}=t;let{renderer:m}=t;const f=(S,O,I,k,q)=>({device:q,fps:k,gpu:I,isMobile:h,tier:S,type:O});let _,w="";if(m)m=Ii(m),_=[m];else{const S=i||function(I,k=!1){const q={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:k,powerPreference:"high-performance",stencil:!1};I&&delete q.powerPreference;const de=window.document.createElement("canvas"),Se=de.getContext("webgl",q)||de.getContext("experimental-webgl",q);return Se??void 0}(Me?.isSafari12,n);if(!S)return f(0,"WEBGL_UNSUPPORTED");const O=Me?.isFirefox?null:S.getExtension("WEBGL_debug_renderer_info");if(m=O?S.getParameter(O.UNMASKED_RENDERER_WEBGL):S.getParameter(S.RENDERER),!m)return f(1,"FALLBACK");w=m,m=Ii(m),_=function(I,k,q){return k==="apple gpu"?en(I,k,q):[k]}(S,m,h)}const T=(yield Promise.all(_.map(function(S){var O;return Zt(this,void 0,void 0,function*(){const I=(B=>{const ne=h?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Ce of ne)if(B.includes(Ce))return Ce})(S);if(!I)return;const k=`${h?"m":"d"}-${I}${l?"-ipad":""}.json`,q=r[k]=(O=r[k])!==null&&O!==void 0?O:u(k);let de;try{de=yield q}catch(B){if(B instanceof Li)throw B;return}const Se=function(B){var ne;const Ce=(B=B.replace(/\([^)]+\)/,"")).match(/\d+/)||B.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(ne=Ce?.join("").replace(/\W|amd/g,""))!==null&&ne!==void 0?ne:""}(S);let ge=de.filter(([,B])=>B===Se);ge.length||(ge=de.filter(([B])=>B.includes(S)));const oe=ge.length;if(oe===0)return;const K=S.split(/[.,()\[\]/\s]/g).sort().filter((B,ne,Ce)=>ne===0||B!==Ce[ne-1]).join(" ");let Z,[Pe,,,,le]=oe>1?ge.map(B=>[B,tn(K,B[2])]).sort(([,B],[,ne])=>B-ne)[0][0]:ge[0],fe=Number.MAX_VALUE;const{devicePixelRatio:ee}=window,Re=c.width*ee*c.height*ee;for(const B of le){const[ne,Ce]=B,tt=ne*Ce,Ye=Math.abs(Re-tt);Ye<fe&&(fe=Ye,Z=B)}if(!Z)return;const[,,De,Ie]=Z;return[fe,De,Pe,Ie]})}))).filter(sn).sort(([S=Number.MAX_VALUE,O],[I=Number.MAX_VALUE,k])=>S===I?O-k:S-I);if(!T.length){const S=Js.find(O=>m.includes(O));return S?f(0,"BLOCKLISTED",S):f(1,"FALLBACK",`${m} (${w})`)}const[,A,g,y]=T[0];if(A===-1)return f(0,"BLOCKLISTED",g,A,y);const E=h?s:e;let b=0;for(let S=0;S<E.length;S++)A>=E[S]&&(b=S);return f(b,"BENCHMARK",g,A,y)});var fs=(s=>(s[s.High=0]="High",s[s.Medium=1]="Medium",s[s.Low=2]="Low",s))(fs||{});function rn(s){return new Promise(e=>{nn().then(t=>{let i=!1;const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(i="transferControlToOffscreen"in s,n){const r=navigator.userAgent.match(/version\/(\d+)/i);i=(r?parseInt(r[1]):0)>=17}const a={dpr:devicePixelRatio,fps:t.fps!==void 0?t.fps:30,width:innerWidth,height:innerHeight,mobile:t.isMobile!==void 0?t.isMobile:!1,supportOffScreenCanvas:i,quality:2};t.tier===3?a.quality=0:t.tier===2&&(a.quality=1),e(a)})})}class an{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 P=(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.ADD_RENDERER="ToolEvents::addRenderer",s.UPDATE_RENDERER="ToolEvents::updateRenderer",s))(P||{});const R=new o.EventDispatcher;class jt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,i){}handleEditor(e,t,i){}}class on extends jt{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":R.dispatchEvent({type:P.SELECT_DROPDOWN,value:i.data});break;case"draggableListUpdate":R.dispatchEvent({type:P.DRAG_UPDATE,value:i.data});break}}}function ln(s,e,t){if(s.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}s.send({event:c,target:"app",data:u})})});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 cn(){setTimeout(()=>{const s=document.getElementById("theatrejs-studio-root");if(s===null||s.shadowRoot===null)return;const e=s.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t===null)return;const i=t.children[1];i.style.justifyContent="left";try{const n=i.children[1];for(n.style.transform="translateX(10px)";n.children.length>1;)n.removeChild(n.children[0])}catch{}try{const n=t.children[3];n.style.top="0",n.style.right="300px"}catch{}},1e3)}class hn extends jt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=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 new Promise(n=>{const a=t!==void 0?{...t}:{};this.sheet(e,i)?.sequence.play(a).then(r=>n(r)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}})})}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 c=this.sheetObjects.get(h);c!==void 0?c=r.object(t,{...i,...c.value},{reconfigure:!0}):c=r.object(t,i),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:fi);const u=c.onValuesChange(m=>{if(this.app.editor){for(const _ in m){const w=m[_];typeof w=="object"&&us(w)&&(m[_]={r:w.r,g:w.g,b:w.b,a:w.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:m}})}const f=this.sheetObjectCBs.get(h);f!==void 0&&f(m)});return this.sheetObjectUnsubscribe.set(h,u),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const 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,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:u})})});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 dn(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 et(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(et(t))}),e}function un(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 pn(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function We(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||pn(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:gt.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=un(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 Xt(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(We(a))}),e.material=n}else e.material=We(i.material)}else if(t.search("points")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(We(a))}),e.material=n}else e.material=We(i.material)}else if(t.search("line")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(We(a))}),e.material=n}else e.material=We(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 mn(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 fn(s,e){for(const t in e)s[t]=e[t]}function J(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&&fn(r,t)}}function gs(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})}function He(s,e,t){return Math.min(e,Math.max(s,t))}function ki(s,e,t){return(t-s)/(e-s)}function li(s,e,t){return s*(1-t)+e*t}function Ee(s,e=1){return Number(s.toFixed(e))}class gn extends jt{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Ae(e)}),this.scenes.clear(),this.scene&&Ae(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(gt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(gt.renderer=this.renderer);const t=Xt(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)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t,!this.app.debugEnabled)return;const i=`#${e.getClearColor(new o.Color).getHexString()}`;this.app.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:i,clearAlpha:e.getClearAlpha(),colorManagement:o.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure}})}updateRenderer(e){this.app.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;oi(),Ut(e);const t=et(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=et(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=et(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&&(gt.renderer=this.renderer),oi(),Ut(e);const t=et(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Xt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Xt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,i){const n=t;switch(i.event){case"getObject":R.dispatchEvent({type:P.GET_OBJECT,value:i.data});break;case"updateObject":R.dispatchEvent({type:P.UPDATE_OBJECT,value:i.data});break;case"createTexture":R.dispatchEvent({type:P.CREATE_TEXTURE,value:i.data});break;case"requestMethod":R.dispatchEvent({type:P.REQUEST_METHOD,value:i.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:et(n.scenes.get(i.data.name))});break;case"updateRenderer":n.renderer&&(n.renderer.autoClear=i.data.autoClear,n.renderer.autoClearColor=i.data.autoClearColor,n.renderer.autoClearDepth=i.data.autoClearDepth,n.renderer.autoClearStencil=i.data.autoClearStencil,n.renderer.outputColorSpace=i.data.outputColorSpace,n.renderer.localClippingEnabled=i.data.localClippingEnabled,n.renderer.setClearColor(i.data.clearColor,i.data.clearAlpha),n.renderer.toneMapping=i.data.toneMapping,n.renderer.toneMappingExposure=i.data.toneMappingExposure,o.ColorManagement.enabled=i.data.colorManagement);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":R.dispatchEvent({type:P.SET_OBJECT,value:i.data});break;case"addScene":R.dispatchEvent({type:P.ADD_SCENE,value:i.data});break;case"refreshScene":R.dispatchEvent({type:P.REFRESH_SCENE,value:i.data});break;case"removeScene":R.dispatchEvent({type:P.REMOVE_SCENE,value:i.data});break;case"setScene":R.dispatchEvent({type:P.SET_SCENE,value:i.data});break;case"addCamera":R.dispatchEvent({type:P.ADD_CAMERA,value:i.data});break;case"removeCamera":R.dispatchEvent({type:P.REMOVE_CAMERA,value:i.data});break;case"addGroup":R.dispatchEvent({type:P.ADD_GROUP,value:i.data});break;case"removeGroup":R.dispatchEvent({type:P.REMOVE_GROUP,value:i.data});break;case"addSpline":R.dispatchEvent({type:P.ADD_SPLINE,value:i.data});break;case"addRenderer":R.dispatchEvent({type:P.ADD_RENDERER,value:i.data})}}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(a=>{a.setSize(e*i,t*i)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(He(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}}var ci={exports:{}},st={};/**
19
- * @license React
20
- * react-jsx-runtime.production.min.js
21
- *
22
- * Copyright (c) Facebook, Inc. and its affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- */var ji;function _n(){if(ji)return st;ji=1;var s=x,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,c){var u,m={},f=null,_=null;c!==void 0&&(f=""+c),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(_=h.ref);for(u in h)i.call(h,u)&&!a.hasOwnProperty(u)&&(m[u]=h[u]);if(l&&l.defaultProps)for(u in h=l.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:e,type:l,key:f,ref:_,props:m,_owner:n.current}}return st.Fragment=t,st.jsx=r,st.jsxs=r,st}var nt={};/**
27
- * @license React
28
- * react-jsx-runtime.development.js
29
- *
30
- * Copyright (c) Facebook, Inc. and its affiliates.
31
- *
32
- * This source code is licensed under the MIT license found in the
33
- * LICENSE file in the root directory of this source tree.
34
- */var Ni;function vn(){return Ni||(Ni=1,process.env.NODE_ENV!=="production"&&function(){var s=x,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"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),w=Symbol.iterator,T="@@iterator";function A(d){if(d===null||typeof d!="object")return null;var C=w&&d[w]||d[T];return typeof C=="function"?C:null}var g=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(d){{for(var C=arguments.length,M=new Array(C>1?C-1:0),L=1;L<C;L++)M[L-1]=arguments[L];E("error",d,M)}}function E(d,C,M){{var L=g.ReactDebugCurrentFrame,z=L.getStackAddendum();z!==""&&(C+="%s",M=M.concat([z]));var Y=M.map(function(N){return String(N)});Y.unshift("Warning: "+C),Function.prototype.apply.call(console[d],console,Y)}}var b=!1,S=!1,O=!1,I=!1,k=!1,q;q=Symbol.for("react.module.reference");function de(d){return!!(typeof d=="string"||typeof d=="function"||d===i||d===a||k||d===n||d===c||d===u||I||d===_||b||S||O||typeof d=="object"&&d!==null&&(d.$$typeof===f||d.$$typeof===m||d.$$typeof===r||d.$$typeof===l||d.$$typeof===h||d.$$typeof===q||d.getModuleId!==void 0))}function Se(d,C,M){var L=d.displayName;if(L)return L;var z=C.displayName||C.name||"";return z!==""?M+"("+z+")":M}function ge(d){return d.displayName||"Context"}function oe(d){if(d==null)return null;if(typeof d.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case i:return"Fragment";case t:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case l:var C=d;return ge(C)+".Consumer";case r:var M=d;return ge(M._context)+".Provider";case h:return Se(d,d.render,"ForwardRef");case m:var L=d.displayName||null;return L!==null?L:oe(d.type)||"Memo";case f:{var z=d,Y=z._payload,N=z._init;try{return oe(N(Y))}catch{return null}}}return null}var K=Object.assign,Z=0,Pe,le,fe,ee,Re,De,Ie;function B(){}B.__reactDisabledLog=!0;function ne(){{if(Z===0){Pe=console.log,le=console.info,fe=console.warn,ee=console.error,Re=console.group,De=console.groupCollapsed,Ie=console.groupEnd;var d={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:d,log:d,warn:d,error:d,group:d,groupCollapsed:d,groupEnd:d})}Z++}}function Ce(){{if(Z--,Z===0){var d={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},d,{value:Pe}),info:K({},d,{value:le}),warn:K({},d,{value:fe}),error:K({},d,{value:ee}),group:K({},d,{value:Re}),groupCollapsed:K({},d,{value:De}),groupEnd:K({},d,{value:Ie})})}Z<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var tt=g.ReactCurrentDispatcher,Ye;function yt(d,C,M){{if(Ye===void 0)try{throw Error()}catch(z){var L=z.stack.trim().match(/\n( *(at )?)/);Ye=L&&L[1]||""}return`
35
- `+Ye+d}}var zt=!1,Ct;{var Ts=typeof WeakMap=="function"?WeakMap:Map;Ct=new Ts}function yi(d,C){if(!d||zt)return"";{var M=Ct.get(d);if(M!==void 0)return M}var L;zt=!0;var z=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Y;Y=tt.current,tt.current=null,ne();try{if(C){var N=function(){throw Error()};if(Object.defineProperty(N.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(N,[])}catch(Le){L=Le}Reflect.construct(d,[],N)}else{try{N.call()}catch(Le){L=Le}d.call(N.prototype)}}else{try{throw Error()}catch(Le){L=Le}d()}}catch(Le){if(Le&&L&&typeof Le.stack=="string"){for(var j=Le.stack.split(`
36
- `),ue=L.stack.split(`
37
- `),$=j.length-1,te=ue.length-1;$>=1&&te>=0&&j[$]!==ue[te];)te--;for(;$>=1&&te>=0;$--,te--)if(j[$]!==ue[te]){if($!==1||te!==1)do if($--,te--,te<0||j[$]!==ue[te]){var _e=`
38
- `+j[$].replace(" at new "," at ");return d.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",d.displayName)),typeof d=="function"&&Ct.set(d,_e),_e}while($>=1&&te>=0);break}}}finally{zt=!1,tt.current=Y,Ce(),Error.prepareStackTrace=z}var Ze=d?d.displayName||d.name:"",Di=Ze?yt(Ze):"";return typeof d=="function"&&Ct.set(d,Di),Di}function As(d,C,M){return yi(d,!1)}function Ps(d){var C=d.prototype;return!!(C&&C.isReactComponent)}function bt(d,C,M){if(d==null)return"";if(typeof d=="function")return yi(d,Ps(d));if(typeof d=="string")return yt(d);switch(d){case c:return yt("Suspense");case u:return yt("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return As(d.render);case m:return bt(d.type,C,M);case f:{var L=d,z=L._payload,Y=L._init;try{return bt(Y(z),C,M)}catch{}}}return""}var Et=Object.prototype.hasOwnProperty,Ci={},bi=g.ReactDebugCurrentFrame;function St(d){if(d){var C=d._owner,M=bt(d.type,d._source,C?C.type:null);bi.setExtraStackFrame(M)}else bi.setExtraStackFrame(null)}function Rs(d,C,M,L,z){{var Y=Function.call.bind(Et);for(var N in d)if(Y(d,N)){var j=void 0;try{if(typeof d[N]!="function"){var ue=Error((L||"React class")+": "+M+" type `"+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[N]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}j=d[N](C,N,L,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){j=$}j&&!(j instanceof Error)&&(St(z),y("%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).",L||"React class",M,N,typeof j),St(null)),j instanceof Error&&!(j.message in Ci)&&(Ci[j.message]=!0,St(z),y("Failed %s type: %s",M,j.message),St(null))}}}var Ds=Array.isArray;function Ht(d){return Ds(d)}function Is(d){{var C=typeof Symbol=="function"&&Symbol.toStringTag,M=C&&d[Symbol.toStringTag]||d.constructor.name||"Object";return M}}function Ls(d){try{return Ei(d),!1}catch{return!0}}function Ei(d){return""+d}function Si(d){if(Ls(d))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Is(d)),Ei(d)}var it=g.ReactCurrentOwner,Us={key:!0,ref:!0,__self:!0,__source:!0},wi,xi,Vt;Vt={};function ks(d){if(Et.call(d,"ref")){var C=Object.getOwnPropertyDescriptor(d,"ref").get;if(C&&C.isReactWarning)return!1}return d.ref!==void 0}function js(d){if(Et.call(d,"key")){var C=Object.getOwnPropertyDescriptor(d,"key").get;if(C&&C.isReactWarning)return!1}return d.key!==void 0}function Ns(d,C){if(typeof d.ref=="string"&&it.current&&C&&it.current.stateNode!==C){var M=oe(it.current.type);Vt[M]||(y('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',oe(it.current.type),d.ref),Vt[M]=!0)}}function Fs(d,C){{var M=function(){wi||(wi=!0,y("%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)",C))};M.isReactWarning=!0,Object.defineProperty(d,"key",{get:M,configurable:!0})}}function zs(d,C){{var M=function(){xi||(xi=!0,y("%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)",C))};M.isReactWarning=!0,Object.defineProperty(d,"ref",{get:M,configurable:!0})}}var Hs=function(d,C,M,L,z,Y,N){var j={$$typeof:e,type:d,key:C,ref:M,props:N,_owner:Y};return j._store={},Object.defineProperty(j._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(j,"_self",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.defineProperty(j,"_source",{configurable:!1,enumerable:!1,writable:!1,value:z}),Object.freeze&&(Object.freeze(j.props),Object.freeze(j)),j};function Vs(d,C,M,L,z){{var Y,N={},j=null,ue=null;M!==void 0&&(Si(M),j=""+M),js(C)&&(Si(C.key),j=""+C.key),ks(C)&&(ue=C.ref,Ns(C,z));for(Y in C)Et.call(C,Y)&&!Us.hasOwnProperty(Y)&&(N[Y]=C[Y]);if(d&&d.defaultProps){var $=d.defaultProps;for(Y in $)N[Y]===void 0&&(N[Y]=$[Y])}if(j||ue){var te=typeof d=="function"?d.displayName||d.name||"Unknown":d;j&&Fs(N,te),ue&&zs(N,te)}return Hs(d,j,ue,z,L,it.current,N)}}var Bt=g.ReactCurrentOwner,Oi=g.ReactDebugCurrentFrame;function Ge(d){if(d){var C=d._owner,M=bt(d.type,d._source,C?C.type:null);Oi.setExtraStackFrame(M)}else Oi.setExtraStackFrame(null)}var Yt;Yt=!1;function Gt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function Mi(){{if(Bt.current){var d=oe(Bt.current.type);if(d)return`
39
-
40
- Check the render method of \``+d+"`."}return""}}function Bs(d){{if(d!==void 0){var C=d.fileName.replace(/^.*[\\\/]/,""),M=d.lineNumber;return`
41
-
42
- Check your code at `+C+":"+M+"."}return""}}var Ti={};function Ys(d){{var C=Mi();if(!C){var M=typeof d=="string"?d:d.displayName||d.name;M&&(C=`
43
-
44
- Check the top-level render call using <`+M+">.")}return C}}function Ai(d,C){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var M=Ys(C);if(Ti[M])return;Ti[M]=!0;var L="";d&&d._owner&&d._owner!==Bt.current&&(L=" It was passed a child from "+oe(d._owner.type)+"."),Ge(d),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',M,L),Ge(null)}}function Pi(d,C){{if(typeof d!="object")return;if(Ht(d))for(var M=0;M<d.length;M++){var L=d[M];Gt(L)&&Ai(L,C)}else if(Gt(d))d._store&&(d._store.validated=!0);else if(d){var z=A(d);if(typeof z=="function"&&z!==d.entries)for(var Y=z.call(d),N;!(N=Y.next()).done;)Gt(N.value)&&Ai(N.value,C)}}}function Gs(d){{var C=d.type;if(C==null||typeof C=="string")return;var M;if(typeof C=="function")M=C.propTypes;else if(typeof C=="object"&&(C.$$typeof===h||C.$$typeof===m))M=C.propTypes;else return;if(M){var L=oe(C);Rs(M,d.props,"prop",L,d)}else if(C.PropTypes!==void 0&&!Yt){Yt=!0;var z=oe(C);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",z||"Unknown")}typeof C.getDefaultProps=="function"&&!C.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Zs(d){{for(var C=Object.keys(d.props),M=0;M<C.length;M++){var L=C[M];if(L!=="children"&&L!=="key"){Ge(d),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),Ge(null);break}}d.ref!==null&&(Ge(d),y("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}function Ri(d,C,M,L,z,Y){{var N=de(d);if(!N){var j="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(j+=" 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 ue=Bs(z);ue?j+=ue:j+=Mi();var $;d===null?$="null":Ht(d)?$="array":d!==void 0&&d.$$typeof===e?($="<"+(oe(d.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):$=typeof d,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,j)}var te=Vs(d,C,M,z,Y);if(te==null)return te;if(N){var _e=C.children;if(_e!==void 0)if(L)if(Ht(_e)){for(var Ze=0;Ze<_e.length;Ze++)Pi(_e[Ze],d);Object.freeze&&Object.freeze(_e)}else y("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 Pi(_e,d)}return d===i?Zs(te):Gs(te),te}}function Ws(d,C,M){return Ri(d,C,M,!0)}function Xs(d,C,M){return Ri(d,C,M,!1)}var Qs=Xs,qs=Ws;nt.Fragment=i,nt.jsx=Qs,nt.jsxs=qs}()),nt}process.env.NODE_ENV==="production"?ci.exports=_n():ci.exports=vn();var p=ci.exports;function gi(s){return s.title.search("<")>-1?p.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:s.title}}):p.jsx("button",{children:s.title})}const yn=p.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[p.jsx("circle",{cx:"7",cy:"7",r:"6"}),p.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),p.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Cn=p.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:p.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\r
45
- 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\r
46
- C11,8.22,10.74,8,10.43,8z`})});function _s(s){return p.jsx(cs.Reorder.Item,{value:s.title,children:p.jsxs("div",{children:[Cn,p.jsx("span",{children:s.title}),p.jsx("button",{className:"closeIcon",onClick:()=>{s.onDelete(s.index)},children:yn})]})},s.title)}function vs(s){const[e,t]=x.useState(!1),[i,n]=x.useState(s.options),a=c=>{s.onDragComplete(c),n(c)},r=c=>{const u=[...i];u.splice(c,1),a(u)},l=[];i.forEach((c,u)=>{l.push(p.jsx(_s,{index:u,title:c,onDelete:r},c))});let h="dropdown draggable";return s.subdropdown&&(h+=" subdropdown"),p.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(gi,{title:s.title}),p.jsx(cs.Reorder.Group,{axis:"y",values:i,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function ys(s){const[e,t]=x.useState(!1),i=[];s.options.map((a,r)=>{s.onSelect!==void 0&&(a.onSelect=s.onSelect),i.push(p.jsx(Cs,{option:a},r))});let n="dropdown";return s.subdropdown&&(n+=" subdropdown"),p.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(gi,{title:s.title}),p.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:i})]})}function Cs(s){const{option:e}=s,[t,i]=x.useState("");let n;switch(e.type){case"draggable":n=p.jsx(vs,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=p.jsx(ys,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=p.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 p.jsx("li",{className:t===e.title?"selected":"",children:n},ds())}function bn(s,e,t){function i(a){switch(e.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}function n(a){switch(t.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}s.listen=a=>{a.target==="editor"?n(a):i(a)}}function vt(s){const[e,t]=x.useState(s.open!==void 0?s.open:!0),i=!e||s.children===void 0,n=()=>{R.dispatchEvent({type:P.REMOVE_SCENE,value:s.scene})};return p.jsxs("div",{className:`accordion ${i?"hide":""}`,children:[p.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;s.onToggle!==void 0&&s.onToggle(a),t(a)},children:[p.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),p.jsx("p",{className:"label",children:_t(s.label)})]}),s.onRefresh?p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"refresh",onClick:s.onRefresh}),p.jsx("button",{className:"remove",onClick:n})]}):null,s.button,p.jsx("div",{className:e?"open":"",children:p.jsx("div",{children:s.children})},Math.random())]})}function _i(s){const e=x.useRef(null),[t,i]=x.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(p.jsx(_i,{child:r,three:s.three},l))}),x.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]),p.jsx(p.Fragment,{children:s.child!==void 0&&p.jsxs("div",{className:"childObject",children:[p.jsxs("div",{className:"child",children:[n?p.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{i(!t)}}):null,p.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}`}),p.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",c=!l.visible;e.current.style.opacity=c?"1":"0.25",s.three.updateObject(s.child.uuid,h,c),J(l,h,c)}}}}}),p.jsx("div",{className:`icon ${dn(s.child)}`})]}),p.jsx("div",{className:t?"open":"",children:p.jsx("div",{className:"container",children:a})})]},Math.random())})}function hi(s){const e=[];return s.child?.children.map((t,i)=>{e.push(p.jsx(_i,{child:t,scene:s.scene,three:s.three},i))}),p.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function En(s){const[e,t]=x.useState(s.defaultValue);return x.useEffect(()=>{let i=!1,n=-1,a=0,r=s.defaultValue,l=!1;const h=_=>{l=_.ctrlKey},c=_=>{i=!0,a=Number(s.input.current?.value),n=_.clientX,document.addEventListener("mouseup",m,!1),document.addEventListener("mousemove",u,!1),document.addEventListener("contextmenu",m,!1)},u=_=>{if(!i)return;const w=s.step!==void 0?s.step:1,T=(_.clientX-n)*w*(l?10:1);r=Number((a+T).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)},m=()=>{i=!1,document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m)},f=_=>{const w=Number(_.target.value);s.onChange!==void 0&&s.onChange(w),t(w)};return s.label.current?.addEventListener("mousedown",c,!1),s.sliderRef!==void 0&&s.sliderRef.current?.addEventListener("input",f),document.addEventListener("keydown",h,!1),document.addEventListener("keyup",h,!1),()=>{s.label.current?.removeEventListener("mousedown",c),s.sliderRef!==void 0&&s.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",h),document.addEventListener("keyup",h,!1)}},[]),e}function Be(s){const e=x.useRef(null),t=x.useRef(null),[i,n]=x.useState(s.value);return En({label:s.labelRef,input:e,sliderRef:t,defaultValue:i,min:s.min,max:s.max,step:s.step,onChange:a=>{n(a),s.onChange!==void 0&&s.onChange(s.prop,a)}}),p.jsxs(p.Fragment,{children:[s.type==="number"&&p.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:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||s.onChange!==void 0&&s.onChange(s.prop,r)}}),s.type==="range"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:s.value.toString(),disabled:s.disabled,ref:e,className:"min",onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||s.onChange!==void 0&&s.onChange(s.prop,r)}}),p.jsx("input",{disabled:s.disabled,type:"range",value:s.value,min:s.min,max:s.max,step:s.step,ref:t,onChange:fi})]})]})}function Sn(s){const e=x.useRef(null),t=x.useRef(null),i=x.useRef(null),n=x.useRef(null),a=x.useRef(null),r=x.useRef(null),[l,h]=x.useState(s.value),[c,u]=x.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,f]=x.useState(!1);function _(){m||(window.addEventListener("mousemove",T),window.addEventListener("mouseup",w),window.addEventListener("mouseup",w),f(!0))}function w(){window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",w),f(!1)}function T(b){const S=a.current.getBoundingClientRect(),O=He(0,99,b.clientX-S.left)/99,I=He(0,99,b.clientY-S.top)/99,k=Ee(li(c.min,c.max,O),3),q=Ee(li(c.min,c.max,I),3);s.onChange({target:{value:{x:k,y:q}}}),h({x:k,y:q})}function A(b){let S=l.x,O=l.y;b.target===e.current?S=Number(b.target.value):O=Number(b.target.value),h({x:S,y:O})}function g(){const b=Number(i.current.value);u({min:b,max:c.max}),(l.x<b||l.y<b)&&h({x:He(b,c.max,l.x),y:He(b,c.max,l.y)})}function y(){const b=Number(n.current.value);u({min:c.min,max:b}),(l.x>b||l.y>b)&&h({x:He(c.min,b,l.x),y:He(c.min,b,l.y)})}x.useEffect(()=>{const b=ki(c.min,c.max,l.x),S=ki(c.min,c.max,l.y);r.current.style.left=`${b*100}%`,r.current.style.top=`${S*100}%`},[c,l]);const E=s.step!==void 0?s.step:.01;return p.jsxs("div",{className:"vector2",children:[p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"X:"}),p.jsx("input",{ref:e,type:"number",value:l.x,min:c.min,max:c.max,step:E,onChange:A})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Y:"}),p.jsx("input",{ref:t,type:"number",value:l.y,min:c.min,max:c.max,step:E,onChange:A})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Min:"}),p.jsx("input",{ref:i,type:"number",value:c.min,step:E,onChange:g})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Max:"}),p.jsx("input",{ref:n,type:"number",value:c.max,step:E,onChange:y})]})]}),p.jsxs("div",{className:"input",ref:a,onMouseDown:_,onMouseUp:w,children:[p.jsx("div",{className:"x"}),p.jsx("div",{className:"y"}),p.jsx("div",{className:"pt",ref:r})]})]})}const wn=Math.PI/180,xn=180/Math.PI;function Xe(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Qe(s,e,t){return(1-t)*s+t*e}function di(s){return s*wn}function On(s){return s*xn}function Fi(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=x.useMemo(()=>s.value,[]);["_x","_y","_z"].forEach(h=>{const c=x.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),p.jsx(Be,{value:On(r[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(u,m)=>{r[u]=di(m),s.onChange({target:{value:r}})}})]},h))})}else if(e){const r=x.useMemo(()=>s.value,[]),l=(c,u)=>{r[c]=u,s.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const u=x.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:u,children:c.toUpperCase()}),p.jsx(Be,{value:r[c],type:"number",prop:c,step:n,labelRef:u,onChange:l})]},c))})}else if(i){const r=x.useMemo(()=>s.value,[]),l=(h,c)=>{const u=Number(h);r.elements[u]=c,s.onChange({target:{value:r}})};for(let h=0;h<9;h++){const c=x.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h+1}),p.jsx(Be,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return p.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Mn(s){const e=s.value.x!==void 0,t=s.step!==void 0?s.step:.01,i=[];if(e){const n=x.useMemo(()=>s.value,[]),a=(l,h)=>{n[l]=h,s.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=x.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:h,children:l.toUpperCase()}),p.jsx(Be,{value:n.x,type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=x.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=x.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:l,children:r+1}),p.jsx(Be,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return p.jsx("div",{className:"grid4",children:i})}function Tn(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 An(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 Nt(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 bs(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 Pn(){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 Rn=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],Dn=[{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}],In=[{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}],Ln=[{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}],Un=[{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 rt(s,e){s.needsUpdate=!0,s.type="option",s.options=e}function kn(s,e,t,i){return{type:"boolean",title:Nt(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);J(l,`material.${s}`,a)}}}}function jn(s,e,t,i){const n={type:"number",title:Nt(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);J(h,`material.${s}`,r)}}};switch(s){case"blending":rt(n,Dn);break;case"blendDst":rt(n,Un);break;case"blendEquation":rt(n,In);break;case"blendSrc":rt(n,Ln);break;case"side":rt(n,Rn);break}return bs(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 Nn(s,e,t,i){const n={type:"string",title:Nt(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 c=h.getObjectByProperty("uuid",t.uuid);J(c,`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 c=h.getObjectByProperty("uuid",t.uuid);J(c,`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);J(h,"material.needsUpdate",!0)}}}),n}function Fn(s){return s.x!==void 0&&s.y!==void 0&&s.z===void 0}function zn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w===void 0}function Hn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w!==void 0}function ui(s){s.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function pt(s,e,t,i,n="",a=!1){const r=Nt(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:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(h==="number"){const c={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(u,m)=>{i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",t.uuid);J(_,`material.${l}`,m)}}};return bs(r)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:r,prop:l,type:"color",value:e,disabled:a,onChange:(c,u)=>{const m=new o.Color(u);i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",t.uuid);J(_,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const u in e){const m=e[u],f=`[${u.toString()}]`;if(m.value!==void 0){const _=pt(`${f}.value`,m.value,t,i,l,a);_!==void 0&&c.push(_)}else{const _=pt(f,m,t,i,l,a);_!==void 0&&c.push(_)}}if(c.length>0)return ui(c),{title:r,items:c}}else{if(Fn(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(zn(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(Hn(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(c,u)=>{const m=An(s),f=n.length>0?`${n}.${m}`:m;i.createTexture(t.uuid,`material.${f}`,u);const _=i.getScene(t.uuid);if(_!==null){const w=_.getObjectByProperty("uuid",t.uuid);if(w!==void 0){const T=A=>{const g=w.material,y=f.split(".");switch(y.length){case 1:g[y[0]]=A;break;case 2:g[y[0]][y[1]]=A;break;case 3:g[y[0]][y[1]][y[2]]=A;break;case 4:g[y[0]][y[1]][y[2]][y[3]]=A;break;case 5:g[y[0]][y[1]][y[2]][y[3]][y[4]]=A;break}g.needsUpdate=!0};u.src.length>0?gs(u.src).then(A=>{A.offset.set(u.offset[0],u.offset[1]),A.repeat.set(u.repeat[0],u.repeat[1]),T(A)}):T(null)}}}};if(e.elements!==void 0)return{title:r,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};{const c=[],u=s==="defines"||s==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const _=pt(`${m}.value`,f.value,t,i,l,u);_!==void 0&&c.push(_)}else{const _=pt(m,f,t,i,l,u);_!==void 0&&c.push(_)}}}catch{console.log("Issue cycling through material object:",s,e)}if(c.length>0)return ui(c),{title:r,items:c}}}}}function zi(s,e,t){const i=[];for(const n in s){if(!Tn(n))continue;const a=typeof s[n],r=s[n];if(a==="boolean")i.push(kn(n,r,e,t));else if(a==="number")i.push(jn(n,r,e,t));else if(a==="string")i.push(Nn(n,r,e,t));else if(a==="object"){const l=pt(n,r,e,t);l!==void 0&&i.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return ui(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);J(a,"material.needsUpdate",!0)}}}),i}function Vn(s,e){function t(){return`${e.app.appID}_material`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=s.material;if(Array.isArray(r)){const l=[],h=r.length;for(let c=0;c<h;c++)l.push(p.jsx(ye,{title:`Material ${c}`,items:zi(r[c],s,e)},`Material ${c}`));return p.jsx(p.Fragment,{children:l})}else return p.jsx(ye,{title:"Material",items:zi(r,s,e),expanded:n,onToggle:l=>{a(l)}})}const Hi="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 Bn(s){const e=s.step!==void 0?s.step:.01,t=x.useRef(null),i=x.useRef(null),n=x.useRef(null),a=x.useRef(null),r=x.useRef(null),[l]=x.useState(s.value),[h,c]=x.useState(s.value.offset[0]),[u,m]=x.useState(s.value.offset[1]),[f,_]=x.useState(s.value.repeat[0]),[w,T]=x.useState(s.value.repeat[1]);function A(y,E,b,S,O){if(s.onChange!==void 0){const I=s.prop!==void 0?s.prop:s.title;s.onChange(I,{src:y,offset:[E,b],repeat:[S,O]})}}function g(y){const E=t.current.src,b=y.target.value;switch(y.target){case i.current:c(b),A(E,b,u,f,w);break;case n.current:m(b),A(E,h,b,f,w);break;case a.current:_(b),A(E,h,u,b,w);break;case r.current:T(b),A(E,h,u,f,b);break}}return p.jsxs("div",{className:"imageField",children:[p.jsx("img",{alt:s.title,ref:t,onClick:()=>{Pn().then(y=>{t.current.src=y,A(y,h,u,f,w)})},src:l.src.length>0?l.src:Hi}),p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"Offset:"}),p.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:g}),p.jsx("input",{ref:n,type:"number",value:u,step:e,onChange:g})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Repeat:"}),p.jsx("input",{ref:a,type:"number",value:f,step:e,onChange:g}),p.jsx("input",{ref:r,type:"number",value:w,step:e,onChange:g})]}),p.jsx("button",{onClick:()=>{A("",h,u,f,w),t.current.src=Hi},children:"Clear"})]})]})}function It(s){let e=s.value;e!==void 0&&(e.isColor!==void 0?e=ai(s.value):s.type==="color"&&(e=ai(new o.Color().setStyle(s.value,o.LinearSRGBColorSpace))));const[t,i]=x.useState(e),n=x.useRef(null),a=c=>{let u=c.target.value;if(s.type==="boolean")u=c.target.checked;else if(s.type==="option"&&(typeof s.value=="number"?u=Number(u):typeof s.value=="boolean"?u=!!u:typeof s.value=="object"&&(u=JSON.parse(u)),s.options!==void 0)){const m=s.options.length;for(let f=0;f<m&&s.options[f].value!==u;f++);}i(u),s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,u)},r={};s.disabled&&(r.opacity=.8);const l=s.type==="string"&&(t.length>100||t.search(`
47
- `)>-1),h=l||s.type==="image"||s.type==="vector2";return p.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[s.type!=="button"&&p.jsx("label",{ref:n,children:_t(s.title)},"fieldLabel"),s.type==="string"&&!l&&p.jsx("input",{type:"text",disabled:s.disabled,onChange:a,value:t}),s.type==="string"&&l&&p.jsx("textarea",{cols:50,rows:10,disabled:s.disabled!==void 0?s.disabled:!0,onChange:a,onKeyDown:c=>{s.onKeyDown!==void 0&&s.onKeyDown(c)},value:t}),s.type==="boolean"&&p.jsx("input",{type:"checkbox",disabled:s.disabled,onChange:a,checked:t}),s.type==="number"&&p.jsx(Be,{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"&&p.jsx(Be,{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"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:s.disabled,className:"color"}),p.jsx("input",{type:"color",value:t,onChange:a,disabled:s.disabled})]}),s.type==="button"&&p.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"&&p.jsx(Bn,{title:s.title,prop:s.prop,value:s.value,onChange:s.onChange}),s.type==="option"&&p.jsx(p.Fragment,{children:p.jsx("select",{onChange:a,disabled:s.disabled,defaultValue:s.value,children:s.options?.map((c,u)=>p.jsx("option",{value:c.value,children:_t(c.title)},u))})}),s.type==="vector2"&&p.jsx(Sn,{step:s.step,value:t,min:0,max:1,onChange:a}),s.type==="grid3"&&p.jsx(Fi,{step:s.step,value:t,onChange:a}),s.type==="grid4"&&p.jsx(Mn,{step:s.step,value:t,onChange:a}),s.type==="euler"&&p.jsx(Fi,{step:s.step,value:t,onChange:a})]})}function Yn(s){return"items"in s}class ye extends x.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=x.createRef(),n=p.jsx(ye,{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(Yn(t))e.push(p.jsx(ye,{title:_t(t.title),items:t.items},Math.random()));else{const i=this.valueOverrides.get(t.title),n=i!==void 0?i:t.value;e.push(p.jsx(It,{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)),p.jsx(vt,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class ie extends x.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},ie.instance=this,R.addEventListener(P.ADD_GROUP,this.addGroup),R.addEventListener(P.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){R.removeEventListener(P.ADD_GROUP,this.addGroup),R.removeEventListener(P.REMOVE_GROUP,this.removeGroup)}render(){return p.jsx("div",{className:"customGroups",children:ie.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)}})}),ie.groups.push(p.jsx(ye,{title:t.title,items:i},Math.random())),ie.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,i=ie.groupTitles.length;for(let n=0;n<i;n++)if(t===ie.groupTitles[n]){ie.groups.splice(n,1),ie.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=x.createRef(),n=p.jsx(ye,{ref:i,title:e.title,items:t},Math.random());return ie.groups.push(n),ie.groupsRefs.push(i),ie.groupTitles.push(e.title),i}static removeEditorGroup(e){const t=ie.groupTitles.length;for(let i=0;i<t;i++)if(e===ie.groupTitles[i]){ie.groups.splice(i,1),ie.groupTitles.splice(i,1),ie.instance.setState({lastUpdate:Date.now()});return}}}function Vi(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 Gn(s,e){function t(){return`${e.app.appID}_camera`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(s.perspectiveCameraInfo!==void 0)for(const l in s.perspectiveCameraInfo)r.push({title:Vi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(J(m,h,c),m.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const l in s.orthographicCameraInfo)r.push({title:Vi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(J(m,h,c),m.updateProjectionMatrix())}}});return p.jsx(ye,{title:"Camera",items:r,expanded:n,onToggle:l=>{a(l)}})}class Zn 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 Bi={type:"change"},vi={type:"start"},Es={type:"end"},wt=new o.Ray,Yi=new o.Plane,Wn=Math.cos(70*o.MathUtils.DEG2RAD),se=new o.Vector3,pe=2*Math.PI,V={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Qt=1e-6;class Xn extends o.Controls{constructor(e,t=null){super(e,t),this.state=V.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=qn.bind(this),this._onPointerDown=Qn.bind(this),this._onPointerUp=Kn.bind(this),this._onContextMenu=nr.bind(this),this._onMouseWheel=er.bind(this),this._onKeyDown=tr.bind(this),this._onTouchStart=ir.bind(this),this._onTouchMove=sr.bind(this),this._onMouseDown=$n.bind(this),this._onMouseMove=Jn.bind(this),this._interceptControlDown=rr.bind(this),this._interceptControlUp=ar.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(Bi),this.update(),this.state=V.NONE}update(e=null){const t=this.object.position;se.copy(t).sub(this.target),se.applyQuaternion(this._quat),this._spherical.setFromVector3(se),this.autoRotate&&this.state===V.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+=pe:i>Math.PI&&(i-=pe),n<-Math.PI?n+=pe:n>Math.PI&&(n-=pe),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(se.setFromSpherical(this._spherical),se.applyQuaternion(this._quatInverse),t.copy(this.target).add(se),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=se.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 c=new o.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(l),this.object.updateMatrixWorld(),r=se.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):(wt.origin.copy(this.object.position),wt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(wt.direction))<Wn?this.object.lookAt(this.target):(Yi.setFromNormalAndCoplanarPoint(this.object.up,this.target),wt.intersectPlane(Yi,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)>Qt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Qt||this._lastTargetPosition.distanceToSquared(this.target)>Qt?(this.dispatchEvent(Bi),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?pe/60*this.autoRotateSpeed*e:pe/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){se.setFromMatrixColumn(t,0),se.multiplyScalar(-e),this._panOffset.add(se)}_panUp(e,t){this.screenSpacePanning===!0?se.setFromMatrixColumn(t,1):(se.setFromMatrixColumn(t,0),se.crossVectors(this.object.up,se)),se.multiplyScalar(e),this._panOffset.add(se)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;se.copy(n).sub(this.target);let a=se.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(pe*this._rotateDelta.x/t.clientHeight),this._rotateUp(pe*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(pe*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(-pe*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(pe*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(-pe*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(pe*this._rotateDelta.x/t.clientHeight),this._rotateUp(pe*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 Qn(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 qn(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Kn(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(Es),this.state=V.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 $n(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=V.DOLLY;break;case o.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=V.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=V.ROTATE}break;case o.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=V.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=V.PAN}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(vi)}function Jn(s){switch(this.state){case V.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case V.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case V.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function er(s){this.enabled===!1||this.enableZoom===!1||this.state!==V.NONE||(s.preventDefault(),this.dispatchEvent(vi),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Es))}function tr(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function ir(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=V.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=V.TOUCH_PAN;break;default:this.state=V.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=V.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=V.TOUCH_DOLLY_ROTATE;break;default:this.state=V.NONE}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(vi)}function sr(s){switch(this._trackPointer(s),this.state){case V.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case V.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case V.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case V.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=V.NONE}}function nr(s){this.enabled!==!1&&s.preventDefault()}function rr(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ar(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
48
- * camera-controls
49
- * https://github.com/yomotsu/camera-controls
50
- * (c) 2017 @yomotsu
51
- * Released under the MIT License.
52
- */const Q={LEFT:1,RIGHT:2,MIDDLE:4},v=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}),qe={NONE:0,IN:1,OUT:-1};function je(s){return s.isPerspectiveCamera}function ke(s){return s.isOrthographicCamera}const Ke=Math.PI*2,Gi=Math.PI/2,Ss=1e-5,at=Math.PI/180;function be(s,e,t){return Math.max(e,Math.min(t,s))}function W(s,e=Ss){return Math.abs(s)<e}function H(s,e,t=Ss){return W(s-e,t)}function Zi(s,e){return Math.round(s/e)*e}function ot(s){return isFinite(s)?s:s<0?-Number.MAX_VALUE:Number.MAX_VALUE}function lt(s){return Math.abs(s)<Number.MAX_VALUE?s:s*(1/0)}function xt(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 c=s-e;const u=e,m=n*i;c=be(c,-m,m),e=s-c;const f=(t.value+r*c)*a;t.value=(t.value-r*f)*h;let _=e+(c+f)*h;return u-s>0==_>u&&(_=u,t.value=(_-u)/a),_}function Wi(s,e,t,i,n=1/0,a,r){i=Math.max(1e-4,i);const l=2/i,h=l*a,c=1/(1+h+.48*h*h+.235*h*h*h);let u=e.x,m=e.y,f=e.z,_=s.x-u,w=s.y-m,T=s.z-f;const A=u,g=m,y=f,E=n*i,b=E*E,S=_*_+w*w+T*T;if(S>b){const Z=Math.sqrt(S);_=_/Z*E,w=w/Z*E,T=T/Z*E}u=s.x-_,m=s.y-w,f=s.z-T;const O=(t.x+l*_)*a,I=(t.y+l*w)*a,k=(t.z+l*T)*a;t.x=(t.x-l*O)*c,t.y=(t.y-l*I)*c,t.z=(t.z-l*k)*c,r.x=u+(_+O)*c,r.y=m+(w+I)*c,r.z=f+(T+k)*c;const q=A-s.x,de=g-s.y,Se=y-s.z,ge=r.x-A,oe=r.y-g,K=r.z-y;return q*ge+de*oe+Se*K>0&&(r.x=A,r.y=g,r.z=y,t.x=(r.x-A)/a,t.y=(r.y-g)/a,t.z=(r.z-y)/a),r}function qt(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 Kt(s,e){return ke(s)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class or{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 $t;const lr="2.9.0",Ot=1/8,cr=/Mac/.test(($t=globalThis?.navigator)===null||$t===void 0?void 0:$t.platform);let D,Xi,Mt,Jt,me,U,F,$e,ct,we,xe,Ne,Qi,qi,ve,ht,Je,Ki,ei,$i,ti,ii,Tt;class Te extends or{static install(e){D=e.THREE,Xi=Object.freeze(new D.Vector3(0,0,0)),Mt=Object.freeze(new D.Vector3(0,1,0)),Jt=Object.freeze(new D.Vector3(0,0,1)),me=new D.Vector2,U=new D.Vector3,F=new D.Vector3,$e=new D.Vector3,ct=new D.Vector3,we=new D.Vector3,xe=new D.Vector3,Ne=new D.Vector3,Qi=new D.Vector3,qi=new D.Vector3,ve=new D.Spherical,ht=new D.Spherical,Je=new D.Box3,Ki=new D.Box3,ei=new D.Sphere,$i=new D.Quaternion,ti=new D.Quaternion,ii=new D.Matrix4,Tt=new D.Raycaster}static get ACTION(){return v}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=v.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=qe.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new D.Vector3,this._focalOffsetVelocity=new D.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,y,E)=>{let b,S;if(je(this._camera)){const O=U.copy(this._camera.position).sub(this._target),I=this._camera.getEffectiveFOV()*at,k=O.length()*Math.tan(I*.5);b=this.truckSpeed*g*k/this._elementRect.height,S=this.truckSpeed*y*k/this._elementRect.height}else if(ke(this._camera)){const O=this._camera;b=g*(O.right-O.left)/O.zoom/this._elementRect.width,S=y*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(E?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-S,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+S,this._focalOffsetEnd.z,!0):this.truck(b,S,!0)},this._rotateInternal=(g,y)=>{const E=Ke*this.azimuthRotateSpeed*g/this._elementRect.height,b=Ke*this.polarRotateSpeed*y/this._elementRect.height;this.rotate(E,b,!0)},this._dollyInternal=(g,y,E)=>{const b=Math.pow(.95,-g*this.dollySpeed),S=this._sphericalEnd.radius,O=this._sphericalEnd.radius*b,I=be(O,this.minDistance,this.maxDistance),k=I-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(k,!0),this._dollyToNoClamp(I,!0)):this._dollyToNoClamp(I,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:I)-S,this._dollyControlCoord.set(y,E)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,y,E)=>{const b=Math.pow(.95,g*this.dollySpeed),S=this._zoom,O=this._zoom*b;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-S,this._dollyControlCoord.set(y,E))},typeof D>"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 D.Quaternion().setFromUnitVectors(this._camera.up,Mt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=v.NONE,this._target=new D.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new D.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new D.Spherical().setFromVector3(U.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 D.Vector3,new D.Vector3,new D.Vector3,new D.Vector3],this._updateNearPlaneCorners(),this._boundary=new D.Box3(new D.Vector3(-1/0,-1/0,-1/0),new D.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 D.Vector2,this.mouseButtons={left:v.ROTATE,middle:v.DOLLY,right:v.TRUCK,wheel:je(this._camera)?v.DOLLY:ke(this._camera)?v.ZOOM:v.NONE},this.touches={one:v.TOUCH_ROTATE,two:je(this._camera)?v.TOUCH_DOLLY_TRUCK:ke(this._camera)?v.TOUCH_ZOOM_TRUCK:v.NONE,three:v.TOUCH_TRUCK};const i=new D.Vector2,n=new D.Vector2,a=new D.Vector2,r=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const b=this._domElement.getBoundingClientRect(),S=g.clientX/b.width,O=g.clientY/b.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const y=g.pointerType!=="mouse"?null:(g.buttons&Q.LEFT)===Q.LEFT?Q.LEFT:(g.buttons&Q.MIDDLE)===Q.MIDDLE?Q.MIDDLE:(g.buttons&Q.RIGHT)===Q.RIGHT?Q.RIGHT:null;if(y!==null){const b=this._findPointerByMouseButton(y);b&&this._disposePointer(b)}if((g.buttons&Q.LEFT)===Q.LEFT&&this._lockedPointer)return;const E={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:y};this._activePointers.push(E),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,f(g)},l=g=>{g.cancelable&&g.preventDefault();const y=g.pointerId,E=this._lockedPointer||this._findPointerById(y);if(E){if(E.clientX=g.clientX,E.clientY=g.clientY,E.deltaX=g.movementX,E.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&Q.LEFT)===Q.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&Q.MIDDLE)===Q.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&Q.RIGHT)===Q.RIGHT&&(this._state=this._state|this.mouseButtons.right);_()}},h=g=>{const y=this._findPointerById(g.pointerId);if(!(y&&y===this._lockedPointer)){if(y&&this._disposePointer(y),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=v.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=v.NONE;w()}};let c=-1;const u=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===v.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),I=g.clientX/O.width,k=g.clientY/O.height;if(I<this._interactiveArea.left||I>this._interactiveArea.right||k<this._interactiveArea.top||k>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===v.ROTATE||this.mouseButtons.wheel===v.TRUCK){const O=performance.now();c-O<1e3&&this._getClientRect(this._elementRect),c=O}const y=cr?-1:-3,E=g.deltaMode===1?g.deltaY/y:g.deltaY/(y*10),b=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case v.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case v.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case v.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case v.DOLLY:{this._dollyInternal(-E,b,S),this._isUserControllingDolly=!0;break}case v.ZOOM:{this._zoomInternal(-E,b,S),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Te.ACTION.NONE){const y=g instanceof PointerEvent?g.pointerId:0,E=this._findPointerById(y);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}g.preventDefault()}},f=g=>{if(!this._enabled)return;if(qt(this._activePointers,me),this._getClientRect(this._elementRect),i.copy(me),n.copy(me),this._activePointers.length>=2){const E=me.x-this._activePointers[1].clientX,b=me.y-this._activePointers[1].clientY,S=Math.sqrt(E*E+b*b);a.set(0,S);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,I=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(O,I)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&Q.LEFT)===Q.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&Q.MIDDLE)===Q.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&Q.RIGHT)===Q.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.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&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&v.DOLLY)===v.DOLLY||(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&v.ZOOM)===v.ZOOM||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},_=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,qt(this._activePointers,me);const y=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=y?-y.deltaX:n.x-me.x,b=y?-y.deltaY:n.y-me.y;if(n.copy(me),((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,b),this._isUserControllingRotate=!0),(this._state&v.DOLLY)===v.DOLLY||(this._state&v.ZOOM)===v.ZOOM){const S=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,I=this.dollyDragInverted?-1:1;(this._state&v.DOLLY)===v.DOLLY?(this._dollyInternal(I*b*Ot,S,O),this._isUserControllingDolly=!0):(this._zoomInternal(I*b*Ot,S,O),this._isUserControllingZoom=!0)}if((this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE){const S=me.x-this._activePointers[1].clientX,O=me.y-this._activePointers[1].clientY,I=Math.sqrt(S*S+O*O),k=a.y-I;a.set(0,I);const q=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,de=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET?(this._dollyInternal(k*Ot,q,de),this._isUserControllingDolly=!0):(this._zoomInternal(k*Ot,q,de),this._isUserControllingZoom=!0)}((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,b,!1),this._isUserControllingTruck=!0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,b,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},w=()=>{qt(this._activePointers,me),n.copy(me),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",T),this._domElement.ownerDocument.addEventListener("pointerlockerror",A),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),f())},this.unlockPointer=()=>{var g,y,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockchange",T),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",A),this.cancel()};const T=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},A=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",u,{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",u,{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",T),this._domElement.ownerDocument.removeEventListener("pointerlockerror",A))},this.cancel=()=>{this._state!==v.NONE&&(this._state=v.NONE,this._activePointers.length=0,w())},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=be(e.width,0,1),this._interactiveArea.height=be(e.height,0,1),this._interactiveArea.x=be(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=be(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=be(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=be(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||H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(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=qe.NONE,this._changedDolly=0,this._dollyToNoClamp(be(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=H(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||H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(ct).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(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=be(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||H(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(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),we.multiplyScalar(e),xe.multiplyScalar(-t);const n=U.copy(we).add(xe),a=F.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,i)}forward(e,t=!1){U.setFromMatrixColumn(this._camera.matrix,0),U.crossVectors(this._camera.up,U),U.multiplyScalar(e);const i=F.copy(this._targetEnd).add(U);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return U.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+U.x,this._targetEnd.y+U.y,this._targetEnd.z+U.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;const a=U.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||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,n=!1){const l=U.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=[],c=e.isBox3?Je.copy(e):Je.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Zi(this._sphericalEnd.theta,Gi),m=Zi(this._sphericalEnd.phi,Gi);h.push(this.rotateTo(u,m,t));const f=U.setFromSpherical(this._sphericalEnd).normalize(),_=$i.setFromUnitVectors(f,Jt),w=H(Math.abs(f.y),1);w&&_.multiply(ti.setFromAxisAngle(Mt,u)),_.multiply(this._yAxisUpSpaceInverse);const T=Ki.makeEmpty();F.copy(c.min).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setX(c.max.x).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setY(c.max.y).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setZ(c.min.z).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setZ(c.max.z).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setY(c.min.y).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setX(c.min.x).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).applyQuaternion(_),T.expandByPoint(F),T.min.x-=n,T.min.y-=r,T.max.x+=a,T.max.y+=l,_.setFromUnitVectors(Jt,f),w&&_.premultiply(ti.invert()),_.premultiply(this._yAxisUpSpace);const A=T.getSize(U),g=T.getCenter(F).applyQuaternion(_);if(je(this._camera)){const y=this.getDistanceToFitBox(A.x,A.y,A.z,i);h.push(this.moveTo(g.x,g.y,g.z,t)),h.push(this.dollyTo(y,t)),h.push(this.setFocalOffset(0,0,0,t))}else if(ke(this._camera)){const y=this._camera,E=y.right-y.left,b=y.top-y.bottom,S=i?Math.max(E/A.x,b/A.y):Math.min(E/A.x,b/A.y);h.push(this.moveTo(g.x,g.y,g.z,t)),h.push(this.zoomTo(S,t)),h.push(this.setFocalOffset(0,0,0,t))}return Promise.all(h)}fitToSphere(e,t){const i=[],a="isObject3D"in e?Te.createBoundingSphere(e,ei):ei.copy(e);if(i.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),je(this._camera)){const r=this.getDistanceToFitSphere(a.radius);i.push(this.dollyTo(r,t))}else if(ke(this._camera)){const r=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,h=2*a.radius,c=Math.min(r/h,l/h);i.push(this.zoomTo(c,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=qe.NONE,this._changedDolly=0;const h=F.set(n,a,r),c=U.set(e,t,i);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!l||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,i,n,a,r,l,h,c,u,m,f,_,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=qe.NONE,this._changedDolly=0;const T=U.set(n,a,r),A=F.set(e,t,i);ve.setFromVector3(A.sub(T).applyQuaternion(this._yAxisUpSpace));const g=$e.set(u,m,f),y=F.set(l,h,c);ht.setFromVector3(y.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(T.lerp(g,_));const E=ht.theta-ve.theta,b=ht.phi-ve.phi,S=ht.radius-ve.radius;this._sphericalEnd.set(ve.radius+S*_,ve.phi+b*_,ve.theta+E*_),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!w||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(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(U),r=this.setLookAt(a.x,a.y,a.z,e,t,i,n);return this._sphericalEnd.phi=be(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||H(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&H(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&H(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrixWorldInverse,0),xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ne.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=U.set(e,t,i),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);we.multiplyScalar(r.x),xe.multiplyScalar(r.y),Ne.multiplyScalar(r.z),U.copy(we).add(xe).add(Ne),U.z=U.z+a,this.dollyTo(a,!1),this.setFocalOffset(-U.x,U.y,-U.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 D.Vector4,typeof e=="number"?this._viewport.set(e,t,i,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,n=!1){if(Kt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*at,l=this._camera.aspect;return((n?a>l:a<l)?t:e/l)*.5/Math.tan(r*.5)+i*.5}getDistanceToFitSphere(e){if(Kt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*at,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 D.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new D.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new D.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new D.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ke,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ke),this._spherical.theta+=Ke*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ke)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!H(this._camera.up.x,this._cameraUp0.x)||!H(this._camera.up.y,this._cameraUp0.y)||!H(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(U);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,Mt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=U.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(U);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=Qi.subVectors(this._targetEnd,this._target),r=qi.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(W(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=xt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(W(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=xt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(W(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=xt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(W(a.x)&&W(a.y)&&W(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Wi(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(W(r.x)&&W(r.y)&&W(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Wi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(W(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=xt(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(je(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,f=this._camera,_=this._getCameraDirection(ct),w=U.copy(_).cross(f.up).normalize();w.lengthSq()===0&&(w.x=1);const T=F.crossVectors(w,_),A=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*at*.5),y=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=$e.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*A*f.aspect)).add(T.multiplyScalar(this._dollyControlCoord.y*A)),b=U.copy(this._targetEnd).lerp(E,y),S=this._lastDollyDirection===qe.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===qe.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||O)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const k=F.copy(_).multiplyScalar(-m);b.add(k)}this._boundary.clampPoint(b,b);const I=F.subVectors(b,this._targetEnd);this._targetEnd.copy(b),this._target.add(I),this._changedDolly-=m,W(this._changedDolly)&&(this._changedDolly=0)}else if(ke(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,f=this._camera,_=U.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),w=F.set(0,0,-1).applyQuaternion(f.quaternion),T=$e.copy(_).add(w.multiplyScalar(-_.dot(f.up))),g=-(this._zoom-m-this._zoom)/this._zoom,y=this._getCameraDirection(ct),E=this._targetEnd.dot(y),b=U.copy(this._targetEnd).lerp(T,g),S=b.dot(y),O=y.multiplyScalar(S-E);b.sub(O),this._boundary.clampPoint(b,b);const I=F.subVectors(b,this._targetEnd);this._targetEnd.copy(b),this._target.add(I),this._changedZoom-=m,W(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),(!W(this._focalOffset.x)||!W(this._focalOffset.y)||!W(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),Ne.setFromMatrixColumn(this._camera.matrix,2),we.multiplyScalar(this._focalOffset.x),xe.multiplyScalar(-this._focalOffset.y),Ne.multiplyScalar(this._focalOffset.z),U.copy(we).add(xe).add(Ne),this._camera.position.add(U)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),U.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),W(t,this.restThreshold)&&W(i,this.restThreshold)&&W(n,this.restThreshold)&&W(a.x,this.restThreshold)&&W(a.y,this.restThreshold)&&W(a.z,this.restThreshold)&&W(r.x,this.restThreshold)&&W(r.y,this.restThreshold)&&W(r.z,this.restThreshold)&&W(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ot(this.maxDistance),minZoom:this.minZoom,maxZoom:ot(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ot(this.maxPolarAngle),minAzimuthAngle:ot(this.minAzimuthAngle),maxAzimuthAngle:ot(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:U.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=lt(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=lt(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=lt(i.maxPolarAngle),this.minAzimuthAngle=lt(i.minAzimuthAngle),this.maxAzimuthAngle=lt(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),ve.setFromVector3(U.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ve.theta,ve.phi,t),this.dollyTo(ve.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",lr),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,$e).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 c=1+i*h/t.dot(l);return e.add(F.copy(t).multiplyScalar(c)).add(l.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(je(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*at,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(ke(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)||Kt(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(ct);ii.lookAt(Xi,i,this._camera.up);for(let n=0;n<4;n++){const a=F.copy(this._nearPlaneCorners[n]);a.applyMatrix4(ii);const r=$e.addVectors(this._target,a);Tt.set(r,i),Tt.far=this._spherical.radius+1;const l=Tt.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 D.Sphere){const i=t,n=i.center;Je.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&Je.expandByObject(r)}),Je.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 u=h.attributes.position;for(let m=0,f=u.count;m<f;m++)U.fromBufferAttribute(u,m),a=Math.max(a,n.distanceToSquared(U))}),i.radius=Math.sqrt(a),i}}const kt=s=>{const[e,t]=x.useState(s.options[s.index]),i=()=>{s.onToggle(!s.open)},n=a=>{a!==e&&(s.onSelect(a),t(a)),s.onToggle(!1)};return p.jsxs("div",{className:`dropdown ${s.up===!0?"up":""}`,children:[p.jsx("div",{className:"dropdown-toggle",onClick:i,children:`${s.title}: ${e}`}),s.open&&p.jsx("ul",{className:"dropdown-menu",children:s.options.map(a=>p.jsx("li",{onClick:()=>n(a),children:a},a))})]})},Fe=x.forwardRef(function(e,t){const i=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=x.useState("Renderer"),[r,l]=x.useState(!1),[h,c]=x.useState(!1),[u,m]=x.useState(!1);return p.jsxs("div",{className:`CameraWindow ${e.name}`,children:[p.jsx("div",{ref:t,className:"clickable",onClick:()=>{u&&m(!1)}}),p.jsxs("div",{className:"options",children:[e.camera!==null&&p.jsx(kt,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:f=>{m(f)},up:!0}),p.jsx(kt,{title:"Mode",index:i.indexOf(n),open:h,options:i,onSelect:f=>{if(f===n)return;const _=f;e.onSelectRenderMode(_),a(_)},onToggle:f=>{r&&l(!1),c(f)},up:!0})]})]})});class hr 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;
53
- uniform float uDistance;
54
-
55
- void main() {
56
- // Scale the plane by the drawing distance
57
- worldPosition = position.xzy * uDistance;
58
- worldPosition.xz += cameraPosition.xz;
59
-
60
- gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
61
- }`,fragmentShader:`out vec4 fragColor;
62
- in vec3 worldPosition;
63
-
64
- uniform float uDivisions;
65
- uniform float uScale;
66
- uniform vec3 uColor;
67
- uniform float uDistance;
68
- uniform float uSubgridOpacity;
69
- uniform float uGridOpacity;
70
-
71
- float getGrid(float gapSize) {
72
- vec2 worldPositionByDivision = worldPosition.xz / gapSize;
73
-
74
- // Inverted, 0 where line, >1 where there's no line
75
- // We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
76
- // We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
77
- // worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
78
- // otherwise only one side of the line will be anti-aliased
79
- vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
80
- float gridLine = min(grid.x, grid.y);
81
-
82
- // Uninvert and clamp
83
- return 1.0 - min(gridLine, 1.0);
84
- }
85
-
86
- void main() {
87
- float cameraDistanceToGridPlane = distance(cameraPosition.y, worldPosition.y);
88
- float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xz, worldPosition.xz);
89
-
90
- // The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
91
- // The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
92
- float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
93
- float gridPower = subGridPower * uDivisions;
94
-
95
- // If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
96
- float nextGridPower = gridPower * uDivisions;
97
-
98
- // 1 where grid, 0 where no grid
99
- float subgrid = getGrid(subGridPower * uScale);
100
- float grid = getGrid(gridPower * uScale);
101
- float nextGrid = getGrid(nextGridPower * uScale);
102
-
103
- // Where we are between the introduction of the current grid power and when we switch to the next grid power
104
- float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
105
-
106
- // The last x percentage of the current step over which we want to fade
107
- float fadeRange = 0.3;
108
-
109
- // We calculate the fade percentage from the step percentage and the fade range
110
- float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
111
-
112
- // Set base opacity based on how close we are to the drawing distance, with a cubic falloff
113
- float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
114
-
115
- // Shade the subgrid
116
- fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
117
-
118
- // Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
119
- float fadeCoefficient = 0.5;
120
-
121
- // Shade the grid
122
- fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
123
-
124
- // Shade the next grid
125
- fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
126
-
127
- if (fragColor.a <= 0.0) discard;
128
- }`,name:"InfiniteGrid",depthWrite:!1})}}class dr extends o.Mesh{gridMaterial;constructor(){const e=new hr;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}}function Ji(s){const[e,t]=x.useState(s.selected),i="toggle"+(e?" selected":"");return p.jsx("button",{className:i,onClick:()=>{const n=!e;t(n),s.onClick(n)},style:{backgroundImage:`url(${s.icon})`,backgroundPositionY:`${s.top}px`,backgroundSize:`26px ${s.height}px`}},s.name)}const ur=`#include <common>
129
- #include <batching_pars_vertex>
130
- #include <uv_pars_vertex>
131
- #include <color_pars_vertex>
132
- #include <morphtarget_pars_vertex>
133
- #include <skinning_pars_vertex>
134
- #include <logdepthbuf_pars_vertex>
135
- #include <clipping_planes_pars_vertex>
136
-
137
- void main() {
138
- #include <uv_vertex>
139
- #include <color_vertex>
140
- #include <morphcolor_vertex>
141
- #include <batching_vertex>
142
-
143
- #if defined ( USE_SKINNING )
144
- #include <beginnormal_vertex>
145
- #include <morphnormal_vertex>
146
- #include <skinbase_vertex>
147
- #include <skinnormal_vertex>
148
- #include <defaultnormal_vertex>
149
- #endif
150
-
151
- #include <begin_vertex>
152
- #include <morphtarget_vertex>
153
- #include <skinning_vertex>
154
- #include <project_vertex>
155
- #include <logdepthbuf_vertex>
156
- #include <clipping_planes_vertex>
157
- #include <worldpos_vertex>
158
- }`,pr=`
159
- #include <common>
160
- #include <uv_pars_fragment>
161
- #include <clipping_planes_pars_fragment>
162
-
163
- void main() {
164
- #include <clipping_planes_fragment>
165
- gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
166
- }`;class mr extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:ur,fragmentShader:pr})}}const ze=new o.Raycaster,ce=new o.Vector3,Ue=new o.Vector3,X=new o.Quaternion,es={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},si={type:"change"},ts={type:"mouseDown",mode:null},is={type:"mouseUp",mode:null},ss={type:"objectChange"};class fr extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new br(this);this._root=i;const n=new Er;this._gizmo=n,i.add(n);const a=new Sr;this._plane=a,i.add(a);const r=this;function l(E,b){let S=b;Object.defineProperty(r,E,{get:function(){return S!==void 0?S:b},set:function(O){S!==O&&(S=O,a[E]=O,n[E]=O,r.dispatchEvent({type:E+"-changed",value:O}),r.dispatchEvent(si))}}),r[E]=b,a[E]=b,n[E]=b}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,c=new o.Vector3,u=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,_=new o.Quaternion,w=new o.Vector3,T=new o.Vector3,A=new o.Vector3,g=0,y=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",u),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",_),l("pointStart",w),l("pointEnd",T),l("rotationAxis",A),l("rotationAngle",g),l("eye",y),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=gr.bind(this),this._onPointerDown=vr.bind(this),this._onPointerHover=_r.bind(this),this._onPointerMove=yr.bind(this),this._onPointerUp=Cr.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&&ze.setFromCamera(e,this.camera);const t=ni(this._gizmo.picker[this.mode],ze);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&&ze.setFromCamera(e,this.camera);const t=ni(this._plane,ze,!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,ts.mode=this.mode,this.dispatchEvent(ts)}}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&&ze.setFromCamera(e,this.camera);const r=ni(this._plane,ze,!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(X.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(ce.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(ce.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),Ue.set(l,l,l)}else ce.copy(this.pointStart),Ue.copy(this.pointEnd),ce.applyQuaternion(this._worldQuaternionInv),Ue.applyQuaternion(this._worldQuaternionInv),Ue.divide(ce),t.search("X")===-1&&(Ue.x=1),t.search("Y")===-1&&(Ue.y=1),t.search("Z")===-1&&(Ue.z=1);n.scale.copy(this._scaleStart).multiply(Ue),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(ce.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ce.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(es[t]),ce.copy(es[t]),a==="local"&&ce.applyQuaternion(this.worldQuaternion),ce.cross(this.eye),ce.length()===0?h=!0:this.rotationAngle=this._offset.dot(ce.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(X.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(X.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(si),this.dispatchEvent(ss)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(is.mode=this.mode,this.dispatchEvent(is)),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(si),this.dispatchEvent(ss),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ze}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 gr(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 _r(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function vr(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 yr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function Cr(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ni(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 At=new o.Euler,G=new o.Vector3(0,1,0),ns=new o.Vector3(0,0,0),rs=new o.Matrix4,Pt=new o.Quaternion,Lt=new o.Quaternion,Oe=new o.Vector3,as=new o.Matrix4,mt=new o.Vector3(1,0,0),Ve=new o.Vector3(0,1,0),ft=new o.Vector3(0,0,1),Rt=new o.Vector3,dt=new o.Vector3,ut=new o.Vector3;class br 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 Er 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 c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const m=e.clone();m.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const w=e.clone();w.color.setHex(7895160);const T=new o.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const A=new o.BoxGeometry(.08,.08,.08);A.translate(0,.04,0);const g=new o.BufferGeometry;g.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const y=new o.CylinderGeometry(.0075,.0075,.5,3);y.translate(0,.25,0);function E(Z,Pe){const le=new o.TorusGeometry(Z,.0075,3,64,Pe*Math.PI*2);return le.rotateY(Math.PI/2),le.rotateX(Math.PI/2),le}function b(){const Z=new o.BufferGeometry;return Z.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(y,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(T,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(y,r)]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(y,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),u.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),c.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]]]},I={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(b(),n),null,null,null,"helper"]],X:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},k={XYZE:[[new o.Mesh(E(.5,1),w),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(E(.5,.5),a)]],Y:[[new o.Mesh(E(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},q={AXIS:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},de={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)]]},Se={X:[[new o.Mesh(A,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(y,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(A,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(A,r),[0,.5,0]],[new o.Mesh(y,r)],[new o.Mesh(A,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(A,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(y,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(A,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.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),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},ge={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]]]},oe={X:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function K(Z){const Pe=new o.Object3D;for(const le in Z)for(let fe=Z[le].length;fe--;){const ee=Z[le][fe][0].clone(),Re=Z[le][fe][1],De=Z[le][fe][2],Ie=Z[le][fe][3],B=Z[le][fe][4];ee.name=le,ee.tag=B,Re&&ee.position.set(Re[0],Re[1],Re[2]),De&&ee.rotation.set(De[0],De[1],De[2]),Ie&&ee.scale.set(Ie[0],Ie[1],Ie[2]),ee.updateMatrix();const ne=ee.geometry.clone();ne.applyMatrix4(ee.matrix),ee.geometry=ne,ee.renderOrder=1/0,ee.position.set(0,0,0),ee.rotation.set(0,0,0),ee.scale.set(1,1,1),Pe.add(ee)}return Pe}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=K(S)),this.add(this.gizmo.rotate=K(k)),this.add(this.gizmo.scale=K(Se)),this.add(this.picker.translate=K(O)),this.add(this.picker.rotate=K(de)),this.add(this.picker.scale=K(ge)),this.add(this.helper.translate=K(I)),this.add(this.helper.rotate=K(q)),this.add(this.helper.scale=K(oe)),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:Lt;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"&&(X.setFromEuler(At.set(0,0,0)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(mt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(X.setFromEuler(At.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(X.setFromEuler(At.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(X.setFromEuler(At.set(0,Math.PI/2,0)),G.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(rs.lookAt(ns,G,Ve)),r.quaternion.multiply(X),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),ce.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ce.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ce),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(G.copy(mt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(G.copy(mt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Pt.copy(i),G.copy(this.eye).applyQuaternion(X.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(rs.lookAt(this.eye,ns,Ve)),r.name==="X"&&(X.setFromAxisAngle(mt,Math.atan2(-G.y,G.z)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X)),r.name==="Y"&&(X.setFromAxisAngle(Ve,Math.atan2(G.x,G.z)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X)),r.name==="Z"&&(X.setFromAxisAngle(ft,Math.atan2(G.y,G.x)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X))),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 Sr 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"),Rt.copy(mt).applyQuaternion(t==="local"?this.worldQuaternion:Lt),dt.copy(Ve).applyQuaternion(t==="local"?this.worldQuaternion:Lt),ut.copy(ft).applyQuaternion(t==="local"?this.worldQuaternion:Lt),G.copy(dt),this.mode){case"translate":case"scale":switch(this.axis){case"X":G.copy(this.eye).cross(Rt),Oe.copy(Rt).cross(G);break;case"Y":G.copy(this.eye).cross(dt),Oe.copy(dt).cross(G);break;case"Z":G.copy(this.eye).cross(ut),Oe.copy(ut).cross(G);break;case"XY":Oe.copy(ut);break;case"YZ":Oe.copy(Rt);break;case"XZ":G.copy(ut),Oe.copy(dt);break;case"XYZ":case"E":Oe.set(0,0,0);break}break;case"rotate":default:Oe.set(0,0,0)}Oe.length()===0?this.quaternion.copy(this.cameraQuaternion):(as.lookAt(ce.set(0,0,0),Oe,G),this.quaternion.setFromRotationMatrix(as)),super.updateMatrixWorld(e)}}class he extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;constructor(){super(),R.addEventListener(P.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Ae(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 fr(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:he.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:he.DRAG_END})}),t.addEventListener("dragging-changed",n=>{ae.instance?.toggleOrbitControls(n.value)})}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(),Ae(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})}setScene=()=>{this.clear()};static get instance(){return he._instance||(he._instance=new he),he._instance}}const wr=new o.BoxGeometry,ri=new o.Vector2;class pi 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(Qe(.5,1,Math.random()),Qe(.5,1,Math.random()),Qe(.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),he.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([Ee(t.position.x,3),Ee(t.position.y,3),Ee(t.position.z,3)])}),hs({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(wr,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(Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()),Qe(-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)}Ae(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(!ae.instance||this._transform&&!this._transform.getHelper().visible)return;const i=ae.instance.currentWindow.current.getBoundingClientRect();ri.x=(e.clientX-i.x)/i.width*2-1,ri.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ri,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=he.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),ae.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":Ae(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 Dt=0;class ws extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,R.addEventListener(P.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=ie.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(){R.removeEventListener(P.ADD_SPLINE,this.onAddSpline),ie.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 ${Dt+1}`,i=new pi(t,this._camera);return i.addPoints(e),this.addSpline(i),Dt++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCatmullRom=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 ${Dt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new pi(i,this.camera);a.addPoints(n),this.addSpline(a),Dt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const os=["Single","Side by Side","Stacked","Quad"],xr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",Or="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==";class ae extends x.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 dr;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new mr;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;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=x.createRef(),this.containerRef=x.createRef(),this.tlWindow=x.createRef(),this.trWindow=x.createRef(),this.blWindow=x.createRef(),this.brWindow=x.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};Te.install({THREE:a}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);this.cameraVisibility=r!==null?r==="open":!1,this.saveExpandedCameraVisibility();const l=localStorage.getItem(this.expandedLightVisibility);this.lightVisibility=l!==null?l==="open":!1,this.saveExpandedLightVisibility(),ae.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),he.instance.three=this.props.three,he.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)}),p.jsxs("div",{className:"multiview",children:[p.jsx("canvas",{ref:this.canvasRef}),p.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&p.jsx(p.Fragment,{children:p.jsx(Fe,{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")&&p.jsxs(p.Fragment,{children:[p.jsx(Fe,{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)}}),p.jsx(Fe,{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"&&p.jsxs(p.Fragment,{children:[p.jsx(Fe,{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)}}),p.jsx(Fe,{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)}}),p.jsx(Fe,{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)}}),p.jsx(Fe,{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)}})]})]}),p.jsxs("div",{className:"settings",children:[p.jsx(kt,{title:"View",index:os.indexOf(this.state.mode),options:os,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),p.jsx(kt,{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})}}),p.jsx(Ji,{name:"cameraHelper",icon:xr,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem instanceof o.PerspectiveCamera){const i=this.cameraHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}}),p.jsx(Ji,{name:"lightHelper",icon:Or,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const i=this.lightHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}})]},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 ws(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),R.addEventListener(P.SET_SCENE,this.sceneUpdate),R.addEventListener(P.ADD_CAMERA,this.addCamera),R.addEventListener(P.REMOVE_CAMERA,this.removeCamera),R.addEventListener(P.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),R.removeEventListener(P.SET_SCENE,this.sceneUpdate),R.removeEventListener(P.ADD_CAMERA,this.addCamera),R.removeEventListener(P.REMOVE_CAMERA,this.removeCamera),R.removeEventListener(P.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),Ae(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);n.visible=this.cameraVisibility,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=Xe(i,0,t.x,-1,1),this.pointer.y=Xe(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=Xe(i,0,a,-1,1):this.pointer.x=Xe(i,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Xe(n,0,r,1,-1):this.pointer.y=Xe(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 c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(di(45),di(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;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),he.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=he.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0){if(this.selectedItem instanceof o.PerspectiveCamera&&!this.cameraVisibility){const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}else if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}}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),Ft.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`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Zn(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,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 Xn(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),he.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-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=li(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}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}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}}class Ft extends x.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);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;this.open=i,this.saveExpanded(),this.state={lastUpdated:0,expanded:i},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)),Ft.instance=this}update(){if(ae.instance){const e=ae.instance.selectedItem;if(e===void 0)return;this.position.x=Ee(e.position.x,3),this.position.y=Ee(e.position.y,3),this.position.z=Ee(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=Ee(e.scale.x,3),this.scale.y=Ee(e.scale.y,3),this.scale.z=Ee(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return p.jsx(ye,{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.saveExpanded()}},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);J(a,e,i)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function ls(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 Mr(s,e){function t(){return`${e.app.appID}_light`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(s.lightInfo!==void 0)for(const l in s.lightInfo){const h=s.lightInfo[l];h!==void 0&&(h.isColor!==void 0?r.push({title:ls(l),prop:l,type:"color",value:h,onChange:(c,u)=>{const m=new o.Color(u);e.updateObject(s.uuid,c,m);const f=e.getScene(s.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",s.uuid);J(_,c,m)}}}):r.push({title:ls(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,u)=>{e.updateObject(s.uuid,c,u);const m=e.getScene(s.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",s.uuid);J(f,c,u)}}}))}return p.jsx(ye,{title:"Light",items:r,expanded:n,onToggle:l=>{a(l)}})}function Tr(s){const e=s.object,t=s.three;function i(){return`${t.app.appID}_animation`}const n=localStorage.getItem(i()),a=n!==null?n==="open":!1;function r(f){localStorage.setItem(i(),f?"open":"closed")}const l=[],h=[];let c=0;e.animations.forEach(f=>{c=Math.max(c,f.duration),f.duration>0&&h.push({title:f.name,items:[{title:"Duration",type:"number",value:f.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:h});let u;const m=t.getScene(e.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",e.uuid);if(f!==void 0){const _=f.mixer;if(_!==void 0){const T=[{title:"Time Scale",type:"range",value:_.timeScale,step:.01,min:-1,max:2,onChange:(A,g)=>{_.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];T.push({title:"Stop All",type:"button",onChange:()=>{_.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:T}),u=new o.SkeletonHelper(f),ae.instance?.scene.add(u)}}}return x.useEffect(()=>()=>{u!==void 0&&Ae(u)},[]),p.jsx(ye,{title:"Animation",items:l,expanded:a,onToggle:f=>{r(f)}})}const mi={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let re={...mi};function xs(s){const[e,t]=x.useState(-1);x.useEffect(()=>{function r(h){re={...h.value},t(Date.now())}function l(){re={...mi},t(Date.now())}return R.addEventListener(P.SET_SCENE,l),R.addEventListener(P.SET_OBJECT,r),()=>{R.removeEventListener(P.SET_SCENE,l),R.removeEventListener(P.SET_OBJECT,r)}},[]);const i=re.type.toLowerCase(),n=re.animations.length>0||re.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return p.jsx(vt,{label:"Inspector",button:re.uuid.length>0?p.jsx("button",{className:"remove",onClick:()=>{he.instance.remove(re.name),re={...mi},t(Date.now())}}):void 0,children:p.jsx("div",{id:"Inspector",className:s.class,children:re.uuid.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(p.Fragment,{children:[p.jsx(It,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),p.jsx(It,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),p.jsx(It,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0})]}),p.jsxs(p.Fragment,{children:[p.jsx(Ft,{object:re,three:s.three}),n?p.jsx(Tr,{object:re,three:s.three}):null,i.search("camera")>-1?Gn(re,s.three):null,i.search("light")>-1?Mr(re,s.three):null,a?Vn(re,s.three):null]})]})},e)},"Inspector")}class Ar extends x.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=o.SRGBColorSpace;localClippingEnabled=!1;clearColor=new o.Color(0);clearAlpha=1;toneMapping=o.NoToneMapping;toneMappingExposure=1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;if(this.state={expanded:i,lastUpdated:Date.now()},this.saveExpanded(i),ae.instance){const n=ae.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n.getClearColor(this.clearColor))}R.addEventListener(P.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){R.removeEventListener(P.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,o.LinearSRGBColorSpace),o.ColorManagement.enabled=t.colorManagement,ae.instance){const i=ae.instance.renderer;i&&(i.autoClear=this.autoClear,i.autoClearColor=this.autoClearColor,i.autoClearDepth=this.autoClearDepth,i.autoClearStencil=this.autoClearStencil,i.outputColorSpace=this.outputColorSpace,i.localClippingEnabled=this.localClippingEnabled,i.toneMapping=this.toneMapping,i.toneMappingExposure=this.toneMappingExposure,i.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(ae.instance){const t=ae.instance.renderer;t&&(t.autoClear=this.autoClear,t.autoClearColor=this.autoClearColor,t.autoClearDepth=this.autoClearDepth,t.autoClearStencil=this.autoClearStencil,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:o.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return p.jsx(ye,{title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,i)=>{this.autoClear=i}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,i)=>{this.autoClearColor=i,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,i)=>{this.autoClearDepth=i,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,i)=>{this.autoClearStencil=i,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,i)=>{this.localClippingEnabled=i,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,i)=>{this.clearColor.setStyle(i),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,i)=>{this.clearAlpha=i,e()}},{type:"boolean",title:"Clear Management",value:o.ColorManagement.enabled,onChange:(t,i)=>{o.ColorManagement.enabled=i,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:o.NoColorSpace},{title:"SRB Color Space",value:o.SRGBColorSpace},{title:"Linear SRB Color Space",value:o.LinearSRGBColorSpace}],onChange:(t,i)=>{this.outputColorSpace=i,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:o.NoToneMapping},{title:"Linear ",value:o.LinearToneMapping},{title:"Reinhard",value:o.ReinhardToneMapping},{title:"Cineon ",value:o.CineonToneMapping},{title:"ACES Filmic",value:o.ACESFilmicToneMapping},{title:"AgX",value:o.AgXToneMapping},{title:"Neutral",value:o.NeutralToneMapping},{title:"Custom",value:o.CustomToneMapping}],onChange:(t,i)=>{this.toneMapping=i,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,i)=>{this.toneMappingExposure=i,e()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Os(s){const[e]=x.useState([]),[t]=x.useState([]),[i,n]=x.useState(0),a=u=>{const m=u.value;e.push(m),t.push(p.jsx(vt,{label:`Scene: ${m.name}`,scene:m,open:!0,onRefresh:()=>{s.three.refreshScene(m.name)},children:p.jsx(hi,{child:m,scene:m,three:s.three})},Math.random())),n(Date.now())},r=u=>{const m=u.value;for(let f=0;f<e.length;f++)if(m.uuid===e[f].uuid){e[f]=m,t[f]=p.jsx(vt,{label:`Scene: ${m.name}`,scene:m,open:!0,onRefresh:()=>{s.three.refreshScene(m.name)},children:p.jsx(hi,{child:m,scene:m,three:s.three})},Math.random()),n(Date.now());return}},l=u=>{const m=u.value;for(let f=0;f<e.length;f++)if(m.uuid===e[f].uuid){e.splice(f,1),t.splice(f,1),n(Date.now());return}};x.useEffect(()=>(R.addEventListener(P.ADD_SCENE,a),R.addEventListener(P.REFRESH_SCENE,r),R.addEventListener(P.REMOVE_SCENE,l),()=>{R.removeEventListener(P.ADD_SCENE,a),R.removeEventListener(P.REFRESH_SCENE,r),R.removeEventListener(P.REMOVE_SCENE,l)}),[]);const[h,c]=x.useState(0);return p.jsxs("div",{id:"SidePanel",children:[p.jsx("div",{className:"scenes",children:t},i),p.jsx(xs,{three:s.three}),p.jsx(Ar,{three:s.three}),p.jsx(ie,{three:s.three}),p.jsx("input",{type:"number",value:h,onChange:u=>{const m=u.target.value;console.log(`Value: ${m}, Length: ${m.length}, #${Number(m)}`),c(m)}})]})}function Pr(s){return x.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,u=e(h)?.getObjectByProperty("uuid",h);u!==void 0&&s.three.setObject(u)},i=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&J(m,h,c)},n=l=>{const h=l.value,{key:c,value:u,uuid:m}=h;i(m,c,u)},a=l=>{const h=l.value,u=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(u!==void 0){const m=f=>{const _=h.key.split(".");switch(_.length){case 1:u[_[0]]=f;break;case 2:u[_[0]][_[1]]=f;break;case 3:u[_[0]][_[1]][_[2]]=f;break;case 4:u[_[0]][_[1]][_[2]][_[3]]=f;break;case 5:u[_[0]][_[1]][_[2]][_[3]][_[4]]=f;break}u.material.needsUpdate=!0};h.value.src.length>0?gs(h.value.src).then(f=>{f.offset.set(h.value.offset[0],h.value.offset[1]),f.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(f)}):m(null)}},r=l=>{const{key:h,uuid:c,value:u,subitem:m}=l.value,_=e(c)?.getObjectByProperty("uuid",c);if(_!==void 0)try{m!==void 0?mn(_,m)[h](u):_[h](u)}catch(w){console.log("Error requesting method:"),console.log(w),console.log(h),console.log(u)}};return R.addEventListener(P.GET_OBJECT,t),R.addEventListener(P.UPDATE_OBJECT,n),R.addEventListener(P.CREATE_TEXTURE,a),R.addEventListener(P.REQUEST_METHOD,r),()=>{R.removeEventListener(P.GET_OBJECT,t),R.removeEventListener(P.UPDATE_OBJECT,n),R.removeEventListener(P.CREATE_TEXTURE,a),R.removeEventListener(P.REQUEST_METHOD,r)}},[]),null}function Ms(s){return p.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[p.jsx("div",{className:"header",children:s.header}),s.children,p.jsx("div",{className:"footer",children:s.footer})]})}function Rr(s){return p.jsx(Ms,{children:p.jsxs(p.Fragment,{children:[p.jsx(ae,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),p.jsx(Os,{three:s.three})]})})}exports.Accordion=vt;exports.Application=an;exports.BaseRemote=jt;exports.ChildObject=_i;exports.ContainerObject=hi;exports.Draggable=vs;exports.DraggableItem=_s;exports.Dropdown=ys;exports.DropdownItem=Cs;exports.Editor=Ms;exports.ExportTexture=gt;exports.Inspector=xs;exports.MultiView=ae;exports.NavButton=gi;exports.QualityType=fs;exports.RemoteComponents=on;exports.RemoteController=bn;exports.RemoteTheatre=hn;exports.RemoteThree=gn;exports.SceneInspector=Pr;exports.SidePanel=Os;exports.Spline=pi;exports.SplineEditor=ws;exports.ThreeEditor=Rr;exports.ToolEvents=P;exports.Transform=he;exports.capitalize=_t;exports.colorToHex=ai;exports.copyToClipboard=hs;exports.customizeTheatreElements=cn;exports.debugDispatcher=R;exports.defaultTheatreCallback=Ks;exports.detectSettings=rn;exports.dispose=Ae;exports.disposeMaterial=ps;exports.disposeTexture=$s;exports.hierarchyUUID=Ut;exports.isColor=us;exports.noop=fi;exports.randomID=ds;exports.resetThreeObjects=oi;exports.theatreEditorApp=ln;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),O=require("react"),cs=require("framer-motion"),gi=()=>{},Ks=()=>{};function _t(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function hs(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function ds(){return Math.round(Math.random()*1e6).toString()}function us(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function oi(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),i=Math.round(s.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=n(e),r=n(t),l=n(i);return"#"+a+r+l}function Wt(s,e,t,i){return new(t||(t=Promise))(function(n,a){function r(c){try{h(i.next(c))}catch(u){a(u)}}function l(c){try{h(i.throw(c))}catch(u){a(u)}}function h(c){var u;c.done?n(c.value):(u=c.value,u instanceof t?u:new t(function(m){m(u)})).then(r,l)}h((i=i.apply(s,e||[])).next())})}const $s=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function Li(s){return s=s.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const ps=typeof window>"u",Me=(()=>{if(ps)return;const{userAgent:s,platform:e,maxTouchPoints:t}=window.navigator,i=/(iphone|ipod|ipad)/i.test(s),n=e==="iPad"||e==="MacIntel"&&t>0&&!window.MSStream;return{isIpad:n,isMobile:/android/i.test(s)||i||n,isSafari12:/Version\/12.+Safari/.test(s),isFirefox:/Firefox/.test(s)}})();function Js(s,e,t){if(!t)return[e];const i=function(c){const u=`
2
+ precision highp float;
3
+ attribute vec3 aPosition;
4
+ varying float vvv;
5
+ void main() {
6
+ vvv = 0.31622776601683794;
7
+ gl_Position = vec4(aPosition, 1.0);
8
+ }
9
+ `,m=`
10
+ precision highp float;
11
+ varying float vvv;
12
+ void main() {
13
+ vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;
14
+ enc = fract(enc);
15
+ enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
16
+ gl_FragColor = enc;
17
+ }
18
+ `,f=c.createShader(35633),_=c.createShader(35632),w=c.createProgram();if(!(_&&f&&w))return;c.shaderSource(f,u),c.shaderSource(_,m),c.compileShader(f),c.compileShader(_),c.attachShader(w,f),c.attachShader(w,_),c.linkProgram(w),c.detachShader(w,f),c.detachShader(w,_),c.deleteShader(f),c.deleteShader(_),c.useProgram(w);const T=c.createBuffer();c.bindBuffer(34962,T),c.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const A=c.getAttribLocation(w,"aPosition");c.vertexAttribPointer(A,3,5126,!1,0,0),c.enableVertexAttribArray(A),c.clearColor(1,1,1,1),c.clear(16384),c.viewport(0,0,1,1),c.drawArrays(4,0,3);const g=new Uint8Array(4);return c.readPixels(0,0,1,1,6408,5121,g),c.deleteProgram(w),c.deleteBuffer(T),g.join("")}(s),n="801621810",a="8016218135",r="80162181161",l=Me?.isIpad?[["a7",r,12],["a8",a,15],["a8x",a,15],["a9",a,15],["a9x",a,15],["a10",a,15],["a10x",a,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",r,12],["a8",a,12],["a9",a,15],["a10",a,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let h;return i==="80162181255"?h=l.filter(([,,c])=>c>=14):(h=l.filter(([,c])=>c===i),h.length||(h=l)),h.map(([c])=>`apple ${c} gpu`)}class Ui extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const Xt=[],ki=[];function en(s,e){if(s===e)return 0;const t=s;s.length>e.length&&(s=e,e=t);let i=s.length,n=e.length;for(;i>0&&s.charCodeAt(~-i)===e.charCodeAt(~-n);)i--,n--;let a,r=0;for(;r<i&&s.charCodeAt(r)===e.charCodeAt(r);)r++;if(i-=r,n-=r,i===0)return n;let l,h,c=0,u=0,m=0;for(;u<i;)ki[u]=s.charCodeAt(r+u),Xt[u]=++u;for(;m<n;)for(a=e.charCodeAt(r+m),l=m++,c=m,u=0;u<i;u++)h=a===ki[u]?l:l+1,l=Xt[u],c=Xt[u]=l>c?h>c?c+1:h:h>l?l+1:h;return c}function tn(s){return s!=null}const sn=({mobileTiers:s=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:i,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:a="https://unpkg.com/detect-gpu@5.0.57/dist/benchmarks"}={})=>Wt(void 0,void 0,void 0,function*(){const r={};if(ps)return{tier:0,type:"SSR"};const{isIpad:l=!!Me?.isIpad,isMobile:h=!!Me?.isMobile,screenSize:c=window.screen,loadBenchmarks:u=S=>Wt(void 0,void 0,void 0,function*(){const x=yield fetch(`${a}/${S}`).then(I=>I.json());if(parseInt(x.shift().split(".")[0],10)<4)throw new Ui("Detect GPU benchmark data is out of date. Please update to version 4x");return x})}=t;let{renderer:m}=t;const f=(S,x,I,k,q)=>({device:q,fps:k,gpu:I,isMobile:h,tier:S,type:x});let _,w="";if(m)m=Li(m),_=[m];else{const S=i||function(I,k=!1){const q={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:k,powerPreference:"high-performance",stencil:!1};I&&delete q.powerPreference;const de=window.document.createElement("canvas"),Se=de.getContext("webgl",q)||de.getContext("experimental-webgl",q);return Se??void 0}(Me?.isSafari12,n);if(!S)return f(0,"WEBGL_UNSUPPORTED");const x=Me?.isFirefox?null:S.getExtension("WEBGL_debug_renderer_info");if(m=x?S.getParameter(x.UNMASKED_RENDERER_WEBGL):S.getParameter(S.RENDERER),!m)return f(1,"FALLBACK");w=m,m=Li(m),_=function(I,k,q){return k==="apple gpu"?Js(I,k,q):[k]}(S,m,h)}const T=(yield Promise.all(_.map(function(S){var x;return Wt(this,void 0,void 0,function*(){const I=(B=>{const ne=h?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const be of ne)if(B.includes(be))return be})(S);if(!I)return;const k=`${h?"m":"d"}-${I}${l?"-ipad":""}.json`,q=r[k]=(x=r[k])!==null&&x!==void 0?x:u(k);let de;try{de=yield q}catch(B){if(B instanceof Ui)throw B;return}const Se=function(B){var ne;const be=(B=B.replace(/\([^)]+\)/,"")).match(/\d+/)||B.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(ne=be?.join("").replace(/\W|amd/g,""))!==null&&ne!==void 0?ne:""}(S);let ge=de.filter(([,B])=>B===Se);ge.length||(ge=de.filter(([B])=>B.includes(S)));const oe=ge.length;if(oe===0)return;const K=S.split(/[.,()\[\]/\s]/g).sort().filter((B,ne,be)=>ne===0||B!==be[ne-1]).join(" ");let Z,[Pe,,,,le]=oe>1?ge.map(B=>[B,en(K,B[2])]).sort(([,B],[,ne])=>B-ne)[0][0]:ge[0],fe=Number.MAX_VALUE;const{devicePixelRatio:ee}=window,Re=c.width*ee*c.height*ee;for(const B of le){const[ne,be]=B,tt=ne*be,Ye=Math.abs(Re-tt);Ye<fe&&(fe=Ye,Z=B)}if(!Z)return;const[,,De,Ie]=Z;return[fe,De,Pe,Ie]})}))).filter(tn).sort(([S=Number.MAX_VALUE,x],[I=Number.MAX_VALUE,k])=>S===I?x-k:S-I);if(!T.length){const S=$s.find(x=>m.includes(x));return S?f(0,"BLOCKLISTED",S):f(1,"FALLBACK",`${m} (${w})`)}const[,A,g,y]=T[0];if(A===-1)return f(0,"BLOCKLISTED",g,A,y);const E=h?s:e;let b=0;for(let S=0;S<E.length;S++)A>=E[S]&&(b=S);return f(b,"BENCHMARK",g,A,y)});var ms=(s=>(s[s.High=0]="High",s[s.Medium=1]="Medium",s[s.Low=2]="Low",s))(ms||{});function nn(s){return new Promise(e=>{sn().then(t=>{let i=!1;const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(i="transferControlToOffscreen"in s,n){const r=navigator.userAgent.match(/version\/(\d+)/i);i=(r?parseInt(r[1]):0)>=17}const a={dpr:devicePixelRatio,fps:t.fps!==void 0?t.fps:30,width:innerWidth,height:innerHeight,mobile:t.isMobile!==void 0?t.isMobile:!1,supportOffScreenCanvas:i,quality:2};t.tier===3?a.quality=0:t.tier===2&&(a.quality=1),e(a)})})}function je(s,e,t){return Math.min(e,Math.max(s,t))}function li(s,e,t){return(t-s)/(e-s)}function Ut(s,e,t){return s*(1-t)+e*t}function rn(s,e){const t=s-e;return Math.sqrt(t*t)}function ye(s,e=1){return Number(s.toFixed(e))}const an=s=>{s?.dispose()},fs=s=>{s&&(Array.isArray(s)?s.forEach(e=>e.dispose()):s.dispose())},Ae=s=>{if(s){for(;s.children.length>0;){const e=s.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Ae(e)}if(s.parent&&s.parent.remove(s),s.isMesh){const e=s;e.geometry?.dispose(),fs(e.material)}s.dispose!==void 0&&s.dispose()}};exports.totalThreeObjects=0;const ci=()=>{exports.totalThreeObjects=0},kt=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=>kt(t))};class gt{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 on{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 P=(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.ADD_RENDERER="ToolEvents::addRenderer",s.UPDATE_RENDERER="ToolEvents::updateRenderer",s))(P||{});const R=new o.EventDispatcher;class Nt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,i){}handleEditor(e,t,i){}}class ln extends Nt{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":R.dispatchEvent({type:P.SELECT_DROPDOWN,value:i.data});break;case"draggableListUpdate":R.dispatchEvent({type:P.DRAG_UPDATE,value:i.data});break}}}function cn(s,e,t){if(s.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}s.send({event:c,target:"app",data:u})})});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 hn(){setTimeout(()=>{const s=document.getElementById("theatrejs-studio-root");if(s===null||s.shadowRoot===null)return;const e=s.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t===null)return;const i=t.children[1];i.style.justifyContent="left";try{const n=i.children[1];for(n.style.transform="translateX(10px)";n.children.length>1;)n.removeChild(n.children[0])}catch{}try{const n=t.children[3];n.style.top="0",n.style.right="300px"}catch{}},1e3)}class dn extends Nt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=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 new Promise(n=>{const a=t!==void 0?{...t}:{};this.sheet(e,i)?.sequence.play(a).then(r=>n(r)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:i,value:t}})})}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 c=this.sheetObjects.get(h);c!==void 0?c=r.object(t,{...i,...c.value},{reconfigure:!0}):c=r.object(t,i),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:gi);const u=c.onValuesChange(m=>{if(this.app.editor){for(const _ in m){const w=m[_];typeof w=="object"&&us(w)&&(m[_]={r:w.r,g:w.g,b:w.b,a:w.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:m}})}const f=this.sheetObjectCBs.get(h);f!==void 0&&f(m)});return this.sheetObjectUnsubscribe.set(h,u),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const 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,c="setSheet",u={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",u={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,u={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:u})})});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 un(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 et(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(et(t))}),e}function pn(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 mn(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function We(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||mn(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:gt.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=pn(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 Qt(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(We(a))}),e.material=n}else e.material=We(i.material)}else if(t.search("points")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(We(a))}),e.material=n}else e.material=We(i.material)}else if(t.search("line")>-1){const i=s;if(Array.isArray(i.material)){const n=[];i.material.forEach(a=>{n.push(We(a))}),e.material=n}else e.material=We(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 fn(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 gn(s,e){for(const t in e)s[t]=e[t]}function J(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&&gn(r,t)}}function gs(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 _n extends Nt{canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Ae(e)}),this.scenes.clear(),this.scene&&Ae(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(gt.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(gt.renderer=this.renderer);const t=Qt(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)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t,!this.app.debugEnabled)return;const i=`#${e.getClearColor(new o.Color).getHexString()}`;this.app.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:i,clearAlpha:e.getClearAlpha(),colorManagement:o.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure}})}updateRenderer(e){this.app.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;ci(),kt(e);const t=et(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=et(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=et(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&&(gt.renderer=this.renderer),ci(),kt(e);const t=et(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Qt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Qt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,i){const n=t;switch(i.event){case"getObject":R.dispatchEvent({type:P.GET_OBJECT,value:i.data});break;case"updateObject":R.dispatchEvent({type:P.UPDATE_OBJECT,value:i.data});break;case"createTexture":R.dispatchEvent({type:P.CREATE_TEXTURE,value:i.data});break;case"requestMethod":R.dispatchEvent({type:P.REQUEST_METHOD,value:i.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:et(n.scenes.get(i.data.name))});break;case"updateRenderer":n.renderer&&(n.renderer.autoClear=i.data.autoClear,n.renderer.autoClearColor=i.data.autoClearColor,n.renderer.autoClearDepth=i.data.autoClearDepth,n.renderer.autoClearStencil=i.data.autoClearStencil,n.renderer.outputColorSpace=i.data.outputColorSpace,n.renderer.localClippingEnabled=i.data.localClippingEnabled,n.renderer.setClearColor(i.data.clearColor,i.data.clearAlpha),n.renderer.toneMapping=i.data.toneMapping,n.renderer.toneMappingExposure=i.data.toneMappingExposure,o.ColorManagement.enabled=i.data.colorManagement);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":R.dispatchEvent({type:P.SET_OBJECT,value:i.data});break;case"addScene":R.dispatchEvent({type:P.ADD_SCENE,value:i.data});break;case"refreshScene":R.dispatchEvent({type:P.REFRESH_SCENE,value:i.data});break;case"removeScene":R.dispatchEvent({type:P.REMOVE_SCENE,value:i.data});break;case"setScene":R.dispatchEvent({type:P.SET_SCENE,value:i.data});break;case"addCamera":R.dispatchEvent({type:P.ADD_CAMERA,value:i.data});break;case"removeCamera":R.dispatchEvent({type:P.REMOVE_CAMERA,value:i.data});break;case"addGroup":R.dispatchEvent({type:P.ADD_GROUP,value:i.data});break;case"removeGroup":R.dispatchEvent({type:P.REMOVE_GROUP,value:i.data});break;case"addSpline":R.dispatchEvent({type:P.ADD_SPLINE,value:i.data});break;case"addRenderer":R.dispatchEvent({type:P.ADD_RENDERER,value:i.data})}}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(a=>{a.setSize(e*i,t*i)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(je(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}}var hi={exports:{}},st={};/**
19
+ * @license React
20
+ * react-jsx-runtime.production.min.js
21
+ *
22
+ * Copyright (c) Facebook, Inc. and its affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var ji;function vn(){if(ji)return st;ji=1;var s=O,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,c){var u,m={},f=null,_=null;c!==void 0&&(f=""+c),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(_=h.ref);for(u in h)i.call(h,u)&&!a.hasOwnProperty(u)&&(m[u]=h[u]);if(l&&l.defaultProps)for(u in h=l.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:e,type:l,key:f,ref:_,props:m,_owner:n.current}}return st.Fragment=t,st.jsx=r,st.jsxs=r,st}var nt={};/**
27
+ * @license React
28
+ * react-jsx-runtime.development.js
29
+ *
30
+ * Copyright (c) Facebook, Inc. and its affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var Ni;function yn(){return Ni||(Ni=1,process.env.NODE_ENV!=="production"&&function(){var s=O,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"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),w=Symbol.iterator,T="@@iterator";function A(d){if(d===null||typeof d!="object")return null;var C=w&&d[w]||d[T];return typeof C=="function"?C:null}var g=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(d){{for(var C=arguments.length,M=new Array(C>1?C-1:0),L=1;L<C;L++)M[L-1]=arguments[L];E("error",d,M)}}function E(d,C,M){{var L=g.ReactDebugCurrentFrame,z=L.getStackAddendum();z!==""&&(C+="%s",M=M.concat([z]));var Y=M.map(function(N){return String(N)});Y.unshift("Warning: "+C),Function.prototype.apply.call(console[d],console,Y)}}var b=!1,S=!1,x=!1,I=!1,k=!1,q;q=Symbol.for("react.module.reference");function de(d){return!!(typeof d=="string"||typeof d=="function"||d===i||d===a||k||d===n||d===c||d===u||I||d===_||b||S||x||typeof d=="object"&&d!==null&&(d.$$typeof===f||d.$$typeof===m||d.$$typeof===r||d.$$typeof===l||d.$$typeof===h||d.$$typeof===q||d.getModuleId!==void 0))}function Se(d,C,M){var L=d.displayName;if(L)return L;var z=C.displayName||C.name||"";return z!==""?M+"("+z+")":M}function ge(d){return d.displayName||"Context"}function oe(d){if(d==null)return null;if(typeof d.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case i:return"Fragment";case t:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case l:var C=d;return ge(C)+".Consumer";case r:var M=d;return ge(M._context)+".Provider";case h:return Se(d,d.render,"ForwardRef");case m:var L=d.displayName||null;return L!==null?L:oe(d.type)||"Memo";case f:{var z=d,Y=z._payload,N=z._init;try{return oe(N(Y))}catch{return null}}}return null}var K=Object.assign,Z=0,Pe,le,fe,ee,Re,De,Ie;function B(){}B.__reactDisabledLog=!0;function ne(){{if(Z===0){Pe=console.log,le=console.info,fe=console.warn,ee=console.error,Re=console.group,De=console.groupCollapsed,Ie=console.groupEnd;var d={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:d,log:d,warn:d,error:d,group:d,groupCollapsed:d,groupEnd:d})}Z++}}function be(){{if(Z--,Z===0){var d={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},d,{value:Pe}),info:K({},d,{value:le}),warn:K({},d,{value:fe}),error:K({},d,{value:ee}),group:K({},d,{value:Re}),groupCollapsed:K({},d,{value:De}),groupEnd:K({},d,{value:Ie})})}Z<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var tt=g.ReactCurrentDispatcher,Ye;function yt(d,C,M){{if(Ye===void 0)try{throw Error()}catch(z){var L=z.stack.trim().match(/\n( *(at )?)/);Ye=L&&L[1]||""}return`
35
+ `+Ye+d}}var Ht=!1,Ct;{var Ts=typeof WeakMap=="function"?WeakMap:Map;Ct=new Ts}function Ci(d,C){if(!d||Ht)return"";{var M=Ct.get(d);if(M!==void 0)return M}var L;Ht=!0;var z=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Y;Y=tt.current,tt.current=null,ne();try{if(C){var N=function(){throw Error()};if(Object.defineProperty(N.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(N,[])}catch(Le){L=Le}Reflect.construct(d,[],N)}else{try{N.call()}catch(Le){L=Le}d.call(N.prototype)}}else{try{throw Error()}catch(Le){L=Le}d()}}catch(Le){if(Le&&L&&typeof Le.stack=="string"){for(var j=Le.stack.split(`
36
+ `),ue=L.stack.split(`
37
+ `),$=j.length-1,te=ue.length-1;$>=1&&te>=0&&j[$]!==ue[te];)te--;for(;$>=1&&te>=0;$--,te--)if(j[$]!==ue[te]){if($!==1||te!==1)do if($--,te--,te<0||j[$]!==ue[te]){var _e=`
38
+ `+j[$].replace(" at new "," at ");return d.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",d.displayName)),typeof d=="function"&&Ct.set(d,_e),_e}while($>=1&&te>=0);break}}}finally{Ht=!1,tt.current=Y,be(),Error.prepareStackTrace=z}var Ze=d?d.displayName||d.name:"",Ii=Ze?yt(Ze):"";return typeof d=="function"&&Ct.set(d,Ii),Ii}function As(d,C,M){return Ci(d,!1)}function Ps(d){var C=d.prototype;return!!(C&&C.isReactComponent)}function bt(d,C,M){if(d==null)return"";if(typeof d=="function")return Ci(d,Ps(d));if(typeof d=="string")return yt(d);switch(d){case c:return yt("Suspense");case u:return yt("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return As(d.render);case m:return bt(d.type,C,M);case f:{var L=d,z=L._payload,Y=L._init;try{return bt(Y(z),C,M)}catch{}}}return""}var Et=Object.prototype.hasOwnProperty,bi={},Ei=g.ReactDebugCurrentFrame;function St(d){if(d){var C=d._owner,M=bt(d.type,d._source,C?C.type:null);Ei.setExtraStackFrame(M)}else Ei.setExtraStackFrame(null)}function Rs(d,C,M,L,z){{var Y=Function.call.bind(Et);for(var N in d)if(Y(d,N)){var j=void 0;try{if(typeof d[N]!="function"){var ue=Error((L||"React class")+": "+M+" type `"+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[N]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}j=d[N](C,N,L,M,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){j=$}j&&!(j instanceof Error)&&(St(z),y("%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).",L||"React class",M,N,typeof j),St(null)),j instanceof Error&&!(j.message in bi)&&(bi[j.message]=!0,St(z),y("Failed %s type: %s",M,j.message),St(null))}}}var Ds=Array.isArray;function Vt(d){return Ds(d)}function Is(d){{var C=typeof Symbol=="function"&&Symbol.toStringTag,M=C&&d[Symbol.toStringTag]||d.constructor.name||"Object";return M}}function Ls(d){try{return Si(d),!1}catch{return!0}}function Si(d){return""+d}function wi(d){if(Ls(d))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Is(d)),Si(d)}var it=g.ReactCurrentOwner,Us={key:!0,ref:!0,__self:!0,__source:!0},xi,Oi,Bt;Bt={};function ks(d){if(Et.call(d,"ref")){var C=Object.getOwnPropertyDescriptor(d,"ref").get;if(C&&C.isReactWarning)return!1}return d.ref!==void 0}function js(d){if(Et.call(d,"key")){var C=Object.getOwnPropertyDescriptor(d,"key").get;if(C&&C.isReactWarning)return!1}return d.key!==void 0}function Ns(d,C){if(typeof d.ref=="string"&&it.current&&C&&it.current.stateNode!==C){var M=oe(it.current.type);Bt[M]||(y('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',oe(it.current.type),d.ref),Bt[M]=!0)}}function Fs(d,C){{var M=function(){xi||(xi=!0,y("%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)",C))};M.isReactWarning=!0,Object.defineProperty(d,"key",{get:M,configurable:!0})}}function zs(d,C){{var M=function(){Oi||(Oi=!0,y("%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)",C))};M.isReactWarning=!0,Object.defineProperty(d,"ref",{get:M,configurable:!0})}}var Hs=function(d,C,M,L,z,Y,N){var j={$$typeof:e,type:d,key:C,ref:M,props:N,_owner:Y};return j._store={},Object.defineProperty(j._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(j,"_self",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.defineProperty(j,"_source",{configurable:!1,enumerable:!1,writable:!1,value:z}),Object.freeze&&(Object.freeze(j.props),Object.freeze(j)),j};function Vs(d,C,M,L,z){{var Y,N={},j=null,ue=null;M!==void 0&&(wi(M),j=""+M),js(C)&&(wi(C.key),j=""+C.key),ks(C)&&(ue=C.ref,Ns(C,z));for(Y in C)Et.call(C,Y)&&!Us.hasOwnProperty(Y)&&(N[Y]=C[Y]);if(d&&d.defaultProps){var $=d.defaultProps;for(Y in $)N[Y]===void 0&&(N[Y]=$[Y])}if(j||ue){var te=typeof d=="function"?d.displayName||d.name||"Unknown":d;j&&Fs(N,te),ue&&zs(N,te)}return Hs(d,j,ue,z,L,it.current,N)}}var Yt=g.ReactCurrentOwner,Mi=g.ReactDebugCurrentFrame;function Ge(d){if(d){var C=d._owner,M=bt(d.type,d._source,C?C.type:null);Mi.setExtraStackFrame(M)}else Mi.setExtraStackFrame(null)}var Gt;Gt=!1;function Zt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function Ti(){{if(Yt.current){var d=oe(Yt.current.type);if(d)return`
39
+
40
+ Check the render method of \``+d+"`."}return""}}function Bs(d){{if(d!==void 0){var C=d.fileName.replace(/^.*[\\\/]/,""),M=d.lineNumber;return`
41
+
42
+ Check your code at `+C+":"+M+"."}return""}}var Ai={};function Ys(d){{var C=Ti();if(!C){var M=typeof d=="string"?d:d.displayName||d.name;M&&(C=`
43
+
44
+ Check the top-level render call using <`+M+">.")}return C}}function Pi(d,C){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var M=Ys(C);if(Ai[M])return;Ai[M]=!0;var L="";d&&d._owner&&d._owner!==Yt.current&&(L=" It was passed a child from "+oe(d._owner.type)+"."),Ge(d),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',M,L),Ge(null)}}function Ri(d,C){{if(typeof d!="object")return;if(Vt(d))for(var M=0;M<d.length;M++){var L=d[M];Zt(L)&&Pi(L,C)}else if(Zt(d))d._store&&(d._store.validated=!0);else if(d){var z=A(d);if(typeof z=="function"&&z!==d.entries)for(var Y=z.call(d),N;!(N=Y.next()).done;)Zt(N.value)&&Pi(N.value,C)}}}function Gs(d){{var C=d.type;if(C==null||typeof C=="string")return;var M;if(typeof C=="function")M=C.propTypes;else if(typeof C=="object"&&(C.$$typeof===h||C.$$typeof===m))M=C.propTypes;else return;if(M){var L=oe(C);Rs(M,d.props,"prop",L,d)}else if(C.PropTypes!==void 0&&!Gt){Gt=!0;var z=oe(C);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",z||"Unknown")}typeof C.getDefaultProps=="function"&&!C.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Zs(d){{for(var C=Object.keys(d.props),M=0;M<C.length;M++){var L=C[M];if(L!=="children"&&L!=="key"){Ge(d),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),Ge(null);break}}d.ref!==null&&(Ge(d),y("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}function Di(d,C,M,L,z,Y){{var N=de(d);if(!N){var j="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(j+=" 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 ue=Bs(z);ue?j+=ue:j+=Ti();var $;d===null?$="null":Vt(d)?$="array":d!==void 0&&d.$$typeof===e?($="<"+(oe(d.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):$=typeof d,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,j)}var te=Vs(d,C,M,z,Y);if(te==null)return te;if(N){var _e=C.children;if(_e!==void 0)if(L)if(Vt(_e)){for(var Ze=0;Ze<_e.length;Ze++)Ri(_e[Ze],d);Object.freeze&&Object.freeze(_e)}else y("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 Ri(_e,d)}return d===i?Zs(te):Gs(te),te}}function Ws(d,C,M){return Di(d,C,M,!0)}function Xs(d,C,M){return Di(d,C,M,!1)}var Qs=Xs,qs=Ws;nt.Fragment=i,nt.jsx=Qs,nt.jsxs=qs}()),nt}process.env.NODE_ENV==="production"?hi.exports=vn():hi.exports=yn();var p=hi.exports;function _i(s){return s.title.search("<")>-1?p.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:s.title}}):p.jsx("button",{children:s.title})}const Cn=p.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[p.jsx("circle",{cx:"7",cy:"7",r:"6"}),p.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),p.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),bn=p.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:p.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\r
45
+ 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\r
46
+ C11,8.22,10.74,8,10.43,8z`})});function _s(s){return p.jsx(cs.Reorder.Item,{value:s.title,children:p.jsxs("div",{children:[bn,p.jsx("span",{children:s.title}),p.jsx("button",{className:"closeIcon",onClick:()=>{s.onDelete(s.index)},children:Cn})]})},s.title)}function vs(s){const[e,t]=O.useState(!1),[i,n]=O.useState(s.options),a=c=>{s.onDragComplete(c),n(c)},r=c=>{const u=[...i];u.splice(c,1),a(u)},l=[];i.forEach((c,u)=>{l.push(p.jsx(_s,{index:u,title:c,onDelete:r},c))});let h="dropdown draggable";return s.subdropdown&&(h+=" subdropdown"),p.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(_i,{title:s.title}),p.jsx(cs.Reorder.Group,{axis:"y",values:i,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function ys(s){const[e,t]=O.useState(!1),i=[];s.options.map((a,r)=>{s.onSelect!==void 0&&(a.onSelect=s.onSelect),i.push(p.jsx(Cs,{option:a},r))});let n="dropdown";return s.subdropdown&&(n+=" subdropdown"),p.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[p.jsx(_i,{title:s.title}),p.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:i})]})}function Cs(s){const{option:e}=s,[t,i]=O.useState("");let n;switch(e.type){case"draggable":n=p.jsx(vs,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=p.jsx(ys,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=p.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 p.jsx("li",{className:t===e.title?"selected":"",children:n},ds())}function En(s,e,t){function i(a){switch(e.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}function n(a){switch(t.forEach(r=>{r.callback(s,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}s.listen=a=>{a.target==="editor"?n(a):i(a)}}function vt(s){const[e,t]=O.useState(s.open!==void 0?s.open:!0),i=!e||s.children===void 0,n=()=>{R.dispatchEvent({type:P.REMOVE_SCENE,value:s.scene})};return p.jsxs("div",{className:`accordion ${i?"hide":""}`,children:[p.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;s.onToggle!==void 0&&s.onToggle(a),t(a)},children:[p.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),p.jsx("p",{className:"label",children:_t(s.label)})]}),s.onRefresh?p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"refresh",onClick:s.onRefresh}),p.jsx("button",{className:"remove",onClick:n})]}):null,s.button,p.jsx("div",{className:e?"open":"",children:p.jsx("div",{children:s.children})},Math.random())]})}function vi(s){const e=O.useRef(null),[t,i]=O.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(p.jsx(vi,{child:r,three:s.three},l))}),O.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]),p.jsx(p.Fragment,{children:s.child!==void 0&&p.jsxs("div",{className:"childObject",children:[p.jsxs("div",{className:"child",children:[n?p.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{i(!t)}}):null,p.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}`}),p.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",c=!l.visible;e.current.style.opacity=c?"1":"0.25",s.three.updateObject(s.child.uuid,h,c),J(l,h,c)}}}}}),p.jsx("div",{className:`icon ${un(s.child)}`})]}),p.jsx("div",{className:t?"open":"",children:p.jsx("div",{className:"container",children:a})})]},Math.random())})}function di(s){const e=[];return s.child?.children.map((t,i)=>{e.push(p.jsx(vi,{child:t,scene:s.scene,three:s.three},i))}),p.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function Sn(s){const[e,t]=O.useState(s.defaultValue);return O.useEffect(()=>{let i=!1,n=-1,a=0,r=s.defaultValue,l=!1;const h=_=>{l=_.ctrlKey},c=_=>{i=!0,a=Number(s.input.current?.value),n=_.clientX,document.addEventListener("mouseup",m,!1),document.addEventListener("mousemove",u,!1),document.addEventListener("contextmenu",m,!1)},u=_=>{if(!i)return;const w=s.step!==void 0?s.step:1,T=(_.clientX-n)*w*(l?10:1);r=Number((a+T).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)},m=()=>{i=!1,document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m)},f=_=>{const w=Number(_.target.value);s.onChange!==void 0&&s.onChange(w),t(w)};return s.label.current?.addEventListener("mousedown",c,!1),s.sliderRef!==void 0&&s.sliderRef.current?.addEventListener("input",f),document.addEventListener("keydown",h,!1),document.addEventListener("keyup",h,!1),()=>{s.label.current?.removeEventListener("mousedown",c),s.sliderRef!==void 0&&s.sliderRef.current?.removeEventListener("input",f),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",u),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",h),document.addEventListener("keyup",h,!1)}},[]),e}function Be(s){const e=O.useRef(null),t=O.useRef(null),[i,n]=O.useState(s.value);return Sn({label:s.labelRef,input:e,sliderRef:t,defaultValue:i,min:s.min,max:s.max,step:s.step,onChange:a=>{n(a),s.onChange!==void 0&&s.onChange(s.prop,a)}}),p.jsxs(p.Fragment,{children:[s.type==="number"&&p.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:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||s.onChange!==void 0&&s.onChange(s.prop,r)}}),s.type==="range"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:i.toString(),disabled:s.disabled,ref:e,className:"min",onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||s.onChange!==void 0&&s.onChange(s.prop,r)}}),p.jsx("input",{disabled:s.disabled,type:"range",value:i,min:s.min,max:s.max,step:s.step,ref:t,onChange:gi})]})]})}function wn(s){const e=O.useRef(null),t=O.useRef(null),i=O.useRef(null),n=O.useRef(null),a=O.useRef(null),r=O.useRef(null),[l,h]=O.useState(s.value),[c,u]=O.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,f]=O.useState(!1);function _(){m||(window.addEventListener("mousemove",T),window.addEventListener("mouseup",w),window.addEventListener("mouseup",w),f(!0))}function w(){window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",w),f(!1)}function T(b){const S=a.current.getBoundingClientRect(),x=je(0,99,b.clientX-S.left)/99,I=je(0,99,b.clientY-S.top)/99,k=ye(Ut(c.min,c.max,x),3),q=ye(Ut(c.min,c.max,I),3);s.onChange({target:{value:{x:k,y:q}}}),h({x:k,y:q})}function A(b){let S=l.x,x=l.y;b.target===e.current?S=Number(b.target.value):x=Number(b.target.value),h({x:S,y:x})}function g(){const b=Number(i.current.value);u({min:b,max:c.max}),(l.x<b||l.y<b)&&h({x:je(b,c.max,l.x),y:je(b,c.max,l.y)})}function y(){const b=Number(n.current.value);u({min:c.min,max:b}),(l.x>b||l.y>b)&&h({x:je(c.min,b,l.x),y:je(c.min,b,l.y)})}O.useEffect(()=>{const b=li(c.min,c.max,l.x),S=li(c.min,c.max,l.y);r.current.style.left=`${b*100}%`,r.current.style.top=`${S*100}%`},[c,l]);const E=s.step!==void 0?s.step:.01;return p.jsxs("div",{className:"vector2",children:[p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"X:"}),p.jsx("input",{ref:e,type:"number",value:l.x,min:c.min,max:c.max,step:E,onChange:A})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Y:"}),p.jsx("input",{ref:t,type:"number",value:l.y,min:c.min,max:c.max,step:E,onChange:A})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Min:"}),p.jsx("input",{ref:i,type:"number",value:c.min,step:E,onChange:g})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Max:"}),p.jsx("input",{ref:n,type:"number",value:c.max,step:E,onChange:y})]})]}),p.jsxs("div",{className:"input",ref:a,onMouseDown:_,onMouseUp:w,children:[p.jsx("div",{className:"x"}),p.jsx("div",{className:"y"}),p.jsx("div",{className:"pt",ref:r})]})]})}const xn=Math.PI/180,On=180/Math.PI;function Xe(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Qe(s,e,t){return(1-t)*s+t*e}function ui(s){return s*xn}function Mn(s){return s*On}function Fi(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=O.useMemo(()=>s.value,[]);["_x","_y","_z"].forEach(h=>{const c=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),p.jsx(Be,{value:Mn(r[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(u,m)=>{r[u]=ui(m),s.onChange({target:{value:r}})}})]},h))})}else if(e){const r=O.useMemo(()=>s.value,[]),l=(c,u)=>{r[c]=u,s.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const u=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:u,children:c.toUpperCase()}),p.jsx(Be,{value:r[c],type:"number",prop:c,step:n,labelRef:u,onChange:l})]},c))})}else if(i){const r=O.useMemo(()=>s.value,[]),l=(h,c)=>{const u=Number(h);r.elements[u]=c,s.onChange({target:{value:r}})};for(let h=0;h<9;h++){const c=O.useRef(null);a.push(p.jsxs("div",{children:[p.jsx("label",{ref:c,children:h+1}),p.jsx(Be,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return p.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Tn(s){const e=s.value.x!==void 0,t=s.step!==void 0?s.step:.01,i=[];if(e){const n=O.useMemo(()=>s.value,[]),a=(l,h)=>{n[l]=h,s.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=O.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:h,children:l.toUpperCase()}),p.jsx(Be,{value:n.x,type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=O.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=O.useRef(null);i.push(p.jsxs("div",{children:[p.jsx("label",{ref:l,children:r+1}),p.jsx(Be,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return p.jsx("div",{className:"grid4",children:i})}function An(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 Pn(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 Ft(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 bs(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 Rn(){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 Dn=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],In=[{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}],Ln=[{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}],Un=[{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}],kn=[{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 rt(s,e){s.needsUpdate=!0,s.type="option",s.options=e}function jn(s,e,t,i){return{type:"boolean",title:Ft(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);J(l,`material.${s}`,a)}}}}function Nn(s,e,t,i){const n={type:"number",title:Ft(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);J(h,`material.${s}`,r)}}};switch(s){case"blending":rt(n,In);break;case"blendDst":rt(n,kn);break;case"blendEquation":rt(n,Ln);break;case"blendSrc":rt(n,Un);break;case"side":rt(n,Dn);break}return bs(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 Fn(s,e,t,i){const n={type:"string",title:Ft(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 c=h.getObjectByProperty("uuid",t.uuid);J(c,`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 c=h.getObjectByProperty("uuid",t.uuid);J(c,`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);J(h,"material.needsUpdate",!0)}}}),n}function zn(s){return s.x!==void 0&&s.y!==void 0&&s.z===void 0}function Hn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w===void 0}function Vn(s){return s.x!==void 0&&s.y!==void 0&&s.z!==void 0&&s.w!==void 0}function pi(s){s.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function pt(s,e,t,i,n="",a=!1){const r=Ft(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:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(h==="number"){const c={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(u,m)=>{i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",t.uuid);J(_,`material.${l}`,m)}}};return bs(r)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:r,prop:l,type:"color",value:e,disabled:a,onChange:(c,u)=>{const m=new o.Color(u);i.updateObject(t.uuid,`material.${l}`,m);const f=i.getScene(t.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",t.uuid);J(_,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const u in e){const m=e[u],f=`[${u.toString()}]`;if(m.value!==void 0){const _=pt(`${f}.value`,m.value,t,i,l,a);_!==void 0&&c.push(_)}else{const _=pt(f,m,t,i,l,a);_!==void 0&&c.push(_)}}if(c.length>0)return pi(c),{title:r,items:c}}else{if(zn(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(Hn(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(Vn(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(c,u)=>{const m=Pn(s),f=n.length>0?`${n}.${m}`:m;i.createTexture(t.uuid,`material.${f}`,u);const _=i.getScene(t.uuid);if(_!==null){const w=_.getObjectByProperty("uuid",t.uuid);if(w!==void 0){const T=A=>{const g=w.material,y=f.split(".");switch(y.length){case 1:g[y[0]]=A;break;case 2:g[y[0]][y[1]]=A;break;case 3:g[y[0]][y[1]][y[2]]=A;break;case 4:g[y[0]][y[1]][y[2]][y[3]]=A;break;case 5:g[y[0]][y[1]][y[2]][y[3]][y[4]]=A;break}g.needsUpdate=!0};u.src.length>0?gs(u.src).then(A=>{A.offset.set(u.offset[0],u.offset[1]),A.repeat.set(u.repeat[0],u.repeat[1]),T(A)}):T(null)}}}};if(e.elements!==void 0)return{title:r,prop:l,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(c,u)=>{i.updateObject(t.uuid,`material.${l}`,u);const m=i.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);J(f,`material.${l}`,u)}}};{const c=[],u=s==="defines"||s==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const _=pt(`${m}.value`,f.value,t,i,l,u);_!==void 0&&c.push(_)}else{const _=pt(m,f,t,i,l,u);_!==void 0&&c.push(_)}}}catch{console.log("Issue cycling through material object:",s,e)}if(c.length>0)return pi(c),{title:r,items:c}}}}}function zi(s,e,t){const i=[];for(const n in s){if(!An(n))continue;const a=typeof s[n],r=s[n];if(a==="boolean")i.push(jn(n,r,e,t));else if(a==="number")i.push(Nn(n,r,e,t));else if(a==="string")i.push(Fn(n,r,e,t));else if(a==="object"){const l=pt(n,r,e,t);l!==void 0&&i.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return pi(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);J(a,"material.needsUpdate",!0)}}}),i}function Bn(s,e){function t(){return`${e.app.appID}_material`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=s.material;if(Array.isArray(r)){const l=[],h=r.length;for(let c=0;c<h;c++)l.push(p.jsx(Ce,{title:`Material ${c}`,items:zi(r[c],s,e)},`Material ${c}`));return p.jsx(p.Fragment,{children:l})}else return p.jsx(Ce,{title:"Material",items:zi(r,s,e),expanded:n,onToggle:l=>{a(l)}})}const Hi="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 Yn(s){const e=s.step!==void 0?s.step:.01,t=O.useRef(null),i=O.useRef(null),n=O.useRef(null),a=O.useRef(null),r=O.useRef(null),[l]=O.useState(s.value),[h,c]=O.useState(s.value.offset[0]),[u,m]=O.useState(s.value.offset[1]),[f,_]=O.useState(s.value.repeat[0]),[w,T]=O.useState(s.value.repeat[1]);function A(y,E,b,S,x){if(s.onChange!==void 0){const I=s.prop!==void 0?s.prop:s.title;s.onChange(I,{src:y,offset:[E,b],repeat:[S,x]})}}function g(y){const E=t.current.src,b=y.target.value;switch(y.target){case i.current:c(b),A(E,b,u,f,w);break;case n.current:m(b),A(E,h,b,f,w);break;case a.current:_(b),A(E,h,u,b,w);break;case r.current:T(b),A(E,h,u,f,b);break}}return p.jsxs("div",{className:"imageField",children:[p.jsx("img",{alt:s.title,ref:t,onClick:()=>{Rn().then(y=>{t.current.src=y,A(y,h,u,f,w)})},src:l.src.length>0?l.src:Hi}),p.jsxs("div",{className:"fields",children:[p.jsxs("div",{children:[p.jsx("label",{children:"Offset:"}),p.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:g}),p.jsx("input",{ref:n,type:"number",value:u,step:e,onChange:g})]}),p.jsxs("div",{children:[p.jsx("label",{children:"Repeat:"}),p.jsx("input",{ref:a,type:"number",value:f,step:e,onChange:g}),p.jsx("input",{ref:r,type:"number",value:w,step:e,onChange:g})]}),p.jsx("button",{onClick:()=>{A("",h,u,f,w),t.current.src=Hi},children:"Clear"})]})]})}function It(s){let e=s.value;e!==void 0&&(e.isColor!==void 0?e=oi(s.value):s.type==="color"&&(e=oi(new o.Color().setStyle(s.value,o.LinearSRGBColorSpace))));const[t,i]=O.useState(e),n=O.useRef(null),a=c=>{let u=c.target.value;if(s.type==="boolean")u=c.target.checked;else if(s.type==="option"&&(typeof s.value=="number"?u=Number(u):typeof s.value=="boolean"?u=!!u:typeof s.value=="object"&&(u=JSON.parse(u)),s.options!==void 0)){const m=s.options.length;for(let f=0;f<m&&s.options[f].value!==u;f++);}i(u),s.onChange!==void 0&&s.onChange(s.prop!==void 0?s.prop:s.title,u)},r={};s.disabled&&(r.opacity=.8);const l=s.type==="string"&&(t.length>100||t.search(`
47
+ `)>-1),h=l||s.type==="image"||s.type==="vector2";return p.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[s.type!=="button"&&p.jsx("label",{ref:n,children:_t(s.title)},"fieldLabel"),s.type==="string"&&!l&&p.jsx("input",{type:"text",disabled:s.disabled,onChange:a,value:t}),s.type==="string"&&l&&p.jsx("textarea",{cols:50,rows:10,disabled:s.disabled!==void 0?s.disabled:!0,onChange:a,onKeyDown:c=>{s.onKeyDown!==void 0&&s.onKeyDown(c)},value:t}),s.type==="boolean"&&p.jsx("input",{type:"checkbox",disabled:s.disabled,onChange:a,checked:t}),s.type==="number"&&p.jsx(Be,{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"&&p.jsx(Be,{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"&&p.jsxs(p.Fragment,{children:[p.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:s.disabled,className:"color"}),p.jsx("input",{type:"color",value:t,onChange:a,disabled:s.disabled})]}),s.type==="button"&&p.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"&&p.jsx(Yn,{title:s.title,prop:s.prop,value:s.value,onChange:s.onChange}),s.type==="option"&&p.jsx(p.Fragment,{children:p.jsx("select",{onChange:a,disabled:s.disabled,defaultValue:s.value,children:s.options?.map((c,u)=>p.jsx("option",{value:c.value,children:_t(c.title)},u))})}),s.type==="vector2"&&p.jsx(wn,{step:s.step,value:t,min:0,max:1,onChange:a}),s.type==="grid3"&&p.jsx(Fi,{step:s.step,value:t,onChange:a}),s.type==="grid4"&&p.jsx(Tn,{step:s.step,value:t,onChange:a}),s.type==="euler"&&p.jsx(Fi,{step:s.step,value:t,onChange:a})]})}function Gn(s){return"items"in s}class Ce extends O.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=O.createRef(),n=p.jsx(Ce,{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(Gn(t))e.push(p.jsx(Ce,{title:_t(t.title),items:t.items},Math.random()));else{const i=this.valueOverrides.get(t.title),n=i!==void 0?i:t.value;e.push(p.jsx(It,{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)),p.jsx(vt,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class ie extends O.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},ie.instance=this,R.addEventListener(P.ADD_GROUP,this.addGroup),R.addEventListener(P.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){R.removeEventListener(P.ADD_GROUP,this.addGroup),R.removeEventListener(P.REMOVE_GROUP,this.removeGroup)}render(){return p.jsx("div",{className:"customGroups",children:ie.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)}})}),ie.groups.push(p.jsx(Ce,{title:t.title,items:i},Math.random())),ie.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,i=ie.groupTitles.length;for(let n=0;n<i;n++)if(t===ie.groupTitles[n]){ie.groups.splice(n,1),ie.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=O.createRef(),n=p.jsx(Ce,{ref:i,title:e.title,items:t},Math.random());return ie.groups.push(n),ie.groupsRefs.push(i),ie.groupTitles.push(e.title),i}static removeEditorGroup(e){const t=ie.groupTitles.length;for(let i=0;i<t;i++)if(e===ie.groupTitles[i]){ie.groups.splice(i,1),ie.groupTitles.splice(i,1),ie.instance.setState({lastUpdate:Date.now()});return}}}function Vi(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 Zn(s,e){function t(){return`${e.app.appID}_camera`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(s.perspectiveCameraInfo!==void 0)for(const l in s.perspectiveCameraInfo)r.push({title:Vi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(J(m,h,c),m.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const l in s.orthographicCameraInfo)r.push({title:Vi(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(s.uuid,h,c),e.requestMethod(s.uuid,"updateProjectionMatrix");const u=e.getScene(s.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",s.uuid);m!==void 0&&(J(m,h,c),m.updateProjectionMatrix())}}});return p.jsx(Ce,{title:"Camera",items:r,expanded:n,onToggle:l=>{a(l)}})}class Wn 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 Bi={type:"change"},yi={type:"start"},Es={type:"end"},wt=new o.Ray,Yi=new o.Plane,Xn=Math.cos(70*o.MathUtils.DEG2RAD),se=new o.Vector3,pe=2*Math.PI,V={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},qt=1e-6;class Qn extends o.Controls{constructor(e,t=null){super(e,t),this.state=V.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=qn.bind(this),this._onPointerUp=$n.bind(this),this._onContextMenu=rr.bind(this),this._onMouseWheel=tr.bind(this),this._onKeyDown=ir.bind(this),this._onTouchStart=sr.bind(this),this._onTouchMove=nr.bind(this),this._onMouseDown=Jn.bind(this),this._onMouseMove=er.bind(this),this._interceptControlDown=ar.bind(this),this._interceptControlUp=or.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(Bi),this.update(),this.state=V.NONE}update(e=null){const t=this.object.position;se.copy(t).sub(this.target),se.applyQuaternion(this._quat),this._spherical.setFromVector3(se),this.autoRotate&&this.state===V.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+=pe:i>Math.PI&&(i-=pe),n<-Math.PI?n+=pe:n>Math.PI&&(n-=pe),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(se.setFromSpherical(this._spherical),se.applyQuaternion(this._quatInverse),t.copy(this.target).add(se),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=se.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 c=new o.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(l),this.object.updateMatrixWorld(),r=se.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):(wt.origin.copy(this.object.position),wt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(wt.direction))<Xn?this.object.lookAt(this.target):(Yi.setFromNormalAndCoplanarPoint(this.object.up,this.target),wt.intersectPlane(Yi,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)>qt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>qt||this._lastTargetPosition.distanceToSquared(this.target)>qt?(this.dispatchEvent(Bi),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?pe/60*this.autoRotateSpeed*e:pe/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){se.setFromMatrixColumn(t,0),se.multiplyScalar(-e),this._panOffset.add(se)}_panUp(e,t){this.screenSpacePanning===!0?se.setFromMatrixColumn(t,1):(se.setFromMatrixColumn(t,0),se.crossVectors(this.object.up,se)),se.multiplyScalar(e),this._panOffset.add(se)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;se.copy(n).sub(this.target);let a=se.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(pe*this._rotateDelta.x/t.clientHeight),this._rotateUp(pe*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(pe*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(-pe*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(pe*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(-pe*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(pe*this._rotateDelta.x/t.clientHeight),this._rotateUp(pe*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 qn(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 $n(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(Es),this.state=V.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=V.DOLLY;break;case o.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=V.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=V.ROTATE}break;case o.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=V.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=V.PAN}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(yi)}function er(s){switch(this.state){case V.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case V.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case V.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function tr(s){this.enabled===!1||this.enableZoom===!1||this.state!==V.NONE||(s.preventDefault(),this.dispatchEvent(yi),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Es))}function ir(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function sr(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=V.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=V.TOUCH_PAN;break;default:this.state=V.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=V.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=V.TOUCH_DOLLY_ROTATE;break;default:this.state=V.NONE}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(yi)}function nr(s){switch(this._trackPointer(s),this.state){case V.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case V.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case V.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case V.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=V.NONE}}function rr(s){this.enabled!==!1&&s.preventDefault()}function ar(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function or(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
48
+ * camera-controls
49
+ * https://github.com/yomotsu/camera-controls
50
+ * (c) 2017 @yomotsu
51
+ * Released under the MIT License.
52
+ */const Q={LEFT:1,RIGHT:2,MIDDLE:4},v=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}),qe={NONE:0,IN:1,OUT:-1};function Ne(s){return s.isPerspectiveCamera}function ke(s){return s.isOrthographicCamera}const Ke=Math.PI*2,Gi=Math.PI/2,Ss=1e-5,at=Math.PI/180;function Ee(s,e,t){return Math.max(e,Math.min(t,s))}function W(s,e=Ss){return Math.abs(s)<e}function H(s,e,t=Ss){return W(s-e,t)}function Zi(s,e){return Math.round(s/e)*e}function ot(s){return isFinite(s)?s:s<0?-Number.MAX_VALUE:Number.MAX_VALUE}function lt(s){return Math.abs(s)<Number.MAX_VALUE?s:s*(1/0)}function xt(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 c=s-e;const u=e,m=n*i;c=Ee(c,-m,m),e=s-c;const f=(t.value+r*c)*a;t.value=(t.value-r*f)*h;let _=e+(c+f)*h;return u-s>0==_>u&&(_=u,t.value=(_-u)/a),_}function Wi(s,e,t,i,n=1/0,a,r){i=Math.max(1e-4,i);const l=2/i,h=l*a,c=1/(1+h+.48*h*h+.235*h*h*h);let u=e.x,m=e.y,f=e.z,_=s.x-u,w=s.y-m,T=s.z-f;const A=u,g=m,y=f,E=n*i,b=E*E,S=_*_+w*w+T*T;if(S>b){const Z=Math.sqrt(S);_=_/Z*E,w=w/Z*E,T=T/Z*E}u=s.x-_,m=s.y-w,f=s.z-T;const x=(t.x+l*_)*a,I=(t.y+l*w)*a,k=(t.z+l*T)*a;t.x=(t.x-l*x)*c,t.y=(t.y-l*I)*c,t.z=(t.z-l*k)*c,r.x=u+(_+x)*c,r.y=m+(w+I)*c,r.z=f+(T+k)*c;const q=A-s.x,de=g-s.y,Se=y-s.z,ge=r.x-A,oe=r.y-g,K=r.z-y;return q*ge+de*oe+Se*K>0&&(r.x=A,r.y=g,r.z=y,t.x=(r.x-A)/a,t.y=(r.y-g)/a,t.z=(r.z-y)/a),r}function Kt(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 $t(s,e){return ke(s)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class lr{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 Jt;const cr="2.9.0",Ot=1/8,hr=/Mac/.test((Jt=globalThis?.navigator)===null||Jt===void 0?void 0:Jt.platform);let D,Xi,Mt,ei,me,U,F,$e,ct,we,xe,Fe,Qi,qi,ve,ht,Je,Ki,ti,$i,ii,si,Tt;class Te extends lr{static install(e){D=e.THREE,Xi=Object.freeze(new D.Vector3(0,0,0)),Mt=Object.freeze(new D.Vector3(0,1,0)),ei=Object.freeze(new D.Vector3(0,0,1)),me=new D.Vector2,U=new D.Vector3,F=new D.Vector3,$e=new D.Vector3,ct=new D.Vector3,we=new D.Vector3,xe=new D.Vector3,Fe=new D.Vector3,Qi=new D.Vector3,qi=new D.Vector3,ve=new D.Spherical,ht=new D.Spherical,Je=new D.Box3,Ki=new D.Box3,ti=new D.Sphere,$i=new D.Quaternion,ii=new D.Quaternion,si=new D.Matrix4,Tt=new D.Raycaster}static get ACTION(){return v}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=v.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=qe.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new D.Vector3,this._focalOffsetVelocity=new D.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,y,E)=>{let b,S;if(Ne(this._camera)){const x=U.copy(this._camera.position).sub(this._target),I=this._camera.getEffectiveFOV()*at,k=x.length()*Math.tan(I*.5);b=this.truckSpeed*g*k/this._elementRect.height,S=this.truckSpeed*y*k/this._elementRect.height}else if(ke(this._camera)){const x=this._camera;b=g*(x.right-x.left)/x.zoom/this._elementRect.width,S=y*(x.top-x.bottom)/x.zoom/this._elementRect.height}else return;this.verticalDragToForward?(E?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-S,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+S,this._focalOffsetEnd.z,!0):this.truck(b,S,!0)},this._rotateInternal=(g,y)=>{const E=Ke*this.azimuthRotateSpeed*g/this._elementRect.height,b=Ke*this.polarRotateSpeed*y/this._elementRect.height;this.rotate(E,b,!0)},this._dollyInternal=(g,y,E)=>{const b=Math.pow(.95,-g*this.dollySpeed),S=this._sphericalEnd.radius,x=this._sphericalEnd.radius*b,I=Ee(x,this.minDistance,this.maxDistance),k=I-x;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(x,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(k,!0),this._dollyToNoClamp(I,!0)):this._dollyToNoClamp(I,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?x:I)-S,this._dollyControlCoord.set(y,E)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,y,E)=>{const b=Math.pow(.95,g*this.dollySpeed),S=this._zoom,x=this._zoom*b;this.zoomTo(x,!0),this.dollyToCursor&&(this._changedZoom+=x-S,this._dollyControlCoord.set(y,E))},typeof D>"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 D.Quaternion().setFromUnitVectors(this._camera.up,Mt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=v.NONE,this._target=new D.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new D.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new D.Spherical().setFromVector3(U.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 D.Vector3,new D.Vector3,new D.Vector3,new D.Vector3],this._updateNearPlaneCorners(),this._boundary=new D.Box3(new D.Vector3(-1/0,-1/0,-1/0),new D.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 D.Vector2,this.mouseButtons={left:v.ROTATE,middle:v.DOLLY,right:v.TRUCK,wheel:Ne(this._camera)?v.DOLLY:ke(this._camera)?v.ZOOM:v.NONE},this.touches={one:v.TOUCH_ROTATE,two:Ne(this._camera)?v.TOUCH_DOLLY_TRUCK:ke(this._camera)?v.TOUCH_ZOOM_TRUCK:v.NONE,three:v.TOUCH_TRUCK};const i=new D.Vector2,n=new D.Vector2,a=new D.Vector2,r=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const b=this._domElement.getBoundingClientRect(),S=g.clientX/b.width,x=g.clientY/b.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||x<this._interactiveArea.top||x>this._interactiveArea.bottom)return}const y=g.pointerType!=="mouse"?null:(g.buttons&Q.LEFT)===Q.LEFT?Q.LEFT:(g.buttons&Q.MIDDLE)===Q.MIDDLE?Q.MIDDLE:(g.buttons&Q.RIGHT)===Q.RIGHT?Q.RIGHT:null;if(y!==null){const b=this._findPointerByMouseButton(y);b&&this._disposePointer(b)}if((g.buttons&Q.LEFT)===Q.LEFT&&this._lockedPointer)return;const E={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:y};this._activePointers.push(E),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,f(g)},l=g=>{g.cancelable&&g.preventDefault();const y=g.pointerId,E=this._lockedPointer||this._findPointerById(y);if(E){if(E.clientX=g.clientX,E.clientY=g.clientY,E.deltaX=g.movementX,E.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&Q.LEFT)===Q.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&Q.MIDDLE)===Q.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&Q.RIGHT)===Q.RIGHT&&(this._state=this._state|this.mouseButtons.right);_()}},h=g=>{const y=this._findPointerById(g.pointerId);if(!(y&&y===this._lockedPointer)){if(y&&this._disposePointer(y),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=v.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=v.NONE;w()}};let c=-1;const u=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===v.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const x=this._domElement.getBoundingClientRect(),I=g.clientX/x.width,k=g.clientY/x.height;if(I<this._interactiveArea.left||I>this._interactiveArea.right||k<this._interactiveArea.top||k>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===v.ROTATE||this.mouseButtons.wheel===v.TRUCK){const x=performance.now();c-x<1e3&&this._getClientRect(this._elementRect),c=x}const y=hr?-1:-3,E=g.deltaMode===1?g.deltaY/y:g.deltaY/(y*10),b=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case v.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case v.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case v.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case v.DOLLY:{this._dollyInternal(-E,b,S),this._isUserControllingDolly=!0;break}case v.ZOOM:{this._zoomInternal(-E,b,S),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Te.ACTION.NONE){const y=g instanceof PointerEvent?g.pointerId:0,E=this._findPointerById(y);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}g.preventDefault()}},f=g=>{if(!this._enabled)return;if(Kt(this._activePointers,me),this._getClientRect(this._elementRect),i.copy(me),n.copy(me),this._activePointers.length>=2){const E=me.x-this._activePointers[1].clientX,b=me.y-this._activePointers[1].clientY,S=Math.sqrt(E*E+b*b);a.set(0,S);const x=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,I=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(x,I)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&Q.LEFT)===Q.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&Q.MIDDLE)===Q.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&Q.RIGHT)===Q.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.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&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&v.DOLLY)===v.DOLLY||(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&v.ZOOM)===v.ZOOM||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},_=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Kt(this._activePointers,me);const y=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=y?-y.deltaX:n.x-me.x,b=y?-y.deltaY:n.y-me.y;if(n.copy(me),((this._state&v.ROTATE)===v.ROTATE||(this._state&v.TOUCH_ROTATE)===v.TOUCH_ROTATE||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,b),this._isUserControllingRotate=!0),(this._state&v.DOLLY)===v.DOLLY||(this._state&v.ZOOM)===v.ZOOM){const S=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,I=this.dollyDragInverted?-1:1;(this._state&v.DOLLY)===v.DOLLY?(this._dollyInternal(I*b*Ot,S,x),this._isUserControllingDolly=!0):(this._zoomInternal(I*b*Ot,S,x),this._isUserControllingZoom=!0)}if((this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_ZOOM)===v.TOUCH_ZOOM||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_ZOOM_ROTATE)===v.TOUCH_ZOOM_ROTATE){const S=me.x-this._activePointers[1].clientX,x=me.y-this._activePointers[1].clientY,I=Math.sqrt(S*S+x*x),k=a.y-I;a.set(0,I);const q=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,de=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&v.TOUCH_DOLLY)===v.TOUCH_DOLLY||(this._state&v.TOUCH_DOLLY_ROTATE)===v.TOUCH_DOLLY_ROTATE||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET?(this._dollyInternal(k*Ot,q,de),this._isUserControllingDolly=!0):(this._zoomInternal(k*Ot,q,de),this._isUserControllingZoom=!0)}((this._state&v.TRUCK)===v.TRUCK||(this._state&v.TOUCH_TRUCK)===v.TOUCH_TRUCK||(this._state&v.TOUCH_DOLLY_TRUCK)===v.TOUCH_DOLLY_TRUCK||(this._state&v.TOUCH_ZOOM_TRUCK)===v.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,b,!1),this._isUserControllingTruck=!0),((this._state&v.OFFSET)===v.OFFSET||(this._state&v.TOUCH_OFFSET)===v.TOUCH_OFFSET||(this._state&v.TOUCH_DOLLY_OFFSET)===v.TOUCH_DOLLY_OFFSET||(this._state&v.TOUCH_ZOOM_OFFSET)===v.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,b,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},w=()=>{Kt(this._activePointers,me),n.copy(me),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",T),this._domElement.ownerDocument.addEventListener("pointerlockerror",A),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),f())},this.unlockPointer=()=>{var g,y,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockchange",T),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",A),this.cancel()};const T=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},A=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",u,{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",u,{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",T),this._domElement.ownerDocument.removeEventListener("pointerlockerror",A))},this.cancel=()=>{this._state!==v.NONE&&(this._state=v.NONE,this._activePointers.length=0,w())},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=Ee(e.width,0,1),this._interactiveArea.height=Ee(e.height,0,1),this._interactiveArea.x=Ee(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ee(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=Ee(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=Ee(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||H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(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=qe.NONE,this._changedDolly=0,this._dollyToNoClamp(Ee(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=H(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||H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(ct).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(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=Ee(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||H(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(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),we.multiplyScalar(e),xe.multiplyScalar(-t);const n=U.copy(we).add(xe),a=F.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,i)}forward(e,t=!1){U.setFromMatrixColumn(this._camera.matrix,0),U.crossVectors(this._camera.up,U),U.multiplyScalar(e);const i=F.copy(this._targetEnd).add(U);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return U.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+U.x,this._targetEnd.y+U.y,this._targetEnd.z+U.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;const a=U.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||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,n=!1){const l=U.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=[],c=e.isBox3?Je.copy(e):Je.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Zi(this._sphericalEnd.theta,Gi),m=Zi(this._sphericalEnd.phi,Gi);h.push(this.rotateTo(u,m,t));const f=U.setFromSpherical(this._sphericalEnd).normalize(),_=$i.setFromUnitVectors(f,ei),w=H(Math.abs(f.y),1);w&&_.multiply(ii.setFromAxisAngle(Mt,u)),_.multiply(this._yAxisUpSpaceInverse);const T=Ki.makeEmpty();F.copy(c.min).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setX(c.max.x).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setY(c.max.y).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setZ(c.min.z).applyQuaternion(_),T.expandByPoint(F),F.copy(c.min).setZ(c.max.z).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setY(c.min.y).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).setX(c.min.x).applyQuaternion(_),T.expandByPoint(F),F.copy(c.max).applyQuaternion(_),T.expandByPoint(F),T.min.x-=n,T.min.y-=r,T.max.x+=a,T.max.y+=l,_.setFromUnitVectors(ei,f),w&&_.premultiply(ii.invert()),_.premultiply(this._yAxisUpSpace);const A=T.getSize(U),g=T.getCenter(F).applyQuaternion(_);if(Ne(this._camera)){const y=this.getDistanceToFitBox(A.x,A.y,A.z,i);h.push(this.moveTo(g.x,g.y,g.z,t)),h.push(this.dollyTo(y,t)),h.push(this.setFocalOffset(0,0,0,t))}else if(ke(this._camera)){const y=this._camera,E=y.right-y.left,b=y.top-y.bottom,S=i?Math.max(E/A.x,b/A.y):Math.min(E/A.x,b/A.y);h.push(this.moveTo(g.x,g.y,g.z,t)),h.push(this.zoomTo(S,t)),h.push(this.setFocalOffset(0,0,0,t))}return Promise.all(h)}fitToSphere(e,t){const i=[],a="isObject3D"in e?Te.createBoundingSphere(e,ti):ti.copy(e);if(i.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),Ne(this._camera)){const r=this.getDistanceToFitSphere(a.radius);i.push(this.dollyTo(r,t))}else if(ke(this._camera)){const r=this._camera.right-this._camera.left,l=this._camera.top-this._camera.bottom,h=2*a.radius,c=Math.min(r/h,l/h);i.push(this.zoomTo(c,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=qe.NONE,this._changedDolly=0;const h=F.set(n,a,r),c=U.set(e,t,i);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,l||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!l||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,i,n,a,r,l,h,c,u,m,f,_,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=qe.NONE,this._changedDolly=0;const T=U.set(n,a,r),A=F.set(e,t,i);ve.setFromVector3(A.sub(T).applyQuaternion(this._yAxisUpSpace));const g=$e.set(u,m,f),y=F.set(l,h,c);ht.setFromVector3(y.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(T.lerp(g,_));const E=ht.theta-ve.theta,b=ht.phi-ve.phi,S=ht.radius-ve.radius;this._sphericalEnd.set(ve.radius+S*_,ve.phi+b*_,ve.theta+E*_),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const x=!w||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(x)}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(U),r=this.setLookAt(a.x,a.y,a.z,e,t,i,n);return this._sphericalEnd.phi=Ee(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||H(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&H(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&H(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrixWorldInverse,0),xe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Fe.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=U.set(e,t,i),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);we.multiplyScalar(r.x),xe.multiplyScalar(r.y),Fe.multiplyScalar(r.z),U.copy(we).add(xe).add(Fe),U.z=U.z+a,this.dollyTo(a,!1),this.setFocalOffset(-U.x,U.y,-U.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 D.Vector4,typeof e=="number"?this._viewport.set(e,t,i,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,n=!1){if($t(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*at,l=this._camera.aspect;return((n?a>l:a<l)?t:e/l)*.5/Math.tan(r*.5)+i*.5}getDistanceToFitSphere(e){if($t(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*at,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 D.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new D.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new D.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new D.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ke,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ke),this._spherical.theta+=Ke*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ke)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!H(this._camera.up.x,this._cameraUp0.x)||!H(this._camera.up.y,this._cameraUp0.y)||!H(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(U);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,Mt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=U.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(U);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=Qi.subVectors(this._targetEnd,this._target),r=qi.subVectors(this._focalOffsetEnd,this._focalOffset),l=this._zoomEnd-this._zoom;if(W(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=xt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(W(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=xt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(W(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=xt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(W(a.x)&&W(a.y)&&W(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Wi(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(W(r.x)&&W(r.y)&&W(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Wi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(W(l))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=xt(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Ne(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,f=this._camera,_=this._getCameraDirection(ct),w=U.copy(_).cross(f.up).normalize();w.lengthSq()===0&&(w.x=1);const T=F.crossVectors(w,_),A=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*at*.5),y=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=$e.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*A*f.aspect)).add(T.multiplyScalar(this._dollyControlCoord.y*A)),b=U.copy(this._targetEnd).lerp(E,y),S=this._lastDollyDirection===qe.IN&&this._spherical.radius<=this.minDistance,x=this._lastDollyDirection===qe.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||x)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const k=F.copy(_).multiplyScalar(-m);b.add(k)}this._boundary.clampPoint(b,b);const I=F.subVectors(b,this._targetEnd);this._targetEnd.copy(b),this._target.add(I),this._changedDolly-=m,W(this._changedDolly)&&(this._changedDolly=0)}else if(ke(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,f=this._camera,_=U.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),w=F.set(0,0,-1).applyQuaternion(f.quaternion),T=$e.copy(_).add(w.multiplyScalar(-_.dot(f.up))),g=-(this._zoom-m-this._zoom)/this._zoom,y=this._getCameraDirection(ct),E=this._targetEnd.dot(y),b=U.copy(this._targetEnd).lerp(T,g),S=b.dot(y),x=y.multiplyScalar(S-E);b.sub(x),this._boundary.clampPoint(b,b);const I=F.subVectors(b,this._targetEnd);this._targetEnd.copy(b),this._target.add(I),this._changedZoom-=m,W(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),(!W(this._focalOffset.x)||!W(this._focalOffset.y)||!W(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrix,0),xe.setFromMatrixColumn(this._camera.matrix,1),Fe.setFromMatrixColumn(this._camera.matrix,2),we.multiplyScalar(this._focalOffset.x),xe.multiplyScalar(-this._focalOffset.y),Fe.multiplyScalar(this._focalOffset.z),U.copy(we).add(xe).add(Fe),this._camera.position.add(U)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),U.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),W(t,this.restThreshold)&&W(i,this.restThreshold)&&W(n,this.restThreshold)&&W(a.x,this.restThreshold)&&W(a.y,this.restThreshold)&&W(a.z,this.restThreshold)&&W(r.x,this.restThreshold)&&W(r.y,this.restThreshold)&&W(r.z,this.restThreshold)&&W(l,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ot(this.maxDistance),minZoom:this.minZoom,maxZoom:ot(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ot(this.maxPolarAngle),minAzimuthAngle:ot(this.minAzimuthAngle),maxAzimuthAngle:ot(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:U.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=lt(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=lt(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=lt(i.maxPolarAngle),this.minAzimuthAngle=lt(i.minAzimuthAngle),this.maxAzimuthAngle=lt(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),ve.setFromVector3(U.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ve.theta,ve.phi,t),this.dollyTo(ve.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",cr),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,$e).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 c=1+i*h/t.dot(l);return e.add(F.copy(t).multiplyScalar(c)).add(l.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ne(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*at,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(ke(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)||$t(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(ct);si.lookAt(Xi,i,this._camera.up);for(let n=0;n<4;n++){const a=F.copy(this._nearPlaneCorners[n]);a.applyMatrix4(si);const r=$e.addVectors(this._target,a);Tt.set(r,i),Tt.far=this._spherical.radius+1;const l=Tt.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 D.Sphere){const i=t,n=i.center;Je.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&Je.expandByObject(r)}),Je.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 u=h.attributes.position;for(let m=0,f=u.count;m<f;m++)U.fromBufferAttribute(u,m),a=Math.max(a,n.distanceToSquared(U))}),i.radius=Math.sqrt(a),i}}const jt=s=>{const[e,t]=O.useState(s.options[s.index]),i=()=>{s.onToggle(!s.open)},n=a=>{a!==e&&(s.onSelect(a),t(a)),s.onToggle(!1)};return p.jsxs("div",{className:`dropdown ${s.up===!0?"up":""}`,children:[p.jsx("div",{className:"dropdown-toggle",onClick:i,children:`${s.title}: ${e}`}),s.open&&p.jsx("ul",{className:"dropdown-menu",children:s.options.map(a=>p.jsx("li",{onClick:()=>n(a),children:a},a))})]})},ze=O.forwardRef(function(e,t){const i=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=O.useState("Renderer"),[r,l]=O.useState(!1),[h,c]=O.useState(!1),[u,m]=O.useState(!1);return p.jsxs("div",{className:`CameraWindow ${e.name}`,children:[p.jsx("div",{ref:t,className:"clickable",onClick:()=>{u&&m(!1)}}),p.jsxs("div",{className:"options",children:[e.camera!==null&&p.jsx(jt,{title:"Camera",index:e.options.indexOf(e.camera.name),open:u,options:e.options,onSelect:e.onSelectCamera,onToggle:f=>{m(f)},up:!0}),p.jsx(jt,{title:"Mode",index:i.indexOf(n),open:h,options:i,onSelect:f=>{if(f===n)return;const _=f;e.onSelectRenderMode(_),a(_)},onToggle:f=>{r&&l(!1),c(f)},up:!0})]})]})});class dr 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;
53
+ uniform float uDistance;
54
+
55
+ void main() {
56
+ // Scale the plane by the drawing distance
57
+ worldPosition = position.xzy * uDistance;
58
+ worldPosition.xz += cameraPosition.xz;
59
+
60
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
61
+ }`,fragmentShader:`out vec4 fragColor;
62
+ in vec3 worldPosition;
63
+
64
+ uniform float uDivisions;
65
+ uniform float uScale;
66
+ uniform vec3 uColor;
67
+ uniform float uDistance;
68
+ uniform float uSubgridOpacity;
69
+ uniform float uGridOpacity;
70
+
71
+ float getGrid(float gapSize) {
72
+ vec2 worldPositionByDivision = worldPosition.xz / gapSize;
73
+
74
+ // Inverted, 0 where line, >1 where there's no line
75
+ // We use the worldPosition (which in this case we use similarly to UVs) differential to control the anti-aliasing
76
+ // We need to do the -0.5)-0.5 trick because the result fades out from 0 to 1, and we want both
77
+ // worldPositionByDivision == 0.3 and worldPositionByDivision == 0.7 to result in the same fade, i.e. 0.3,
78
+ // otherwise only one side of the line will be anti-aliased
79
+ vec2 grid = abs(fract(worldPositionByDivision-0.5)-0.5) / fwidth(worldPositionByDivision) / 2.0;
80
+ float gridLine = min(grid.x, grid.y);
81
+
82
+ // Uninvert and clamp
83
+ return 1.0 - min(gridLine, 1.0);
84
+ }
85
+
86
+ void main() {
87
+ float cameraDistanceToGridPlane = distance(cameraPosition.y, worldPosition.y);
88
+ float cameraDistanceToFragmentOnGridPlane = distance(cameraPosition.xz, worldPosition.xz);
89
+
90
+ // The size of the grid and subgrid are powers of each other and they are determined based on camera distance.
91
+ // The current grid will become the next subgrid when it becomes too small, and its next power becomes the new grid.
92
+ float subGridPower = pow(uDivisions, floor(log(cameraDistanceToGridPlane) / log(uDivisions)));
93
+ float gridPower = subGridPower * uDivisions;
94
+
95
+ // If we want to fade both the grid and its subgrid, we need to displays 3 different opacities, with the next grid being the third
96
+ float nextGridPower = gridPower * uDivisions;
97
+
98
+ // 1 where grid, 0 where no grid
99
+ float subgrid = getGrid(subGridPower * uScale);
100
+ float grid = getGrid(gridPower * uScale);
101
+ float nextGrid = getGrid(nextGridPower * uScale);
102
+
103
+ // Where we are between the introduction of the current grid power and when we switch to the next grid power
104
+ float stepPercentage = (cameraDistanceToGridPlane - subGridPower)/(gridPower - subGridPower);
105
+
106
+ // The last x percentage of the current step over which we want to fade
107
+ float fadeRange = 0.3;
108
+
109
+ // We calculate the fade percentage from the step percentage and the fade range
110
+ float fadePercentage = max(stepPercentage - 1.0 + fadeRange, 0.0) / fadeRange;
111
+
112
+ // Set base opacity based on how close we are to the drawing distance, with a cubic falloff
113
+ float baseOpacity = subgrid * pow(1.0 - min(cameraDistanceToFragmentOnGridPlane / uDistance, 1.0), 3.0);
114
+
115
+ // Shade the subgrid
116
+ fragColor = vec4(uColor.rgb, (baseOpacity - fadePercentage) * uSubgridOpacity);
117
+
118
+ // Somewhat arbitrary additional fade coefficient to counter anti-aliasing popping when switching between grid powers
119
+ float fadeCoefficient = 0.5;
120
+
121
+ // Shade the grid
122
+ fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity - fadePercentage * (uGridOpacity - uSubgridOpacity) * fadeCoefficient, grid);
123
+
124
+ // Shade the next grid
125
+ fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
126
+
127
+ if (fragColor.a <= 0.0) discard;
128
+ }`,name:"InfiniteGrid",depthWrite:!1})}}class ur extends o.Mesh{gridMaterial;constructor(){const e=new dr;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}}function Ji(s){const[e,t]=O.useState(s.selected),i="toggle"+(e?" selected":"");return p.jsx("button",{className:i,onClick:()=>{const n=!e;t(n),s.onClick(n)},style:{backgroundImage:`url(${s.icon})`,backgroundPositionY:`${s.top}px`,backgroundSize:`26px ${s.height}px`}},s.name)}const pr=`#include <common>
129
+ #include <batching_pars_vertex>
130
+ #include <uv_pars_vertex>
131
+ #include <color_pars_vertex>
132
+ #include <morphtarget_pars_vertex>
133
+ #include <skinning_pars_vertex>
134
+ #include <logdepthbuf_pars_vertex>
135
+ #include <clipping_planes_pars_vertex>
136
+
137
+ void main() {
138
+ #include <uv_vertex>
139
+ #include <color_vertex>
140
+ #include <morphcolor_vertex>
141
+ #include <batching_vertex>
142
+
143
+ #if defined ( USE_SKINNING )
144
+ #include <beginnormal_vertex>
145
+ #include <morphnormal_vertex>
146
+ #include <skinbase_vertex>
147
+ #include <skinnormal_vertex>
148
+ #include <defaultnormal_vertex>
149
+ #endif
150
+
151
+ #include <begin_vertex>
152
+ #include <morphtarget_vertex>
153
+ #include <skinning_vertex>
154
+ #include <project_vertex>
155
+ #include <logdepthbuf_vertex>
156
+ #include <clipping_planes_vertex>
157
+ #include <worldpos_vertex>
158
+ }`,mr=`
159
+ #include <common>
160
+ #include <uv_pars_fragment>
161
+ #include <clipping_planes_pars_fragment>
162
+
163
+ void main() {
164
+ #include <clipping_planes_fragment>
165
+ gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
166
+ }`;class fr extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:pr,fragmentShader:mr})}}const He=new o.Raycaster,ce=new o.Vector3,Ue=new o.Vector3,X=new o.Quaternion,es={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ni={type:"change"},ts={type:"mouseDown",mode:null},is={type:"mouseUp",mode:null},ss={type:"objectChange"};class gr extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new Er(this);this._root=i;const n=new Sr;this._gizmo=n,i.add(n);const a=new wr;this._plane=a,i.add(a);const r=this;function l(E,b){let S=b;Object.defineProperty(r,E,{get:function(){return S!==void 0?S:b},set:function(x){S!==x&&(S=x,a[E]=x,n[E]=x,r.dispatchEvent({type:E+"-changed",value:x}),r.dispatchEvent(ni))}}),r[E]=b,a[E]=b,n[E]=b}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,c=new o.Vector3,u=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,_=new o.Quaternion,w=new o.Vector3,T=new o.Vector3,A=new o.Vector3,g=0,y=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",u),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",_),l("pointStart",w),l("pointEnd",T),l("rotationAxis",A),l("rotationAngle",g),l("eye",y),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=_r.bind(this),this._onPointerDown=yr.bind(this),this._onPointerHover=vr.bind(this),this._onPointerMove=Cr.bind(this),this._onPointerUp=br.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&&He.setFromCamera(e,this.camera);const t=ri(this._gizmo.picker[this.mode],He);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&&He.setFromCamera(e,this.camera);const t=ri(this._plane,He,!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,ts.mode=this.mode,this.dispatchEvent(ts)}}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&&He.setFromCamera(e,this.camera);const r=ri(this._plane,He,!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(X.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(ce.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(ce.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),Ue.set(l,l,l)}else ce.copy(this.pointStart),Ue.copy(this.pointEnd),ce.applyQuaternion(this._worldQuaternionInv),Ue.applyQuaternion(this._worldQuaternionInv),Ue.divide(ce),t.search("X")===-1&&(Ue.x=1),t.search("Y")===-1&&(Ue.y=1),t.search("Z")===-1&&(Ue.z=1);n.scale.copy(this._scaleStart).multiply(Ue),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(ce.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ce.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(es[t]),ce.copy(es[t]),a==="local"&&ce.applyQuaternion(this.worldQuaternion),ce.cross(this.eye),ce.length()===0?h=!0:this.rotationAngle=this._offset.dot(ce.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(X.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(X.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ni),this.dispatchEvent(ss)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(is.mode=this.mode,this.dispatchEvent(is)),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(ni),this.dispatchEvent(ss),this.pointStart.copy(this.pointEnd))}getRaycaster(){return He}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 _r(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 vr(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function yr(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 Cr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function br(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ri(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 At=new o.Euler,G=new o.Vector3(0,1,0),ns=new o.Vector3(0,0,0),rs=new o.Matrix4,Pt=new o.Quaternion,Lt=new o.Quaternion,Oe=new o.Vector3,as=new o.Matrix4,mt=new o.Vector3(1,0,0),Ve=new o.Vector3(0,1,0),ft=new o.Vector3(0,0,1),Rt=new o.Vector3,dt=new o.Vector3,ut=new o.Vector3;class Er 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 Sr 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 c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const m=e.clone();m.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const w=e.clone();w.color.setHex(7895160);const T=new o.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const A=new o.BoxGeometry(.08,.08,.08);A.translate(0,.04,0);const g=new o.BufferGeometry;g.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const y=new o.CylinderGeometry(.0075,.0075,.5,3);y.translate(0,.25,0);function E(Z,Pe){const le=new o.TorusGeometry(Z,.0075,3,64,Pe*Math.PI*2);return le.rotateY(Math.PI/2),le.rotateX(Math.PI/2),le}function b(){const Z=new o.BufferGeometry;return Z.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(y,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(T,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(y,r)]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(y,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),u.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),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},x={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]]]},I={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(b(),n),null,null,null,"helper"]],X:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},k={XYZE:[[new o.Mesh(E(.5,1),w),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(E(.5,.5),a)]],Y:[[new o.Mesh(E(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},q={AXIS:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},de={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)]]},Se={X:[[new o.Mesh(A,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(y,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(A,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(A,r),[0,.5,0]],[new o.Mesh(y,r)],[new o.Mesh(A,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(A,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(y,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(A,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),u),[.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),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},ge={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]]]},oe={X:[[new o.Line(g,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(g,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(g,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function K(Z){const Pe=new o.Object3D;for(const le in Z)for(let fe=Z[le].length;fe--;){const ee=Z[le][fe][0].clone(),Re=Z[le][fe][1],De=Z[le][fe][2],Ie=Z[le][fe][3],B=Z[le][fe][4];ee.name=le,ee.tag=B,Re&&ee.position.set(Re[0],Re[1],Re[2]),De&&ee.rotation.set(De[0],De[1],De[2]),Ie&&ee.scale.set(Ie[0],Ie[1],Ie[2]),ee.updateMatrix();const ne=ee.geometry.clone();ne.applyMatrix4(ee.matrix),ee.geometry=ne,ee.renderOrder=1/0,ee.position.set(0,0,0),ee.rotation.set(0,0,0),ee.scale.set(1,1,1),Pe.add(ee)}return Pe}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=K(S)),this.add(this.gizmo.rotate=K(k)),this.add(this.gizmo.scale=K(Se)),this.add(this.picker.translate=K(x)),this.add(this.picker.rotate=K(de)),this.add(this.picker.scale=K(ge)),this.add(this.helper.translate=K(I)),this.add(this.helper.rotate=K(q)),this.add(this.helper.scale=K(oe)),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:Lt;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"&&(X.setFromEuler(At.set(0,0,0)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(mt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(X.setFromEuler(At.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(X.setFromEuler(At.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(X),Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(X.setFromEuler(At.set(0,Math.PI/2,0)),G.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(rs.lookAt(ns,G,Ve)),r.quaternion.multiply(X),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),ce.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ce.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ce),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(G.copy(mt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(G.copy(ft).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(G.copy(mt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(G.copy(Ve).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Pt.copy(i),G.copy(this.eye).applyQuaternion(X.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(rs.lookAt(this.eye,ns,Ve)),r.name==="X"&&(X.setFromAxisAngle(mt,Math.atan2(-G.y,G.z)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X)),r.name==="Y"&&(X.setFromAxisAngle(Ve,Math.atan2(G.x,G.z)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X)),r.name==="Z"&&(X.setFromAxisAngle(ft,Math.atan2(G.y,G.x)),X.multiplyQuaternions(Pt,X),r.quaternion.copy(X))),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 wr 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"),Rt.copy(mt).applyQuaternion(t==="local"?this.worldQuaternion:Lt),dt.copy(Ve).applyQuaternion(t==="local"?this.worldQuaternion:Lt),ut.copy(ft).applyQuaternion(t==="local"?this.worldQuaternion:Lt),G.copy(dt),this.mode){case"translate":case"scale":switch(this.axis){case"X":G.copy(this.eye).cross(Rt),Oe.copy(Rt).cross(G);break;case"Y":G.copy(this.eye).cross(dt),Oe.copy(dt).cross(G);break;case"Z":G.copy(this.eye).cross(ut),Oe.copy(ut).cross(G);break;case"XY":Oe.copy(ut);break;case"YZ":Oe.copy(Rt);break;case"XZ":G.copy(ut),Oe.copy(dt);break;case"XYZ":case"E":Oe.set(0,0,0);break}break;case"rotate":default:Oe.set(0,0,0)}Oe.length()===0?this.quaternion.copy(this.cameraQuaternion):(as.lookAt(ce.set(0,0,0),Oe,G),this.quaternion.setFromRotationMatrix(as)),super.updateMatrixWorld(e)}}class he extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;constructor(){super(),R.addEventListener(P.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Ae(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 gr(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:he.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:he.DRAG_END})}),t.addEventListener("dragging-changed",n=>{ae.instance?.toggleOrbitControls(n.value)})}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(),Ae(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})}setScene=()=>{this.clear()};static get instance(){return he._instance||(he._instance=new he),he._instance}}const xr=new o.BoxGeometry,ai=new o.Vector2;class mi 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(Qe(.5,1,Math.random()),Qe(.5,1,Math.random()),Qe(.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),he.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([ye(t.position.x,3),ye(t.position.y,3),ye(t.position.z,3)])}),hs({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(xr,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(Qe(-this.offset,this.offset,Math.random()),Qe(-this.offset,this.offset,Math.random()),Qe(-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)}Ae(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(!ae.instance||this._transform&&!this._transform.getHelper().visible)return;const i=ae.instance.currentWindow.current.getBoundingClientRect();ai.x=(e.clientX-i.x)/i.width*2-1,ai.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ai,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=he.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),ae.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":Ae(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 Dt=0;class ws extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,R.addEventListener(P.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=ie.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(){R.removeEventListener(P.ADD_SPLINE,this.onAddSpline),ie.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 ${Dt+1}`,i=new mi(t,this._camera);return i.addPoints(e),this.addSpline(i),Dt++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCatmullRom=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 ${Dt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new mi(i,this.camera);a.addPoints(n),this.addSpline(a),Dt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const os=["Single","Side by Side","Stacked","Quad"],Or="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",Mr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==";class ae extends O.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 ur;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new fr;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;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=O.createRef(),this.containerRef=O.createRef(),this.tlWindow=O.createRef(),this.trWindow=O.createRef(),this.blWindow=O.createRef(),this.brWindow=O.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};Te.install({THREE:a}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);this.cameraVisibility=r!==null?r==="open":!1,this.saveExpandedCameraVisibility();const l=localStorage.getItem(this.expandedLightVisibility);this.lightVisibility=l!==null?l==="open":!1,this.saveExpandedLightVisibility(),ae.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),he.instance.three=this.props.three,he.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)}),p.jsxs("div",{className:"multiview",children:[p.jsx("canvas",{ref:this.canvasRef}),p.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&p.jsx(p.Fragment,{children:p.jsx(ze,{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")&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{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)}}),p.jsx(ze,{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"&&p.jsxs(p.Fragment,{children:[p.jsx(ze,{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)}}),p.jsx(ze,{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)}}),p.jsx(ze,{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)}}),p.jsx(ze,{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)}})]})]}),p.jsxs("div",{className:"settings",children:[p.jsx(jt,{title:"View",index:os.indexOf(this.state.mode),options:os,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),p.jsx(jt,{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})}}),p.jsx(Ji,{name:"cameraHelper",icon:Or,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem instanceof o.PerspectiveCamera){const i=this.cameraHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}}),p.jsx(Ji,{name:"lightHelper",icon:Mr,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(i=>{i.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const i=this.lightHelpers.get(this.selectedItem.name);i!==void 0&&(i.visible=!0)}}})]},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 ws(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),R.addEventListener(P.SET_SCENE,this.sceneUpdate),R.addEventListener(P.ADD_CAMERA,this.addCamera),R.addEventListener(P.REMOVE_CAMERA,this.removeCamera),R.addEventListener(P.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),R.removeEventListener(P.SET_SCENE,this.sceneUpdate),R.removeEventListener(P.ADD_CAMERA,this.addCamera),R.removeEventListener(P.REMOVE_CAMERA,this.removeCamera),R.removeEventListener(P.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),Ae(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);n.visible=this.cameraVisibility,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=Xe(i,0,t.x,-1,1),this.pointer.y=Xe(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=Xe(i,0,a,-1,1):this.pointer.x=Xe(i,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Xe(n,0,r,1,-1):this.pointer.y=Xe(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 c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(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"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Te(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(ui(45),ui(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;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),he.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=he.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0){if(this.selectedItem instanceof o.PerspectiveCamera&&!this.cameraVisibility){const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}else if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}}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),zt.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`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Wn(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,t.visible=this.lightVisibility,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 Qn(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),he.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-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=Ut(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}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}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}}class zt extends O.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);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;this.open=i,this.saveExpanded(),this.state={lastUpdated:0,expanded:i},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)),zt.instance=this}update(){if(ae.instance){const e=ae.instance.selectedItem;if(e===void 0)return;this.position.x=ye(e.position.x,3),this.position.y=ye(e.position.y,3),this.position.z=ye(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=ye(e.scale.x,3),this.scale.y=ye(e.scale.y,3),this.scale.z=ye(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return p.jsx(Ce,{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.saveExpanded()}},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);J(a,e,i)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function ls(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 Tr(s,e){function t(){return`${e.app.appID}_light`}const i=localStorage.getItem(t()),n=i!==null?i==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(s.lightInfo!==void 0)for(const l in s.lightInfo){const h=s.lightInfo[l];h!==void 0&&(h.isColor!==void 0?r.push({title:ls(l),prop:l,type:"color",value:h,onChange:(c,u)=>{const m=new o.Color(u);e.updateObject(s.uuid,c,m);const f=e.getScene(s.uuid);if(f!==null){const _=f.getObjectByProperty("uuid",s.uuid);J(_,c,m)}}}):r.push({title:ls(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,u)=>{e.updateObject(s.uuid,c,u);const m=e.getScene(s.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",s.uuid);J(f,c,u)}}}))}return p.jsx(Ce,{title:"Light",items:r,expanded:n,onToggle:l=>{a(l)}})}function Ar(s){const e=s.object,t=s.three;function i(){return`${t.app.appID}_animation`}const n=localStorage.getItem(i()),a=n!==null?n==="open":!1;function r(f){localStorage.setItem(i(),f?"open":"closed")}const l=[],h=[];let c=0;e.animations.forEach(f=>{c=Math.max(c,f.duration),f.duration>0&&h.push({title:f.name,items:[{title:"Duration",type:"number",value:f.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:h});let u;const m=t.getScene(e.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",e.uuid);if(f!==void 0){const _=f.mixer;if(_!==void 0){const T=[{title:"Time Scale",type:"range",value:_.timeScale,step:.01,min:-1,max:2,onChange:(A,g)=>{_.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];T.push({title:"Stop All",type:"button",onChange:()=>{_.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:T}),u=new o.SkeletonHelper(f),ae.instance?.scene.add(u)}}}return O.useEffect(()=>()=>{u!==void 0&&Ae(u)},[]),p.jsx(Ce,{title:"Animation",items:l,expanded:a,onToggle:f=>{r(f)}})}const fi={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let re={...fi};function xs(s){const[e,t]=O.useState(-1);O.useEffect(()=>{function r(h){re={...h.value},t(Date.now())}function l(){re={...fi},t(Date.now())}return R.addEventListener(P.SET_SCENE,l),R.addEventListener(P.SET_OBJECT,r),()=>{R.removeEventListener(P.SET_SCENE,l),R.removeEventListener(P.SET_OBJECT,r)}},[]);const i=re.type.toLowerCase(),n=re.animations.length>0||re.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return p.jsx(vt,{label:"Inspector",button:re.uuid.length>0?p.jsx("button",{className:"remove",onClick:()=>{he.instance.remove(re.name),re={...fi},t(Date.now())}}):void 0,children:p.jsx("div",{id:"Inspector",className:s.class,children:re.uuid.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(p.Fragment,{children:[p.jsx(It,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),p.jsx(It,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),p.jsx(It,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0})]}),p.jsxs(p.Fragment,{children:[p.jsx(zt,{object:re,three:s.three}),n?p.jsx(Ar,{object:re,three:s.three}):null,i.search("camera")>-1?Zn(re,s.three):null,i.search("light")>-1?Tr(re,s.three):null,a?Bn(re,s.three):null]})]})},e)},"Inspector")}class Pr extends O.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=o.SRGBColorSpace;localClippingEnabled=!1;clearColor=new o.Color(0);clearAlpha=1;toneMapping=o.NoToneMapping;toneMappingExposure=1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),i=t!==null?t==="open":!1;if(this.state={expanded:i,lastUpdated:Date.now()},this.saveExpanded(i),ae.instance){const n=ae.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n.getClearColor(this.clearColor))}R.addEventListener(P.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){R.removeEventListener(P.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,o.LinearSRGBColorSpace),o.ColorManagement.enabled=t.colorManagement,ae.instance){const i=ae.instance.renderer;i&&(i.autoClear=this.autoClear,i.autoClearColor=this.autoClearColor,i.autoClearDepth=this.autoClearDepth,i.autoClearStencil=this.autoClearStencil,i.outputColorSpace=this.outputColorSpace,i.localClippingEnabled=this.localClippingEnabled,i.toneMapping=this.toneMapping,i.toneMappingExposure=this.toneMappingExposure,i.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(ae.instance){const t=ae.instance.renderer;t&&(t.autoClear=this.autoClear,t.autoClearColor=this.autoClearColor,t.autoClearDepth=this.autoClearDepth,t.autoClearStencil=this.autoClearStencil,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:o.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return p.jsx(Ce,{title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,i)=>{this.autoClear=i}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,i)=>{this.autoClearColor=i,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,i)=>{this.autoClearDepth=i,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,i)=>{this.autoClearStencil=i,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,i)=>{this.localClippingEnabled=i,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,i)=>{this.clearColor.setStyle(i),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,i)=>{this.clearAlpha=i,e()}},{type:"boolean",title:"Clear Management",value:o.ColorManagement.enabled,onChange:(t,i)=>{o.ColorManagement.enabled=i,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:o.NoColorSpace},{title:"SRB Color Space",value:o.SRGBColorSpace},{title:"Linear SRB Color Space",value:o.LinearSRGBColorSpace}],onChange:(t,i)=>{this.outputColorSpace=i,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:o.NoToneMapping},{title:"Linear ",value:o.LinearToneMapping},{title:"Reinhard",value:o.ReinhardToneMapping},{title:"Cineon ",value:o.CineonToneMapping},{title:"ACES Filmic",value:o.ACESFilmicToneMapping},{title:"AgX",value:o.AgXToneMapping},{title:"Neutral",value:o.NeutralToneMapping},{title:"Custom",value:o.CustomToneMapping}],onChange:(t,i)=>{this.toneMapping=i,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,i)=>{this.toneMappingExposure=i,e()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Os(s){const[e]=O.useState([]),[t]=O.useState([]),[i,n]=O.useState(0),a=h=>{const c=h.value;e.push(c),t.push(p.jsx(vt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{s.three.refreshScene(c.name)},children:p.jsx(di,{child:c,scene:c,three:s.three})},Math.random())),n(Date.now())},r=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e[u]=c,t[u]=p.jsx(vt,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{s.three.refreshScene(c.name)},children:p.jsx(di,{child:c,scene:c,three:s.three})},Math.random()),n(Date.now());return}},l=h=>{const c=h.value;for(let u=0;u<e.length;u++)if(c.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}};return O.useEffect(()=>(R.addEventListener(P.ADD_SCENE,a),R.addEventListener(P.REFRESH_SCENE,r),R.addEventListener(P.REMOVE_SCENE,l),()=>{R.removeEventListener(P.ADD_SCENE,a),R.removeEventListener(P.REFRESH_SCENE,r),R.removeEventListener(P.REMOVE_SCENE,l)}),[]),p.jsxs("div",{id:"SidePanel",children:[p.jsx("div",{className:"scenes",children:t},i),p.jsx(xs,{three:s.three}),p.jsx(Pr,{three:s.three}),p.jsx(ie,{three:s.three})]})}function Rr(s){return O.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,u=e(h)?.getObjectByProperty("uuid",h);u!==void 0&&s.three.setObject(u)},i=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&J(m,h,c)},n=l=>{const h=l.value,{key:c,value:u,uuid:m}=h;i(m,c,u)},a=l=>{const h=l.value,u=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(u!==void 0){const m=f=>{const _=h.key.split(".");switch(_.length){case 1:u[_[0]]=f;break;case 2:u[_[0]][_[1]]=f;break;case 3:u[_[0]][_[1]][_[2]]=f;break;case 4:u[_[0]][_[1]][_[2]][_[3]]=f;break;case 5:u[_[0]][_[1]][_[2]][_[3]][_[4]]=f;break}u.material.needsUpdate=!0};h.value.src.length>0?gs(h.value.src).then(f=>{f.offset.set(h.value.offset[0],h.value.offset[1]),f.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(f)}):m(null)}},r=l=>{const{key:h,uuid:c,value:u,subitem:m}=l.value,_=e(c)?.getObjectByProperty("uuid",c);if(_!==void 0)try{m!==void 0?fn(_,m)[h](u):_[h](u)}catch(w){console.log("Error requesting method:"),console.log(w),console.log(h),console.log(u)}};return R.addEventListener(P.GET_OBJECT,t),R.addEventListener(P.UPDATE_OBJECT,n),R.addEventListener(P.CREATE_TEXTURE,a),R.addEventListener(P.REQUEST_METHOD,r),()=>{R.removeEventListener(P.GET_OBJECT,t),R.removeEventListener(P.UPDATE_OBJECT,n),R.removeEventListener(P.CREATE_TEXTURE,a),R.removeEventListener(P.REQUEST_METHOD,r)}},[]),null}function Ms(s){return p.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[p.jsx("div",{className:"header",children:s.header}),s.children,p.jsx("div",{className:"footer",children:s.footer})]})}function Dr(s){return p.jsx(Ms,{children:p.jsxs(p.Fragment,{children:[p.jsx(ae,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),p.jsx(Os,{three:s.three})]})})}exports.Accordion=vt;exports.Application=on;exports.BaseRemote=Nt;exports.ChildObject=vi;exports.ContainerObject=di;exports.Draggable=vs;exports.DraggableItem=_s;exports.Dropdown=ys;exports.DropdownItem=Cs;exports.Editor=Ms;exports.ExportTexture=gt;exports.Inspector=xs;exports.MultiView=ae;exports.NavButton=_i;exports.QualityType=ms;exports.RemoteComponents=ln;exports.RemoteController=En;exports.RemoteTheatre=dn;exports.RemoteThree=_n;exports.SceneInspector=Rr;exports.SidePanel=Os;exports.Spline=mi;exports.SplineEditor=ws;exports.ThreeEditor=Dr;exports.ToolEvents=P;exports.Transform=he;exports.capitalize=_t;exports.clamp=je;exports.colorToHex=oi;exports.copyToClipboard=hs;exports.customizeTheatreElements=hn;exports.debugDispatcher=R;exports.defaultTheatreCallback=Ks;exports.detectSettings=nn;exports.dispose=Ae;exports.disposeMaterial=fs;exports.disposeTexture=an;exports.distance=rn;exports.hierarchyUUID=kt;exports.isColor=us;exports.mix=Ut;exports.noop=gi;exports.normalize=li;exports.randomID=ds;exports.resetThreeObjects=ci;exports.round=ye;exports.theatreEditorApp=cn;