@tomorrowevening/hermes 0.0.109 → 0.0.111

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),w=require("react"),is=require("framer-motion"),ui=()=>{},Bs=()=>{};function dt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ss(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function Te(i,e,t){return Math.min(e,Math.max(i,t))}function si(i,e,t){return(t-i)/(e-i)}function Rt(i,e,t){return i*(1-t)+e*t}function Ys(i,e){const t=i-e;return Math.sqrt(t*t)}function ns(){return Math.round(Math.random()*1e6).toString()}function rs(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function ni(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=n(e),r=n(t),l=n(s);return"#"+a+r+l}function pe(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const ri=()=>{exports.totalThreeObjects=0},Dt=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const t=i;if(Array.isArray(t.material))t.material.forEach((s,n)=>{s.uuid=`${e}.material.${n}`});else{const s=t.material;s.uuid=`${e}.material`}}i.children.forEach(t=>Dt(t))},Gs=i=>{i?.dispose()},as=i=>{i&&(Array.isArray(i)?i.forEach(e=>e.dispose()):i.dispose())},Se=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Se(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),as(e.material)}i.dispose!==void 0&&i.dispose()}};class ht{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),s=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(s),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 s=new o.Mesh(t,this.material);this.scene.add(s)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,s=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=s}return this.renderer.domElement}}class Zs{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,s=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=s,s?(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=(i=>(i.CUSTOM="ToolEvents::custom",i.SELECT_DROPDOWN="ToolEvents::selectDropdown",i.DRAG_UPDATE="ToolEvents::dragUpdate",i.ADD_SCENE="ToolEvents::addScene",i.REFRESH_SCENE="ToolEvents::refreshScene",i.REMOVE_SCENE="ToolEvents::removeScene",i.SET_SCENE="ToolEvents::setScene",i.GET_OBJECT="ToolEvents::getObject",i.SET_OBJECT="ToolEvents::setObject",i.UPDATE_OBJECT="ToolEvents::updateObject",i.CREATE_TEXTURE="ToolEvents::createTexture",i.REQUEST_METHOD="ToolEvents::requestMethod",i.ADD_CAMERA="ToolEvents::addCamera",i.REMOVE_CAMERA="ToolEvents::removeCamera",i.ADD_GROUP="ToolEvents::addGroup",i.REMOVE_GROUP="ToolEvents::removeGroup",i.ADD_SPLINE="ToolEvents::addSpline",i))(P||{});const R=new o.EventDispatcher;class Lt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,s){}handleEditor(e,t,s){}}class Ws extends Lt{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,s){switch(s.event){case"selectComponent":R.dispatchEvent({type:P.SELECT_DROPDOWN,value:s.data});break;case"draggableListUpdate":R.dispatchEvent({type:P.DRAG_UPDATE,value:s.data});break}}}function Xs(i,e,t){if(i.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",p={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}i.send({event:c,target:"app",data:p})})});let s=-1;const n=()=>{if(e.activeSheet!==void 0&&s!==e.activeSheet.sequence.position){s=e.activeSheet.sequence.position;const r=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else t.ui.hide()}function Qs(){const i=document.getElementById("theatrejs-studio-root")?.shadowRoot?.getElementById("pointer-root")?.children[0],e=i?.children[1];e.style.justifyContent="left";const t=e.children[1];for(t.style.transform="translateX(10px)";t.children.length>1;)t.removeChild(t.children[0]);const s=i?.children[3];s.style.top="0",s.style.right="300px"}class qs extends Lt{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 s=this.getSheetInstance(e,t);let n=this.sheets.get(s);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(s,n)),n}playSheet(e,t,s){return new Promise(n=>{const a=t!==void 0?{...t}:{};this.sheet(e,s)?.sequence.play(a).then(r=>n(r)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,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,s)=>{s.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,s,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,{...s,...c.value},{reconfigure:!0}):c=r.object(t,s),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:ui);const p=c.onValuesChange(m=>{if(this.app.editor){for(const y in m){const x=m[y];typeof x=="object"&&rs(x)&&(m[y]={r:x.r,g:x.g,b:x.b,a:x.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:m}})}const f=this.sheetObjectCBs.get(h);f!==void 0&&f(m)});return this.sheetObjectUnsubscribe.set(h,p),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,s=e.address.objectKey;this.sheets.get(t)?.detachObject(s);const a=`${t}_${s}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e,t,s){const n=t;let a;switch(s.event){case"setSheet":a=n.sheets.get(s.data.sheet),a!==void 0&&(n.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=n.sheetObjects.get(`${s.data.sheet}_${s.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=n.sheets.get(s.data.sheet),a!==void 0&&a.sequence.pause(),a=n.sheetObjectCBs.get(s.data.sheetObject),a!==void 0&&a(s.data.values);break;case"updateTimeline":a=n.sheets.get(s.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=s.data.position);break}}handleEditor(e,t,s){if(e.editor){const n=t;switch(s.event){case"playSheet":n.sheet(s.data.sheet,s.data.instance)?.sequence.play(s.data.value);break;case"pauseSheet":n.sheet(s.data.sheet,s.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",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",p={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:p})})});let s=-1;const n=()=>{if(t.activeSheet!==void 0&&s!==t.activeSheet.sequence.position){s=t.activeSheet.sequence.position;const r=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else this.studio?.ui.hide()}}function Ks(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function Xe(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(Xe(t))}),e}function $s(i){const e={};for(const t in i){const s=i[t].value;e[t]={value:s},s===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:s!==void 0&&s.isTexture&&(e[t].value={src:s.image.src,offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]})}return e}function Js(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function He(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Js(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:ht.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=$s(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function Gt(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(s=>{e.animations.push({name:s.name,duration:s.duration,blendMode:s.blendMode})});const t=i.type.toLowerCase();if(t.search("mesh")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else t.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):t.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function en(i,e){const t=e.split(".");switch(t.length){case 1:return i[t[0]];case 2:return i[t[0]][t[1]];case 3:return i[t[0]][t[1]][t[2]];case 4:return i[t[0]][t[1]][t[2]][t[3]];case 5:return i[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return i[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function tn(i,e){for(const t in e)i[t]=e[t]}function K(i,e,t){if(i===void 0)return;const s=e.split("."),n=s.length;if(typeof t!="object")switch(n){case 1:i[s[0]]=t;break;case 2:i[s[0]][s[1]]=t;break;case 3:i[s[0]][s[1]][s[2]]=t;break;case 4:i[s[0]][s[1]][s[2]][s[3]]=t;break;case 5:i[s[0]][s[1]][s[2]][s[3]][s[4]]=t;break}else{let r;switch(n){case 1:r=i[s[0]];break;case 2:r=i[s[0]][s[1]];break;case 3:r=i[s[0]][s[1]][s[2]];break;case 4:r=i[s[0]][s[1]][s[2]][s[3]];break;case 5:r=i[s[0]][s[1]][s[2]][s[3]][s[4]];break}r!=null&&tn(r,t)}}function os(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new o.Texture(s);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}class sn extends Lt{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Se(e)}),this.scenes.clear(),this.scene&&Se(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(ht.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(ht.renderer=this.renderer);const t=Gt(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,s,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:s,subitem:n}})}updateObject(e,t,s){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}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,s){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;ri(),Dt(e);const t=Xe(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const s=Xe(t);this.app.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=Xe(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(ht.renderer=this.renderer),ri(),Dt(e);const t=Xe(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,s){const n=t;switch(s.event){case"getObject":R.dispatchEvent({type:P.GET_OBJECT,value:s.data});break;case"updateObject":R.dispatchEvent({type:P.UPDATE_OBJECT,value:s.data});break;case"createTexture":R.dispatchEvent({type:P.CREATE_TEXTURE,value:s.data});break;case"requestMethod":R.dispatchEvent({type:P.REQUEST_METHOD,value:s.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:Xe(n.scenes.get(s.data.name))});break}if(s.event==="updateGroup"){const a=JSON.parse(s.data);n.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,t,s){switch(s.event){case"setObject":R.dispatchEvent({type:P.SET_OBJECT,value:s.data});break;case"addScene":R.dispatchEvent({type:P.ADD_SCENE,value:s.data});break;case"refreshScene":R.dispatchEvent({type:P.REFRESH_SCENE,value:s.data});break;case"removeScene":R.dispatchEvent({type:P.REMOVE_SCENE,value:s.data});break;case"setScene":R.dispatchEvent({type:P.SET_SCENE,value:s.data});break;case"addCamera":R.dispatchEvent({type:P.ADD_CAMERA,value:s.data});break;case"removeCamera":R.dispatchEvent({type:P.REMOVE_CAMERA,value:s.data});break;case"addGroup":R.dispatchEvent({type:P.ADD_GROUP,value:s.data});break;case"removeGroup":R.dispatchEvent({type:P.REMOVE_GROUP,value:s.data});break;case"addSpline":R.dispatchEvent({type:P.ADD_SPLINE,value:s.data});break}}addRT(e,t){const s=new o.WebGLRenderTarget(32,32,t);s.texture.name=e,this.renderTargets.set(e,s)}resize(e,t){const s=this.dpr;this.renderTargets.forEach(n=>{n.setSize(e*s,t*s)}),this.renderer?.setSize(e,t)}set dpr(e){this.renderer?.setPixelRatio(Te(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}var ai={exports:{}},Ke={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),w=require("react"),is=require("framer-motion"),ui=()=>{},Bs=()=>{};function dt(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function ss(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function Te(i,e,t){return Math.min(e,Math.max(i,t))}function si(i,e,t){return(t-i)/(e-i)}function Rt(i,e,t){return i*(1-t)+e*t}function Ys(i,e){const t=i-e;return Math.sqrt(t*t)}function ns(){return Math.round(Math.random()*1e6).toString()}function rs(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function ni(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=h=>{const c=h.toString(16);return c.length===1?"0"+c:c},a=n(e),r=n(t),l=n(s);return"#"+a+r+l}function pe(i,e=1){return Number(i.toFixed(e))}exports.totalThreeObjects=0;const ri=()=>{exports.totalThreeObjects=0},Dt=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const t=i;if(Array.isArray(t.material))t.material.forEach((s,n)=>{s.uuid=`${e}.material.${n}`});else{const s=t.material;s.uuid=`${e}.material`}}i.children.forEach(t=>Dt(t))},Gs=i=>{i?.dispose()},as=i=>{i&&(Array.isArray(i)?i.forEach(e=>e.dispose()):i.dispose())},Se=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Se(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),as(e.material)}i.dispose!==void 0&&i.dispose()}};class ht{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),s=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(s),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 s=new o.Mesh(t,this.material);this.scene.add(s)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,s=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=s}return this.renderer.domElement}}class Zs{components=new Map;listen;_appID="";_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(e,t,s=!0){this._appID=e,this._debugEnabled=t,t&&(this._useBC=s,s?(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=(i=>(i.CUSTOM="ToolEvents::custom",i.SELECT_DROPDOWN="ToolEvents::selectDropdown",i.DRAG_UPDATE="ToolEvents::dragUpdate",i.ADD_SCENE="ToolEvents::addScene",i.REFRESH_SCENE="ToolEvents::refreshScene",i.REMOVE_SCENE="ToolEvents::removeScene",i.SET_SCENE="ToolEvents::setScene",i.GET_OBJECT="ToolEvents::getObject",i.SET_OBJECT="ToolEvents::setObject",i.UPDATE_OBJECT="ToolEvents::updateObject",i.CREATE_TEXTURE="ToolEvents::createTexture",i.REQUEST_METHOD="ToolEvents::requestMethod",i.ADD_CAMERA="ToolEvents::addCamera",i.REMOVE_CAMERA="ToolEvents::removeCamera",i.ADD_GROUP="ToolEvents::addGroup",i.REMOVE_GROUP="ToolEvents::removeGroup",i.ADD_SPLINE="ToolEvents::addSpline",i))(P||{});const R=new o.EventDispatcher;class Lt{app;constructor(e){this.app=e}dispose(){}handleApp(e,t,s){}handleEditor(e,t,s){}}class Ws extends Lt{selectDropdown(e,t){this.app.send({event:"selectComponent",target:"app",data:{dropdown:e,value:t}})}updateDropdown(e,t){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:e,value:t}})}handleApp(e,t,s){switch(s.event){case"selectComponent":R.dispatchEvent({type:P.SELECT_DROPDOWN,value:s.data});break;case"draggableListUpdate":R.dispatchEvent({type:P.DRAG_UPDATE,value:s.data});break}}}function Xs(i,e,t){if(i.editor){t.ui.restore(),t.onSelectionChange(r=>{r.length<1||r.forEach(l=>{let h=l.address.sheetId,c="setSheet",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",p={sheet:l.address.sheetId},e.activeSheet=e.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},e.activeSheet=e.sheets.get(l.address.sheetId);break}i.send({event:c,target:"app",data:p})})});let s=-1;const n=()=>{if(e.activeSheet!==void 0&&s!==e.activeSheet.sequence.position){s=e.activeSheet.sequence.position;const r=e.activeSheet;i.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else t.ui.hide()}function Qs(){setTimeout(()=>{const i=document.getElementById("theatrejs-studio-root");if(i===null||i.shadowRoot===null)return;const e=i.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t===null)return;const s=t.children[1];s.style.justifyContent="left";try{const n=s.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 qs extends Lt{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 s=this.getSheetInstance(e,t);let n=this.sheets.get(s);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(s,n)),n}playSheet(e,t,s){return new Promise(n=>{const a=t!==void 0?{...t}:{};this.sheet(e,s)?.sequence.play(a).then(r=>n(r)),this.app.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,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,s)=>{s.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,s,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,{...s,...c.value},{reconfigure:!0}):c=r.object(t,s),this.sheetObjects.set(h,c),this.sheetObjectCBs.set(h,n!==void 0?n:ui);const p=c.onValuesChange(m=>{if(this.app.editor){for(const y in m){const x=m[y];typeof x=="object"&&rs(x)&&(m[y]={r:x.r,g:x.g,b:x.b,a:x.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:h,values:m}})}const f=this.sheetObjectCBs.get(h);f!==void 0&&f(m)});return this.sheetObjectUnsubscribe.set(h,p),c}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,s=e.address.objectKey;this.sheets.get(t)?.detachObject(s);const a=`${t}_${s}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e,t,s){const n=t;let a;switch(s.event){case"setSheet":a=n.sheets.get(s.data.sheet),a!==void 0&&(n.activeSheet=a,this.studio?.setSelection([a]));break;case"setSheetObject":a=n.sheetObjects.get(`${s.data.sheet}_${s.data.key}`),a!==void 0&&this.studio?.setSelection([a]);break;case"updateSheetObject":a=n.sheets.get(s.data.sheet),a!==void 0&&a.sequence.pause(),a=n.sheetObjectCBs.get(s.data.sheetObject),a!==void 0&&a(s.data.values);break;case"updateTimeline":a=n.sheets.get(s.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=s.data.position);break}}handleEditor(e,t,s){if(e.editor){const n=t;switch(s.event){case"playSheet":n.sheet(s.data.sheet,s.data.instance)?.sequence.play(s.data.value);break;case"pauseSheet":n.sheet(s.data.sheet,s.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",p={};switch(l.type){case"Theatre_Sheet_PublicAPI":c="setSheet",p={sheet:l.address.sheetId},t.activeSheet=t.sheets.get(l.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":c="setSheetObject",h+=`_${l.address.objectKey}`,p={id:h,sheet:l.address.sheetId,key:l.address.objectKey},t.activeSheet=t.sheets.get(l.address.sheetId);break}e.send({event:c,target:"app",data:p})})});let s=-1;const n=()=>{if(t.activeSheet!==void 0&&s!==t.activeSheet.sequence.position){s=t.activeSheet.sequence.position;const r=t.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:s,sheet:r.address.sheetId}})}},a=()=>{n(),requestAnimationFrame(a)};n(),a()}else this.studio?.ui.hide()}}function Ks(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function Xe(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(Xe(t))}),e}function $s(i){const e={};for(const t in i){const s=i[t].value;e[t]={value:s},s===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:s!==void 0&&s.isTexture&&(e[t].value={src:s.image.src,offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]})}return e}function Js(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function He(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Js(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:ht.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=$s(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function Gt(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(s=>{e.animations.push({name:s.name,duration:s.duration,blendMode:s.blendMode})});const t=i.type.toLowerCase();if(t.search("mesh")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(He(a))}),e.material=n}else e.material=He(s.material)}else t.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):t.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function en(i,e){const t=e.split(".");switch(t.length){case 1:return i[t[0]];case 2:return i[t[0]][t[1]];case 3:return i[t[0]][t[1]][t[2]];case 4:return i[t[0]][t[1]][t[2]][t[3]];case 5:return i[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return i[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function tn(i,e){for(const t in e)i[t]=e[t]}function q(i,e,t){if(i===void 0)return;const s=e.split("."),n=s.length;if(typeof t!="object")switch(n){case 1:i[s[0]]=t;break;case 2:i[s[0]][s[1]]=t;break;case 3:i[s[0]][s[1]][s[2]]=t;break;case 4:i[s[0]][s[1]][s[2]][s[3]]=t;break;case 5:i[s[0]][s[1]][s[2]][s[3]][s[4]]=t;break}else{let r;switch(n){case 1:r=i[s[0]];break;case 2:r=i[s[0]][s[1]];break;case 3:r=i[s[0]][s[1]][s[2]];break;case 4:r=i[s[0]][s[1]][s[2]][s[3]];break;case 5:r=i[s[0]][s[1]][s[2]][s[3]][s[4]];break}r!=null&&tn(r,t)}}function os(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new o.Texture(s);n.wrapS=o.RepeatWrapping,n.wrapT=o.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}class sn extends Lt{scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;groups=new Map;dispose(){this.scenes.forEach(e=>{Se(e)}),this.scenes.clear(),this.scene&&Se(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}getObject(e){this.app.debugEnabled&&(this.renderer!==void 0&&(ht.renderer=this.renderer),this.app.send({event:"getObject",target:"app",data:e}))}setObject(e){this.renderer!==void 0&&(ht.renderer=this.renderer);const t=Gt(e);this.app.send({event:"setObject",target:"editor",data:t})}requestMethod(e,t,s,n){this.app.send({event:"requestMethod",target:"app",data:{uuid:e,key:t,value:s,subitem:n}})}updateObject(e,t,s){this.app.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.app.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}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,s){this.app.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}removeAllGroups(){this.groups.forEach(e=>{const t=e.title;this.groups.delete(t),this.app.send({event:"removeGroup",target:"editor",data:t})}),this.groups.clear()}addSpline(e){setTimeout(()=>{this.app.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.app.debugEnabled))return;ri(),Dt(e);const t=Xe(e);this.app.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.app.debugEnabled)return;const t=this.scenes.get(e);if(t!==void 0){const s=Xe(t);this.app.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.app.debugEnabled))return;const t=Xe(e);this.app.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t}setScene(e){if(e===void 0||(this.scene=e,!this.app.debugEnabled))return;this.renderer!==void 0&&(ht.renderer=this.renderer),ri(),Dt(e);const t=Xe(e);this.app.send({event:"setScene",target:"editor",data:t})}addCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.app.debugEnabled)return;const t=Gt(e);this.app.send({event:"removeCamera",target:"editor",data:t})}handleApp(e,t,s){const n=t;switch(s.event){case"getObject":R.dispatchEvent({type:P.GET_OBJECT,value:s.data});break;case"updateObject":R.dispatchEvent({type:P.UPDATE_OBJECT,value:s.data});break;case"createTexture":R.dispatchEvent({type:P.CREATE_TEXTURE,value:s.data});break;case"requestMethod":R.dispatchEvent({type:P.REQUEST_METHOD,value:s.data});break;case"refreshScene":e.send({event:"refreshScene",target:"editor",data:Xe(n.scenes.get(s.data.name))});break}if(s.event==="updateGroup"){const a=JSON.parse(s.data);n.groups.get(a.group)?.onUpdate(a.prop,a.value)}}handleEditor(e,t,s){switch(s.event){case"setObject":R.dispatchEvent({type:P.SET_OBJECT,value:s.data});break;case"addScene":R.dispatchEvent({type:P.ADD_SCENE,value:s.data});break;case"refreshScene":R.dispatchEvent({type:P.REFRESH_SCENE,value:s.data});break;case"removeScene":R.dispatchEvent({type:P.REMOVE_SCENE,value:s.data});break;case"setScene":R.dispatchEvent({type:P.SET_SCENE,value:s.data});break;case"addCamera":R.dispatchEvent({type:P.ADD_CAMERA,value:s.data});break;case"removeCamera":R.dispatchEvent({type:P.REMOVE_CAMERA,value:s.data});break;case"addGroup":R.dispatchEvent({type:P.ADD_GROUP,value:s.data});break;case"removeGroup":R.dispatchEvent({type:P.REMOVE_GROUP,value:s.data});break;case"addSpline":R.dispatchEvent({type:P.ADD_SPLINE,value:s.data});break}}addRT(e,t){const s=new o.WebGLRenderTarget(32,32,t);s.texture.name=e,this.renderTargets.set(e,s)}resize(e,t){const s=this.dpr;this.renderTargets.forEach(n=>{n.setSize(e*s,t*s)}),this.renderer?.setSize(e,t)}set dpr(e){this.renderer?.setPixelRatio(Te(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}get canvas(){return this.renderer!==void 0?this.renderer?.domElement:null}}var ai={exports:{}},Ke={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -17,17 +17,17 @@
17
17
  */var Ri;function rn(){return Ri||(Ri=1,process.env.NODE_ENV!=="production"&&function(){var i=w,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=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"),p=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),x=Symbol.iterator,T="@@iterator";function M(d){if(d===null||typeof d!="object")return null;var b=x&&d[x]||d[T];return typeof b=="function"?b:null}var _=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(d){{for(var b=arguments.length,S=new Array(b>1?b-1:0),I=1;I<b;I++)S[I-1]=arguments[I];C("error",d,S)}}function C(d,b,S){{var I=_.ReactDebugCurrentFrame,N=I.getStackAddendum();N!==""&&(b+="%s",S=S.concat([N]));var V=S.map(function(k){return String(k)});V.unshift("Warning: "+b),Function.prototype.apply.call(console[d],console,V)}}var E=!1,A=!1,O=!1,j=!1,W=!1,he;he=Symbol.for("react.module.reference");function we(d){return!!(typeof d=="string"||typeof d=="function"||d===s||d===a||W||d===n||d===c||d===p||j||d===y||E||A||O||typeof d=="object"&&d!==null&&(d.$$typeof===f||d.$$typeof===m||d.$$typeof===r||d.$$typeof===l||d.$$typeof===h||d.$$typeof===he||d.getModuleId!==void 0))}function Qe(d,b,S){var I=d.displayName;if(I)return I;var N=b.displayName||b.name||"";return N!==""?S+"("+N+")":S}function Fe(d){return d.displayName||"Context"}function ce(d){if(d==null)return null;if(typeof d.tag=="number"&&v("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 s:return"Fragment";case t:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case p:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case l:var b=d;return Fe(b)+".Consumer";case r:var S=d;return Fe(S._context)+".Provider";case h:return Qe(d,d.render,"ForwardRef");case m:var I=d.displayName||null;return I!==null?I:ce(d.type)||"Memo";case f:{var N=d,V=N._payload,k=N._init;try{return ce(k(V))}catch{return null}}}return null}var J=Object.assign,X=0,Me,ae,Ee,te,Pe,Ae,Re;function pt(){}pt.__reactDisabledLog=!0;function mt(){{if(X===0){Me=console.log,ae=console.info,Ee=console.warn,te=console.error,Pe=console.group,Ae=console.groupCollapsed,Re=console.groupEnd;var d={configurable:!0,enumerable:!0,value:pt,writable:!0};Object.defineProperties(console,{info:d,log:d,warn:d,error:d,group:d,groupCollapsed:d,groupEnd:d})}X++}}function vs(){{if(X--,X===0){var d={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},d,{value:Me}),info:J({},d,{value:ae}),warn:J({},d,{value:Ee}),error:J({},d,{value:te}),group:J({},d,{value:Pe}),groupCollapsed:J({},d,{value:Ae}),groupEnd:J({},d,{value:Re})})}X<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var jt=_.ReactCurrentDispatcher,Ft;function ft(d,b,S){{if(Ft===void 0)try{throw Error()}catch(N){var I=N.stack.trim().match(/\n( *(at )?)/);Ft=I&&I[1]||""}return`
18
18
  `+Ft+d}}var Nt=!1,gt;{var bs=typeof WeakMap=="function"?WeakMap:Map;gt=new bs}function gi(d,b){if(!d||Nt)return"";{var S=gt.get(d);if(S!==void 0)return S}var I;Nt=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=jt.current,jt.current=null,mt();try{if(b){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Ce){I=Ce}Reflect.construct(d,[],k)}else{try{k.call()}catch(Ce){I=Ce}d.call(k.prototype)}}else{try{throw Error()}catch(Ce){I=Ce}d()}}catch(Ce){if(Ce&&I&&typeof Ce.stack=="string"){for(var U=Ce.stack.split(`
19
19
  `),re=I.stack.split(`
20
- `),Q=U.length-1,$=re.length-1;Q>=1&&$>=0&&U[Q]!==re[$];)$--;for(;Q>=1&&$>=0;Q--,$--)if(U[Q]!==re[$]){if(Q!==1||$!==1)do if(Q--,$--,$<0||U[Q]!==re[$]){var de=`
21
- `+U[Q].replace(" at new "," at ");return d.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",d.displayName)),typeof d=="function"&&gt.set(d,de),de}while(Q>=1&&$>=0);break}}}finally{Nt=!1,jt.current=V,vs(),Error.prepareStackTrace=N}var ze=d?d.displayName||d.name:"",Pi=ze?ft(ze):"";return typeof d=="function"&&gt.set(d,Pi),Pi}function Es(d,b,S){return gi(d,!1)}function Cs(d){var b=d.prototype;return!!(b&&b.isReactComponent)}function _t(d,b,S){if(d==null)return"";if(typeof d=="function")return gi(d,Cs(d));if(typeof d=="string")return ft(d);switch(d){case c:return ft("Suspense");case p:return ft("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return Es(d.render);case m:return _t(d.type,b,S);case f:{var I=d,N=I._payload,V=I._init;try{return _t(V(N),b,S)}catch{}}}return""}var yt=Object.prototype.hasOwnProperty,_i={},yi=_.ReactDebugCurrentFrame;function vt(d){if(d){var b=d._owner,S=_t(d.type,d._source,b?b.type:null);yi.setExtraStackFrame(S)}else yi.setExtraStackFrame(null)}function Ss(d,b,S,I,N){{var V=Function.call.bind(yt);for(var k in d)if(V(d,k)){var U=void 0;try{if(typeof d[k]!="function"){var re=Error((I||"React class")+": "+S+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw re.name="Invariant Violation",re}U=d[k](b,k,I,S,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){U=Q}U&&!(U instanceof Error)&&(vt(N),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",I||"React class",S,k,typeof U),vt(null)),U instanceof Error&&!(U.message in _i)&&(_i[U.message]=!0,vt(N),v("Failed %s type: %s",S,U.message),vt(null))}}}var ws=Array.isArray;function zt(d){return ws(d)}function xs(d){{var b=typeof Symbol=="function"&&Symbol.toStringTag,S=b&&d[Symbol.toStringTag]||d.constructor.name||"Object";return S}}function Os(d){try{return vi(d),!1}catch{return!0}}function vi(d){return""+d}function bi(d){if(Os(d))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",xs(d)),vi(d)}var qe=_.ReactCurrentOwner,Ts={key:!0,ref:!0,__self:!0,__source:!0},Ei,Ci,Ht;Ht={};function Ms(d){if(yt.call(d,"ref")){var b=Object.getOwnPropertyDescriptor(d,"ref").get;if(b&&b.isReactWarning)return!1}return d.ref!==void 0}function Ps(d){if(yt.call(d,"key")){var b=Object.getOwnPropertyDescriptor(d,"key").get;if(b&&b.isReactWarning)return!1}return d.key!==void 0}function As(d,b){if(typeof d.ref=="string"&&qe.current&&b&&qe.current.stateNode!==b){var S=ce(qe.current.type);Ht[S]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ce(qe.current.type),d.ref),Ht[S]=!0)}}function Rs(d,b){{var S=function(){Ei||(Ei=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};S.isReactWarning=!0,Object.defineProperty(d,"key",{get:S,configurable:!0})}}function Ds(d,b){{var S=function(){Ci||(Ci=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};S.isReactWarning=!0,Object.defineProperty(d,"ref",{get:S,configurable:!0})}}var Is=function(d,b,S,I,N,V,k){var U={$$typeof:e,type:d,key:b,ref:S,props:k,_owner:V};return U._store={},Object.defineProperty(U._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(U,"_self",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.defineProperty(U,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(U.props),Object.freeze(U)),U};function Ls(d,b,S,I,N){{var V,k={},U=null,re=null;S!==void 0&&(bi(S),U=""+S),Ps(b)&&(bi(b.key),U=""+b.key),Ms(b)&&(re=b.ref,As(b,N));for(V in b)yt.call(b,V)&&!Ts.hasOwnProperty(V)&&(k[V]=b[V]);if(d&&d.defaultProps){var Q=d.defaultProps;for(V in Q)k[V]===void 0&&(k[V]=Q[V])}if(U||re){var $=typeof d=="function"?d.displayName||d.name||"Unknown":d;U&&Rs(k,$),re&&Ds(k,$)}return Is(d,U,re,N,I,qe.current,k)}}var Vt=_.ReactCurrentOwner,Si=_.ReactDebugCurrentFrame;function Ne(d){if(d){var b=d._owner,S=_t(d.type,d._source,b?b.type:null);Si.setExtraStackFrame(S)}else Si.setExtraStackFrame(null)}var Bt;Bt=!1;function Yt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function wi(){{if(Vt.current){var d=ce(Vt.current.type);if(d)return`
20
+ `),Q=U.length-1,K=re.length-1;Q>=1&&K>=0&&U[Q]!==re[K];)K--;for(;Q>=1&&K>=0;Q--,K--)if(U[Q]!==re[K]){if(Q!==1||K!==1)do if(Q--,K--,K<0||U[Q]!==re[K]){var de=`
21
+ `+U[Q].replace(" at new "," at ");return d.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",d.displayName)),typeof d=="function"&&gt.set(d,de),de}while(Q>=1&&K>=0);break}}}finally{Nt=!1,jt.current=V,vs(),Error.prepareStackTrace=N}var ze=d?d.displayName||d.name:"",Pi=ze?ft(ze):"";return typeof d=="function"&&gt.set(d,Pi),Pi}function Es(d,b,S){return gi(d,!1)}function Cs(d){var b=d.prototype;return!!(b&&b.isReactComponent)}function _t(d,b,S){if(d==null)return"";if(typeof d=="function")return gi(d,Cs(d));if(typeof d=="string")return ft(d);switch(d){case c:return ft("Suspense");case p:return ft("SuspenseList")}if(typeof d=="object")switch(d.$$typeof){case h:return Es(d.render);case m:return _t(d.type,b,S);case f:{var I=d,N=I._payload,V=I._init;try{return _t(V(N),b,S)}catch{}}}return""}var yt=Object.prototype.hasOwnProperty,_i={},yi=_.ReactDebugCurrentFrame;function vt(d){if(d){var b=d._owner,S=_t(d.type,d._source,b?b.type:null);yi.setExtraStackFrame(S)}else yi.setExtraStackFrame(null)}function Ss(d,b,S,I,N){{var V=Function.call.bind(yt);for(var k in d)if(V(d,k)){var U=void 0;try{if(typeof d[k]!="function"){var re=Error((I||"React class")+": "+S+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof d[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw re.name="Invariant Violation",re}U=d[k](b,k,I,S,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Q){U=Q}U&&!(U instanceof Error)&&(vt(N),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",I||"React class",S,k,typeof U),vt(null)),U instanceof Error&&!(U.message in _i)&&(_i[U.message]=!0,vt(N),v("Failed %s type: %s",S,U.message),vt(null))}}}var ws=Array.isArray;function zt(d){return ws(d)}function xs(d){{var b=typeof Symbol=="function"&&Symbol.toStringTag,S=b&&d[Symbol.toStringTag]||d.constructor.name||"Object";return S}}function Os(d){try{return vi(d),!1}catch{return!0}}function vi(d){return""+d}function bi(d){if(Os(d))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",xs(d)),vi(d)}var qe=_.ReactCurrentOwner,Ts={key:!0,ref:!0,__self:!0,__source:!0},Ei,Ci,Ht;Ht={};function Ms(d){if(yt.call(d,"ref")){var b=Object.getOwnPropertyDescriptor(d,"ref").get;if(b&&b.isReactWarning)return!1}return d.ref!==void 0}function Ps(d){if(yt.call(d,"key")){var b=Object.getOwnPropertyDescriptor(d,"key").get;if(b&&b.isReactWarning)return!1}return d.key!==void 0}function As(d,b){if(typeof d.ref=="string"&&qe.current&&b&&qe.current.stateNode!==b){var S=ce(qe.current.type);Ht[S]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ce(qe.current.type),d.ref),Ht[S]=!0)}}function Rs(d,b){{var S=function(){Ei||(Ei=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};S.isReactWarning=!0,Object.defineProperty(d,"key",{get:S,configurable:!0})}}function Ds(d,b){{var S=function(){Ci||(Ci=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};S.isReactWarning=!0,Object.defineProperty(d,"ref",{get:S,configurable:!0})}}var Is=function(d,b,S,I,N,V,k){var U={$$typeof:e,type:d,key:b,ref:S,props:k,_owner:V};return U._store={},Object.defineProperty(U._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(U,"_self",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.defineProperty(U,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(U.props),Object.freeze(U)),U};function Ls(d,b,S,I,N){{var V,k={},U=null,re=null;S!==void 0&&(bi(S),U=""+S),Ps(b)&&(bi(b.key),U=""+b.key),Ms(b)&&(re=b.ref,As(b,N));for(V in b)yt.call(b,V)&&!Ts.hasOwnProperty(V)&&(k[V]=b[V]);if(d&&d.defaultProps){var Q=d.defaultProps;for(V in Q)k[V]===void 0&&(k[V]=Q[V])}if(U||re){var K=typeof d=="function"?d.displayName||d.name||"Unknown":d;U&&Rs(k,K),re&&Ds(k,K)}return Is(d,U,re,N,I,qe.current,k)}}var Vt=_.ReactCurrentOwner,Si=_.ReactDebugCurrentFrame;function Ne(d){if(d){var b=d._owner,S=_t(d.type,d._source,b?b.type:null);Si.setExtraStackFrame(S)}else Si.setExtraStackFrame(null)}var Bt;Bt=!1;function Yt(d){return typeof d=="object"&&d!==null&&d.$$typeof===e}function wi(){{if(Vt.current){var d=ce(Vt.current.type);if(d)return`
22
22
 
23
23
  Check the render method of \``+d+"`."}return""}}function Us(d){{if(d!==void 0){var b=d.fileName.replace(/^.*[\\\/]/,""),S=d.lineNumber;return`
24
24
 
25
25
  Check your code at `+b+":"+S+"."}return""}}var xi={};function ks(d){{var b=wi();if(!b){var S=typeof d=="string"?d:d.displayName||d.name;S&&(b=`
26
26
 
27
- Check the top-level render call using <`+S+">.")}return b}}function Oi(d,b){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var S=ks(b);if(xi[S])return;xi[S]=!0;var I="";d&&d._owner&&d._owner!==Vt.current&&(I=" It was passed a child from "+ce(d._owner.type)+"."),Ne(d),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',S,I),Ne(null)}}function Ti(d,b){{if(typeof d!="object")return;if(zt(d))for(var S=0;S<d.length;S++){var I=d[S];Yt(I)&&Oi(I,b)}else if(Yt(d))d._store&&(d._store.validated=!0);else if(d){var N=M(d);if(typeof N=="function"&&N!==d.entries)for(var V=N.call(d),k;!(k=V.next()).done;)Yt(k.value)&&Oi(k.value,b)}}}function js(d){{var b=d.type;if(b==null||typeof b=="string")return;var S;if(typeof b=="function")S=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===h||b.$$typeof===m))S=b.propTypes;else return;if(S){var I=ce(b);Ss(S,d.props,"prop",I,d)}else if(b.PropTypes!==void 0&&!Bt){Bt=!0;var N=ce(b);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Fs(d){{for(var b=Object.keys(d.props),S=0;S<b.length;S++){var I=b[S];if(I!=="children"&&I!=="key"){Ne(d),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",I),Ne(null);break}}d.ref!==null&&(Ne(d),v("Invalid attribute `ref` supplied to `React.Fragment`."),Ne(null))}}function Mi(d,b,S,I,N,V){{var k=we(d);if(!k){var U="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(U+=" 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 re=Us(N);re?U+=re:U+=wi();var Q;d===null?Q="null":zt(d)?Q="array":d!==void 0&&d.$$typeof===e?(Q="<"+(ce(d.type)||"Unknown")+" />",U=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof d,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,U)}var $=Ls(d,b,S,N,V);if($==null)return $;if(k){var de=b.children;if(de!==void 0)if(I)if(zt(de)){for(var ze=0;ze<de.length;ze++)Ti(de[ze],d);Object.freeze&&Object.freeze(de)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ti(de,d)}return d===s?Fs($):js($),$}}function Ns(d,b,S){return Mi(d,b,S,!0)}function zs(d,b,S){return Mi(d,b,S,!1)}var Hs=zs,Vs=Ns;$e.Fragment=s,$e.jsx=Hs,$e.jsxs=Vs}()),$e}process.env.NODE_ENV==="production"?ai.exports=nn():ai.exports=rn();var u=ai.exports;function pi(i){return i.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):u.jsx("button",{children:i.title})}const an=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),on=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
27
+ Check the top-level render call using <`+S+">.")}return b}}function Oi(d,b){{if(!d._store||d._store.validated||d.key!=null)return;d._store.validated=!0;var S=ks(b);if(xi[S])return;xi[S]=!0;var I="";d&&d._owner&&d._owner!==Vt.current&&(I=" It was passed a child from "+ce(d._owner.type)+"."),Ne(d),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',S,I),Ne(null)}}function Ti(d,b){{if(typeof d!="object")return;if(zt(d))for(var S=0;S<d.length;S++){var I=d[S];Yt(I)&&Oi(I,b)}else if(Yt(d))d._store&&(d._store.validated=!0);else if(d){var N=M(d);if(typeof N=="function"&&N!==d.entries)for(var V=N.call(d),k;!(k=V.next()).done;)Yt(k.value)&&Oi(k.value,b)}}}function js(d){{var b=d.type;if(b==null||typeof b=="string")return;var S;if(typeof b=="function")S=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===h||b.$$typeof===m))S=b.propTypes;else return;if(S){var I=ce(b);Ss(S,d.props,"prop",I,d)}else if(b.PropTypes!==void 0&&!Bt){Bt=!0;var N=ce(b);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Fs(d){{for(var b=Object.keys(d.props),S=0;S<b.length;S++){var I=b[S];if(I!=="children"&&I!=="key"){Ne(d),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",I),Ne(null);break}}d.ref!==null&&(Ne(d),v("Invalid attribute `ref` supplied to `React.Fragment`."),Ne(null))}}function Mi(d,b,S,I,N,V){{var k=we(d);if(!k){var U="";(d===void 0||typeof d=="object"&&d!==null&&Object.keys(d).length===0)&&(U+=" 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 re=Us(N);re?U+=re:U+=wi();var Q;d===null?Q="null":zt(d)?Q="array":d!==void 0&&d.$$typeof===e?(Q="<"+(ce(d.type)||"Unknown")+" />",U=" Did you accidentally export a JSX literal instead of a component?"):Q=typeof d,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Q,U)}var K=Ls(d,b,S,N,V);if(K==null)return K;if(k){var de=b.children;if(de!==void 0)if(I)if(zt(de)){for(var ze=0;ze<de.length;ze++)Ti(de[ze],d);Object.freeze&&Object.freeze(de)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ti(de,d)}return d===s?Fs(K):js(K),K}}function Ns(d,b,S){return Mi(d,b,S,!0)}function zs(d,b,S){return Mi(d,b,S,!1)}var Hs=zs,Vs=Ns;$e.Fragment=s,$e.jsx=Hs,$e.jsxs=Vs}()),$e}process.env.NODE_ENV==="production"?ai.exports=nn():ai.exports=rn();var u=ai.exports;function pi(i){return i.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):u.jsx("button",{children:i.title})}const an=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),on=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
28
28
  C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1\r
29
- C11,8.22,10.74,8,10.43,8z`})});function ls(i){return u.jsx(is.Reorder.Item,{value:i.title,children:u.jsxs("div",{children:[on,u.jsx("span",{children:i.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:an})]})},i.title)}function cs(i){const[e,t]=w.useState(!1),[s,n]=w.useState(i.options),a=c=>{i.onDragComplete(c),n(c)},r=c=>{const p=[...s];p.splice(c,1),a(p)},l=[];s.forEach((c,p)=>{l.push(u.jsx(ls,{index:p,title:c,onDelete:r},c))});let h="dropdown draggable";return i.subdropdown&&(h+=" subdropdown"),u.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(pi,{title:i.title}),u.jsx(is.Reorder.Group,{axis:"y",values:s,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function hs(i){const[e,t]=w.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(u.jsx(ds,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),u.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(pi,{title:i.title}),u.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function ds(i){const{option:e}=i,[t,s]=w.useState("");let n;switch(e.type){case"draggable":n=u.jsx(cs,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=u.jsx(hs,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=u.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return u.jsx("li",{className:t===e.title?"selected":"",children:n},ns())}function ln(i,e,t){function s(a){switch(e.forEach(r=>{r.callback(i,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(i,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}i.listen=a=>{a.target==="editor"?n(a):s(a)}}function ut(i){const[e,t]=w.useState(i.open!==void 0?i.open:!0),s=!e||i.children===void 0,n=()=>{R.dispatchEvent({type:P.REMOVE_SCENE,value:i.scene})};return u.jsxs("div",{className:`accordion ${s?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;i.onToggle!==void 0&&i.onToggle(a),t(a)},children:[u.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:dt(i.label)})]}),i.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:i.onRefresh}),u.jsx("button",{className:"remove",onClick:n})]}):null,i.button,u.jsx("div",{className:e?"open":"",children:u.jsx("div",{children:i.children})},Math.random())]})}function mi(i){const e=w.useRef(null),[t,s]=w.useState(!1),n=i.child!==void 0&&i.child.children.length>0,a=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((r,l)=>{a.push(u.jsx(mi,{child:r,three:i.three},l))}),w.useEffect(()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),u.jsx(u.Fragment,{children:i.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[n?u.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,u.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0&&(i.three.getObject(i.child.uuid),t||s(!0))},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),u.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);if(l!==void 0){const h="visible",c=!l.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,h,c),K(l,h,c)}}}}}),u.jsx("div",{className:`icon ${Ks(i.child)}`})]}),u.jsx("div",{className:t?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function oi(i){const e=[];return i.child?.children.map((t,s)=>{e.push(u.jsx(mi,{child:t,scene:i.scene,three:i.three},s))}),u.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function cn(i){const[e,t]=w.useState(i.defaultValue);return w.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue;const l=f=>{s=!0,a=Number(i.input.current?.value),n=f.clientX,document.addEventListener("mouseup",c,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",c,!1)},h=f=>{if(!s)return;const y=i.step!==void 0?i.step:1,x=(f.clientX-n)*y;r=Number((a+x).toFixed(4)),i.min!==void 0&&(r=Math.max(r,i.min)),i.max!==void 0&&(r=Math.min(r,i.max)),i.onChange!==void 0&&i.onChange(r),t(r)},c=()=>{s=!1,document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)},p=f=>{const y=Number(f.target.value);t(y)},m=f=>{const y=Number(f.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.input.current?.addEventListener("input",p),i.label.current?.addEventListener("mousedown",l,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),()=>{i.input.current?.removeEventListener("input",p),i.label.current?.removeEventListener("mousedown",l),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)}},[]),e}function je(i){const e=w.useRef(null),t=w.useRef(null),s=cn({label:i.labelRef,input:e,sliderRef:t,defaultValue:i.value,min:i.min,max:i.max,step:i.step,onChange:n=>{i.onChange!==void 0&&i.onChange(i.prop,n)}});return u.jsxs(u.Fragment,{children:[i.type==="number"&&u.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,onChange:n=>{const a=Number(n.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),i.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",onChange:n=>{const a=Number(n.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),u.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,onChange:ui})]})]})}function hn(i){const e=w.useRef(null),t=w.useRef(null),s=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l,h]=w.useState(i.value),[c,p]=w.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[m,f]=w.useState(!1);function y(){m||(window.addEventListener("mousemove",T),window.addEventListener("mouseup",x),window.addEventListener("mouseup",x),f(!0))}function x(){window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",x),f(!1)}function T(E){const A=a.current.getBoundingClientRect(),O=Te(0,99,E.clientX-A.left)/99,j=Te(0,99,E.clientY-A.top)/99,W=pe(Rt(c.min,c.max,O),3),he=pe(Rt(c.min,c.max,j),3);i.onChange({target:{value:{x:W,y:he}}}),h({x:W,y:he})}function M(E){let A=l.x,O=l.y;E.target===e.current?A=Number(E.target.value):O=Number(E.target.value),h({x:A,y:O})}function _(){const E=Number(s.current.value);p({min:E,max:c.max}),(l.x<E||l.y<E)&&h({x:Te(E,c.max,l.x),y:Te(E,c.max,l.y)})}function v(){const E=Number(n.current.value);p({min:c.min,max:E}),(l.x>E||l.y>E)&&h({x:Te(c.min,E,l.x),y:Te(c.min,E,l.y)})}w.useEffect(()=>{const E=si(c.min,c.max,l.x),A=si(c.min,c.max,l.y);r.current.style.left=`${E*100}%`,r.current.style.top=`${A*100}%`},[c,l]);const C=i.step!==void 0?i.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"X:"}),u.jsx("input",{ref:e,type:"number",value:l.x,min:c.min,max:c.max,step:C,onChange:M})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:t,type:"number",value:l.y,min:c.min,max:c.max,step:C,onChange:M})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:s,type:"number",value:c.min,step:C,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:n,type:"number",value:c.max,step:C,onChange:v})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:x,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:r})]})]})}const dn=Math.PI/180,un=180/Math.PI;function Ve(i,e,t,s,n){return s+(i-e)*(n-s)/(t-e)}function Be(i,e,t){return(1-t)*i+t*e}function li(i){return i*dn}function pn(i){return i*un}function Di(i){const e=i.value.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,t=i.value.isEuler!==void 0,s=i.value.elements!==void 0,n=i.step!==void 0?i.step:.01,a=[];if(t){const r=w.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(h=>{const c=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),u.jsx(je,{value:pn(r[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(p,m)=>{r[p]=li(m),i.onChange({target:{value:r}})}})]},h))})}else if(e){const r=w.useMemo(()=>i.value,[]),l=(c,p)=>{r[c]=p,i.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const p=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:p,children:c.toUpperCase()}),u.jsx(je,{value:r[c],type:"number",prop:c,step:n,labelRef:p,onChange:l})]},c))})}else if(s){const r=w.useMemo(()=>i.value,[]),l=(h,c)=>{const p=Number(h);r.elements[p]=c,i.onChange({target:{value:r}})};for(let h=0;h<9;h++){const c=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h+1}),u.jsx(je,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function mn(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=w.useMemo(()=>i.value,[]),a=(l,h)=>{n[l]=h,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=w.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:l.toUpperCase()}),u.jsx(je,{value:n.x,type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=w.useMemo(()=>i.value,[]),a=(r,l)=>{const h=Number(r);n.elements[h]=l,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const l=w.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("label",{ref:l,children:r+1}),u.jsx(je,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return u.jsx("div",{className:"grid4",children:s})}function fn(i){return!(i==="defaultAttributeValues"||i==="forceSinglePass"||i==="linecap"||i==="linejoin"||i==="linewidth"||i==="normalMapType"||i==="precision"||i==="shadowSide"||i==="uniformsGroups"||i==="uniformsNeedUpdate"||i==="userData"||i==="version"||i==="wireframeLinecap"||i==="wireframeLinejoin"||i==="wireframeLinewidth"||i.slice(0,4)==="clip"||i.slice(0,7)==="polygon"||i.slice(0,7)==="stencil"||i.slice(0,2)==="is")}function gn(i){switch(i){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return i}function Ut(i){switch(i){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return i}function us(i){const e=i.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function _n(){const i=document.createElement("input");return i.type="file",new Promise((e,t)=>{i.addEventListener("change",function(){if(i.files===null)t();else{const s=i.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(s)}}),i.click()})}const yn=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],vn=[{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}],bn=[{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}],En=[{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}],Cn=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function Je(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Sn(i,e,t,s){return{type:"boolean",title:Ut(i),prop:i,value:e,needsUpdate:!0,onChange:(n,a)=>{s.updateObject(t.uuid,`material.${i}`,a),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",t.uuid);K(l,`material.${i}`,a)}}}}function wn(i,e,t,s){const n={type:"number",title:Ut(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);K(h,`material.${i}`,r)}}};switch(i){case"blending":Je(n,vn);break;case"blendDst":Je(n,Cn);break;case"blendEquation":Je(n,bn);break;case"blendSrc":Je(n,En);break;case"side":Je(n,yn);break}return us(i)&&(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 xn(i,e,t,s){const n={type:"string",title:Ut(i),prop:i,value:e,needsUpdate:!0,onChange:(r,l)=>{s.updateObject(t.uuid,`material.${i}`,l),s.updateObject(t.uuid,"material.needsUpdate",!0);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);K(c,`material.${i}`,l)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(r,l)=>{n.latest=l,s.updateObject(t.uuid,`material.${i}`,l);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);K(c,`material.${i}`,l)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);K(h,"material.needsUpdate",!0)}}}),n}function On(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Tn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Mn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function ci(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function ot(i,e,t,s,n="",a=!1){const r=Ut(i).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${i}`:i,h=typeof e;if(h==="boolean"||h==="string")return{title:r,prop:l,type:h,value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};if(h==="number"){const c={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(p,m)=>{s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);K(y,`material.${l}`,m)}}};return us(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,p)=>{const m=new o.Color(p);s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);K(y,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const p in e){const m=e[p],f=`[${p.toString()}]`;if(m.value!==void 0){const y=ot(`${f}.value`,m.value,t,s,l,a);y!==void 0&&c.push(y)}else{const y=ot(f,m,t,s,l,a);y!==void 0&&c.push(y)}}if(c.length>0)return ci(c),{title:r,items:c}}else{if(On(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};if(Tn(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};if(Mn(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(c,p)=>{const m=gn(i),f=n.length>0?`${n}.${m}`:m;s.createTexture(t.uuid,`material.${f}`,p);const y=s.getScene(t.uuid);if(y!==null){const x=y.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const T=M=>{const _=x.material,v=f.split(".");switch(v.length){case 1:_[v[0]]=M;break;case 2:_[v[0]][v[1]]=M;break;case 3:_[v[0]][v[1]][v[2]]=M;break;case 4:_[v[0]][v[1]][v[2]][v[3]]=M;break;case 5:_[v[0]][v[1]][v[2]][v[3]][v[4]]=M;break}_.needsUpdate=!0};p.src.length>0?os(p.src).then(M=>{M.offset.set(p.offset[0],p.offset[1]),M.repeat.set(p.repeat[0],p.repeat[1]),T(M)}):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,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);K(f,`material.${l}`,p)}}};{const c=[],p=i==="defines"||i==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const y=ot(`${m}.value`,f.value,t,s,l,p);y!==void 0&&c.push(y)}else{const y=ot(m,f,t,s,l,p);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return ci(c),{title:r,items:c}}}}}function Ii(i,e,t){const s=[];for(const n in i){if(!fn(n))continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Sn(n,r,e,t));else if(a==="number")s.push(wn(n,r,e,t));else if(a==="string")s.push(xn(n,r,e,t));else if(a==="object"){const l=ot(n,r,e,t);l!==void 0&&s.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return ci(s),s.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);K(a,"material.needsUpdate",!0)}}}),s}function Pn(i,e){function t(){return`${e.app.appID}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=i.material;if(Array.isArray(r)){const l=[],h=r.length;for(let c=0;c<h;c++)l.push(u.jsx(fe,{title:`Material ${c}`,items:Ii(r[c],i,e)},`Material ${c}`));return u.jsx(u.Fragment,{children:l})}else return u.jsx(fe,{title:"Material",items:Ii(r,i,e),expanded:n,onToggle:l=>{a(l)}})}const Li="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 An(i){const e=i.step!==void 0?i.step:.01,t=w.useRef(null),s=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l]=w.useState(i.value),[h,c]=w.useState(i.value.offset[0]),[p,m]=w.useState(i.value.offset[1]),[f,y]=w.useState(i.value.repeat[0]),[x,T]=w.useState(i.value.repeat[1]);function M(v,C,E,A,O){if(i.onChange!==void 0){const j=i.prop!==void 0?i.prop:i.title;i.onChange(j,{src:v,offset:[C,E],repeat:[A,O]})}}function _(v){const C=t.current.src,E=v.target.value;switch(v.target){case s.current:c(E),M(C,E,p,f,x);break;case n.current:m(E),M(C,h,E,f,x);break;case a.current:y(E),M(C,h,p,E,x);break;case r.current:T(E),M(C,h,p,f,E);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:i.title,ref:t,onClick:()=>{_n().then(v=>{t.current.src=v,M(v,h,p,f,x)})},src:l.src.length>0?l.src:Li}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:s,type:"number",value:h,step:e,onChange:_}),u.jsx("input",{ref:n,type:"number",value:p,step:e,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:f,step:e,onChange:_}),u.jsx("input",{ref:r,type:"number",value:x,step:e,onChange:_})]}),u.jsx("button",{onClick:()=>{M("",h,p,f,x),t.current.src=Li},children:"Clear"})]})]})}function Pt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=ni(i.value):i.type==="color"&&(e=ni(new o.Color(i.value))));const[t,s]=w.useState(e),n=w.useRef(null),a=c=>{let p=c.target.value;if(i.type==="boolean")p=c.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?p=Number(p):typeof i.value=="boolean"?p=!!p:typeof i.value=="object"&&(p=JSON.parse(p)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==p;f++);}s(p),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,p)},r={};i.disabled&&(r.opacity=.8);const l=i.type==="string"&&(t.length>100||t.search(`
30
- `)>-1),h=l||i.type==="image"||i.type==="vector2";return u.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[i.type!=="button"&&u.jsx("label",{ref:n,children:dt(i.title)},"fieldLabel"),i.type==="string"&&!l&&u.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t}),i.type==="string"&&l&&u.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:t}),i.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t}),i.type==="number"&&u.jsx(je,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="range"&&u.jsx(je,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color"}),u.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled})]}),i.type==="button"&&u.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&u.jsx(An,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,children:i.options?.map((c,p)=>u.jsx("option",{value:c.value,children:dt(c.title)},p))})}),i.type==="vector2"&&u.jsx(hn,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&u.jsx(Di,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&u.jsx(mn,{step:i.step,value:t,onChange:a}),i.type==="euler"&&u.jsx(Di,{step:i.step,value:t,onChange:a})]})}function Rn(i){return"items"in i}class fe extends w.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const s=w.createRef(),n=u.jsx(fe,{ref:s,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,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(Rn(t))e.push(u.jsx(fe,{title:dt(t.title),items:t.items},Math.random()));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(u.jsx(Pt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),u.jsx(ut,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class q extends w.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},q.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 u.jsx("div",{className:"customGroups",children:q.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(n=>{s.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)}})}),q.groups.push(u.jsx(fe,{title:t.title,items:s},Math.random())),q.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=q.groupTitles.length;for(let n=0;n<s;n++)if(t===q.groupTitles[n]){q.groups.splice(n,1),q.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 s=w.createRef(),n=u.jsx(fe,{ref:s,title:e.title,items:t},Math.random());return q.groups.push(n),q.groupsRefs.push(s),q.groupTitles.push(e.title),s}static removeEditorGroup(e){const t=q.groupTitles.length;console.log("removeEditorGroup:",e,q.groupTitles);for(let s=0;s<t;s++)if(e===q.groupTitles[s]){console.log("remove group:",e),q.groups.splice(s,1),q.groupTitles.splice(s,1),q.instance.setState({lastUpdate:Date.now()});return}}}function Ui(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function Dn(i,e){function t(){return`${e.app.appID}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const l in i.perspectiveCameraInfo)r.push({title:Ui(l),prop:l,type:"number",step:.01,value:i.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);m!==void 0&&(K(m,h,c),m.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const l in i.orthographicCameraInfo)r.push({title:Ui(l),prop:l,type:"number",step:.01,value:i.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);m!==void 0&&(K(m,h,c),m.updateProjectionMatrix())}}});return u.jsx(fe,{title:"Camera",items:r,expanded:n,onToggle:l=>{a(l)}})}class In extends o.Line{constructor(e,t){const s=[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(s,3)),n.computeBoundingSphere();const a=new o.LineBasicMaterial({fog:!1});super(n,a),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(r,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const ki={type:"change"},fi={type:"start"},ps={type:"end"},bt=new o.Ray,ji=new o.Plane,Ln=Math.cos(70*o.MathUtils.DEG2RAD),ee=new o.Vector3,oe=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Zt=1e-6;class Un extends o.Controls{constructor(e,t=null){super(e,t),this.state=H.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=jn.bind(this),this._onPointerDown=kn.bind(this),this._onPointerUp=Fn.bind(this),this._onContextMenu=Gn.bind(this),this._onMouseWheel=Hn.bind(this),this._onKeyDown=Vn.bind(this),this._onTouchStart=Bn.bind(this),this._onTouchMove=Yn.bind(this),this._onMouseDown=Nn.bind(this),this._onMouseMove=zn.bind(this),this._interceptControlDown=Zn.bind(this),this._interceptControlUp=Wn.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ki),this.update(),this.state=H.NONE}update(e=null){const t=this.object.position;ee.copy(t).sub(this.target),ee.applyQuaternion(this._quat),this._spherical.setFromVector3(ee),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=oe:s>Math.PI&&(s-=oe),n<-Math.PI?n+=oe:n>Math.PI&&(n-=oe),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(ee.setFromSpherical(this._spherical),ee.applyQuaternion(this._quatInverse),t.copy(this.target).add(ee),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const l=ee.length();r=this._clampDistance(l*this._scale);const h=l-r;this.object.position.addScaledVector(this._dollyDirection,h),this.object.updateMatrixWorld(),a=!!h}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const h=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=h!==this.object.zoom;const 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=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(bt.origin.copy(this.object.position),bt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(bt.direction))<Ln?this.object.lookAt(this.target):(ji.setFromNormalAndCoplanarPoint(this.object.up,this.target),bt.intersectPlane(ji,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Zt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Zt||this._lastTargetPosition.distanceToSquared(this.target)>Zt?(this.dispatchEvent(ki),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?oe/60*this.autoRotateSpeed*e:oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ee.setFromMatrixColumn(t,0),ee.multiplyScalar(-e),this._panOffset.add(ee)}_panUp(e,t){this.screenSpacePanning===!0?ee.setFromMatrixColumn(t,1):(ee.setFromMatrixColumn(t,0),ee.crossVectors(this.object.up,ee)),ee.multiplyScalar(e),this._panOffset.add(ee)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ee.copy(n).sub(this.target);let a=ee.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/s.clientHeight,this.object.matrix),this._panUp(2*t*a/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.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 s=this.domElement.getBoundingClientRect(),n=e-s.left,a=t-s.top,r=s.width,l=s.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(oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(oe*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(oe*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(-oe*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(oe*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(-oe*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+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 s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),a=.5*(e.pageY+s.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(oe*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,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),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+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,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function kn(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function jn(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Fn(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ps),this.state=H.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Nn(i){let e;switch(i.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(i),this.state=H.DOLLY;break;case o.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}break;case o.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(fi)}function zn(i){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Hn(i){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(i.preventDefault(),this.dispatchEvent(fi),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ps))}function Vn(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function Bn(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=H.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=H.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(fi)}function Yn(i){switch(this._trackPointer(i),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=H.NONE}}function Gn(i){this.enabled!==!1&&i.preventDefault()}function Zn(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Wn(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
29
+ C11,8.22,10.74,8,10.43,8z`})});function ls(i){return u.jsx(is.Reorder.Item,{value:i.title,children:u.jsxs("div",{children:[on,u.jsx("span",{children:i.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{i.onDelete(i.index)},children:an})]})},i.title)}function cs(i){const[e,t]=w.useState(!1),[s,n]=w.useState(i.options),a=c=>{i.onDragComplete(c),n(c)},r=c=>{const p=[...s];p.splice(c,1),a(p)},l=[];s.forEach((c,p)=>{l.push(u.jsx(ls,{index:p,title:c,onDelete:r},c))});let h="dropdown draggable";return i.subdropdown&&(h+=" subdropdown"),u.jsxs("div",{className:h,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(pi,{title:i.title}),u.jsx(is.Reorder.Group,{axis:"y",values:s,onReorder:a,style:{visibility:e?"visible":"hidden"},children:l})]})}function hs(i){const[e,t]=w.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(u.jsx(ds,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),u.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(pi,{title:i.title}),u.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function ds(i){const{option:e}=i,[t,s]=w.useState("");let n;switch(e.type){case"draggable":n=u.jsx(cs,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=u.jsx(hs,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=u.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return u.jsx("li",{className:t===e.title?"selected":"",children:n},ns())}function ln(i,e,t){function s(a){switch(e.forEach(r=>{r.callback(i,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(i,r.remote,a)}),a.event){case"custom":R.dispatchEvent({type:P.CUSTOM,value:a.data});break}}i.listen=a=>{a.target==="editor"?n(a):s(a)}}function ut(i){const[e,t]=w.useState(i.open!==void 0?i.open:!0),s=!e||i.children===void 0,n=()=>{R.dispatchEvent({type:P.REMOVE_SCENE,value:i.scene})};return u.jsxs("div",{className:`accordion ${s?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const a=!e;i.onToggle!==void 0&&i.onToggle(a),t(a)},children:[u.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:dt(i.label)})]}),i.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"refresh",onClick:i.onRefresh}),u.jsx("button",{className:"remove",onClick:n})]}):null,i.button,u.jsx("div",{className:e?"open":"",children:u.jsx("div",{children:i.children})},Math.random())]})}function mi(i){const e=w.useRef(null),[t,s]=w.useState(!1),n=i.child!==void 0&&i.child.children.length>0,a=[];return i.child!==void 0&&i.child.children.length>0&&i.child.children.map((r,l)=>{a.push(u.jsx(mi,{child:r,three:i.three},l))}),w.useEffect(()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);l!==void 0&&(e.current.style.opacity=l.visible?"1":"0.25")}}},[t]),u.jsx(u.Fragment,{children:i.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[n?u.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,u.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0&&(i.three.getObject(i.child.uuid),t||s(!0))},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),u.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",i.child.uuid);if(l!==void 0){const h="visible",c=!l.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,h,c),q(l,h,c)}}}}}),u.jsx("div",{className:`icon ${Ks(i.child)}`})]}),u.jsx("div",{className:t?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())})}function oi(i){const e=[];return i.child?.children.map((t,s)=>{e.push(u.jsx(mi,{child:t,scene:i.scene,three:i.three},s))}),u.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function cn(i){const[e,t]=w.useState(i.defaultValue);return w.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue;const l=f=>{s=!0,a=Number(i.input.current?.value),n=f.clientX,document.addEventListener("mouseup",c,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",c,!1)},h=f=>{if(!s)return;const y=i.step!==void 0?i.step:1,x=(f.clientX-n)*y;r=Number((a+x).toFixed(4)),i.min!==void 0&&(r=Math.max(r,i.min)),i.max!==void 0&&(r=Math.min(r,i.max)),i.onChange!==void 0&&i.onChange(r),t(r)},c=()=>{s=!1,document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)},p=f=>{const y=Number(f.target.value);t(y)},m=f=>{const y=Number(f.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.input.current?.addEventListener("input",p),i.label.current?.addEventListener("mousedown",l,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),()=>{i.input.current?.removeEventListener("input",p),i.label.current?.removeEventListener("mousedown",l),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",c)}},[]),e}function je(i){const e=w.useRef(null),t=w.useRef(null),s=cn({label:i.labelRef,input:e,sliderRef:t,defaultValue:i.value,min:i.min,max:i.max,step:i.step,onChange:n=>{i.onChange!==void 0&&i.onChange(i.prop,n)}});return u.jsxs(u.Fragment,{children:[i.type==="number"&&u.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,onChange:n=>{const a=Number(n.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),i.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",onChange:n=>{const a=Number(n.target.value);i.onChange!==void 0&&i.onChange(i.prop,a)}}),u.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,onChange:ui})]})]})}function hn(i){const e=w.useRef(null),t=w.useRef(null),s=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l,h]=w.useState(i.value),[c,p]=w.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[m,f]=w.useState(!1);function y(){m||(window.addEventListener("mousemove",T),window.addEventListener("mouseup",x),window.addEventListener("mouseup",x),f(!0))}function x(){window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",x),f(!1)}function T(E){const A=a.current.getBoundingClientRect(),O=Te(0,99,E.clientX-A.left)/99,j=Te(0,99,E.clientY-A.top)/99,W=pe(Rt(c.min,c.max,O),3),he=pe(Rt(c.min,c.max,j),3);i.onChange({target:{value:{x:W,y:he}}}),h({x:W,y:he})}function M(E){let A=l.x,O=l.y;E.target===e.current?A=Number(E.target.value):O=Number(E.target.value),h({x:A,y:O})}function _(){const E=Number(s.current.value);p({min:E,max:c.max}),(l.x<E||l.y<E)&&h({x:Te(E,c.max,l.x),y:Te(E,c.max,l.y)})}function v(){const E=Number(n.current.value);p({min:c.min,max:E}),(l.x>E||l.y>E)&&h({x:Te(c.min,E,l.x),y:Te(c.min,E,l.y)})}w.useEffect(()=>{const E=si(c.min,c.max,l.x),A=si(c.min,c.max,l.y);r.current.style.left=`${E*100}%`,r.current.style.top=`${A*100}%`},[c,l]);const C=i.step!==void 0?i.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"X:"}),u.jsx("input",{ref:e,type:"number",value:l.x,min:c.min,max:c.max,step:C,onChange:M})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Y:"}),u.jsx("input",{ref:t,type:"number",value:l.y,min:c.min,max:c.max,step:C,onChange:M})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Min:"}),u.jsx("input",{ref:s,type:"number",value:c.min,step:C,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Max:"}),u.jsx("input",{ref:n,type:"number",value:c.max,step:C,onChange:v})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:y,onMouseUp:x,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:r})]})]})}const dn=Math.PI/180,un=180/Math.PI;function Ve(i,e,t,s,n){return s+(i-e)*(n-s)/(t-e)}function Be(i,e,t){return(1-t)*i+t*e}function li(i){return i*dn}function pn(i){return i*un}function Di(i){const e=i.value.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,t=i.value.isEuler!==void 0,s=i.value.elements!==void 0,n=i.step!==void 0?i.step:.01,a=[];if(t){const r=w.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(h=>{const c=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h.substring(1).toUpperCase()}),u.jsx(je,{value:pn(r[h]),type:"number",prop:h,step:.1,labelRef:c,onChange:(p,m)=>{r[p]=li(m),i.onChange({target:{value:r}})}})]},h))})}else if(e){const r=w.useMemo(()=>i.value,[]),l=(c,p)=>{r[c]=p,i.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const p=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:p,children:c.toUpperCase()}),u.jsx(je,{value:r[c],type:"number",prop:c,step:n,labelRef:p,onChange:l})]},c))})}else if(s){const r=w.useMemo(()=>i.value,[]),l=(h,c)=>{const p=Number(h);r.elements[p]=c,i.onChange({target:{value:r}})};for(let h=0;h<9;h++){const c=w.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:h+1}),u.jsx(je,{value:r.elements[h],type:"number",prop:h.toString(),step:n,labelRef:c,onChange:l})]},h.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function mn(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=w.useMemo(()=>i.value,[]),a=(l,h)=>{n[l]=h,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(l=>{const h=w.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:l.toUpperCase()}),u.jsx(je,{value:n.x,type:"number",prop:l,step:t,labelRef:h,onChange:a})]},l))})}else{const n=w.useMemo(()=>i.value,[]),a=(r,l)=>{const h=Number(r);n.elements[h]=l,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const l=w.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("label",{ref:l,children:r+1}),u.jsx(je,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:l,onChange:a})]},r.toString()))}}return u.jsx("div",{className:"grid4",children:s})}function fn(i){return!(i==="defaultAttributeValues"||i==="forceSinglePass"||i==="linecap"||i==="linejoin"||i==="linewidth"||i==="normalMapType"||i==="precision"||i==="shadowSide"||i==="uniformsGroups"||i==="uniformsNeedUpdate"||i==="userData"||i==="version"||i==="wireframeLinecap"||i==="wireframeLinejoin"||i==="wireframeLinewidth"||i.slice(0,4)==="clip"||i.slice(0,7)==="polygon"||i.slice(0,7)==="stencil"||i.slice(0,2)==="is")}function gn(i){switch(i){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return i}function Ut(i){switch(i){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return i}function us(i){const e=i.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function _n(){const i=document.createElement("input");return i.type="file",new Promise((e,t)=>{i.addEventListener("change",function(){if(i.files===null)t();else{const s=i.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(s)}}),i.click()})}const yn=[{title:"Front",value:o.FrontSide},{title:"Back",value:o.BackSide},{title:"Double",value:o.DoubleSide}],vn=[{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}],bn=[{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}],En=[{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}],Cn=[{title:"Zero",value:o.ZeroFactor},{title:"One",value:o.OneFactor},{title:"Src Color",value:o.SrcColorFactor},{title:"One Minus Src Color",value:o.OneMinusSrcColorFactor},{title:"Src Alpha",value:o.SrcAlphaFactor},{title:"One Minus Src Alpha",value:o.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:o.DstAlphaFactor},{title:"One Minus Dst Alpha",value:o.OneMinusDstAlphaFactor},{title:"Dst Color",value:o.DstColorFactor},{title:"One Minus Dst Color",value:o.OneMinusDstColorFactor},{title:"Constant Color",value:o.ConstantColorFactor},{title:"One Minus Constant Color",value:o.OneMinusConstantColorFactor},{title:"Constant Alpha",value:o.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:o.OneMinusConstantAlphaFactor}];function Je(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Sn(i,e,t,s){return{type:"boolean",title:Ut(i),prop:i,value:e,needsUpdate:!0,onChange:(n,a)=>{s.updateObject(t.uuid,`material.${i}`,a),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const l=r.getObjectByProperty("uuid",t.uuid);q(l,`material.${i}`,a)}}}}function wn(i,e,t,s){const n={type:"number",title:Ut(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);q(h,`material.${i}`,r)}}};switch(i){case"blending":Je(n,vn);break;case"blendDst":Je(n,Cn);break;case"blendEquation":Je(n,bn);break;case"blendSrc":Je(n,En);break;case"side":Je(n,yn);break}return us(i)&&(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 xn(i,e,t,s){const n={type:"string",title:Ut(i),prop:i,value:e,needsUpdate:!0,onChange:(r,l)=>{s.updateObject(t.uuid,`material.${i}`,l),s.updateObject(t.uuid,"material.needsUpdate",!0);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);q(c,`material.${i}`,l)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.disabled=!1,n.latest=n.value,n.onChange=(r,l)=>{n.latest=l,s.updateObject(t.uuid,`material.${i}`,l);const h=s.getScene(t.uuid);if(h!==null){const c=h.getObjectByProperty("uuid",t.uuid);q(c,`material.${i}`,l)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",t.uuid);q(h,"material.needsUpdate",!0)}}}),n}function On(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Tn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Mn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function ci(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function ot(i,e,t,s,n="",a=!1){const r=Ut(i).split(".")[0].replaceAll("[","").replaceAll("]",""),l=n.length>0?`${n}.${i}`:i,h=typeof e;if(h==="boolean"||h==="string")return{title:r,prop:l,type:h,value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};if(h==="number"){const c={title:r,prop:l,type:"number",value:e,step:.01,disabled:a,onChange:(p,m)=>{s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,m)}}};return us(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,p)=>{const m=new o.Color(p);s.updateObject(t.uuid,`material.${l}`,m);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);q(y,`material.${l}`,m)}}};if(Array.isArray(e)){const c=[];for(const p in e){const m=e[p],f=`[${p.toString()}]`;if(m.value!==void 0){const y=ot(`${f}.value`,m.value,t,s,l,a);y!==void 0&&c.push(y)}else{const y=ot(f,m,t,s,l,a);y!==void 0&&c.push(y)}}if(c.length>0)return ci(c),{title:r,items:c}}else{if(On(e))return{title:r,prop:l,type:"vector2",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};if(Tn(e))return{title:r,prop:l,type:"grid3",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};if(Mn(e))return{title:r,prop:l,type:"grid4",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};if(e.isEuler)return{title:r,prop:l,type:"euler",value:e,disabled:a,onChange:(c,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(c,p)=>{const m=gn(i),f=n.length>0?`${n}.${m}`:m;s.createTexture(t.uuid,`material.${f}`,p);const y=s.getScene(t.uuid);if(y!==null){const x=y.getObjectByProperty("uuid",t.uuid);if(x!==void 0){const T=M=>{const _=x.material,v=f.split(".");switch(v.length){case 1:_[v[0]]=M;break;case 2:_[v[0]][v[1]]=M;break;case 3:_[v[0]][v[1]][v[2]]=M;break;case 4:_[v[0]][v[1]][v[2]][v[3]]=M;break;case 5:_[v[0]][v[1]][v[2]][v[3]][v[4]]=M;break}_.needsUpdate=!0};p.src.length>0?os(p.src).then(M=>{M.offset.set(p.offset[0],p.offset[1]),M.repeat.set(p.repeat[0],p.repeat[1]),T(M)}):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,p)=>{s.updateObject(t.uuid,`material.${l}`,p);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);q(f,`material.${l}`,p)}}};{const c=[],p=i==="defines"||i==="extensions";try{for(const m in e){const f=e[m];if(f!==void 0)if(f.value!==void 0){const y=ot(`${m}.value`,f.value,t,s,l,p);y!==void 0&&c.push(y)}else{const y=ot(m,f,t,s,l,p);y!==void 0&&c.push(y)}}}catch{console.log("Issue cycling through material object:",i,e)}if(c.length>0)return ci(c),{title:r,items:c}}}}}function Ii(i,e,t){const s=[];for(const n in i){if(!fn(n))continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Sn(n,r,e,t));else if(a==="number")s.push(wn(n,r,e,t));else if(a==="string")s.push(xn(n,r,e,t));else if(a==="object"){const l=ot(n,r,e,t);l!==void 0&&s.push(l)}else r!==void 0&&console.log("other:",n,a,r)}return ci(s),s.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const a=n.getObjectByProperty("uuid",e.uuid);q(a,"material.needsUpdate",!0)}}}),s}function Pn(i,e){function t(){return`${e.app.appID}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=i.material;if(Array.isArray(r)){const l=[],h=r.length;for(let c=0;c<h;c++)l.push(u.jsx(fe,{title:`Material ${c}`,items:Ii(r[c],i,e)},`Material ${c}`));return u.jsx(u.Fragment,{children:l})}else return u.jsx(fe,{title:"Material",items:Ii(r,i,e),expanded:n,onToggle:l=>{a(l)}})}const Li="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 An(i){const e=i.step!==void 0?i.step:.01,t=w.useRef(null),s=w.useRef(null),n=w.useRef(null),a=w.useRef(null),r=w.useRef(null),[l]=w.useState(i.value),[h,c]=w.useState(i.value.offset[0]),[p,m]=w.useState(i.value.offset[1]),[f,y]=w.useState(i.value.repeat[0]),[x,T]=w.useState(i.value.repeat[1]);function M(v,C,E,A,O){if(i.onChange!==void 0){const j=i.prop!==void 0?i.prop:i.title;i.onChange(j,{src:v,offset:[C,E],repeat:[A,O]})}}function _(v){const C=t.current.src,E=v.target.value;switch(v.target){case s.current:c(E),M(C,E,p,f,x);break;case n.current:m(E),M(C,h,E,f,x);break;case a.current:y(E),M(C,h,p,E,x);break;case r.current:T(E),M(C,h,p,f,E);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:i.title,ref:t,onClick:()=>{_n().then(v=>{t.current.src=v,M(v,h,p,f,x)})},src:l.src.length>0?l.src:Li}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("label",{children:"Offset:"}),u.jsx("input",{ref:s,type:"number",value:h,step:e,onChange:_}),u.jsx("input",{ref:n,type:"number",value:p,step:e,onChange:_})]}),u.jsxs("div",{children:[u.jsx("label",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:f,step:e,onChange:_}),u.jsx("input",{ref:r,type:"number",value:x,step:e,onChange:_})]}),u.jsx("button",{onClick:()=>{M("",h,p,f,x),t.current.src=Li},children:"Clear"})]})]})}function Pt(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=ni(i.value):i.type==="color"&&(e=ni(new o.Color(i.value))));const[t,s]=w.useState(e),n=w.useRef(null),a=c=>{let p=c.target.value;if(i.type==="boolean")p=c.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?p=Number(p):typeof i.value=="boolean"?p=!!p:typeof i.value=="object"&&(p=JSON.parse(p)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==p;f++);}s(p),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,p)},r={};i.disabled&&(r.opacity=.8);const l=i.type==="string"&&(t.length>100||t.search(`
30
+ `)>-1),h=l||i.type==="image"||i.type==="vector2";return u.jsxs("div",{className:`field ${h?"block":""}`,style:r,children:[i.type!=="button"&&u.jsx("label",{ref:n,children:dt(i.title)},"fieldLabel"),i.type==="string"&&!l&&u.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t}),i.type==="string"&&l&&u.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:c=>{i.onKeyDown!==void 0&&i.onKeyDown(c)},value:t}),i.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t}),i.type==="number"&&u.jsx(je,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="range"&&u.jsx(je,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color"}),u.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled})]}),i.type==="button"&&u.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&u.jsx(An,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,children:i.options?.map((c,p)=>u.jsx("option",{value:c.value,children:dt(c.title)},p))})}),i.type==="vector2"&&u.jsx(hn,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&u.jsx(Di,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&u.jsx(mn,{step:i.step,value:t,onChange:a}),i.type==="euler"&&u.jsx(Di,{step:i.step,value:t,onChange:a})]})}function Rn(i){return"items"in i}class fe extends w.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;constructor(e){super(e),this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const s=w.createRef(),n=u.jsx(fe,{ref:s,title:e.title,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,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(Rn(t))e.push(u.jsx(fe,{title:dt(t.title),items:t.items},Math.random()));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(u.jsx(Pt,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),u.jsx(ut,{label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class $ extends w.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];constructor(e){super(e),this.state={lastUpdate:Date.now()},$.instance=this,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 u.jsx("div",{className:"customGroups",children:$.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(n=>{s.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),$.groups.push(u.jsx(fe,{title:t.title,items:s},Math.random())),$.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=$.groupTitles.length;for(let n=0;n<s;n++)if(t===$.groupTitles[n]){$.groups.splice(n,1),$.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,l)=>{e.onUpdate(r,l)}})});const s=w.createRef(),n=u.jsx(fe,{ref:s,title:e.title,items:t},Math.random());return $.groups.push(n),$.groupsRefs.push(s),$.groupTitles.push(e.title),s}static removeEditorGroup(e){const t=$.groupTitles.length;for(let s=0;s<t;s++)if(e===$.groupTitles[s]){$.groups.splice(s,1),$.groupTitles.splice(s,1),$.instance.setState({lastUpdate:Date.now()});return}}}function Ui(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function Dn(i,e){function t(){return`${e.app.appID}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const l in i.perspectiveCameraInfo)r.push({title:Ui(l),prop:l,type:"number",step:.01,value:i.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);m!==void 0&&(q(m,h,c),m.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const l in i.orthographicCameraInfo)r.push({title:Ui(l),prop:l,type:"number",step:.01,value:i.perspectiveCameraInfo[l],onChange:(h,c)=>{e.updateObject(i.uuid,h,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);m!==void 0&&(q(m,h,c),m.updateProjectionMatrix())}}});return u.jsx(fe,{title:"Camera",items:r,expanded:n,onToggle:l=>{a(l)}})}class In extends o.Line{constructor(e,t){const s=[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(s,3)),n.computeBoundingSphere();const a=new o.LineBasicMaterial({fog:!1});super(n,a),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new o.BufferGeometry;l.setAttribute("position",new o.Float32BufferAttribute(r,3)),l.computeBoundingSphere(),this.add(new o.Mesh(l,new o.MeshBasicMaterial({side:o.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const ki={type:"change"},fi={type:"start"},ps={type:"end"},bt=new o.Ray,ji=new o.Plane,Ln=Math.cos(70*o.MathUtils.DEG2RAD),ee=new o.Vector3,oe=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Zt=1e-6;class Un extends o.Controls{constructor(e,t=null){super(e,t),this.state=H.NONE,this.enabled=!0,this.target=new o.Vector3,this.cursor=new o.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:o.MOUSE.ROTATE,MIDDLE:o.MOUSE.DOLLY,RIGHT:o.MOUSE.PAN},this.touches={ONE:o.TOUCH.ROTATE,TWO:o.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new o.Vector3,this._lastQuaternion=new o.Quaternion,this._lastTargetPosition=new o.Vector3,this._quat=new o.Quaternion().setFromUnitVectors(e.up,new o.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new o.Spherical,this._sphericalDelta=new o.Spherical,this._scale=1,this._panOffset=new o.Vector3,this._rotateStart=new o.Vector2,this._rotateEnd=new o.Vector2,this._rotateDelta=new o.Vector2,this._panStart=new o.Vector2,this._panEnd=new o.Vector2,this._panDelta=new o.Vector2,this._dollyStart=new o.Vector2,this._dollyEnd=new o.Vector2,this._dollyDelta=new o.Vector2,this._dollyDirection=new o.Vector3,this._mouse=new o.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=jn.bind(this),this._onPointerDown=kn.bind(this),this._onPointerUp=Fn.bind(this),this._onContextMenu=Gn.bind(this),this._onMouseWheel=Hn.bind(this),this._onKeyDown=Vn.bind(this),this._onTouchStart=Bn.bind(this),this._onTouchMove=Yn.bind(this),this._onMouseDown=Nn.bind(this),this._onMouseMove=zn.bind(this),this._interceptControlDown=Zn.bind(this),this._interceptControlUp=Wn.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ki),this.update(),this.state=H.NONE}update(e=null){const t=this.object.position;ee.copy(t).sub(this.target),ee.applyQuaternion(this._quat),this._spherical.setFromVector3(ee),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=oe:s>Math.PI&&(s-=oe),n<-Math.PI?n+=oe:n>Math.PI&&(n-=oe),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(ee.setFromSpherical(this._spherical),ee.applyQuaternion(this._quatInverse),t.copy(this.target).add(ee),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const l=ee.length();r=this._clampDistance(l*this._scale);const h=l-r;this.object.position.addScaledVector(this._dollyDirection,h),this.object.updateMatrixWorld(),a=!!h}else if(this.object.isOrthographicCamera){const l=new o.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const h=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=h!==this.object.zoom;const 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=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(bt.origin.copy(this.object.position),bt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(bt.direction))<Ln?this.object.lookAt(this.target):(ji.setFromNormalAndCoplanarPoint(this.object.up,this.target),bt.intersectPlane(ji,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Zt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Zt||this._lastTargetPosition.distanceToSquared(this.target)>Zt?(this.dispatchEvent(ki),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?oe/60*this.autoRotateSpeed*e:oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ee.setFromMatrixColumn(t,0),ee.multiplyScalar(-e),this._panOffset.add(ee)}_panUp(e,t){this.screenSpacePanning===!0?ee.setFromMatrixColumn(t,1):(ee.setFromMatrixColumn(t,0),ee.crossVectors(this.object.up,ee)),ee.multiplyScalar(e),this._panOffset.add(ee)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;ee.copy(n).sub(this.target);let a=ee.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/s.clientHeight,this.object.matrix),this._panUp(2*t*a/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.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 s=this.domElement.getBoundingClientRect(),n=e-s.left,a=t-s.top,r=s.width,l=s.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(oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(oe*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(oe*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(-oe*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(oe*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(-oe*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+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 s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),a=.5*(e.pageY+s.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(oe*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,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),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+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,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function kn(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function jn(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Fn(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ps),this.state=H.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Nn(i){let e;switch(i.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(i),this.state=H.DOLLY;break;case o.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}break;case o.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(fi)}function zn(i){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Hn(i){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(i.preventDefault(),this.dispatchEvent(fi),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ps))}function Vn(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function Bn(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case o.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=H.TOUCH_ROTATE;break;case o.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case o.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=H.TOUCH_DOLLY_PAN;break;case o.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(fi)}function Yn(i){switch(this._trackPointer(i),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=H.NONE}}function Gn(i){this.enabled!==!1&&i.preventDefault()}function Zn(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Wn(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*!
31
31
  * camera-controls
32
32
  * https://github.com/yomotsu/camera-controls
33
33
  * (c) 2017 @yomotsu
@@ -146,4 +146,4 @@ void main() {
146
146
  void main() {
147
147
  #include <clipping_planes_fragment>
148
148
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
149
- }`;class tr extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Jn,fragmentShader:er})}}const Ue=new o.Raycaster,se=new o.Vector3,xe=new o.Vector3,G=new o.Quaternion,Wi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ei={type:"change"},Xi={type:"mouseDown",mode:null},Qi={type:"mouseUp",mode:null},qi={type:"objectChange"};class ir extends o.Controls{constructor(e,t=null){super(void 0,t);const s=new lr(this);this._root=s;const n=new cr;this._gizmo=n,s.add(n);const a=new hr;this._plane=a,s.add(a);const r=this;function l(C,E){let A=E;Object.defineProperty(r,C,{get:function(){return A!==void 0?A:E},set:function(O){A!==O&&(A=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(ei))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,c=new o.Vector3,p=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,T=new o.Vector3,M=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",p),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",T),l("rotationAxis",M),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=sr.bind(this),this._onPointerDown=rr.bind(this),this._onPointerHover=nr.bind(this),this._onPointerMove=ar.bind(this),this._onPointerUp=or.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&&Ue.setFromCamera(e,this.camera);const t=ti(this._gizmo.picker[this.mode],Ue);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&&Ue.setFromCamera(e,this.camera);const t=ti(this._plane,Ue,!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,Xi.mode=this.mode,this.dispatchEvent(Xi)}}pointerMove(e){const t=this.axis,s=this.mode,n=this.object;let a=this.space;if(s==="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&&Ue.setFromCamera(e,this.camera);const r=ti(this._plane,Ue,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(se.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(se.setFromMatrixPosition(n.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),xe.set(l,l,l)}else se.copy(this.pointStart),xe.copy(this.pointEnd),se.applyQuaternion(this._worldQuaternionInv),xe.applyQuaternion(this._worldQuaternionInv),xe.divide(se),t.search("X")===-1&&(xe.x=1),t.search("Y")===-1&&(xe.y=1),t.search("Z")===-1&&(xe.z=1);n.scale.copy(this._scaleStart).multiply(xe),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(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(se.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(se.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Wi[t]),se.copy(Wi[t]),a==="local"&&se.applyQuaternion(this.worldQuaternion),se.cross(this.eye),se.length()===0?h=!0:this.rotationAngle=this._offset.dot(se.normalize())*l),(t==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ei),this.dispatchEvent(qi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Qi.mode=this.mode,this.dispatchEvent(Qi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ei),this.dispatchEvent(qi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ue}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 sr(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function nr(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function rr(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function ar(i){this.enabled&&this.pointerMove(this._getPointer(i))}function or(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function ti(i,e,t){const s=e.intersectObject(i,!0);for(let n=0;n<s.length;n++)if(s[n].object.visible||t)return s[n];return!1}const xt=new o.Euler,B=new o.Vector3(0,1,0),Ki=new o.Vector3(0,0,0),$i=new o.Matrix4,Ot=new o.Quaternion,At=new o.Quaternion,ye=new o.Vector3,Ji=new o.Matrix4,lt=new o.Vector3(1,0,0),ke=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class lr 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 cr 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}),s=e.clone();s.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 p=e.clone();p.color.setHex(255),p.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 x=e.clone();x.color.setHex(7895160);const T=new o.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const M=new o.BoxGeometry(.08,.08,.08);M.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Me){const ae=new o.TorusGeometry(X,.0075,3,64,Me*Math.PI*2);return ae.rotateY(Math.PI/2),ae.rotateX(Math.PI/2),ae}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const A={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(v,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(v,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(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),s)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),f),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},we={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),s)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),s)]]},Qe={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(M,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},Fe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Me=new o.Object3D;for(const ae in X)for(let Ee=X[ae].length;Ee--;){const te=X[ae][Ee][0].clone(),Pe=X[ae][Ee][1],Ae=X[ae][Ee][2],Re=X[ae][Ee][3],pt=X[ae][Ee][4];te.name=ae,te.tag=pt,Pe&&te.position.set(Pe[0],Pe[1],Pe[2]),Ae&&te.rotation.set(Ae[0],Ae[1],Ae[2]),Re&&te.scale.set(Re[0],Re[1],Re[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Me.add(te)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(A)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(we)),this.add(this.picker.scale=J(Fe)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:At;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),B.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix($i.lookAt(Ki,B,ke)),r.quaternion.multiply(G),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),se.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),se.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(se),r.visible=this.dragging):(r.quaternion.copy(s),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(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(s),B.copy(this.eye).applyQuaternion(G.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix($i.lookAt(this.eye,Ki,ke)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-B.y,B.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(ke,Math.atan2(B.x,B.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(B.y,B.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class hr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:At),rt.copy(ke).applyQuaternion(t==="local"?this.worldQuaternion:At),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:At),B.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":B.copy(this.eye).cross(Tt),ye.copy(Tt).cross(B);break;case"Y":B.copy(this.eye).cross(rt),ye.copy(rt).cross(B);break;case"Z":B.copy(this.eye).cross(at),ye.copy(at).cross(B);break;case"XY":ye.copy(at);break;case"YZ":ye.copy(Tt);break;case"XZ":B.copy(at),ye.copy(rt);break;case"XYZ":case"E":ye.set(0,0,0);break}break;case"rotate":default:ye.set(0,0,0)}ye.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ji.lookAt(se.set(0,0,0),ye,B),this.quaternion.setFromRotationMatrix(Ji)),super.updateMatrixWorld(e)}}class ne 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();Se(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new ir(this.activeCamera,s),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:ne.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:ne.DRAG_END})}),t.addEventListener("dragging-changed",n=>{be.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(),Se(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(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}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 ne._instance||(ne._instance=new ne),ne._instance}}const dr=new o.BoxGeometry,ii=new o.Vector2;class hi 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 s=new o.Color(Be(.5,1,Math.random()),Be(.5,1,Math.random()),Be(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:s}),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=s,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:s})),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),ne.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([pe(t.position.x,3),pe(t.position.y,3),pe(t.position.z,3)])}),ss({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 s=0;s<t;s++)this.addPoint(e[s],!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 s=this.draggable.children.length,n=new o.Mesh(dr,this.draggedMat);return n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const s=this.addPoint(t);this._transform?.attach(s),this.group.current?.setField("Current Point",s.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)}Se(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!be.instance||this._transform&&!this._transform.getHelper().visible)return;const s=be.instance.currentWindow.current.getBoundingClientRect();ii.x=(e.clientX-s.x)/s.width*2-1,ii.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ii,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=ne.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),be.instance?.scene.add(this._transform.getHelper());const s=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:s}],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":Se(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Mt=0;class fs 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=q.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),q.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Mt+1}`,s=new hi(t,this._camera);return s.addPoints(e),this.addSpline(s),Mt++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new o.Vector3(s[0],s[1],s[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),s=`Spline ${Mt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new hi(s,this.camera);a.addPoints(n),this.addSpline(a),Mt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const es=["Single","Side by Side","Stacked","Quad"],ur="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",pr="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 be extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new $n;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new tr;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";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=w.createRef(),this.containerRef=w.createRef(),this.tlWindow=w.createRef(),this.trWindow=w.createRef(),this.blWindow=w.createRef(),this.brWindow=w.createRef();const t=e.three.app.appID,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ve.install({THREE:a}),this.setupScene(),this.setupTools();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(),be.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),ne.instance.three=this.props.three,ne.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Le,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Le,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(It,{title:"View",index:es.indexOf(this.state.mode),options:es,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})}}),u.jsx(It,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),u.jsx(Zi,{name:"cameraHelper",icon:ur,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t})}}),u.jsx(Zi,{name:"lightHelper",icon:pr,selected:this.lightVisibility,height:24,top:4,onClick:t=>{this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t})}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.axisHelper.name="axisHelper",this.helpersContainer.add(this.axisHelper),this.interactionHelper.name="interactionHelper",this.helpersContainer.add(this.interactionHelper),this.interactionHelper.visible=!1;const e=(n,a)=>{const r=new o.OrthographicCamera(-100,100,100,-100,50,5e3);return r.name=n,r.position.copy(a),r.lookAt(0,0,0),this.cameras.set(n,r),r};e("Top",new o.Vector3(0,1e3,0)),e("Bottom",new o.Vector3(0,-1e3,0)),e("Left",new o.Vector3(-1e3,0,0)),e("Right",new o.Vector3(1e3,0,0)),e("Front",new o.Vector3(0,0,1e3)),e("Back",new o.Vector3(0,0,-1e3)),e("Orthographic",new o.Vector3(1e3,1e3,1e3)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const t=localStorage,s=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${s}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${s}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${s}_blCam`)),this.brCam=this.cameras.get(t.getItem(`${s}_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 fs(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 s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=s/-2,r.right=s/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),Se(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.currentScene=s,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,s=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(s!==void 0&&this.cameras.set(t.name,s),s instanceof o.PerspectiveCamera){const n=new o.CameraHelper(s);n.visible=this.cameraVisibility,this.cameraHelpers.set(s.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 s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Ve(s,0,t.x,-1,1),this.pointer.y=Ve(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{s<a?this.pointer.x=Ve(s,0,a,-1,1):this.pointer.x=Ve(s,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Ve(n,0,r,1,-1):this.pointer.y=Ve(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(s,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 s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(li(45),li(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),ne.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=ne.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform))};onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),kt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,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 In(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 s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new Un(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 s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.scene.remove(s),s.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,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?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),ne.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.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,s),e.object.position.lerp(e.position0,s),e.object.zoom=Rt(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};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),s=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,s,this.height),this.renderer?.setScissor(0,0,s,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(s,0,s,this.height),this.renderer?.setScissor(s,0,s,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),s=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=s,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 kt extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),kt.instance=this}update(){if(be.instance){const e=be.instance.selectedItem;if(e===void 0)return;this.position.x=pe(e.position.x,3),this.position.y=pe(e.position.y,3),this.position.z=pe(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=pe(e.scale.x,3),this.scale.y=pe(e.scale.y,3),this.scale.z=pe(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(fe,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);K(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function ts(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function mr(i,e){function t(){return`${e.app.appID}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const l in i.lightInfo){const h=i.lightInfo[l];h!==void 0&&(h.isColor!==void 0?r.push({title:ts(l),prop:l,type:"color",value:h,onChange:(c,p)=>{const m=new o.Color(p);e.updateObject(i.uuid,c,m);const f=e.getScene(i.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",i.uuid);K(y,c,m)}}}):r.push({title:ts(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,p)=>{e.updateObject(i.uuid,c,p);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);K(f,c,p)}}}))}return u.jsx(fe,{title:"Light",items:r,expanded:n,onToggle:l=>{a(l)}})}function fr(i,e){function t(){return`${e.app.appID}_animation`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(p){localStorage.setItem(t(),p?"open":"closed")}const r=[],l=[];let h=0;i.animations.forEach(p=>{h=Math.max(h,p.duration),p.duration>0&&l.push({title:p.name,items:[{title:"Duration",type:"number",value:p.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),r.push({title:"Animations",items:l});const c=e.getScene(i.uuid);if(c!==null){const p=c.getObjectByProperty("uuid",i.uuid);let m=!1;if(p!==void 0){const f=p.mixer;if(m=f!==void 0,m){const y=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(x,T)=>{f.timeScale=T,e.updateObject(i.uuid,"mixer.timeScale",T)}}];y.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),e.requestMethod(i.uuid,"stopAllAction",void 0,"mixer")}}),r.push({title:"Mixer",items:y})}}}return u.jsx(fe,{title:"Animation",items:r,expanded:n,onToggle:p=>{a(p)}})}const di={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 ie={...di};function gs(i){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(h){ie={...h.value},t(Date.now())}function l(){ie={...di},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 s=ie.type.toLowerCase(),n=ie.animations.length>0||ie.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return u.jsx(ut,{label:"Inspector",button:ie.uuid.length>0?u.jsx("button",{className:"remove",onClick:()=>{ne.instance.remove(ie.name),ie={...di},t(Date.now())}}):void 0,children:u.jsx("div",{id:"Inspector",className:i.class,children:ie.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Pt,{type:"string",title:"Name",prop:"name",value:ie.name,disabled:!0}),u.jsx(Pt,{type:"string",title:"Type",prop:"type",value:ie.type,disabled:!0}),u.jsx(Pt,{type:"string",title:"UUID",prop:"uuid",value:ie.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(kt,{object:ie,three:i.three}),n?fr(ie,i.three):null,s.search("camera")>-1?Dn(ie,i.three):null,s.search("light")>-1?mr(ie,i.three):null,a?Pn(ie,i.three):null]})]})},e)},"Inspector")}function _s(i){const[e]=w.useState([]),[t]=w.useState([]),[s,n]=w.useState(0),a=h=>{const c=h.value;e.push(c),t.push(u.jsx(ut,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(oi,{child:c,scene:c,three:i.three})},Math.random())),n(Date.now())},r=h=>{const c=h.value;for(let p=0;p<e.length;p++)if(c.uuid===e[p].uuid){e[p]=c,t[p]=u.jsx(ut,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(oi,{child:c,scene:c,three:i.three})},Math.random()),n(Date.now());return}},l=h=>{const c=h.value;for(let p=0;p<e.length;p++)if(c.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.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)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},s),u.jsx(gs,{three:i.three}),u.jsx(q,{three:i.three})]})}function gr(i){return w.useEffect(()=>{function e(l){let h=null;return i.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,p=e(h)?.getObjectByProperty("uuid",h);p!==void 0&&i.three.setObject(p)},s=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&K(m,h,c)},n=l=>{const h=l.value,{key:c,value:p,uuid:m}=h;s(m,c,p)},a=l=>{const h=l.value,p=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(p!==void 0){const m=f=>{const y=h.key.split(".");switch(y.length){case 1:p[y[0]]=f;break;case 2:p[y[0]][y[1]]=f;break;case 3:p[y[0]][y[1]][y[2]]=f;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=f;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=f;break}p.material.needsUpdate=!0};h.value.src.length>0?os(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:p,subitem:m}=l.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{m!==void 0?en(y,m)[h](p):y[h](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(p)}};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 ys(i){return u.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[u.jsx("div",{className:"header",children:i.header}),i.children,u.jsx("div",{className:"footer",children:i.footer})]})}function _r(i){return u.jsx(ys,{children:u.jsxs(u.Fragment,{children:[u.jsx(be,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),u.jsx(_s,{three:i.three})]})})}exports.Accordion=ut;exports.Application=Zs;exports.BaseRemote=Lt;exports.ChildObject=mi;exports.ContainerObject=oi;exports.Draggable=cs;exports.DraggableItem=ls;exports.Dropdown=hs;exports.DropdownItem=ds;exports.Editor=ys;exports.ExportTexture=ht;exports.Inspector=gs;exports.MultiView=be;exports.NavButton=pi;exports.RemoteComponents=Ws;exports.RemoteController=ln;exports.RemoteTheatre=qs;exports.RemoteThree=sn;exports.SceneInspector=gr;exports.SidePanel=_s;exports.Spline=hi;exports.SplineEditor=fs;exports.ThreeEditor=_r;exports.ToolEvents=P;exports.Transform=ne;exports.capitalize=dt;exports.clamp=Te;exports.colorToHex=ni;exports.copyToClipboard=ss;exports.customizeTheatreElements=Qs;exports.debugDispatcher=R;exports.defaultTheatreCallback=Bs;exports.dispose=Se;exports.disposeMaterial=as;exports.disposeTexture=Gs;exports.distance=Ys;exports.hierarchyUUID=Dt;exports.isColor=rs;exports.mix=Rt;exports.noop=ui;exports.normalize=si;exports.randomID=ns;exports.resetThreeObjects=ri;exports.round=pe;exports.theatreEditorApp=Xs;
149
+ }`;class tr extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Jn,fragmentShader:er})}}const Ue=new o.Raycaster,se=new o.Vector3,xe=new o.Vector3,G=new o.Quaternion,Wi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ei={type:"change"},Xi={type:"mouseDown",mode:null},Qi={type:"mouseUp",mode:null},qi={type:"objectChange"};class ir extends o.Controls{constructor(e,t=null){super(void 0,t);const s=new lr(this);this._root=s;const n=new cr;this._gizmo=n,s.add(n);const a=new hr;this._plane=a,s.add(a);const r=this;function l(C,E){let A=E;Object.defineProperty(r,C,{get:function(){return A!==void 0?A:E},set:function(O){A!==O&&(A=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(ei))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,c=new o.Vector3,p=new o.Quaternion,m=new o.Quaternion,f=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,T=new o.Vector3,M=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",h),l("worldPositionStart",c),l("worldQuaternion",p),l("worldQuaternionStart",m),l("cameraPosition",f),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",T),l("rotationAxis",M),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=sr.bind(this),this._onPointerDown=rr.bind(this),this._onPointerHover=nr.bind(this),this._onPointerMove=ar.bind(this),this._onPointerUp=or.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&&Ue.setFromCamera(e,this.camera);const t=ti(this._gizmo.picker[this.mode],Ue);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&&Ue.setFromCamera(e,this.camera);const t=ti(this._plane,Ue,!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,Xi.mode=this.mode,this.dispatchEvent(Xi)}}pointerMove(e){const t=this.axis,s=this.mode,n=this.object;let a=this.space;if(s==="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&&Ue.setFromCamera(e,this.camera);const r=ti(this._plane,Ue,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(se.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(se.setFromMatrixPosition(n.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),xe.set(l,l,l)}else se.copy(this.pointStart),xe.copy(this.pointEnd),se.applyQuaternion(this._worldQuaternionInv),xe.applyQuaternion(this._worldQuaternionInv),xe.divide(se),t.search("X")===-1&&(xe.x=1),t.search("Y")===-1&&(xe.y=1),t.search("Z")===-1&&(xe.z=1);n.scale.copy(this._scaleStart).multiply(xe),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(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(se.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(se.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Wi[t]),se.copy(Wi[t]),a==="local"&&se.applyQuaternion(this.worldQuaternion),se.cross(this.eye),se.length()===0?h=!0:this.rotationAngle=this._offset.dot(se.normalize())*l),(t==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ei),this.dispatchEvent(qi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Qi.mode=this.mode,this.dispatchEvent(Qi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ei),this.dispatchEvent(qi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ue}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 sr(i){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:i.button};{const e=this.domElement.getBoundingClientRect();return{x:(i.clientX-e.left)/e.width*2-1,y:-(i.clientY-e.top)/e.height*2+1,button:i.button}}}function nr(i){if(this.enabled)switch(i.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(i));break}}function rr(i){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(i)),this.pointerDown(this._getPointer(i)))}function ar(i){this.enabled&&this.pointerMove(this._getPointer(i))}function or(i){this.enabled&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(i)))}function ti(i,e,t){const s=e.intersectObject(i,!0);for(let n=0;n<s.length;n++)if(s[n].object.visible||t)return s[n];return!1}const xt=new o.Euler,B=new o.Vector3(0,1,0),Ki=new o.Vector3(0,0,0),$i=new o.Matrix4,Ot=new o.Quaternion,At=new o.Quaternion,ye=new o.Vector3,Ji=new o.Matrix4,lt=new o.Vector3(1,0,0),ke=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class lr 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 cr 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}),s=e.clone();s.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 p=e.clone();p.color.setHex(255),p.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 x=e.clone();x.color.setHex(7895160);const T=new o.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const M=new o.BoxGeometry(.08,.08,.08);M.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Me){const ae=new o.TorusGeometry(X,.0075,3,64,Me*Math.PI*2);return ae.rotateY(Math.PI/2),ae.rotateX(Math.PI/2),ae}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const A={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(v,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(v,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(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),s)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),f),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},we={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),s)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),s)]]},Qe={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(M,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},Fe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Me=new o.Object3D;for(const ae in X)for(let Ee=X[ae].length;Ee--;){const te=X[ae][Ee][0].clone(),Pe=X[ae][Ee][1],Ae=X[ae][Ee][2],Re=X[ae][Ee][3],pt=X[ae][Ee][4];te.name=ae,te.tag=pt,Pe&&te.position.set(Pe[0],Pe[1],Pe[2]),Ae&&te.rotation.set(Ae[0],Ae[1],Ae[2]),Re&&te.scale.set(Re[0],Re[1],Re[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Me.add(te)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(A)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(we)),this.add(this.picker.scale=J(Fe)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:At;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(G),Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),B.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix($i.lookAt(Ki,B,ke)),r.quaternion.multiply(G),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),se.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),se.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(se),r.visible=this.dragging):(r.quaternion.copy(s),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(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(B.copy(ct).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(B.copy(lt).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(B.copy(ke).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(s),B.copy(this.eye).applyQuaternion(G.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix($i.lookAt(this.eye,Ki,ke)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-B.y,B.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(ke,Math.atan2(B.x,B.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(B.y,B.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class hr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:At),rt.copy(ke).applyQuaternion(t==="local"?this.worldQuaternion:At),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:At),B.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":B.copy(this.eye).cross(Tt),ye.copy(Tt).cross(B);break;case"Y":B.copy(this.eye).cross(rt),ye.copy(rt).cross(B);break;case"Z":B.copy(this.eye).cross(at),ye.copy(at).cross(B);break;case"XY":ye.copy(at);break;case"YZ":ye.copy(Tt);break;case"XZ":B.copy(at),ye.copy(rt);break;case"XYZ":case"E":ye.set(0,0,0);break}break;case"rotate":default:ye.set(0,0,0)}ye.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ji.lookAt(se.set(0,0,0),ye,B),this.quaternion.setFromRotationMatrix(Ji)),super.updateMatrixWorld(e)}}class ne 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();Se(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new ir(this.activeCamera,s),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:ne.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:ne.DRAG_END})}),t.addEventListener("dragging-changed",n=>{be.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(),Se(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(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}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 ne._instance||(ne._instance=new ne),ne._instance}}const dr=new o.BoxGeometry,ii=new o.Vector2;class hi 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 s=new o.Color(Be(.5,1,Math.random()),Be(.5,1,Math.random()),Be(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:s}),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=s,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:s})),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),ne.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([pe(t.position.x,3),pe(t.position.y,3),pe(t.position.z,3)])}),ss({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 s=0;s<t;s++)this.addPoint(e[s],!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 s=this.draggable.children.length,n=new o.Mesh(dr,this.draggedMat);return n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()),Be(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const s=this.addPoint(t);this._transform?.attach(s),this.group.current?.setField("Current Point",s.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)}Se(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!be.instance||this._transform&&!this._transform.getHelper().visible)return;const s=be.instance.currentWindow.current.getBoundingClientRect();ii.x=(e.clientX-s.x)/s.width*2-1,ii.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ii,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=ne.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),be.instance?.scene.add(this._transform.getHelper());const s=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:s}],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":Se(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Mt=0;class fs 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=$.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),$.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Mt+1}`,s=new hi(t,this._camera);return s.addPoints(e),this.addSpline(s),Mt++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new o.Vector3(s[0],s[1],s[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),s=`Spline ${Mt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new hi(s,this.camera);a.addPoints(n),this.addSpline(a),Mt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const es=["Single","Side by Side","Stacked","Quad"],ur="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",pr="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 be extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new $n;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new tr;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";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=w.createRef(),this.containerRef=w.createRef(),this.tlWindow=w.createRef(),this.trWindow=w.createRef(),this.blWindow=w.createRef(),this.brWindow=w.createRef();const t=e.three.app.appID,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ve.install({THREE:a}),this.setupScene(),this.setupTools();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(),be.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),ne.instance.three=this.props.three,ne.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Le,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Le,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(It,{title:"View",index:es.indexOf(this.state.mode),options:es,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})}}),u.jsx(It,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),u.jsx(Zi,{name:"cameraHelper",icon:ur,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem instanceof o.PerspectiveCamera){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),u.jsx(Zi,{name:"lightHelper",icon:pr,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.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,s=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${s}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${s}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${s}_blCam`)),this.brCam=this.cameras.get(t.getItem(`${s}_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 fs(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 s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=s/-2,r.right=s/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),Se(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.currentScene=s,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,s=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(s!==void 0&&this.cameras.set(t.name,s),s instanceof o.PerspectiveCamera){const n=new o.CameraHelper(s);n.visible=this.cameraVisibility,this.cameraHelpers.set(s.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 s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Ve(s,0,t.x,-1,1),this.pointer.y=Ve(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{s<a?this.pointer.x=Ve(s,0,a,-1,1):this.pointer.x=Ve(s,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Ve(n,0,r,1,-1):this.pointer.y=Ve(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(s,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 s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(li(45),li(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;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),ne.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=ne.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),kt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,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 In(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 s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new Un(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 s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.scene.remove(s),s.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,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?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),ne.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.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,s),e.object.position.lerp(e.position0,s),e.object.zoom=Rt(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};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),s=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,s,this.height),this.renderer?.setScissor(0,0,s,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(s,0,s,this.height),this.renderer?.setScissor(s,0,s,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),s=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=s,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 kt extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),kt.instance=this}update(){if(be.instance){const e=be.instance.selectedItem;if(e===void 0)return;this.position.x=pe(e.position.x,3),this.position.y=pe(e.position.y,3),this.position.z=pe(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=pe(e.scale.x,3),this.scale.y=pe(e.scale.y,3),this.scale.z=pe(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(fe,{title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);q(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function ts(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function mr(i,e){function t(){return`${e.app.appID}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(l){localStorage.setItem(t(),l?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const l in i.lightInfo){const h=i.lightInfo[l];h!==void 0&&(h.isColor!==void 0?r.push({title:ts(l),prop:l,type:"color",value:h,onChange:(c,p)=>{const m=new o.Color(p);e.updateObject(i.uuid,c,m);const f=e.getScene(i.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",i.uuid);q(y,c,m)}}}):r.push({title:ts(l),prop:l,type:typeof h,value:h,step:typeof h=="number"?.01:void 0,onChange:(c,p)=>{e.updateObject(i.uuid,c,p);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);q(f,c,p)}}}))}return u.jsx(fe,{title:"Light",items:r,expanded:n,onToggle:l=>{a(l)}})}function fr(i,e){function t(){return`${e.app.appID}_animation`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(p){localStorage.setItem(t(),p?"open":"closed")}const r=[],l=[];let h=0;i.animations.forEach(p=>{h=Math.max(h,p.duration),p.duration>0&&l.push({title:p.name,items:[{title:"Duration",type:"number",value:p.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),r.push({title:"Animations",items:l});const c=e.getScene(i.uuid);if(c!==null){const p=c.getObjectByProperty("uuid",i.uuid);let m=!1;if(p!==void 0){const f=p.mixer;if(m=f!==void 0,m){const y=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(x,T)=>{f.timeScale=T,e.updateObject(i.uuid,"mixer.timeScale",T)}}];y.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),e.requestMethod(i.uuid,"stopAllAction",void 0,"mixer")}}),r.push({title:"Mixer",items:y})}}}return u.jsx(fe,{title:"Animation",items:r,expanded:n,onToggle:p=>{a(p)}})}const di={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 ie={...di};function gs(i){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(h){ie={...h.value},t(Date.now())}function l(){ie={...di},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 s=ie.type.toLowerCase(),n=ie.animations.length>0||ie.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return u.jsx(ut,{label:"Inspector",button:ie.uuid.length>0?u.jsx("button",{className:"remove",onClick:()=>{ne.instance.remove(ie.name),ie={...di},t(Date.now())}}):void 0,children:u.jsx("div",{id:"Inspector",className:i.class,children:ie.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Pt,{type:"string",title:"Name",prop:"name",value:ie.name,disabled:!0}),u.jsx(Pt,{type:"string",title:"Type",prop:"type",value:ie.type,disabled:!0}),u.jsx(Pt,{type:"string",title:"UUID",prop:"uuid",value:ie.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(kt,{object:ie,three:i.three}),n?fr(ie,i.three):null,s.search("camera")>-1?Dn(ie,i.three):null,s.search("light")>-1?mr(ie,i.three):null,a?Pn(ie,i.three):null]})]})},e)},"Inspector")}function _s(i){const[e]=w.useState([]),[t]=w.useState([]),[s,n]=w.useState(0),a=h=>{const c=h.value;e.push(c),t.push(u.jsx(ut,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(oi,{child:c,scene:c,three:i.three})},Math.random())),n(Date.now())},r=h=>{const c=h.value;for(let p=0;p<e.length;p++)if(c.uuid===e[p].uuid){e[p]=c,t[p]=u.jsx(ut,{label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{i.three.refreshScene(c.name)},children:u.jsx(oi,{child:c,scene:c,three:i.three})},Math.random()),n(Date.now());return}},l=h=>{const c=h.value;for(let p=0;p<e.length;p++)if(c.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.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)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},s),u.jsx(gs,{three:i.three}),u.jsx($,{three:i.three})]})}function gr(i){return w.useEffect(()=>{function e(l){let h=null;return i.three.scenes.forEach(c=>{l.search(c.uuid)>-1&&(h=c)}),h}const t=l=>{const h=l.value,p=e(h)?.getObjectByProperty("uuid",h);p!==void 0&&i.three.setObject(p)},s=(l,h,c)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&q(m,h,c)},n=l=>{const h=l.value,{key:c,value:p,uuid:m}=h;s(m,c,p)},a=l=>{const h=l.value,p=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(p!==void 0){const m=f=>{const y=h.key.split(".");switch(y.length){case 1:p[y[0]]=f;break;case 2:p[y[0]][y[1]]=f;break;case 3:p[y[0]][y[1]][y[2]]=f;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=f;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=f;break}p.material.needsUpdate=!0};h.value.src.length>0?os(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:p,subitem:m}=l.value,y=e(c)?.getObjectByProperty("uuid",c);if(y!==void 0)try{m!==void 0?en(y,m)[h](p):y[h](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(p)}};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 ys(i){return u.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[u.jsx("div",{className:"header",children:i.header}),i.children,u.jsx("div",{className:"footer",children:i.footer})]})}function _r(i){return u.jsx(ys,{children:u.jsxs(u.Fragment,{children:[u.jsx(be,{three:i.three,scenes:i.scenes,onSceneResize:i.onSceneResize,onSceneSet:i.onSceneSet,onSceneUpdate:i.onSceneUpdate}),u.jsx(_s,{three:i.three})]})})}exports.Accordion=ut;exports.Application=Zs;exports.BaseRemote=Lt;exports.ChildObject=mi;exports.ContainerObject=oi;exports.Draggable=cs;exports.DraggableItem=ls;exports.Dropdown=hs;exports.DropdownItem=ds;exports.Editor=ys;exports.ExportTexture=ht;exports.Inspector=gs;exports.MultiView=be;exports.NavButton=pi;exports.RemoteComponents=Ws;exports.RemoteController=ln;exports.RemoteTheatre=qs;exports.RemoteThree=sn;exports.SceneInspector=gr;exports.SidePanel=_s;exports.Spline=hi;exports.SplineEditor=fs;exports.ThreeEditor=_r;exports.ToolEvents=P;exports.Transform=ne;exports.capitalize=dt;exports.clamp=Te;exports.colorToHex=ni;exports.copyToClipboard=ss;exports.customizeTheatreElements=Qs;exports.debugDispatcher=R;exports.defaultTheatreCallback=Bs;exports.dispose=Se;exports.disposeMaterial=as;exports.disposeTexture=Gs;exports.distance=Ys;exports.hierarchyUUID=Dt;exports.isColor=rs;exports.mix=Rt;exports.noop=ui;exports.normalize=si;exports.randomID=ns;exports.resetThreeObjects=ri;exports.round=pe;exports.theatreEditorApp=Xs;