@tomorrowevening/hermes 0.1.28 → 0.1.30
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.
- package/dist/hermes.cjs.js +10 -10
- package/dist/hermes.es.js +868 -862
- package/dist/index-C9PVvFM6.js +10422 -0
- package/dist/{index-EMVSCFBo.css → index-D82t4hmO.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/types/core/remote/RemoteThree.d.ts +2 -2
- package/types/editor/multiView/DepthNodeMaterial.d.ts +1 -1
- package/types/editor/multiView/InfiniteGridHelperGPU.d.ts +1 -1
- package/types/editor/multiView/InfiniteGridNodeMaterial.d.ts +1 -2
- package/types/editor/multiView/MultiView.d.ts +2 -2
- package/types/editor/multiView/UVNodeMaterial.d.ts +1 -1
- package/types/editor/tools/splineEditor/Spline.d.ts +1 -1
- package/dist/index-CVtJiys9.js +0 -8907
package/dist/hermes.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Ai=Object.create;var Mt=Object.defineProperty;var Ri=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,Ii=Object.prototype.hasOwnProperty;var Ui=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Pi(e))!Ii.call(i,n)&&n!==t&&Mt(i,n,{get:()=>e[n],enumerable:!(s=Ri(e,n))||s.enumerable});return i};var Li=(i,e,t)=>(t=i!=null?Ai(Di(i)):{},Ui(e||!i||!i.__esModule?Mt(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@tomorrowevening/theatre-core"),b=require("react"),m=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"),ki=require("three/examples/jsm/controls/OrbitControls.js"),R=require("three/tsl"),Zt=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),ze=require("three/src/nodes/TSL.js"),Fi=require("three/examples/jsm/controls/TransformControls.js"),He=()=>{},zi=()=>{};function je(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function $t(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function Y(){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=c=>{const l=c.toString(16);return l.length===1?"0"+l:l},a=n(e),r=n(t),o=n(s);return"#"+a+r+o}function st(i,e,t,s){return new(t||(t=Promise))(function(n,a){function r(l){try{c(s.next(l))}catch(h){a(h)}}function o(l){try{c(s.throw(l))}catch(h){a(h)}}function c(l){var h;l.done?n(l.value):(h=l.value,h instanceof t?h:new t(function(u){u(h)})).then(r,o)}c((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 At(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 Kt=typeof window>"u",se=(()=>{if(Kt)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 ji(i,e,t){if(!t)return[e];const s=function(l){const h=`
|
|
2
2
|
precision highp float;
|
|
3
3
|
attribute vec3 aPosition;
|
|
4
4
|
varying float vvv;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
vvv = 0.31622776601683794;
|
|
7
7
|
gl_Position = vec4(aPosition, 1.0);
|
|
8
8
|
}
|
|
9
|
-
`,
|
|
9
|
+
`,u=`
|
|
10
10
|
precision highp float;
|
|
11
11
|
varying float vvv;
|
|
12
12
|
void main() {
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
|
|
16
16
|
gl_FragColor = enc;
|
|
17
17
|
}
|
|
18
|
-
`,m=l.createShader(35633),g=l.createShader(35632),y=l.createProgram();if(!(g&&m&&y))return;l.shaderSource(m,h),l.shaderSource(g,p),l.compileShader(m),l.compileShader(g),l.attachShader(y,m),l.attachShader(y,g),l.linkProgram(y),l.detachShader(y,m),l.detachShader(y,g),l.deleteShader(m),l.deleteShader(g),l.useProgram(y);const _=l.createBuffer();l.bindBuffer(34962,_),l.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const E=l.getAttribLocation(y,"aPosition");l.vertexAttribPointer(E,3,5126,!1,0,0),l.enableVertexAttribArray(E),l.clearColor(1,1,1,1),l.clear(16384),l.viewport(0,0,1,1),l.drawArrays(4,0,3);const v=new Uint8Array(4);return l.readPixels(0,0,1,1,6408,5121,v),l.deleteProgram(y),l.deleteBuffer(_),v.join("")}(i),n="801621810",a="8016218135",r="80162181161",o=ie?.isIpad?[["a7",r,12],["a8",a,15],["a8x",a,15],["a9",a,15],["a9x",a,15],["a10",a,15],["a10x",a,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",r,12],["a8",a,12],["a9",a,15],["a10",a,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let c;return s==="80162181255"?c=o.filter(([,,l])=>l>=14):(c=o.filter(([,l])=>l===s),c.length||(c=o)),c.map(([l])=>`apple ${l} gpu`)}class At extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const st=[],Rt=[];function Hi(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 a,r=0;for(;r<s&&i.charCodeAt(r)===e.charCodeAt(r);)r++;if(s-=r,n-=r,s===0)return n;let o,c,l=0,h=0,p=0;for(;h<s;)Rt[h]=i.charCodeAt(r+h),st[h]=++h;for(;p<n;)for(a=e.charCodeAt(r+p),o=p++,l=p,h=0;h<s;h++)c=a===Rt[h]?o:o+1,o=st[h],l=st[h]=o>l?c>l?l+1:c:c>o?o+1:c;return l}function ji(i){return i!=null}const Bi=({mobileTiers:i=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:s,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:a="https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks"}={})=>it(void 0,void 0,void 0,function*(){const r={};if($t)return{tier:0,type:"SSR"};const{isIpad:o=!!ie?.isIpad,isMobile:c=!!ie?.isMobile,screenSize:l=window.screen,loadBenchmarks:h=S=>it(void 0,void 0,void 0,function*(){const w=yield fetch(`${a}/${S}`).then(M=>M.json());if(parseInt(w.shift().split(".")[0],10)<4)throw new At("Detect GPU benchmark data is out of date. Please update to version 4x");return w})}=t;let{renderer:p}=t;const m=(S,w,M,U,A)=>({device:A,fps:U,gpu:M,isMobile:c,tier:S,type:w});let g,y="";if(p)p=Mt(p),g=[p];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 F=window.document.createElement("canvas"),Q=F.getContext("webgl",A)||F.getContext("experimental-webgl",A);return Q??void 0}(ie?.isSafari12,n);if(!S)return m(0,"WEBGL_UNSUPPORTED");const w=ie?.isFirefox?null:S.getExtension("WEBGL_debug_renderer_info");if(p=w?S.getParameter(w.UNMASKED_RENDERER_WEBGL):S.getParameter(S.RENDERER),!p)return m(1,"FALLBACK");y=p,p=Mt(p),g=function(M,U,A){return U==="apple gpu"?zi(M,U,A):[U]}(S,p,c)}const _=(yield Promise.all(g.map(function(S){var w;return it(this,void 0,void 0,function*(){const M=(j=>{const $=c?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const ae of $)if(j.includes(ae))return ae})(S);if(!M)return;const U=`${c?"m":"d"}-${M}${o?"-ipad":""}.json`,A=r[U]=(w=r[U])!==null&&w!==void 0?w:h(U);let F;try{F=yield A}catch(j){if(j instanceof At)throw j;return}const Q=function(j){var $;const ae=(j=j.replace(/\([^)]+\)/,"")).match(/\d+/)||j.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return($=ae?.join("").replace(/\W|amd/g,""))!==null&&$!==void 0?$:""}(S);let re=F.filter(([,j])=>j===Q);re.length||(re=F.filter(([j])=>j.includes(S)));const de=re.length;if(de===0)return;const _e=S.split(/[.,()\[\]/\s]/g).sort().filter((j,$,ae)=>$===0||j!==ae[$-1]).join(" ");let ue,[bi,,,,Ei]=de>1?re.map(j=>[j,Hi(_e,j[2])]).sort(([,j],[,$])=>j-$)[0][0]:re[0],tt=Number.MAX_VALUE;const{devicePixelRatio:Ot}=window,Si=l.width*Ot*l.height*Ot;for(const j of Ei){const[$,ae]=j,wi=$*ae,wt=Math.abs(Si-wi);wt<tt&&(tt=wt,ue=j)}if(!ue)return;const[,,xi,Oi]=ue;return[tt,xi,bi,Oi]})}))).filter(ji).sort(([S=Number.MAX_VALUE,w],[M=Number.MAX_VALUE,U])=>S===M?w-U:S-M);if(!_.length){const S=Fi.find(w=>p.includes(w));return S?m(0,"BLOCKLISTED",S):m(1,"FALLBACK",`${p} (${y})`)}const[,E,v,C]=_[0];if(E===-1)return m(0,"BLOCKLISTED",v,E,C);const x=c?i:e;let O=0;for(let S=0;S<x.length;S++)E>=x[S]&&(O=S);return m(O,"BENCHMARK",v,E,C)});function qt(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 Kt(i=!1,e=!1){return new Promise(t=>{Bi().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 c=navigator.userAgent.match(/version\/(\d+)/i);n=(c?parseInt(c[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"),qt(c=>{o.fps=c,t(o)})})})}function he(i,e,t){return Math.min(e,Math.max(i,t))}function Ke(i,e,t){return(t-i)/(e-i)}function Ae(i,e,t){return i*(1-t)+e*t}function Vi(i,e,t,s,n){return Ae(t,s,Ke(i,e,n))}function Gi(i,e){const t=i-e;return Math.sqrt(t*t)}function Wi(i,e,t,s){return Ae(i,e,1-Math.exp(-t*s))}function K(i,e=1){return Number(i.toFixed(e))}function Yi(i,e,t,s){return Math.atan2(s-e,t-i)}function Zi(i,e,t,s){return i===e&&t===s}function $i(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function qi(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function Ki(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function Xi(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(Zi(e,t,s,n))return i;const a=0,r=0,o=e,c=t,l=s,h=n,p=1,m=1,g=p-3*l+3*o-a,y=3*l-6*o+3*a,_=3*o-3*a,E=a,v=m-3*h+3*c-r,C=3*h-6*c+3*r,x=3*c-3*r,O=r;let S=i;for(let w=0;w<5;w++){const M=qi(S,g,y,_,E);let U=$i(S,g,y,_);U===1/0&&(U=i),S-=(M-i)*U,S=Math.min(Math.max(S,0),1)}return Ki(S,v,C,x,O)}const je=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function Qi({r:i,g:e,b:t,a:s=1}){const n=`#${je(i)}${je(e)}${je(t)}`;return s<1?`${n}${je(s)}`:n}let Ce;function Ji(){const[i,e]=b.useState(Ce);return b.useEffect(()=>{Ce||import("@tomorrowevening/theatre-studio").then(t=>{Ce=t.default,Ce.initialize(),Ce.ui.hide(),e(Ce)})},[]),i}async function es(){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 ts(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 is=["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 Dt(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 Xt(i){const e=[];for(const s in i){const n=is.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||a))if(s==="uniforms"){const o=i.uniforms;for(const c in o){const l=o[c].value,h=Dt(l);h==="array"||h==="object"||e.push({name:`uniforms.${c}.value`,type:h,value:l})}}else{const o=Dt(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 Qt(i){const e={},t={nudgeMultiplier:.01};return i.forEach(s=>{let n=s.value;switch(s.type){case"color":n=P.types.rgba({r:n.r,g:n.g,b:n.b,a:1});break;case"number":n=P.types.number(n,t);break;case"euler":case"vector3":n={x:P.types.number(n.x,t),y:P.types.number(n.y,t),z:P.types.number(n.z,t)};break;case"vector2":n={x:P.types.number(n.x,t),y:P.types.number(n.y,t)};break;case"vector4":n={x:P.types.number(n.x,t),y:P.types.number(n.y,t),z:P.types.number(n.z,t),w:P.types.number(n.w,t)};break;case"matrix2":n={0:P.types.number(n.elements[0],t),1:P.types.number(n.elements[1],t),2:P.types.number(n.elements[2],t),3:P.types.number(n.elements[3],t)};break;case"matrix3":n={0:P.types.number(n.elements[0],t),1:P.types.number(n.elements[1],t),2:P.types.number(n.elements[2],t),3:P.types.number(n.elements[3],t),4:P.types.number(n.elements[4],t),5:P.types.number(n.elements[5],t),6:P.types.number(n.elements[6],t),7:P.types.number(n.elements[7],t),8:P.types.number(n.elements[8],t)};break;case"matrix4":n={0:P.types.number(n.elements[0],t),1:P.types.number(n.elements[1],t),2:P.types.number(n.elements[2],t),3:P.types.number(n.elements[3],t),4:P.types.number(n.elements[4],t),5:P.types.number(n.elements[5],t),6:P.types.number(n.elements[6],t),7:P.types.number(n.elements[7],t),8:P.types.number(n.elements[8],t),9:P.types.number(n.elements[9],t),10:P.types.number(n.elements[10],t),11:P.types.number(n.elements[11],t),12:P.types.number(n.elements[12],t),13:P.types.number(n.elements[13],t),14:P.types.number(n.elements[14],t),15:P.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 c=a[o];r[c]||(r[c]={}),r=r[c]}r[a[a.length-1]]=n}else e[s.name]=n}),e}function Jt(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 ss(i,e,t,s){if(!t.isMaterial)return;const n=Xt(t),a=Qt(n);s.sheetObject(i,e,{material:a},r=>{Jt(t,n,r)})}const Qe=new d.BufferGeometry;Qe.setAttribute("position",new d.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));Qe.setAttribute("normal",new d.Float32BufferAttribute([0,0,1,0,0,1],3));Qe.setAttribute("uv",new d.Float32BufferAttribute([0,0,2,0,0,2],2));const ns=new d.OrthographicCamera(-.5,.5,.5,-.5,0,100),vt=i=>{i?.dispose()},yt=i=>{if(i)if(Array.isArray(i))i.forEach(e=>yt(e));else{for(const e in i){const t=i[e];t!==null&&t instanceof d.Texture&&vt(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 d.Texture&&vt(s.value)}}i.dispose()}},ne=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):ne(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),yt(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const Ne=()=>{exports.totalThreeObjects=0},Te=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=>Te(t))};class oe{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 d.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new d.Scene,this.material=new d.MeshBasicMaterial;const t=new d.BufferGeometry;t.setAttribute("position",new d.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new d.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new d.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new d.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=d.LinearSRGBColorSpace,e.colorSpace=d.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function rs(i){return new Promise(e=>{const t=new d.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new d.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(c=>d.AnimationClip.parse(c));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 as=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function ei(i,e,t,s){i.applyMatrix4(new d.Matrix4().makeTranslation(e,-t,-s))}function os(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;ei(i,t,s,0)}function ls(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 cs(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 hs(){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 ds(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=d.AlwaysStencilFunc,a.stencilFail=d.ReplaceStencilOp,a.stencilZFail=d.ReplaceStencilOp,a.stencilZPass=d.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=d.AlwaysStencilFunc,n.stencilFail=d.ReplaceStencilOp,n.stencilZFail=d.ReplaceStencilOp,n.stencilZPass=d.ReplaceStencilOp)}function us(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?d.NotEqualStencilFunc:d.EqualStencilFunc,n.stencilFail=d.KeepStencilOp,n.stencilZFail=d.KeepStencilOp,n.stencilZPass=d.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?d.NotEqualStencilFunc:d.EqualStencilFunc,s.stencilFail=d.KeepStencilOp,s.stencilZFail=d.KeepStencilOp,s.stencilZPass=d.KeepStencilOp)}function ps(i){i.blending=d.NormalBlending,i.blendEquation=d.AddEquation,i.blendSrc=d.SrcAlphaFactor,i.blendDst=d.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ms(i){i.blending=d.CustomBlending,i.blendEquation=d.AddEquation,i.blendSrc=d.SrcAlphaFactor,i.blendDst=d.OneFactor,i.needsUpdate=!0}function fs(i){i.blending=d.CustomBlending,i.blendEquation=d.AddEquation,i.blendSrc=d.DstColorFactor,i.blendDst=d.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function gs(i){i.blending=d.CustomBlending,i.blendEquation=d.AddEquation,i.blendSrc=d.OneMinusDstColorFactor,i.blendDst=d.OneFactor,i.needsUpdate=!0}let _t=[];function ti(i,e,t=!0){oe.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,c)=>{if(c==="map")return;const l=`${r.name.replace("Effect","")} ${c}`;if(o.value===null&&t)s.push({prop:c,title:l,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,p=oe.renderToBlob(h);s.push({prop:c,title:l,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:p}})}else typeof o.value=="number"?s.push({prop:c,title:l,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:c,title:l,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:c,title:l,type:"boolean",value:o.value})})}),n=(r,o)=>{i.effects.forEach(c=>{c.uniforms.size>0&&c.uniforms.forEach((l,h)=>{h===r&&(l.value=o)})})};else if(i.name==="ShaderPass"){const r=i.fullscreenMaterial;for(const o in r.uniforms){if(o==="inputBuffer"||o==="map")continue;const c=r.uniforms[o],l=`${r.name.replace("Material","")} ${o}`;if(c.value===null&&t)s.push({title:l,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(c.value.isTexture&&t){const h=c.value,p=oe.renderToBlob(h);s.push({title:l,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:p}})}else typeof c.value=="number"?s.push({title:l,prop:o,type:"number",value:c.value,step:.01}):typeof c.value=="string"?s.push({title:l,prop:o,type:"string",value:c.value}):typeof c.value=="boolean"&&s.push({title:l,prop:o,type:"boolean",value:c.value})}n=(o,c)=>{const l=r.uniforms[o];l.value=c}}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)}}),_t.push(a)}function vs(i,e){i.passes.forEach(t=>{ti(t,e)})}function _s(i){_t.forEach(e=>{i.removeGroup(e)}),_t=[]}function Cs(i,e,t,s=1024){return new Promise(n=>{const a=e.aspect,r=e.fov,o=e.rotation.clone(),c=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const l=new d.WebGLRenderTarget(s,s,{format:d.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=l,ye(i,l,e,"nx",t,s).then(()=>{ye(i,l,e,"ny",t,s).then(()=>{ye(i,l,e,"nz",t,s).then(()=>{ye(i,l,e,"px",t,s).then(()=>{ye(i,l,e,"py",t,s).then(()=>{ye(i,l,e,"pz",t,s).then(()=>{e.aspect=a,e.fov=r,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=c,l.dispose(),n()})})})})})})})}function ye(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 c=new Uint8Array(a*a*4);i.readRenderTargetPixels(e,0,0,a,a,c);const l=document.createElement("canvas");l.width=l.height=a;const h=l.getContext("2d"),p=h.createImageData(a,a);p.data.set(c),h.putImageData(p,0,0);const m=document.createElement("canvas");m.width=m.height=a;const g=m.getContext("2d");g.translate(0,a),g.scale(1,-1),g.drawImage(l,0,0);const y=m.toDataURL("image/png"),_=document.createElement("a");_.href=y,_.download=`${t.name}_${s}.png`,document.body.appendChild(_),_.click(),_.remove(),r()})}const be=bt(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),ys=bt(["clientX","clientY","deltaX","deltaY","deltaMode"]),bs=bt(["ctrlKey","metaKey","shiftKey","keyCode"]);function Es(i,e){i.preventDefault(),ys(i,e)}function Ss(i){i.preventDefault()}function xs(i,e,t){for(const s of e)t[s]=i[s]}function bt(i){return function(t,s){const n={type:t.type};xs(t,i,n),s(n)}}function nt(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 Os={37:!0,38:!0,39:!0,40:!0};function ws(i,e){const{keyCode:t}=i;Os[t]&&(i.preventDefault(),bs(i,e))}const Ts={contextmenu:Ss,mousedown:be,mousemove:be,mouseup:be,pointerdown:be,pointermove:be,pointerup:be,touchstart:nt,touchmove:nt,touchend:nt,wheel:Es,keydown:ws};let Ms=0;class As{id;worker;constructor(e,t,s){this.id=Ms++,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,c=>{o(c,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class ii extends d.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 Rs{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new ii;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class Ds{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;dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(e=!1,t=!1){return new Promise(s=>{Kt(e,t).then(n=>{this.settings=n,s()})})}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 Et{name;_debug=!1;_editor=!1;broadcastChannel;constructor(e,t=!1,s=!1){this.name=e,this._debug=t,this._editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.broadcastChannel.addEventListener("message",this.messageHandler.bind(this)))}dispose(){this.broadcastChannel?.removeEventListener("message",this.messageHandler.bind(this)),this.broadcastChannel?.close()}get debug(){return this._debug}get editor(){return this._editor}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 Ps(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 Is(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 Ps(a,i.value,i.value+s,e.value+n,e.value)}class Us extends Et{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=P.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 c=`${this.getSheetInstance(e,a)}_${t}`;let l=this.sheetObjects.get(c),h=s;l!==void 0&&(h={...s,...l.value}),l=r.object(t,h,{reconfigure:!0}),this.sheetObjects.set(c,l),this.sheetObjectCBs.set(c,n!==void 0?n:ze);function p(g,y,_){if(typeof _=="object")if(Zt(_))g[y]={r:_.r,g:_.g,b:_.b,a:_.a};else for(const E in _){const v=_[E];typeof v=="object"&&p(_,E,v)}}const m=l.onValuesChange(g=>{const y=this.sheetObjectCBs.get(c);if(this.editor){for(const _ in g){const E=g[_];typeof E=="object"&&p(g,_,E)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:c,values:g}}),y&&y(g)}else y&&y(g)});return this.sheetObjectUnsubscribe.set(c,m),l}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),c=s.sequence.__experimental_getKeyframes(a.props.y),l=s.sequence.__experimental_getKeyframes(a.props.z),h=new Set;return o.forEach(m=>h.add(m.position)),c.forEach(m=>h.add(m.position)),l.forEach(m=>h.add(m.position)),Array.from(h).sort((m,g)=>m-g).forEach(m=>{const g=(y,_)=>{const E=y.find((x,O)=>x.position<=_&&(y[O+1]?.position||1/0)>_),v=y.find(x=>x.position>_);if(!E)return v?.value||0;if(!v||E.position===_)return E.value;if(E.type==="bezier")return Is(E,v,_);const C=(_-E.position)/(v.position-E.position);return E.value+C*(v.value-E.value)};r.push({position:m,x:g(o,m),y:g(c,m),z:g(l,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",c={};switch(a.type){case"Theatre_Sheet_PublicAPI":o="setSheet",c={sheet:a.address.sheetId},this.activeSheet=this.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",r+=`_${a.address.objectKey}`,c={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:c})})});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 Ls(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 le(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(le(t))}),e}function Ns(i){const e={};for(const t in i){const s=i[t].value;e[t]={value:s},s===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:s!==void 0&&s.isTexture&&(e[t].value={src:s.image.src,offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]})}return e}function ks(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"||ks(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:oe.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=Ns(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function rt(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(Ee(a))}),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(a=>{n.push(Ee(a))}),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(a=>{n.push(Ee(a))}),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 Fs(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 zs(i,e){for(const t in e)i[t]=e[t]}function B(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?zs(r,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function si(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new d.Texture(s);n.wrapS=d.RepeatWrapping,n.wrapT=d.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}var I=(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))(I||{});class Hs extends Et{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=>{ne(e)}),this.scenes.clear(),this.scene&&ne(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&&(oe.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){this.renderer!==void 0&&(oe.renderer=this.renderer);const t=rt(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const a=this.getObjectByUUID(e);if(a)try{n!==void 0?Fs(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&&B(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?si(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 d.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:d.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(),Te(e);const t=le(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=le(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=le(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&&(oe.renderer=this.renderer),Ne(),Te(e);const t=le(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=rt(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug)return;const t=rt(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:le(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.localClippingEnabled=e.data.localClippingEnabled,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,d.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new d.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClear:this.renderer.autoClear,autoClearColor:this.renderer.autoClearColor,autoClearDepth:this.renderer.autoClearDepth,autoClearStencil:this.renderer.autoClearStencil,outputColorSpace:this.renderer.outputColorSpace,localClippingEnabled:this.renderer.localClippingEnabled,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:d.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(t=>{Ne(),Te(t),this.send({event:"addScene",target:"editor",data:le(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(oe.renderer=this.renderer),Ne(),Te(this.scene),this.send({event:"setScene",target:"editor",data:le(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){const n=new d.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(he(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}function St(i){return i.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):u.jsx("button",{children:i.title})}const js=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Bs=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
|
|
18
|
+
`,p=l.createShader(35633),g=l.createShader(35632),y=l.createProgram();if(!(g&&p&&y))return;l.shaderSource(p,h),l.shaderSource(g,u),l.compileShader(p),l.compileShader(g),l.attachShader(y,p),l.attachShader(y,g),l.linkProgram(y),l.detachShader(y,p),l.detachShader(y,g),l.deleteShader(p),l.deleteShader(g),l.useProgram(y);const _=l.createBuffer();l.bindBuffer(34962,_),l.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const E=l.getAttribLocation(y,"aPosition");l.vertexAttribPointer(E,3,5126,!1,0,0),l.enableVertexAttribArray(E),l.clearColor(1,1,1,1),l.clear(16384),l.viewport(0,0,1,1),l.drawArrays(4,0,3);const v=new Uint8Array(4);return l.readPixels(0,0,1,1,6408,5121,v),l.deleteProgram(y),l.deleteBuffer(_),v.join("")}(i),n="801621810",a="8016218135",r="80162181161",o=se?.isIpad?[["a7",r,12],["a8",a,15],["a8x",a,15],["a9",a,15],["a9x",a,15],["a10",a,15],["a10x",a,15],["a12",n,15],["a12x",n,15],["a12z",n,15],["a14",n,15],["a15",n,15],["m1",n,15],["m2",n,15]]:[["a7",r,12],["a8",a,12],["a9",a,15],["a10",a,15],["a11",n,15],["a12",n,15],["a13",n,15],["a14",n,15],["a15",n,15],["a16",n,15],["a17",n,15]];let c;return s==="80162181255"?c=o.filter(([,,l])=>l>=14):(c=o.filter(([,l])=>l===s),c.length||(c=o)),c.map(([l])=>`apple ${l} gpu`)}class Rt extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const nt=[],Pt=[];function Bi(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 a,r=0;for(;r<s&&i.charCodeAt(r)===e.charCodeAt(r);)r++;if(s-=r,n-=r,s===0)return n;let o,c,l=0,h=0,u=0;for(;h<s;)Pt[h]=i.charCodeAt(r+h),nt[h]=++h;for(;u<n;)for(a=e.charCodeAt(r+u),o=u++,l=u,h=0;h<s;h++)c=a===Pt[h]?o:o+1,o=nt[h],l=nt[h]=o>l?c>l?l+1:c:c>o?o+1:c;return l}function Vi(i){return i!=null}const Gi=({mobileTiers:i=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:s,failIfMajorPerformanceCaveat:n=!1,benchmarksURL:a="https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks"}={})=>st(void 0,void 0,void 0,function*(){const r={};if(Kt)return{tier:0,type:"SSR"};const{isIpad:o=!!se?.isIpad,isMobile:c=!!se?.isMobile,screenSize:l=window.screen,loadBenchmarks:h=S=>st(void 0,void 0,void 0,function*(){const T=yield fetch(`${a}/${S}`).then(M=>M.json());if(parseInt(T.shift().split(".")[0],10)<4)throw new Rt("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,L,A)=>({device:A,fps:L,gpu:M,isMobile:c,tier:S,type:T});let g,y="";if(u)u=At(u),g=[u];else{const S=s||function(M,L=!1){const A={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:L,powerPreference:"high-performance",stencil:!1};M&&delete A.powerPreference;const z=window.document.createElement("canvas"),J=z.getContext("webgl",A)||z.getContext("experimental-webgl",A);return J??void 0}(se?.isSafari12,n);if(!S)return p(0,"WEBGL_UNSUPPORTED");const T=se?.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");y=u,u=At(u),g=function(M,L,A){return L==="apple gpu"?ji(M,L,A):[L]}(S,u,c)}const _=(yield Promise.all(g.map(function(S){var T;return st(this,void 0,void 0,function*(){const M=(B=>{const q=c?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const oe of q)if(B.includes(oe))return oe})(S);if(!M)return;const L=`${c?"m":"d"}-${M}${o?"-ipad":""}.json`,A=r[L]=(T=r[L])!==null&&T!==void 0?T:h(L);let z;try{z=yield A}catch(B){if(B instanceof Rt)throw B;return}const J=function(B){var q;const oe=(B=B.replace(/\([^)]+\)/,"")).match(/\d+/)||B.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(q=oe?.join("").replace(/\W|amd/g,""))!==null&&q!==void 0?q:""}(S);let ae=z.filter(([,B])=>B===J);ae.length||(ae=z.filter(([B])=>B.includes(S)));const ue=ae.length;if(ue===0)return;const _e=S.split(/[.,()\[\]/\s]/g).sort().filter((B,q,oe)=>q===0||B!==oe[q-1]).join(" ");let pe,[Si,,,,xi]=ue>1?ae.map(B=>[B,Bi(_e,B[2])]).sort(([,B],[,q])=>B-q)[0][0]:ae[0],it=Number.MAX_VALUE;const{devicePixelRatio:wt}=window,Oi=l.width*wt*l.height*wt;for(const B of xi){const[q,oe]=B,Mi=q*oe,Tt=Math.abs(Oi-Mi);Tt<it&&(it=Tt,pe=B)}if(!pe)return;const[,,wi,Ti]=pe;return[it,wi,Si,Ti]})}))).filter(Vi).sort(([S=Number.MAX_VALUE,T],[M=Number.MAX_VALUE,L])=>S===M?T-L:S-M);if(!_.length){const S=Hi.find(T=>u.includes(T));return S?p(0,"BLOCKLISTED",S):p(1,"FALLBACK",`${u} (${y})`)}const[,E,v,C]=_[0];if(E===-1)return p(0,"BLOCKLISTED",v,E,C);const x=c?i:e;let O=0;for(let S=0;S<x.length;S++)E>=x[S]&&(O=S);return p(O,"BENCHMARK",v,E,C)});function Xt(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 Qt(i=!1,e=!1){return new Promise(t=>{Gi().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 c=navigator.userAgent.match(/version\/(\d+)/i);n=(c?parseInt(c[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"),Xt(c=>{o.fps=c,t(o)})})})}function de(i,e,t){return Math.min(e,Math.max(i,t))}function Xe(i,e,t){return(t-i)/(e-i)}function Ae(i,e,t){return i*(1-t)+e*t}function Wi(i,e,t,s,n){return Ae(t,s,Xe(i,e,n))}function Yi(i,e){const t=i-e;return Math.sqrt(t*t)}function Zi(i,e,t,s){return Ae(i,e,1-Math.exp(-t*s))}function X(i,e=1){return Number(i.toFixed(e))}function $i(i,e,t,s){return Math.atan2(s-e,t-i)}function qi(i,e,t,s){return i===e&&t===s}function Ki(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function Xi(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function Qi(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function Ji(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(qi(e,t,s,n))return i;const a=0,r=0,o=e,c=t,l=s,h=n,u=1,p=1,g=u-3*l+3*o-a,y=3*l-6*o+3*a,_=3*o-3*a,E=a,v=p-3*h+3*c-r,C=3*h-6*c+3*r,x=3*c-3*r,O=r;let S=i;for(let T=0;T<5;T++){const M=Xi(S,g,y,_,E);let L=Ki(S,g,y,_);L===1/0&&(L=i),S-=(M-i)*L,S=Math.min(Math.max(S,0),1)}return Qi(S,v,C,x,O)}const Be=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function es({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 Ce;function ts(){const[i,e]=b.useState(Ce);return b.useEffect(()=>{Ce||import("@tomorrowevening/theatre-studio").then(t=>{Ce=t.default,Ce.initialize(),Ce.ui.hide(),e(Ce)})},[]),i}async function is(){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 ss(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 ns=["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 Dt(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 Jt(i){const e=[];for(const s in i){const n=ns.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||a))if(s==="uniforms"){const o=i.uniforms;for(const c in o){const l=o[c].value,h=Dt(l);h==="array"||h==="object"||e.push({name:`uniforms.${c}.value`,type:h,value:l})}}else{const o=Dt(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 ei(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 a=s.name.split(".");let r=e;for(let o=0;o<a.length-1;o++){const c=a[o];r[c]||(r[c]={}),r=r[c]}r[a[a.length-1]]=n}else e[s.name]=n}),e}function ti(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 rs(i,e,t,s){if(!t.isMaterial)return;const n=Jt(t),a=ei(n);s.sheetObject(i,e,{material:a},r=>{ti(t,n,r)})}const Je=new m.BufferGeometry;Je.setAttribute("position",new m.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));Je.setAttribute("normal",new m.Float32BufferAttribute([0,0,1,0,0,1],3));Je.setAttribute("uv",new m.Float32BufferAttribute([0,0,2,0,0,2],2));const as=new m.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 m.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 m.Texture&&_t(s.value)}}i.dispose()}},re=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):re(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},Te=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=>Te(t))};class le{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 m.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new m.Scene,this.material=new m.MeshBasicMaterial;const t=new m.BufferGeometry;t.setAttribute("position",new m.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new m.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new m.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new m.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=m.LinearSRGBColorSpace,e.colorSpace=m.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function os(i){return new Promise(e=>{const t=new m.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new m.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(c=>m.AnimationClip.parse(c));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 ls=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function ii(i,e,t,s){i.applyMatrix4(new m.Matrix4().makeTranslation(e,-t,-s))}function cs(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;ii(i,t,s,0)}function hs(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 ds(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 us(){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 ps(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=m.AlwaysStencilFunc,a.stencilFail=m.ReplaceStencilOp,a.stencilZFail=m.ReplaceStencilOp,a.stencilZPass=m.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=m.AlwaysStencilFunc,n.stencilFail=m.ReplaceStencilOp,n.stencilZFail=m.ReplaceStencilOp,n.stencilZPass=m.ReplaceStencilOp)}function ms(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?m.NotEqualStencilFunc:m.EqualStencilFunc,n.stencilFail=m.KeepStencilOp,n.stencilZFail=m.KeepStencilOp,n.stencilZPass=m.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?m.NotEqualStencilFunc:m.EqualStencilFunc,s.stencilFail=m.KeepStencilOp,s.stencilZFail=m.KeepStencilOp,s.stencilZPass=m.KeepStencilOp)}function fs(i){i.blending=m.NormalBlending,i.blendEquation=m.AddEquation,i.blendSrc=m.SrcAlphaFactor,i.blendDst=m.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function gs(i){i.blending=m.CustomBlending,i.blendEquation=m.AddEquation,i.blendSrc=m.SrcAlphaFactor,i.blendDst=m.OneFactor,i.needsUpdate=!0}function vs(i){i.blending=m.CustomBlending,i.blendEquation=m.AddEquation,i.blendSrc=m.DstColorFactor,i.blendDst=m.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function _s(i){i.blending=m.CustomBlending,i.blendEquation=m.AddEquation,i.blendSrc=m.OneMinusDstColorFactor,i.blendDst=m.OneFactor,i.needsUpdate=!0}let Ct=[];function si(i,e,t=!0){le.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,c)=>{if(c==="map")return;const l=`${r.name.replace("Effect","")} ${c}`;if(o.value===null&&t)s.push({prop:c,title:l,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,u=le.renderToBlob(h);s.push({prop:c,title:l,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:c,title:l,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:c,title:l,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:c,title:l,type:"boolean",value:o.value})})}),n=(r,o)=>{i.effects.forEach(c=>{c.uniforms.size>0&&c.uniforms.forEach((l,h)=>{h===r&&(l.value=o)})})};else if(i.name==="ShaderPass"){const r=i.fullscreenMaterial;for(const o in r.uniforms){if(o==="inputBuffer"||o==="map")continue;const c=r.uniforms[o],l=`${r.name.replace("Material","")} ${o}`;if(c.value===null&&t)s.push({title:l,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(c.value.isTexture&&t){const h=c.value,u=le.renderToBlob(h);s.push({title:l,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof c.value=="number"?s.push({title:l,prop:o,type:"number",value:c.value,step:.01}):typeof c.value=="string"?s.push({title:l,prop:o,type:"string",value:c.value}):typeof c.value=="boolean"&&s.push({title:l,prop:o,type:"boolean",value:c.value})}n=(o,c)=>{const l=r.uniforms[o];l.value=c}}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)}}),Ct.push(a)}function Cs(i,e){i.passes.forEach(t=>{si(t,e)})}function ys(i){Ct.forEach(e=>{i.removeGroup(e)}),Ct=[]}function bs(i,e,t,s=1024){return new Promise(n=>{const a=e.aspect,r=e.fov,o=e.rotation.clone(),c=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const l=new m.WebGLRenderTarget(s,s,{format:m.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=l,ye(i,l,e,"nx",t,s).then(()=>{ye(i,l,e,"ny",t,s).then(()=>{ye(i,l,e,"nz",t,s).then(()=>{ye(i,l,e,"px",t,s).then(()=>{ye(i,l,e,"py",t,s).then(()=>{ye(i,l,e,"pz",t,s).then(()=>{e.aspect=a,e.fov=r,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=c,l.dispose(),n()})})})})})})})}function ye(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 c=new Uint8Array(a*a*4);i.readRenderTargetPixels(e,0,0,a,a,c);const l=document.createElement("canvas");l.width=l.height=a;const h=l.getContext("2d"),u=h.createImageData(a,a);u.data.set(c),h.putImageData(u,0,0);const p=document.createElement("canvas");p.width=p.height=a;const g=p.getContext("2d");g.translate(0,a),g.scale(1,-1),g.drawImage(l,0,0);const y=p.toDataURL("image/png"),_=document.createElement("a");_.href=y,_.download=`${t.name}_${s}.png`,document.body.appendChild(_),_.click(),_.remove(),r()})}const be=Et(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),Es=Et(["clientX","clientY","deltaX","deltaY","deltaMode"]),Ss=Et(["ctrlKey","metaKey","shiftKey","keyCode"]);function xs(i,e){i.preventDefault(),Es(i,e)}function Os(i){i.preventDefault()}function ws(i,e,t){for(const s of e)t[s]=i[s]}function Et(i){return function(t,s){const n={type:t.type};ws(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 a=i.touches[n];t.push({pageX:a.pageX,pageY:a.pageY})}e(s)}const Ts={37:!0,38:!0,39:!0,40:!0};function Ms(i,e){const{keyCode:t}=i;Ts[t]&&(i.preventDefault(),Ss(i,e))}const As={contextmenu:Os,mousedown:be,mousemove:be,mouseup:be,pointerdown:be,pointermove:be,pointerup:be,touchstart:rt,touchmove:rt,touchend:rt,wheel:xs,keydown:Ms};let Rs=0;class Ps{id;worker;constructor(e,t,s){this.id=Rs++,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,c=>{o(c,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class ni extends m.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=He,e.stopPropagation=He,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Ds{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new ni;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class Is{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;dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(e=!1,t=!1){return new Promise(s=>{Qt(e,t).then(n=>{this.settings=n,s()})})}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=!1;_editor=!1;broadcastChannel;constructor(e,t=!1,s=!1){this.name=e,this._debug=t,this._editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.broadcastChannel.addEventListener("message",this.messageHandler.bind(this)))}dispose(){this.broadcastChannel?.removeEventListener("message",this.messageHandler.bind(this)),this.broadcastChannel?.close()}get debug(){return this._debug}get editor(){return this._editor}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 Us(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 Ls(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 Us(a,i.value,i.value+s,e.value+n,e.value)}class Ns 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 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 c=`${this.getSheetInstance(e,a)}_${t}`;let l=this.sheetObjects.get(c),h=s;l!==void 0&&(h={...s,...l.value}),l=r.object(t,h,{reconfigure:!0}),this.sheetObjects.set(c,l),this.sheetObjectCBs.set(c,n!==void 0?n:He);function u(g,y,_){if(typeof _=="object")if(qt(_))g[y]={r:_.r,g:_.g,b:_.b,a:_.a};else for(const E in _){const v=_[E];typeof v=="object"&&u(_,E,v)}}const p=l.onValuesChange(g=>{const y=this.sheetObjectCBs.get(c);if(this.editor){for(const _ in g){const E=g[_];typeof E=="object"&&u(g,_,E)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:c,values:g}}),y&&y(g)}else y&&y(g)});return this.sheetObjectUnsubscribe.set(c,p),l}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),c=s.sequence.__experimental_getKeyframes(a.props.y),l=s.sequence.__experimental_getKeyframes(a.props.z),h=new Set;return o.forEach(p=>h.add(p.position)),c.forEach(p=>h.add(p.position)),l.forEach(p=>h.add(p.position)),Array.from(h).sort((p,g)=>p-g).forEach(p=>{const g=(y,_)=>{const E=y.find((x,O)=>x.position<=_&&(y[O+1]?.position||1/0)>_),v=y.find(x=>x.position>_);if(!E)return v?.value||0;if(!v||E.position===_)return E.value;if(E.type==="bezier")return Ls(E,v,_);const C=(_-E.position)/(v.position-E.position);return E.value+C*(v.value-E.value)};r.push({position:p,x:g(o,p),y:g(c,p),z:g(l,p)})}),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",c={};switch(a.type){case"Theatre_Sheet_PublicAPI":o="setSheet",c={sheet:a.address.sheetId},this.activeSheet=this.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",r+=`_${a.address.objectKey}`,c={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:c})})});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 ks(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function 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 Fs(i){const e={};for(const t in i){const s=i[t].value;e[t]={value:s},s===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:s!==void 0&&s.isTexture&&(e[t].value={src:s.image.src,offset:[s.offset.x,s.offset.y],repeat:[s.repeat.x,s.repeat.y]})}return e}function zs(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"||zs(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":n!==null?(e[t]=n,n.isTexture?e[t]={src:le.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]}:t==="uniforms"&&(e[t]=Fs(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function 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(a=>{n.push(Ee(a))}),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(a=>{n.push(Ee(a))}),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(a=>{n.push(Ee(a))}),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 Hs(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 js(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 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?js(r,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function ri(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new m.Texture(s);n.wrapS=m.RepeatWrapping,n.wrapT=m.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}var U=(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))(U||{});class Bs 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=>{re(e)}),this.scenes.clear(),this.scene&&re(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&&(le.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){this.renderer!==void 0&&(le.renderer=this.renderer);const t=at(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const a=this.getObjectByUUID(e);if(a)try{n!==void 0?Hs(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&&V(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?ri(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 w.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClear:e.autoClear,autoClearColor:e.autoClearColor,autoClearDepth:e.autoClearDepth,autoClearStencil:e.autoClearStencil,outputColorSpace:e.outputColorSpace,localClippingEnabled:e.localClippingEnabled,clearColor: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(),Te(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&&(le.renderer=this.renderer),Ne(),Te(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.localClippingEnabled=e.data.localClippingEnabled,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:{autoClear:this.renderer.autoClear,autoClearColor:this.renderer.autoClearColor,autoClearDepth:this.renderer.autoClearDepth,autoClearStencil:this.renderer.autoClearStencil,outputColorSpace:this.renderer.outputColorSpace,localClippingEnabled:this.renderer.localClippingEnabled,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(),Te(t),this.send({event:"addScene",target:"editor",data:ce(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(le.renderer=this.renderer),Ne(),Te(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((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(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 Vs=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"})]}),Gs=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
|
|
19
19
|
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
|
|
20
|
-
C11,8.22,10.74,8,10.43,8z`})});function ni(i){return u.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:u.jsxs("div",{children:[Bs,u.jsx("span",{children:i.title}),u.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:js})]})})}function ri(i){const[e,t]=b.useState(!1),[s,n]=b.useState(i.options),[a,r]=b.useState(null),o=g=>{i.onDragComplete(g),n(g)},c=g=>{const y=[...s];y.splice(g,1),o(y)},l=g=>{r(g)},h=g=>{if(a===g||a===null)return;const y=[...s],_=y.splice(a,1)[0];y.splice(g,0,_),r(g),n(y)},p=()=>{i.onDragComplete(s),r(null)};let m="dropdown draggable";return i.subdropdown&&(m+=" subdropdown"),u.jsxs("div",{className:m,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(St,{title:i.title}),u.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((g,y)=>u.jsx(ni,{title:g,index:y,draggingIndex:a,onDelete:c,onDragStart:l,onDragOver:h,onDragEnd:p},g))})]})}function ai(i){const[e,t]=b.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(u.jsx(oi,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),u.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[u.jsx(St,{title:i.title}),u.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function oi(i){const{option:e}=i,[t,s]=b.useState("");let n;switch(e.type){case"draggable":n=u.jsx(ri,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=u.jsx(ai,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=u.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return u.jsx("li",{className:t===e.title?"selected":"",children:n},W())}function Me(i){const[e,t]=b.useState(i.open!==void 0?i.open:!1),[s,n]=b.useState(i.visible!==void 0?i.visible:!1),a=!e||i.children===void 0,r=()=>{i.three.dispatchEvent({type:I.REMOVE_SCENE,value:i.scene})};return u.jsxs("div",{className:`accordion ${a?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const o=!e;i.onToggle!==void 0&&i.onToggle(o),t(o)},children:[u.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:He(i.label)})]}),i.onRefresh?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const c=i.three.getScene(i.scene.uuid);if(c){const l=!c.visible;c.visible=l,n(l)}}}),u.jsx("button",{className:"refresh",onClick:i.onRefresh}),u.jsx("button",{className:"remove",onClick:r})]}):null,i.button,u.jsx("div",{className:e?"open":"",children:u.jsx("div",{children:i.children})},Math.random())]})}function xt(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,a=[];return i.child.children.length>0&&i.child.children.map((r,o)=>{a.push(u.jsx(xt,{child:r,three:i.three},o))}),b.useEffect(()=>{if(i.child){const r=i.child.uuid.split(".")[0],o=i.three.getScene(r);if(o!==null)try{const c=o.getObjectByProperty("uuid",i.child.uuid);c!==void 0?e.current.style.opacity=c.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(c){console.log("Error looking for child:",c),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]),u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[n?u.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,u.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0?(i.three.getObject(i.child.uuid),!t&&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}`}),u.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 c="visible",l=!o.visible;e.current.style.opacity=l?"1":"0.25",i.three.updateObject(i.child.uuid,c,l),B(o,c,l)}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}`)}}}),u.jsx("div",{className:`icon ${Ls(i.child)}`})]}),u.jsx("div",{className:t?"open":"",children:u.jsx("div",{className:"container",children:a})})]},Math.random())}function Ze(i){const e=[];return i.child?.children.map((t,s)=>{e.push(u.jsx(xt,{child:t,scene:i.scene,three:i.three},s))}),u.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function ke(i){const[e,t]=b.useState(i.defaultValue);return b.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,o=!1;const c=g=>{o=g.ctrlKey},l=g=>{s=!0,a=Number(i.input.current?.value),n=g.clientX,document.addEventListener("mouseup",p,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",p,!1)},h=g=>{if(!s)return;const y=i.step!==void 0?i.step:1,_=(g.clientX-n)*y*(o?10:1);r=Number((a+_).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)},p=()=>{s=!1,document.removeEventListener("mouseup",p),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",p)},m=g=>{const y=Number(g.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.label.current?.addEventListener("mousedown",l,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),document.addEventListener("keydown",c,!1),document.addEventListener("keyup",c,!1),()=>{i.label.current?.removeEventListener("mousedown",l),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",p),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",p),document.removeEventListener("keydown",c),document.addEventListener("keyup",c,!1)}},[]),e}function ve(i){const e=b.useRef(null),t=b.useRef(null),[s,n]=b.useState(i.value);return ke({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)}}),u.jsxs(u.Fragment,{children:[i.type==="number"&&u.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,name:W(),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"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:W(),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))}}),u.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 Vs(i){const e=b.useRef(null),t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),a=b.useRef(null),r=b.useRef(null),o=b.useRef(null),c=b.useRef(null),l=b.useRef(null),h=b.useRef(null),[p,m]=b.useState(i.value.x),[g,y]=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))}),[v,C]=b.useState(!1);ke({label:o,input:e,defaultValue:p,min:_.min,max:_.max,step:.01,onChange:A=>{m(A),i.onChange({target:{value:{x:A,y:g}}})}}),ke({label:c,input:t,defaultValue:g,min:_.min,max:_.max,step:.01,onChange:A=>{y(A),i.onChange({target:{value:{x:p,y:A}}})}}),ke({label:l,input:s,defaultValue:_.min,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:A,max:_.max})}}),ke({label:h,input:n,defaultValue:_.max,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:_.min,max:A})}});function x(){v||(window.addEventListener("mousemove",S),window.addEventListener("mouseup",O),C(!0))}function O(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",O),C(!1)}function S(A){const F=a.current.getBoundingClientRect(),Q=he(0,99,A.clientX-F.left)/99,re=1-he(0,99,A.clientY-F.top)/99,de=K(Ae(_.min,_.max,Q),3),_e=K(Ae(_.min,_.max,re),3);i.onChange({target:{value:{x:de,y:_e}}}),m(de),y(_e)}function w(){const A=Number(s.current.value);E({min:A,max:_.max}),p<A&&m(he(A,_.max,p)),g<A&&y(he(A,_.max,g))}function M(){const A=Number(n.current.value);E({min:_.min,max:A}),p>A&&m(he(_.min,A,p)),g>A&&y(he(_.min,A,g))}b.useEffect(()=>{r.current.style.left=`${Ke(_.min,_.max,p)*100}%`,r.current.style.top=`${(1-Ke(_.min,_.max,g))*100}%`},[_,p,g]);const U=i.step!==void 0?i.step:.01;return u.jsxs("div",{className:"vector2",children:[u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("span",{ref:o,children:"X"}),u.jsx("input",{ref:e,type:"number",value:p,min:_.min,max:_.max,step:U,name:W(),onChange:A=>{if(m(A.target.value),A.target.value.length===0)return;const F=Number(A.target.value);isNaN(F)||(i.onChange({target:{value:{x:F,y:g}}}),F<_.min&&E({min:F,max:_.max}))}})]}),u.jsxs("div",{children:[u.jsx("span",{ref:c,children:"Y"}),u.jsx("input",{ref:t,type:"number",value:g,min:_.min,max:_.max,step:U,name:W(),onChange:A=>{if(y(A.target.value),A.target.value.length===0)return;const F=Number(A.target.value);isNaN(F)||(i.onChange({target:{value:{x:p,y:F}}}),F>_.max&&E({min:_.min,max:F}))}})]}),u.jsxs("div",{children:[u.jsx("span",{ref:l,children:"Min"}),u.jsx("input",{ref:s,type:"number",value:_.min,step:U,name:W(),onChange:w})]}),u.jsxs("div",{children:[u.jsx("span",{ref:h,children:"Max"}),u.jsx("input",{ref:n,type:"number",value:_.max,step:U,name:W(),onChange:M})]})]}),u.jsxs("div",{className:"input",ref:a,onMouseDown:x,onMouseUp:O,children:[u.jsx("div",{className:"x"}),u.jsx("div",{className:"y"}),u.jsx("div",{className:"pt",ref:r})]})]})}function Pt(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=b.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(c=>{const l=b.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("span",{ref:l,children:c.substring(1).toUpperCase()}),u.jsx(ve,{value:Z.radToDeg(r[c]),type:"number",prop:c,step:.1,labelRef:l,onChange:(h,p)=>{r[h]=Z.degToRad(p),i.onChange({target:{value:r}})}})]},c))})}else if(e){const r=b.useMemo(()=>i.value,[]),o=(l,h)=>{r[l]=h,i.onChange({target:{value:r}})};["x","y","z"].forEach(l=>{const h=b.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:h,children:l.toUpperCase()}),u.jsx(ve,{value:r[l],type:"number",prop:l,step:n,labelRef:h,onChange:o})]},l))})}else if(s){const r=b.useMemo(()=>i.value,[]),o=(c,l)=>{const h=Number(c);r.elements[h]=l,i.onChange({target:{value:r}})};for(let c=0;c<9;c++){const l=b.useRef(null);a.push(u.jsxs("div",{children:[u.jsx("label",{ref:l,children:c+1}),u.jsx(ve,{value:r.elements[c],type:"number",prop:c.toString(),step:n,labelRef:l,onChange:o})]},c.toString()))}}return u.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Gs(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,[]),a=(o,c)=>{n[o]=c,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const c=b.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("label",{ref:c,children:o.toUpperCase()}),u.jsx(ve,{value:n[o],type:"number",prop:o,step:t,labelRef:c,onChange:a})]},o))})}else{const n=b.useMemo(()=>i.value,[]),a=(r,o)=>{const c=Number(r);n.elements[c]=o,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const o=b.useRef(null);s.push(u.jsxs("div",{children:[u.jsx("span",{ref:o,children:r+1}),u.jsx(ve,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:a})]},r.toString()))}}return u.jsx("div",{className:"grid4",children:s})}function Ws(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 Ys(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 Je(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 li(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 Zs(){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 $s=[{title:"Front",value:d.FrontSide},{title:"Back",value:d.BackSide},{title:"Double",value:d.DoubleSide}],qs=[{title:"No Blending",value:d.NoBlending},{title:"Normal",value:d.NormalBlending},{title:"Additive",value:d.AdditiveBlending},{title:"Subtractive",value:d.SubtractiveBlending},{title:"Multiply",value:d.MultiplyBlending},{title:"Custom",value:d.CustomBlending}],Ks=[{title:"Add",value:d.AddEquation},{title:"Subtract",value:d.SubtractEquation},{title:"Reverse Subtract",value:d.ReverseSubtractEquation},{title:"Min",value:d.MinEquation},{title:"Max",value:d.MaxEquation}],Xs=[{title:"Zero",value:d.ZeroFactor},{title:"One",value:d.OneFactor},{title:"Src Color",value:d.SrcColorFactor},{title:"One Minus Src Color",value:d.OneMinusSrcColorFactor},{title:"Src Alpha",value:d.SrcAlphaFactor},{title:"One Minus Src Alpha",value:d.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:d.DstAlphaFactor},{title:"One Minus Dst Alpha",value:d.OneMinusDstAlphaFactor},{title:"Dst Color",value:d.DstColorFactor},{title:"One Minus Dst Color",value:d.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:d.SrcAlphaSaturateFactor},{title:"Constant Color",value:d.ConstantColorFactor},{title:"One Minus Constant Color",value:d.OneMinusConstantColorFactor},{title:"Constant Alpha",value:d.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:d.OneMinusConstantAlphaFactor}],Qs=[{title:"Zero",value:d.ZeroFactor},{title:"One",value:d.OneFactor},{title:"Src Color",value:d.SrcColorFactor},{title:"One Minus Src Color",value:d.OneMinusSrcColorFactor},{title:"Src Alpha",value:d.SrcAlphaFactor},{title:"One Minus Src Alpha",value:d.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:d.DstAlphaFactor},{title:"One Minus Dst Alpha",value:d.OneMinusDstAlphaFactor},{title:"Dst Color",value:d.DstColorFactor},{title:"One Minus Dst Color",value:d.OneMinusDstColorFactor},{title:"Constant Color",value:d.ConstantColorFactor},{title:"One Minus Constant Color",value:d.OneMinusConstantColorFactor},{title:"Constant Alpha",value:d.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:d.OneMinusConstantAlphaFactor}];function Re(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Js(i,e,t,s){return{type:"boolean",title:Je(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);B(o,`material.${i}`,a)}}}}function en(i,e,t,s){const n={type:"number",title:Je(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 c=o.getObjectByProperty("uuid",t.uuid);B(c,`material.${i}`,r)}}};switch(i){case"blending":Re(n,qs);break;case"blendDst":Re(n,Qs);break;case"blendEquation":Re(n,Ks);break;case"blendSrc":Re(n,Xs);break;case"side":Re(n,$s);break}return li(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 tn(i,e,t,s){const n={type:"string",title:Je(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 c=s.getScene(t.uuid);if(c!==null){const l=c.getObjectByProperty("uuid",t.uuid);B(l,`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 c=s.getScene(t.uuid);if(c!==null){const l=c.getObjectByProperty("uuid",t.uuid);B(l,`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 c=o.getObjectByProperty("uuid",t.uuid);B(c,"material.needsUpdate",!0)}}}),n}function sn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function nn(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function rn(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 Fe(i,e,t,s,n="",a=!1){const r=Je(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,c=typeof e;if(c==="boolean"||c==="string")return{title:r,prop:o,type:c,value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};if(c==="number"){const l={title:r,prop:o,type:"number",value:e,step:.01,disabled:a,onChange:(h,p)=>{s.updateObject(t.uuid,`material.${o}`,p);const m=s.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);B(g,`material.${o}`,p)}}};return li(r)&&(l.type="range",l.min=0,l.max=1),l}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:a,onChange:(l,h)=>{const p=new d.Color(h);s.updateObject(t.uuid,`material.${o}`,p);const m=s.getScene(t.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",t.uuid);B(g,`material.${o}`,p)}}};if(Array.isArray(e)){const l=[];for(const h in e){const p=e[h],m=`[${h.toString()}]`;if(p.value!==void 0){const g=Fe(`${m}.value`,p.value,t,s,o,a);g!==void 0&&l.push(g)}else{const g=Fe(m,p,t,s,o,a);g!==void 0&&l.push(g)}}if(l.length>0)return Ct(l),{title:r,items:l}}else{if(sn(e))return{title:r,prop:o,type:"vector2",value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};if(nn(e))return{title:r,prop:o,type:"grid3",value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};if(rn(e))return{title:r,prop:o,type:"grid4",value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(l,h)=>{const p=Ys(i),m=n.length>0?`${n}.${p}`:p;s.createTexture(t.uuid,`material.${m}`,h);const g=s.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);if(y!==void 0){const _=E=>{const v=y.material,C=m.split(".");switch(C.length){case 1:v[C[0]]=E;break;case 2:v[C[0]][C[1]]=E;break;case 3:v[C[0]][C[1]][C[2]]=E;break;case 4:v[C[0]][C[1]][C[2]][C[3]]=E;break;case 5:v[C[0]][C[1]][C[2]][C[3]][C[4]]=E;break}v.needsUpdate=!0};h.src.length>0?si(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:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(l,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const p=s.getScene(t.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",t.uuid);B(m,`material.${o}`,h)}}};{const l=[],h=i==="defines"||i==="extensions";try{for(const p in e){const m=e[p];if(m!==void 0)if(m.value!==void 0){const g=Fe(`${p}.value`,m.value,t,s,o,h);g!==void 0&&l.push(g)}else{const g=Fe(p,m,t,s,o,h);g!==void 0&&l.push(g)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(l.length>0)return Ct(l),{title:r,items:l}}}}}function It(i,e,t){const s=[];for(const n in i){if(!Ws(n)||n.search("Node")>-1)continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Js(n,r,e,t));else if(a==="number")s.push(en(n,r,e,t));else if(a==="string")s.push(tn(n,r,e,t));else if(a==="object"){const o=Fe(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 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 a=n.getObjectByProperty("uuid",e.uuid);B(a,"material.needsUpdate",!0)}}}),s}function an(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=[],c=r.length;for(let l=0;l<c;l++)o.push(u.jsx(X,{three:e,title:`Material ${l}`,items:It(r[l],i,e)},`Material ${l}`));return u.jsx(u.Fragment,{children:o})}else return u.jsx(X,{three:e,title:"Material",items:It(r,i,e),expanded:n,onToggle:o=>{a(o)}})}const Ut="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 on(i){const e=i.step!==void 0?i.step:.01,t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),a=b.useRef(null),r=b.useRef(null),[o]=b.useState(i.value),[c,l]=b.useState(i.value.offset[0]),[h,p]=b.useState(i.value.offset[1]),[m,g]=b.useState(i.value.repeat[0]),[y,_]=b.useState(i.value.repeat[1]);function E(C,x,O,S,w){if(i.onChange!==void 0){const M=i.prop!==void 0?i.prop:i.title;i.onChange(M,{src:C,offset:[x,O],repeat:[S,w]})}}function v(C){const x=t.current.src,O=C.target.value;switch(C.target){case s.current:l(O),E(x,O,h,m,y);break;case n.current:p(O),E(x,c,O,m,y);break;case a.current:g(O),E(x,c,h,O,y);break;case r.current:_(O),E(x,c,h,m,O);break}}return u.jsxs("div",{className:"imageField",children:[u.jsx("img",{alt:i.title,ref:t,onClick:()=>{Zs().then(C=>{t.current.src=C,E(C,c,h,m,y)})},src:o.src.length>0?o.src:Ut}),u.jsxs("div",{className:"fields",children:[u.jsxs("div",{children:[u.jsx("span",{children:"Offset:"}),u.jsx("input",{ref:s,type:"number",value:c,step:e,name:W(),onChange:v}),u.jsx("input",{ref:n,type:"number",value:h,step:e,name:W(),onChange:v})]}),u.jsxs("div",{children:[u.jsx("span",{children:"Repeat:"}),u.jsx("input",{ref:a,type:"number",value:m,step:e,name:W(),onChange:v}),u.jsx("input",{ref:r,type:"number",value:y,step:e,name:W(),onChange:v})]}),u.jsx("button",{onClick:()=>{E("",c,h,m,y),t.current.src=Ut},children:"Clear"})]})]})}function $e(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=gt(i.value):i.type==="color"&&(e=gt(new d.Color().setStyle(i.value,d.LinearSRGBColorSpace))));const[t,s]=b.useState(e),n=b.useRef(null),a=l=>{let h=l.target.value;if(i.type==="boolean")h=l.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?h=Number(h):typeof i.value=="boolean"?h=!!h:typeof i.value=="object"&&(h=JSON.parse(h)),i.options!==void 0)){const p=i.options.length;for(let m=0;m<p&&i.options[m].value!==h;m++);}s(h),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,h)},r={};i.disabled&&(r.opacity=.8);const o=i.type==="field"||i.type==="string"&&(t.length>100||t.search(`
|
|
21
|
-
`)>-1),c=o||i.type==="image"||i.type==="vector2";return
|
|
20
|
+
C11,8.22,10.74,8,10.43,8z`})});function ai(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:[Gs,d.jsx("span",{children:i.title}),d.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:Vs})]})})}function oi(i){const[e,t]=b.useState(!1),[s,n]=b.useState(i.options),[a,r]=b.useState(null),o=g=>{i.onDragComplete(g),n(g)},c=g=>{const y=[...s];y.splice(g,1),o(y)},l=g=>{r(g)},h=g=>{if(a===g||a===null)return;const y=[...s],_=y.splice(a,1)[0];y.splice(g,0,_),r(g),n(y)},u=()=>{i.onDragComplete(s),r(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((g,y)=>d.jsx(ai,{title:g,index:y,draggingIndex:a,onDelete:c,onDragStart:l,onDragOver:h,onDragEnd:u},g))})]})}function li(i){const[e,t]=b.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(d.jsx(ci,{option:a},r))});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 ci(i){const{option:e}=i,[t,s]=b.useState("");let n;switch(e.type){case"draggable":n=d.jsx(oi,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=d.jsx(li,{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},Y())}function Me(i){const[e,t]=b.useState(i.open!==void 0?i.open:!1),[s,n]=b.useState(i.visible!==void 0?i.visible:!1),a=!e||i.children===void 0,r=()=>{i.three.dispatchEvent({type:U.REMOVE_SCENE,value:i.scene})};return d.jsxs("div",{className:`accordion ${a?"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:je(i.label)})]}),i.onRefresh?d.jsxs(d.Fragment,{children:[d.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const c=i.three.getScene(i.scene.uuid);if(c){const l=!c.visible;c.visible=l,n(l)}}}),d.jsx("button",{className:"refresh",onClick:i.onRefresh}),d.jsx("button",{className:"remove",onClick:r})]}):null,i.button,d.jsx("div",{className:e?"open":"",children:d.jsx("div",{children:i.children})},Math.random())]})}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,a=[];return i.child.children.length>0&&i.child.children.map((r,o)=>{a.push(d.jsx(Ot,{child:r,three:i.three},o))}),b.useEffect(()=>{if(i.child){const r=i.child.uuid.split(".")[0],o=i.three.getScene(r);if(o!==null)try{const c=o.getObjectByProperty("uuid",i.child.uuid);c!==void 0?e.current.style.opacity=c.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(c){console.log("Error looking for child:",c),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]),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 r=i.three.getScene(i.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.child.uuid);if(o!==void 0){const c="visible",l=!o.visible;e.current.style.opacity=l?"1":"0.25",i.three.updateObject(i.child.uuid,c,l),V(o,c,l)}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}`)}}}),d.jsx("div",{className:`icon ${ks(i.child)}`})]}),d.jsx("div",{className:t?"open":"",children:d.jsx("div",{className:"container",children:a})})]},Math.random())}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 ke(i){const[e,t]=b.useState(i.defaultValue);return b.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,o=!1;const c=g=>{o=g.ctrlKey},l=g=>{s=!0,a=Number(i.input.current?.value),n=g.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=g=>{if(!s)return;const y=i.step!==void 0?i.step:1,_=(g.clientX-n)*y*(o?10:1);r=Number((a+_).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)},p=g=>{const y=Number(g.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.label.current?.addEventListener("mousedown",l,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",p),document.addEventListener("keydown",c,!1),document.addEventListener("keyup",c,!1),()=>{i.label.current?.removeEventListener("mousedown",l),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",c),document.addEventListener("keyup",c,!1)}},[]),e}function ve(i){const e=b.useRef(null),t=b.useRef(null),[s,n]=b.useState(i.value);return ke({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)}}),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:Y(),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"&&d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:Y(),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))}}),d.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,name:Y(),onChange:He})]})]})}function Ws(i){const e=b.useRef(null),t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),a=b.useRef(null),r=b.useRef(null),o=b.useRef(null),c=b.useRef(null),l=b.useRef(null),h=b.useRef(null),[u,p]=b.useState(i.value.x),[g,y]=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))}),[v,C]=b.useState(!1);ke({label:o,input:e,defaultValue:u,min:_.min,max:_.max,step:.01,onChange:A=>{p(A),i.onChange({target:{value:{x:A,y:g}}})}}),ke({label:c,input:t,defaultValue:g,min:_.min,max:_.max,step:.01,onChange:A=>{y(A),i.onChange({target:{value:{x:u,y:A}}})}}),ke({label:l,input:s,defaultValue:_.min,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:A,max:_.max})}}),ke({label:h,input:n,defaultValue:_.max,min:_.min-1,max:_.max+1,step:.01,onChange:A=>{E({min:_.min,max:A})}});function x(){v||(window.addEventListener("mousemove",S),window.addEventListener("mouseup",O),C(!0))}function O(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",O),C(!1)}function S(A){const z=a.current.getBoundingClientRect(),J=de(0,99,A.clientX-z.left)/99,ae=1-de(0,99,A.clientY-z.top)/99,ue=X(Ae(_.min,_.max,J),3),_e=X(Ae(_.min,_.max,ae),3);i.onChange({target:{value:{x:ue,y:_e}}}),p(ue),y(_e)}function T(){const A=Number(s.current.value);E({min:A,max:_.max}),u<A&&p(de(A,_.max,u)),g<A&&y(de(A,_.max,g))}function M(){const A=Number(n.current.value);E({min:_.min,max:A}),u>A&&p(de(_.min,A,u)),g>A&&y(de(_.min,A,g))}b.useEffect(()=>{r.current.style.left=`${Xe(_.min,_.max,u)*100}%`,r.current.style.top=`${(1-Xe(_.min,_.max,g))*100}%`},[_,u,g]);const L=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:L,name:Y(),onChange:A=>{if(p(A.target.value),A.target.value.length===0)return;const z=Number(A.target.value);isNaN(z)||(i.onChange({target:{value:{x:z,y:g}}}),z<_.min&&E({min:z,max:_.max}))}})]}),d.jsxs("div",{children:[d.jsx("span",{ref:c,children:"Y"}),d.jsx("input",{ref:t,type:"number",value:g,min:_.min,max:_.max,step:L,name:Y(),onChange:A=>{if(y(A.target.value),A.target.value.length===0)return;const z=Number(A.target.value);isNaN(z)||(i.onChange({target:{value:{x:u,y:z}}}),z>_.max&&E({min:_.min,max:z}))}})]}),d.jsxs("div",{children:[d.jsx("span",{ref:l,children:"Min"}),d.jsx("input",{ref:s,type:"number",value:_.min,step:L,name:Y(),onChange:T})]}),d.jsxs("div",{children:[d.jsx("span",{ref:h,children:"Max"}),d.jsx("input",{ref:n,type:"number",value:_.max,step:L,name:Y(),onChange:M})]})]}),d.jsxs("div",{className:"input",ref:a,onMouseDown:x,onMouseUp:O,children:[d.jsx("div",{className:"x"}),d.jsx("div",{className:"y"}),d.jsx("div",{className:"pt",ref:r})]})]})}function It(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=b.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(c=>{const l=b.useRef(null);a.push(d.jsxs("div",{children:[d.jsx("span",{ref:l,children:c.substring(1).toUpperCase()}),d.jsx(ve,{value:$.radToDeg(r[c]),type:"number",prop:c,step:.1,labelRef:l,onChange:(h,u)=>{r[h]=$.degToRad(u),i.onChange({target:{value:r}})}})]},c))})}else if(e){const r=b.useMemo(()=>i.value,[]),o=(l,h)=>{r[l]=h,i.onChange({target:{value:r}})};["x","y","z"].forEach(l=>{const h=b.useRef(null);a.push(d.jsxs("div",{children:[d.jsx("label",{ref:h,children:l.toUpperCase()}),d.jsx(ve,{value:r[l],type:"number",prop:l,step:n,labelRef:h,onChange:o})]},l))})}else if(s){const r=b.useMemo(()=>i.value,[]),o=(c,l)=>{const h=Number(c);r.elements[h]=l,i.onChange({target:{value:r}})};for(let c=0;c<9;c++){const l=b.useRef(null);a.push(d.jsxs("div",{children:[d.jsx("label",{ref:l,children:c+1}),d.jsx(ve,{value:r.elements[c],type:"number",prop:c.toString(),step:n,labelRef:l,onChange:o})]},c.toString()))}}return d.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Ys(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,[]),a=(o,c)=>{n[o]=c,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const c=b.useRef(null);s.push(d.jsxs("div",{children:[d.jsx("label",{ref:c,children:o.toUpperCase()}),d.jsx(ve,{value:n[o],type:"number",prop:o,step:t,labelRef:c,onChange:a})]},o))})}else{const n=b.useMemo(()=>i.value,[]),a=(r,o)=>{const c=Number(r);n.elements[c]=o,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const o=b.useRef(null);s.push(d.jsxs("div",{children:[d.jsx("span",{ref:o,children:r+1}),d.jsx(ve,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:a})]},r.toString()))}}return d.jsx("div",{className:"grid4",children:s})}function Zs(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 $s(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 hi(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(a){e(a.target.result)},n.readAsDataURL(s)}}),i.click()})}const Ks=[{title:"Front",value:m.FrontSide},{title:"Back",value:m.BackSide},{title:"Double",value:m.DoubleSide}],Xs=[{title:"No Blending",value:m.NoBlending},{title:"Normal",value:m.NormalBlending},{title:"Additive",value:m.AdditiveBlending},{title:"Subtractive",value:m.SubtractiveBlending},{title:"Multiply",value:m.MultiplyBlending},{title:"Custom",value:m.CustomBlending}],Qs=[{title:"Add",value:m.AddEquation},{title:"Subtract",value:m.SubtractEquation},{title:"Reverse Subtract",value:m.ReverseSubtractEquation},{title:"Min",value:m.MinEquation},{title:"Max",value:m.MaxEquation}],Js=[{title:"Zero",value:m.ZeroFactor},{title:"One",value:m.OneFactor},{title:"Src Color",value:m.SrcColorFactor},{title:"One Minus Src Color",value:m.OneMinusSrcColorFactor},{title:"Src Alpha",value:m.SrcAlphaFactor},{title:"One Minus Src Alpha",value:m.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:m.DstAlphaFactor},{title:"One Minus Dst Alpha",value:m.OneMinusDstAlphaFactor},{title:"Dst Color",value:m.DstColorFactor},{title:"One Minus Dst Color",value:m.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:m.SrcAlphaSaturateFactor},{title:"Constant Color",value:m.ConstantColorFactor},{title:"One Minus Constant Color",value:m.OneMinusConstantColorFactor},{title:"Constant Alpha",value:m.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:m.OneMinusConstantAlphaFactor}],en=[{title:"Zero",value:m.ZeroFactor},{title:"One",value:m.OneFactor},{title:"Src Color",value:m.SrcColorFactor},{title:"One Minus Src Color",value:m.OneMinusSrcColorFactor},{title:"Src Alpha",value:m.SrcAlphaFactor},{title:"One Minus Src Alpha",value:m.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:m.DstAlphaFactor},{title:"One Minus Dst Alpha",value:m.OneMinusDstAlphaFactor},{title:"Dst Color",value:m.DstColorFactor},{title:"One Minus Dst Color",value:m.OneMinusDstColorFactor},{title:"Constant Color",value:m.ConstantColorFactor},{title:"One Minus Constant Color",value:m.OneMinusConstantColorFactor},{title:"Constant Alpha",value:m.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:m.OneMinusConstantAlphaFactor}];function Re(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function tn(i,e,t,s){return{type:"boolean",title:et(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);V(o,`material.${i}`,a)}}}}function sn(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:(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 c=o.getObjectByProperty("uuid",t.uuid);V(c,`material.${i}`,r)}}};switch(i){case"blending":Re(n,Xs);break;case"blendDst":Re(n,en);break;case"blendEquation":Re(n,Qs);break;case"blendSrc":Re(n,Js);break;case"side":Re(n,Ks);break}return hi(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 nn(i,e,t,s){const n={type:"string",title:et(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 c=s.getScene(t.uuid);if(c!==null){const l=c.getObjectByProperty("uuid",t.uuid);V(l,`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 c=s.getScene(t.uuid);if(c!==null){const l=c.getObjectByProperty("uuid",t.uuid);V(l,`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 c=o.getObjectByProperty("uuid",t.uuid);V(c,"material.needsUpdate",!0)}}}),n}function rn(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function an(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function on(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function yt(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Fe(i,e,t,s,n="",a=!1){const r=et(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,c=typeof e;if(c==="boolean"||c==="string")return{title:r,prop:o,type:c,value:e,disabled:a,onChange:(l,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(c==="number"){const l={title:r,prop:o,type:"number",value:e,step:.01,disabled:a,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const p=s.getScene(t.uuid);if(p!==null){const g=p.getObjectByProperty("uuid",t.uuid);V(g,`material.${o}`,u)}}};return hi(r)&&(l.type="range",l.min=0,l.max=1),l}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:a,onChange:(l,h)=>{const u=new m.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const p=s.getScene(t.uuid);if(p!==null){const g=p.getObjectByProperty("uuid",t.uuid);V(g,`material.${o}`,u)}}};if(Array.isArray(e)){const l=[];for(const h in e){const u=e[h],p=`[${h.toString()}]`;if(u.value!==void 0){const g=Fe(`${p}.value`,u.value,t,s,o,a);g!==void 0&&l.push(g)}else{const g=Fe(p,u,t,s,o,a);g!==void 0&&l.push(g)}}if(l.length>0)return yt(l),{title:r,items:l}}else{if(rn(e))return{title:r,prop:o,type:"vector2",value:e,disabled:a,onChange:(l,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(an(e))return{title:r,prop:o,type:"grid3",value:e,disabled:a,onChange:(l,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(on(e))return{title:r,prop:o,type:"grid4",value:e,disabled:a,onChange:(l,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:r,prop:o,type:"euler",value:e,disabled:a,onChange:(l,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:r,type:"image",value:e,disabled:a,onChange:(l,h)=>{const u=$s(i),p=n.length>0?`${n}.${u}`:u;s.createTexture(t.uuid,`material.${p}`,h);const g=s.getScene(t.uuid);if(g!==null){const y=g.getObjectByProperty("uuid",t.uuid);if(y!==void 0){const _=E=>{const v=y.material,C=p.split(".");switch(C.length){case 1:v[C[0]]=E;break;case 2:v[C[0]][C[1]]=E;break;case 3:v[C[0]][C[1]][C[2]]=E;break;case 4:v[C[0]][C[1]][C[2]][C[3]]=E;break;case 5:v[C[0]][C[1]][C[2]][C[3]][C[4]]=E;break}v.needsUpdate=!0};h.src.length>0?ri(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:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(l,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 l=[],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 g=Fe(`${u}.value`,p.value,t,s,o,h);g!==void 0&&l.push(g)}else{const g=Fe(u,p,t,s,o,h);g!==void 0&&l.push(g)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(l.length>0)return yt(l),{title:r,items:l}}}}}function Ut(i,e,t){const s=[];for(const n in i){if(!Zs(n)||n.search("Node")>-1)continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(tn(n,r,e,t));else if(a==="number")s.push(sn(n,r,e,t));else if(a==="string")s.push(nn(n,r,e,t));else if(a==="object"){const o=Fe(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 yt(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);V(a,"material.needsUpdate",!0)}}}),s}function ln(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=[],c=r.length;for(let l=0;l<c;l++)o.push(d.jsx(Q,{three:e,title:`Material ${l}`,items:Ut(r[l],i,e)},`Material ${l}`));return d.jsx(d.Fragment,{children:o})}else return d.jsx(Q,{three:e,title:"Material",items:Ut(r,i,e),expanded:n,onToggle:o=>{a(o)}})}const Lt="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 cn(i){const e=i.step!==void 0?i.step:.01,t=b.useRef(null),s=b.useRef(null),n=b.useRef(null),a=b.useRef(null),r=b.useRef(null),[o]=b.useState(i.value),[c,l]=b.useState(i.value.offset[0]),[h,u]=b.useState(i.value.offset[1]),[p,g]=b.useState(i.value.repeat[0]),[y,_]=b.useState(i.value.repeat[1]);function E(C,x,O,S,T){if(i.onChange!==void 0){const M=i.prop!==void 0?i.prop:i.title;i.onChange(M,{src:C,offset:[x,O],repeat:[S,T]})}}function v(C){const x=t.current.src,O=C.target.value;switch(C.target){case s.current:l(O),E(x,O,h,p,y);break;case n.current:u(O),E(x,c,O,p,y);break;case a.current:g(O),E(x,c,h,O,y);break;case r.current:_(O),E(x,c,h,p,O);break}}return d.jsxs("div",{className:"imageField",children:[d.jsx("img",{alt:i.title,ref:t,onClick:()=>{qs().then(C=>{t.current.src=C,E(C,c,h,p,y)})},src:o.src.length>0?o.src:Lt}),d.jsxs("div",{className:"fields",children:[d.jsxs("div",{children:[d.jsx("span",{children:"Offset:"}),d.jsx("input",{ref:s,type:"number",value:c,step:e,name:Y(),onChange:v}),d.jsx("input",{ref:n,type:"number",value:h,step:e,name:Y(),onChange:v})]}),d.jsxs("div",{children:[d.jsx("span",{children:"Repeat:"}),d.jsx("input",{ref:a,type:"number",value:p,step:e,name:Y(),onChange:v}),d.jsx("input",{ref:r,type:"number",value:y,step:e,name:Y(),onChange:v})]}),d.jsx("button",{onClick:()=>{E("",c,h,p,y),t.current.src=Lt},children:"Clear"})]})]})}function qe(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=vt(i.value):i.type==="color"&&(e=vt(new m.Color().setStyle(i.value,m.LinearSRGBColorSpace))));const[t,s]=b.useState(e),n=b.useRef(null),a=l=>{let h=l.target.value;if(i.type==="boolean")h=l.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?h=Number(h):typeof i.value=="boolean"?h=!!h:typeof i.value=="object"&&(h=JSON.parse(h)),i.options!==void 0)){const u=i.options.length;for(let p=0;p<u&&i.options[p].value!==h;p++);}s(h),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,h)},r={};i.disabled&&(r.opacity=.8);const o=i.type==="field"||i.type==="string"&&(t.length>100||t.search(`
|
|
21
|
+
`)>-1),c=o||i.type==="image"||i.type==="vector2";return d.jsxs("div",{className:`field ${c?"block":""}`,style:r,children:[i.type!=="button"&&d.jsx("span",{ref:n,children:je(i.title)},"fieldLabel"),i.type==="string"&&!o&&d.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t,name:Y()}),(i.type==="field"||i.type==="string"&&o)&&d.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:l=>{i.onKeyDown!==void 0&&i.onKeyDown(l)},value:t,name:Y()}),i.type==="boolean"&&d.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t,name:Y()}),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:a,disabled:i.disabled,className:"color",name:Y()}),d.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled,name:Y()})]}),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(cn,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&d.jsx(d.Fragment,{children:d.jsx("select",{onChange:a,disabled:i.disabled,defaultValue:i.value,name:Y(),children:i.options?.map((l,h)=>d.jsx("option",{value:l.value,children:je(l.title)},h))})}),i.type==="vector2"&&d.jsx(Ws,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&d.jsx(It,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&d.jsx(Ys,{step:i.step,value:t,onChange:a}),i.type==="euler"&&d.jsx(It,{step:i.step,value:t,onChange:a})]})}function hn(i){return"items"in i}class Q 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(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=b.createRef(),n=d.jsx(Q,{three:this.props.three,ref:s,title:e.title,expanded:e.expanded,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(hn(t))e.push(d.jsx(Q,{three:this.props.three,title:je(t.title),items:t.items},Math.random()));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(d.jsx(qe,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),d.jsx(Me,{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 N extends b.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static three;constructor(e){super(e),this.state={lastUpdate:Date.now()},N.instance=this,N.three=e.three,e.three.addEventListener(U.ADD_GROUP,this.addGroup),e.three.addEventListener(U.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){this.props.three.removeEventListener(U.ADD_GROUP,this.addGroup),this.props.three.removeEventListener(U.REMOVE_GROUP,this.removeGroup)}render(){return d.jsx("div",{className:"customGroups",children:N.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)}})}),N.groups.push(d.jsx(Q,{three:this.props.three,title:t.title,items:s},Math.random())),N.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=N.groupTitles.length;for(let n=0;n<s;n++)if(t===N.groupTitles[n]){N.groups.splice(n,1),N.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=N.groupTitles.length;for(let r=0;r<t;r++)if(N.groupTitles[r]===e.title)return N.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,c)=>{e.onUpdate(o,c)}})}),e.subgroups&&e.subgroups.length>0&&e.subgroups.forEach(r=>{const o=[];r.items.forEach(c=>{o.push({type:c.type,prop:c.prop,title:c.title!==void 0?c.title:c.prop,value:c.value,min:c.min,max:c.max,step:c.step,options:c.options,disabled:c.disabled,onChange:(l,h)=>{r.onUpdate(l,h)}})}),s.push({three:N.three,title:r.title,expanded:r.expanded,items:o})});const n=b.createRef(),a=d.jsx(Q,{three:N.three,ref:n,title:e.title,expanded:e.expanded,items:s},Math.random());return N.groups.push(a),N.groupsRefs.push(n),N.groupTitles.push(e.title),setTimeout(()=>{N.instance.setState({lastUpdate:Date.now()})},0),n}static removeEditorGroup(e){const t=N.groupTitles.length;for(let s=0;s<t;s++)if(e===N.groupTitles[s]){N.groups.splice(s,1),N.groupTitles.splice(s,1),N.instance.setState({lastUpdate:Date.now()});return}}static removeAllGroups(){for(let e=N.groupTitles.length;e>0;e--)N.groups.splice(e,1),N.groupTitles.splice(e,1);N.instance.setState({lastUpdate:Date.now()})}}function Nt(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function dn(i,e){function t(){return`${e.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:Nt(o),prop:o,type:"number",step:.01,value:i.perspectiveCameraInfo[o],onChange:(c,l)=>{e.updateObject(i.uuid,c,l),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,c,l),u.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const o in i.orthographicCameraInfo)r.push({title:Nt(o),prop:o,type:"number",step:.01,value:i.orthographicCameraInfo[o],onChange:(c,l)=>{e.updateObject(i.uuid,c,l),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,c,l),u.updateProjectionMatrix())}}});return d.jsx(Q,{three:e,title:"Camera",items:r,expanded:n,onToggle:o=>{a(o)}})}/*!
|
|
22
22
|
* camera-controls
|
|
23
23
|
* https://github.com/yomotsu/camera-controls
|
|
24
24
|
* (c) 2017 @yomotsu
|
|
25
25
|
* Released under the MIT License.
|
|
26
|
-
*/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 pe(i){return i.isPerspectiveCamera}function ce(i){return i.isOrthographicCamera}const xe=Math.PI*2,Nt=Math.PI/2,ci=1e-5,De=Math.PI/180;function J(i,e,t){return Math.max(e,Math.min(t,i))}function z(i,e=ci){return Math.abs(i)<e}function k(i,e,t=ci){return z(i-e,t)}function kt(i,e){return Math.round(i/e)*e}function Pe(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Ie(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Be(i,e,t,s,n=1/0,a){s=Math.max(1e-4,s);const r=2/s,o=r*a,c=1/(1+o+.48*o*o+.235*o*o*o);let l=i-e;const h=e,p=n*s;l=J(l,-p,p),e=i-l;const m=(t.value+r*l)*a;t.value=(t.value-r*m)*c;let g=e+(l+m)*c;return h-i>0==g>h&&(g=h,t.value=(g-h)/a),g}function Ft(i,e,t,s,n=1/0,a,r){s=Math.max(1e-4,s);const o=2/s,c=o*a,l=1/(1+c+.48*c*c+.235*c*c*c);let h=e.x,p=e.y,m=e.z,g=i.x-h,y=i.y-p,_=i.z-m;const E=h,v=p,C=m,x=n*s,O=x*x,S=g*g+y*y+_*_;if(S>O){const ue=Math.sqrt(S);g=g/ue*x,y=y/ue*x,_=_/ue*x}h=i.x-g,p=i.y-y,m=i.z-_;const w=(t.x+o*g)*a,M=(t.y+o*y)*a,U=(t.z+o*_)*a;t.x=(t.x-o*w)*l,t.y=(t.y-o*M)*l,t.z=(t.z-o*U)*l,r.x=h+(g+w)*l,r.y=p+(y+M)*l,r.z=m+(_+U)*l;const A=E-i.x,F=v-i.y,Q=C-i.z,re=r.x-E,de=r.y-v,_e=r.z-C;return A*re+F*de+Q*_e>0&&(r.x=E,r.y=v,r.z=C,t.x=(r.x-E)/a,t.y=(r.y-v)/a,t.z=(r.z-C)/a),r}function at(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 ot(i,e){return ce(i)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class hn{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 a=n.indexOf(t);a!==-1&&n.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let a=0,r=n.length;a<r;a++)n[a].call(this,e)}}}var lt;const dn="2.10.1",Ve=1/8,un=/Mac/.test((lt=globalThis?.navigator)===null||lt===void 0?void 0:lt.platform);let R,zt,Ge,ct,Y,D,N,Oe,Ue,ee,te,me,Ht,jt,q,Le,we,Bt,ht,Vt,dt,ut,We;class se extends hn{static install(e){R=e.THREE,zt=Object.freeze(new R.Vector3(0,0,0)),Ge=Object.freeze(new R.Vector3(0,1,0)),ct=Object.freeze(new R.Vector3(0,0,1)),Y=new R.Vector2,D=new R.Vector3,N=new R.Vector3,Oe=new R.Vector3,Ue=new R.Vector3,ee=new R.Vector3,te=new R.Vector3,me=new R.Vector3,Ht=new R.Vector3,jt=new R.Vector3,q=new R.Spherical,Le=new R.Spherical,we=new R.Box3,Bt=new R.Box3,ht=new R.Sphere,Vt=new R.Quaternion,dt=new R.Quaternion,ut=new R.Matrix4,We=new R.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 R.Vector3,this._focalOffsetVelocity=new R.Vector3,this._zoomVelocity={value:0},this._truckInternal=(v,C,x,O)=>{let S,w;if(pe(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*v*A/this._elementRect.height,w=this.truckSpeed*C*A/this._elementRect.height}else if(ce(this._camera)){const M=this._camera;S=this.truckSpeed*v*(M.right-M.left)/M.zoom/this._elementRect.width,w=this.truckSpeed*C*(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(-w,!0)):x?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+w,this._focalOffsetEnd.z,!0):this.truck(S,w,!0)},this._rotateInternal=(v,C)=>{const x=xe*this.azimuthRotateSpeed*v/this._elementRect.height,O=xe*this.polarRotateSpeed*C/this._elementRect.height;this.rotate(x,O,!0)},this._dollyInternal=(v,C,x)=>{const O=Math.pow(.95,-v*this.dollySpeed),S=this._sphericalEnd.radius,w=this._sphericalEnd.radius*O,M=J(w,this.minDistance,this.maxDistance),U=M-w;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(w,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(M,!0)):this._dollyToNoClamp(M,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?w:M)-S,this._dollyControlCoord.set(C,x)),this._lastDollyDirection=Math.sign(-v)},this._zoomInternal=(v,C,x)=>{const O=Math.pow(.95,v*this.dollySpeed),S=this._zoom,w=this._zoom*O;this.zoomTo(w,!0),this.dollyToCursor&&(this._changedZoom+=w-S,this._dollyControlCoord.set(C,x))},typeof R>"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 R.Quaternion().setFromUnitVectors(this._camera.up,Ge),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=f.NONE,this._target=new R.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new R.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new R.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 R.Vector3,new R.Vector3,new R.Vector3,new R.Vector3],this._updateNearPlaneCorners(),this._boundary=new R.Box3(new R.Vector3(-1/0,-1/0,-1/0),new R.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 R.Vector2,this.mouseButtons={left:f.ROTATE,middle:f.DOLLY,right:f.TRUCK,wheel:pe(this._camera)?f.DOLLY:ce(this._camera)?f.ZOOM:f.NONE},this.touches={one:f.TOUCH_ROTATE,two:pe(this._camera)?f.TOUCH_DOLLY_TRUCK:ce(this._camera)?f.TOUCH_ZOOM_TRUCK:f.NONE,three:f.TOUCH_TRUCK};const s=new R.Vector2,n=new R.Vector2,a=new R.Vector2,r=v=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),S=v.clientX/O.width,w=v.clientY/O.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}const C=v.pointerType!=="mouse"?null:(v.buttons&H.LEFT)===H.LEFT?H.LEFT:(v.buttons&H.MIDDLE)===H.MIDDLE?H.MIDDLE:(v.buttons&H.RIGHT)===H.RIGHT?H.RIGHT:null;if(C!==null){const O=this._findPointerByMouseButton(C);O&&this._disposePointer(O)}if((v.buttons&H.LEFT)===H.LEFT&&this._lockedPointer)return;const x={pointerId:v.pointerId,clientX:v.clientX,clientY:v.clientY,deltaX:0,deltaY:0,mouseButton:C};this._activePointers.push(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,m(v)},o=v=>{v.cancelable&&v.preventDefault();const C=v.pointerId,x=this._lockedPointer||this._findPointerById(C);if(x){if(x.clientX=v.clientX,x.clientY=v.clientY,x.deltaX=v.movementX,x.deltaY=v.movementY,this._state=0,v.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(v.buttons&H.LEFT)===H.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(v.buttons&H.MIDDLE)===H.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(v.buttons&H.RIGHT)===H.RIGHT&&(this._state=this._state|this.mouseButtons.right);g()}},c=v=>{const C=this._findPointerById(v.pointerId);if(!(C&&C===this._lockedPointer)){if(C&&this._disposePointer(C),v.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=f.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=f.NONE;y()}};let l=-1;const h=v=>{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 w=this._domElement.getBoundingClientRect(),M=v.clientX/w.width,U=v.clientY/w.height;if(M<this._interactiveArea.left||M>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(v.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===f.ROTATE||this.mouseButtons.wheel===f.TRUCK){const w=performance.now();l-w<1e3&&this._getClientRect(this._elementRect),l=w}const C=un?-1:-3,x=v.deltaMode===1||v.ctrlKey?v.deltaY/C:v.deltaY/(C*10),O=this.dollyToCursor?(v.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(v.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case f.ROTATE:{this._rotateInternal(v.deltaX,v.deltaY),this._isUserControllingRotate=!0;break}case f.TRUCK:{this._truckInternal(v.deltaX,v.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case f.SCREEN_PAN:{this._truckInternal(v.deltaX,v.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case f.OFFSET:{this._truckInternal(v.deltaX,v.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"})},p=v=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===se.ACTION.NONE){const C=v instanceof PointerEvent?v.pointerId:0,x=this._findPointerById(C);x&&this._disposePointer(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}v.preventDefault()}},m=v=>{if(!this._enabled)return;if(at(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);a.set(0,S);const w=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,M=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(w,M)}if(this._state=0,!v)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in v&&v.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(v.buttons&H.LEFT)===H.LEFT&&(this._state=this._state|this.mouseButtons.left),(v.buttons&H.MIDDLE)===H.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(v.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"})},g=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,at(this._activePointers,Y);const C=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,x=C?-C.deltaX:n.x-Y.x,O=C?-C.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,w=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*Ve,S,w),this._isUserControllingDolly=!0):(this._zoomInternal(M*O*Ve,S,w),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,w=Y.y-this._activePointers[1].clientY,M=Math.sqrt(S*S+w*w),U=a.y-M;a.set(0,M);const A=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,F=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*Ve,A,F),this._isUserControllingDolly=!0):(this._zoomInternal(U*Ve,A,F),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"})},y=()=>{at(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",c),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",c),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",c),m())},this.unlockPointer=()=>{var v,C,x;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(v=this._domElement)===null||v===void 0||v.ownerDocument.exitPointerLock(),(C=this._domElement)===null||C===void 0||C.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=v=>{this._domElement=v,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",p),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),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,y())},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=J(e.width,0,1),this._interactiveArea.height=J(e.height,0,1),this._interactiveArea.x=J(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=J(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=J(e,this.minAzimuthAngle,this.maxAzimuthAngle),a=J(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!s||k(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&k(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0,this._dollyToNoClamp(J(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),o=k(r,this._spherical.radius);if(!(s>e)&&o)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||k(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ue).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||k(this._target.x,this._targetEnd.x,this.restThreshold)&&k(this._target.y,this._targetEnd.y,this.restThreshold)&&k(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=J(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||k(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(),ee.setFromMatrixColumn(this._camera.matrix,0),te.setFromMatrixColumn(this._camera.matrix,1),ee.multiplyScalar(e),te.multiplyScalar(-t);const n=D.copy(ee).add(te),a=N.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.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 a=D.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const r=!n||k(this._target.x,this._targetEnd.x,this.restThreshold)&&k(this._target.y,this._targetEnd.y,this.restThreshold)&&k(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}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:a=0,paddingBottom:r=0,paddingTop:o=0}={}){const c=[],l=e.isBox3?we.copy(e):we.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=kt(this._sphericalEnd.theta,Nt),p=kt(this._sphericalEnd.phi,Nt);c.push(this.rotateTo(h,p,t));const m=D.setFromSpherical(this._sphericalEnd).normalize(),g=Vt.setFromUnitVectors(m,ct),y=k(Math.abs(m.y),1);y&&g.multiply(dt.setFromAxisAngle(Ge,h)),g.multiply(this._yAxisUpSpaceInverse);const _=Bt.makeEmpty();N.copy(l.min).applyQuaternion(g),_.expandByPoint(N),N.copy(l.min).setX(l.max.x).applyQuaternion(g),_.expandByPoint(N),N.copy(l.min).setY(l.max.y).applyQuaternion(g),_.expandByPoint(N),N.copy(l.max).setZ(l.min.z).applyQuaternion(g),_.expandByPoint(N),N.copy(l.min).setZ(l.max.z).applyQuaternion(g),_.expandByPoint(N),N.copy(l.max).setY(l.min.y).applyQuaternion(g),_.expandByPoint(N),N.copy(l.max).setX(l.min.x).applyQuaternion(g),_.expandByPoint(N),N.copy(l.max).applyQuaternion(g),_.expandByPoint(N),_.min.x-=n,_.min.y-=r,_.max.x+=a,_.max.y+=o,g.setFromUnitVectors(ct,m),y&&g.premultiply(dt.invert()),g.premultiply(this._yAxisUpSpace);const E=_.getSize(D),v=_.getCenter(N).applyQuaternion(g);if(pe(this._camera)){const C=this.getDistanceToFitBox(E.x,E.y,E.z,s);c.push(this.moveTo(v.x,v.y,v.z,t)),c.push(this.dollyTo(C,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(ce(this._camera)){const C=this._camera,x=C.right-C.left,O=C.top-C.bottom,S=s?Math.max(x/E.x,O/E.y):Math.min(x/E.x,O/E.y);c.push(this.moveTo(v.x,v.y,v.z,t)),c.push(this.zoomTo(S,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const s=[],a="isObject3D"in e?se.createBoundingSphere(e,ht):ht.copy(e);if(s.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),pe(this._camera)){const r=this.getDistanceToFitSphere(a.radius);s.push(this.dollyTo(r,t))}else if(ce(this._camera)){const r=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,c=2*a.radius,l=Math.min(r/c,o/c);s.push(this.zoomTo(l,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,a,r,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const c=N.set(n,a,r),l=D.set(e,t,s);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(l.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!o||k(this._target.x,this._targetEnd.x,this.restThreshold)&&k(this._target.y,this._targetEnd.y,this.restThreshold)&&k(this._target.z,this._targetEnd.z,this.restThreshold)&&k(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&k(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&k(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,s,n,a,r,o,c,l,h,p,m,g,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const _=D.set(n,a,r),E=N.set(e,t,s);q.setFromVector3(E.sub(_).applyQuaternion(this._yAxisUpSpace));const v=Oe.set(h,p,m),C=N.set(o,c,l);Le.setFromVector3(C.sub(v).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(v,g));const x=Le.theta-q.theta,O=Le.phi-q.phi,S=Le.radius-q.radius;this._sphericalEnd.set(q.radius+S*g,q.phi+O*g,q.theta+x*g),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const w=!y||k(this._target.x,this._targetEnd.x,this.restThreshold)&&k(this._target.y,this._targetEnd.y,this.restThreshold)&&k(this._target.z,this._targetEnd.z,this.restThreshold)&&k(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&k(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&k(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(w)}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 a=this.getPosition(D),r=this.setLookAt(a.x,a.y,a.z,e,t,s,n);return this._sphericalEnd.phi=J(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}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 a=!n||k(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&k(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&k(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),ee.setFromMatrixColumn(this._camera.matrixWorldInverse,0),te.setFromMatrixColumn(this._camera.matrixWorldInverse,1),me.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=D.set(e,t,s),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);ee.multiplyScalar(r.x),te.multiplyScalar(r.y),me.multiplyScalar(r.z),D.copy(ee).add(te).add(me),D.z=D.z+a,this.dollyTo(a,!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 R.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(ot(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=e/t,r=this._camera.getEffectiveFOV()*De,o=this._camera.aspect;return((n?a>o:a<o)?t:e/o)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(e){if(ot(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 R.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new R.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new R.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new R.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(!k(this._camera.up.x,this._cameraUp0.x)||!k(this._camera.up.y,this._cameraUp0.y)||!k(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,Ge),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,a=Ht.subVectors(this._targetEnd,this._target),r=jt.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 p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Be(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(z(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Be(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(z(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Be(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(z(a.x)&&z(a.y)&&z(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Ft(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(z(r.x)&&z(r.y)&&z(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Ft(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(z(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Be(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(pe(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,m=this._camera,g=this._getCameraDirection(Ue),y=D.copy(g).cross(m.up).normalize();y.lengthSq()===0&&(y.x=1);const _=N.crossVectors(y,g),E=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*De*.5),C=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,x=Oe.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*E*m.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*E)),O=D.copy(this._targetEnd).lerp(x,C),S=this._lastDollyDirection===Se.IN&&this._spherical.radius<=this.minDistance,w=this._lastDollyDirection===Se.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||w)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const U=N.copy(g).multiplyScalar(-p);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-=p,z(this._changedDolly)&&(this._changedDolly=0)}else if(ce(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,m=this._camera,g=D.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),y=N.set(0,0,-1).applyQuaternion(m.quaternion),_=Oe.copy(g).add(y.multiplyScalar(-g.dot(m.up))),v=-(this._zoom-p-this._zoom)/this._zoom,C=this._getCameraDirection(Ue),x=this._targetEnd.dot(C),O=D.copy(this._targetEnd).lerp(_,v),S=O.dot(C),w=C.multiplyScalar(S-x);O.sub(w),this._boundary.clampPoint(O,O);const M=N.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(M),this._changedZoom-=p,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 c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),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))&&(ee.setFromMatrixColumn(this._camera.matrix,0),te.setFromMatrixColumn(this._camera.matrix,1),me.setFromMatrixColumn(this._camera.matrix,2),ee.multiplyScalar(this._focalOffset.x),te.multiplyScalar(-this._focalOffset.y),me.multiplyScalar(this._focalOffset.z),D.copy(ee).add(te).add(me),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(a.x,this.restThreshold)&&z(a.y,this.restThreshold)&&z(a.z,this.restThreshold)&&z(r.x,this.restThreshold)&&z(r.y,this.restThreshold)&&z(r.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:Pe(this.maxDistance),minZoom:this.minZoom,maxZoom:Pe(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Pe(this.maxPolarAngle),minAzimuthAngle:Pe(this.minAzimuthAngle),maxAzimuthAngle:Pe(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=Ie(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Ie(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Ie(s.maxPolarAngle),this.minAzimuthAngle=Ie(s.minAzimuthAngle),this.maxAzimuthAngle=Ie(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),q.setFromVector3(D.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(q.theta,q.phi,t),this.dollyTo(q.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",dn),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 a=N.copy(t).add(e),o=this._boundary.clampPoint(a,Oe).sub(a),c=o.lengthSq();if(c===0)return e.add(t);if(c===n)return e;if(s===0)return e.add(t).add(o);{const l=1+s*c/t.dot(o);return e.add(N.copy(t).multiplyScalar(l)).add(o.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(pe(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*De,n=Math.tan(s*.5)*t,a=n*e.aspect;this._nearPlaneCorners[0].set(-a,-n,0),this._nearPlaneCorners[1].set(a,-n,0),this._nearPlaneCorners[2].set(a,n,0),this._nearPlaneCorners[3].set(-a,n,0)}else if(ce(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,a=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(s,a,0),this._nearPlaneCorners[1].set(n,a,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(s,r,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||ot(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(Ue);ut.lookAt(zt,s,this._camera.up);for(let n=0;n<4;n++){const a=N.copy(this._nearPlaneCorners[n]);a.applyMatrix4(ut);const r=Oe.addVectors(this._target,a);We.set(r,s),We.far=this._spherical.radius+1;const o=We.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 R.Sphere){const s=t,n=s.center;we.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&we.expandByObject(r)}),we.getCenter(n);let a=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const o=r;if(!o.geometry)return;const c=o.geometry.clone();c.applyMatrix4(o.matrixWorld);const h=c.attributes.position;for(let p=0,m=h.count;p<m;p++)D.fromBufferAttribute(h,p),a=Math.max(a,n.distanceToSquared(D))}),s.radius=Math.sqrt(a),s}}const Xe=i=>{const[e,t]=b.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 u.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),u.jsx("ul",{className:"dropdown-menu",style:{height:a},children:i.options.map(r=>u.jsx("li",{onClick:()=>n(r),children:r},r))})]})},fe=b.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=b.useState("Renderer"),[r,o]=b.useState(!1),[c,l]=b.useState(!1),[h,p]=b.useState(!1);return u.jsxs("div",{className:`CameraWindow ${e.name}`,children:[u.jsx("div",{ref:t,className:"clickable",onClick:()=>{h&&p(!1)}}),u.jsxs("div",{className:"options",children:[e.camera!==null&&u.jsx(Xe,{title:"Camera",index:e.options.indexOf(e.camera.name),open:h,options:e.options,onSelect:e.onSelectCamera,onToggle:m=>{m&&c&&l(!1),p(m)},up:!0}),u.jsx(Xe,{title:"Mode",index:s.indexOf(n),open:c,options:s,onSelect:m=>{if(m===n)return;const g=m;e.onSelectRenderMode(g),a(g)},onToggle:m=>{m&&h&&p(!1),r&&o(!1),l(m)},up:!0})]})]})}),pn=`out vec3 worldPosition;
|
|
26
|
+
*/const j={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,kt=Math.PI/2,di=1e-5,Pe=Math.PI/180;function ee(i,e,t){return Math.max(e,Math.min(t,i))}function H(i,e=di){return Math.abs(i)<e}function F(i,e,t=di){return H(i-e,t)}function Ft(i,e){return Math.round(i/e)*e}function De(i){return isFinite(i)?i:i<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Ie(i){return Math.abs(i)<Number.MAX_VALUE?i:i*(1/0)}function Ve(i,e,t,s,n=1/0,a){s=Math.max(1e-4,s);const r=2/s,o=r*a,c=1/(1+o+.48*o*o+.235*o*o*o);let l=i-e;const h=e,u=n*s;l=ee(l,-u,u),e=i-l;const p=(t.value+r*l)*a;t.value=(t.value-r*p)*c;let g=e+(l+p)*c;return h-i>0==g>h&&(g=h,t.value=(g-h)/a),g}function zt(i,e,t,s,n=1/0,a,r){s=Math.max(1e-4,s);const o=2/s,c=o*a,l=1/(1+c+.48*c*c+.235*c*c*c);let h=e.x,u=e.y,p=e.z,g=i.x-h,y=i.y-u,_=i.z-p;const E=h,v=u,C=p,x=n*s,O=x*x,S=g*g+y*y+_*_;if(S>O){const pe=Math.sqrt(S);g=g/pe*x,y=y/pe*x,_=_/pe*x}h=i.x-g,u=i.y-y,p=i.z-_;const T=(t.x+o*g)*a,M=(t.y+o*y)*a,L=(t.z+o*_)*a;t.x=(t.x-o*T)*l,t.y=(t.y-o*M)*l,t.z=(t.z-o*L)*l,r.x=h+(g+T)*l,r.y=u+(y+M)*l,r.z=p+(_+L)*l;const A=E-i.x,z=v-i.y,J=C-i.z,ae=r.x-E,ue=r.y-v,_e=r.z-C;return A*ae+z*ue+J*_e>0&&(r.x=E,r.y=v,r.z=C,t.x=(r.x-E)/a,t.y=(r.y-v)/a,t.z=(r.z-C)/a),r}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 un{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 a=n.indexOf(t);a!==-1&&n.splice(a,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let a=0,r=n.length;a<r;a++)n[a].call(this,e)}}}var ct;const pn="2.10.1",Ge=1/8,mn=/Mac/.test((ct=globalThis?.navigator)===null||ct===void 0?void 0:ct.platform);let P,Ht,We,ht,Z,D,k,Oe,Ue,te,ie,fe,jt,Bt,K,Le,we,Vt,dt,Gt,ut,pt,Ye;class ne extends un{static install(e){P=e.THREE,Ht=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)),Z=new P.Vector2,D=new P.Vector3,k=new P.Vector3,Oe=new P.Vector3,Ue=new P.Vector3,te=new P.Vector3,ie=new P.Vector3,fe=new P.Vector3,jt=new P.Vector3,Bt=new P.Vector3,K=new P.Spherical,Le=new P.Spherical,we=new P.Box3,Vt=new P.Box3,dt=new P.Sphere,Gt=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=(v,C,x,O)=>{let S,T;if(me(this._camera)){const M=D.copy(this._camera.position).sub(this._target),L=this._camera.getEffectiveFOV()*Pe,A=M.length()*Math.tan(L*.5);S=this.truckSpeed*v*A/this._elementRect.height,T=this.truckSpeed*C*A/this._elementRect.height}else if(he(this._camera)){const M=this._camera;S=this.truckSpeed*v*(M.right-M.left)/M.zoom/this._elementRect.width,T=this.truckSpeed*C*(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=(v,C)=>{const x=xe*this.azimuthRotateSpeed*v/this._elementRect.height,O=xe*this.polarRotateSpeed*C/this._elementRect.height;this.rotate(x,O,!0)},this._dollyInternal=(v,C,x)=>{const O=Math.pow(.95,-v*this.dollySpeed),S=this._sphericalEnd.radius,T=this._sphericalEnd.radius*O,M=ee(T,this.minDistance,this.maxDistance),L=M-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(L,!0),this._dollyToNoClamp(M,!0)):this._dollyToNoClamp(M,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:M)-S,this._dollyControlCoord.set(C,x)),this._lastDollyDirection=Math.sign(-v)},this._zoomInternal=(v,C,x)=>{const O=Math.pow(.95,v*this.dollySpeed),S=this._zoom,T=this._zoom*O;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-S,this._dollyControlCoord.set(C,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,a=new P.Vector2,r=v=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),S=v.clientX/O.width,T=v.clientY/O.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const C=v.pointerType!=="mouse"?null:(v.buttons&j.LEFT)===j.LEFT?j.LEFT:(v.buttons&j.MIDDLE)===j.MIDDLE?j.MIDDLE:(v.buttons&j.RIGHT)===j.RIGHT?j.RIGHT:null;if(C!==null){const O=this._findPointerByMouseButton(C);O&&this._disposePointer(O)}if((v.buttons&j.LEFT)===j.LEFT&&this._lockedPointer)return;const x={pointerId:v.pointerId,clientX:v.clientX,clientY:v.clientY,deltaX:0,deltaY:0,mouseButton:C};this._activePointers.push(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,p(v)},o=v=>{v.cancelable&&v.preventDefault();const C=v.pointerId,x=this._lockedPointer||this._findPointerById(C);if(x){if(x.clientX=v.clientX,x.clientY=v.clientY,x.deltaX=v.movementX,x.deltaY=v.movementY,this._state=0,v.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(v.buttons&j.LEFT)===j.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(v.buttons&j.MIDDLE)===j.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(v.buttons&j.RIGHT)===j.RIGHT&&(this._state=this._state|this.mouseButtons.right);g()}},c=v=>{const C=this._findPointerById(v.pointerId);if(!(C&&C===this._lockedPointer)){if(C&&this._disposePointer(C),v.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=f.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=f.NONE;y()}};let l=-1;const h=v=>{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=v.clientX/T.width,L=v.clientY/T.height;if(M<this._interactiveArea.left||M>this._interactiveArea.right||L<this._interactiveArea.top||L>this._interactiveArea.bottom)return}if(v.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===f.ROTATE||this.mouseButtons.wheel===f.TRUCK){const T=performance.now();l-T<1e3&&this._getClientRect(this._elementRect),l=T}const C=mn?-1:-3,x=v.deltaMode===1||v.ctrlKey?v.deltaY/C:v.deltaY/(C*10),O=this.dollyToCursor?(v.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(v.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case f.ROTATE:{this._rotateInternal(v.deltaX,v.deltaY),this._isUserControllingRotate=!0;break}case f.TRUCK:{this._truckInternal(v.deltaX,v.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case f.SCREEN_PAN:{this._truckInternal(v.deltaX,v.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case f.OFFSET:{this._truckInternal(v.deltaX,v.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=v=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ne.ACTION.NONE){const C=v instanceof PointerEvent?v.pointerId:0,x=this._findPointerById(C);x&&this._disposePointer(x),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}v.preventDefault()}},p=v=>{if(!this._enabled)return;if(ot(this._activePointers,Z),this._getClientRect(this._elementRect),s.copy(Z),n.copy(Z),this._activePointers.length>=2){const x=Z.x-this._activePointers[1].clientX,O=Z.y-this._activePointers[1].clientY,S=Math.sqrt(x*x+O*O);a.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,!v)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in v&&v.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(v.buttons&j.LEFT)===j.LEFT&&(this._state=this._state|this.mouseButtons.left),(v.buttons&j.MIDDLE)===j.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(v.buttons&j.RIGHT)===j.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"})},g=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ot(this._activePointers,Z);const C=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,x=C?-C.deltaX:n.x-Z.x,O=C?-C.deltaY:n.y-Z.y;if(n.copy(Z),((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=Z.x-this._activePointers[1].clientX,T=Z.y-this._activePointers[1].clientY,M=Math.sqrt(S*S+T*T),L=a.y-M;a.set(0,M);const A=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,z=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(L*Ge,A,z),this._isUserControllingDolly=!0):(this._zoomInternal(L*Ge,A,z),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"})},y=()=>{ot(this._activePointers,Z),n.copy(Z),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",c),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",c),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",c),p())},this.unlockPointer=()=>{var v,C,x;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(v=this._domElement)===null||v===void 0||v.ownerDocument.exitPointerLock(),(C=this._domElement)===null||C===void 0||C.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=v=>{this._domElement=v,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",c),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",r),this._domElement.removeEventListener("pointercancel",c),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",c),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,y())},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),a=ee(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!s||F(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&F(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=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 r=this._collisionTest(),o=F(r,this._spherical.radius);if(!(s>e)&&o)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const a=!t||F(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ue).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(),te.setFromMatrixColumn(this._camera.matrix,0),ie.setFromMatrixColumn(this._camera.matrix,1),te.multiplyScalar(e),ie.multiplyScalar(-t);const n=D.copy(te).add(ie),a=k.copy(this._targetEnd).add(n);return this.moveTo(a.x,a.y,a.z,s)}forward(e,t=!1){D.setFromMatrixColumn(this._camera.matrix,0),D.crossVectors(this._camera.up,D),D.multiplyScalar(e);const s=k.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 a=D.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const r=!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(r)}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:a=0,paddingBottom:r=0,paddingTop:o=0}={}){const c=[],l=e.isBox3?we.copy(e):we.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=Ft(this._sphericalEnd.theta,kt),u=Ft(this._sphericalEnd.phi,kt);c.push(this.rotateTo(h,u,t));const p=D.setFromSpherical(this._sphericalEnd).normalize(),g=Gt.setFromUnitVectors(p,ht),y=F(Math.abs(p.y),1);y&&g.multiply(ut.setFromAxisAngle(We,h)),g.multiply(this._yAxisUpSpaceInverse);const _=Vt.makeEmpty();k.copy(l.min).applyQuaternion(g),_.expandByPoint(k),k.copy(l.min).setX(l.max.x).applyQuaternion(g),_.expandByPoint(k),k.copy(l.min).setY(l.max.y).applyQuaternion(g),_.expandByPoint(k),k.copy(l.max).setZ(l.min.z).applyQuaternion(g),_.expandByPoint(k),k.copy(l.min).setZ(l.max.z).applyQuaternion(g),_.expandByPoint(k),k.copy(l.max).setY(l.min.y).applyQuaternion(g),_.expandByPoint(k),k.copy(l.max).setX(l.min.x).applyQuaternion(g),_.expandByPoint(k),k.copy(l.max).applyQuaternion(g),_.expandByPoint(k),_.min.x-=n,_.min.y-=r,_.max.x+=a,_.max.y+=o,g.setFromUnitVectors(ht,p),y&&g.premultiply(ut.invert()),g.premultiply(this._yAxisUpSpace);const E=_.getSize(D),v=_.getCenter(k).applyQuaternion(g);if(me(this._camera)){const C=this.getDistanceToFitBox(E.x,E.y,E.z,s);c.push(this.moveTo(v.x,v.y,v.z,t)),c.push(this.dollyTo(C,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(he(this._camera)){const C=this._camera,x=C.right-C.left,O=C.top-C.bottom,S=s?Math.max(x/E.x,O/E.y):Math.min(x/E.x,O/E.y);c.push(this.moveTo(v.x,v.y,v.z,t)),c.push(this.zoomTo(S,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const s=[],a="isObject3D"in e?ne.createBoundingSphere(e,dt):dt.copy(e);if(s.push(this.moveTo(a.center.x,a.center.y,a.center.z,t)),me(this._camera)){const r=this.getDistanceToFitSphere(a.radius);s.push(this.dollyTo(r,t))}else if(he(this._camera)){const r=this._camera.right-this._camera.left,o=this._camera.top-this._camera.bottom,c=2*a.radius,l=Math.min(r/c,o/c);s.push(this.zoomTo(l,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,a,r,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const c=k.set(n,a,r),l=D.set(e,t,s);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(l.sub(c).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,a,r,o,c,l,h,u,p,g,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Se.NONE,this._changedDolly=0;const _=D.set(n,a,r),E=k.set(e,t,s);K.setFromVector3(E.sub(_).applyQuaternion(this._yAxisUpSpace));const v=Oe.set(h,u,p),C=k.set(o,c,l);Le.setFromVector3(C.sub(v).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(v,g));const x=Le.theta-K.theta,O=Le.phi-K.phi,S=Le.radius-K.radius;this._sphericalEnd.set(K.radius+S*g,K.phi+O*g,K.theta+x*g),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!y||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 a=this.getPosition(D),r=this.setLookAt(a.x,a.y,a.z,e,t,s,n);return this._sphericalEnd.phi=ee(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}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 a=!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(a)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),te.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ie.setFromMatrixColumn(this._camera.matrixWorldInverse,1),fe.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=D.set(e,t,s),a=n.distanceTo(this._camera.position),r=n.sub(this._camera.position);te.multiplyScalar(r.x),ie.multiplyScalar(r.y),fe.multiplyScalar(r.z),D.copy(te).add(ie).add(fe),D.z=D.z+a,this.dollyTo(a,!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 a=e/t,r=this._camera.getEffectiveFOV()*Pe,o=this._camera.aspect;return((n?a>o:a<o)?t:e/o)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(e){if(lt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Pe,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=k.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,a=jt.subVectors(this._targetEnd,this._target),r=Bt.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(H(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(H(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(H(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(H(a.x)&&H(a.y)&&H(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const u=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;zt(this._target,this._targetEnd,this._targetVelocity,u,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(H(r.x)&&H(r.y)&&H(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const u=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;zt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,u,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(H(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,g=this._getCameraDirection(Ue),y=D.copy(g).cross(p.up).normalize();y.lengthSq()===0&&(y.x=1);const _=k.crossVectors(y,g),E=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*Pe*.5),C=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,x=Oe.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*E*p.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*E)),O=D.copy(this._targetEnd).lerp(x,C),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 L=k.copy(g).multiplyScalar(-u);O.add(L)}this._boundary.clampPoint(O,O);const M=k.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(M),this._changedDolly-=u,H(this._changedDolly)&&(this._changedDolly=0)}else if(he(this._camera)&&this._changedZoom!==0){const u=this._zoom-this._lastZoom,p=this._camera,g=D.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),y=k.set(0,0,-1).applyQuaternion(p.quaternion),_=Oe.copy(g).add(y.multiplyScalar(-g.dot(p.up))),v=-(this._zoom-u-this._zoom)/this._zoom,C=this._getCameraDirection(Ue),x=this._targetEnd.dot(C),O=D.copy(this._targetEnd).lerp(_,v),S=O.dot(C),T=C.multiplyScalar(S-x);O.sub(T),this._boundary.clampPoint(O,O);const M=k.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(M),this._changedZoom-=u,H(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 c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!H(this._focalOffset.x)||!H(this._focalOffset.y)||!H(this._focalOffset.z))&&(te.setFromMatrixColumn(this._camera.matrix,0),ie.setFromMatrixColumn(this._camera.matrix,1),fe.setFromMatrixColumn(this._camera.matrix,2),te.multiplyScalar(this._focalOffset.x),ie.multiplyScalar(-this._focalOffset.y),fe.multiplyScalar(this._focalOffset.z),D.copy(te).add(ie).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"}),H(t,this.restThreshold)&&H(s,this.restThreshold)&&H(n,this.restThreshold)&&H(a.x,this.restThreshold)&&H(a.y,this.restThreshold)&&H(a.z,this.restThreshold)&&H(r.x,this.restThreshold)&&H(r.y,this.restThreshold)&&H(r.z,this.restThreshold)&&H(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:De(this.maxDistance),minZoom:this.minZoom,maxZoom:De(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:De(this.maxPolarAngle),minAzimuthAngle:De(this.minAzimuthAngle),maxAzimuthAngle:De(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=Ie(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Ie(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Ie(s.maxPolarAngle),this.minAzimuthAngle=Ie(s.minAzimuthAngle),this.maxAzimuthAngle=Ie(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",pn),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 a=k.copy(t).add(e),o=this._boundary.clampPoint(a,Oe).sub(a),c=o.lengthSq();if(c===0)return e.add(t);if(c===n)return e;if(s===0)return e.add(t).add(o);{const l=1+s*c/t.dot(o);return e.add(k.copy(t).multiplyScalar(l)).add(o.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(me(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*Pe,n=Math.tan(s*.5)*t,a=n*e.aspect;this._nearPlaneCorners[0].set(-a,-n,0),this._nearPlaneCorners[1].set(a,-n,0),this._nearPlaneCorners[2].set(a,n,0),this._nearPlaneCorners[3].set(-a,n,0)}else if(he(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,a=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(s,a,0),this._nearPlaneCorners[1].set(n,a,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(s,r,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||lt(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(Ue);pt.lookAt(Ht,s,this._camera.up);for(let n=0;n<4;n++){const a=k.copy(this._nearPlaneCorners[n]);a.applyMatrix4(pt);const r=Oe.addVectors(this._target,a);Ye.set(r,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(r=>{r.isMesh&&we.expandByObject(r)}),we.getCenter(n);let a=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const o=r;if(!o.geometry)return;const c=o.geometry.clone();c.applyMatrix4(o.matrixWorld);const h=c.attributes.position;for(let u=0,p=h.count;u<p;u++)D.fromBufferAttribute(h,u),a=Math.max(a,n.distanceToSquared(D))}),s.radius=Math.sqrt(a),s}}const Qe=i=>{const[e,t]=b.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 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:a},children:i.options.map(r=>d.jsx("li",{onClick:()=>n(r),children:r},r))})]})},ge=b.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=b.useState("Renderer"),[r,o]=b.useState(!1),[c,l]=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&&c&&l(!1),u(p)},up:!0}),d.jsx(Qe,{title:"Mode",index:s.indexOf(n),open:c,options:s,onSelect:p=>{if(p===n)return;const g=p;e.onSelectRenderMode(g),a(g)},onToggle:p=>{p&&h&&u(!1),r&&o(!1),l(p)},up:!0})]})]})}),fn=`out vec3 worldPosition;
|
|
27
27
|
uniform float uDistance;
|
|
28
28
|
|
|
29
29
|
void main() {
|
|
@@ -32,7 +32,7 @@ void main() {
|
|
|
32
32
|
worldPosition.xz += cameraPosition.xz;
|
|
33
33
|
|
|
34
34
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
|
|
35
|
-
}`,
|
|
35
|
+
}`,gn=`out vec4 fragColor;
|
|
36
36
|
in vec3 worldPosition;
|
|
37
37
|
uniform float uDivisions;
|
|
38
38
|
uniform float uScale;
|
|
@@ -100,7 +100,7 @@ void main() {
|
|
|
100
100
|
fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
|
|
101
101
|
|
|
102
102
|
if (fragColor.a <= minAlpha) discard;
|
|
103
|
-
}`;class
|
|
103
|
+
}`;class ui extends m.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 m.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:m.GLSL3,side:m.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:fn,fragmentShader:gn})}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 pi extends m.Mesh{gridMaterial;constructor(e){const t=new ui(e);super(new m.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 mi 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:a,uSubgridOpacity:r,uGridOpacity:o}=this,c=R.varyingProperty("vec3","vWorldPosition");this.positionNode=R.Fn(()=>{const h=R.positionLocal.xzy.mul(a).add(R.vec3(R.cameraPosition.x,R.float(0),R.cameraPosition.z));return c.assign(h),h})();const l=R.Fn(([h])=>{const u=c.xz.div(h),p=R.fwidth(u),g=R.abs(R.fract(u.sub(.5)).sub(.5)).div(p).div(2),y=R.min(g.x,g.y);return R.float(1).sub(R.min(y,R.float(1)))});this.outputNode=R.Fn(()=>{const h=c,u=R.max(R.float(200),R.abs(R.cameraPosition.y.sub(h.y))),p=R.float(R.distance(R.cameraPosition,h)),g=R.log(u).div(R.log(s)),y=R.pow(s,R.floor(g)),_=y.mul(s),E=_.mul(s),v=l(y.mul(t)),C=l(_.mul(t)),x=l(E.mul(t)),O=u.sub(y).div(_.sub(y)),S=R.float(.3),T=R.max(O.sub(R.float(1)).add(S),R.float(0)).div(S),M=v.mul(R.pow(R.float(1).sub(R.min(p.div(a),R.float(1))),R.float(3))),L=R.float(.5),A=M.sub(T).mul(r),z=R.mix(A,M.mul(o).sub(T.mul(o.sub(r)).mul(L)),C),J=R.float(R.mix(z,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 fi extends w.Mesh{gridMaterial;constructor(e){const t=new mi(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 gi extends Zt{constructor(){super();const e=ze.remapClamp(ze.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=ze.vec4(e,e,e,1)}}const vn=`#include <common>
|
|
104
104
|
#include <batching_pars_vertex>
|
|
105
105
|
#include <uv_pars_vertex>
|
|
106
106
|
#include <color_pars_vertex>
|
|
@@ -130,7 +130,7 @@ void main() {
|
|
|
130
130
|
#include <logdepthbuf_vertex>
|
|
131
131
|
#include <clipping_planes_vertex>
|
|
132
132
|
#include <worldpos_vertex>
|
|
133
|
-
}`,
|
|
133
|
+
}`,_n=`
|
|
134
134
|
uniform float opacity;
|
|
135
135
|
#include <common>
|
|
136
136
|
#include <uv_pars_fragment>
|
|
@@ -140,4 +140,4 @@ void main() {
|
|
|
140
140
|
#include <clipping_planes_fragment>
|
|
141
141
|
if (opacity < 0.015) discard;
|
|
142
142
|
gl_FragColor = vec4(vec3(vUv, 0.0), opacity);
|
|
143
|
-
}`;class fi extends d.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:fn,fragmentShader:gn,transparent:!0})}}class gi extends ge.MeshBasicNodeMaterial{constructor(){super(),this.colorNode=T.vec4(T.uv(),0,1)}}class G extends d.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(I.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();ne(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 Ni.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=>{V.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(),ne(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 vn=new d.BoxGeometry,mt=new d.Vector2;class qe extends d.Object3D{curve=new d.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new d.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new d.Color(Z.lerp(.5,1,Math.random()),Z.lerp(.5,1,Math.random()),Z.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new d.LineBasicMaterial({color:s}),this.line=new d.Line(new d.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 d.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new d.Mesh(new d.SphereGeometry(1.5),new d.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new d.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([K(t.position.x,3),K(t.position.y,3),K(t.position.z,3)])}),Yt({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 d.Mesh(vn,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 d.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)}ne(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 d.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new d.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(!V.instance||!V.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=V.instance.currentWindow.current.getBoundingClientRect();mt.x=(e.clientX-s.x)/s.width*2-1,mt.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(mt,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 d.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]),V.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,ne(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 Ye=0;class vi extends d.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(I.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=L.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(I.ADD_SPLINE,this.onAddSpline),L.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 ${Ye+1}`,s=new qe(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),Ye++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new d.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 d.Vector3(n[0],n[1],n[2]))});const s=new qe(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 ${Ye+1}`,n=new qe(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 d.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),Ye++};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(V.instance){const o=new d.Raycaster;o.setFromCamera(new d.Vector2(n,a),this._camera);const c=o.intersectObjects(V.instance.helpersContainer.children,!0);for(let l=0;l<c.length;l++){const h=c[l];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 d.Vector3,r=Math.PI/2,o=this._camera,c=o.zoom,l=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,p=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,g=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 _=e,E=t;h||m?_*=-1:g&&(E*=-1);const v=s/2/c,C=n/2/c;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),l||h){const x=_*v+o.position.x,O=E*C+o.position.y;a.set(x,O,0)}else if(p||m){const x=_*v+o.position.z,O=E*C+o.position.y;a.set(0,O,x)}else if(g||y){const x=_*v+o.position.x,O=E*C+o.position.z;a.set(x,0,O)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Gt=["Single","Side by Side","Stacked","Quad"],_n="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",Cn="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==",yn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class V extends b.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new d.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new d.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new d.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;debugCamera;raycaster=new d.Raycaster;pointer=new d.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(I.ADD_RENDERER,this.setupRenderer),this.scene=new d.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 a={Vector2:d.Vector2,Vector3:d.Vector3,Vector4:d.Vector4,Quaternion:d.Quaternion,Matrix4:d.Matrix4,Spherical:d.Spherical,Box3:d.Box3,Sphere:d.Sphere,Raycaster:d.Raycaster};se.install({THREE:a}),this.setupScene(),this.setupTools();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 c=localStorage.getItem(this.expandedGridVisibility);c!==null&&(this.gridVisibility=c==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),V.instance=this}componentDidMount(){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(),L.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(fe,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(fe,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(fe,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(fe,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(fe,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(fe,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(fe,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(Xe,{title:"View",index:Gt.indexOf(this.state.mode),options:Gt,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),u.jsx(Xe,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),u.jsx(pt,{name:"cameraHelper",icon:_n,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)}}}),u.jsx(pt,{name:"lightHelper",icon:Cn,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)}}}),u.jsx(pt,{name:"gridHelper",icon:yn,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose(),this.rendererReady=!1;const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new d.WebGLRenderer({canvas:t,stencil:!1}),this.depthMaterial=new d.MeshDepthMaterial,this.normalsMaterial=new d.MeshNormalMaterial,this.uvMaterial=new fi,this.grid=new di,this.scene.add(this.grid),this.rendererReady=!0):s.type==="WebGPURenderer"&&(this.renderer=new ge.WebGPURenderer({canvas:t,stencil:!1}),this.grid=new pi,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=new mi,this.normalsMaterial=new ge.MeshNormalNodeMaterial,this.uvMaterial=new gi,s.type==="WebGPURenderer"&&this.renderer.init().then(()=>{this.rendererReady=!0})),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 d.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 d.Vector3(0,t,0)),e("Bottom",new d.Vector3(0,-t,0)),e("Left",new d.Vector3(-t,0,0)),e("Right",new d.Vector3(t,0,0)),e("Front",new d.Vector3(0,0,t)),e("Back",new d.Vector3(0,0,-t)),e("Orthographic",new d.Vector3(t,t,t)),e("UI",new d.Vector3),this.debugCamera=new d.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")),L.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){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:(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 vi(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:I.CLEAR_OBJECT}),L.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:I.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:I.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.renderer&&this.rendererReady&&this.renderer?.clear(),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(I.ADD_SCENE,this.addScene),this.three.addEventListener(I.SET_SCENE,this.sceneUpdate),this.three.addEventListener(I.REMOVE_SCENE,this.removeScene),this.three.addEventListener(I.ADD_CAMERA,this.addCamera),this.three.addEventListener(I.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(I.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(I.ADD_SCENE,this.addScene),this.three.removeEventListener(I.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(I.ADD_CAMERA,this.addCamera),this.three.removeEventListener(I.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(I.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 d.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 d.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=new t;s.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}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))};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{ne(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 d.CameraHelper(a);r.visible=this.cameraVisibility,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 d.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Z.mapLinear(s,0,t.x,-1,1),this.pointer.y=Z.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=Z.mapLinear(s,0,a,-1,1):this.pointer.x=Z.mapLinear(s,a,t.x,-1,1)},c=()=>{n<r?this.pointer.y=Z.mapLinear(n,0,r,1,-1):this.pointer.y=Z.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),c();break;case"Side by Side":o();break;case"Stacked":c(),c();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const l=this.raycaster.intersectObjects(this.currentScene.children);l.length>0&&this.interactionHelper.position.copy(l[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new d.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 se(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof d.Mesh||this.selectedItem instanceof d.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 se(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 se(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 se(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 se(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 se(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Z.degToRad(45),Z.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),et.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 d.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 d.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 Ui.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 d.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 d.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 Li.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,n=new d.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=Ae(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}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 ge.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 ge.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),c=this.height-o;let l=0,h=e?0:this.height-o;l=0,this.drawTo(l,h,r,o,this.tlCam,t),l=r,this.drawTo(l,h,r,o,this.trCam,s),h=e?c:0,l=0,this.scene.overrideMaterial=n,this.drawTo(l,h,r,o,this.blCam,n),l=r,this.drawTo(l,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 et extends b.Component{static instance;matrix=new d.Matrix4;position=new d.Vector3;rotation=new d.Euler;scale=new d.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)),et.instance=this}update(){if(V.instance){const e=V.instance.selectedItem;if(e===void 0)return;this.position.x=K(e.position.x,3),this.position.y=K(e.position.y,3),this.position.z=K(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=K(e.scale.x,3),this.scale.y=K(e.scale.y,3),this.scale.z=K(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(X,{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);B(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function Wt(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 bn(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 c=i.lightInfo[o];c!==void 0&&(c.isColor!==void 0?r.push({title:Wt(o),prop:o,type:"color",value:c,onChange:(l,h)=>{const p=new d.Color(h);e.updateObject(i.uuid,l,p);const m=e.getScene(i.uuid);if(m!==null){const g=m.getObjectByProperty("uuid",i.uuid);B(g,l,p)}}}):r.push({title:Wt(o),prop:o,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(l,h)=>{e.updateObject(i.uuid,l,h);const p=e.getScene(i.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",i.uuid);B(m,l,h)}}}))}return u.jsx(X,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function En(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=[],c=[];let l=0;e.animations.forEach(m=>{l=Math.max(l,m.duration),m.duration>0&&c.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:c});let h;const p=t.getScene(e.uuid);if(p!==null){const m=p.getObjectByProperty("uuid",e.uuid);if(m!==void 0){const g=m.mixer;if(g!==void 0){const _=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(E,v)=>{g.timeScale=v,t.updateObject(e.uuid,"mixer.timeScale",v)}}];_.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:_}),h=new d.SkeletonHelper(m),V.instance?.scene.add(h)}}}return b.useEffect(()=>()=>{h!==void 0&&ne(h)},[]),u.jsx(X,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:m=>{r(m)}})}const ft={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 _i(i){const[e,t]=b.useState(ft);b.useEffect(()=>{function r(c){t(c.value)}function o(){t(ft)}return i.three.addEventListener(I.CLEAR_OBJECT,o),i.three.addEventListener(I.SET_SCENE,o),i.three.addEventListener(I.SET_OBJECT,r),()=>{i.three.removeEventListener(I.CLEAR_OBJECT,o),i.three.removeEventListener(I.SET_SCENE,o),i.three.removeEventListener(I.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 a&&console.log(s,e),u.jsx(Me,{three:i.three,label:"Inspector",button:e.uuid.length>0?u.jsx("button",{className:"remove",onClick:()=>{G.instance.remove(e.name),t(ft)}}):void 0,children:u.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx($e,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),u.jsx($e,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),u.jsx($e,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(et,{object:e,three:i.three}),n?u.jsx(En,{object:e,three:i.three}):null,s.search("camera")>-1?cn(e,i.three):null,s.search("light")>-1?bn(e,i.three):null,a?an(e,i.three):null]})]})})},"Inspector")}class Sn extends b.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=d.SRGBColorSpace;localClippingEnabled=!1;clearColor=new d.Color(0);clearAlpha=1;toneMapping=d.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),V.instance){const n=V.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n instanceof d.WebGLRenderer&&(this.localClippingEnabled=n.localClippingEnabled,n.getClearColor(this.clearColor)))}this.props.three.addEventListener(I.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(I.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,d.LinearSRGBColorSpace),d.ColorManagement.enabled=t.colorManagement,V.instance){const s=V.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s instanceof d.WebGLRenderer&&(s.localClippingEnabled=this.localClippingEnabled),s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(V.instance){const t=V.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t instanceof d.WebGLRenderer&&(t.localClippingEnabled=this.localClippingEnabled),t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:d.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return u.jsx(X,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Color Management",value:d.ColorManagement.enabled,onChange:(t,s)=>{d.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:d.NoColorSpace},{title:"SRB Color Space",value:d.SRGBColorSpace},{title:"Linear SRB Color Space",value:d.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:d.NoToneMapping},{title:"Linear ",value:d.LinearToneMapping},{title:"Reinhard",value:d.ReinhardToneMapping},{title:"Cineon ",value:d.CineonToneMapping},{title:"ACES Filmic",value:d.ACESFilmicToneMapping},{title:"AgX",value:d.AgXToneMapping},{title:"Neutral",value:d.NeutralToneMapping},{title:"Custom",value:d.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function Ci(i){const[e]=b.useState([]),[t]=b.useState([]),[s,n]=b.useState(0),a=l=>{const h=l.value;e.push(h),t.push(u.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:u.jsx(Ze,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=l=>{const h=l.value;for(let p=0;p<e.length;p++)if(h.uuid===e[p].uuid){e[p]=h,t[p]=u.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[p].props.open,visible:t[p].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:u.jsx(Ze,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=l=>{const h=l.value;for(let p=0;p<e.length;p++)if(h.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}},c=l=>{const h=l.value.name;for(let p=0;p<e.length;p++){const m=e[p],g=m.name===h;t[p]=u.jsx(Me,{three:i.three,label:`Scene: ${m.name}`,scene:m,open:g,visible:g,onRefresh:()=>{i.three.refreshScene(m.name)},children:u.jsx(Ze,{child:m,scene:m,three:i.three})},m.name)}n(Date.now())};return b.useEffect(()=>(i.three.addEventListener(I.ADD_SCENE,a),i.three.addEventListener(I.SET_SCENE,c),i.three.addEventListener(I.REFRESH_SCENE,r),i.three.addEventListener(I.REMOVE_SCENE,o),()=>{i.three.removeEventListener(I.ADD_SCENE,a),i.three.removeEventListener(I.SET_SCENE,c),i.three.removeEventListener(I.REFRESH_SCENE,r),i.three.removeEventListener(I.REMOVE_SCENE,o)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},s),u.jsx(_i,{three:i.three}),u.jsx(Sn,{three:i.three}),u.jsx(L,{three:i.three})]})}function yi(i){return u.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[u.jsx("div",{className:"header",children:i.header}),i.children,u.jsx("div",{className:"footer",children:i.footer})]})}function xn(i){return u.jsx(yi,{children:u.jsxs(u.Fragment,{children:[u.jsx(V,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),u.jsx(Ci,{three:i.three})]})})}exports.Accordion=Me;exports.Application=Ds;exports.BaseRemote=Et;exports.ChildObject=xt;exports.ContainerObject=Ze;exports.DepthNodeMaterial=mi;exports.Draggable=ri;exports.DraggableItem=ni;exports.Dropdown=ai;exports.DropdownItem=oi;exports.Editor=yi;exports.ElementProxy=As;exports.ElementProxyReceiver=ii;exports.ExportTexture=oe;exports.InfiniteGridHelper=di;exports.InfiniteGridHelperGPU=pi;exports.InfiniteGridMaterial=hi;exports.InfiniteGridNodeMaterial=ui;exports.Inspector=_i;exports.MultiView=V;exports.NavButton=St;exports.ProxyManager=Rs;exports.RemoteTheatre=Us;exports.RemoteThree=Hs;exports.SidePanel=Ci;exports.Spline=qe;exports.SplineEditor=vi;exports.ThreeEditor=xn;exports.Transform=G;exports.UVMaterial=fi;exports.UVNodeMaterial=gi;exports.WebworkerEventHandlers=Ts;exports.anchorGeometry=ei;exports.anchorGeometryTL=os;exports.animateObjectMaterial=ss;exports.animateObjectTransform=ts;exports.applyObjectMaterial=Jt;exports.capitalize=He;exports.clamp=he;exports.clearComposerGroups=_s;exports.colorToHex=gt;exports.copyToClipboard=Yt;exports.createMask=ds;exports.cubicBezier=Xi;exports.customizeTheatreElements=es;exports.damp=Wi;exports.defaultTheatreCallback=ki;exports.detectMaxFrameRate=qt;exports.detectSettings=Kt;exports.dispose=ne;exports.disposeMaterial=yt;exports.disposeTexture=vt;exports.distance=Gi;exports.generateCubemap=Cs;exports.getAngle=Yi;exports.getObjectMaterialObject=Qt;exports.getObjectMaterialProps=Xt;exports.hierarchyUUID=Te;exports.inspectComposer=vs;exports.inspectComposerPass=ti;exports.isColor=Zt;exports.map=Vi;exports.mix=Ae;exports.noop=ze;exports.normalize=Ke;exports.orthoCamera=ns;exports.parseModelLite=rs;exports.randomID=W;exports.renderToTexture=as;exports.resetThreeObjects=Ne;exports.rgbaToHex=Qi;exports.roundTo=K;exports.setMaterialBlendAdd=ms;exports.setMaterialBlendMultiply=fs;exports.setMaterialBlendNormal=ps;exports.setMaterialBlendScreen=gs;exports.supportsOffscreenCanvas=hs;exports.triangle=Qe;exports.updateCameraOrtho=ls;exports.updateCameraOrtho16x9=cs;exports.useMask=us;exports.useStudio=Ji;
|
|
143
|
+
}`;class vi extends m.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:vn,fragmentShader:_n,transparent:!0})}}class _i extends Zt{constructor(){super(),this.colorNode=ze.vec4(ze.uv(),0,1)}}class W extends m.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(U.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();re(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 Fi.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:W.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:W.DRAG_END})}),t.addEventListener("dragging-changed",n=>{G.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(),re(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 W._instance||(W._instance=new W),W._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),W.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)])}),$t({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 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 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)}re(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(!G.instance||!G.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=G.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 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 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=W.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]),G.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,re(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 Ze=0;class Ci extends m.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(U.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=N.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(U.ADD_SPLINE,this.onAddSpline),N.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 ${Ze+1}`,s=new Ke(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),Ze++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new m.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 m.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 ${Ze+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 a=[];t.points.forEach(r=>{a.push(new m.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),Ze++};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(G.instance){const o=new m.Raycaster;o.setFromCamera(new m.Vector2(n,a),this._camera);const c=o.intersectObjects(G.instance.helpersContainer.children,!0);for(let l=0;l<c.length;l++){const h=c[l];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 m.Vector3,r=Math.PI/2,o=this._camera,c=o.zoom,l=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,p=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,g=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 _=e,E=t;h||p?_*=-1:g&&(E*=-1);const v=s/2/c,C=n/2/c;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),l||h){const x=_*v+o.position.x,O=E*C+o.position.y;a.set(x,O,0)}else if(u||p){const x=_*v+o.position.z,O=E*C+o.position.y;a.set(0,O,x)}else if(g||y){const x=_*v+o.position.x,O=E*C+o.position.z;a.set(x,0,O)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Wt=["Single","Side by Side","Stacked","Quad"],yn="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",bn="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==",En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class G 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;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(U.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 a={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};ne.install({THREE:a}),this.setupScene(),this.setupTools();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 c=localStorage.getItem(this.expandedGridVisibility);c!==null&&(this.gridVisibility=c==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),G.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),W.instance.setApp(this.props.three),W.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(),N.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:Wt.indexOf(this.state.mode),options:Wt,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:yn,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:bn,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:En,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 m.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof w.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new m.WebGLRenderer({canvas:s,stencil:!1}),this.depthMaterial=new w.MeshDepthMaterial,this.normalsMaterial=new w.MeshNormalMaterial,this.uvMaterial=new vi,this.grid=new pi,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new w.WebGPURenderer({canvas:s,stencil:!1}),this.grid=new fi,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=new gi,this.normalsMaterial=new w.MeshNormalNodeMaterial,this.uvMaterial=new _i,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 w.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 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")),N.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":W.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 Ci(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:U.CLEAR_OBJECT}),N.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,W.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:U.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:U.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.renderer&&this.rendererReady&&this.renderer?.clear(),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(U.ADD_SCENE,this.addScene),this.three.addEventListener(U.SET_SCENE,this.sceneUpdate),this.three.addEventListener(U.REMOVE_SCENE,this.removeScene),this.three.addEventListener(U.ADD_CAMERA,this.addCamera),this.three.addEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(U.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(U.ADD_SCENE,this.addScene),this.three.removeEventListener(U.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(U.ADD_CAMERA,this.addCamera),this.three.removeEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(U.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 w.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 w.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=new t;s.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}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))};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{re(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 w.CameraHelper(a);r.visible=this.cameraVisibility,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 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 a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=$.mapLinear(s,0,a,-1,1):this.pointer.x=$.mapLinear(s,a,t.x,-1,1)},c=()=>{n<r?this.pointer.y=$.mapLinear(n,0,r,1,-1):this.pointer.y=$.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),c();break;case"Side by Side":o();break;case"Stacked":c(),c();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const l=this.raycaster.intersectObjects(this.currentScene.children);l.length>0&&this.interactionHelper.position.copy(l[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 ne(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 ne(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 ne(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 ne(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 ne(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 ne(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),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=W.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 ki.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),W.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,n=new w.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=Ae(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}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 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 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 w.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),c=this.height-o;let l=0,h=e?0:this.height-o;l=0,this.drawTo(l,h,r,o,this.tlCam,t),l=r,this.drawTo(l,h,r,o,this.trCam,s),h=e?c:0,l=0,this.scene.overrideMaterial=n,this.drawTo(l,h,r,o,this.blCam,n),l=r,this.drawTo(l,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 tt extends b.Component{static instance;matrix=new m.Matrix4;position=new m.Vector3;rotation=new m.Euler;scale=new m.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(G.instance){const e=G.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(Q,{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);V(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function Yt(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 Sn(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 c=i.lightInfo[o];c!==void 0&&(c.isColor!==void 0?r.push({title:Yt(o),prop:o,type:"color",value:c,onChange:(l,h)=>{const u=new m.Color(h);e.updateObject(i.uuid,l,u);const p=e.getScene(i.uuid);if(p!==null){const g=p.getObjectByProperty("uuid",i.uuid);V(g,l,u)}}}):r.push({title:Yt(o),prop:o,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(l,h)=>{e.updateObject(i.uuid,l,h);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);V(p,l,h)}}}))}return d.jsx(Q,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function xn(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(p){localStorage.setItem(s(),p?"open":"closed")}const o=[],c=[];let l=0;e.animations.forEach(p=>{l=Math.max(l,p.duration),p.duration>0&&c.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:c});let h;const u=t.getScene(e.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",e.uuid);if(p!==void 0){const g=p.mixer;if(g!==void 0){const _=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(E,v)=>{g.timeScale=v,t.updateObject(e.uuid,"mixer.timeScale",v)}}];_.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:_}),h=new m.SkeletonHelper(p),G.instance?.scene.add(h)}}}return b.useEffect(()=>()=>{h!==void 0&&re(h)},[]),d.jsx(Q,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:p=>{r(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 yi(i){const[e,t]=b.useState(gt);b.useEffect(()=>{function r(c){t(c.value)}function o(){t(gt)}return i.three.addEventListener(U.CLEAR_OBJECT,o),i.three.addEventListener(U.SET_SCENE,o),i.three.addEventListener(U.SET_OBJECT,r),()=>{i.three.removeEventListener(U.CLEAR_OBJECT,o),i.three.removeEventListener(U.SET_SCENE,o),i.three.removeEventListener(U.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 d.jsx(Me,{three:i.three,label:"Inspector",button:e.uuid.length>0?d.jsx("button",{className:"remove",onClick:()=>{W.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(qe,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),d.jsx(qe,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),d.jsx(qe,{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(xn,{object:e,three:i.three}):null,s.search("camera")>-1?dn(e,i.three):null,s.search("light")>-1?Sn(e,i.three):null,a?ln(e,i.three):null]})]})})},"Inspector")}class On extends b.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=m.SRGBColorSpace;localClippingEnabled=!1;clearColor=new m.Color(0);clearAlpha=1;toneMapping=m.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),G.instance){const n=G.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n instanceof m.WebGLRenderer&&(this.localClippingEnabled=n.localClippingEnabled,n.getClearColor(this.clearColor)))}this.props.three.addEventListener(U.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(U.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,m.LinearSRGBColorSpace),m.ColorManagement.enabled=t.colorManagement,G.instance){const s=G.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s instanceof m.WebGLRenderer&&(s.localClippingEnabled=this.localClippingEnabled),s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(G.instance){const t=G.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t instanceof m.WebGLRenderer&&(t.localClippingEnabled=this.localClippingEnabled),t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:m.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return d.jsx(Q,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Color Management",value:m.ColorManagement.enabled,onChange:(t,s)=>{m.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:m.NoColorSpace},{title:"SRB Color Space",value:m.SRGBColorSpace},{title:"Linear SRB Color Space",value:m.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:m.NoToneMapping},{title:"Linear ",value:m.LinearToneMapping},{title:"Reinhard",value:m.ReinhardToneMapping},{title:"Cineon ",value:m.CineonToneMapping},{title:"ACES Filmic",value:m.ACESFilmicToneMapping},{title:"AgX",value:m.AgXToneMapping},{title:"Neutral",value:m.NeutralToneMapping},{title:"Custom",value:m.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function bi(i){const[e]=b.useState([]),[t]=b.useState([]),[s,n]=b.useState(0),a=l=>{const h=l.value;e.push(h),t.push(d.jsx(Me,{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())},r=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=d.jsx(Me,{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=l=>{const h=l.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}},c=l=>{const h=l.value.name;for(let u=0;u<e.length;u++){const p=e[u],g=p.name===h;t[u]=d.jsx(Me,{three:i.three,label:`Scene: ${p.name}`,scene:p,open:g,visible:g,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(U.ADD_SCENE,a),i.three.addEventListener(U.SET_SCENE,c),i.three.addEventListener(U.REFRESH_SCENE,r),i.three.addEventListener(U.REMOVE_SCENE,o),()=>{i.three.removeEventListener(U.ADD_SCENE,a),i.three.removeEventListener(U.SET_SCENE,c),i.three.removeEventListener(U.REFRESH_SCENE,r),i.three.removeEventListener(U.REMOVE_SCENE,o)}),[]),d.jsxs("div",{id:"SidePanel",children:[d.jsx("div",{className:"scenes",children:t},s),d.jsx(yi,{three:i.three}),d.jsx(On,{three:i.three}),d.jsx(N,{three:i.three})]})}function Ei(i){return d.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[d.jsx("div",{className:"header",children:i.header}),i.children,d.jsx("div",{className:"footer",children:i.footer})]})}function wn(i){return d.jsx(Ei,{children:d.jsxs(d.Fragment,{children:[d.jsx(G,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),d.jsx(bi,{three:i.three})]})})}exports.Accordion=Me;exports.Application=Is;exports.BaseRemote=St;exports.ChildObject=Ot;exports.ContainerObject=$e;exports.DepthNodeMaterial=gi;exports.Draggable=oi;exports.DraggableItem=ai;exports.Dropdown=li;exports.DropdownItem=ci;exports.Editor=Ei;exports.ElementProxy=Ps;exports.ElementProxyReceiver=ni;exports.ExportTexture=le;exports.InfiniteGridHelper=pi;exports.InfiniteGridHelperGPU=fi;exports.InfiniteGridMaterial=ui;exports.InfiniteGridNodeMaterial=mi;exports.Inspector=yi;exports.MultiView=G;exports.NavButton=xt;exports.ProxyManager=Ds;exports.RemoteTheatre=Ns;exports.RemoteThree=Bs;exports.SidePanel=bi;exports.Spline=Ke;exports.SplineEditor=Ci;exports.ThreeEditor=wn;exports.Transform=W;exports.UVMaterial=vi;exports.UVNodeMaterial=_i;exports.WebworkerEventHandlers=As;exports.anchorGeometry=ii;exports.anchorGeometryTL=cs;exports.animateObjectMaterial=rs;exports.animateObjectTransform=ss;exports.applyObjectMaterial=ti;exports.capitalize=je;exports.clamp=de;exports.clearComposerGroups=ys;exports.colorToHex=vt;exports.copyToClipboard=$t;exports.createMask=ps;exports.cubicBezier=Ji;exports.customizeTheatreElements=is;exports.damp=Zi;exports.defaultTheatreCallback=zi;exports.detectMaxFrameRate=Xt;exports.detectSettings=Qt;exports.dispose=re;exports.disposeMaterial=bt;exports.disposeTexture=_t;exports.distance=Yi;exports.generateCubemap=bs;exports.getAngle=$i;exports.getObjectMaterialObject=ei;exports.getObjectMaterialProps=Jt;exports.hierarchyUUID=Te;exports.inspectComposer=Cs;exports.inspectComposerPass=si;exports.isColor=qt;exports.map=Wi;exports.mix=Ae;exports.noop=He;exports.normalize=Xe;exports.orthoCamera=as;exports.parseModelLite=os;exports.randomID=Y;exports.renderToTexture=ls;exports.resetThreeObjects=Ne;exports.rgbaToHex=es;exports.roundTo=X;exports.setMaterialBlendAdd=gs;exports.setMaterialBlendMultiply=vs;exports.setMaterialBlendNormal=fs;exports.setMaterialBlendScreen=_s;exports.supportsOffscreenCanvas=us;exports.triangle=Je;exports.updateCameraOrtho=hs;exports.updateCameraOrtho16x9=ds;exports.useMask=ms;exports.useStudio=ts;
|