@tomorrowevening/hermes 0.1.39 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/{ThreeEditor-CTkjs-SY.js → ThreeEditor-CB5dBR7Q.js} +1 -1
  2. package/dist/core/Application.js +77 -0
  3. package/dist/core/remote/BaseRemote.js +33 -0
  4. package/dist/core/remote/RemoteTheatre.js +253 -0
  5. package/dist/core/remote/RemoteThree.js +442 -0
  6. package/dist/core/types.js +7 -0
  7. package/dist/editor/Editor.js +12 -0
  8. package/dist/editor/HermesApp.js +24 -0
  9. package/dist/editor/ThreeEditor.js +22 -0
  10. package/dist/editor/components/Draggable.js +40 -0
  11. package/dist/editor/components/DraggableItem.js +25 -0
  12. package/dist/editor/components/Dropdown.js +32 -0
  13. package/dist/editor/components/DropdownItem.js +50 -0
  14. package/dist/editor/components/NavButton.js +7 -0
  15. package/dist/editor/components/content.js +4 -0
  16. package/dist/editor/components/icons/CloseIcon.js +9 -0
  17. package/dist/editor/components/icons/DragIcon.js +12 -0
  18. package/dist/editor/multiView/CameraWindow.js +64 -0
  19. package/dist/editor/multiView/DepthNodeMaterial.js +12 -0
  20. package/dist/editor/multiView/InfiniteGridHelper.js +31 -0
  21. package/dist/editor/multiView/InfiniteGridHelperGPU.js +31 -0
  22. package/dist/editor/multiView/InfiniteGridMaterial.js +137 -0
  23. package/dist/editor/multiView/InfiniteGridNodeMaterial.js +63 -0
  24. package/dist/editor/multiView/MultiView.js +890 -0
  25. package/dist/editor/multiView/Toggle.js +25 -0
  26. package/dist/editor/multiView/UVMaterial.js +60 -0
  27. package/dist/editor/multiView/UVNodeMaterial.js +10 -0
  28. package/dist/editor/sidePanel/Accordion.js +56 -0
  29. package/dist/editor/sidePanel/ChildObject.js +78 -0
  30. package/dist/editor/sidePanel/ContainerObject.js +11 -0
  31. package/dist/editor/sidePanel/DebugData.js +133 -0
  32. package/dist/editor/sidePanel/SidePanel.js +91 -0
  33. package/dist/editor/sidePanel/inspector/InspectGrid3.js +82 -0
  34. package/dist/editor/sidePanel/inspector/InspectGrid4.js +58 -0
  35. package/dist/editor/sidePanel/inspector/InspectImage.js +100 -0
  36. package/dist/editor/sidePanel/inspector/InspectNumber.js +76 -0
  37. package/dist/editor/sidePanel/inspector/InspectVector2.js +154 -0
  38. package/dist/editor/sidePanel/inspector/Inspector.js +95 -0
  39. package/dist/editor/sidePanel/inspector/InspectorField.js +128 -0
  40. package/dist/editor/sidePanel/inspector/InspectorGroup.js +110 -0
  41. package/dist/editor/sidePanel/inspector/utils/DragNumber.js +27 -0
  42. package/dist/editor/sidePanel/inspector/utils/InspectAnimation.js +99 -0
  43. package/dist/editor/sidePanel/inspector/utils/InspectCamera.js +91 -0
  44. package/dist/editor/sidePanel/inspector/utils/InspectLight.js +85 -0
  45. package/dist/editor/sidePanel/inspector/utils/InspectMaterial.js +861 -0
  46. package/dist/editor/sidePanel/inspector/utils/InspectTransform.js +93 -0
  47. package/dist/editor/sidePanel/utils.js +259 -0
  48. package/dist/editor/tools/Transform.js +77 -0
  49. package/dist/editor/tools/splineEditor/Spline.js +348 -0
  50. package/dist/editor/tools/splineEditor/index.js +193 -0
  51. package/dist/editor/utils.js +27 -0
  52. package/dist/hermes.cjs.js +8 -30
  53. package/dist/{index-BpKOzCuX.js → index-DepTXu6T.js} +454 -454
  54. package/dist/index.html +1 -1
  55. package/dist/index.js +125 -0
  56. package/dist/utils/ImageSequenceCapturer.js +148 -0
  57. package/dist/utils/detectSettings.js +46 -0
  58. package/dist/utils/math.js +68 -0
  59. package/dist/utils/post.js +206 -0
  60. package/dist/utils/theatre.js +316 -0
  61. package/dist/utils/three.js +199 -0
  62. package/dist/webworkers/EventHandling.js +115 -0
  63. package/dist/webworkers/ProxyManager.js +76 -0
  64. package/package.json +13 -7
  65. package/dist/.vite/manifest.json +0 -12
  66. package/dist/hermes.es.js +0 -8077
@@ -1,21 +1,4 @@
1
- "use strict";var Ri=Object.create;var At=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Ii=Object.getPrototypeOf,Ui=Object.prototype.hasOwnProperty;var Li=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Di(e))!Ui.call(i,n)&&n!==t&&At(i,n,{get:()=>e[n],enumerable:!(s=Pi(e,n))||s.enumerable});return i};var ki=(i,e,t)=>(t=i!=null?Ri(Ii(i)):{},Li(e||!i||!i.__esModule?At(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@tomorrowevening/theatre-core"),b=require("react"),v=require("three"),w=require("three/webgpu"),d=require("react/jsx-runtime"),$=require("three/src/math/MathUtils.js"),Ni=require("three/examples/jsm/helpers/RectAreaLightHelper.js"),Fi=require("three/examples/jsm/controls/OrbitControls.js"),R=require("three/tsl"),Kt=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),je=require("three/src/nodes/TSL.js"),ji=require("three/examples/jsm/controls/TransformControls.js"),ze=()=>{},zi=()=>{};function He(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function Xt(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function W(){return Math.round(Math.random()*1e6).toString()}function Qt(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function vt(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=l=>{const c=l.toString(16);return c.length===1?"0"+c:c},r=n(e),a=n(t),o=n(s);return"#"+r+a+o}function st(i,e,t,s){return new(t||(t=Promise))(function(n,r){function a(c){try{l(s.next(c))}catch(h){r(h)}}function o(c){try{l(s.throw(c))}catch(h){r(h)}}function l(c){var h;c.done?n(c.value):(h=c.value,h instanceof t?h:new t(function(u){u(h)})).then(a,o)}l((s=s.apply(i,[])).next())})}const Hi=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function Rt(i){return i=i.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const Jt=typeof window>"u",ne=(()=>{if(Jt)return;const{userAgent:i,platform:e,maxTouchPoints:t}=window.navigator,s=/(iphone|ipod|ipad)/i.test(i),n=e==="iPad"||e==="MacIntel"&&t>0&&!window.MSStream;return{isIpad:n,isMobile:/android/i.test(i)||s||n,isSafari12:/Version\/12.+Safari/.test(i),isFirefox:/Firefox/.test(i)}})();function Bi(i,e,t){if(!t)return[e];const s=function(c){const h=`
2
- precision highp float;
3
- attribute vec3 aPosition;
4
- varying float vvv;
5
- void main() {
6
- vvv = 0.31622776601683794;
7
- gl_Position = vec4(aPosition, 1.0);
8
- }
9
- `,u=`
10
- precision highp float;
11
- varying float vvv;
12
- void main() {
13
- vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;
14
- enc = fract(enc);
15
- enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
16
- gl_FragColor = enc;
17
- }
18
- `,p=c.createShader(35633),m=c.createShader(35632),C=c.createProgram();if(!(m&&p&&C))return;c.shaderSource(p,h),c.shaderSource(m,u),c.compileShader(p),c.compileShader(m),c.attachShader(C,p),c.attachShader(C,m),c.linkProgram(C),c.detachShader(C,p),c.detachShader(C,m),c.deleteShader(p),c.deleteShader(m),c.useProgram(C);const _=c.createBuffer();c.bindBuffer(34962,_),c.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const E=c.getAttribLocation(C,"aPosition");c.vertexAttribPointer(E,3,5126,!1,0,0),c.enableVertexAttribArray(E),c.clearColor(1,1,1,1),c.clear(16384),c.viewport(0,0,1,1),c.drawArrays(4,0,3);const g=new Uint8Array(4);return c.readPixels(0,0,1,1,6408,5121,g),c.deleteProgram(C),c.deleteBuffer(_),g.join("")}(i),n="801621810",r="8016218135",a="80162181161",o=ne?.isIpad?[["a7",a,12],["a8",r,15],["a8x",r,15],["a9",r,15],["a9x",r,15],["a10",r,15],["a10x",r,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",a,12],["a8",r,12],["a9",r,15],["a10",r,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let l;return s==="80162181255"?l=o.filter(([,,c])=>c>=14):(l=o.filter(([,c])=>c===s),l.length||(l=o)),l.map(([c])=>`apple ${c} gpu`)}class Pt extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const nt=[],Dt=[];function Vi(i,e){if(i===e)return 0;const t=i;i.length>e.length&&(i=e,e=t);let s=i.length,n=e.length;for(;s>0&&i.charCodeAt(~-s)===e.charCodeAt(~-n);)s--,n--;let r,a=0;for(;a<s&&i.charCodeAt(a)===e.charCodeAt(a);)a++;if(s-=a,n-=a,s===0)return n;let o,l,c=0,h=0,u=0;for(;h<s;)Dt[h]=i.charCodeAt(a+h),nt[h]=++h;for(;u<n;)for(r=e.charCodeAt(a+u),o=u++,c=u,h=0;h<s;h++)l=r===Dt[h]?o:o+1,o=nt[h],c=nt[h]=o>c?l>c?c+1:l:l>o?o+1:l;return c}function Gi(i){return i!=null}const Wi=({mobileTiers:i=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:s,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:r="https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks"}={})=>st(void 0,void 0,void 0,function*(){const a={};if(Jt)return{tier:0,type:"SSR"};const{isIpad:o=!!ne?.isIpad,isMobile:l=!!ne?.isMobile,screenSize:c=window.screen,loadBenchmarks:h=S=>st(void 0,void 0,void 0,function*(){const T=yield fetch(`${r}/${S}`).then(M=>M.json());if(parseInt(T.shift().split(".")[0],10)<4)throw new Pt("Detect GPU benchmark data is out of date. Please update to version 4x");return T})}=t;let{renderer:u}=t;const p=(S,T,M,U,A)=>({device:A,fps:U,gpu:M,isMobile:l,tier:S,type:T});let m,C="";if(u)u=Rt(u),m=[u];else{const S=s||function(M,U=!1){const A={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:U,powerPreference:"high-performance",stencil:!1};M&&delete A.powerPreference;const j=window.document.createElement("canvas"),J=j.getContext("webgl",A)||j.getContext("experimental-webgl",A);return J??void 0}(ne?.isSafari12,n);if(!S)return p(0,"WEBGL_UNSUPPORTED");const T=ne?.isFirefox?null:S.getExtension("WEBGL_debug_renderer_info");if(u=T?S.getParameter(T.UNMASKED_RENDERER_WEBGL):S.getParameter(S.RENDERER),!u)return p(1,"FALLBACK");C=u,u=Rt(u),m=function(M,U,A){return U==="apple gpu"?Bi(M,U,A):[U]}(S,u,l)}const _=(yield Promise.all(m.map(function(S){var T;return st(this,void 0,void 0,function*(){const M=(B=>{const Z=l?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const le of Z)if(B.includes(le))return le})(S);if(!M)return;const U=`${l?"m":"d"}-${M}${o?"-ipad":""}.json`,A=a[U]=(T=a[U])!==null&&T!==void 0?T:h(U);let j;try{j=yield A}catch(B){if(B instanceof Pt)throw B;return}const J=function(B){var Z;const le=(B=B.replace(/\([^)]+\)/,"")).match(/\d+/)||B.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(Z=le?.join("").replace(/\W|amd/g,""))!==null&&Z!==void 0?Z:""}(S);let oe=j.filter(([,B])=>B===J);oe.length||(oe=j.filter(([B])=>B.includes(S)));const ue=oe.length;if(ue===0)return;const _e=S.split(/[.,()\[\]/\s]/g).sort().filter((B,Z,le)=>Z===0||B!==le[Z-1]).join(" ");let pe,[xi,,,,Oi]=ue>1?oe.map(B=>[B,Vi(_e,B[2])]).sort(([,B],[,Z])=>B-Z)[0][0]:oe[0],it=Number.MAX_VALUE;const{devicePixelRatio:Tt}=window,wi=c.width*Tt*c.height*Tt;for(const B of Oi){const[Z,le]=B,Ai=Z*le,Mt=Math.abs(wi-Ai);Mt<it&&(it=Mt,pe=B)}if(!pe)return;const[,,Ti,Mi]=pe;return[it,Ti,xi,Mi]})}))).filter(Gi).sort(([S=Number.MAX_VALUE,T],[M=Number.MAX_VALUE,U])=>S===M?T-U:S-M);if(!_.length){const S=Hi.find(T=>u.includes(T));return S?p(0,"BLOCKLISTED",S):p(1,"FALLBACK",`${u} (${C})`)}const[,E,g,y]=_[0];if(E===-1)return p(0,"BLOCKLISTED",g,E,y);const x=l?i:e;let O=0;for(let S=0;S<x.length;S++)E>=x[S]&&(O=S);return p(O,"BENCHMARK",g,E,y)});function ei(i){let e=0;const t=performance.now();function s(){e++;const n=performance.now();if(n-t>=100){const r=e/((n-t)/1e3),a=Math.round(r/30)*30;i(a)}else requestAnimationFrame(s)}requestAnimationFrame(s)}function ti(i=!1,e=!1){return new Promise(t=>{Wi().then(s=>{let n=!1;const r=document.createElement("canvas"),a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(n="transferControlToOffscreen"in r,a){const l=navigator.userAgent.match(/version\/(\d+)/i);n=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:n,supportWebGPU:!!navigator.gpu,quality:"Low",dev:i,editor:e};s.tier===3?o.quality="High":s.tier===2&&(o.quality="Medium"),ei(l=>{o.fps=l,t(o)})})})}const Yi=`
1
+ "use strict";var Ct=Object.create;var _e=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var wt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var Et=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xt(e))!Mt.call(i,n)&&n!==t&&_e(i,n,{get:()=>e[n],enumerable:!(s=St(e,n))||s.enumerable});return i};var At=(i,e,t)=>(t=i!=null?Ct(wt(i)):{},Et(e||!i||!i.__esModule?_e(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ot=require("detect-gpu"),x=require("@tomorrowevening/theatre-core"),v=require("react"),p=require("three"),b=require("three/webgpu"),c=require("react/jsx-runtime"),L=require("three/src/math/MathUtils.js"),Rt=require("three/examples/jsm/helpers/RectAreaLightHelper.js"),Tt=require("three/examples/jsm/controls/OrbitControls.js"),q=require("camera-controls"),C=require("three/tsl"),$e=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),ae=require("three/src/nodes/TSL.js"),It=require("three/examples/jsm/controls/TransformControls.js"),oe=()=>{},Pt=()=>{};function ce(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function Ke(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function k(){return Math.round(Math.random()*1e6).toString()}function Ye(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function Ee(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=l=>{const d=l.toString(16);return d.length===1?"0"+d:d},a=n(e),r=n(t),o=n(s);return"#"+a+r+o}function Je(i){let e=0;const t=performance.now();function s(){e++;const n=performance.now();if(n-t>=100){const a=e/((n-t)/1e3),r=Math.round(a/30)*30;i(r)}else requestAnimationFrame(s)}requestAnimationFrame(s)}function Xe(i=!1,e=!1){return new Promise(t=>{Ot.getGPUTier().then(s=>{let n=!1;const a=document.createElement("canvas"),r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(n="transferControlToOffscreen"in a,r){const l=navigator.userAgent.match(/version\/(\d+)/i);n=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:n,supportWebGPU:!!navigator.gpu,quality:"Low",dev:i,editor:e};s.tier===3?o.quality="High":s.tier===2&&(o.quality="Medium"),Je(l=>{o.fps=l,t(o)})})})}const kt=`
19
2
  self.onmessage = async ({ data }) => {
20
3
  if (data.type !== 'encode') return;
21
4
  const { bitmap, index, format, quality } = data;
@@ -27,15 +10,10 @@ self.onmessage = async ({ data }) => {
27
10
  const blob = await canvas.convertToBlob({ type: mime, quality });
28
11
  self.postMessage({ type: 'encoded', index, blob });
29
12
  };
30
- `;class qi{worker;source;transfer;ctx;opts;_capturing=!1;_captured=0;_encoded=0;_pending=0;_lastFrameTime=-1/0;frames=new Map;constructor(e,t={}){this.source=e,this.transfer=document.createElement("canvas"),this.transfer.width=e.width,this.transfer.height=e.height,this.ctx=this.transfer.getContext("2d",{willReadFrequently:!0}),this.opts={format:t.format??"png",quality:t.quality??.92,prefix:t.prefix??"frame",padLength:t.padLength??5,maxQueue:t.maxQueue??32,fps:t.fps??30,onProgress:t.onProgress??(()=>{}),onError:t.onError??(r=>console.error("[ImageSequenceCapturer]",r))};const s=new Blob([Yi],{type:"application/javascript"}),n=URL.createObjectURL(s);this.worker=new Worker(n),URL.revokeObjectURL(n),this.worker.onmessage=({data:r})=>{r.type==="encoded"&&(this.frames.set(r.index,r.blob),this._pending--,this._encoded++,this.opts.onProgress(this._captured,this._encoded))},this.worker.onerror=r=>this.opts.onError(new Error(r.message))}get isCapturing(){return this._capturing}get framesCaptured(){return this._captured}get framesEncoded(){return this._encoded}get isIdle(){return this._pending===0}resize(){this.transfer.width=this.source.width,this.transfer.height=this.source.height}start(){this._capturing=!0,this._captured=0,this._encoded=0,this._pending=0,this._lastFrameTime=-1/0,this.frames.clear()}stop(){this._capturing=!1}captureFrame(){if(!this._capturing||this._pending>=this.opts.maxQueue)return!1;const e=performance.now();if(e-this._lastFrameTime<1e3/this.opts.fps)return!1;this._lastFrameTime=e,this.ctx.drawImage(this.source,0,0);const t=this._captured++;return this._pending++,createImageBitmap(this.transfer).then(s=>{this.worker.postMessage({type:"encode",bitmap:s,index:t,format:this.opts.format,quality:this.opts.quality},[s])}).catch(s=>{this._pending--,this.opts.onError(s)}),!0}flush(){return new Promise(e=>{const t=()=>this._pending===0?e():setTimeout(t,16);t()})}async download(){await this.flush();const e=this.opts.format==="jpeg"?"jpg":this.opts.format,s=[...this.frames.entries()].sort(([n],[r])=>n-r).map(([n,r])=>({name:`${this.opts.prefix}_${String(n).padStart(this.opts.padLength,"0")}.${e}`,blob:r}));if("showDirectoryPicker"in window)try{const n=await window.showDirectoryPicker({mode:"readwrite",startIn:"downloads"});await Promise.all(s.map(async({name:r,blob:a})=>{const l=await(await n.getFileHandle(r,{create:!0})).createWritable();await l.write(a),await l.close()}));return}catch(n){if(n.name==="AbortError")return}for(const{name:n,blob:r}of s){const a=URL.createObjectURL(r);Object.assign(document.createElement("a"),{href:a,download:n}).click(),URL.revokeObjectURL(a),await new Promise(l=>setTimeout(l,50))}}reset(){this._capturing=!1,this._captured=0,this._encoded=0,this._pending=0,this.frames.clear()}destroy(){this.reset(),this.worker.terminate()}}function de(i,e,t){return Math.min(e,Math.max(i,t))}function Xe(i,e,t){return(t-i)/(e-i)}function Re(i,e,t){return i*(1-t)+e*t}function $i(i,e,t,s,n){return Re(t,s,Xe(i,e,n))}function Zi(i,e){const t=i-e;return Math.sqrt(t*t)}function Ki(i,e,t,s){return Re(i,e,1-Math.exp(-t*s))}function X(i,e=1){return Number(i.toFixed(e))}function Xi(i,e,t,s){return Math.atan2(s-e,t-i)}function Qi(i,e,t,s){return i===e&&t===s}function Ji(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function es(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function ts(i,e,t,s,n){const r=i*i;return e*(r*i)+t*r+s*i+n}function is(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(Qi(e,t,s,n))return i;const r=0,a=0,o=e,l=t,c=s,h=n,u=1,p=1,m=u-3*c+3*o-r,C=3*c-6*o+3*r,_=3*o-3*r,E=r,g=p-3*h+3*l-a,y=3*h-6*l+3*a,x=3*l-3*a,O=a;let S=i;for(let T=0;T<5;T++){const M=es(S,m,C,_,E);let U=Ji(S,m,C,_);U===1/0&&(U=i),S-=(M-i)*U,S=Math.min(Math.max(S,0),1)}return ts(S,g,y,x,O)}const Be=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function ss({r:i,g:e,b:t,a:s=1}){const n=`#${Be(i)}${Be(e)}${Be(t)}`;return s<1?`${n}${Be(s)}`:n}let ye;function ns(){const[i,e]=b.useState(ye);return b.useEffect(()=>{ye||import("@tomorrowevening/theatre-studio").then(t=>{ye=t.default,ye.initialize(),ye.ui.hide(),e(ye)})},[]),i}async function rs(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,100));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){try{const n=t.children[1].children[1];n.parentElement?.removeChild(n)}catch{}try{const s=t.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function as(i,e,t,s){s.sheetObject(i,e,{transform:{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},visible:t.visible}},n=>{const r=n.transform;t.position.copy(r.position),t.rotation.copy(r.rotation),t.scale.copy(r.scale),t.visible=r.visible})}const os=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function It(i){const e=typeof i;if(i===null||i.isTexture)return"texture";if(e==="boolean")return"boolean";if(e==="number")return"number";if(e==="string")return"string";if(e==="object"){if(i.isColor)return"color";if(i.isVector2)return"vector2";if(i.isVector3)return"vector3";if(i.isVector4)return"vector4";if(i.isMatrix2)return"matrix2";if(i.isMatrix3)return"matrix3";if(i.isMatrix4)return"matrix4";if(i.isEuler)return"euler";if(Array.isArray(i))return"array"}return"object"}function ii(i){const e=[];for(const s in i){const n=os.find(o=>o===s),r=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||r))if(s==="uniforms"){const o=i.uniforms;for(const l in o){const c=o[l].value,h=It(c);h==="array"||h==="object"||e.push({name:`uniforms.${l}.value`,type:h,value:c})}}else{const o=It(i[s]);e.push({name:s,type:o,value:i[s]})}}return e.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function si(i){const e={},t={nudgeMultiplier:.01};return i.forEach(s=>{let n=s.value;switch(s.type){case"color":n=I.types.rgba({r:n.r,g:n.g,b:n.b,a:1});break;case"number":n=I.types.number(n,t);break;case"euler":case"vector3":n={x:I.types.number(n.x,t),y:I.types.number(n.y,t),z:I.types.number(n.z,t)};break;case"vector2":n={x:I.types.number(n.x,t),y:I.types.number(n.y,t)};break;case"vector4":n={x:I.types.number(n.x,t),y:I.types.number(n.y,t),z:I.types.number(n.z,t),w:I.types.number(n.w,t)};break;case"matrix2":n={0:I.types.number(n.elements[0],t),1:I.types.number(n.elements[1],t),2:I.types.number(n.elements[2],t),3:I.types.number(n.elements[3],t)};break;case"matrix3":n={0:I.types.number(n.elements[0],t),1:I.types.number(n.elements[1],t),2:I.types.number(n.elements[2],t),3:I.types.number(n.elements[3],t),4:I.types.number(n.elements[4],t),5:I.types.number(n.elements[5],t),6:I.types.number(n.elements[6],t),7:I.types.number(n.elements[7],t),8:I.types.number(n.elements[8],t)};break;case"matrix4":n={0:I.types.number(n.elements[0],t),1:I.types.number(n.elements[1],t),2:I.types.number(n.elements[2],t),3:I.types.number(n.elements[3],t),4:I.types.number(n.elements[4],t),5:I.types.number(n.elements[5],t),6:I.types.number(n.elements[6],t),7:I.types.number(n.elements[7],t),8:I.types.number(n.elements[8],t),9:I.types.number(n.elements[9],t),10:I.types.number(n.elements[10],t),11:I.types.number(n.elements[11],t),12:I.types.number(n.elements[12],t),13:I.types.number(n.elements[13],t),14:I.types.number(n.elements[14],t),15:I.types.number(n.elements[15],t)};break}if(s.name.includes(".")){const r=s.name.split(".");let a=e;for(let o=0;o<r.length-1;o++){const l=r[o];a[l]||(a[l]={}),a=a[l]}a[r[r.length-1]]=n}else e[s.name]=n}),e}function ni(i,e,t){e.forEach(s=>{if(i[s.name]!==void 0)switch(s.type){case"boolean":case"number":i[s.name]=t.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":i[s.name].copy(t.material[s.name]);break}})}function ls(i,e,t,s){if(!t.isMaterial)return;const n=ii(t),r=si(n);s.sheetObject(i,e,{material:r},a=>{ni(t,n,a)})}const Je=new v.BufferGeometry;Je.setAttribute("position",new v.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));Je.setAttribute("normal",new v.Float32BufferAttribute([0,0,1,0,0,1],3));Je.setAttribute("uv",new v.Float32BufferAttribute([0,0,2,0,0,2],2));const cs=new v.OrthographicCamera(-.5,.5,.5,-.5,0,100),_t=i=>{i?.dispose()},bt=i=>{if(i)if(Array.isArray(i))i.forEach(e=>bt(e));else{for(const e in i){const t=i[e];t!==null&&t instanceof v.Texture&&_t(t)}if(i.isShaderMaterial===!0){const e=i;for(const t in e.uniforms){const s=e.uniforms[t];s.value!==null&&s.value instanceof v.Texture&&_t(s.value)}}i.dispose()}},Q=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):Q(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),bt(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const Ne=()=>{exports.totalThreeObjects=0},Me=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=>Me(t))};class ae{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 r=this.canvas.width/n.width,a=this.renderToCanvas(e);this.context.drawImage(a,0,0,n.width*r,n.height*r)}}return e.repeat.copy(t),e.offset.copy(s),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new v.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new v.Scene,this.material=new v.MeshBasicMaterial;const t=new v.BufferGeometry;t.setAttribute("position",new v.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new v.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new v.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new v.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=v.LinearSRGBColorSpace,e.colorSpace=v.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function hs(i){return new Promise(e=>{const t=new v.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new v.AnimationMixer(s);if(i.animations.length>0){const a=i.animations.map(l=>v.AnimationClip.parse(l));n.clipAction(a[0]).play(),n.getRoot().animations=i.animations,n.getRoot().mixer=n}const r=[];i.cameras&&i.cameras.length>0&&i.cameras.forEach(a=>{const o=t.parse(a);r.push(o)}),e({animations:i.animations,model:s,mixer:n,cameras:r})})})}const ds=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function ri(i,e,t,s){i.applyMatrix4(new v.Matrix4().makeTranslation(e,-t,-s))}function us(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;ri(i,t,s,0)}function ps(i,e,t){i.left=e/-2,i.right=e/2,i.top=t/2,i.bottom=t/-2,i.position.x=e/2,i.position.y=t/-2,i.updateProjectionMatrix()}function ms(i,e,t){const s=1.7777777777777777,n=e/t;let r=e,a=t;n>s?r=t*s:a=e/s,i.left=r/-2,i.right=r/2,i.top=a/2,i.bottom=a/-2,i.updateProjectionMatrix()}function fs(){let e="transferControlToOffscreen"in document.createElement("canvas");if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){const s=navigator.userAgent.match(/version\/(\d+)/i);e=(s?parseInt(s[1]):0)>=17}return e}function gs(i,e,t=!0,s=!1){i.renderOrder=-e;const n=i.material;Array.isArray(n)?n.forEach(r=>{r.colorWrite=t,r.depthWrite=s,r.stencilWrite=!0,r.stencilRef=e,r.stencilFunc=v.AlwaysStencilFunc,r.stencilFail=v.ReplaceStencilOp,r.stencilZFail=v.ReplaceStencilOp,r.stencilZPass=v.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=v.AlwaysStencilFunc,n.stencilFail=v.ReplaceStencilOp,n.stencilZFail=v.ReplaceStencilOp,n.stencilZPass=v.ReplaceStencilOp)}function vs(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?v.NotEqualStencilFunc:v.EqualStencilFunc,n.stencilFail=v.KeepStencilOp,n.stencilZFail=v.KeepStencilOp,n.stencilZPass=v.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?v.NotEqualStencilFunc:v.EqualStencilFunc,s.stencilFail=v.KeepStencilOp,s.stencilZFail=v.KeepStencilOp,s.stencilZPass=v.KeepStencilOp)}function _s(i){i.blending=v.NormalBlending,i.blendEquation=v.AddEquation,i.blendSrc=v.SrcAlphaFactor,i.blendDst=v.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ys(i){i.blending=v.CustomBlending,i.blendEquation=v.AddEquation,i.blendSrc=v.SrcAlphaFactor,i.blendDst=v.OneFactor,i.needsUpdate=!0}function Cs(i){i.blending=v.CustomBlending,i.blendEquation=v.AddEquation,i.blendSrc=v.DstColorFactor,i.blendDst=v.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function bs(i){i.blending=v.CustomBlending,i.blendEquation=v.AddEquation,i.blendSrc=v.OneMinusDstColorFactor,i.blendDst=v.OneFactor,i.needsUpdate=!0}let yt=[];function ai(i,e,t=!0){ae.renderer=e.renderer;const s=[];s.push({type:"boolean",prop:"Enabled",value:i.enabled});let n=(a,o)=>{console.log("Default Handle Pass:",a,o)};if(i.name==="EffectPass")i.effects.forEach(a=>{a.uniforms.size>0&&a.uniforms.forEach((o,l)=>{if(l==="map")return;const c=`${a.name.replace("Effect","")} ${l}`;if(o.value===null&&t)s.push({prop:l,title:c,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,u=ae.renderToBlob(h);s.push({prop:l,title:c,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof o.value=="number"?s.push({prop:l,title:c,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:l,title:c,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:l,title:c,type:"boolean",value:o.value})})}),n=(a,o)=>{i.effects.forEach(l=>{l.uniforms.size>0&&l.uniforms.forEach((c,h)=>{h===a&&(c.value=o)})})};else if(i.name==="ShaderPass"){const a=i.fullscreenMaterial;for(const o in a.uniforms){if(o==="inputBuffer"||o==="map")continue;const l=a.uniforms[o],c=`${a.name.replace("Material","")} ${o}`;if(l.value===null&&t)s.push({title:c,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(l.value.isTexture&&t){const h=l.value,u=ae.renderToBlob(h);s.push({title:c,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof l.value=="number"?s.push({title:c,prop:o,type:"number",value:l.value,step:.01}):typeof l.value=="string"?s.push({title:c,prop:o,type:"string",value:l.value}):typeof l.value=="boolean"&&s.push({title:c,prop:o,type:"boolean",value:l.value})}n=(o,l)=>{const c=a.uniforms[o];c.value=l}}else return;const r=`${i.name}: ${i.scene.name}`;e.addGroup({title:r,items:s,onUpdate:(a,o)=>{a==="Enabled"?i.enabled=o:n(a,o)}}),yt.push(r)}function Es(i,e){i.passes.forEach(t=>{ai(t,e)})}function Ss(i){yt.forEach(e=>{i.removeGroup(e)}),yt=[]}function xs(i,e,t,s=1024){return new Promise(n=>{const r=e.aspect,a=e.fov,o=e.rotation.clone(),l=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const c=new v.WebGLRenderTarget(s,s,{format:v.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=c,Ce(i,c,e,"nx",t,s).then(()=>{Ce(i,c,e,"ny",t,s).then(()=>{Ce(i,c,e,"nz",t,s).then(()=>{Ce(i,c,e,"px",t,s).then(()=>{Ce(i,c,e,"py",t,s).then(()=>{Ce(i,c,e,"pz",t,s).then(()=>{e.aspect=r,e.fov=a,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=l,c.dispose(),n()})})})})})})})}function Ce(i,e,t,s,n,r){return new Promise(a=>{const o=Math.PI/2;switch(s){case"nx":t.rotation.set(0,-o,0);break;case"ny":t.rotation.set(-o,0,Math.PI);break;case"nz":t.rotation.set(0,0,0);break;case"px":t.rotation.set(0,o,0);break;case"py":t.rotation.set(o,0,Math.PI);break;case"pz":t.rotation.set(0,Math.PI,0);break}t.updateMatrixWorld(),n.render();const l=new Uint8Array(r*r*4);i.readRenderTargetPixels(e,0,0,r,r,l);const c=document.createElement("canvas");c.width=c.height=r;const h=c.getContext("2d"),u=h.createImageData(r,r);u.data.set(l),h.putImageData(u,0,0);const p=document.createElement("canvas");p.width=p.height=r;const m=p.getContext("2d");m.translate(0,r),m.scale(1,-1),m.drawImage(c,0,0);const C=p.toDataURL("image/png"),_=document.createElement("a");_.href=C,_.download=`${t.name}_${s}.png`,document.body.appendChild(_),_.click(),_.remove(),a()})}const be=Et(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),Os=Et(["clientX","clientY","deltaX","deltaY","deltaMode"]),ws=Et(["ctrlKey","metaKey","shiftKey","keyCode"]);function Ts(i,e){i.preventDefault(),Os(i,e)}function Ms(i){i.preventDefault()}function As(i,e,t){for(const s of e)t[s]=i[s]}function Et(i){return function(t,s){const n={type:t.type};As(t,i,n),s(n)}}function rt(i,e){const t=[],s={type:i.type,touches:t};for(let n=0;n<i.touches.length;++n){const r=i.touches[n];t.push({pageX:r.pageX,pageY:r.pageY})}e(s)}const Rs={37:!0,38:!0,39:!0,40:!0};function Ps(i,e){const{keyCode:t}=i;Rs[t]&&(i.preventDefault(),ws(i,e))}const Ds={contextmenu:Ms,mousedown:be,mousemove:be,mouseup:be,pointerdown:be,pointermove:be,pointerup:be,touchstart:rt,touchmove:rt,touchend:rt,wheel:Ts,keydown:Ps};let Is=0;class Us{id;worker;constructor(e,t,s){this.id=Is++,this.worker=t;const n=a=>{this.worker.postMessage({type:"event",id:this.id,data:a})};t.postMessage({type:"makeProxy",id:this.id});for(const[a,o]of Object.entries(s))e.addEventListener(a,l=>{o(l,n)});function r(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",r),r()}}class oi extends v.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=ze,e.stopPropagation=ze,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Ls{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new oi;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class ks{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1};onUpdateCallback;playing=!1;rafID=-1;constructor(e,t=!1){this.settings.dev=e,this.settings.editor=t}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(){return new Promise(e=>{ti(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};addComponent(e,t){this.components.set(e,t)}get debugEnabled(){return this.settings.dev}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e}}class St{name;debug;editor;broadcastChannel;onMessageHandler;constructor(e,t=!1,s=!1){this.name=e,this.debug=t,this.editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){this.broadcastChannel?.removeEventListener("message",this.onMessageHandler),this.broadcastChannel?.close()}send(e){if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{this.broadcastChannel?.postMessage(e)}catch(s){console.log("Hermes - Error sending message:"),console.log(s),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}function Ns(i,e,t,s,n){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*s+i*i*i*n}function Fs(i,e,t){if(i.type!=="bezier"||i.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[s,n]=i.handles,r=(t-i.position)/(e.position-i.position);return Ns(r,i.value,i.value+s,e.value+n,e.value)}class js extends St{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e=!1,t=!1){super("RemoteTheatre",e,t)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(e,t){return this.project=I.getProject(e,{state:t}),new Promise((s,n)=>{this.project?.ready.then(()=>{if(t){const r=t.sheetsById;for(const a in r)this.sheet(a)}s()}).catch(()=>n())})}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=>{this.sheet(e,s)?.sequence.play(t).then(r=>n(r)),this.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.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,r){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=this.sheet(e,r);if(a===void 0)return;const l=`${this.getSheetInstance(e,r)}_${t}`;let c=this.sheetObjects.get(l),h=s;c!==void 0&&(h={...s,...c.value}),c=a.object(t,h,{reconfigure:!0}),this.sheetObjects.set(l,c),this.sheetObjectCBs.set(l,n!==void 0?n:ze);function u(m,C,_){if(typeof _=="object")if(Qt(_))m[C]={r:_.r,g:_.g,b:_.b,a:_.a};else for(const E in _){const g=_[E];typeof g=="object"&&u(_,E,g)}}const p=c.onValuesChange(m=>{const C=this.sheetObjectCBs.get(l);if(this.editor){for(const _ in m){const E=m[_];typeof E=="object"&&u(m,_,E)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:l,values:m}}),C&&C(m)}else C&&C(m)});return this.sheetObjectUnsubscribe.set(l,p),c}getSheetObjectKeyframes(e,t,s){const n=this.sheet(e);if(n===void 0)return[];const r=`${e}_${t}`,a=this.sheetObjects.get(r);return a===void 0?[]:n.sequence.__experimental_getKeyframes(a.props[s])}getSheetObjectVectors(e,t){const s=this.sheet(e);if(s===void 0)return[];const n=`${e}_${t}`,r=this.sheetObjects.get(n);if(r===void 0)return[];const a=[],o=s.sequence.__experimental_getKeyframes(r.props.x),l=s.sequence.__experimental_getKeyframes(r.props.y),c=s.sequence.__experimental_getKeyframes(r.props.z),h=new Set;return o.forEach(p=>h.add(p.position)),l.forEach(p=>h.add(p.position)),c.forEach(p=>h.add(p.position)),Array.from(h).sort((p,m)=>p-m).forEach(p=>{const m=(C,_)=>{const E=C.find((x,O)=>x.position<=_&&(C[O+1]?.position||1/0)>_),g=C.find(x=>x.position>_);if(!E)return g?.value||0;if(!g||E.position===_)return E.value;if(E.type==="bezier")return Fs(E,g,_);const y=(_-E.position)/(g.position-E.position);return E.value+y*(g.value-E.value)};a.push({position:p,x:m(o,p),y:m(l,p),z:m(c,p)})}),a}update(e){}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 r=`${t}_${s}`,a=this.sheetObjectUnsubscribe.get(r);a!==void 0&&(this.sheetObjects.delete(r),this.sheetObjectCBs.delete(r),this.sheetObjectUnsubscribe.delete(r),a())}handleApp(e){let t;switch(e.event){case"setSheet":t=this.sheets.get(e.data.sheet),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet: ${e.data.sheet}`,t);break;case"setSheetObject":t=this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet Object: ${e.data.sheet}, ${e.data.key}: ${e.data.sheet}_${e.data.key}`,t);break;case"updateSheetObject":t=this.sheets.get(e.data.sheet),t!==void 0&&t.sequence.pause(),t=this.sheetObjectCBs.get(e.data.sheetObject),t!==void 0?t(e.data.values):console.log(`Hermes - Can't update Sheet Object: ${e.data.sheetObject}, ${e.data.sheet}`,t);break;case"updateTimeline":t=this.sheets.get(e.data.sheet),t!==void 0?t.sequence.position=e.data.position:console.log(`Hermes - Can't update sheet position: ${e.data.sheet}, ${e.data.position}`);break}}handleEditor(e){switch(e.event){case"playSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break}}getSheetNames(){const e=[];return this.sheets.forEach((t,s)=>{e.push(s)}),e}handleEditorApp(){if(this.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(n=>{n.length<1||n.forEach(r=>{let a=r.address.sheetId,o="setSheet",l={};switch(r.type){case"Theatre_Sheet_PublicAPI":o="setSheet",l={sheet:r.address.sheetId},this.activeSheet=this.sheets.get(r.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",a+=`_${r.address.objectKey}`,l={id:a,sheet:r.address.sheetId,key:r.address.objectKey},this.activeSheet=this.sheets.get(r.address.sheetId);break}this.send({event:o,target:"app",data:l})})});let e=-1;const t=()=>{if(this.activeSheet!==void 0&&e!==this.activeSheet.sequence.position){e=this.activeSheet.sequence.position;const n=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:e,sheet:n.address.sheetId}})}},s=()=>{t(),requestAnimationFrame(s)};t(),s()}else this.studio?.ui.hide()}}function zs(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 ce(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(ce(t))}),e}function Ut(i){return{src:i.image?.src??"",offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}}const Lt={src:"",offset:[0,0],repeat:[1,1]};function Hs(i){const e={};for(const t in i){const s=i[t];if(s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")){const r=s.value;r==null?e[t]={value:Lt}:r.isTexture?e[t]={value:Ut(r)}:e[t]={value:r}}else s==null?e[t]=Lt:s.isTexture?e[t]=Ut(s):e[t]=s}return e}function Bs(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Ee(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Bs(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":if(n!==null)if(n.isTexture)e[t]={src:ae.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]};else if(n.isUniformNode){const r=n.value;e[t]={__isUniform:!0,value:r?.isTexture?{src:ae.renderToBlob(r),offset:[r.offset.x,r.offset.y],repeat:[r.repeat.x,r.repeat.y]}:r}}else t==="uniforms"?e[t]=Hs(n):t.search("Node")>-1||(e[t]=n);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(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 at(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(r=>{n.push(Ee(r))}),e.material=n}else e.material=Ee(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(r=>{n.push(Ee(r))}),e.material=n}else e.material=Ee(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(r=>{n.push(Ee(r))}),e.material=n}else e.material=Ee(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 Vs(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 Gs(i,e){for(const t in e)i[t]=e[t]}function V(i,e,t){if(i===void 0){console.log(`Hermes - Can't set props: ${e}`,t);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 a;switch(n){case 1:a=i[s[0]];break;case 2:a=i[s[0]][s[1]];break;case 3:a=i[s[0]][s[1]][s[2]];break;case 4:a=i[s[0]][s[1]][s[2]][s[3]];break;case 5:a=i[s[0]][s[1]][s[2]][s[3]][s[4]];break}a!=null?Gs(a,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function li(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new v.Texture(s);n.wrapS=v.RepeatWrapping,n.wrapT=v.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}var L=(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.SET_OBJECT="ToolEvents::setObject",i.CLEAR_OBJECT="ToolEvents::clearObject",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.ADD_RENDERER="ToolEvents::addRenderer",i.UPDATE_RENDERER="ToolEvents::updateRenderer",i))(L||{});class Ws extends St{name;canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;_listeners={};constructor(e,t=!1,s=!1){super("RemoteThree",t,s),this.name=e}dispose(){this.scenes.forEach(e=>{Q(e)}),this.scenes.clear(),this.scene&&Q(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const n=s[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){const n={...e,target:this},r=s.slice(0);for(let a=0,o=r.length;a<o;a++)r[a].call(this,n)}}getObjectByUUID(e){const t=e.split(".")[0],s=this.scenes.get(t);if(s!==void 0)return s.getObjectByProperty("uuid",e)}getObject(e){if(!this.debug)return;this.renderer!==void 0&&(ae.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){this.renderer!==void 0&&(ae.renderer=this.renderer);const t=at(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const r=this.getObjectByUUID(e);if(r)try{n!==void 0?Vs(r,n)[t](s):r[t](s)}catch(a){console.log("Hermes - Error requesting method:",e,t,s),console.log(a)}}updateObject(e,t,s){this.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}onUpdateObject(e,t,s){const n=this.getObjectByUUID(e);n&&V(n,t,s)}onCreateTexture(e,t,s){const n=this.getObjectByUUID(e);if(n){const r=a=>{const o=t.split(".");switch(o.length){case 1:n[o[0]]=a;break;case 2:n[o[0]][o[1]]=a;break;case 3:n[o[0]][o[1]][o[2]]=a;break;case 4:n[o[0]][o[1]][o[2]][o[3]]=a;break;case 5:n[o[0]][o[1]][o[2]][o[3]][o[4]]=a;break}n.material.needsUpdate=!0};s.src.length>0?li(s.src).then(a=>{a.offset.set(s.offset[0],s.offset[1]),a.repeat.set(s.repeat[0],s.repeat[1]),r(a)}):r(null)}}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}addSplineCurve(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addSplineObject(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e)})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.debug)return;const s=`#${e.getClearColor(new w.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:e.autoClearColor,outputColorSpace:e.outputColorSpace,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:w.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.debug))return;Ne(),Me(e);const t=ce(e);this.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.debug)return;const t=this.scenes.get(e);if(t!==void 0){const s=ce(t);this.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.debug))return;const t=ce(e);this.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scene!==void 0&&this.scene.uuid.search(e)>-1?this.scene:(this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t)}setScene(e){if(e===void 0||(this.scene=e,!this.debug))return;this.renderer!==void 0&&(ae.renderer=this.renderer),Ne(),Me(e);const t=ce(e);this.send({event:"setScene",target:"editor",data:t})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(e){if(!this.debug)return;const t=at(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug)return;const t=at(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:ce(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,w.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new w.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:w.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(t=>{Ne(),Me(t),this.send({event:"addScene",target:"editor",data:ce(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(ae.renderer=this.renderer),Ne(),Me(this.scene),this.send({event:"setScene",target:"editor",data:ce(this.scene)}));break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:e.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:e.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:e.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:e.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:e.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:e.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:e.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:e.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:e.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:e.data})}}messageHandler(e){const t=e.data;if(t.event==="updateObject"){this.onUpdateObject(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="createTexture"){this.onCreateTexture(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="requestSize"){t.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(s=>{s.resize!==void 0&&s.resize(t.data.width,t.data.height)});return}t.target==="app"?this.handleApp(t):this.handleEditor(t)}addRT(e,t=!0,s){if(!this.renderer)return;let n;this.renderer instanceof w.WebGPURenderer?n=new w.RenderTarget(32,32,s):n=new w.WebGLRenderTarget(32,32,s),n.texture.name=e,this.renderTargets.set(e,n),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((r,a)=>{this.renderTargetsResize.get(a)&&r.setSize(e*s,t*s)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(de(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}}function xt(i){return i.title.search("<")>-1?d.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):d.jsx("button",{children:i.title})}const Ys=d.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[d.jsx("circle",{cx:"7",cy:"7",r:"6"}),d.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),d.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),qs=d.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:d.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
13
+ `;class Dt{worker;source;transfer;ctx;opts;_capturing=!1;_captured=0;_encoded=0;_pending=0;_lastFrameTime=-1/0;frames=new Map;constructor(e,t={}){this.source=e,this.transfer=document.createElement("canvas"),this.transfer.width=e.width,this.transfer.height=e.height,this.ctx=this.transfer.getContext("2d",{willReadFrequently:!0}),this.opts={format:t.format??"png",quality:t.quality??.92,prefix:t.prefix??"frame",padLength:t.padLength??5,maxQueue:t.maxQueue??32,fps:t.fps??30,onProgress:t.onProgress??(()=>{}),onError:t.onError??(a=>console.error("[ImageSequenceCapturer]",a))};const s=new Blob([kt],{type:"application/javascript"}),n=URL.createObjectURL(s);this.worker=new Worker(n),URL.revokeObjectURL(n),this.worker.onmessage=({data:a})=>{a.type==="encoded"&&(this.frames.set(a.index,a.blob),this._pending--,this._encoded++,this.opts.onProgress(this._captured,this._encoded))},this.worker.onerror=a=>this.opts.onError(new Error(a.message))}get isCapturing(){return this._capturing}get framesCaptured(){return this._captured}get framesEncoded(){return this._encoded}get isIdle(){return this._pending===0}resize(){this.transfer.width=this.source.width,this.transfer.height=this.source.height}start(){this._capturing=!0,this._captured=0,this._encoded=0,this._pending=0,this._lastFrameTime=-1/0,this.frames.clear()}stop(){this._capturing=!1}captureFrame(){if(!this._capturing||this._pending>=this.opts.maxQueue)return!1;const e=performance.now();if(e-this._lastFrameTime<1e3/this.opts.fps)return!1;this._lastFrameTime=e,this.ctx.drawImage(this.source,0,0);const t=this._captured++;return this._pending++,createImageBitmap(this.transfer).then(s=>{this.worker.postMessage({type:"encode",bitmap:s,index:t,format:this.opts.format,quality:this.opts.quality},[s])}).catch(s=>{this._pending--,this.opts.onError(s)}),!0}flush(){return new Promise(e=>{const t=()=>this._pending===0?e():setTimeout(t,16);t()})}async download(){await this.flush();const e=this.opts.format==="jpeg"?"jpg":this.opts.format,s=[...this.frames.entries()].sort(([n],[a])=>n-a).map(([n,a])=>({name:`${this.opts.prefix}_${String(n).padStart(this.opts.padLength,"0")}.${e}`,blob:a}));if("showDirectoryPicker"in window)try{const n=await window.showDirectoryPicker({mode:"readwrite",startIn:"downloads"});await Promise.all(s.map(async({name:a,blob:r})=>{const l=await(await n.getFileHandle(a,{create:!0})).createWritable();await l.write(r),await l.close()}));return}catch(n){if(n.name==="AbortError")return}for(const{name:n,blob:a}of s){const r=URL.createObjectURL(a);Object.assign(document.createElement("a"),{href:r,download:n}).click(),URL.revokeObjectURL(r),await new Promise(l=>setTimeout(l,50))}}reset(){this._capturing=!1,this._captured=0,this._encoded=0,this._pending=0,this.frames.clear()}destroy(){this.reset(),this.worker.terminate()}}function z(i,e,t){return Math.min(e,Math.max(i,t))}function fe(i,e,t){return(t-i)/(e-i)}function ie(i,e,t){return i*(1-t)+e*t}function jt(i,e,t,s,n){return ie(t,s,fe(i,e,n))}function Nt(i,e){const t=i-e;return Math.sqrt(t*t)}function Lt(i,e,t,s){return ie(i,e,1-Math.exp(-t*s))}function _(i,e=1){return Number(i.toFixed(e))}function _t(i,e,t,s){return Math.atan2(s-e,t-i)}function Ut(i,e,t,s){return i===e&&t===s}function Gt(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function Ft(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function Bt(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function Vt(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(Ut(e,t,s,n))return i;const a=0,r=0,o=e,l=t,d=s,h=n,u=1,m=1,f=u-3*d+3*o-a,y=3*d-6*o+3*a,g=3*o-3*a,S=a,O=m-3*h+3*l-r,M=3*h-6*l+3*r,T=3*l-3*r,R=r;let D=i;for(let V=0;V<5;V++){const H=Ft(D,f,y,g,S);let F=Gt(D,f,y,g);F===1/0&&(F=i),D-=(H-i)*F,D=Math.min(Math.max(D,0),1)}return Bt(D,O,M,T,R)}const de=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function Ht({r:i,g:e,b:t,a:s=1}){const n=`#${de(i)}${de(e)}${de(t)}`;return s<1?`${n}${de(s)}`:n}let Y;function Wt(){const[i,e]=v.useState(Y);return v.useEffect(()=>{Y||import("@tomorrowevening/theatre-studio").then(t=>{Y=t.default,Y.initialize(),Y.ui.hide(),e(Y)})},[]),i}async function zt(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,100));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){try{const n=t.children[1].children[1];n.parentElement?.removeChild(n)}catch{}try{const s=t.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function qt(i,e,t,s){s.sheetObject(i,e,{transform:{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},visible:t.visible}},n=>{const a=n.transform;t.position.copy(a.position),t.rotation.copy(a.rotation),t.scale.copy(a.scale),t.visible=a.visible})}const $t=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function Ue(i){const e=typeof i;if(i===null||i.isTexture)return"texture";if(e==="boolean")return"boolean";if(e==="number")return"number";if(e==="string")return"string";if(e==="object"){if(i.isColor)return"color";if(i.isVector2)return"vector2";if(i.isVector3)return"vector3";if(i.isVector4)return"vector4";if(i.isMatrix2)return"matrix2";if(i.isMatrix3)return"matrix3";if(i.isMatrix4)return"matrix4";if(i.isEuler)return"euler";if(Array.isArray(i))return"array"}return"object"}function Qe(i){const e=[];for(const s in i){const n=$t.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||a))if(s==="uniforms"){const o=i.uniforms;for(const l in o){const d=o[l].value,h=Ue(d);h==="array"||h==="object"||e.push({name:`uniforms.${l}.value`,type:h,value:d})}}else{const o=Ue(i[s]);e.push({name:s,type:o,value:i[s]})}}return e.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function Ze(i){const e={},t={nudgeMultiplier:.01};return i.forEach(s=>{let n=s.value;switch(s.type){case"color":n=x.types.rgba({r:n.r,g:n.g,b:n.b,a:1});break;case"number":n=x.types.number(n,t);break;case"euler":case"vector3":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t)};break;case"vector2":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t)};break;case"vector4":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t),w:x.types.number(n.w,t)};break;case"matrix2":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t)};break;case"matrix3":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t)};break;case"matrix4":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t),9:x.types.number(n.elements[9],t),10:x.types.number(n.elements[10],t),11:x.types.number(n.elements[11],t),12:x.types.number(n.elements[12],t),13:x.types.number(n.elements[13],t),14:x.types.number(n.elements[14],t),15:x.types.number(n.elements[15],t)};break}if(s.name.includes(".")){const a=s.name.split(".");let r=e;for(let o=0;o<a.length-1;o++){const l=a[o];r[l]||(r[l]={}),r=r[l]}r[a[a.length-1]]=n}else e[s.name]=n}),e}function et(i,e,t){e.forEach(s=>{if(i[s.name]!==void 0)switch(s.type){case"boolean":case"number":i[s.name]=t.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":i[s.name].copy(t.material[s.name]);break}})}function Kt(i,e,t,s){if(!t.isMaterial)return;const n=Qe(t),a=Ze(n);s.sheetObject(i,e,{material:a},r=>{et(t,n,r)})}const ve=new p.BufferGeometry;ve.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));ve.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3));ve.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const Yt=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),Ae=i=>{i?.dispose()},Te=i=>{if(i)if(Array.isArray(i))i.forEach(e=>Te(e));else{for(const e in i){const t=i[e];t!==null&&t instanceof p.Texture&&Ae(t)}if(i.isShaderMaterial===!0){const e=i;for(const t in e.uniforms){const s=e.uniforms[t];s.value!==null&&s.value instanceof p.Texture&&Ae(s.value)}}i.dispose()}},U=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):U(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),Te(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const ne=()=>{exports.totalThreeObjects=0},ee=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=>ee(t))};class B{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 p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const t=new p.BufferGeometry;t.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new p.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=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function Jt(i){return new Promise(e=>{const t=new p.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new p.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(l=>p.AnimationClip.parse(l));n.clipAction(r[0]).play(),n.getRoot().animations=i.animations,n.getRoot().mixer=n}const a=[];i.cameras&&i.cameras.length>0&&i.cameras.forEach(r=>{const o=t.parse(r);a.push(o)}),e({animations:i.animations,model:s,mixer:n,cameras:a})})})}const Xt=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function tt(i,e,t,s){i.applyMatrix4(new p.Matrix4().makeTranslation(e,-t,-s))}function Qt(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;tt(i,t,s,0)}function Zt(i,e,t){i.left=e/-2,i.right=e/2,i.top=t/2,i.bottom=t/-2,i.position.x=e/2,i.position.y=t/-2,i.updateProjectionMatrix()}function ei(i,e,t){const s=1.7777777777777777,n=e/t;let a=e,r=t;n>s?a=t*s:r=e/s,i.left=a/-2,i.right=a/2,i.top=r/2,i.bottom=r/-2,i.updateProjectionMatrix()}function ti(){let e="transferControlToOffscreen"in document.createElement("canvas");if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){const s=navigator.userAgent.match(/version\/(\d+)/i);e=(s?parseInt(s[1]):0)>=17}return e}function ii(i,e,t=!0,s=!1){i.renderOrder=-e;const n=i.material;Array.isArray(n)?n.forEach(a=>{a.colorWrite=t,a.depthWrite=s,a.stencilWrite=!0,a.stencilRef=e,a.stencilFunc=p.AlwaysStencilFunc,a.stencilFail=p.ReplaceStencilOp,a.stencilZFail=p.ReplaceStencilOp,a.stencilZPass=p.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=p.AlwaysStencilFunc,n.stencilFail=p.ReplaceStencilOp,n.stencilZFail=p.ReplaceStencilOp,n.stencilZPass=p.ReplaceStencilOp)}function si(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,n.stencilFail=p.KeepStencilOp,n.stencilZFail=p.KeepStencilOp,n.stencilZPass=p.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,s.stencilFail=p.KeepStencilOp,s.stencilZFail=p.KeepStencilOp,s.stencilZPass=p.KeepStencilOp)}function ni(i){i.blending=p.NormalBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ri(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}function ai(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.DstColorFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function oi(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.OneMinusDstColorFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}let Oe=[];function it(i,e,t=!0){B.renderer=e.renderer;const s=[];s.push({type:"boolean",prop:"Enabled",value:i.enabled});let n=(r,o)=>{console.log("Default Handle Pass:",r,o)};if(i.name==="EffectPass")i.effects.forEach(r=>{r.uniforms.size>0&&r.uniforms.forEach((o,l)=>{if(l==="map")return;const d=`${r.name.replace("Effect","")} ${l}`;if(o.value===null&&t)s.push({prop:l,title:d,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,u=B.renderToBlob(h);s.push({prop:l,title:d,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof o.value=="number"?s.push({prop:l,title:d,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:l,title:d,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:l,title:d,type:"boolean",value:o.value})})}),n=(r,o)=>{i.effects.forEach(l=>{l.uniforms.size>0&&l.uniforms.forEach((d,h)=>{h===r&&(d.value=o)})})};else if(i.name==="ShaderPass"){const r=i.fullscreenMaterial;for(const o in r.uniforms){if(o==="inputBuffer"||o==="map")continue;const l=r.uniforms[o],d=`${r.name.replace("Material","")} ${o}`;if(l.value===null&&t)s.push({title:d,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(l.value.isTexture&&t){const h=l.value,u=B.renderToBlob(h);s.push({title:d,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof l.value=="number"?s.push({title:d,prop:o,type:"number",value:l.value,step:.01}):typeof l.value=="string"?s.push({title:d,prop:o,type:"string",value:l.value}):typeof l.value=="boolean"&&s.push({title:d,prop:o,type:"boolean",value:l.value})}n=(o,l)=>{const d=r.uniforms[o];d.value=l}}else return;const a=`${i.name}: ${i.scene.name}`;e.addGroup({title:a,items:s,onUpdate:(r,o)=>{r==="Enabled"?i.enabled=o:n(r,o)}}),Oe.push(a)}function ci(i,e){i.passes.forEach(t=>{it(t,e)})}function li(i){Oe.forEach(e=>{i.removeGroup(e)}),Oe=[]}function di(i,e,t,s=1024){return new Promise(n=>{const a=e.aspect,r=e.fov,o=e.rotation.clone(),l=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const d=new p.WebGLRenderTarget(s,s,{format:p.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=d,J(i,d,e,"nx",t,s).then(()=>{J(i,d,e,"ny",t,s).then(()=>{J(i,d,e,"nz",t,s).then(()=>{J(i,d,e,"px",t,s).then(()=>{J(i,d,e,"py",t,s).then(()=>{J(i,d,e,"pz",t,s).then(()=>{e.aspect=a,e.fov=r,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=l,d.dispose(),n()})})})})})})})}function J(i,e,t,s,n,a){return new Promise(r=>{const o=Math.PI/2;switch(s){case"nx":t.rotation.set(0,-o,0);break;case"ny":t.rotation.set(-o,0,Math.PI);break;case"nz":t.rotation.set(0,0,0);break;case"px":t.rotation.set(0,o,0);break;case"py":t.rotation.set(o,0,Math.PI);break;case"pz":t.rotation.set(0,Math.PI,0);break}t.updateMatrixWorld(),n.render();const l=new Uint8Array(a*a*4);i.readRenderTargetPixels(e,0,0,a,a,l);const d=document.createElement("canvas");d.width=d.height=a;const h=d.getContext("2d"),u=h.createImageData(a,a);u.data.set(l),h.putImageData(u,0,0);const m=document.createElement("canvas");m.width=m.height=a;const f=m.getContext("2d");f.translate(0,a),f.scale(1,-1),f.drawImage(d,0,0);const y=m.toDataURL("image/png"),g=document.createElement("a");g.href=y,g.download=`${t.name}_${s}.png`,document.body.appendChild(g),g.click(),g.remove(),r()})}const X=Ie(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),hi=Ie(["clientX","clientY","deltaX","deltaY","deltaMode"]),ui=Ie(["ctrlKey","metaKey","shiftKey","keyCode"]);function pi(i,e){i.preventDefault(),hi(i,e)}function mi(i){i.preventDefault()}function fi(i,e,t){for(const s of e)t[s]=i[s]}function Ie(i){return function(t,s){const n={type:t.type};fi(t,i,n),s(n)}}function Ce(i,e){const t=[],s={type:i.type,touches:t};for(let n=0;n<i.touches.length;++n){const a=i.touches[n];t.push({pageX:a.pageX,pageY:a.pageY})}e(s)}const gi={37:!0,38:!0,39:!0,40:!0};function vi(i,e){const{keyCode:t}=i;gi[t]&&(i.preventDefault(),ui(i,e))}const bi={contextmenu:mi,mousedown:X,mousemove:X,mouseup:X,pointerdown:X,pointermove:X,pointerup:X,touchstart:Ce,touchmove:Ce,touchend:Ce,wheel:pi,keydown:vi};let yi=0;class Ci{id;worker;constructor(e,t,s){this.id=yi++,this.worker=t;const n=r=>{this.worker.postMessage({type:"event",id:this.id,data:r})};t.postMessage({type:"makeProxy",id:this.id});for(const[r,o]of Object.entries(s))e.addEventListener(r,l=>{o(l,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class st extends p.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=oe,e.stopPropagation=oe,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Si{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new st;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class xi{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1};onUpdateCallback;playing=!1;rafID=-1;constructor(e,t=!1){this.settings.dev=e,this.settings.editor=t}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(){return new Promise(e=>{Xe(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};addComponent(e,t){this.components.set(e,t)}get debugEnabled(){return this.settings.dev}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e}}class Pe{name;debug;editor;broadcastChannel;onMessageHandler;constructor(e,t=!1,s=!1){this.name=e,this.debug=t,this.editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){this.broadcastChannel?.removeEventListener("message",this.onMessageHandler),this.broadcastChannel?.close()}send(e){if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{this.broadcastChannel?.postMessage(e)}catch(s){console.log("Hermes - Error sending message:"),console.log(s),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}function wi(i,e,t,s,n){const a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*s+i*i*i*n}function Mi(i,e,t){if(i.type!=="bezier"||i.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[s,n]=i.handles,a=(t-i.position)/(e.position-i.position);return wi(a,i.value,i.value+s,e.value+n,e.value)}class Ei extends Pe{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e=!1,t=!1){super("RemoteTheatre",e,t)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(e,t){return this.project=x.getProject(e,{state:t}),new Promise((s,n)=>{this.project?.ready.then(()=>{if(t){const a=t.sheetsById;for(const r in a)this.sheet(r)}s()}).catch(()=>n())})}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=>{this.sheet(e,s)?.sequence.play(t).then(a=>n(a)),this.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.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 l=`${this.getSheetInstance(e,a)}_${t}`;let d=this.sheetObjects.get(l),h=s;d!==void 0&&(h={...s,...d.value}),d=r.object(t,h,{reconfigure:!0}),this.sheetObjects.set(l,d),this.sheetObjectCBs.set(l,n!==void 0?n:oe);function u(f,y,g){if(typeof g=="object")if(Ye(g))f[y]={r:g.r,g:g.g,b:g.b,a:g.a};else for(const S in g){const O=g[S];typeof O=="object"&&u(g,S,O)}}const m=d.onValuesChange(f=>{const y=this.sheetObjectCBs.get(l);if(this.editor){for(const g in f){const S=f[g];typeof S=="object"&&u(f,g,S)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:l,values:f}}),y&&y(f)}else y&&y(f)});return this.sheetObjectUnsubscribe.set(l,m),d}getSheetObjectKeyframes(e,t,s){const n=this.sheet(e);if(n===void 0)return[];const a=`${e}_${t}`,r=this.sheetObjects.get(a);return r===void 0?[]:n.sequence.__experimental_getKeyframes(r.props[s])}getSheetObjectVectors(e,t){const s=this.sheet(e);if(s===void 0)return[];const n=`${e}_${t}`,a=this.sheetObjects.get(n);if(a===void 0)return[];const r=[],o=s.sequence.__experimental_getKeyframes(a.props.x),l=s.sequence.__experimental_getKeyframes(a.props.y),d=s.sequence.__experimental_getKeyframes(a.props.z),h=new Set;return o.forEach(m=>h.add(m.position)),l.forEach(m=>h.add(m.position)),d.forEach(m=>h.add(m.position)),Array.from(h).sort((m,f)=>m-f).forEach(m=>{const f=(y,g)=>{const S=y.find((T,R)=>T.position<=g&&(y[R+1]?.position||1/0)>g),O=y.find(T=>T.position>g);if(!S)return O?.value||0;if(!O||S.position===g)return S.value;if(S.type==="bezier")return Mi(S,O,g);const M=(g-S.position)/(O.position-S.position);return S.value+M*(O.value-S.value)};r.push({position:m,x:f(o,m),y:f(l,m),z:f(d,m)})}),r}update(e){}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){let t;switch(e.event){case"setSheet":t=this.sheets.get(e.data.sheet),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet: ${e.data.sheet}`,t);break;case"setSheetObject":t=this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet Object: ${e.data.sheet}, ${e.data.key}: ${e.data.sheet}_${e.data.key}`,t);break;case"updateSheetObject":t=this.sheets.get(e.data.sheet),t!==void 0&&t.sequence.pause(),t=this.sheetObjectCBs.get(e.data.sheetObject),t!==void 0?t(e.data.values):console.log(`Hermes - Can't update Sheet Object: ${e.data.sheetObject}, ${e.data.sheet}`,t);break;case"updateTimeline":t=this.sheets.get(e.data.sheet),t!==void 0?t.sequence.position=e.data.position:console.log(`Hermes - Can't update sheet position: ${e.data.sheet}, ${e.data.position}`);break}}handleEditor(e){switch(e.event){case"playSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break}}getSheetNames(){const e=[];return this.sheets.forEach((t,s)=>{e.push(s)}),e}handleEditorApp(){if(this.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(n=>{n.length<1||n.forEach(a=>{let r=a.address.sheetId,o="setSheet",l={};switch(a.type){case"Theatre_Sheet_PublicAPI":o="setSheet",l={sheet:a.address.sheetId},this.activeSheet=this.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",r+=`_${a.address.objectKey}`,l={id:r,sheet:a.address.sheetId,key:a.address.objectKey},this.activeSheet=this.sheets.get(a.address.sheetId);break}this.send({event:o,target:"app",data:l})})});let e=-1;const t=()=>{if(this.activeSheet!==void 0&&e!==this.activeSheet.sequence.position){e=this.activeSheet.sequence.position;const n=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:e,sheet:n.address.sheetId}})}},s=()=>{t(),requestAnimationFrame(s)};t(),s()}else this.studio?.ui.hide()}}function Ai(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 W(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(W(t))}),e}function Ge(i){return{src:i.image?.src??"",offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}}const Fe={src:"",offset:[0,0],repeat:[1,1]};function Oi(i){const e={};for(const t in i){const s=i[t];if(s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")){const a=s.value;a==null?e[t]={value:Fe}:a.isTexture?e[t]={value:Ge(a)}:e[t]={value:a}}else s==null?e[t]=Fe:s.isTexture?e[t]=Ge(s):e[t]=s}return e}function Ri(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Q(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Ri(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":if(n!==null)if(n.isTexture)e[t]={src:B.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]};else if(n.isUniformNode){const a=n.value;e[t]={__isUniform:!0,value:a?.isTexture?{src:B.renderToBlob(a),offset:[a.offset.x,a.offset.y],repeat:[a.repeat.x,a.repeat.y]}:a}}else t==="uniforms"?e[t]=Oi(n):t.search("Node")>-1||(e[t]=n);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(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 Se(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(Q(a))}),e.material=n}else e.material=Q(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Q(a))}),e.material=n}else e.material=Q(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Q(a))}),e.material=n}else e.material=Q(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 Ti(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 Ii(i,e){for(const t in e)i[t]=e[t]}function I(i,e,t){if(i===void 0){console.log(`Hermes - Can't set props: ${e}`,t);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?Ii(r,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function nt(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new p.Texture(s);n.wrapS=p.RepeatWrapping,n.wrapT=p.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}var w=(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.SET_OBJECT="ToolEvents::setObject",i.CLEAR_OBJECT="ToolEvents::clearObject",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.ADD_RENDERER="ToolEvents::addRenderer",i.UPDATE_RENDERER="ToolEvents::updateRenderer",i))(w||{});class Pi extends Pe{name;canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;_listeners={};constructor(e,t=!1,s=!1){super("RemoteThree",t,s),this.name=e}dispose(){this.scenes.forEach(e=>{U(e)}),this.scenes.clear(),this.scene&&U(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const n=s[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){const n={...e,target:this},a=s.slice(0);for(let r=0,o=a.length;r<o;r++)a[r].call(this,n)}}getObjectByUUID(e){const t=e.split(".")[0],s=this.scenes.get(t);if(s!==void 0)return s.getObjectByProperty("uuid",e)}getObject(e){if(!this.debug)return;this.renderer!==void 0&&(B.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){this.renderer!==void 0&&(B.renderer=this.renderer);const t=Se(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const a=this.getObjectByUUID(e);if(a)try{n!==void 0?Ti(a,n)[t](s):a[t](s)}catch(r){console.log("Hermes - Error requesting method:",e,t,s),console.log(r)}}updateObject(e,t,s){this.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}onUpdateObject(e,t,s){const n=this.getObjectByUUID(e);n&&I(n,t,s)}onCreateTexture(e,t,s){const n=this.getObjectByUUID(e);if(n){const a=r=>{const o=t.split(".");switch(o.length){case 1:n[o[0]]=r;break;case 2:n[o[0]][o[1]]=r;break;case 3:n[o[0]][o[1]][o[2]]=r;break;case 4:n[o[0]][o[1]][o[2]][o[3]]=r;break;case 5:n[o[0]][o[1]][o[2]][o[3]][o[4]]=r;break}n.material.needsUpdate=!0};s.src.length>0?nt(s.src).then(r=>{r.offset.set(s.offset[0],s.offset[1]),r.repeat.set(s.repeat[0],s.repeat[1]),a(r)}):a(null)}}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}addSplineCurve(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addSplineObject(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e)})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.debug)return;const s=`#${e.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:e.autoClearColor,outputColorSpace:e.outputColorSpace,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.debug))return;ne(),ee(e);const t=W(e);this.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.debug)return;const t=this.scenes.get(e);if(t!==void 0){const s=W(t);this.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.debug))return;const t=W(e);this.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scene!==void 0&&this.scene.uuid.search(e)>-1?this.scene:(this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t)}setScene(e){if(e===void 0||(this.scene=e,!this.debug))return;this.renderer!==void 0&&(B.renderer=this.renderer),ne(),ee(e);const t=W(e);this.send({event:"setScene",target:"editor",data:t})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(e){if(!this.debug)return;const t=Se(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug)return;const t=Se(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:W(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,b.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(t=>{ne(),ee(t),this.send({event:"addScene",target:"editor",data:W(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(B.renderer=this.renderer),ne(),ee(this.scene),this.send({event:"setScene",target:"editor",data:W(this.scene)}));break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:e.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:e.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:e.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:e.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:e.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:e.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:e.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:e.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:e.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:e.data})}}messageHandler(e){const t=e.data;if(t.event==="updateObject"){this.onUpdateObject(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="createTexture"){this.onCreateTexture(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="requestSize"){t.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(s=>{s.resize!==void 0&&s.resize(t.data.width,t.data.height)});return}t.target==="app"?this.handleApp(t):this.handleEditor(t)}addRT(e,t=!0,s){if(!this.renderer)return;let n;this.renderer instanceof b.WebGPURenderer?n=new b.RenderTarget(32,32,s):n=new b.WebGLRenderTarget(32,32,s),n.texture.name=e,this.renderTargets.set(e,n),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((a,r)=>{this.renderTargetsResize.get(r)&&a.setSize(e*s,t*s)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(z(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}}function ke(i){return i.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):c.jsx("button",{children:i.title})}const ki=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Di=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.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
31
14
  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
32
- C11,8.22,10.74,8,10.43,8z`})});function ci(i){return d.jsx("li",{className:`reorder-item ${i.draggingIndex===i.index?"dragging":""}`,draggable:!0,onDragStart:()=>i.onDragStart(i.index),onDragOver:e=>{e.preventDefault(),i.onDragOver(i.index)},onDragEnd:i.onDragEnd,children:d.jsxs("div",{children:[qs,d.jsx("span",{children:i.title}),d.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:Ys})]})})}function hi(i){const[e,t]=b.useState(!1),[s,n]=b.useState(i.options),[r,a]=b.useState(null),o=m=>{i.onDragComplete(m),n(m)},l=m=>{const C=[...s];C.splice(m,1),o(C)},c=m=>{a(m)},h=m=>{if(r===m||r===null)return;const C=[...s],_=C.splice(r,1)[0];C.splice(m,0,_),a(m),n(C)},u=()=>{i.onDragComplete(s),a(null)};let p="dropdown draggable";return i.subdropdown&&(p+=" subdropdown"),d.jsxs("div",{className:p,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[d.jsx(xt,{title:i.title}),d.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((m,C)=>d.jsx(ci,{title:m,index:C,draggingIndex:r,onDelete:l,onDragStart:c,onDragOver:h,onDragEnd:u},m))})]})}function di(i){const[e,t]=b.useState(!1),s=[];i.options.map((r,a)=>{i.onSelect!==void 0&&(r.onSelect=i.onSelect),s.push(d.jsx(ui,{option:r},a))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),d.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[d.jsx(xt,{title:i.title}),d.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function ui(i){const{option:e}=i,[t,s]=b.useState("");let n;switch(e.type){case"draggable":n=d.jsx(hi,{title:e.title,options:e.value,onDragComplete:r=>{e.onDragComplete!==void 0&&e.onDragComplete(r)},subdropdown:!0});break;case"dropdown":n=d.jsx(di,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=d.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 d.jsx("li",{className:t===e.title?"selected":"",children:n},W())}function Ae(i){const[e,t]=b.useState(i.open!==void 0?i.open:!1),[s,n]=b.useState(i.visible!==void 0?i.visible:!1),r=!e||i.children===void 0,a=()=>{i.three.dispatchEvent({type:L.REMOVE_SCENE,value:i.scene})};return d.jsxs("div",{className:`accordion ${r?"hide":""}`,children:[d.jsxs("button",{className:"toggle",onClick:()=>{const o=!e;i.onToggle!==void 0&&i.onToggle(o),t(o)},children:[d.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),d.jsx("p",{className:"label",children:He(i.label)})]}),i.onRefresh?d.jsxs(d.Fragment,{children:[d.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const l=i.three.getScene(i.scene.uuid);if(l){const c=!l.visible;l.visible=c,n(c)}}}),d.jsx("button",{className:"refresh",onClick:i.onRefresh}),d.jsx("button",{className:"remove",onClick:a})]}):null,i.button,d.jsx("div",{className:e?"open":"",children:d.jsx("div",{children:i.children})})]})}function Ot(i){if(i.child===void 0)return console.log("Hermes - No child attached"),null;const e=b.useRef(null),[t,s]=b.useState(!1),n=i.child.children.length>0,r=[];return i.child.children.length>0&&i.child.children.map((a,o)=>{r.push(d.jsx(Ot,{child:a,three:i.three},o))}),b.useEffect(()=>{if(i.child){const a=i.child.uuid.split(".")[0],o=i.three.getScene(a);if(o!==null)try{const l=o.getObjectByProperty("uuid",i.child.uuid);l!==void 0?e.current.style.opacity=l.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(l){console.log("Error looking for child:",l),console.log(i.child),console.log(i.three.scenes),console.log(o)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${a} with child UUID: ${i.child.uuid}`,i.three.scenes,i.three.scene,o)}},[t]),d.jsxs("div",{className:"childObject",children:[d.jsxs("div",{className:"child",children:[n?d.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,d.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0?(i.three.getObject(i.child.uuid),!t&&n&&s(!0)):console.log("Hermes - No child attached...")},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),d.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const a=i.three.getScene(i.child.uuid);if(a!==null){const o=a.getObjectByProperty("uuid",i.child.uuid);if(o!==void 0){const l="visible",c=!o.visible;e.current.style.opacity=c?"1":"0.25",i.three.updateObject(i.child.uuid,l,c),V(o,l,c)}else console.log(`Hermes - Couldn't find object: ${i.child.uuid}`,a)}else console.log(`Hermes - Couldn't find object in scene: ${i.child.uuid}, ${i.child.name}`)}}}),d.jsx("div",{className:`icon ${zs(i.child)}`})]}),d.jsx("div",{className:t?"open":"",children:d.jsx("div",{className:"container",children:r})})]})}function $e(i){const e=[];return i.child?.children.map((t,s)=>{e.push(d.jsx(Ot,{child:t,scene:i.scene,three:i.three},s))}),d.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function Fe(i){const[e,t]=b.useState(i.defaultValue);return b.useEffect(()=>{let s=!1,n=-1,r=0,a=i.defaultValue,o=!1;const l=m=>{o=m.ctrlKey},c=m=>{s=!0,r=Number(i.input.current?.value),n=m.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=m=>{if(!s)return;const C=i.step!==void 0?i.step:1,_=(m.clientX-n)*C*(o?10:1);a=Number((r+_).toFixed(4)),i.min!==void 0&&(a=Math.max(a,i.min)),i.max!==void 0&&(a=Math.min(a,i.max)),i.onChange!==void 0&&i.onChange(a),t(a)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},p=m=>{const C=Number(m.target.value);i.onChange!==void 0&&i.onChange(C),t(C)};return i.label.current?.addEventListener("mousedown",c,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",p),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{i.label.current?.removeEventListener("mousedown",c),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",p),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function ve(i){const e=b.useRef(null),t=b.useRef(null),[s,n]=b.useState(i.value);return Fe({label:i.labelRef,input:e,sliderRef:t,defaultValue:s,min:i.min,max:i.max,step:i.step,onChange:r=>{n(r),i.onChange!==void 0&&i.onChange(i.prop,r)}}),d.jsxs(d.Fragment,{children:[i.type==="number"&&d.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,name:W(),onChange:r=>{if(n(r.target.value),r.target.value.length===0)return;const a=Number(r.target.value);isNaN(a)||i.onChange!==void 0&&i.onChange(i.prop,a)}}),i.type==="range"&&d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:W(),onChange:r=>{if(r.target.value.length===0)return;const a=Number(r.target.value);isNaN(a)||(n(a),i.onChange!==void 0&&i.onChange(i.prop,a))}}),d.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,name:W(),onChange:ze})]})]})}function $s(i){const e=b.useRef(null),t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),r=b.useRef(null),a=b.useRef(null),o=b.useRef(null),l=b.useRef(null),c=b.useRef(null),h=b.useRef(null),[u,p]=b.useState(i.value.x),[m,C]=b.useState(i.value.y),[_,E]=b.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))}),[g,y]=b.useState(!1);Fe({label:o,input:e,defaultValue:u,min:_.min,max:_.max,step:.01,onChange:A=>{p(A),i.onChange({target:{value:{x:A,y:m}}})}}),Fe({label:l,input:t,defaultValue:m,min:_.min,max:_.max,step:.01,onChange:A=>{C(A),i.onChange({target:{value:{x:u,y:A}}})}}),Fe({label:c,input:s,defaultValue:_.min,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:A,max:_.max})}}),Fe({label:h,input:n,defaultValue:_.max,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:_.min,max:A})}});function x(){g||(window.addEventListener("mousemove",S),window.addEventListener("mouseup",O),y(!0))}function O(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",O),y(!1)}function S(A){const j=r.current.getBoundingClientRect(),J=de(0,99,A.clientX-j.left)/99,oe=1-de(0,99,A.clientY-j.top)/99,ue=X(Re(_.min,_.max,J),3),_e=X(Re(_.min,_.max,oe),3);i.onChange({target:{value:{x:ue,y:_e}}}),p(ue),C(_e)}function T(){const A=Number(s.current.value);E({min:A,max:_.max}),u<A&&p(de(A,_.max,u)),m<A&&C(de(A,_.max,m))}function M(){const A=Number(n.current.value);E({min:_.min,max:A}),u>A&&p(de(_.min,A,u)),m>A&&C(de(_.min,A,m))}b.useEffect(()=>{a.current.style.left=`${Xe(_.min,_.max,u)*100}%`,a.current.style.top=`${(1-Xe(_.min,_.max,m))*100}%`},[_,u,m]);const U=i.step!==void 0?i.step:.01;return d.jsxs("div",{className:"vector2",children:[d.jsxs("div",{className:"fields",children:[d.jsxs("div",{children:[d.jsx("span",{ref:o,children:"X"}),d.jsx("input",{ref:e,type:"number",value:u,min:_.min,max:_.max,step:U,name:W(),onChange:A=>{if(p(A.target.value),A.target.value.length===0)return;const j=Number(A.target.value);isNaN(j)||(i.onChange({target:{value:{x:j,y:m}}}),j<_.min&&E({min:j,max:_.max}))}})]}),d.jsxs("div",{children:[d.jsx("span",{ref:l,children:"Y"}),d.jsx("input",{ref:t,type:"number",value:m,min:_.min,max:_.max,step:U,name:W(),onChange:A=>{if(C(A.target.value),A.target.value.length===0)return;const j=Number(A.target.value);isNaN(j)||(i.onChange({target:{value:{x:u,y:j}}}),j>_.max&&E({min:_.min,max:j}))}})]}),d.jsxs("div",{children:[d.jsx("span",{ref:c,children:"Min"}),d.jsx("input",{ref:s,type:"number",value:_.min,step:U,name:W(),onChange:T})]}),d.jsxs("div",{children:[d.jsx("span",{ref:h,children:"Max"}),d.jsx("input",{ref:n,type:"number",value:_.max,step:U,name:W(),onChange:M})]})]}),d.jsxs("div",{className:"input",ref:r,onMouseDown:x,onMouseUp:O,children:[d.jsx("div",{className:"x"}),d.jsx("div",{className:"y"}),d.jsx("div",{className:"pt",ref:a})]})]})}function kt(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,r=[];if(t){const a=b.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(l=>{const c=b.useRef(null);r.push(d.jsxs("div",{children:[d.jsx("span",{ref:c,children:l.substring(1).toUpperCase()}),d.jsx(ve,{value:$.radToDeg(a[l]),type:"number",prop:l,step:.1,labelRef:c,onChange:(h,u)=>{a[h]=$.degToRad(u),i.onChange({target:{value:a}})}})]},l))})}else if(e){const a=b.useMemo(()=>i.value,[]),o=(c,h)=>{a[c]=h,i.onChange({target:{value:a}})};["x","y","z"].forEach(c=>{const h=b.useRef(null);r.push(d.jsxs("div",{children:[d.jsx("label",{ref:h,children:c.toUpperCase()}),d.jsx(ve,{value:a[c],type:"number",prop:c,step:n,labelRef:h,onChange:o})]},c))})}else if(s){const a=b.useMemo(()=>i.value,[]),o=(l,c)=>{const h=Number(l);a.elements[h]=c,i.onChange({target:{value:a}})};for(let l=0;l<9;l++){const c=b.useRef(null);r.push(d.jsxs("div",{children:[d.jsx("label",{ref:c,children:l+1}),d.jsx(ve,{value:a.elements[l],type:"number",prop:l.toString(),step:n,labelRef:c,onChange:o})]},l.toString()))}}return d.jsx("div",{className:"grid3",children:r},Math.random().toString())}function Zs(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=b.useMemo(()=>i.value,[]),r=(o,l)=>{n[o]=l,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const l=b.useRef(null);s.push(d.jsxs("div",{children:[d.jsx("label",{ref:l,children:o.toUpperCase()}),d.jsx(ve,{value:n[o],type:"number",prop:o,step:t,labelRef:l,onChange:r})]},o))})}else{const n=b.useMemo(()=>i.value,[]),r=(a,o)=>{const l=Number(a);n.elements[l]=o,i.onChange({target:{value:n}})};for(let a=0;a<16;a++){const o=b.useRef(null);s.push(d.jsxs("div",{children:[d.jsx("span",{ref:o,children:a+1}),d.jsx(ve,{value:n.elements[a],type:"number",prop:a.toString(),step:t,labelRef:o,onChange:r})]},a.toString()))}}return d.jsx("div",{className:"grid4",children:s})}function Ks(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 Xs(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 et(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 pi(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 Qs(){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(r){e(r.target.result)},n.readAsDataURL(s)}}),i.click()})}const Js=[{title:"Front",value:v.FrontSide},{title:"Back",value:v.BackSide},{title:"Double",value:v.DoubleSide}],en=[{title:"No Blending",value:v.NoBlending},{title:"Normal",value:v.NormalBlending},{title:"Additive",value:v.AdditiveBlending},{title:"Subtractive",value:v.SubtractiveBlending},{title:"Multiply",value:v.MultiplyBlending},{title:"Custom",value:v.CustomBlending}],tn=[{title:"Add",value:v.AddEquation},{title:"Subtract",value:v.SubtractEquation},{title:"Reverse Subtract",value:v.ReverseSubtractEquation},{title:"Min",value:v.MinEquation},{title:"Max",value:v.MaxEquation}],sn=[{title:"Zero",value:v.ZeroFactor},{title:"One",value:v.OneFactor},{title:"Src Color",value:v.SrcColorFactor},{title:"One Minus Src Color",value:v.OneMinusSrcColorFactor},{title:"Src Alpha",value:v.SrcAlphaFactor},{title:"One Minus Src Alpha",value:v.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:v.DstAlphaFactor},{title:"One Minus Dst Alpha",value:v.OneMinusDstAlphaFactor},{title:"Dst Color",value:v.DstColorFactor},{title:"One Minus Dst Color",value:v.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:v.SrcAlphaSaturateFactor},{title:"Constant Color",value:v.ConstantColorFactor},{title:"One Minus Constant Color",value:v.OneMinusConstantColorFactor},{title:"Constant Alpha",value:v.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:v.OneMinusConstantAlphaFactor}],nn=[{title:"Zero",value:v.ZeroFactor},{title:"One",value:v.OneFactor},{title:"Src Color",value:v.SrcColorFactor},{title:"One Minus Src Color",value:v.OneMinusSrcColorFactor},{title:"Src Alpha",value:v.SrcAlphaFactor},{title:"One Minus Src Alpha",value:v.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:v.DstAlphaFactor},{title:"One Minus Dst Alpha",value:v.OneMinusDstAlphaFactor},{title:"Dst Color",value:v.DstColorFactor},{title:"One Minus Dst Color",value:v.OneMinusDstColorFactor},{title:"Constant Color",value:v.ConstantColorFactor},{title:"One Minus Constant Color",value:v.OneMinusConstantColorFactor},{title:"Constant Alpha",value:v.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:v.OneMinusConstantAlphaFactor}];function Pe(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function rn(i,e,t,s){return{type:"boolean",title:et(i),prop:i,value:e,needsUpdate:!0,onChange:(n,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const a=s.getScene(t.uuid);if(a!==null){const o=a.getObjectByProperty("uuid",t.uuid);V(o,`material.${i}`,r)}}}}function an(i,e,t,s){const n={type:"number",title:et(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(r,a)=>{s.updateObject(t.uuid,`material.${i}`,a),s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);V(l,`material.${i}`,a)}}};switch(i){case"blending":Pe(n,en);break;case"blendDst":Pe(n,nn);break;case"blendEquation":Pe(n,tn);break;case"blendSrc":Pe(n,sn);break;case"side":Pe(n,Js);break}return pi(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 on(i,e,t,s){const n={type:"string",title:et(i),prop:i,value:e,needsUpdate:!0,onChange:(a,o)=>{s.updateObject(t.uuid,`material.${i}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);V(c,`material.${i}`,o)}},onKeyDown:a=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.type="field",n.disabled=!1,n.latest=n.value,n.onChange=(a,o)=>{n.latest=o,s.updateObject(t.uuid,`material.${i}`,o);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);V(c,`material.${i}`,o)}},n.onKeyDown=a=>{if(a.key==="Enter"&&(a.altKey||a.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);V(l,"material.needsUpdate",!0)}}}),n}function ln(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function cn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function hn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Ct(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Te(i,e,t,s,n="",r=!1){const a=et(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,l=typeof e;if(l==="object"&&e!==null&&e.__isUniform===!0)return Te(`${i}.value`,e.value,t,s,n,r);if(l==="boolean"||l==="string")return{title:a,prop:o,type:l,value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};if(l==="number"){const c={title:a,prop:o,type:"number",value:e,step:.01,disabled:r,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);V(m,`material.${o}`,u)}}};return pi(a)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:a,prop:o,type:"color",value:e,disabled:r,onChange:(c,h)=>{const u=new v.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);V(m,`material.${o}`,u)}}};if(Array.isArray(e)){const c=[];for(const h in e){const u=e[h],p=`[${h.toString()}]`;if(u.value!==void 0){const m=Te(`${p}.value`,u.value,t,s,o,r);m!==void 0&&c.push(m)}else{const m=Te(p,u,t,s,o,r);m!==void 0&&c.push(m)}}if(c.length>0)return Ct(c),{title:a,items:c}}else{if(ln(e))return{title:a,prop:o,type:"vector2",value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};if(cn(e))return{title:a,prop:o,type:"grid3",value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};if(hn(e))return{title:a,prop:o,type:"grid4",value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};if(e.isEuler)return{title:a,prop:o,type:"euler",value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};if(e.src!==void 0)return{title:a,type:"image",value:e,disabled:r,onChange:(c,h)=>{const u=Xs(i),p=n.length>0?`${n}.${u}`:u;s.createTexture(t.uuid,`material.${p}`,h);const m=s.getScene(t.uuid);if(m!==null){const C=m.getObjectByProperty("uuid",t.uuid);if(C!==void 0){const _=E=>{const g=C.material,y=p.split(".");switch(y.length){case 1:g[y[0]]=E;break;case 2:g[y[0]][y[1]]=E;break;case 3:g[y[0]][y[1]][y[2]]=E;break;case 4:g[y[0]][y[1]][y[2]][y[3]]=E;break;case 5:g[y[0]][y[1]][y[2]][y[3]][y[4]]=E;break}g.needsUpdate=!0};h.src.length>0?li(h.src).then(E=>{E.offset.set(h.offset[0],h.offset[1]),E.repeat.set(h.repeat[0],h.repeat[1]),_(E)}):_(null)}}}};if(e.elements!==void 0)return{title:a,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:r,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",t.uuid);V(p,`material.${o}`,h)}}};{const c=[],h=i==="defines"||i==="extensions";try{for(const u in e){const p=e[u];if(p!==void 0)if(p.value!==void 0){const m=Te(`${u}.value`,p.value,t,s,o,h);m!==void 0&&c.push(m)}else{const m=Te(u,p,t,s,o,h);m!==void 0&&c.push(m)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(c.length>0)return Ct(c),{title:a,items:c}}}}}function Nt(i,e,t){const s=[];for(const n in i){if(!Ks(n)||n.search("Node")>-1||i[n]instanceof w.ComputeNode)continue;const r=typeof i[n],a=i[n];if(r==="boolean")s.push(rn(n,a,e,t));else if(r==="number")s.push(an(n,a,e,t));else if(r==="string")s.push(on(n,a,e,t));else if(r==="object"){const o=Te(n,a,e,t);o!==void 0&&s.push(o)}else a!==void 0&&console.log("Hermes - Other Material Prop Type:",n,r,a)}return Ct(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 r=n.getObjectByProperty("uuid",e.uuid);V(r,"material.needsUpdate",!0)}}}),s}function dn(i,e){function t(){return`${e.name}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function r(o){localStorage.setItem(t(),o?"open":"closed")}const a=i.material;if(Array.isArray(a)){const o=[],l=a.length;for(let c=0;c<l;c++)o.push(d.jsx(te,{three:e,title:`Material ${c}`,items:Nt(a[c],i,e)},`Material ${c}`));return d.jsx(d.Fragment,{children:o})}else return d.jsx(te,{three:e,title:"Material",items:Nt(a,i,e),expanded:n,onToggle:o=>{r(o)}})}const Ft="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 un(i){const e=i.step!==void 0?i.step:.01,t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),r=b.useRef(null),a=b.useRef(null),[o]=b.useState(i.value),[l,c]=b.useState(i.value.offset[0]),[h,u]=b.useState(i.value.offset[1]),[p,m]=b.useState(i.value.repeat[0]),[C,_]=b.useState(i.value.repeat[1]);function E(y,x,O,S,T){if(i.onChange!==void 0){const M=i.prop!==void 0?i.prop:i.title;i.onChange(M,{src:y,offset:[x,O],repeat:[S,T]})}}function g(y){const x=t.current.src,O=y.target.value;switch(y.target){case s.current:c(O),E(x,O,h,p,C);break;case n.current:u(O),E(x,l,O,p,C);break;case r.current:m(O),E(x,l,h,O,C);break;case a.current:_(O),E(x,l,h,p,O);break}}return d.jsxs("div",{className:"imageField",children:[d.jsx("img",{alt:i.title,ref:t,onClick:()=>{Qs().then(y=>{t.current.src=y,E(y,l,h,p,C)})},src:o.src.length>0?o.src:Ft}),d.jsxs("div",{className:"fields",children:[d.jsxs("div",{children:[d.jsx("span",{children:"Offset:"}),d.jsx("input",{ref:s,type:"number",value:l,step:e,name:W(),onChange:g}),d.jsx("input",{ref:n,type:"number",value:h,step:e,name:W(),onChange:g})]}),d.jsxs("div",{children:[d.jsx("span",{children:"Repeat:"}),d.jsx("input",{ref:r,type:"number",value:p,step:e,name:W(),onChange:g}),d.jsx("input",{ref:a,type:"number",value:C,step:e,name:W(),onChange:g})]}),d.jsx("button",{onClick:()=>{E("",l,h,p,C),t.current.src=Ft},children:"Clear"})]})]})}function Ze(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=vt(i.value):i.type==="color"&&(e=vt(new v.Color().setStyle(i.value,v.LinearSRGBColorSpace))));const[t,s]=b.useState(e),n=b.useRef(null);b.useEffect(()=>{s(e)},[e]);const r=h=>{let u=h.target.value;if(i.type==="boolean")u=h.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const p=i.options.length;for(let m=0;m<p&&i.options[m].value!==u;m++);}s(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},a={};i.disabled&&(a.opacity=.8);const o=typeof t=="string"?t:String(t??""),l=i.type==="field"||i.type==="string"&&(o.length>100||o.search(`
33
- `)>-1),c=l||i.type==="image"||i.type==="vector2";return d.jsxs("div",{className:`field ${c?"block":""}`,style:a,children:[i.type!=="button"&&d.jsx("span",{ref:n,children:He(i.title)},"fieldLabel"),i.type==="string"&&!l&&d.jsx("input",{type:"text",disabled:i.disabled,onChange:r,value:t,name:W()}),(i.type==="field"||i.type==="string"&&l)&&d.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:r,onKeyDown:h=>{i.onKeyDown!==void 0&&i.onKeyDown(h)},value:t,name:W()}),i.type==="boolean"&&d.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:r,checked:t,name:W()}),i.type==="number"&&d.jsx(ve,{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"&&d.jsx(ve,{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"&&d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:t.toString(),onChange:r,disabled:i.disabled,className:"color",name:W()}),d.jsx("input",{type:"color",value:t,onChange:r,disabled:i.disabled,name:W()})]}),i.type==="button"&&d.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"&&d.jsx(un,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&d.jsx(d.Fragment,{children:d.jsx("select",{onChange:r,disabled:i.disabled,value:t,name:W(),children:i.options?.map((h,u)=>d.jsx("option",{value:h.value,children:He(h.title)},u))})}),i.type==="vector2"&&d.jsx($s,{step:i.step,value:t,min:0,max:1,onChange:r}),i.type==="grid3"&&d.jsx(kt,{step:i.step,value:t,onChange:r}),i.type==="grid4"&&d.jsx(Zs,{step:i.step,value:t,onChange:r}),i.type==="euler"&&d.jsx(kt,{step:i.step,value:t,onChange:r})]})}function pn(i){return"items"in i}class te extends b.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;three;constructor(e){super(e),this.three=e.three,this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(r=>{t.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(a,o)=>{e.onUpdate(a,o)}})});const s=b.createRef(),n=d.jsx(te,{three:this.props.three,ref:s,title:e.title,expanded:e.expanded,items:t},e.title);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(pn(t))e.push(d.jsx(te,{three:this.props.three,title:He(t.title),items:t.items},t.title));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(d.jsx(Ze,{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:(r,a)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(r,a))},onKeyDown:r=>{t.onKeyDown!==void 0&&t.onKeyDown(r)}},t.title))}}),this.subgroupElements.forEach(t=>e.push(t)),d.jsx(Ae,{three:this.props.three,label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class k extends b.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static three;constructor(e){super(e),this.state={lastUpdate:Date.now()},k.instance=this,k.three=e.three,e.three.addEventListener(L.ADD_GROUP,this.addGroup),e.three.addEventListener(L.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){this.props.three.removeEventListener(L.ADD_GROUP,this.addGroup),this.props.three.removeEventListener(L.REMOVE_GROUP,this.removeGroup)}render(){return d.jsx("div",{className:"customGroups",children:k.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:(r,a)=>{this.props.three.updateGroup(t.title,r,a)}})}),k.groups.push(d.jsx(te,{three:this.props.three,title:t.title,items:s},t.title)),k.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=k.groupTitles.length;for(let n=0;n<s;n++)if(t===k.groupTitles[n]){k.groups.splice(n,1),k.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=k.groupTitles.length;for(let a=0;a<t;a++)if(k.groupTitles[a]===e.title)return k.groupsRefs[a];const s=[];e.items.forEach(a=>{s.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:(o,l)=>{e.onUpdate(o,l)}})}),e.subgroups&&e.subgroups.length>0&&e.subgroups.forEach(a=>{const o=[];a.items.forEach(l=>{o.push({type:l.type,prop:l.prop,title:l.title!==void 0?l.title:l.prop,value:l.value,min:l.min,max:l.max,step:l.step,options:l.options,disabled:l.disabled,onChange:(c,h)=>{a.onUpdate(c,h)}})}),s.push({three:k.three,title:a.title,expanded:a.expanded,items:o})});const n=b.createRef(),r=d.jsx(te,{three:k.three,ref:n,title:e.title,expanded:e.expanded,items:s},e.title);return k.groups.push(r),k.groupsRefs.push(n),k.groupTitles.push(e.title),setTimeout(()=>{k.instance?.setState({lastUpdate:Date.now()})},0),n}static removeEditorGroup(e){const t=k.groupTitles.length;for(let s=0;s<t;s++)if(e===k.groupTitles[s]){k.groups.splice(s,1),k.groupTitles.splice(s,1),k.instance?.setState({lastUpdate:Date.now()});return}}static removeAllGroups(){k.groups=[],k.groupTitles=[],k.groupsRefs=[],k.instance?.setState({lastUpdate:Date.now()})}}function jt(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 mn(i,e){function t(){return`${e.name}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function r(o){localStorage.setItem(t(),o?"open":"closed")}const a=[];if(i.perspectiveCameraInfo!==void 0)for(const o in i.perspectiveCameraInfo)a.push({title:jt(o),prop:o,type:"number",step:.01,value:i.perspectiveCameraInfo[o],onChange:(l,c)=>{e.updateObject(i.uuid,l,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(V(u,l,c),u.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const o in i.orthographicCameraInfo)a.push({title:jt(o),prop:o,type:"number",step:.01,value:i.orthographicCameraInfo[o],onChange:(l,c)=>{e.updateObject(i.uuid,l,c),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(V(u,l,c),u.updateProjectionMatrix())}}});return d.jsx(te,{three:e,title:"Camera",items:a,expanded:n,onToggle:o=>{r(o)}})}/*!
34
- * camera-controls
35
- * https://github.com/yomotsu/camera-controls
36
- * (c) 2017 @yomotsu
37
- * Released under the MIT License.
38
- */const H={LEFT:1,RIGHT:2,MIDDLE:4},f=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Se={NONE:0,IN:1,OUT:-1};function me(i){return i.isPerspectiveCamera}function he(i){return i.isOrthographicCamera}const xe=Math.PI*2,zt=Math.PI/2,mi=1e-5,De=Math.PI/180;function ee(i,e,t){return Math.max(e,Math.min(t,i))}function z(i,e=mi){return Math.abs(i)<e}function F(i,e,t=mi){return z(i-e,t)}function Ht(i,e){return Math.round(i/e)*e}function Ie(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Ue(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Ve(i,e,t,s,n=1/0,r){s=Math.max(1e-4,s);const a=2/s,o=a*r,l=1/(1+o+.48*o*o+.235*o*o*o);let c=i-e;const h=e,u=n*s;c=ee(c,-u,u),e=i-c;const p=(t.value+a*c)*r;t.value=(t.value-a*p)*l;let m=e+(c+p)*l;return h-i>0==m>h&&(m=h,t.value=(m-h)/r),m}function Bt(i,e,t,s,n=1/0,r,a){s=Math.max(1e-4,s);const o=2/s,l=o*r,c=1/(1+l+.48*l*l+.235*l*l*l);let h=e.x,u=e.y,p=e.z,m=i.x-h,C=i.y-u,_=i.z-p;const E=h,g=u,y=p,x=n*s,O=x*x,S=m*m+C*C+_*_;if(S>O){const pe=Math.sqrt(S);m=m/pe*x,C=C/pe*x,_=_/pe*x}h=i.x-m,u=i.y-C,p=i.z-_;const T=(t.x+o*m)*r,M=(t.y+o*C)*r,U=(t.z+o*_)*r;t.x=(t.x-o*T)*c,t.y=(t.y-o*M)*c,t.z=(t.z-o*U)*c,a.x=h+(m+T)*c,a.y=u+(C+M)*c,a.z=p+(_+U)*c;const A=E-i.x,j=g-i.y,J=y-i.z,oe=a.x-E,ue=a.y-g,_e=a.z-y;return A*oe+j*ue+J*_e>0&&(a.x=E,a.y=g,a.z=y,t.x=(a.x-E)/r,t.y=(a.y-g)/r,t.z=(a.z-y)/r),a}function ot(i,e){e.set(0,0),i.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=i.length,e.y/=i.length}function lt(i,e){return he(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class fn{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let r=0,a=n.length;r<a;r++)n[r].call(this,e)}}}var ct;const gn="2.10.1",Ge=1/8,vn=/Mac/.test((ct=globalThis?.navigator)===null||ct===void 0?void 0:ct.platform);let P,Vt,We,ht,Y,D,N,Oe,Le,ie,se,fe,Gt,Wt,K,ke,we,Yt,dt,qt,ut,pt,Ye;class re extends fn{static install(e){P=e.THREE,Vt=Object.freeze(new P.Vector3(0,0,0)),We=Object.freeze(new P.Vector3(0,1,0)),ht=Object.freeze(new P.Vector3(0,0,1)),Y=new P.Vector2,D=new P.Vector3,N=new P.Vector3,Oe=new P.Vector3,Le=new P.Vector3,ie=new P.Vector3,se=new P.Vector3,fe=new P.Vector3,Gt=new P.Vector3,Wt=new P.Vector3,K=new P.Spherical,ke=new P.Spherical,we=new P.Box3,Yt=new P.Box3,dt=new P.Sphere,qt=new P.Quaternion,ut=new P.Quaternion,pt=new P.Matrix4,Ye=new P.Raycaster}static get ACTION(){return f}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=f.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Se.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new P.Vector3,this._focalOffsetVelocity=new P.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,y,x,O)=>{let S,T;if(me(this._camera)){const M=D.copy(this._camera.position).sub(this._target),U=this._camera.getEffectiveFOV()*De,A=M.length()*Math.tan(U*.5);S=this.truckSpeed*g*A/this._elementRect.height,T=this.truckSpeed*y*A/this._elementRect.height}else if(he(this._camera)){const M=this._camera;S=this.truckSpeed*g*(M.right-M.left)/M.zoom/this._elementRect.width,T=this.truckSpeed*y*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;O?(x?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-T,!0)):x?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(S,T,!0)},this._rotateInternal=(g,y)=>{const x=xe*this.azimuthRotateSpeed*g/this._elementRect.height,O=xe*this.polarRotateSpeed*y/this._elementRect.height;this.rotate(x,O,!0)},this._dollyInternal=(g,y,x)=>{const O=Math.pow(.95,-g*this.dollySpeed),S=this._sphericalEnd.radius,T=this._sphericalEnd.radius*O,M=ee(T,this.minDistance,this.maxDistance),U=M-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(M,!0)):this._dollyToNoClamp(M,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:M)-S,this._dollyControlCoord.set(y,x)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,y,x)=>{const O=Math.pow(.95,g*this.dollySpeed),S=this._zoom,T=this._zoom*O;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-S,this._dollyControlCoord.set(y,x))},typeof P>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new P.Quaternion().setFromUnitVectors(this._camera.up,We),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=f.NONE,this._target=new P.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new P.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new P.Spherical().setFromVector3(D.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new P.Vector3,new P.Vector3,new P.Vector3,new P.Vector3],this._updateNearPlaneCorners(),this._boundary=new P.Box3(new P.Vector3(-1/0,-1/0,-1/0),new P.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new P.Vector2,this.mouseButtons={left:f.ROTATE,middle:f.DOLLY,right:f.TRUCK,wheel:me(this._camera)?f.DOLLY:he(this._camera)?f.ZOOM:f.NONE},this.touches={one:f.TOUCH_ROTATE,two:me(this._camera)?f.TOUCH_DOLLY_TRUCK:he(this._camera)?f.TOUCH_ZOOM_TRUCK:f.NONE,three:f.TOUCH_TRUCK};const s=new P.Vector2,n=new P.Vector2,r=new P.Vector2,a=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),S=g.clientX/O.width,T=g.clientY/O.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const y=g.pointerType!=="mouse"?null:(g.buttons&H.LEFT)===H.LEFT?H.LEFT:(g.buttons&H.MIDDLE)===H.MIDDLE?H.MIDDLE:(g.buttons&H.RIGHT)===H.RIGHT?H.RIGHT:null;if(y!==null){const O=this._findPointerByMouseButton(y);O&&this._disposePointer(O)}if((g.buttons&H.LEFT)===H.LEFT&&this._lockedPointer)return;const x={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:y};this._activePointers.push(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,p(g)},o=g=>{g.cancelable&&g.preventDefault();const y=g.pointerId,x=this._lockedPointer||this._findPointerById(y);if(x){if(x.clientX=g.clientX,x.clientY=g.clientY,x.deltaX=g.movementX,x.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&H.LEFT)===H.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&H.MIDDLE)===H.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&H.RIGHT)===H.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=g=>{const y=this._findPointerById(g.pointerId);if(!(y&&y===this._lockedPointer)){if(y&&this._disposePointer(y),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=f.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=f.NONE;C()}};let c=-1;const h=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===f.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),M=g.clientX/T.width,U=g.clientY/T.height;if(M<this._interactiveArea.left||M>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===f.ROTATE||this.mouseButtons.wheel===f.TRUCK){const T=performance.now();c-T<1e3&&this._getClientRect(this._elementRect),c=T}const y=vn?-1:-3,x=g.deltaMode===1||g.ctrlKey?g.deltaY/y:g.deltaY/(y*10),O=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case f.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case f.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case f.SCREEN_PAN:{this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case f.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case f.DOLLY:{this._dollyInternal(-x,O,S),this._isUserControllingDolly=!0;break}case f.ZOOM:{this._zoomInternal(-x,O,S),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},u=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===re.ACTION.NONE){const y=g instanceof PointerEvent?g.pointerId:0,x=this._findPointerById(y);x&&this._disposePointer(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(ot(this._activePointers,Y),this._getClientRect(this._elementRect),s.copy(Y),n.copy(Y),this._activePointers.length>=2){const x=Y.x-this._activePointers[1].clientX,O=Y.y-this._activePointers[1].clientY,S=Math.sqrt(x*x+O*O);r.set(0,S);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,M=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(T,M)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&H.LEFT)===H.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&H.MIDDLE)===H.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&H.RIGHT)===H.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&f.ROTATE)===f.ROTATE||(this._state&f.TOUCH_ROTATE)===f.TOUCH_ROTATE||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&f.TRUCK)===f.TRUCK||(this._state&f.SCREEN_PAN)===f.SCREEN_PAN||(this._state&f.TOUCH_TRUCK)===f.TOUCH_TRUCK||(this._state&f.TOUCH_SCREEN_PAN)===f.TOUCH_SCREEN_PAN||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_DOLLY_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK||(this._state&f.TOUCH_ZOOM_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&f.DOLLY)===f.DOLLY||(this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_DOLLY_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&f.ZOOM)===f.ZOOM||(this._state&f.TOUCH_ZOOM)===f.TOUCH_ZOOM||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK||(this._state&f.TOUCH_ZOOM_SCREEN_PAN)===f.TOUCH_ZOOM_SCREEN_PAN||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&f.OFFSET)===f.OFFSET||(this._state&f.TOUCH_OFFSET)===f.TOUCH_OFFSET||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ot(this._activePointers,Y);const y=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,x=y?-y.deltaX:n.x-Y.x,O=y?-y.deltaY:n.y-Y.y;if(n.copy(Y),((this._state&f.ROTATE)===f.ROTATE||(this._state&f.TOUCH_ROTATE)===f.TOUCH_ROTATE||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(x,O),this._isUserControllingRotate=!0),(this._state&f.DOLLY)===f.DOLLY||(this._state&f.ZOOM)===f.ZOOM){const S=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,M=this.dollyDragInverted?-1:1;(this._state&f.DOLLY)===f.DOLLY?(this._dollyInternal(M*O*Ge,S,T),this._isUserControllingDolly=!0):(this._zoomInternal(M*O*Ge,S,T),this._isUserControllingZoom=!0)}if((this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_ZOOM)===f.TOUCH_ZOOM||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK||(this._state&f.TOUCH_DOLLY_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN||(this._state&f.TOUCH_ZOOM_SCREEN_PAN)===f.TOUCH_ZOOM_SCREEN_PAN||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_ZOOM_ROTATE)===f.TOUCH_ZOOM_ROTATE){const S=Y.x-this._activePointers[1].clientX,T=Y.y-this._activePointers[1].clientY,M=Math.sqrt(S*S+T*T),U=r.y-M;r.set(0,M);const A=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,j=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&f.TOUCH_DOLLY)===f.TOUCH_DOLLY||(this._state&f.TOUCH_DOLLY_ROTATE)===f.TOUCH_DOLLY_ROTATE||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_DOLLY_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*Ge,A,j),this._isUserControllingDolly=!0):(this._zoomInternal(U*Ge,A,j),this._isUserControllingZoom=!0)}((this._state&f.TRUCK)===f.TRUCK||(this._state&f.TOUCH_TRUCK)===f.TOUCH_TRUCK||(this._state&f.TOUCH_DOLLY_TRUCK)===f.TOUCH_DOLLY_TRUCK||(this._state&f.TOUCH_ZOOM_TRUCK)===f.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(x,O,!1,!1),this._isUserControllingTruck=!0),((this._state&f.SCREEN_PAN)===f.SCREEN_PAN||(this._state&f.TOUCH_SCREEN_PAN)===f.TOUCH_SCREEN_PAN||(this._state&f.TOUCH_DOLLY_SCREEN_PAN)===f.TOUCH_DOLLY_SCREEN_PAN||(this._state&f.TOUCH_ZOOM_SCREEN_PAN)===f.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(x,O,!1,!0),this._isUserControllingTruck=!0),((this._state&f.OFFSET)===f.OFFSET||(this._state&f.TOUCH_OFFSET)===f.TOUCH_OFFSET||(this._state&f.TOUCH_DOLLY_OFFSET)===f.TOUCH_DOLLY_OFFSET||(this._state&f.TOUCH_ZOOM_OFFSET)===f.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(x,O,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},C=()=>{ot(this._activePointers,Y),n.copy(Y),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",_),this._domElement.ownerDocument.addEventListener("pointerlockerror",E),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),p())},this.unlockPointer=()=>{var g,y,x;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockchange",_),(x=this._domElement)===null||x===void 0||x.ownerDocument.removeEventListener("pointerlockerror",E),this.cancel()};const _=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},E=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",u)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",u),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",_),this._domElement.ownerDocument.removeEventListener("pointerlockerror",E))},this.cancel=()=>{this._state!==f.NONE&&(this._state=f.NONE,this._activePointers.length=0,C())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=ee(e.width,0,1),this._interactiveArea.height=ee(e.height,0,1),this._interactiveArea.x=ee(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ee(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,s=!1){this._isUserControllingRotate=!1;const n=ee(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=ee(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const a=!s||F(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&F(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0,this._dollyToNoClamp(ee(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const a=this._collisionTest(),o=F(a,this._spherical.radius);if(!(s>e)&&o)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,a)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||F(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Le).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||F(this._target.x,this._targetEnd.x,this.restThreshold)&&F(this._target.y,this._targetEnd.y,this.restThreshold)&&F(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=ee(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||F(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),ie.setFromMatrixColumn(this._camera.matrix,0),se.setFromMatrixColumn(this._camera.matrix,1),ie.multiplyScalar(e),se.multiplyScalar(-t);const n=D.copy(ie).add(se),r=N.copy(this._targetEnd).add(n);return this.moveTo(r.x,r.y,r.z,s)}forward(e,t=!1){D.setFromMatrixColumn(this._camera.matrix,0),D.crossVectors(this._camera.up,D),D.multiplyScalar(e);const s=N.copy(this._targetEnd).add(D);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return D.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+D.x,this._targetEnd.y+D.y,this._targetEnd.z+D.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const r=D.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const a=!n||F(this._target.x,this._targetEnd.x,this.restThreshold)&&F(this._target.y,this._targetEnd.y,this.restThreshold)&&F(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,s,n=!1){const o=D.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(o.x,o.y,o.z,n)}fitToBox(e,t,{cover:s=!1,paddingLeft:n=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:o=0}={}){const l=[],c=e.isBox3?we.copy(e):we.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=Ht(this._sphericalEnd.theta,zt),u=Ht(this._sphericalEnd.phi,zt);l.push(this.rotateTo(h,u,t));const p=D.setFromSpherical(this._sphericalEnd).normalize(),m=qt.setFromUnitVectors(p,ht),C=F(Math.abs(p.y),1);C&&m.multiply(ut.setFromAxisAngle(We,h)),m.multiply(this._yAxisUpSpaceInverse);const _=Yt.makeEmpty();N.copy(c.min).applyQuaternion(m),_.expandByPoint(N),N.copy(c.min).setX(c.max.x).applyQuaternion(m),_.expandByPoint(N),N.copy(c.min).setY(c.max.y).applyQuaternion(m),_.expandByPoint(N),N.copy(c.max).setZ(c.min.z).applyQuaternion(m),_.expandByPoint(N),N.copy(c.min).setZ(c.max.z).applyQuaternion(m),_.expandByPoint(N),N.copy(c.max).setY(c.min.y).applyQuaternion(m),_.expandByPoint(N),N.copy(c.max).setX(c.min.x).applyQuaternion(m),_.expandByPoint(N),N.copy(c.max).applyQuaternion(m),_.expandByPoint(N),_.min.x-=n,_.min.y-=a,_.max.x+=r,_.max.y+=o,m.setFromUnitVectors(ht,p),C&&m.premultiply(ut.invert()),m.premultiply(this._yAxisUpSpace);const E=_.getSize(D),g=_.getCenter(N).applyQuaternion(m);if(me(this._camera)){const y=this.getDistanceToFitBox(E.x,E.y,E.z,s);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.dollyTo(y,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(he(this._camera)){const y=this._camera,x=y.right-y.left,O=y.top-y.bottom,S=s?Math.max(x/E.x,O/E.y):Math.min(x/E.x,O/E.y);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.zoomTo(S,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const s=[],r="isObject3D"in e?re.createBoundingSphere(e,dt):dt.copy(e);if(s.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),me(this._camera)){const a=this.getDistanceToFitSphere(r.radius);s.push(this.dollyTo(a,t))}else if(he(this._camera)){const a=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,l=2*r.radius,c=Math.min(a/l,o/l);s.push(this.zoomTo(c,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,r,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const l=N.set(n,r,a),c=D.set(e,t,s);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!o||F(this._target.x,this._targetEnd.x,this.restThreshold)&&F(this._target.y,this._targetEnd.y,this.restThreshold)&&F(this._target.z,this._targetEnd.z,this.restThreshold)&&F(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&F(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&F(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,s,n,r,a,o,l,c,h,u,p,m,C=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const _=D.set(n,r,a),E=N.set(e,t,s);K.setFromVector3(E.sub(_).applyQuaternion(this._yAxisUpSpace));const g=Oe.set(h,u,p),y=N.set(o,l,c);ke.setFromVector3(y.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(g,m));const x=ke.theta-K.theta,O=ke.phi-K.phi,S=ke.radius-K.radius;this._sphericalEnd.set(K.radius+S*m,K.phi+O*m,K.theta+x*m),this.normalizeRotations(),this._needsUpdate=!0,C||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!C||F(this._target.x,this._targetEnd.x,this.restThreshold)&&F(this._target.y,this._targetEnd.y,this.restThreshold)&&F(this._target.z,this._targetEnd.z,this.restThreshold)&&F(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&F(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&F(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,s,n=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,s,n=!1){const r=this.getPosition(D),a=this.setLookAt(r.x,r.y,r.z,e,t,s,n);return this._sphericalEnd.phi=ee(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,s,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const r=!n||F(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&F(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&F(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),ie.setFromMatrixColumn(this._camera.matrixWorldInverse,0),se.setFromMatrixColumn(this._camera.matrixWorldInverse,1),fe.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=D.set(e,t,s),r=n.distanceTo(this._camera.position),a=n.sub(this._camera.position);ie.multiplyScalar(a.x),se.multiplyScalar(a.y),fe.multiplyScalar(a.z),D.copy(ie).add(se).add(fe),D.z=D.z+r,this.dollyTo(r,!1),this.setFocalOffset(-D.x,D.y,-D.z,!1),this.moveTo(e,t,s,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,s,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new P.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(lt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,a=this._camera.getEffectiveFOV()*De,o=this._camera.aspect;return((n?r>o:r<o)?t:e/o)*.5/Math.tan(a*.5)+s*.5}getDistanceToFitSphere(e){if(lt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*De,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:s;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new P.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new P.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new P.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new P.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%xe,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=xe),this._spherical.theta+=xe*Math.round((this._sphericalEnd.theta-this._spherical.theta)/xe)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!F(this._camera.up.x,this._cameraUp0.x)||!F(this._camera.up.y,this._cameraUp0.y)||!F(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(D);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,We),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=D.subVectors(this._target,this._camera.position).normalize(),t=N.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(D);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,r=Gt.subVectors(this._targetEnd,this._target),a=Wt.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(z(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const u=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Ve(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,u,1/0,e),this._needsUpdate=!0}if(z(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const u=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Ve(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,u,1/0,e),this._needsUpdate=!0}if(z(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const u=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Ve(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,u,this.maxSpeed,e),this._needsUpdate=!0}if(z(r.x)&&z(r.y)&&z(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const u=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Bt(this._target,this._targetEnd,this._targetVelocity,u,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(z(a.x)&&z(a.y)&&z(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const u=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Bt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,u,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(z(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const u=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Ve(this._zoom,this._zoomEnd,this._zoomVelocity,u,1/0,e)}if(this.dollyToCursor){if(me(this._camera)&&this._changedDolly!==0){const u=this._spherical.radius-this._lastDistance,p=this._camera,m=this._getCameraDirection(Le),C=D.copy(m).cross(p.up).normalize();C.lengthSq()===0&&(C.x=1);const _=N.crossVectors(C,m),E=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*De*.5),y=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,x=Oe.copy(this._targetEnd).add(C.multiplyScalar(this._dollyControlCoord.x*E*p.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*E)),O=D.copy(this._targetEnd).lerp(x,y),S=this._lastDollyDirection===Se.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===Se.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||T)){this._sphericalEnd.radius-=u,this._spherical.radius-=u;const U=N.copy(m).multiplyScalar(-u);O.add(U)}this._boundary.clampPoint(O,O);const M=N.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(M),this._changedDolly-=u,z(this._changedDolly)&&(this._changedDolly=0)}else if(he(this._camera)&&this._changedZoom!==0){const u=this._zoom-this._lastZoom,p=this._camera,m=D.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),C=N.set(0,0,-1).applyQuaternion(p.quaternion),_=Oe.copy(m).add(C.multiplyScalar(-m.dot(p.up))),g=-(this._zoom-u-this._zoom)/this._zoom,y=this._getCameraDirection(Le),x=this._targetEnd.dot(y),O=D.copy(this._targetEnd).lerp(_,g),S=O.dot(y),T=y.multiplyScalar(S-x);O.sub(T),this._boundary.clampPoint(O,O);const M=N.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(M),this._changedZoom-=u,z(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!z(this._focalOffset.x)||!z(this._focalOffset.y)||!z(this._focalOffset.z))&&(ie.setFromMatrixColumn(this._camera.matrix,0),se.setFromMatrixColumn(this._camera.matrix,1),fe.setFromMatrixColumn(this._camera.matrix,2),ie.multiplyScalar(this._focalOffset.x),se.multiplyScalar(-this._focalOffset.y),fe.multiplyScalar(this._focalOffset.z),D.copy(ie).add(se).add(fe),this._camera.position.add(D),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),D.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),z(t,this.restThreshold)&&z(s,this.restThreshold)&&z(n,this.restThreshold)&&z(r.x,this.restThreshold)&&z(r.y,this.restThreshold)&&z(r.z,this.restThreshold)&&z(a.x,this.restThreshold)&&z(a.y,this.restThreshold)&&z(a.z,this.restThreshold)&&z(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Ie(this.maxDistance),minZoom:this.minZoom,maxZoom:Ie(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Ie(this.maxPolarAngle),minAzimuthAngle:Ie(this.minAzimuthAngle),maxAzimuthAngle:Ie(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:D.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=Ue(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Ue(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Ue(s.maxPolarAngle),this.minAzimuthAngle=Ue(s.minAzimuthAngle),this.maxAzimuthAngle=Ue(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),K.setFromVector3(D.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(K.theta,K.phi,t),this.dollyTo(K.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",gn),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,s){const n=t.lengthSq();if(n===0)return e;const r=N.copy(t).add(e),o=this._boundary.clampPoint(r,Oe).sub(r),l=o.lengthSq();if(l===0)return e.add(t);if(l===n)return e;if(s===0)return e.add(t).add(o);{const c=1+s*l/t.dot(o);return e.add(N.copy(t).multiplyScalar(c)).add(o.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(me(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*De,n=Math.tan(s*.5)*t,r=n*e.aspect;this._nearPlaneCorners[0].set(-r,-n,0),this._nearPlaneCorners[1].set(r,-n,0),this._nearPlaneCorners[2].set(r,n,0),this._nearPlaneCorners[3].set(-r,n,0)}else if(he(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(s,r,0),this._nearPlaneCorners[1].set(n,r,0),this._nearPlaneCorners[2].set(n,a,0),this._nearPlaneCorners[3].set(s,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||lt(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(Le);pt.lookAt(Vt,s,this._camera.up);for(let n=0;n<4;n++){const r=N.copy(this._nearPlaneCorners[n]);r.applyMatrix4(pt);const a=Oe.addVectors(this._target,r);Ye.set(a,s),Ye.far=this._spherical.radius+1;const o=Ye.intersectObjects(this.colliderMeshes);o.length!==0&&o[0].distance<e&&(e=o[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new P.Sphere){const s=t,n=s.center;we.makeEmpty(),e.traverseVisible(a=>{a.isMesh&&we.expandByObject(a)}),we.getCenter(n);let r=0;return e.traverseVisible(a=>{if(!a.isMesh)return;const o=a;if(!o.geometry)return;const l=o.geometry.clone();l.applyMatrix4(o.matrixWorld);const h=l.attributes.position;for(let u=0,p=h.count;u<p;u++)D.fromBufferAttribute(h,u),r=Math.max(r,n.distanceToSquared(D))}),s.radius=Math.sqrt(r),s}}const Qe=i=>{const[e,t]=b.useState(i.options[i.index]),s=()=>{i.onToggle(!i.open)},n=a=>{a!==e&&(i.onSelect(a),t(a)),i.onToggle(!1)},r=i.open?`${i.options.length*31-1}px`:"0px";return d.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[d.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),d.jsx("ul",{className:"dropdown-menu",style:{height:r},children:i.options.map(a=>d.jsx("li",{onClick:()=>n(a),children:a},a))})]})},ge=b.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,r]=b.useState("Renderer"),[a,o]=b.useState(!1),[l,c]=b.useState(!1),[h,u]=b.useState(!1);return d.jsxs("div",{className:`CameraWindow ${e.name}`,children:[d.jsx("div",{ref:t,className:"clickable",onClick:()=>{h&&u(!1)}}),d.jsxs("div",{className:"options",children:[e.camera!==null&&d.jsx(Qe,{title:"Camera",index:e.options.indexOf(e.camera.name),open:h,options:e.options,onSelect:e.onSelectCamera,onToggle:p=>{p&&l&&c(!1),u(p)},up:!0}),d.jsx(Qe,{title:"Mode",index:s.indexOf(n),open:l,options:s,onSelect:p=>{if(p===n)return;const m=p;e.onSelectRenderMode(m),r(m)},onToggle:p=>{p&&h&&u(!1),a&&o(!1),c(p)},up:!0})]})]})}),_n=`out vec3 worldPosition;
15
+ C11,8.22,10.74,8,10.43,8z`})});function rt(i){return c.jsx("li",{className:`reorder-item ${i.draggingIndex===i.index?"dragging":""}`,draggable:!0,onDragStart:()=>i.onDragStart(i.index),onDragOver:e=>{e.preventDefault(),i.onDragOver(i.index)},onDragEnd:i.onDragEnd,children:c.jsxs("div",{children:[Di,c.jsx("span",{children:i.title}),c.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:ki})]})})}function at(i){const[e,t]=v.useState(!1),[s,n]=v.useState(i.options),[a,r]=v.useState(null),o=f=>{i.onDragComplete(f),n(f)},l=f=>{const y=[...s];y.splice(f,1),o(y)},d=f=>{r(f)},h=f=>{if(a===f||a===null)return;const y=[...s],g=y.splice(a,1)[0];y.splice(f,0,g),r(f),n(y)},u=()=>{i.onDragComplete(s),r(null)};let m="dropdown draggable";return i.subdropdown&&(m+=" subdropdown"),c.jsxs("div",{className:m,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(ke,{title:i.title}),c.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((f,y)=>c.jsx(rt,{title:f,index:y,draggingIndex:a,onDelete:l,onDragStart:d,onDragOver:h,onDragEnd:u},f))})]})}function ot(i){const[e,t]=v.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(c.jsx(ct,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),c.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(ke,{title:i.title}),c.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function ct(i){const{option:e}=i,[t,s]=v.useState("");let n;switch(e.type){case"draggable":n=c.jsx(at,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=c.jsx(ot,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=c.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 c.jsx("li",{className:t===e.title?"selected":"",children:n},k())}function te(i){const[e,t]=v.useState(i.open!==void 0?i.open:!1),[s,n]=v.useState(i.visible!==void 0?i.visible:!1),a=!e||i.children===void 0,r=()=>{i.three.dispatchEvent({type:w.REMOVE_SCENE,value:i.scene})};return c.jsxs("div",{className:`accordion ${a?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const o=!e;i.onToggle!==void 0&&i.onToggle(o),t(o)},children:[c.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:ce(i.label)})]}),i.onRefresh?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const l=i.three.getScene(i.scene.uuid);if(l){const d=!l.visible;l.visible=d,n(d)}}}),c.jsx("button",{className:"refresh",onClick:i.onRefresh}),c.jsx("button",{className:"remove",onClick:r})]}):null,i.button,c.jsx("div",{className:e?"open":"",children:c.jsx("div",{children:i.children})})]})}function De(i){if(i.child===void 0)return console.log("Hermes - No child attached"),null;const e=v.useRef(null),[t,s]=v.useState(!1),n=i.child.children.length>0,a=[];return i.child.children.length>0&&i.child.children.map((r,o)=>{a.push(c.jsx(De,{child:r,three:i.three},o))}),v.useEffect(()=>{if(i.child){const r=i.child.uuid.split(".")[0],o=i.three.getScene(r);if(o!==null)try{const l=o.getObjectByProperty("uuid",i.child.uuid);l!==void 0?e.current.style.opacity=l.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(l){console.log("Error looking for child:",l),console.log(i.child),console.log(i.three.scenes),console.log(o)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${r} with child UUID: ${i.child.uuid}`,i.three.scenes,i.three.scene,o)}},[t]),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[n?c.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,c.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0?(i.three.getObject(i.child.uuid),!t&&n&&s(!0)):console.log("Hermes - No child attached...")},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),c.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.child.uuid);if(o!==void 0){const l="visible",d=!o.visible;e.current.style.opacity=d?"1":"0.25",i.three.updateObject(i.child.uuid,l,d),I(o,l,d)}else console.log(`Hermes - Couldn't find object: ${i.child.uuid}`,r)}else console.log(`Hermes - Couldn't find object in scene: ${i.child.uuid}, ${i.child.name}`)}}}),c.jsx("div",{className:`icon ${Ai(i.child)}`})]}),c.jsx("div",{className:t?"open":"",children:c.jsx("div",{className:"container",children:a})})]})}function ue(i){const e=[];return i.child?.children.map((t,s)=>{e.push(c.jsx(De,{child:t,scene:i.scene,three:i.three},s))}),c.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function re(i){const[e,t]=v.useState(i.defaultValue);return v.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,o=!1;const l=f=>{o=f.ctrlKey},d=f=>{s=!0,a=Number(i.input.current?.value),n=f.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=f=>{if(!s)return;const y=i.step!==void 0?i.step:1,g=(f.clientX-n)*y*(o?10:1);r=Number((a+g).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)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},m=f=>{const y=Number(f.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.label.current?.addEventListener("mousedown",d,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{i.label.current?.removeEventListener("mousedown",d),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function K(i){const e=v.useRef(null),t=v.useRef(null),[s,n]=v.useState(i.value);return re({label:i.labelRef,input:e,sliderRef:t,defaultValue:s,min:i.min,max:i.max,step:i.step,onChange:a=>{n(a),i.onChange!==void 0&&i.onChange(i.prop,a)}}),c.jsxs(c.Fragment,{children:[i.type==="number"&&c.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,name:k(),onChange:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||i.onChange!==void 0&&i.onChange(i.prop,r)}}),i.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:k(),onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||(n(r),i.onChange!==void 0&&i.onChange(i.prop,r))}}),c.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,name:k(),onChange:oe})]})]})}function ji(i){const e=v.useRef(null),t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),o=v.useRef(null),l=v.useRef(null),d=v.useRef(null),h=v.useRef(null),[u,m]=v.useState(i.value.x),[f,y]=v.useState(i.value.y),[g,S]=v.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))}),[O,M]=v.useState(!1);re({label:o,input:e,defaultValue:u,min:g.min,max:g.max,step:.01,onChange:E=>{m(E),i.onChange({target:{value:{x:E,y:f}}})}}),re({label:l,input:t,defaultValue:f,min:g.min,max:g.max,step:.01,onChange:E=>{y(E),i.onChange({target:{value:{x:u,y:E}}})}}),re({label:d,input:s,defaultValue:g.min,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:E,max:g.max})}}),re({label:h,input:n,defaultValue:g.max,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:g.min,max:E})}});function T(){O||(window.addEventListener("mousemove",D),window.addEventListener("mouseup",R),M(!0))}function R(){window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",R),M(!1)}function D(E){const j=a.current.getBoundingClientRect(),le=z(0,99,E.clientX-j.left)/99,yt=1-z(0,99,E.clientY-j.top)/99,Ne=_(ie(g.min,g.max,le),3),Le=_(ie(g.min,g.max,yt),3);i.onChange({target:{value:{x:Ne,y:Le}}}),m(Ne),y(Le)}function V(){const E=Number(s.current.value);S({min:E,max:g.max}),u<E&&m(z(E,g.max,u)),f<E&&y(z(E,g.max,f))}function H(){const E=Number(n.current.value);S({min:g.min,max:E}),u>E&&m(z(g.min,E,u)),f>E&&y(z(g.min,E,f))}v.useEffect(()=>{r.current.style.left=`${fe(g.min,g.max,u)*100}%`,r.current.style.top=`${(1-fe(g.min,g.max,f))*100}%`},[g,u,f]);const F=i.step!==void 0?i.step:.01;return c.jsxs("div",{className:"vector2",children:[c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{ref:o,children:"X"}),c.jsx("input",{ref:e,type:"number",value:u,min:g.min,max:g.max,step:F,name:k(),onChange:E=>{if(m(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:j,y:f}}}),j<g.min&&S({min:j,max:g.max}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:l,children:"Y"}),c.jsx("input",{ref:t,type:"number",value:f,min:g.min,max:g.max,step:F,name:k(),onChange:E=>{if(y(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:u,y:j}}}),j>g.max&&S({min:g.min,max:j}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:d,children:"Min"}),c.jsx("input",{ref:s,type:"number",value:g.min,step:F,name:k(),onChange:V})]}),c.jsxs("div",{children:[c.jsx("span",{ref:h,children:"Max"}),c.jsx("input",{ref:n,type:"number",value:g.max,step:F,name:k(),onChange:H})]})]}),c.jsxs("div",{className:"input",ref:a,onMouseDown:T,onMouseUp:R,children:[c.jsx("div",{className:"x"}),c.jsx("div",{className:"y"}),c.jsx("div",{className:"pt",ref:r})]})]})}function Be(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=v.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(l=>{const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("span",{ref:d,children:l.substring(1).toUpperCase()}),c.jsx(K,{value:L.radToDeg(r[l]),type:"number",prop:l,step:.1,labelRef:d,onChange:(h,u)=>{r[h]=L.degToRad(u),i.onChange({target:{value:r}})}})]},l))})}else if(e){const r=v.useMemo(()=>i.value,[]),o=(d,h)=>{r[d]=h,i.onChange({target:{value:r}})};["x","y","z"].forEach(d=>{const h=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:h,children:d.toUpperCase()}),c.jsx(K,{value:r[d],type:"number",prop:d,step:n,labelRef:h,onChange:o})]},d))})}else if(s){const r=v.useMemo(()=>i.value,[]),o=(l,d)=>{const h=Number(l);r.elements[h]=d,i.onChange({target:{value:r}})};for(let l=0;l<9;l++){const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:d,children:l+1}),c.jsx(K,{value:r.elements[l],type:"number",prop:l.toString(),step:n,labelRef:d,onChange:o})]},l.toString()))}}return c.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Ni(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=v.useMemo(()=>i.value,[]),a=(o,l)=>{n[o]=l,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const l=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("label",{ref:l,children:o.toUpperCase()}),c.jsx(K,{value:n[o],type:"number",prop:o,step:t,labelRef:l,onChange:a})]},o))})}else{const n=v.useMemo(()=>i.value,[]),a=(r,o)=>{const l=Number(r);n.elements[l]=o,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const o=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("span",{ref:o,children:r+1}),c.jsx(K,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:a})]},r.toString()))}}return c.jsx("div",{className:"grid4",children:s})}function Li(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 _i(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 be(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 lt(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 Ui(){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 Gi=[{title:"Front",value:p.FrontSide},{title:"Back",value:p.BackSide},{title:"Double",value:p.DoubleSide}],Fi=[{title:"No Blending",value:p.NoBlending},{title:"Normal",value:p.NormalBlending},{title:"Additive",value:p.AdditiveBlending},{title:"Subtractive",value:p.SubtractiveBlending},{title:"Multiply",value:p.MultiplyBlending},{title:"Custom",value:p.CustomBlending}],Bi=[{title:"Add",value:p.AddEquation},{title:"Subtract",value:p.SubtractEquation},{title:"Reverse Subtract",value:p.ReverseSubtractEquation},{title:"Min",value:p.MinEquation},{title:"Max",value:p.MaxEquation}],Vi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:p.SrcAlphaSaturateFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}],Hi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}];function se(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Wi(i,e,t,s){return{type:"boolean",title:be(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 o=r.getObjectByProperty("uuid",t.uuid);I(o,`material.${i}`,a)}}}}function zi(i,e,t,s){const n={type:"number",title:be(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 o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);I(l,`material.${i}`,r)}}};switch(i){case"blending":se(n,Fi);break;case"blendDst":se(n,Hi);break;case"blendEquation":se(n,Bi);break;case"blendSrc":se(n,Vi);break;case"side":se(n,Gi);break}return lt(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 qi(i,e,t,s){const n={type:"string",title:be(i),prop:i,value:e,needsUpdate:!0,onChange:(r,o)=>{s.updateObject(t.uuid,`material.${i}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);I(d,`material.${i}`,o)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.type="field",n.disabled=!1,n.latest=n.value,n.onChange=(r,o)=>{n.latest=o,s.updateObject(t.uuid,`material.${i}`,o);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);I(d,`material.${i}`,o)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);I(l,"material.needsUpdate",!0)}}}),n}function $i(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Ki(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Yi(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Re(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Z(i,e,t,s,n="",a=!1){const r=be(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,l=typeof e;if(l==="object"&&e!==null&&e.__isUniform===!0)return Z(`${i}.value`,e.value,t,s,n,a);if(l==="boolean"||l==="string")return{title:r,prop:o,type:l,value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(l==="number"){const d={title:r,prop:o,type:"number",value:e,step:.01,disabled:a,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);I(f,`material.${o}`,u)}}};return lt(r)&&(d.type="range",d.min=0,d.max=1),d}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:a,onChange:(d,h)=>{const u=new p.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);I(f,`material.${o}`,u)}}};if(Array.isArray(e)){const d=[];for(const h in e){const u=e[h],m=`[${h.toString()}]`;if(u.value!==void 0){const f=Z(`${m}.value`,u.value,t,s,o,a);f!==void 0&&d.push(f)}else{const f=Z(m,u,t,s,o,a);f!==void 0&&d.push(f)}}if(d.length>0)return Re(d),{title:r,items:d}}else{if($i(e))return{title:r,prop:o,type:"vector2",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(Ki(e))return{title:r,prop:o,type:"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(Yi(e))return{title:r,prop:o,type:"grid4",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(d,h)=>{const u=_i(i),m=n.length>0?`${n}.${u}`:u;s.createTexture(t.uuid,`material.${m}`,h);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);if(y!==void 0){const g=S=>{const O=y.material,M=m.split(".");switch(M.length){case 1:O[M[0]]=S;break;case 2:O[M[0]][M[1]]=S;break;case 3:O[M[0]][M[1]][M[2]]=S;break;case 4:O[M[0]][M[1]][M[2]][M[3]]=S;break;case 5:O[M[0]][M[1]][M[2]][M[3]][M[4]]=S;break}O.needsUpdate=!0};h.src.length>0?nt(h.src).then(S=>{S.offset.set(h.offset[0],h.offset[1]),S.repeat.set(h.repeat[0],h.repeat[1]),g(S)}):g(null)}}}};if(e.elements!==void 0)return{title:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};{const d=[],h=i==="defines"||i==="extensions";try{for(const u in e){const m=e[u];if(m!==void 0)if(m.value!==void 0){const f=Z(`${u}.value`,m.value,t,s,o,h);f!==void 0&&d.push(f)}else{const f=Z(u,m,t,s,o,h);f!==void 0&&d.push(f)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(d.length>0)return Re(d),{title:r,items:d}}}}}function Ve(i,e,t){const s=[];for(const n in i){if(!Li(n)||n.search("Node")>-1||i[n]instanceof b.ComputeNode)continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Wi(n,r,e,t));else if(a==="number")s.push(zi(n,r,e,t));else if(a==="string")s.push(qi(n,r,e,t));else if(a==="object"){const o=Z(n,r,e,t);o!==void 0&&s.push(o)}else r!==void 0&&console.log("Hermes - Other Material Prop Type:",n,a,r)}return Re(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);I(a,"material.needsUpdate",!0)}}}),s}function Ji(i,e){function t(){return`${e.name}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=i.material;if(Array.isArray(r)){const o=[],l=r.length;for(let d=0;d<l;d++)o.push(c.jsx(G,{three:e,title:`Material ${d}`,items:Ve(r[d],i,e)},`Material ${d}`));return c.jsx(c.Fragment,{children:o})}else return c.jsx(G,{three:e,title:"Material",items:Ve(r,i,e),expanded:n,onToggle:o=>{a(o)}})}const He="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 Xi(i){const e=i.step!==void 0?i.step:.01,t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),[o]=v.useState(i.value),[l,d]=v.useState(i.value.offset[0]),[h,u]=v.useState(i.value.offset[1]),[m,f]=v.useState(i.value.repeat[0]),[y,g]=v.useState(i.value.repeat[1]);function S(M,T,R,D,V){if(i.onChange!==void 0){const H=i.prop!==void 0?i.prop:i.title;i.onChange(H,{src:M,offset:[T,R],repeat:[D,V]})}}function O(M){const T=t.current.src,R=M.target.value;switch(M.target){case s.current:d(R),S(T,R,h,m,y);break;case n.current:u(R),S(T,l,R,m,y);break;case a.current:f(R),S(T,l,h,R,y);break;case r.current:g(R),S(T,l,h,m,R);break}}return c.jsxs("div",{className:"imageField",children:[c.jsx("img",{alt:i.title,ref:t,onClick:()=>{Ui().then(M=>{t.current.src=M,S(M,l,h,m,y)})},src:o.src.length>0?o.src:He}),c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{children:"Offset:"}),c.jsx("input",{ref:s,type:"number",value:l,step:e,name:k(),onChange:O}),c.jsx("input",{ref:n,type:"number",value:h,step:e,name:k(),onChange:O})]}),c.jsxs("div",{children:[c.jsx("span",{children:"Repeat:"}),c.jsx("input",{ref:a,type:"number",value:m,step:e,name:k(),onChange:O}),c.jsx("input",{ref:r,type:"number",value:y,step:e,name:k(),onChange:O})]}),c.jsx("button",{onClick:()=>{S("",l,h,m,y),t.current.src=He},children:"Clear"})]})]})}function pe(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=Ee(i.value):i.type==="color"&&(e=Ee(new p.Color().setStyle(i.value,p.LinearSRGBColorSpace))));const[t,s]=v.useState(e),n=v.useRef(null);v.useEffect(()=>{s(e)},[e]);const a=h=>{let u=h.target.value;if(i.type==="boolean")u=h.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==u;f++);}s(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},r={};i.disabled&&(r.opacity=.8);const o=typeof t=="string"?t:String(t??""),l=i.type==="field"||i.type==="string"&&(o.length>100||o.search(`
16
+ `)>-1),d=l||i.type==="image"||i.type==="vector2";return c.jsxs("div",{className:`field ${d?"block":""}`,style:r,children:[i.type!=="button"&&c.jsx("span",{ref:n,children:ce(i.title)},"fieldLabel"),i.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t,name:k()}),(i.type==="field"||i.type==="string"&&l)&&c.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:h=>{i.onKeyDown!==void 0&&i.onKeyDown(h)},value:t,name:k()}),i.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t,name:k()}),i.type==="number"&&c.jsx(K,{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"&&c.jsx(K,{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"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color",name:k()}),c.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled,name:k()})]}),i.type==="button"&&c.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"&&c.jsx(Xi,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&c.jsx(c.Fragment,{children:c.jsx("select",{onChange:a,disabled:i.disabled,value:t,name:k(),children:i.options?.map((h,u)=>c.jsx("option",{value:h.value,children:ce(h.title)},u))})}),i.type==="vector2"&&c.jsx(ji,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&c.jsx(Be,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&c.jsx(Ni,{step:i.step,value:t,onChange:a}),i.type==="euler"&&c.jsx(Be,{step:i.step,value:t,onChange:a})]})}function Qi(i){return"items"in i}class G extends v.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;three;constructor(e){super(e),this.three=e.three,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,o)=>{e.onUpdate(r,o)}})});const s=v.createRef(),n=c.jsx(G,{three:this.props.three,ref:s,title:e.title,expanded:e.expanded,items:t},e.title);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(Qi(t))e.push(c.jsx(G,{three:this.props.three,title:ce(t.title),items:t.items},t.title));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(c.jsx(pe,{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)}},t.title))}}),this.subgroupElements.forEach(t=>e.push(t)),c.jsx(te,{three:this.props.three,label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class A extends v.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static three;constructor(e){super(e),this.state={lastUpdate:Date.now()},A.instance=this,A.three=e.three,e.three.addEventListener(w.ADD_GROUP,this.addGroup),e.three.addEventListener(w.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){this.props.three.removeEventListener(w.ADD_GROUP,this.addGroup),this.props.three.removeEventListener(w.REMOVE_GROUP,this.removeGroup)}render(){return c.jsx("div",{className:"customGroups",children:A.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)}})}),A.groups.push(c.jsx(G,{three:this.props.three,title:t.title,items:s},t.title)),A.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=A.groupTitles.length;for(let n=0;n<s;n++)if(t===A.groupTitles[n]){A.groups.splice(n,1),A.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=A.groupTitles.length;for(let r=0;r<t;r++)if(A.groupTitles[r]===e.title)return A.groupsRefs[r];const s=[];e.items.forEach(r=>{s.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(o,l)=>{e.onUpdate(o,l)}})}),e.subgroups&&e.subgroups.length>0&&e.subgroups.forEach(r=>{const o=[];r.items.forEach(l=>{o.push({type:l.type,prop:l.prop,title:l.title!==void 0?l.title:l.prop,value:l.value,min:l.min,max:l.max,step:l.step,options:l.options,disabled:l.disabled,onChange:(d,h)=>{r.onUpdate(d,h)}})}),s.push({three:A.three,title:r.title,expanded:r.expanded,items:o})});const n=v.createRef(),a=c.jsx(G,{three:A.three,ref:n,title:e.title,expanded:e.expanded,items:s},e.title);return A.groups.push(a),A.groupsRefs.push(n),A.groupTitles.push(e.title),setTimeout(()=>{A.instance?.setState({lastUpdate:Date.now()})},0),n}static removeEditorGroup(e){const t=A.groupTitles.length;for(let s=0;s<t;s++)if(e===A.groupTitles[s]){A.groups.splice(s,1),A.groupTitles.splice(s,1),A.instance?.setState({lastUpdate:Date.now()});return}}static removeAllGroups(){A.groups=[],A.groupTitles=[],A.groupsRefs=[],A.instance?.setState({lastUpdate:Date.now()})}}function We(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 Zi(i,e){function t(){return`${e.name}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const o in i.perspectiveCameraInfo)r.push({title:We(o),prop:o,type:"number",step:.01,value:i.perspectiveCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(I(u,l,d),u.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const o in i.orthographicCameraInfo)r.push({title:We(o),prop:o,type:"number",step:.01,value:i.orthographicCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(I(u,l,d),u.updateProjectionMatrix())}}});return c.jsx(G,{three:e,title:"Camera",items:r,expanded:n,onToggle:o=>{a(o)}})}const ge=i=>{const[e,t]=v.useState(i.options[i.index]),s=()=>{i.onToggle(!i.open)},n=r=>{r!==e&&(i.onSelect(r),t(r)),i.onToggle(!1)},a=i.open?`${i.options.length*31-1}px`:"0px";return c.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),c.jsx("ul",{className:"dropdown-menu",style:{height:a},children:i.options.map(r=>c.jsx("li",{onClick:()=>n(r),children:r},r))})]})},$=v.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=v.useState("Renderer"),[r,o]=v.useState(!1),[l,d]=v.useState(!1),[h,u]=v.useState(!1);return c.jsxs("div",{className:`CameraWindow ${e.name}`,children:[c.jsx("div",{ref:t,className:"clickable",onClick:()=>{h&&u(!1)}}),c.jsxs("div",{className:"options",children:[e.camera!==null&&c.jsx(ge,{title:"Camera",index:e.options.indexOf(e.camera.name),open:h,options:e.options,onSelect:e.onSelectCamera,onToggle:m=>{m&&l&&d(!1),u(m)},up:!0}),c.jsx(ge,{title:"Mode",index:s.indexOf(n),open:l,options:s,onSelect:m=>{if(m===n)return;const f=m;e.onSelectRenderMode(f),a(f)},onToggle:m=>{m&&h&&u(!1),r&&o(!1),d(m)},up:!0})]})]})}),es=`out vec3 worldPosition;
39
17
  uniform float uDistance;
40
18
 
41
19
  void main() {
@@ -44,7 +22,7 @@ void main() {
44
22
  worldPosition.xz += cameraPosition.xz;
45
23
 
46
24
  gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
47
- }`,yn=`out vec4 fragColor;
25
+ }`,ts=`out vec4 fragColor;
48
26
  in vec3 worldPosition;
49
27
  uniform float uDivisions;
50
28
  uniform float uScale;
@@ -112,7 +90,7 @@ void main() {
112
90
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
113
91
 
114
92
  if (fragColor.a <= minAlpha) discard;
115
- }`;class fi extends v.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new v.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:v.GLSL3,side:v.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:_n,fragmentShader:yn})}get color(){return this.uniforms.uColor.value}set color(e){this.uniforms.uColor.value=e}get gridOpacity(){return this.uniforms.uGridOpacity.value}set gridOpacity(e){this.uniforms.uGridOpacity.value=e}get subgridOpacity(){return this.uniforms.uSubgridOpacity.value}set subgridOpacity(e){this.uniforms.uSubgridOpacity.value=e}}class gi extends v.Mesh{gridMaterial;constructor(e){const t=new fi(e);super(new v.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}class vi extends w.NodeMaterial{uScale;uDivisions;uColor;uDistance;uSubgridOpacity;uGridOpacity;constructor(e){super(),this.name="InfiniteGrid",this.side=w.DoubleSide,this.transparent=!0,this.uScale=R.uniform(e?.scale??.1),this.uDivisions=R.uniform(e?.divisions??10),this.uColor=R.uniform(e?.color??new w.Color(16777215)),this.uDistance=R.uniform(e?.distance??1e4),this.uSubgridOpacity=R.uniform(e?.subgridOpacity??.15),this.uGridOpacity=R.uniform(e?.gridOpacity??.25);const{uScale:t,uDivisions:s,uColor:n,uDistance:r,uSubgridOpacity:a,uGridOpacity:o}=this,l=R.varyingProperty("vec3","vWorldPosition");this.positionNode=R.Fn(()=>{const h=R.positionLocal.xzy.mul(r).add(R.vec3(R.cameraPosition.x,R.float(0),R.cameraPosition.z));return l.assign(h),h})();const c=R.Fn(([h])=>{const u=l.xz.div(h),p=R.fwidth(u),m=R.abs(R.fract(u.sub(.5)).sub(.5)).div(p).div(2),C=R.min(m.x,m.y);return R.float(1).sub(R.min(C,R.float(1)))});this.outputNode=R.Fn(()=>{const h=l,u=R.max(R.float(200),R.abs(R.cameraPosition.y.sub(h.y))),p=R.float(R.distance(R.cameraPosition,h)),m=R.log(u).div(R.log(s)),C=R.pow(s,R.floor(m)),_=C.mul(s),E=_.mul(s),g=c(C.mul(t)),y=c(_.mul(t)),x=c(E.mul(t)),O=u.sub(C).div(_.sub(C)),S=R.float(.3),T=R.max(O.sub(R.float(1)).add(S),R.float(0)).div(S),M=g.mul(R.pow(R.float(1).sub(R.min(p.div(r),R.float(1))),R.float(3))),U=R.float(.5),A=M.sub(T).mul(a),j=R.mix(A,M.mul(o).sub(T.mul(o.sub(a)).mul(U)),y),J=R.float(R.mix(j,M.mul(o),x));return R.If(R.lessThanEqual(J,R.float(1/127)),()=>{R.Discard()}),R.vec4(n,J)})()}get color(){return this.uColor.value}set color(e){this.uColor.value=e}get gridOpacity(){return this.uGridOpacity.value}set gridOpacity(e){this.uGridOpacity.value=e}get subgridOpacity(){return this.uSubgridOpacity.value}set subgridOpacity(e){this.uSubgridOpacity.value=e}}class _i extends w.Mesh{gridMaterial;constructor(e){const t=new vi(e);super(new w.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}function mt(i){const[e,t]=b.useState(i.selected),s="toggle"+(e?" selected":"");return d.jsx("button",{className:s,onClick:()=>{const n=!e;t(n),i.onClick(n)},style:{backgroundImage:`url(${i.icon})`,backgroundPositionX:"center",backgroundPositionY:i.top!==void 0?`${i.top}px`:"center",backgroundSize:`${i.width!==void 0?`${i.width}px`:"26px"} ${i.height}px`}},i.name)}class yi extends Kt{constructor(){super();const e=je.remapClamp(je.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=je.vec4(e,e,e,1)}}class Ci extends Kt{constructor(){super(),this.colorNode=je.vec4(je.uv(),0,1)}}class G extends v.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(L.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Q(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 ji.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:G.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:G.DRAG_END})}),t.addEventListener("dragging-changed",n=>{q.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(),Q(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(t))})}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 G._instance||(G._instance=new G),G._instance}}const Cn=new w.BoxGeometry,ft=new w.Vector2;class Ke extends w.Object3D{curve=new w.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new w.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new w.Color($.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new w.LineBasicMaterial({color:s}),this.line=new w.Line(new w.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new w.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new w.Mesh(new w.SphereGeometry(1.5),new w.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new w.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),G.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([X(t.position.x,3),X(t.position.y,3),X(t.position.z,3)])}),Xt({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])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new w.Mesh(Cn,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const r=this.points.length>1;return r&&t&&this.updateSpline(),this.line.visible=r,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new w.Vector3,s=this.addPoint(t);this.updateField(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.updateField(t.position)}Q(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)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new w.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new w.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!q.instance||!q.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=q.instance.currentWindow.current.getBoundingClientRect();ft.x=(e.clientX-s.x)/s.width*2-1,ft.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ft,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const r=n[0].object;r!==this._transform?.object&&(this._transform?.attach(r),this.updateField(r.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new w.Vector3}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))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=G.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),q.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,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:1e3,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:n}],onUpdate:(r,a)=>{switch(r){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":this.parent.currentSpline=null,Q(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const o=this._transform?.object;o.name.search("point")>-1&&(o.position.copy(a),this.updateSpline())}break}}}),this.draggable.children.forEach(r=>{this.debugPoint(r)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let qe=0;class bi extends v.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(L.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=k.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{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"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(L.ADD_SPLINE,this.onAddSpline),k.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${qe+1}`,s=new Ke(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),qe++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new v.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new v.Vector3(n[0],n[1],n[2]))});const s=new Ke(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s,!1),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=t.name!==void 0?t.name:`Spline ${qe+1}`,n=new Ke(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const r=[];t.points.forEach(a=>{r.push(new v.Vector3(a[0],a[1],a[2]))}),n.addPoints(r),this.addSpline(n,!1),qe++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,r=-((e.clientY-s.top)/s.height)*2+1;if(q.instance){const o=new v.Raycaster;o.setFromCamera(new v.Vector2(n,r),this._camera);const l=o.intersectObjects(q.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const a=this.mouseToSplinePos(n,r,s.width,s.height);this.currentSpline?.addPoint(a),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,r=-((e.clientY-s.top)/s.height)*2+1,a=this.mouseToSplinePos(n,r,s.width,s.height);this.currentSpline?.updateLastPoint(a),this.currentSpline?.updateField(a)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const r=new v.Vector3,a=Math.PI/2,o=this._camera,l=o.zoom,c=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-a&&o.rotation.z===0,p=o.rotation.x===-6162975822039155e-48&&o.rotation.y===a&&o.rotation.z===0,m=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,C=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let _=e,E=t;h||p?_*=-1:m&&(E*=-1);const g=s/2/l,y=n/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const x=_*g+o.position.x,O=E*y+o.position.y;r.set(x,O,0)}else if(u||p){const x=_*g+o.position.z,O=E*y+o.position.y;r.set(0,O,x)}else if(m||C){const x=_*g+o.position.x,O=E*y+o.position.z;r.set(x,0,O)}return r}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const $t=["Single","Side by Side","Stacked","Quad"],bn="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",En="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==",Sn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class q extends b.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new w.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new w.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new w.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;cameraControlsStartTime=0;cameraControlsLastTime=0;debugCamera;raycaster=new w.Raycaster;pointer=new w.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(L.ADD_RENDERER,this.setupRenderer),this.scene=new w.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=b.createRef(),this.containerRef=b.createRef(),this.tlWindow=b.createRef(),this.trWindow=b.createRef(),this.blWindow=b.createRef(),this.brWindow=b.createRef();const t=e.three.name,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 r={Vector2:w.Vector2,Vector3:w.Vector3,Vector4:w.Vector4,Quaternion:w.Quaternion,Matrix4:w.Matrix4,Spherical:w.Spherical,Box3:w.Box3,Sphere:w.Sphere,Raycaster:w.Raycaster};re.install({THREE:r});const a=localStorage.getItem(this.expandedCameraVisibility);a!==null&&(this.cameraVisibility=a==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),q.instance=this}componentDidMount(){this.setupScene(),this.setupTools(),this.enable(),this.assignControls(),this.resize(),this.play(),G.instance.setApp(this.props.three),G.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),k.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),d.jsxs("div",{className:"multiview",children:[d.jsx("canvas",{ref:this.canvasRef}),d.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&d.jsx(d.Fragment,{children:d.jsx(ge,{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")&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{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)}}),d.jsx(ge,{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"&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{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)}}),d.jsx(ge,{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)}}),d.jsx(ge,{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)}}),d.jsx(ge,{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)}})]})]}),d.jsxs("div",{className:"settings",children:[d.jsx(Qe,{title:"View",index:$t.indexOf(this.state.mode),options:$t,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})}}),d.jsx(Qe,{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})}}),d.jsx(mt,{name:"cameraHelper",icon:bn,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){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),d.jsx(mt,{name:"lightHelper",icon:En,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)}}}),d.jsx(mt,{name:"gridHelper",icon:Sn,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof v.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof w.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;if(s===null){setTimeout(()=>this.props.three.requestRenderer(),100);return}this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new v.WebGLRenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),Q(this.grid)),this.grid=new gi,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new w.WebGPURenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),Q(this.grid)),this.grid=new _i,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial?.dispose(),this.normalsMaterial?.dispose(),this.uvMaterial?.dispose(),this.depthMaterial=new yi,this.normalsMaterial=new w.MeshNormalNodeMaterial,this.uvMaterial=new Ci,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(r,a)=>{const o=new w.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=r,o.position.copy(a),o.lookAt(0,0,0),this.cameras.set(r,o),o},t=1e3;e("Top",new w.Vector3(0,t,0)),e("Bottom",new w.Vector3(0,-t,0)),e("Left",new w.Vector3(-t,0,0)),e("Right",new w.Vector3(t,0,0)),e("Front",new w.Vector3(0,0,t)),e("Back",new w.Vector3(0,0,-t)),e("Orthographic",new w.Vector3(t,t,t)),e("UI",new w.Vector3),this.debugCamera=new w.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_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")),k.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(r,a)=>{switch(r){case"Hide All Transforms":G.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(r,a)=>{switch(r){case"Near":this.debugCamera.near=a,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=a,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(r,a)=>{switch(r){case"Position":this.grid&&(this.grid.position.y=a);break;case"Color":this.grid&&this.grid.color.setStyle(a);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=a);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=a);break}}}]})}setupTools(){this.splineEditor=new bi(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.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})}clear(){this.three.dispatchEvent({type:L.CLEAR_OBJECT}),k.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),G.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,G.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:L.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:L.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=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.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&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),this.three.addEventListener(L.ADD_SCENE,this.addScene),this.three.addEventListener(L.SET_SCENE,this.sceneUpdate),this.three.addEventListener(L.REMOVE_SCENE,this.removeScene),this.three.addEventListener(L.ADD_CAMERA,this.addCamera),this.three.addEventListener(L.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(L.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),this.three.removeEventListener(L.ADD_SCENE,this.addScene),this.three.removeEventListener(L.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(L.REMOVE_SCENE,this.removeScene),this.three.removeEventListener(L.ADD_CAMERA,this.addCamera),this.three.removeEventListener(L.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(L.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);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.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 r=s/n;this.cameras.forEach(a=>{a instanceof w.OrthographicCamera?(a.left=s/-2,a.right=s/2,a.top=n/2,a.bottom=n/-2,a.name==="UI"&&(a.position.x=this.width/2,a.position.y=this.height/-2,a.position.z=100),a.updateProjectionMatrix()):a instanceof w.PerspectiveCamera&&(a.aspect=r,a.updateProjectionMatrix()),this.cameraHelpers.get(a.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=this.scenes.get(e.value.name);if(s!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s;return}const n=new t;n.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(n),this.props.three.scene=n,this.scenes.set(e.value.name,n),this.scene.add(n)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene)),this.cameraHelpers.forEach((s,n)=>{const r=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",n)!==void 0;s.visible=this.cameraVisibility&&r})};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{Q(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const r=n;this.cameras.set(s,r);const a=new w.CameraHelper(r),o=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",s)!==void 0;a.visible=this.cameraVisibility&&o,this.cameraHelpers.set(s,a),this.helpersContainer.add(a),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new w.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=$.mapLinear(s,0,t.x,-1,1),this.pointer.y=$.mapLinear(n,0,t.y,1,-1);const r=t.x/2,a=t.y/2,o=()=>{s<r?this.pointer.x=$.mapLinear(s,0,r,-1,1):this.pointer.x=$.mapLinear(s,r,t.x,-1,1)},l=()=>{n<a?this.pointer.y=$.mapLinear(n,0,a,1,-1):this.pointer.y=$.mapLinear(n,a,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,n,r,a),this.state.interactionMode==="Orbit"||this.currentScene===void 0)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"||this.currentScene===void 0)return;const t=new w.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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof w.Mesh||this.selectedItem instanceof w.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new re(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo($.degToRad(45),$.degToRad(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=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),G.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=G.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.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),tt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new w.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new w.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Ni.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new w.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new w.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);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 Fi.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,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.helpersContainer.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.helpersContainer.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),G.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15;this.cameraControlsStartTime=performance.now(),this.cameraControlsLastTime=this.cameraControlsStartTime,this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=performance.now(),a=(r-this.cameraControlsLastTime)/1e3;this.cameraControlsLastTime=r,this.cameraControls&&this.cameraControls.update(a),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=Re(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),(r-this.cameraControlsStartTime)/1e3>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};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")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"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}drawTo(e,t,s,n,r,a){switch(r.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=a,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,r)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),r=this.renderer instanceof w.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const a=this.height-n;r?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,a,this.width,n,this.trCam,t)):(this.drawTo(0,a,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof w.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),r=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),o=Math.floor(this.height/2),l=this.height-o;let c=0,h=e?0:this.height-o;c=0,this.drawTo(c,h,a,o,this.tlCam,t),c=a,this.drawTo(c,h,a,o,this.trCam,s),h=e?l:0,c=0,this.scene.overrideMaterial=n,this.drawTo(c,h,a,o,this.blCam,n),c=a,this.drawTo(c,h,a,o,this.brCam,r)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class tt extends b.Component{static instance;matrix=new v.Matrix4;position=new v.Vector3;rotation=new v.Euler;scale=new v.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)),tt.instance=this}update(){if(q.instance){const e=q.instance.selectedItem;if(e===void 0)return;this.position.x=X(e.position.x,3),this.position.y=X(e.position.y,3),this.position.z=X(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=X(e.scale.x,3),this.scale.y=X(e.scale.y,3),this.scale.z=X(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return d.jsx(te,{three:this.props.three,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 r=n.getObjectByProperty("uuid",this.props.object.uuid);V(r,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function Zt(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 xn(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function r(o){localStorage.setItem(t(),o?"open":"closed")}const a=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const l=i.lightInfo[o];l!==void 0&&(l.isColor!==void 0?a.push({title:Zt(o),prop:o,type:"color",value:l,onChange:(c,h)=>{const u=new v.Color(h);e.updateObject(i.uuid,c,u);const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);V(m,c,u)}}}):a.push({title:Zt(o),prop:o,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(c,h)=>{e.updateObject(i.uuid,c,h);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);V(p,c,h)}}}))}return d.jsx(te,{three:e,title:"Light",items:a,expanded:n,onToggle:o=>{r(o)}})}function On(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),r=n!==null?n==="open":!1;function a(p){localStorage.setItem(s(),p?"open":"closed")}const o=[],l=[];let c=0;e.animations.forEach(p=>{c=Math.max(c,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}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",e.uuid);if(p!==void 0){const m=p.mixer;if(m!==void 0){const _=[{title:"Time Scale",type:"range",value:m.timeScale,step:.01,min:-1,max:2,onChange:(E,g)=>{m.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];_.push({title:"Stop All",type:"button",onChange:()=>{m.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:_}),h=new v.SkeletonHelper(p),q.instance?.scene.add(h)}}}return b.useEffect(()=>()=>{h!==void 0&&Q(h)},[]),d.jsx(te,{three:i.three,title:"Animation",items:o,expanded:r,onToggle:p=>{a(p)}})}const gt={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:[]};function Ei(i){const[e,t]=b.useState(gt);b.useEffect(()=>{function a(l){t(l.value)}function o(){t(gt)}return i.three.addEventListener(L.CLEAR_OBJECT,o),i.three.addEventListener(L.SET_SCENE,o),i.three.addEventListener(L.SET_OBJECT,a),()=>{i.three.removeEventListener(L.CLEAR_OBJECT,o),i.three.removeEventListener(L.SET_SCENE,o),i.three.removeEventListener(L.SET_OBJECT,a)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,r=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return d.jsx(Ae,{three:i.three,label:"Inspector",button:e.uuid.length>0?d.jsx("button",{className:"remove",onClick:()=>{G.instance.remove(e.name),t(gt)}}):void 0,children:d.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs(d.Fragment,{children:[d.jsx(Ze,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),d.jsx(Ze,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),d.jsx(Ze,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),d.jsxs(d.Fragment,{children:[d.jsx(tt,{object:e,three:i.three}),n?d.jsx(On,{object:e,three:i.three}):null,s.search("camera")>-1?mn(e,i.three):null,s.search("light")>-1?xn(e,i.three):null,r?dn(e,i.three):null]})]})})},"Inspector")}function Si(i){const[e]=b.useState([]),[t]=b.useState([]),[s,n]=b.useState(0),r=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid)return;e.push(h),t.push(d.jsx(Ae,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},a=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=d.jsx(Ae,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},l=c=>{const h=c.value.name;for(let u=0;u<e.length;u++){const p=e[u],m=p.name===h;t[u]=d.jsx(Ae,{three:i.three,label:`Scene: ${p.name}`,scene:p,open:m,visible:m,onRefresh:()=>{i.three.refreshScene(p.name)},children:d.jsx($e,{child:p,scene:p,three:i.three})},p.name)}n(Date.now())};return b.useEffect(()=>(i.three.addEventListener(L.ADD_SCENE,r),i.three.addEventListener(L.SET_SCENE,l),i.three.addEventListener(L.REFRESH_SCENE,a),i.three.addEventListener(L.REMOVE_SCENE,o),()=>{i.three.removeEventListener(L.ADD_SCENE,r),i.three.removeEventListener(L.SET_SCENE,l),i.three.removeEventListener(L.REFRESH_SCENE,a),i.three.removeEventListener(L.REMOVE_SCENE,o)}),[]),d.jsxs("div",{id:"SidePanel",children:[d.jsx("div",{className:"scenes",children:t},s),d.jsx(Ei,{three:i.three}),d.jsx(k,{three:i.three})]})}const wt=b.forwardRef((i,e)=>d.jsxs("div",{className:"editor",ref:e,style:i.style,children:[i.header&&d.jsx("div",{className:"header",children:i.header}),i.children,i.footer&&d.jsx("div",{className:"footer",children:i.footer})]}));wt.displayName="Editor";function wn(i){return d.jsxs(wt,{children:[d.jsx(q,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),d.jsx(Si,{three:i.three})]})}function Tn(i){const{app:e,renderEditor:t,onLoad:s,renderLoading:n=null,children:r}=i,[a,o]=b.useState(!1);if(b.useEffect(()=>{e.detectSettings().then(()=>{s?s(e).then(()=>o(!0)):o(!0)})},[]),!a)return d.jsx(d.Fragment,{children:n});if(e.editor&&t){const l=e.components.get("three");return d.jsx(d.Fragment,{children:t(l)})}return d.jsx(d.Fragment,{children:r?.(e)})}const Mn=`#include <common>
93
+ }`;class dt extends p.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new p.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:p.GLSL3,side:p.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:es,fragmentShader:ts})}get color(){return this.uniforms.uColor.value}set color(e){this.uniforms.uColor.value=e}get gridOpacity(){return this.uniforms.uGridOpacity.value}set gridOpacity(e){this.uniforms.uGridOpacity.value=e}get subgridOpacity(){return this.uniforms.uSubgridOpacity.value}set subgridOpacity(e){this.uniforms.uSubgridOpacity.value=e}}class ht extends p.Mesh{gridMaterial;constructor(e){const t=new dt(e);super(new p.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}class ut extends b.NodeMaterial{uScale;uDivisions;uColor;uDistance;uSubgridOpacity;uGridOpacity;constructor(e){super(),this.name="InfiniteGrid",this.side=b.DoubleSide,this.transparent=!0,this.uScale=C.uniform(e?.scale??.1),this.uDivisions=C.uniform(e?.divisions??10),this.uColor=C.uniform(e?.color??new b.Color(16777215)),this.uDistance=C.uniform(e?.distance??1e4),this.uSubgridOpacity=C.uniform(e?.subgridOpacity??.15),this.uGridOpacity=C.uniform(e?.gridOpacity??.25);const{uScale:t,uDivisions:s,uColor:n,uDistance:a,uSubgridOpacity:r,uGridOpacity:o}=this,l=C.varyingProperty("vec3","vWorldPosition");this.positionNode=C.Fn(()=>{const h=C.positionLocal.xzy.mul(a).add(C.vec3(C.cameraPosition.x,C.float(0),C.cameraPosition.z));return l.assign(h),h})();const d=C.Fn(([h])=>{const u=l.xz.div(h),m=C.fwidth(u),f=C.abs(C.fract(u.sub(.5)).sub(.5)).div(m).div(2),y=C.min(f.x,f.y);return C.float(1).sub(C.min(y,C.float(1)))});this.outputNode=C.Fn(()=>{const h=l,u=C.max(C.float(200),C.abs(C.cameraPosition.y.sub(h.y))),m=C.float(C.distance(C.cameraPosition,h)),f=C.log(u).div(C.log(s)),y=C.pow(s,C.floor(f)),g=y.mul(s),S=g.mul(s),O=d(y.mul(t)),M=d(g.mul(t)),T=d(S.mul(t)),R=u.sub(y).div(g.sub(y)),D=C.float(.3),V=C.max(R.sub(C.float(1)).add(D),C.float(0)).div(D),H=O.mul(C.pow(C.float(1).sub(C.min(m.div(a),C.float(1))),C.float(3))),F=C.float(.5),E=H.sub(V).mul(r),j=C.mix(E,H.mul(o).sub(V.mul(o.sub(r)).mul(F)),M),le=C.float(C.mix(j,H.mul(o),T));return C.If(C.lessThanEqual(le,C.float(1/127)),()=>{C.Discard()}),C.vec4(n,le)})()}get color(){return this.uColor.value}set color(e){this.uColor.value=e}get gridOpacity(){return this.uGridOpacity.value}set gridOpacity(e){this.uGridOpacity.value=e}get subgridOpacity(){return this.uSubgridOpacity.value}set subgridOpacity(e){this.uSubgridOpacity.value=e}}class pt extends b.Mesh{gridMaterial;constructor(e){const t=new ut(e);super(new b.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}function xe(i){const[e,t]=v.useState(i.selected),s="toggle"+(e?" selected":"");return c.jsx("button",{className:s,onClick:()=>{const n=!e;t(n),i.onClick(n)},style:{backgroundImage:`url(${i.icon})`,backgroundPositionX:"center",backgroundPositionY:i.top!==void 0?`${i.top}px`:"center",backgroundSize:`${i.width!==void 0?`${i.width}px`:"26px"} ${i.height}px`}},i.name)}class mt extends $e{constructor(){super();const e=ae.remapClamp(ae.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=ae.vec4(e,e,e,1)}}class ft extends $e{constructor(){super(),this.colorNode=ae.vec4(ae.uv(),0,1)}}class P extends p.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(w.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();U(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 It.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:P.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:P.DRAG_END})}),t.addEventListener("dragging-changed",n=>{N.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(),U(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(t))})}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 P._instance||(P._instance=new P),P._instance}}const is=new b.BoxGeometry,we=new b.Vector2;class me extends b.Object3D{curve=new b.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new b.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new b.Color(L.lerp(.5,1,Math.random()),L.lerp(.5,1,Math.random()),L.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new b.LineBasicMaterial({color:s}),this.line=new b.Line(new b.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new b.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new b.Mesh(new b.SphereGeometry(1.5),new b.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new b.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),P.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([_(t.position.x,3),_(t.position.y,3),_(t.position.z,3)])}),Ke({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])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new b.Mesh(is,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const a=this.points.length>1;return a&&t&&this.updateSpline(),this.line.visible=a,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new b.Vector3,s=this.addPoint(t);this.updateField(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.updateField(t.position)}U(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)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new b.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new b.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!N.instance||!N.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=N.instance.currentWindow.current.getBoundingClientRect();we.x=(e.clientX-s.x)/s.width*2-1,we.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(we,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.updateField(a.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new b.Vector3}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))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=P.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),N.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,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:1e3,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:n}],onUpdate:(a,r)=>{switch(a){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;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":this.parent.currentSpline=null,U(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const o=this._transform?.object;o.name.search("point")>-1&&(o.position.copy(r),this.updateSpline())}break}}}),this.draggable.children.forEach(a=>{this.debugPoint(a)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let he=0;class gt extends p.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(w.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=A.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{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"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(w.ADD_SPLINE,this.onAddSpline),A.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${he+1}`,s=new me(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),he++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new p.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new p.Vector3(n[0],n[1],n[2]))});const s=new me(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s,!1),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=t.name!==void 0?t.name:`Spline ${he+1}`,n=new me(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const a=[];t.points.forEach(r=>{a.push(new p.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),he++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1;if(N.instance){const o=new p.Raycaster;o.setFromCamera(new p.Vector2(n,a),this._camera);const l=o.intersectObjects(N.instance.helpersContainer.children,!0);for(let d=0;d<l.length;d++){const h=l[d];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.updateLastPoint(r),this.currentSpline?.updateField(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const a=new p.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,d=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,m=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,f=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,y=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let g=e,S=t;h||m?g*=-1:f&&(S*=-1);const O=s/2/l,M=n/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),d||h){const T=g*O+o.position.x,R=S*M+o.position.y;a.set(T,R,0)}else if(u||m){const T=g*O+o.position.z,R=S*M+o.position.y;a.set(0,R,T)}else if(f||y){const T=g*O+o.position.x,R=S*M+o.position.z;a.set(T,0,R)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const ze=["Single","Side by Side","Stacked","Quad"],ss="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",ns="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==",rs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class N extends v.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new b.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new b.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new b.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;cameraControlsStartTime=0;cameraControlsLastTime=0;debugCamera;raycaster=new b.Raycaster;pointer=new b.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(w.ADD_RENDERER,this.setupRenderer),this.scene=new b.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=v.createRef(),this.containerRef=v.createRef(),this.tlWindow=v.createRef(),this.trWindow=v.createRef(),this.blWindow=v.createRef(),this.brWindow=v.createRef();const t=e.three.name,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:b.Vector2,Vector3:b.Vector3,Vector4:b.Vector4,Quaternion:b.Quaternion,Matrix4:b.Matrix4,Spherical:b.Spherical,Box3:b.Box3,Sphere:b.Sphere,Raycaster:b.Raycaster};q.install({THREE:a});const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),N.instance=this}componentDidMount(){this.setupScene(),this.setupTools(),this.enable(),this.assignControls(),this.resize(),this.play(),P.instance.setApp(this.props.three),P.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),A.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:this.canvasRef}),c.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&c.jsx(c.Fragment,{children:c.jsx($,{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")&&c.jsxs(c.Fragment,{children:[c.jsx($,{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)}}),c.jsx($,{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"&&c.jsxs(c.Fragment,{children:[c.jsx($,{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)}}),c.jsx($,{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)}}),c.jsx($,{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)}}),c.jsx($,{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)}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(ge,{title:"View",index:ze.indexOf(this.state.mode),options:ze,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})}}),c.jsx(ge,{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})}}),c.jsx(xe,{name:"cameraHelper",icon:ss,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){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),c.jsx(xe,{name:"lightHelper",icon:ns,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)}}}),c.jsx(xe,{name:"gridHelper",icon:rs,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof p.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof b.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;if(s===null){setTimeout(()=>this.props.three.requestRenderer(),100);return}this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new p.WebGLRenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),U(this.grid)),this.grid=new ht,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new b.WebGPURenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),U(this.grid)),this.grid=new pt,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial?.dispose(),this.normalsMaterial?.dispose(),this.uvMaterial?.dispose(),this.depthMaterial=new mt,this.normalsMaterial=new b.MeshNormalNodeMaterial,this.uvMaterial=new ft,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const o=new b.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=a,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(a,o),o},t=1e3;e("Top",new b.Vector3(0,t,0)),e("Bottom",new b.Vector3(0,-t,0)),e("Left",new b.Vector3(-t,0,0)),e("Right",new b.Vector3(t,0,0)),e("Front",new b.Vector3(0,0,t)),e("Back",new b.Vector3(0,0,-t)),e("Orthographic",new b.Vector3(t,t,t)),e("UI",new b.Vector3),this.debugCamera=new b.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_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")),A.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":P.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(a,r)=>{switch(a){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(a,r)=>{switch(a){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new gt(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.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})}clear(){this.three.dispatchEvent({type:w.CLEAR_OBJECT}),A.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,P.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:w.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:w.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=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.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&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),this.three.addEventListener(w.ADD_SCENE,this.addScene),this.three.addEventListener(w.SET_SCENE,this.sceneUpdate),this.three.addEventListener(w.REMOVE_SCENE,this.removeScene),this.three.addEventListener(w.ADD_CAMERA,this.addCamera),this.three.addEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(w.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),this.three.removeEventListener(w.ADD_SCENE,this.addScene),this.three.removeEventListener(w.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(w.REMOVE_SCENE,this.removeScene),this.three.removeEventListener(w.ADD_CAMERA,this.addCamera),this.three.removeEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(w.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);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.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 b.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 b.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=this.scenes.get(e.value.name);if(s!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s;return}const n=new t;n.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(n),this.props.three.scene=n,this.scenes.set(e.value.name,n),this.scene.add(n)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene)),this.cameraHelpers.forEach((s,n)=>{const a=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",n)!==void 0;s.visible=this.cameraVisibility&&a})};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{U(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const a=n;this.cameras.set(s,a);const r=new b.CameraHelper(a),o=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",s)!==void 0;r.visible=this.cameraVisibility&&o,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new b.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=L.mapLinear(s,0,t.x,-1,1),this.pointer.y=L.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=L.mapLinear(s,0,a,-1,1):this.pointer.x=L.mapLinear(s,a,t.x,-1,1)},l=()=>{n<r?this.pointer.y=L.mapLinear(n,0,r,1,-1):this.pointer.y=L.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new b.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"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof b.Mesh||this.selectedItem instanceof b.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(L.degToRad(45),L.degToRad(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=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=P.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.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),ye.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new b.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new b.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Rt.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new b.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new b.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);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 Tt.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,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.helpersContainer.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.helpersContainer.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),P.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15;this.cameraControlsStartTime=performance.now(),this.cameraControlsLastTime=this.cameraControlsStartTime,this.selectedItem.getWorldPosition(e.target0);const n=()=>{const a=performance.now(),r=(a-this.cameraControlsLastTime)/1e3;this.cameraControlsLastTime=a,this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=ie(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),(a-this.cameraControlsStartTime)/1e3>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};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")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"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}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,a)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),a=this.renderer instanceof b.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const r=this.height-n;a?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,r,this.width,n,this.trCam,t)):(this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof b.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),a=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),o=Math.floor(this.height/2),l=this.height-o;let d=0,h=e?0:this.height-o;d=0,this.drawTo(d,h,r,o,this.tlCam,t),d=r,this.drawTo(d,h,r,o,this.trCam,s),h=e?l:0,d=0,this.scene.overrideMaterial=n,this.drawTo(d,h,r,o,this.blCam,n),d=r,this.drawTo(d,h,r,o,this.brCam,a)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class ye extends v.Component{static instance;matrix=new p.Matrix4;position=new p.Vector3;rotation=new p.Euler;scale=new p.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)),ye.instance=this}update(){if(N.instance){const e=N.instance.selectedItem;if(e===void 0)return;this.position.x=_(e.position.x,3),this.position.y=_(e.position.y,3),this.position.z=_(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=_(e.scale.x,3),this.scale.y=_(e.scale.y,3),this.scale.z=_(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return c.jsx(G,{three:this.props.three,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);I(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function qe(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 as(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const l=i.lightInfo[o];l!==void 0&&(l.isColor!==void 0?r.push({title:qe(o),prop:o,type:"color",value:l,onChange:(d,h)=>{const u=new p.Color(h);e.updateObject(i.uuid,d,u);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);I(f,d,u)}}}):r.push({title:qe(o),prop:o,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(d,h)=>{e.updateObject(i.uuid,d,h);const u=e.getScene(i.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",i.uuid);I(m,d,h)}}}))}return c.jsx(G,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function os(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(m){localStorage.setItem(s(),m?"open":"closed")}const o=[],l=[];let d=0;e.animations.forEach(m=>{d=Math.max(d,m.duration),m.duration>0&&l.push({title:m.name,items:[{title:"Duration",type:"number",value:m.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",e.uuid);if(m!==void 0){const f=m.mixer;if(f!==void 0){const g=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(S,O)=>{f.timeScale=O,t.updateObject(e.uuid,"mixer.timeScale",O)}}];g.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:g}),h=new p.SkeletonHelper(m),N.instance?.scene.add(h)}}}return v.useEffect(()=>()=>{h!==void 0&&U(h)},[]),c.jsx(G,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:m=>{r(m)}})}const Me={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:[]};function vt(i){const[e,t]=v.useState(Me);v.useEffect(()=>{function r(l){t(l.value)}function o(){t(Me)}return i.three.addEventListener(w.CLEAR_OBJECT,o),i.three.addEventListener(w.SET_SCENE,o),i.three.addEventListener(w.SET_OBJECT,r),()=>{i.three.removeEventListener(w.CLEAR_OBJECT,o),i.three.removeEventListener(w.SET_SCENE,o),i.three.removeEventListener(w.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return c.jsx(te,{three:i.three,label:"Inspector",button:e.uuid.length>0?c.jsx("button",{className:"remove",onClick:()=>{P.instance.remove(e.name),t(Me)}}):void 0,children:c.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(pe,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),c.jsx(pe,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),c.jsx(pe,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),c.jsxs(c.Fragment,{children:[c.jsx(ye,{object:e,three:i.three}),n?c.jsx(os,{object:e,three:i.three}):null,s.search("camera")>-1?Zi(e,i.three):null,s.search("light")>-1?as(e,i.three):null,a?Ji(e,i.three):null]})]})})},"Inspector")}function bt(i){const[e]=v.useState([]),[t]=v.useState([]),[s,n]=v.useState(0),a=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid)return;e.push(h),t.push(c.jsx(te,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(ue,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=c.jsx(te,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(ue,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},l=d=>{const h=d.value.name;for(let u=0;u<e.length;u++){const m=e[u],f=m.name===h;t[u]=c.jsx(te,{three:i.three,label:`Scene: ${m.name}`,scene:m,open:f,visible:f,onRefresh:()=>{i.three.refreshScene(m.name)},children:c.jsx(ue,{child:m,scene:m,three:i.three})},m.name)}n(Date.now())};return v.useEffect(()=>(i.three.addEventListener(w.ADD_SCENE,a),i.three.addEventListener(w.SET_SCENE,l),i.three.addEventListener(w.REFRESH_SCENE,r),i.three.addEventListener(w.REMOVE_SCENE,o),()=>{i.three.removeEventListener(w.ADD_SCENE,a),i.three.removeEventListener(w.SET_SCENE,l),i.three.removeEventListener(w.REFRESH_SCENE,r),i.three.removeEventListener(w.REMOVE_SCENE,o)}),[]),c.jsxs("div",{id:"SidePanel",children:[c.jsx("div",{className:"scenes",children:t},s),c.jsx(vt,{three:i.three}),c.jsx(A,{three:i.three})]})}const je=v.forwardRef((i,e)=>c.jsxs("div",{className:"editor",ref:e,style:i.style,children:[i.header&&c.jsx("div",{className:"header",children:i.header}),i.children,i.footer&&c.jsx("div",{className:"footer",children:i.footer})]}));je.displayName="Editor";function cs(i){return c.jsxs(je,{children:[c.jsx(N,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),c.jsx(bt,{three:i.three})]})}function ls(i){const{app:e,renderEditor:t,onLoad:s,renderLoading:n=null,children:a}=i,[r,o]=v.useState(!1);if(v.useEffect(()=>{e.detectSettings().then(()=>{s?s(e).then(()=>o(!0)):o(!0)})},[]),!r)return c.jsx(c.Fragment,{children:n});if(e.editor&&t){const l=e.components.get("three");return c.jsx(c.Fragment,{children:t(l)})}return c.jsx(c.Fragment,{children:a?.(e)})}const ds=`#include <common>
116
94
  #include <batching_pars_vertex>
117
95
  #include <uv_pars_vertex>
118
96
  #include <color_pars_vertex>
@@ -142,7 +120,7 @@ void main() {
142
120
  #include <logdepthbuf_vertex>
143
121
  #include <clipping_planes_vertex>
144
122
  #include <worldpos_vertex>
145
- }`,An=`
123
+ }`,hs=`
146
124
  uniform float opacity;
147
125
  #include <common>
148
126
  #include <uv_pars_fragment>
@@ -152,4 +130,4 @@ void main() {
152
130
  #include <clipping_planes_fragment>
153
131
  if (opacity < 0.015) discard;
154
132
  gl_FragColor = vec4(vec3(vUv, 0.0), opacity);
155
- }`;class Rn extends v.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:Mn,fragmentShader:An,transparent:!0})}}exports.Accordion=Ae;exports.Application=ks;exports.BaseRemote=St;exports.ChildObject=Ot;exports.ContainerObject=$e;exports.DepthNodeMaterial=yi;exports.Draggable=hi;exports.DraggableItem=ci;exports.Dropdown=di;exports.DropdownItem=ui;exports.Editor=wt;exports.ElementProxy=Us;exports.ElementProxyReceiver=oi;exports.ExportTexture=ae;exports.HermesApp=Tn;exports.ImageSequenceCapturer=qi;exports.InfiniteGridHelper=gi;exports.InfiniteGridHelperGPU=_i;exports.InfiniteGridMaterial=fi;exports.InfiniteGridNodeMaterial=vi;exports.Inspector=Ei;exports.MultiView=q;exports.NavButton=xt;exports.ProxyManager=Ls;exports.RemoteTheatre=js;exports.RemoteThree=Ws;exports.SidePanel=Si;exports.Spline=Ke;exports.SplineEditor=bi;exports.ThreeEditor=wn;exports.Transform=G;exports.UVMaterial=Rn;exports.UVNodeMaterial=Ci;exports.WebworkerEventHandlers=Ds;exports.anchorGeometry=ri;exports.anchorGeometryTL=us;exports.animateObjectMaterial=ls;exports.animateObjectTransform=as;exports.applyObjectMaterial=ni;exports.capitalize=He;exports.clamp=de;exports.clearComposerGroups=Ss;exports.colorToHex=vt;exports.copyToClipboard=Xt;exports.createMask=gs;exports.cubicBezier=is;exports.customizeTheatreElements=rs;exports.damp=Ki;exports.defaultTheatreCallback=zi;exports.detectMaxFrameRate=ei;exports.detectSettings=ti;exports.dispose=Q;exports.disposeMaterial=bt;exports.disposeTexture=_t;exports.distance=Zi;exports.generateCubemap=xs;exports.getAngle=Xi;exports.getObjectMaterialObject=si;exports.getObjectMaterialProps=ii;exports.hierarchyUUID=Me;exports.inspectComposer=Es;exports.inspectComposerPass=ai;exports.isColor=Qt;exports.map=$i;exports.mix=Re;exports.noop=ze;exports.normalize=Xe;exports.orthoCamera=cs;exports.parseModelLite=hs;exports.randomID=W;exports.renderToTexture=ds;exports.resetThreeObjects=Ne;exports.rgbaToHex=ss;exports.roundTo=X;exports.setMaterialBlendAdd=ys;exports.setMaterialBlendMultiply=Cs;exports.setMaterialBlendNormal=_s;exports.setMaterialBlendScreen=bs;exports.supportsOffscreenCanvas=fs;exports.triangle=Je;exports.updateCameraOrtho=ps;exports.updateCameraOrtho16x9=ms;exports.useMask=vs;exports.useStudio=ns;
133
+ }`;class us extends p.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:ds,fragmentShader:hs,transparent:!0})}}exports.Accordion=te;exports.Application=xi;exports.BaseRemote=Pe;exports.ChildObject=De;exports.ContainerObject=ue;exports.DepthNodeMaterial=mt;exports.Draggable=at;exports.DraggableItem=rt;exports.Dropdown=ot;exports.DropdownItem=ct;exports.Editor=je;exports.ElementProxy=Ci;exports.ElementProxyReceiver=st;exports.ExportTexture=B;exports.HermesApp=ls;exports.ImageSequenceCapturer=Dt;exports.InfiniteGridHelper=ht;exports.InfiniteGridHelperGPU=pt;exports.InfiniteGridMaterial=dt;exports.InfiniteGridNodeMaterial=ut;exports.Inspector=vt;exports.MultiView=N;exports.NavButton=ke;exports.ProxyManager=Si;exports.RemoteTheatre=Ei;exports.RemoteThree=Pi;exports.SidePanel=bt;exports.Spline=me;exports.SplineEditor=gt;exports.ThreeEditor=cs;exports.Transform=P;exports.UVMaterial=us;exports.UVNodeMaterial=ft;exports.WebworkerEventHandlers=bi;exports.anchorGeometry=tt;exports.anchorGeometryTL=Qt;exports.animateObjectMaterial=Kt;exports.animateObjectTransform=qt;exports.applyObjectMaterial=et;exports.capitalize=ce;exports.clamp=z;exports.clearComposerGroups=li;exports.colorToHex=Ee;exports.copyToClipboard=Ke;exports.createMask=ii;exports.cubicBezier=Vt;exports.customizeTheatreElements=zt;exports.damp=Lt;exports.defaultTheatreCallback=Pt;exports.detectMaxFrameRate=Je;exports.detectSettings=Xe;exports.dispose=U;exports.disposeMaterial=Te;exports.disposeTexture=Ae;exports.distance=Nt;exports.generateCubemap=di;exports.getAngle=_t;exports.getObjectMaterialObject=Ze;exports.getObjectMaterialProps=Qe;exports.hierarchyUUID=ee;exports.inspectComposer=ci;exports.inspectComposerPass=it;exports.isColor=Ye;exports.map=jt;exports.mix=ie;exports.noop=oe;exports.normalize=fe;exports.orthoCamera=Yt;exports.parseModelLite=Jt;exports.randomID=k;exports.renderToTexture=Xt;exports.resetThreeObjects=ne;exports.rgbaToHex=Ht;exports.roundTo=_;exports.setMaterialBlendAdd=ri;exports.setMaterialBlendMultiply=ai;exports.setMaterialBlendNormal=ni;exports.setMaterialBlendScreen=oi;exports.supportsOffscreenCanvas=ti;exports.triangle=ve;exports.updateCameraOrtho=Zt;exports.updateCameraOrtho16x9=ei;exports.useMask=si;exports.useStudio=Wt;