@tomorrowevening/hermes 0.1.40 → 0.1.41

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.
@@ -1,4 +1,4 @@
1
- "use strict";var Ct=Object.create;var _e=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var wt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var Et=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xt(e))!Mt.call(i,n)&&n!==t&&_e(i,n,{get:()=>e[n],enumerable:!(s=St(e,n))||s.enumerable});return i};var At=(i,e,t)=>(t=i!=null?Ct(wt(i)):{},Et(e||!i||!i.__esModule?_e(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ot=require("detect-gpu"),x=require("@tomorrowevening/theatre-core"),v=require("react"),p=require("three"),b=require("three/webgpu"),c=require("react/jsx-runtime"),L=require("three/src/math/MathUtils.js"),Rt=require("three/examples/jsm/helpers/RectAreaLightHelper.js"),Tt=require("three/examples/jsm/controls/OrbitControls.js"),q=require("camera-controls"),C=require("three/tsl"),$e=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),ae=require("three/src/nodes/TSL.js"),It=require("three/examples/jsm/controls/TransformControls.js"),oe=()=>{},Pt=()=>{};function ce(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function Ke(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function k(){return Math.round(Math.random()*1e6).toString()}function Ye(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function Ee(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=l=>{const d=l.toString(16);return d.length===1?"0"+d:d},a=n(e),r=n(t),o=n(s);return"#"+a+r+o}function Je(i){let e=0;const t=performance.now();function s(){e++;const n=performance.now();if(n-t>=100){const a=e/((n-t)/1e3),r=Math.round(a/30)*30;i(r)}else requestAnimationFrame(s)}requestAnimationFrame(s)}function Xe(i=!1,e=!1){return new Promise(t=>{Ot.getGPUTier().then(s=>{let n=!1;const a=document.createElement("canvas"),r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(n="transferControlToOffscreen"in a,r){const l=navigator.userAgent.match(/version\/(\d+)/i);n=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:n,supportWebGPU:!!navigator.gpu,quality:"Low",dev:i,editor:e};s.tier===3?o.quality="High":s.tier===2&&(o.quality="Medium"),Je(l=>{o.fps=l,t(o)})})})}const kt=`
1
+ "use strict";var yt=Object.create;var Ne=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var Mt=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of St(e))!wt.call(i,n)&&n!==t&&Ne(i,n,{get:()=>e[n],enumerable:!(s=Ct(e,n))||s.enumerable});return i};var Et=(i,e,t)=>(t=i!=null?yt(xt(i)):{},Mt(e||!i||!i.__esModule?Ne(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const At=require("detect-gpu"),x=require("@tomorrowevening/theatre-core"),v=require("react"),p=require("three"),b=require("three/webgpu"),c=require("react/jsx-runtime"),U=require("three/src/math/MathUtils.js"),Ot=require("three/examples/jsm/helpers/RectAreaLightHelper.js"),Rt=require("three/examples/jsm/controls/OrbitControls.js"),z=require("camera-controls"),C=require("three/tsl"),ze=require("three/src/materials/nodes/MeshBasicNodeMaterial.js"),re=require("three/src/nodes/TSL.js"),It=require("three/examples/jsm/controls/TransformControls.js"),ae=()=>{},Tt=()=>{};function oe(i){return i.substring(0,1).toUpperCase()+i.substring(1)}function qe(i){const e=JSON.stringify(i);return navigator.clipboard.writeText(e),e}function k(){return Math.round(Math.random()*1e6).toString()}function $e(i){return i.r!==void 0&&i.g!==void 0&&i.b!==void 0}function we(i){const e=Math.round(i.r*255),t=Math.round(i.g*255),s=Math.round(i.b*255),n=l=>{const d=l.toString(16);return d.length===1?"0"+d:d},a=n(e),r=n(t),o=n(s);return"#"+a+r+o}function Ke(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 Ye(i=!1,e=!1){return new Promise(t=>{At.getGPUTier().then(s=>{let n=!1;const a=document.createElement("canvas"),r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(n="transferControlToOffscreen"in a,r){const l=navigator.userAgent.match(/version\/(\d+)/i);n=(l?parseInt(l[1]):0)>=17}const o={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:s.isMobile!==void 0?s.isMobile:!1,supportOffScreenCanvas:n,supportWebGPU:!!navigator.gpu,quality:"Low",dev:i,editor:e};s.tier===3?o.quality="High":s.tier===2&&(o.quality="Medium"),Ke(l=>{o.fps=l,t(o)})})})}const Pt=`
2
2
  self.onmessage = async ({ data }) => {
3
3
  if (data.type !== 'encode') return;
4
4
  const { bitmap, index, format, quality } = data;
@@ -10,10 +10,10 @@ self.onmessage = async ({ data }) => {
10
10
  const blob = await canvas.convertToBlob({ type: mime, quality });
11
11
  self.postMessage({ type: 'encoded', index, blob });
12
12
  };
13
- `;class Dt{worker;source;transfer;ctx;opts;_capturing=!1;_captured=0;_encoded=0;_pending=0;_lastFrameTime=-1/0;frames=new Map;constructor(e,t={}){this.source=e,this.transfer=document.createElement("canvas"),this.transfer.width=e.width,this.transfer.height=e.height,this.ctx=this.transfer.getContext("2d",{willReadFrequently:!0}),this.opts={format:t.format??"png",quality:t.quality??.92,prefix:t.prefix??"frame",padLength:t.padLength??5,maxQueue:t.maxQueue??32,fps:t.fps??30,onProgress:t.onProgress??(()=>{}),onError:t.onError??(a=>console.error("[ImageSequenceCapturer]",a))};const s=new Blob([kt],{type:"application/javascript"}),n=URL.createObjectURL(s);this.worker=new Worker(n),URL.revokeObjectURL(n),this.worker.onmessage=({data:a})=>{a.type==="encoded"&&(this.frames.set(a.index,a.blob),this._pending--,this._encoded++,this.opts.onProgress(this._captured,this._encoded))},this.worker.onerror=a=>this.opts.onError(new Error(a.message))}get isCapturing(){return this._capturing}get framesCaptured(){return this._captured}get framesEncoded(){return this._encoded}get isIdle(){return this._pending===0}resize(){this.transfer.width=this.source.width,this.transfer.height=this.source.height}start(){this._capturing=!0,this._captured=0,this._encoded=0,this._pending=0,this._lastFrameTime=-1/0,this.frames.clear()}stop(){this._capturing=!1}captureFrame(){if(!this._capturing||this._pending>=this.opts.maxQueue)return!1;const e=performance.now();if(e-this._lastFrameTime<1e3/this.opts.fps)return!1;this._lastFrameTime=e,this.ctx.drawImage(this.source,0,0);const t=this._captured++;return this._pending++,createImageBitmap(this.transfer).then(s=>{this.worker.postMessage({type:"encode",bitmap:s,index:t,format:this.opts.format,quality:this.opts.quality},[s])}).catch(s=>{this._pending--,this.opts.onError(s)}),!0}flush(){return new Promise(e=>{const t=()=>this._pending===0?e():setTimeout(t,16);t()})}async download(){await this.flush();const e=this.opts.format==="jpeg"?"jpg":this.opts.format,s=[...this.frames.entries()].sort(([n],[a])=>n-a).map(([n,a])=>({name:`${this.opts.prefix}_${String(n).padStart(this.opts.padLength,"0")}.${e}`,blob:a}));if("showDirectoryPicker"in window)try{const n=await window.showDirectoryPicker({mode:"readwrite",startIn:"downloads"});await Promise.all(s.map(async({name:a,blob:r})=>{const l=await(await n.getFileHandle(a,{create:!0})).createWritable();await l.write(r),await l.close()}));return}catch(n){if(n.name==="AbortError")return}for(const{name:n,blob:a}of s){const r=URL.createObjectURL(a);Object.assign(document.createElement("a"),{href:r,download:n}).click(),URL.revokeObjectURL(r),await new Promise(l=>setTimeout(l,50))}}reset(){this._capturing=!1,this._captured=0,this._encoded=0,this._pending=0,this.frames.clear()}destroy(){this.reset(),this.worker.terminate()}}function z(i,e,t){return Math.min(e,Math.max(i,t))}function fe(i,e,t){return(t-i)/(e-i)}function ie(i,e,t){return i*(1-t)+e*t}function jt(i,e,t,s,n){return ie(t,s,fe(i,e,n))}function Nt(i,e){const t=i-e;return Math.sqrt(t*t)}function Lt(i,e,t,s){return ie(i,e,1-Math.exp(-t*s))}function _(i,e=1){return Number(i.toFixed(e))}function _t(i,e,t,s){return Math.atan2(s-e,t-i)}function Ut(i,e,t,s){return i===e&&t===s}function Gt(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function Ft(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function Bt(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function Vt(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(Ut(e,t,s,n))return i;const a=0,r=0,o=e,l=t,d=s,h=n,u=1,m=1,f=u-3*d+3*o-a,y=3*d-6*o+3*a,g=3*o-3*a,S=a,O=m-3*h+3*l-r,M=3*h-6*l+3*r,T=3*l-3*r,R=r;let D=i;for(let V=0;V<5;V++){const H=Ft(D,f,y,g,S);let F=Gt(D,f,y,g);F===1/0&&(F=i),D-=(H-i)*F,D=Math.min(Math.max(D,0),1)}return Bt(D,O,M,T,R)}const de=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function Ht({r:i,g:e,b:t,a:s=1}){const n=`#${de(i)}${de(e)}${de(t)}`;return s<1?`${n}${de(s)}`:n}let Y;function Wt(){const[i,e]=v.useState(Y);return v.useEffect(()=>{Y||import("@tomorrowevening/theatre-studio").then(t=>{Y=t.default,Y.initialize(),Y.ui.hide(),e(Y)})},[]),i}async function zt(){for(;!document.getElementById("theatrejs-studio-root");)await new Promise(s=>setTimeout(s,100));const i=document.getElementById("theatrejs-studio-root");if(i===null||i.shadowRoot===null)return;const e=i.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t!==null){try{const n=t.children[1].children[1];n.parentElement?.removeChild(n)}catch{}try{const s=t.children[3];s.style.top="0",s.style.right="300px"}catch{}}}function qt(i,e,t,s){s.sheetObject(i,e,{transform:{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},visible:t.visible}},n=>{const a=n.transform;t.position.copy(a.position),t.rotation.copy(a.rotation),t.scale.copy(a.scale),t.visible=a.visible})}const $t=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function Ue(i){const e=typeof i;if(i===null||i.isTexture)return"texture";if(e==="boolean")return"boolean";if(e==="number")return"number";if(e==="string")return"string";if(e==="object"){if(i.isColor)return"color";if(i.isVector2)return"vector2";if(i.isVector3)return"vector3";if(i.isVector4)return"vector4";if(i.isMatrix2)return"matrix2";if(i.isMatrix3)return"matrix3";if(i.isMatrix4)return"matrix4";if(i.isEuler)return"euler";if(Array.isArray(i))return"array"}return"object"}function Qe(i){const e=[];for(const s in i){const n=$t.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||a))if(s==="uniforms"){const o=i.uniforms;for(const l in o){const d=o[l].value,h=Ue(d);h==="array"||h==="object"||e.push({name:`uniforms.${l}.value`,type:h,value:d})}}else{const o=Ue(i[s]);e.push({name:s,type:o,value:i[s]})}}return e.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function Ze(i){const e={},t={nudgeMultiplier:.01};return i.forEach(s=>{let n=s.value;switch(s.type){case"color":n=x.types.rgba({r:n.r,g:n.g,b:n.b,a:1});break;case"number":n=x.types.number(n,t);break;case"euler":case"vector3":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t)};break;case"vector2":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t)};break;case"vector4":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t),w:x.types.number(n.w,t)};break;case"matrix2":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t)};break;case"matrix3":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t)};break;case"matrix4":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t),9:x.types.number(n.elements[9],t),10:x.types.number(n.elements[10],t),11:x.types.number(n.elements[11],t),12:x.types.number(n.elements[12],t),13:x.types.number(n.elements[13],t),14:x.types.number(n.elements[14],t),15:x.types.number(n.elements[15],t)};break}if(s.name.includes(".")){const a=s.name.split(".");let r=e;for(let o=0;o<a.length-1;o++){const l=a[o];r[l]||(r[l]={}),r=r[l]}r[a[a.length-1]]=n}else e[s.name]=n}),e}function et(i,e,t){e.forEach(s=>{if(i[s.name]!==void 0)switch(s.type){case"boolean":case"number":i[s.name]=t.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":i[s.name].copy(t.material[s.name]);break}})}function Kt(i,e,t,s){if(!t.isMaterial)return;const n=Qe(t),a=Ze(n);s.sheetObject(i,e,{material:a},r=>{et(t,n,r)})}const ve=new p.BufferGeometry;ve.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));ve.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3));ve.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const Yt=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),Ae=i=>{i?.dispose()},Te=i=>{if(i)if(Array.isArray(i))i.forEach(e=>Te(e));else{for(const e in i){const t=i[e];t!==null&&t instanceof p.Texture&&Ae(t)}if(i.isShaderMaterial===!0){const e=i;for(const t in e.uniforms){const s=e.uniforms[t];s.value!==null&&s.value instanceof p.Texture&&Ae(s.value)}}i.dispose()}},U=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):U(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),Te(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const ne=()=>{exports.totalThreeObjects=0},ee=i=>{if(!i)return;let e=i.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),i.parent!==null&&i.parent.uuid.length>0&&(e=`${i.parent.uuid}.${e}`),i.uuid=e,i.isMesh!==void 0){const t=i;if(Array.isArray(t.material))t.material.forEach((s,n)=>{s.uuid=`${e}.material.${n}`});else{const s=t.material;s.uuid=`${e}.material`}}i.children.forEach(t=>ee(t))};class B{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),s=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/n.width,r=this.renderToCanvas(e);this.context.drawImage(r,0,0,n.width*a,n.height*a)}}return e.repeat.copy(t),e.offset.copy(s),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const t=new p.BufferGeometry;t.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new p.Mesh(t,this.material);this.scene.add(s)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,s=e.colorSpace;this.renderer.outputColorSpace=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function Jt(i){return new Promise(e=>{const t=new p.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new p.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(l=>p.AnimationClip.parse(l));n.clipAction(r[0]).play(),n.getRoot().animations=i.animations,n.getRoot().mixer=n}const a=[];i.cameras&&i.cameras.length>0&&i.cameras.forEach(r=>{const o=t.parse(r);a.push(o)}),e({animations:i.animations,model:s,mixer:n,cameras:a})})})}const Xt=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function tt(i,e,t,s){i.applyMatrix4(new p.Matrix4().makeTranslation(e,-t,-s))}function Qt(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;tt(i,t,s,0)}function Zt(i,e,t){i.left=e/-2,i.right=e/2,i.top=t/2,i.bottom=t/-2,i.position.x=e/2,i.position.y=t/-2,i.updateProjectionMatrix()}function ei(i,e,t){const s=1.7777777777777777,n=e/t;let a=e,r=t;n>s?a=t*s:r=e/s,i.left=a/-2,i.right=a/2,i.top=r/2,i.bottom=r/-2,i.updateProjectionMatrix()}function ti(){let e="transferControlToOffscreen"in document.createElement("canvas");if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){const s=navigator.userAgent.match(/version\/(\d+)/i);e=(s?parseInt(s[1]):0)>=17}return e}function ii(i,e,t=!0,s=!1){i.renderOrder=-e;const n=i.material;Array.isArray(n)?n.forEach(a=>{a.colorWrite=t,a.depthWrite=s,a.stencilWrite=!0,a.stencilRef=e,a.stencilFunc=p.AlwaysStencilFunc,a.stencilFail=p.ReplaceStencilOp,a.stencilZFail=p.ReplaceStencilOp,a.stencilZPass=p.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=p.AlwaysStencilFunc,n.stencilFail=p.ReplaceStencilOp,n.stencilZFail=p.ReplaceStencilOp,n.stencilZPass=p.ReplaceStencilOp)}function si(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,n.stencilFail=p.KeepStencilOp,n.stencilZFail=p.KeepStencilOp,n.stencilZPass=p.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,s.stencilFail=p.KeepStencilOp,s.stencilZFail=p.KeepStencilOp,s.stencilZPass=p.KeepStencilOp)}function ni(i){i.blending=p.NormalBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ri(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}function ai(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.DstColorFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function oi(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.OneMinusDstColorFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}let Oe=[];function it(i,e,t=!0){B.renderer=e.renderer;const s=[];s.push({type:"boolean",prop:"Enabled",value:i.enabled});let n=(r,o)=>{console.log("Default Handle Pass:",r,o)};if(i.name==="EffectPass")i.effects.forEach(r=>{r.uniforms.size>0&&r.uniforms.forEach((o,l)=>{if(l==="map")return;const d=`${r.name.replace("Effect","")} ${l}`;if(o.value===null&&t)s.push({prop:l,title:d,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,u=B.renderToBlob(h);s.push({prop:l,title:d,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof o.value=="number"?s.push({prop:l,title:d,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:l,title:d,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:l,title:d,type:"boolean",value:o.value})})}),n=(r,o)=>{i.effects.forEach(l=>{l.uniforms.size>0&&l.uniforms.forEach((d,h)=>{h===r&&(d.value=o)})})};else if(i.name==="ShaderPass"){const r=i.fullscreenMaterial;for(const o in r.uniforms){if(o==="inputBuffer"||o==="map")continue;const l=r.uniforms[o],d=`${r.name.replace("Material","")} ${o}`;if(l.value===null&&t)s.push({title:d,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(l.value.isTexture&&t){const h=l.value,u=B.renderToBlob(h);s.push({title:d,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof l.value=="number"?s.push({title:d,prop:o,type:"number",value:l.value,step:.01}):typeof l.value=="string"?s.push({title:d,prop:o,type:"string",value:l.value}):typeof l.value=="boolean"&&s.push({title:d,prop:o,type:"boolean",value:l.value})}n=(o,l)=>{const d=r.uniforms[o];d.value=l}}else return;const a=`${i.name}: ${i.scene.name}`;e.addGroup({title:a,items:s,onUpdate:(r,o)=>{r==="Enabled"?i.enabled=o:n(r,o)}}),Oe.push(a)}function ci(i,e){i.passes.forEach(t=>{it(t,e)})}function li(i){Oe.forEach(e=>{i.removeGroup(e)}),Oe=[]}function di(i,e,t,s=1024){return new Promise(n=>{const a=e.aspect,r=e.fov,o=e.rotation.clone(),l=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const d=new p.WebGLRenderTarget(s,s,{format:p.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=d,J(i,d,e,"nx",t,s).then(()=>{J(i,d,e,"ny",t,s).then(()=>{J(i,d,e,"nz",t,s).then(()=>{J(i,d,e,"px",t,s).then(()=>{J(i,d,e,"py",t,s).then(()=>{J(i,d,e,"pz",t,s).then(()=>{e.aspect=a,e.fov=r,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=l,d.dispose(),n()})})})})})})})}function J(i,e,t,s,n,a){return new Promise(r=>{const o=Math.PI/2;switch(s){case"nx":t.rotation.set(0,-o,0);break;case"ny":t.rotation.set(-o,0,Math.PI);break;case"nz":t.rotation.set(0,0,0);break;case"px":t.rotation.set(0,o,0);break;case"py":t.rotation.set(o,0,Math.PI);break;case"pz":t.rotation.set(0,Math.PI,0);break}t.updateMatrixWorld(),n.render();const l=new Uint8Array(a*a*4);i.readRenderTargetPixels(e,0,0,a,a,l);const d=document.createElement("canvas");d.width=d.height=a;const h=d.getContext("2d"),u=h.createImageData(a,a);u.data.set(l),h.putImageData(u,0,0);const m=document.createElement("canvas");m.width=m.height=a;const f=m.getContext("2d");f.translate(0,a),f.scale(1,-1),f.drawImage(d,0,0);const y=m.toDataURL("image/png"),g=document.createElement("a");g.href=y,g.download=`${t.name}_${s}.png`,document.body.appendChild(g),g.click(),g.remove(),r()})}const X=Ie(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),hi=Ie(["clientX","clientY","deltaX","deltaY","deltaMode"]),ui=Ie(["ctrlKey","metaKey","shiftKey","keyCode"]);function pi(i,e){i.preventDefault(),hi(i,e)}function mi(i){i.preventDefault()}function fi(i,e,t){for(const s of e)t[s]=i[s]}function Ie(i){return function(t,s){const n={type:t.type};fi(t,i,n),s(n)}}function Ce(i,e){const t=[],s={type:i.type,touches:t};for(let n=0;n<i.touches.length;++n){const a=i.touches[n];t.push({pageX:a.pageX,pageY:a.pageY})}e(s)}const gi={37:!0,38:!0,39:!0,40:!0};function vi(i,e){const{keyCode:t}=i;gi[t]&&(i.preventDefault(),ui(i,e))}const bi={contextmenu:mi,mousedown:X,mousemove:X,mouseup:X,pointerdown:X,pointermove:X,pointerup:X,touchstart:Ce,touchmove:Ce,touchend:Ce,wheel:pi,keydown:vi};let yi=0;class Ci{id;worker;constructor(e,t,s){this.id=yi++,this.worker=t;const n=r=>{this.worker.postMessage({type:"event",id:this.id,data:r})};t.postMessage({type:"makeProxy",id:this.id});for(const[r,o]of Object.entries(s))e.addEventListener(r,l=>{o(l,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class st extends p.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=oe,e.stopPropagation=oe,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Si{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new st;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class xi{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1};onUpdateCallback;playing=!1;rafID=-1;constructor(e,t=!1){this.settings.dev=e,this.settings.editor=t}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(){return new Promise(e=>{Xe(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};addComponent(e,t){this.components.set(e,t)}get debugEnabled(){return this.settings.dev}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e}}class Pe{name;debug;editor;broadcastChannel;onMessageHandler;constructor(e,t=!1,s=!1){this.name=e,this.debug=t,this.editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){this.broadcastChannel?.removeEventListener("message",this.onMessageHandler),this.broadcastChannel?.close()}send(e){if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{this.broadcastChannel?.postMessage(e)}catch(s){console.log("Hermes - Error sending message:"),console.log(s),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}function wi(i,e,t,s,n){const a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*s+i*i*i*n}function Mi(i,e,t){if(i.type!=="bezier"||i.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[s,n]=i.handles,a=(t-i.position)/(e.position-i.position);return wi(a,i.value,i.value+s,e.value+n,e.value)}class Ei extends Pe{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e=!1,t=!1){super("RemoteTheatre",e,t)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(e,t){return this.project=x.getProject(e,{state:t}),new Promise((s,n)=>{this.project?.ready.then(()=>{if(t){const a=t.sheetsById;for(const r in a)this.sheet(r)}s()}).catch(()=>n())})}getSheetInstance(e,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const s=this.getSheetInstance(e,t);let n=this.sheets.get(s);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(s,n)),n}playSheet(e,t,s){return new Promise(n=>{this.sheet(e,s)?.sequence.play(t).then(a=>n(a)),this.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,s)=>{s.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,s,n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.sheet(e,a);if(r===void 0)return;const l=`${this.getSheetInstance(e,a)}_${t}`;let d=this.sheetObjects.get(l),h=s;d!==void 0&&(h={...s,...d.value}),d=r.object(t,h,{reconfigure:!0}),this.sheetObjects.set(l,d),this.sheetObjectCBs.set(l,n!==void 0?n:oe);function u(f,y,g){if(typeof g=="object")if(Ye(g))f[y]={r:g.r,g:g.g,b:g.b,a:g.a};else for(const S in g){const O=g[S];typeof O=="object"&&u(g,S,O)}}const m=d.onValuesChange(f=>{const y=this.sheetObjectCBs.get(l);if(this.editor){for(const g in f){const S=f[g];typeof S=="object"&&u(f,g,S)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:l,values:f}}),y&&y(f)}else y&&y(f)});return this.sheetObjectUnsubscribe.set(l,m),d}getSheetObjectKeyframes(e,t,s){const n=this.sheet(e);if(n===void 0)return[];const a=`${e}_${t}`,r=this.sheetObjects.get(a);return r===void 0?[]:n.sequence.__experimental_getKeyframes(r.props[s])}getSheetObjectVectors(e,t){const s=this.sheet(e);if(s===void 0)return[];const n=`${e}_${t}`,a=this.sheetObjects.get(n);if(a===void 0)return[];const r=[],o=s.sequence.__experimental_getKeyframes(a.props.x),l=s.sequence.__experimental_getKeyframes(a.props.y),d=s.sequence.__experimental_getKeyframes(a.props.z),h=new Set;return o.forEach(m=>h.add(m.position)),l.forEach(m=>h.add(m.position)),d.forEach(m=>h.add(m.position)),Array.from(h).sort((m,f)=>m-f).forEach(m=>{const f=(y,g)=>{const S=y.find((T,R)=>T.position<=g&&(y[R+1]?.position||1/0)>g),O=y.find(T=>T.position>g);if(!S)return O?.value||0;if(!O||S.position===g)return S.value;if(S.type==="bezier")return Mi(S,O,g);const M=(g-S.position)/(O.position-S.position);return S.value+M*(O.value-S.value)};r.push({position:m,x:f(o,m),y:f(l,m),z:f(d,m)})}),r}update(e){}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,s=e.address.objectKey;this.sheets.get(t)?.detachObject(s);const a=`${t}_${s}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e){let t;switch(e.event){case"setSheet":t=this.sheets.get(e.data.sheet),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet: ${e.data.sheet}`,t);break;case"setSheetObject":t=this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet Object: ${e.data.sheet}, ${e.data.key}: ${e.data.sheet}_${e.data.key}`,t);break;case"updateSheetObject":t=this.sheets.get(e.data.sheet),t!==void 0&&t.sequence.pause(),t=this.sheetObjectCBs.get(e.data.sheetObject),t!==void 0?t(e.data.values):console.log(`Hermes - Can't update Sheet Object: ${e.data.sheetObject}, ${e.data.sheet}`,t);break;case"updateTimeline":t=this.sheets.get(e.data.sheet),t!==void 0?t.sequence.position=e.data.position:console.log(`Hermes - Can't update sheet position: ${e.data.sheet}, ${e.data.position}`);break}}handleEditor(e){switch(e.event){case"playSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break}}getSheetNames(){const e=[];return this.sheets.forEach((t,s)=>{e.push(s)}),e}handleEditorApp(){if(this.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(n=>{n.length<1||n.forEach(a=>{let r=a.address.sheetId,o="setSheet",l={};switch(a.type){case"Theatre_Sheet_PublicAPI":o="setSheet",l={sheet:a.address.sheetId},this.activeSheet=this.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",r+=`_${a.address.objectKey}`,l={id:r,sheet:a.address.sheetId,key:a.address.objectKey},this.activeSheet=this.sheets.get(a.address.sheetId);break}this.send({event:o,target:"app",data:l})})});let e=-1;const t=()=>{if(this.activeSheet!==void 0&&e!==this.activeSheet.sequence.position){e=this.activeSheet.sequence.position;const n=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:e,sheet:n.address.sheetId}})}},s=()=>{t(),requestAnimationFrame(s)};t(),s()}else this.studio?.ui.hide()}}function Ai(i){if(i.name==="cameras")return"camera";if(i.name==="interactive")return"interactive";if(i.name==="lights")return"light";if(i.name==="ui")return"ui";if(i.name==="utils")return"utils";const e=i.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function W(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(W(t))}),e}function Ge(i){return{src:i.image?.src??"",offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}}const Fe={src:"",offset:[0,0],repeat:[1,1]};function Oi(i){const e={};for(const t in i){const s=i[t];if(s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")){const a=s.value;a==null?e[t]={value:Fe}:a.isTexture?e[t]={value:Ge(a)}:e[t]={value:a}}else s==null?e[t]=Fe:s.isTexture?e[t]=Ge(s):e[t]=s}return e}function Ri(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Q(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Ri(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":if(n!==null)if(n.isTexture)e[t]={src:B.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]};else if(n.isUniformNode){const a=n.value;e[t]={__isUniform:!0,value:a?.isTexture?{src:B.renderToBlob(a),offset:[a.offset.x,a.offset.y],repeat:[a.repeat.x,a.repeat.y]}:a}}else t==="uniforms"?e[t]=Oi(n):t.search("Node")>-1||(e[t]=n);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(e[t]={src:"",offset:[0,0],repeat:[1,1]});break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function Se(i){i.updateMatrix();const e={name:i.name,type:i.type,uuid:i.uuid,visible:i.visible,matrix:i.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};i.animations.forEach(s=>{e.animations.push({name:s.name,duration:s.duration,blendMode:s.blendMode})});const t=i.type.toLowerCase();if(t.search("mesh")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Q(a))}),e.material=n}else e.material=Q(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Q(a))}),e.material=n}else e.material=Q(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(Q(a))}),e.material=n}else e.material=Q(s.material)}else t.search("camera")>-1?i.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:i.fov,zoom:i.zoom,near:i.near,far:i.far,focus:i.focus,aspect:i.aspect,filmGauge:i.filmGauge,filmOffset:i.filmOffset}:i.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:i.zoom,near:i.near,far:i.far,left:i.left,right:i.right,top:i.top,bottom:i.bottom}):t.search("light")>-1&&(e.lightInfo={color:i.color,intensity:i.intensity,decay:i.decay,distance:i.distance,angle:i.angle,penumbra:i.penumbra,groundColor:i.groundColor,width:i.width,height:i.height});return e}function Ti(i,e){const t=e.split(".");switch(t.length){case 1:return i[t[0]];case 2:return i[t[0]][t[1]];case 3:return i[t[0]][t[1]][t[2]];case 4:return i[t[0]][t[1]][t[2]][t[3]];case 5:return i[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return i[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function Ii(i,e){for(const t in e)i[t]=e[t]}function I(i,e,t){if(i===void 0){console.log(`Hermes - Can't set props: ${e}`,t);return}const s=e.split("."),n=s.length;if(typeof t!="object")switch(n){case 1:i[s[0]]=t;break;case 2:i[s[0]][s[1]]=t;break;case 3:i[s[0]][s[1]][s[2]]=t;break;case 4:i[s[0]][s[1]][s[2]][s[3]]=t;break;case 5:i[s[0]][s[1]][s[2]][s[3]][s[4]]=t;break}else{let r;switch(n){case 1:r=i[s[0]];break;case 2:r=i[s[0]][s[1]];break;case 3:r=i[s[0]][s[1]][s[2]];break;case 4:r=i[s[0]][s[1]][s[2]][s[3]];break;case 5:r=i[s[0]][s[1]][s[2]][s[3]][s[4]];break}r!=null?Ii(r,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function nt(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new p.Texture(s);n.wrapS=p.RepeatWrapping,n.wrapT=p.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}var w=(i=>(i.CUSTOM="ToolEvents::custom",i.SELECT_DROPDOWN="ToolEvents::selectDropdown",i.DRAG_UPDATE="ToolEvents::dragUpdate",i.ADD_SCENE="ToolEvents::addScene",i.REFRESH_SCENE="ToolEvents::refreshScene",i.REMOVE_SCENE="ToolEvents::removeScene",i.SET_SCENE="ToolEvents::setScene",i.SET_OBJECT="ToolEvents::setObject",i.CLEAR_OBJECT="ToolEvents::clearObject",i.ADD_CAMERA="ToolEvents::addCamera",i.REMOVE_CAMERA="ToolEvents::removeCamera",i.ADD_GROUP="ToolEvents::addGroup",i.REMOVE_GROUP="ToolEvents::removeGroup",i.ADD_SPLINE="ToolEvents::addSpline",i.ADD_RENDERER="ToolEvents::addRenderer",i.UPDATE_RENDERER="ToolEvents::updateRenderer",i))(w||{});class Pi extends Pe{name;canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;_listeners={};constructor(e,t=!1,s=!1){super("RemoteThree",t,s),this.name=e}dispose(){this.scenes.forEach(e=>{U(e)}),this.scenes.clear(),this.scene&&U(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const n=s[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){const n={...e,target:this},a=s.slice(0);for(let r=0,o=a.length;r<o;r++)a[r].call(this,n)}}getObjectByUUID(e){const t=e.split(".")[0],s=this.scenes.get(t);if(s!==void 0)return s.getObjectByProperty("uuid",e)}getObject(e){if(!this.debug)return;this.renderer!==void 0&&(B.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){this.renderer!==void 0&&(B.renderer=this.renderer);const t=Se(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const a=this.getObjectByUUID(e);if(a)try{n!==void 0?Ti(a,n)[t](s):a[t](s)}catch(r){console.log("Hermes - Error requesting method:",e,t,s),console.log(r)}}updateObject(e,t,s){this.send({event:"updateObject",target:"app",data:{uuid:e,key:t,value:s}})}createTexture(e,t,s){this.send({event:"createTexture",target:"app",data:{uuid:e,key:t,value:s}})}onUpdateObject(e,t,s){const n=this.getObjectByUUID(e);n&&I(n,t,s)}onCreateTexture(e,t,s){const n=this.getObjectByUUID(e);if(n){const a=r=>{const o=t.split(".");switch(o.length){case 1:n[o[0]]=r;break;case 2:n[o[0]][o[1]]=r;break;case 3:n[o[0]][o[1]][o[2]]=r;break;case 4:n[o[0]][o[1]][o[2]][o[3]]=r;break;case 5:n[o[0]][o[1]][o[2]][o[3]][o[4]]=r;break}n.material.needsUpdate=!0};s.src.length>0?nt(s.src).then(r=>{r.offset.set(s.offset[0],s.offset[1]),r.repeat.set(s.repeat[0],s.repeat[1]),a(r)}):a(null)}}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}addSplineCurve(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addSplineObject(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e)})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.debug)return;const s=`#${e.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:e.autoClearColor,outputColorSpace:e.outputColorSpace,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.debug))return;ne(),ee(e);const t=W(e);this.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.debug)return;const t=this.scenes.get(e);if(t!==void 0){const s=W(t);this.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.debug))return;const t=W(e);this.send({event:"removeScene",target:"editor",data:t})}removeAllScenes(){this.scenes.forEach(e=>this.removeScene(e))}getScene(e){let t=null;return this.scene!==void 0&&this.scene.uuid.search(e)>-1?this.scene:(this.scenes.forEach((s,n)=>{e.search(n)>-1&&(t=s)}),t)}setScene(e){if(e===void 0||(this.scene=e,!this.debug))return;this.renderer!==void 0&&(B.renderer=this.renderer),ne(),ee(e);const t=W(e);this.send({event:"setScene",target:"editor",data:t})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(e){if(!this.debug)return;const t=Se(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug)return;const t=Se(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:W(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,b.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(t=>{ne(),ee(t),this.send({event:"addScene",target:"editor",data:W(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(B.renderer=this.renderer),ne(),ee(this.scene),this.send({event:"setScene",target:"editor",data:W(this.scene)}));break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:e.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:e.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:e.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:e.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:e.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:e.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:e.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:e.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:e.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:e.data})}}messageHandler(e){const t=e.data;if(t.event==="updateObject"){this.onUpdateObject(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="createTexture"){this.onCreateTexture(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="requestSize"){t.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(s=>{s.resize!==void 0&&s.resize(t.data.width,t.data.height)});return}t.target==="app"?this.handleApp(t):this.handleEditor(t)}addRT(e,t=!0,s){if(!this.renderer)return;let n;this.renderer instanceof b.WebGPURenderer?n=new b.RenderTarget(32,32,s):n=new b.WebGLRenderTarget(32,32,s),n.texture.name=e,this.renderTargets.set(e,n),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((a,r)=>{this.renderTargetsResize.get(r)&&a.setSize(e*s,t*s)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(z(1,2,e))}get dpr(){return this.renderer!==void 0?this.renderer?.getPixelRatio():1}get width(){return this.renderer!==void 0?this.renderer.domElement.width/this.dpr:0}get height(){return this.renderer!==void 0?this.renderer.domElement.height/this.dpr:0}}function ke(i){return i.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):c.jsx("button",{children:i.title})}const ki=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Di=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
13
+ `;class kt{worker;source;transfer;ctx;opts;_capturing=!1;_captured=0;_encoded=0;_pending=0;_lastFrameTime=-1/0;frames=new Map;constructor(e,t={}){this.source=e,this.transfer=document.createElement("canvas"),this.transfer.width=e.width,this.transfer.height=e.height,this.ctx=this.transfer.getContext("2d",{willReadFrequently:!0}),this.opts={format:t.format??"png",quality:t.quality??.92,prefix:t.prefix??"frame",padLength:t.padLength??5,maxQueue:t.maxQueue??32,fps:t.fps??30,onProgress:t.onProgress??(()=>{}),onError:t.onError??(a=>console.error("[ImageSequenceCapturer]",a))};const s=new Blob([Pt],{type:"application/javascript"}),n=URL.createObjectURL(s);this.worker=new Worker(n),URL.revokeObjectURL(n),this.worker.onmessage=({data:a})=>{a.type==="encoded"&&(this.frames.set(a.index,a.blob),this._pending--,this._encoded++,this.opts.onProgress(this._captured,this._encoded))},this.worker.onerror=a=>this.opts.onError(new Error(a.message))}get isCapturing(){return this._capturing}get framesCaptured(){return this._captured}get framesEncoded(){return this._encoded}get isIdle(){return this._pending===0}resize(){this.transfer.width=this.source.width,this.transfer.height=this.source.height}start(){this._capturing=!0,this._captured=0,this._encoded=0,this._pending=0,this._lastFrameTime=-1/0,this.frames.clear()}stop(){this._capturing=!1}captureFrame(){if(!this._capturing||this._pending>=this.opts.maxQueue)return!1;const e=performance.now();if(e-this._lastFrameTime<1e3/this.opts.fps)return!1;this._lastFrameTime=e,this.ctx.drawImage(this.source,0,0);const t=this._captured++;return this._pending++,createImageBitmap(this.transfer).then(s=>{this.worker.postMessage({type:"encode",bitmap:s,index:t,format:this.opts.format,quality:this.opts.quality},[s])}).catch(s=>{this._pending--,this.opts.onError(s)}),!0}flush(){return new Promise(e=>{const t=()=>this._pending===0?e():setTimeout(t,16);t()})}async download(){await this.flush();const e=this.opts.format==="jpeg"?"jpg":this.opts.format,s=[...this.frames.entries()].sort(([n],[a])=>n-a).map(([n,a])=>({name:`${this.opts.prefix}_${String(n).padStart(this.opts.padLength,"0")}.${e}`,blob:a}));if("showDirectoryPicker"in window)try{const n=await window.showDirectoryPicker({mode:"readwrite",startIn:"downloads"});await Promise.all(s.map(async({name:a,blob:r})=>{const l=await(await n.getFileHandle(a,{create:!0})).createWritable();await l.write(r),await l.close()}));return}catch(n){if(n.name==="AbortError")return}for(const{name:n,blob:a}of s){const r=URL.createObjectURL(a);Object.assign(document.createElement("a"),{href:r,download:n}).click(),URL.revokeObjectURL(r),await new Promise(l=>setTimeout(l,50))}}reset(){this._capturing=!1,this._captured=0,this._encoded=0,this._pending=0,this.frames.clear()}destroy(){this.reset(),this.worker.terminate()}}function W(i,e,t){return Math.min(e,Math.max(i,t))}function me(i,e,t){return(t-i)/(e-i)}function te(i,e,t){return i*(1-t)+e*t}function Dt(i,e,t,s,n){return te(t,s,me(i,e,n))}function jt(i,e){const t=i-e;return Math.sqrt(t*t)}function Nt(i,e,t,s){return te(i,e,1-Math.exp(-t*s))}function L(i,e=1){return Number(i.toFixed(e))}function Ut(i,e,t,s){return Math.atan2(s-e,t-i)}function Lt(i,e,t,s){return i===e&&t===s}function _t(i,e,t,s){return 1/(3*e*i*i+2*t*i+s)}function Ft(i,e,t,s,n){return e*(i*i*i)+t*(i*i)+s*i+n}function Gt(i,e,t,s,n){const a=i*i;return e*(a*i)+t*a+s*i+n}function Bt(i,e,t,s,n){if(i<=0)return 0;if(i>=1)return 1;if(Lt(e,t,s,n))return i;const a=0,r=0,o=e,l=t,d=s,h=n,u=1,m=1,f=u-3*d+3*o-a,y=3*d-6*o+3*a,g=3*o-3*a,S=a,O=m-3*h+3*l-r,M=3*h-6*l+3*r,I=3*l-3*r,R=r;let D=i;for(let V=0;V<5;V++){const H=Ft(D,f,y,g,S);let G=_t(D,f,y,g);G===1/0&&(G=i),D-=(H-i)*G,D=Math.min(Math.max(D,0),1)}return Gt(D,O,M,I,R)}const le=i=>Math.round(Math.min(1,Math.max(0,i))*255).toString(16).padStart(2,"0");function Vt({r:i,g:e,b:t,a:s=1}){const n=`#${le(i)}${le(e)}${le(t)}`;return s<1?`${n}${le(s)}`:n}let K;function Ht(){const[i,e]=v.useState(K);return v.useEffect(()=>{K||import("@tomorrowevening/theatre-studio").then(t=>{K=t.default,K.initialize(),K.ui.hide(),e(K)})},[]),i}async function Wt(){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 zt(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 qt=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function Ue(i){const e=typeof i;if(i===null||i.isTexture)return"texture";if(e==="boolean")return"boolean";if(e==="number")return"number";if(e==="string")return"string";if(e==="object"){if(i.isColor)return"color";if(i.isVector2)return"vector2";if(i.isVector3)return"vector3";if(i.isVector4)return"vector4";if(i.isMatrix2)return"matrix2";if(i.isMatrix3)return"matrix3";if(i.isMatrix4)return"matrix4";if(i.isEuler)return"euler";if(Array.isArray(i))return"array"}return"object"}function Je(i){const e=[];for(const s in i){const n=qt.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(n||a))if(s==="uniforms"){const o=i.uniforms;for(const l in o){const d=o[l].value,h=Ue(d);h==="array"||h==="object"||e.push({name:`uniforms.${l}.value`,type:h,value:d})}}else{const o=Ue(i[s]);e.push({name:s,type:o,value:i[s]})}}return e.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function Xe(i){const e={},t={nudgeMultiplier:.01};return i.forEach(s=>{let n=s.value;switch(s.type){case"color":n=x.types.rgba({r:n.r,g:n.g,b:n.b,a:1});break;case"number":n=x.types.number(n,t);break;case"euler":case"vector3":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t)};break;case"vector2":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t)};break;case"vector4":n={x:x.types.number(n.x,t),y:x.types.number(n.y,t),z:x.types.number(n.z,t),w:x.types.number(n.w,t)};break;case"matrix2":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t)};break;case"matrix3":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t)};break;case"matrix4":n={0:x.types.number(n.elements[0],t),1:x.types.number(n.elements[1],t),2:x.types.number(n.elements[2],t),3:x.types.number(n.elements[3],t),4:x.types.number(n.elements[4],t),5:x.types.number(n.elements[5],t),6:x.types.number(n.elements[6],t),7:x.types.number(n.elements[7],t),8:x.types.number(n.elements[8],t),9:x.types.number(n.elements[9],t),10:x.types.number(n.elements[10],t),11:x.types.number(n.elements[11],t),12:x.types.number(n.elements[12],t),13:x.types.number(n.elements[13],t),14:x.types.number(n.elements[14],t),15:x.types.number(n.elements[15],t)};break}if(s.name.includes(".")){const a=s.name.split(".");let r=e;for(let o=0;o<a.length-1;o++){const l=a[o];r[l]||(r[l]={}),r=r[l]}r[a[a.length-1]]=n}else e[s.name]=n}),e}function Qe(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 $t(i,e,t,s){if(!t.isMaterial)return;const n=Je(t),a=Xe(n);s.sheetObject(i,e,{material:a},r=>{Qe(t,n,r)})}const ge=new p.BufferGeometry;ge.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));ge.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3));ge.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const Kt=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),Me=i=>{i?.dispose()},Oe=i=>{if(i)if(Array.isArray(i))i.forEach(e=>Oe(e));else{for(const e in i){const t=i[e];t!==null&&t instanceof p.Texture&&Me(t)}if(i.isShaderMaterial===!0){const e=i;for(const t in e.uniforms){const s=e.uniforms[t];s.value!==null&&s.value instanceof p.Texture&&Me(s.value)}}i.dispose()}},_=i=>{if(i){for(;i.children.length>0;){const e=i.children[0];e.type==="Audio"?(e.pause(),e.parent&&e.parent.remove(e)):_(e)}if(i.parent&&i.parent.remove(i),i.isMesh){const e=i;e.geometry?.dispose(),Oe(e.material)}i.dispose!==void 0&&i.dispose()}};exports.totalThreeObjects=0;const se=()=>{exports.totalThreeObjects=0},Z=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=>Z(t))};class B{static renderer;static canvas;static context=null;static scene=null;static camera=null;static material=null;static inited=!1;static width=100;static height=100;static init(){this.inited||(this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.context=this.canvas.getContext("2d"),this.inited=!0)}static renderToBlob(e){this.init();const t=e.repeat.clone(),s=e.offset.clone();if(e.repeat.set(1,1),e.offset.set(0,0),this.context!==null){this.context.clearRect(0,0,this.width,this.height);const n=e.image;if(n!=null&&n.width>0){this.canvas.title=e.sourceFile;const a=this.canvas.width/n.width,r=this.renderToCanvas(e);this.context.drawImage(r,0,0,n.width*a,n.height*a)}}return e.repeat.copy(t),e.offset.copy(s),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new p.OrthographicCamera(-.5,.5,.5,-.5,0,100),this.scene=new p.Scene,this.material=new p.MeshBasicMaterial;const t=new p.BufferGeometry;t.setAttribute("position",new p.Float32BufferAttribute([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new p.Float32BufferAttribute([0,0,1,0,0,1],3)),t.setAttribute("uv",new p.Float32BufferAttribute([0,0,2,0,0,2],2));const s=new p.Mesh(t,this.material);this.scene.add(s)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,s=e.colorSpace;this.renderer.outputColorSpace=p.LinearSRGBColorSpace,e.colorSpace=p.LinearSRGBColorSpace,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=s}return this.renderer.domElement}}function Yt(i){return new Promise(e=>{const t=new p.ObjectLoader;t.parseAsync(i.scene).then(s=>{const n=new p.AnimationMixer(s);if(i.animations.length>0){const r=i.animations.map(l=>p.AnimationClip.parse(l));n.clipAction(r[0]).play(),n.getRoot().animations=i.animations,n.getRoot().mixer=n}const a=[];i.cameras&&i.cameras.length>0&&i.cameras.forEach(r=>{const o=t.parse(r);a.push(o)}),e({animations:i.animations,model:s,mixer:n,cameras:a})})})}const Jt=(i,e,t,s)=>{i.setRenderTarget(s),i.clear(),i.render(e,t)};function Ze(i,e,t,s){i.applyMatrix4(new p.Matrix4().makeTranslation(e,-t,-s))}function Xt(i){i.computeBoundingBox();const e=i.boundingBox,t=(e.max.x-e.min.x)/2,s=(e.max.y-e.min.y)/2;Ze(i,t,s,0)}function Qt(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 Zt(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 ei(){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 ti(i,e,t=!0,s=!1){i.renderOrder=-e;const n=i.material;Array.isArray(n)?n.forEach(a=>{a.colorWrite=t,a.depthWrite=s,a.stencilWrite=!0,a.stencilRef=e,a.stencilFunc=p.AlwaysStencilFunc,a.stencilFail=p.ReplaceStencilOp,a.stencilZFail=p.ReplaceStencilOp,a.stencilZPass=p.ReplaceStencilOp}):(n.colorWrite=t,n.depthWrite=s,n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=p.AlwaysStencilFunc,n.stencilFail=p.ReplaceStencilOp,n.stencilZFail=p.ReplaceStencilOp,n.stencilZPass=p.ReplaceStencilOp)}function ii(i,e,t=!1){const s=i.material;Array.isArray(s)?s.forEach(n=>{n.stencilWrite=!0,n.stencilRef=e,n.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,n.stencilFail=p.KeepStencilOp,n.stencilZFail=p.KeepStencilOp,n.stencilZPass=p.KeepStencilOp}):(s.stencilWrite=!0,s.stencilRef=e,s.stencilFunc=t?p.NotEqualStencilFunc:p.EqualStencilFunc,s.stencilFail=p.KeepStencilOp,s.stencilZFail=p.KeepStencilOp,s.stencilZPass=p.KeepStencilOp)}function si(i){i.blending=p.NormalBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ni(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.SrcAlphaFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}function ri(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.DstColorFactor,i.blendDst=p.OneMinusSrcAlphaFactor,i.needsUpdate=!0}function ai(i){i.blending=p.CustomBlending,i.blendEquation=p.AddEquation,i.blendSrc=p.OneMinusDstColorFactor,i.blendDst=p.OneFactor,i.needsUpdate=!0}let Ee=[];function et(i,e,t=!0){B.renderer=e.renderer;const s=[];s.push({type:"boolean",prop:"Enabled",value:i.enabled});let n=(r,o)=>{console.log("Default Handle Pass:",r,o)};if(i.name==="EffectPass")i.effects.forEach(r=>{r.uniforms.size>0&&r.uniforms.forEach((o,l)=>{if(l==="map")return;const d=`${r.name.replace("Effect","")} ${l}`;if(o.value===null&&t)s.push({prop:l,title:d,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(o.value.isTexture&&t){const h=o.value,u=B.renderToBlob(h);s.push({prop:l,title:d,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof o.value=="number"?s.push({prop:l,title:d,type:"number",value:o.value,step:.01}):typeof o.value=="string"?s.push({prop:l,title:d,type:"string",value:o.value}):typeof o.value=="boolean"&&s.push({prop:l,title:d,type:"boolean",value:o.value})})}),n=(r,o)=>{i.effects.forEach(l=>{l.uniforms.size>0&&l.uniforms.forEach((d,h)=>{h===r&&(d.value=o)})})};else if(i.name==="ShaderPass"){const r=i.fullscreenMaterial;for(const o in r.uniforms){if(o==="inputBuffer"||o==="map")continue;const l=r.uniforms[o],d=`${r.name.replace("Material","")} ${o}`;if(l.value===null&&t)s.push({title:d,prop:o,type:"image",value:{offset:[0,0],repeat:[1,1],src:""}});else if(l.value.isTexture&&t){const h=l.value,u=B.renderToBlob(h);s.push({title:d,prop:o,type:"image",value:{offset:[h.offset.x,h.offset.y],repeat:[h.repeat.x,h.repeat.y],src:u}})}else typeof l.value=="number"?s.push({title:d,prop:o,type:"number",value:l.value,step:.01}):typeof l.value=="string"?s.push({title:d,prop:o,type:"string",value:l.value}):typeof l.value=="boolean"&&s.push({title:d,prop:o,type:"boolean",value:l.value})}n=(o,l)=>{const d=r.uniforms[o];d.value=l}}else return;const a=`${i.name}: ${i.scene.name}`;e.addGroup({title:a,items:s,onUpdate:(r,o)=>{r==="Enabled"?i.enabled=o:n(r,o)}}),Ee.push(a)}function oi(i,e){i.passes.forEach(t=>{et(t,e)})}function ci(i){Ee.forEach(e=>{i.removeGroup(e)}),Ee=[]}function li(i,e,t,s=1024){return new Promise(n=>{const a=e.aspect,r=e.fov,o=e.rotation.clone(),l=t.outputBuffer;e.aspect=1,e.fov=90,e.updateProjectionMatrix();const d=new p.WebGLRenderTarget(s,s,{format:p.RGBAFormat,depthBuffer:!0,stencilBuffer:!1});t.outputBuffer=d,Y(i,d,e,"nx",t,s).then(()=>{Y(i,d,e,"ny",t,s).then(()=>{Y(i,d,e,"nz",t,s).then(()=>{Y(i,d,e,"px",t,s).then(()=>{Y(i,d,e,"py",t,s).then(()=>{Y(i,d,e,"pz",t,s).then(()=>{e.aspect=a,e.fov=r,e.rotation.copy(o),e.updateMatrixWorld(),e.updateProjectionMatrix(),t.outputBuffer=l,d.dispose(),n()})})})})})})})}function Y(i,e,t,s,n,a){return new Promise(r=>{const o=Math.PI/2;switch(s){case"nx":t.rotation.set(0,-o,0);break;case"ny":t.rotation.set(-o,0,Math.PI);break;case"nz":t.rotation.set(0,0,0);break;case"px":t.rotation.set(0,o,0);break;case"py":t.rotation.set(o,0,Math.PI);break;case"pz":t.rotation.set(0,Math.PI,0);break}t.updateMatrixWorld(),n.render();const l=new Uint8Array(a*a*4);i.readRenderTargetPixels(e,0,0,a,a,l);const d=document.createElement("canvas");d.width=d.height=a;const h=d.getContext("2d"),u=h.createImageData(a,a);u.data.set(l),h.putImageData(u,0,0);const m=document.createElement("canvas");m.width=m.height=a;const f=m.getContext("2d");f.translate(0,a),f.scale(1,-1),f.drawImage(d,0,0);const y=m.toDataURL("image/png"),g=document.createElement("a");g.href=y,g.download=`${t.name}_${s}.png`,document.body.appendChild(g),g.click(),g.remove(),r()})}const J=Re(["ctrlKey","metaKey","shiftKey","button","pointerId","pointerType","clientX","clientY","pageX","pageY"]),di=Re(["clientX","clientY","deltaX","deltaY","deltaMode"]),hi=Re(["ctrlKey","metaKey","shiftKey","keyCode"]);function ui(i,e){i.preventDefault(),di(i,e)}function pi(i){i.preventDefault()}function mi(i,e,t){for(const s of e)t[s]=i[s]}function Re(i){return function(t,s){const n={type:t.type};mi(t,i,n),s(n)}}function ye(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 fi={37:!0,38:!0,39:!0,40:!0};function gi(i,e){const{keyCode:t}=i;fi[t]&&(i.preventDefault(),hi(i,e))}const vi={contextmenu:pi,mousedown:J,mousemove:J,mouseup:J,pointerdown:J,pointermove:J,pointerup:J,touchstart:ye,touchmove:ye,touchend:ye,wheel:ui,keydown:gi};let bi=0;class yi{id;worker;constructor(e,t,s){this.id=bi++,this.worker=t;const n=r=>{this.worker.postMessage({type:"event",id:this.id,data:r})};t.postMessage({type:"makeProxy",id:this.id});for(const[r,o]of Object.entries(s))e.addEventListener(r,l=>{o(l,n)});function a(){n({type:"resize",left:0,top:0,width:innerWidth,height:innerHeight})}window.addEventListener("resize",a),a()}}class tt extends p.EventDispatcher{style={};left=0;top=0;width=0;height=0;ownerDocument=void 0;constructor(){super(),this.ownerDocument=this}get clientWidth(){return this.width}set clientWidth(e){this.width=e}get clientHeight(){return this.height}set clientHeight(e){this.height=e}setPointerCapture(){}releasePointerCapture(){}getBoundingClientRect(){return{x:this.left,y:this.top,left:this.left,top:this.top,width:this.width,height:this.height,right:this.left+this.width,bottom:this.top+this.height,toJSON:()=>({})}}handleEvent(e){if(e.type==="size"){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height;return}e.preventDefault=ae,e.stopPropagation=ae,this.dispatchEvent(e)}focus(){}getRootNode(){return this}}class Ci{targets={};constructor(){this.handleEvent=this.handleEvent.bind(this)}makeProxy(e){const{id:t}=e,s=new tt;this.targets[t]=s}getProxy(e){return this.targets[e]}handleEvent(e){this.targets[e.id]?.handleEvent(e.data)}}class Si{assets={audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map};components=new Map;settings={dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1};onUpdateCallback;playing=!1;rafID=-1;constructor(e,t=!1){this.settings.dev=e,this.settings.editor=t}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(){return new Promise(e=>{Ye(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}play=()=>{this.playing||(this.playing=!0,this.onUpdate())};pause=()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)};onUpdate=()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)};addComponent(e,t){this.components.set(e,t)}get debugEnabled(){return this.settings.dev}get isApp(){return!this.editor}set isApp(e){this.editor=!e}get editor(){return this.settings.editor}set editor(e){this.settings.editor=e}}class Ie{name;debug;editor;broadcastChannel;onMessageHandler;constructor(e,t=!1,s=!1){this.name=e,this.debug=t,this.editor=s,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){this.broadcastChannel?.removeEventListener("message",this.onMessageHandler),this.broadcastChannel?.close()}send(e){if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{this.broadcastChannel?.postMessage(e)}catch(s){console.log("Hermes - Error sending message:"),console.log(s),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}function xi(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 wi(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 xi(a,i.value,i.value+s,e.value+n,e.value)}class Mi extends Ie{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio=void 0;constructor(e=!1,t=!1){super("RemoteTheatre",e,t)}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(e,t){return this.project=x.getProject(e,{state:t}),new Promise((s,n)=>{this.project?.ready.then(()=>{if(t){const a=t.sheetsById;for(const r in a)this.sheet(r)}s()}).catch(()=>n())})}getSheetInstance(e,t){return t!==void 0?`${e}-${t}`:e}sheet(e,t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const s=this.getSheetInstance(e,t);let n=this.sheets.get(s);return n!==void 0||(n=this.project?.sheet(e,t),this.sheets.set(s,n)),n}playSheet(e,t,s){return new Promise(n=>{this.sheet(e,s)?.sequence.play(t).then(a=>n(a)),this.send({event:"playSheet",target:"editor",data:{sheet:e,instance:s,value:t}})})}pauseSheet(e,t){this.sheet(e,t)?.sequence.pause(),this.send({event:"pauseSheet",target:"editor",data:{sheet:e,instance:t}})}clearSheetObjects(e){this.sheetObjects.forEach((t,s)=>{s.search(`${e}_`)>-1&&this.unsubscribe(t)})}sheetObject(e,t,s,n,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.sheet(e,a);if(r===void 0)return;const l=`${this.getSheetInstance(e,a)}_${t}`;let d=this.sheetObjects.get(l),h=s;d!==void 0&&(h={...s,...d.value}),d=r.object(t,h,{reconfigure:!0}),this.sheetObjects.set(l,d),this.sheetObjectCBs.set(l,n!==void 0?n:ae);function u(f,y,g){if(typeof g=="object")if($e(g))f[y]={r:g.r,g:g.g,b:g.b,a:g.a};else for(const S in g){const O=g[S];typeof O=="object"&&u(g,S,O)}}const m=d.onValuesChange(f=>{const y=this.sheetObjectCBs.get(l);if(this.editor){for(const g in f){const S=f[g];typeof S=="object"&&u(f,g,S)}this.send({event:"updateSheetObject",target:"app",data:{sheet:e,sheetObject:l,values:f}}),y&&y(f)}else y&&y(f)});return this.sheetObjectUnsubscribe.set(l,m),d}getSheetObjectKeyframes(e,t,s){const n=this.sheet(e);if(n===void 0)return[];const a=`${e}_${t}`,r=this.sheetObjects.get(a);return r===void 0?[]:n.sequence.__experimental_getKeyframes(r.props[s])}getSheetObjectVectors(e,t){const s=this.sheet(e);if(s===void 0)return[];const n=`${e}_${t}`,a=this.sheetObjects.get(n);if(a===void 0)return[];const r=[],o=s.sequence.__experimental_getKeyframes(a.props.x),l=s.sequence.__experimental_getKeyframes(a.props.y),d=s.sequence.__experimental_getKeyframes(a.props.z),h=new Set;return o.forEach(m=>h.add(m.position)),l.forEach(m=>h.add(m.position)),d.forEach(m=>h.add(m.position)),Array.from(h).sort((m,f)=>m-f).forEach(m=>{const f=(y,g)=>{const S=y.find((I,R)=>I.position<=g&&(y[R+1]?.position||1/0)>g),O=y.find(I=>I.position>g);if(!S)return O?.value||0;if(!O||S.position===g)return S.value;if(S.type==="bezier")return wi(S,O,g);const M=(g-S.position)/(O.position-S.position);return S.value+M*(O.value-S.value)};r.push({position:m,x:f(o,m),y:f(l,m),z:f(d,m)})}),r}update(e){}unsubscribe(e){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const t=e.address.sheetId,s=e.address.objectKey;this.sheets.get(t)?.detachObject(s);const a=`${t}_${s}`,r=this.sheetObjectUnsubscribe.get(a);r!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),r())}handleApp(e){let t;switch(e.event){case"setSheet":t=this.sheets.get(e.data.sheet),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet: ${e.data.sheet}`,t);break;case"setSheetObject":t=this.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),t!==void 0?this.studio?.setSelection([t]):console.log(`Hermes - Can't set Sheet Object: ${e.data.sheet}, ${e.data.key}: ${e.data.sheet}_${e.data.key}`,t);break;case"updateSheetObject":t=this.sheets.get(e.data.sheet),t!==void 0&&t.sequence.pause(),t=this.sheetObjectCBs.get(e.data.sheetObject),t!==void 0?t(e.data.values):console.log(`Hermes - Can't update Sheet Object: ${e.data.sheetObject}, ${e.data.sheet}`,t);break;case"updateTimeline":t=this.sheets.get(e.data.sheet),t!==void 0?t.sequence.position=e.data.position:console.log(`Hermes - Can't update sheet position: ${e.data.sheet}, ${e.data.position}`);break}}handleEditor(e){switch(e.event){case"playSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.play(e.data.value);break;case"pauseSheet":this.sheet(e.data.sheet,e.data.instance)?.sequence.pause();break}}getSheetNames(){const e=[];return this.sheets.forEach((t,s)=>{e.push(s)}),e}handleEditorApp(){if(this.editor){this.studio?.ui.restore(),this.studio?.onSelectionChange(n=>{n.length<1||n.forEach(a=>{let r=a.address.sheetId,o="setSheet",l={};switch(a.type){case"Theatre_Sheet_PublicAPI":o="setSheet",l={sheet:a.address.sheetId},this.activeSheet=this.sheets.get(a.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":o="setSheetObject",r+=`_${a.address.objectKey}`,l={id:r,sheet:a.address.sheetId,key:a.address.objectKey},this.activeSheet=this.sheets.get(a.address.sheetId);break}this.send({event:o,target:"app",data:l})})});let e=-1;const t=()=>{if(this.activeSheet!==void 0&&e!==this.activeSheet.sequence.position){e=this.activeSheet.sequence.position;const n=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:e,sheet:n.address.sheetId}})}},s=()=>{t(),requestAnimationFrame(s)};t(),s()}else this.studio?.ui.hide()}}var w=(i=>(i.CUSTOM="ToolEvents::custom",i.SELECT_DROPDOWN="ToolEvents::selectDropdown",i.DRAG_UPDATE="ToolEvents::dragUpdate",i.ADD_SCENE="ToolEvents::addScene",i.REFRESH_SCENE="ToolEvents::refreshScene",i.REMOVE_SCENE="ToolEvents::removeScene",i.SET_SCENE="ToolEvents::setScene",i.SET_OBJECT="ToolEvents::setObject",i.CLEAR_OBJECT="ToolEvents::clearObject",i.ADD_CAMERA="ToolEvents::addCamera",i.REMOVE_CAMERA="ToolEvents::removeCamera",i.ADD_GROUP="ToolEvents::addGroup",i.REMOVE_GROUP="ToolEvents::removeGroup",i.ADD_SPLINE="ToolEvents::addSpline",i.ADD_RENDERER="ToolEvents::addRenderer",i.UPDATE_RENDERER="ToolEvents::updateRenderer",i))(w||{});class Ei extends Ie{name;canvas=null;inputElement=null;scene=void 0;scenes=new Map;renderer=void 0;renderTargets=new Map;renderTargetsResize=new Map;groups=new Map;_listeners={};editorUtils;constructor(e,t=!1,s=!1){super("RemoteThree",t,s),this.name=e}setEditorUtils(e){this.editorUtils=e}dispose(){this.scenes.forEach(e=>{_(e)}),this.scenes.clear(),this.scene&&_(this.scene),this.renderTargets.forEach(e=>{e.dispose()}),this.renderTargets.clear(),this.renderer?.dispose()}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const n=s[e];if(n!==void 0){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){const n={...e,target:this},a=s.slice(0);for(let r=0,o=a.length;r<o;r++)a[r].call(this,n)}}getObjectByUUID(e){const t=e.split(".")[0],s=this.scenes.get(t);if(s!==void 0)return s.getObjectByProperty("uuid",e)}getObject(e){if(!this.debug)return;this.renderer!==void 0&&(B.renderer=this.renderer);const t=this.getObjectByUUID(e);t&&this.setObject(t)}setObject(e){if(!this.editorUtils)return;this.renderer!==void 0&&(B.renderer=this.renderer);const t=this.editorUtils.stripObject(e);this.dispatchEvent({type:"ToolEvents::setObject",value:t})}requestMethod(e,t,s,n){const a=this.getObjectByUUID(e);if(a)try{if(n!==void 0){const r=this.editorUtils?.getSubItem(a,n);r!==void 0&&r[t](s)}else 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&&this.editorUtils?.setItemProps(n,t,s)}onCreateTexture(e,t,s){if(!this.editorUtils)return;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?this.editorUtils.textureFromSrc(s.src).then(r=>{r.offset.set(s.offset[0],s.offset[1]),r.repeat.set(s.repeat[0],s.repeat[1]),a(r)}):a(null)}}addGroup(e){this.groups.get(e.title)===void 0&&(this.groups.set(e.title,{title:e.title,onUpdate:e.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(e)}))}removeGroup(e){this.groups.get(e)!==void 0&&(this.groups.delete(e),this.send({event:"removeGroup",target:"editor",data:e}))}updateGroup(e,t,s){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:e,prop:t,value:s})})}addSplineCurve(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e.toJSON())})},1)}addSplineObject(e){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(e)})},1)}setRenderer(e,t=null){if(this.renderer=e,this.canvas=e.domElement,this.inputElement=t!==null?t:this.canvas,!this.debug)return;const s=`#${e.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:e.autoClearColor,outputColorSpace:e.outputColorSpace,clearColor:s,clearAlpha:e.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:e.toneMapping,toneMappingExposure:e.toneMappingExposure,type:e.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(e){this.send({event:"updateRenderer",target:"app",data:e})}addScene(e){if(e===void 0||(this.scenes.set(e.name,e),!this.debug||!this.editorUtils))return;se(),Z(e);const t=this.editorUtils.stripScene(e);this.send({event:"addScene",target:"editor",data:t})}refreshScene(e){if(!this.debug||!this.editorUtils)return;const t=this.scenes.get(e);if(t!==void 0){const s=this.editorUtils.stripScene(t);this.send({event:"refreshScene",target:"app",data:s})}}removeScene(e){if(e===void 0||(this.scenes.delete(e.name),!this.debug||!this.editorUtils))return;const t=this.editorUtils.stripScene(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||!this.editorUtils))return;this.renderer!==void 0&&(B.renderer=this.renderer),se(),Z(e);const t=this.editorUtils.stripScene(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||!this.editorUtils)return;const t=this.editorUtils.stripObject(e);this.send({event:"addCamera",target:"editor",data:t})}removeCamera(e){if(!this.debug||!this.editorUtils)return;const t=this.editorUtils.stripObject(e);this.send({event:"removeCamera",target:"editor",data:t})}handleApp(e){switch(e.event){case"refreshScene":this.editorUtils&&this.send({event:"refreshScene",target:"editor",data:this.editorUtils.stripScene(this.scenes.get(e.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=e.data.autoClearColor,this.renderer.outputColorSpace=e.data.outputColorSpace,this.renderer.setClearColor(e.data.clearColor,e.data.clearAlpha),this.renderer.toneMapping=e.data.toneMapping,this.renderer.toneMappingExposure=e.data.toneMappingExposure,b.ColorManagement.enabled=e.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const t=`#${this.renderer.getClearColor(new b.Color).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:t,clearAlpha:this.renderer.getClearAlpha(),colorManagement:b.ColorManagement.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.editorUtils&&(this.scenes.forEach(t=>{se(),Z(t),this.send({event:"addScene",target:"editor",data:this.editorUtils.stripScene(t)})}),this.scene!==void 0&&(this.renderer!==void 0&&(B.renderer=this.renderer),se(),Z(this.scene),this.send({event:"setScene",target:"editor",data:this.editorUtils.stripScene(this.scene)})));break}if(e.event==="updateGroup"){const t=JSON.parse(e.data);this.groups.get(t.group)?.onUpdate(t.prop,t.value)}}handleEditor(e){switch(e.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:e.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:e.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:e.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:e.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:e.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:e.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:e.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:e.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:e.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:e.data})}}messageHandler(e){const t=e.data;if(t.event==="updateObject"){this.onUpdateObject(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="createTexture"){this.onCreateTexture(t.data.uuid,t.data.key,t.data.value);return}else if(t.event==="requestSize"){t.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(s=>{s.resize!==void 0&&s.resize(t.data.width,t.data.height)});return}t.target==="app"?this.handleApp(t):this.handleEditor(t)}addRT(e,t=!0,s){if(!this.renderer)return;let n;this.renderer instanceof b.WebGPURenderer?n=new b.RenderTarget(32,32,s):n=new b.WebGLRenderTarget(32,32,s),n.texture.name=e,this.renderTargets.set(e,n),this.renderTargetsResize.set(e,t)}removeRT(e){this.renderTargets.delete(e),this.renderTargetsResize.delete(e)}resize(e,t){const s=this.dpr;this.renderTargets.forEach((a,r)=>{this.renderTargetsResize.get(r)&&a.setSize(e*s,t*s)});const n=!(this.renderer?.domElement instanceof OffscreenCanvas);this.renderer?.setSize(e,t,n)}set dpr(e){this.renderer?.setPixelRatio(W(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 Te(i){return i.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:i.title}}):c.jsx("button",{children:i.title})}const Ai=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Oi=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
14
14
  C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1\r
15
- C11,8.22,10.74,8,10.43,8z`})});function rt(i){return c.jsx("li",{className:`reorder-item ${i.draggingIndex===i.index?"dragging":""}`,draggable:!0,onDragStart:()=>i.onDragStart(i.index),onDragOver:e=>{e.preventDefault(),i.onDragOver(i.index)},onDragEnd:i.onDragEnd,children:c.jsxs("div",{children:[Di,c.jsx("span",{children:i.title}),c.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:ki})]})})}function at(i){const[e,t]=v.useState(!1),[s,n]=v.useState(i.options),[a,r]=v.useState(null),o=f=>{i.onDragComplete(f),n(f)},l=f=>{const y=[...s];y.splice(f,1),o(y)},d=f=>{r(f)},h=f=>{if(a===f||a===null)return;const y=[...s],g=y.splice(a,1)[0];y.splice(f,0,g),r(f),n(y)},u=()=>{i.onDragComplete(s),r(null)};let m="dropdown draggable";return i.subdropdown&&(m+=" subdropdown"),c.jsxs("div",{className:m,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(ke,{title:i.title}),c.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((f,y)=>c.jsx(rt,{title:f,index:y,draggingIndex:a,onDelete:l,onDragStart:d,onDragOver:h,onDragEnd:u},f))})]})}function ot(i){const[e,t]=v.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(c.jsx(ct,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),c.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(ke,{title:i.title}),c.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function ct(i){const{option:e}=i,[t,s]=v.useState("");let n;switch(e.type){case"draggable":n=c.jsx(at,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=c.jsx(ot,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=c.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return c.jsx("li",{className:t===e.title?"selected":"",children:n},k())}function te(i){const[e,t]=v.useState(i.open!==void 0?i.open:!1),[s,n]=v.useState(i.visible!==void 0?i.visible:!1),a=!e||i.children===void 0,r=()=>{i.three.dispatchEvent({type:w.REMOVE_SCENE,value:i.scene})};return c.jsxs("div",{className:`accordion ${a?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const o=!e;i.onToggle!==void 0&&i.onToggle(o),t(o)},children:[c.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:ce(i.label)})]}),i.onRefresh?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const l=i.three.getScene(i.scene.uuid);if(l){const d=!l.visible;l.visible=d,n(d)}}}),c.jsx("button",{className:"refresh",onClick:i.onRefresh}),c.jsx("button",{className:"remove",onClick:r})]}):null,i.button,c.jsx("div",{className:e?"open":"",children:c.jsx("div",{children:i.children})})]})}function De(i){if(i.child===void 0)return console.log("Hermes - No child attached"),null;const e=v.useRef(null),[t,s]=v.useState(!1),n=i.child.children.length>0,a=[];return i.child.children.length>0&&i.child.children.map((r,o)=>{a.push(c.jsx(De,{child:r,three:i.three},o))}),v.useEffect(()=>{if(i.child){const r=i.child.uuid.split(".")[0],o=i.three.getScene(r);if(o!==null)try{const l=o.getObjectByProperty("uuid",i.child.uuid);l!==void 0?e.current.style.opacity=l.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(l){console.log("Error looking for child:",l),console.log(i.child),console.log(i.three.scenes),console.log(o)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${r} with child UUID: ${i.child.uuid}`,i.three.scenes,i.three.scene,o)}},[t]),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[n?c.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,c.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0?(i.three.getObject(i.child.uuid),!t&&n&&s(!0)):console.log("Hermes - No child attached...")},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),c.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.child.uuid);if(o!==void 0){const l="visible",d=!o.visible;e.current.style.opacity=d?"1":"0.25",i.three.updateObject(i.child.uuid,l,d),I(o,l,d)}else console.log(`Hermes - Couldn't find object: ${i.child.uuid}`,r)}else console.log(`Hermes - Couldn't find object in scene: ${i.child.uuid}, ${i.child.name}`)}}}),c.jsx("div",{className:`icon ${Ai(i.child)}`})]}),c.jsx("div",{className:t?"open":"",children:c.jsx("div",{className:"container",children:a})})]})}function ue(i){const e=[];return i.child?.children.map((t,s)=>{e.push(c.jsx(De,{child:t,scene:i.scene,three:i.three},s))}),c.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function re(i){const[e,t]=v.useState(i.defaultValue);return v.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,o=!1;const l=f=>{o=f.ctrlKey},d=f=>{s=!0,a=Number(i.input.current?.value),n=f.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=f=>{if(!s)return;const y=i.step!==void 0?i.step:1,g=(f.clientX-n)*y*(o?10:1);r=Number((a+g).toFixed(4)),i.min!==void 0&&(r=Math.max(r,i.min)),i.max!==void 0&&(r=Math.min(r,i.max)),i.onChange!==void 0&&i.onChange(r),t(r)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},m=f=>{const y=Number(f.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.label.current?.addEventListener("mousedown",d,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{i.label.current?.removeEventListener("mousedown",d),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function K(i){const e=v.useRef(null),t=v.useRef(null),[s,n]=v.useState(i.value);return re({label:i.labelRef,input:e,sliderRef:t,defaultValue:s,min:i.min,max:i.max,step:i.step,onChange:a=>{n(a),i.onChange!==void 0&&i.onChange(i.prop,a)}}),c.jsxs(c.Fragment,{children:[i.type==="number"&&c.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,name:k(),onChange:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||i.onChange!==void 0&&i.onChange(i.prop,r)}}),i.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:k(),onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||(n(r),i.onChange!==void 0&&i.onChange(i.prop,r))}}),c.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,name:k(),onChange:oe})]})]})}function ji(i){const e=v.useRef(null),t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),o=v.useRef(null),l=v.useRef(null),d=v.useRef(null),h=v.useRef(null),[u,m]=v.useState(i.value.x),[f,y]=v.useState(i.value.y),[g,S]=v.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[O,M]=v.useState(!1);re({label:o,input:e,defaultValue:u,min:g.min,max:g.max,step:.01,onChange:E=>{m(E),i.onChange({target:{value:{x:E,y:f}}})}}),re({label:l,input:t,defaultValue:f,min:g.min,max:g.max,step:.01,onChange:E=>{y(E),i.onChange({target:{value:{x:u,y:E}}})}}),re({label:d,input:s,defaultValue:g.min,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:E,max:g.max})}}),re({label:h,input:n,defaultValue:g.max,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:g.min,max:E})}});function T(){O||(window.addEventListener("mousemove",D),window.addEventListener("mouseup",R),M(!0))}function R(){window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",R),M(!1)}function D(E){const j=a.current.getBoundingClientRect(),le=z(0,99,E.clientX-j.left)/99,yt=1-z(0,99,E.clientY-j.top)/99,Ne=_(ie(g.min,g.max,le),3),Le=_(ie(g.min,g.max,yt),3);i.onChange({target:{value:{x:Ne,y:Le}}}),m(Ne),y(Le)}function V(){const E=Number(s.current.value);S({min:E,max:g.max}),u<E&&m(z(E,g.max,u)),f<E&&y(z(E,g.max,f))}function H(){const E=Number(n.current.value);S({min:g.min,max:E}),u>E&&m(z(g.min,E,u)),f>E&&y(z(g.min,E,f))}v.useEffect(()=>{r.current.style.left=`${fe(g.min,g.max,u)*100}%`,r.current.style.top=`${(1-fe(g.min,g.max,f))*100}%`},[g,u,f]);const F=i.step!==void 0?i.step:.01;return c.jsxs("div",{className:"vector2",children:[c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{ref:o,children:"X"}),c.jsx("input",{ref:e,type:"number",value:u,min:g.min,max:g.max,step:F,name:k(),onChange:E=>{if(m(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:j,y:f}}}),j<g.min&&S({min:j,max:g.max}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:l,children:"Y"}),c.jsx("input",{ref:t,type:"number",value:f,min:g.min,max:g.max,step:F,name:k(),onChange:E=>{if(y(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:u,y:j}}}),j>g.max&&S({min:g.min,max:j}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:d,children:"Min"}),c.jsx("input",{ref:s,type:"number",value:g.min,step:F,name:k(),onChange:V})]}),c.jsxs("div",{children:[c.jsx("span",{ref:h,children:"Max"}),c.jsx("input",{ref:n,type:"number",value:g.max,step:F,name:k(),onChange:H})]})]}),c.jsxs("div",{className:"input",ref:a,onMouseDown:T,onMouseUp:R,children:[c.jsx("div",{className:"x"}),c.jsx("div",{className:"y"}),c.jsx("div",{className:"pt",ref:r})]})]})}function Be(i){const e=i.value.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,t=i.value.isEuler!==void 0,s=i.value.elements!==void 0,n=i.step!==void 0?i.step:.01,a=[];if(t){const r=v.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(l=>{const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("span",{ref:d,children:l.substring(1).toUpperCase()}),c.jsx(K,{value:L.radToDeg(r[l]),type:"number",prop:l,step:.1,labelRef:d,onChange:(h,u)=>{r[h]=L.degToRad(u),i.onChange({target:{value:r}})}})]},l))})}else if(e){const r=v.useMemo(()=>i.value,[]),o=(d,h)=>{r[d]=h,i.onChange({target:{value:r}})};["x","y","z"].forEach(d=>{const h=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:h,children:d.toUpperCase()}),c.jsx(K,{value:r[d],type:"number",prop:d,step:n,labelRef:h,onChange:o})]},d))})}else if(s){const r=v.useMemo(()=>i.value,[]),o=(l,d)=>{const h=Number(l);r.elements[h]=d,i.onChange({target:{value:r}})};for(let l=0;l<9;l++){const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:d,children:l+1}),c.jsx(K,{value:r.elements[l],type:"number",prop:l.toString(),step:n,labelRef:d,onChange:o})]},l.toString()))}}return c.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Ni(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=v.useMemo(()=>i.value,[]),a=(o,l)=>{n[o]=l,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const l=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("label",{ref:l,children:o.toUpperCase()}),c.jsx(K,{value:n[o],type:"number",prop:o,step:t,labelRef:l,onChange:a})]},o))})}else{const n=v.useMemo(()=>i.value,[]),a=(r,o)=>{const l=Number(r);n.elements[l]=o,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const o=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("span",{ref:o,children:r+1}),c.jsx(K,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:a})]},r.toString()))}}return c.jsx("div",{className:"grid4",children:s})}function Li(i){return!(i==="defaultAttributeValues"||i==="forceSinglePass"||i==="linecap"||i==="linejoin"||i==="linewidth"||i==="normalMapType"||i==="precision"||i==="shadowSide"||i==="uniformsGroups"||i==="uniformsNeedUpdate"||i==="userData"||i==="version"||i==="wireframeLinecap"||i==="wireframeLinejoin"||i==="wireframeLinewidth"||i.slice(0,4)==="clip"||i.slice(0,7)==="polygon"||i.slice(0,7)==="stencil"||i.slice(0,2)==="is")}function _i(i){switch(i){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return i}function be(i){switch(i){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return i}function lt(i){const e=i.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function Ui(){const i=document.createElement("input");return i.type="file",new Promise((e,t)=>{i.addEventListener("change",function(){if(i.files===null)t();else{const s=i.files[0],n=new FileReader;n.onload=function(a){e(a.target.result)},n.readAsDataURL(s)}}),i.click()})}const Gi=[{title:"Front",value:p.FrontSide},{title:"Back",value:p.BackSide},{title:"Double",value:p.DoubleSide}],Fi=[{title:"No Blending",value:p.NoBlending},{title:"Normal",value:p.NormalBlending},{title:"Additive",value:p.AdditiveBlending},{title:"Subtractive",value:p.SubtractiveBlending},{title:"Multiply",value:p.MultiplyBlending},{title:"Custom",value:p.CustomBlending}],Bi=[{title:"Add",value:p.AddEquation},{title:"Subtract",value:p.SubtractEquation},{title:"Reverse Subtract",value:p.ReverseSubtractEquation},{title:"Min",value:p.MinEquation},{title:"Max",value:p.MaxEquation}],Vi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:p.SrcAlphaSaturateFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}],Hi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}];function se(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Wi(i,e,t,s){return{type:"boolean",title:be(i),prop:i,value:e,needsUpdate:!0,onChange:(n,a)=>{s.updateObject(t.uuid,`material.${i}`,a),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",t.uuid);I(o,`material.${i}`,a)}}}}function zi(i,e,t,s){const n={type:"number",title:be(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);I(l,`material.${i}`,r)}}};switch(i){case"blending":se(n,Fi);break;case"blendDst":se(n,Hi);break;case"blendEquation":se(n,Bi);break;case"blendSrc":se(n,Vi);break;case"side":se(n,Gi);break}return lt(i)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function qi(i,e,t,s){const n={type:"string",title:be(i),prop:i,value:e,needsUpdate:!0,onChange:(r,o)=>{s.updateObject(t.uuid,`material.${i}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);I(d,`material.${i}`,o)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.type="field",n.disabled=!1,n.latest=n.value,n.onChange=(r,o)=>{n.latest=o,s.updateObject(t.uuid,`material.${i}`,o);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);I(d,`material.${i}`,o)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);I(l,"material.needsUpdate",!0)}}}),n}function $i(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Ki(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Yi(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Re(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Z(i,e,t,s,n="",a=!1){const r=be(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,l=typeof e;if(l==="object"&&e!==null&&e.__isUniform===!0)return Z(`${i}.value`,e.value,t,s,n,a);if(l==="boolean"||l==="string")return{title:r,prop:o,type:l,value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(l==="number"){const d={title:r,prop:o,type:"number",value:e,step:.01,disabled:a,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);I(f,`material.${o}`,u)}}};return lt(r)&&(d.type="range",d.min=0,d.max=1),d}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:a,onChange:(d,h)=>{const u=new p.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);I(f,`material.${o}`,u)}}};if(Array.isArray(e)){const d=[];for(const h in e){const u=e[h],m=`[${h.toString()}]`;if(u.value!==void 0){const f=Z(`${m}.value`,u.value,t,s,o,a);f!==void 0&&d.push(f)}else{const f=Z(m,u,t,s,o,a);f!==void 0&&d.push(f)}}if(d.length>0)return Re(d),{title:r,items:d}}else{if($i(e))return{title:r,prop:o,type:"vector2",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(Ki(e))return{title:r,prop:o,type:"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(Yi(e))return{title:r,prop:o,type:"grid4",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(d,h)=>{const u=_i(i),m=n.length>0?`${n}.${u}`:u;s.createTexture(t.uuid,`material.${m}`,h);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);if(y!==void 0){const g=S=>{const O=y.material,M=m.split(".");switch(M.length){case 1:O[M[0]]=S;break;case 2:O[M[0]][M[1]]=S;break;case 3:O[M[0]][M[1]][M[2]]=S;break;case 4:O[M[0]][M[1]][M[2]][M[3]]=S;break;case 5:O[M[0]][M[1]][M[2]][M[3]][M[4]]=S;break}O.needsUpdate=!0};h.src.length>0?nt(h.src).then(S=>{S.offset.set(h.offset[0],h.offset[1]),S.repeat.set(h.repeat[0],h.repeat[1]),g(S)}):g(null)}}}};if(e.elements!==void 0)return{title:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);I(m,`material.${o}`,h)}}};{const d=[],h=i==="defines"||i==="extensions";try{for(const u in e){const m=e[u];if(m!==void 0)if(m.value!==void 0){const f=Z(`${u}.value`,m.value,t,s,o,h);f!==void 0&&d.push(f)}else{const f=Z(u,m,t,s,o,h);f!==void 0&&d.push(f)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(d.length>0)return Re(d),{title:r,items:d}}}}}function Ve(i,e,t){const s=[];for(const n in i){if(!Li(n)||n.search("Node")>-1||i[n]instanceof b.ComputeNode)continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Wi(n,r,e,t));else if(a==="number")s.push(zi(n,r,e,t));else if(a==="string")s.push(qi(n,r,e,t));else if(a==="object"){const o=Z(n,r,e,t);o!==void 0&&s.push(o)}else r!==void 0&&console.log("Hermes - Other Material Prop Type:",n,a,r)}return Re(s),s.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const n=t.getScene(e.uuid);if(n!==null){const a=n.getObjectByProperty("uuid",e.uuid);I(a,"material.needsUpdate",!0)}}}),s}function Ji(i,e){function t(){return`${e.name}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=i.material;if(Array.isArray(r)){const o=[],l=r.length;for(let d=0;d<l;d++)o.push(c.jsx(G,{three:e,title:`Material ${d}`,items:Ve(r[d],i,e)},`Material ${d}`));return c.jsx(c.Fragment,{children:o})}else return c.jsx(G,{three:e,title:"Material",items:Ve(r,i,e),expanded:n,onToggle:o=>{a(o)}})}const He="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function Xi(i){const e=i.step!==void 0?i.step:.01,t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),[o]=v.useState(i.value),[l,d]=v.useState(i.value.offset[0]),[h,u]=v.useState(i.value.offset[1]),[m,f]=v.useState(i.value.repeat[0]),[y,g]=v.useState(i.value.repeat[1]);function S(M,T,R,D,V){if(i.onChange!==void 0){const H=i.prop!==void 0?i.prop:i.title;i.onChange(H,{src:M,offset:[T,R],repeat:[D,V]})}}function O(M){const T=t.current.src,R=M.target.value;switch(M.target){case s.current:d(R),S(T,R,h,m,y);break;case n.current:u(R),S(T,l,R,m,y);break;case a.current:f(R),S(T,l,h,R,y);break;case r.current:g(R),S(T,l,h,m,R);break}}return c.jsxs("div",{className:"imageField",children:[c.jsx("img",{alt:i.title,ref:t,onClick:()=>{Ui().then(M=>{t.current.src=M,S(M,l,h,m,y)})},src:o.src.length>0?o.src:He}),c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{children:"Offset:"}),c.jsx("input",{ref:s,type:"number",value:l,step:e,name:k(),onChange:O}),c.jsx("input",{ref:n,type:"number",value:h,step:e,name:k(),onChange:O})]}),c.jsxs("div",{children:[c.jsx("span",{children:"Repeat:"}),c.jsx("input",{ref:a,type:"number",value:m,step:e,name:k(),onChange:O}),c.jsx("input",{ref:r,type:"number",value:y,step:e,name:k(),onChange:O})]}),c.jsx("button",{onClick:()=>{S("",l,h,m,y),t.current.src=He},children:"Clear"})]})]})}function pe(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=Ee(i.value):i.type==="color"&&(e=Ee(new p.Color().setStyle(i.value,p.LinearSRGBColorSpace))));const[t,s]=v.useState(e),n=v.useRef(null);v.useEffect(()=>{s(e)},[e]);const a=h=>{let u=h.target.value;if(i.type==="boolean")u=h.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==u;f++);}s(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},r={};i.disabled&&(r.opacity=.8);const o=typeof t=="string"?t:String(t??""),l=i.type==="field"||i.type==="string"&&(o.length>100||o.search(`
16
- `)>-1),d=l||i.type==="image"||i.type==="vector2";return c.jsxs("div",{className:`field ${d?"block":""}`,style:r,children:[i.type!=="button"&&c.jsx("span",{ref:n,children:ce(i.title)},"fieldLabel"),i.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t,name:k()}),(i.type==="field"||i.type==="string"&&l)&&c.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:h=>{i.onKeyDown!==void 0&&i.onKeyDown(h)},value:t,name:k()}),i.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t,name:k()}),i.type==="number"&&c.jsx(K,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="range"&&c.jsx(K,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color",name:k()}),c.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled,name:k()})]}),i.type==="button"&&c.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&c.jsx(Xi,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&c.jsx(c.Fragment,{children:c.jsx("select",{onChange:a,disabled:i.disabled,value:t,name:k(),children:i.options?.map((h,u)=>c.jsx("option",{value:h.value,children:ce(h.title)},u))})}),i.type==="vector2"&&c.jsx(ji,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&c.jsx(Be,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&c.jsx(Ni,{step:i.step,value:t,onChange:a}),i.type==="euler"&&c.jsx(Be,{step:i.step,value:t,onChange:a})]})}function Qi(i){return"items"in i}class G extends v.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;three;constructor(e){super(e),this.three=e.three,this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,o)=>{e.onUpdate(r,o)}})});const s=v.createRef(),n=c.jsx(G,{three:this.props.three,ref:s,title:e.title,expanded:e.expanded,items:t},e.title);return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(Qi(t))e.push(c.jsx(G,{three:this.props.three,title:ce(t.title),items:t.items},t.title));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(c.jsx(pe,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},t.title))}}),this.subgroupElements.forEach(t=>e.push(t)),c.jsx(te,{three:this.props.three,label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class A extends v.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static three;constructor(e){super(e),this.state={lastUpdate:Date.now()},A.instance=this,A.three=e.three,e.three.addEventListener(w.ADD_GROUP,this.addGroup),e.three.addEventListener(w.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){this.props.three.removeEventListener(w.ADD_GROUP,this.addGroup),this.props.three.removeEventListener(w.REMOVE_GROUP,this.removeGroup)}render(){return c.jsx("div",{className:"customGroups",children:A.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(n=>{s.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),A.groups.push(c.jsx(G,{three:this.props.three,title:t.title,items:s},t.title)),A.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=A.groupTitles.length;for(let n=0;n<s;n++)if(t===A.groupTitles[n]){A.groups.splice(n,1),A.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=A.groupTitles.length;for(let r=0;r<t;r++)if(A.groupTitles[r]===e.title)return A.groupsRefs[r];const s=[];e.items.forEach(r=>{s.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(o,l)=>{e.onUpdate(o,l)}})}),e.subgroups&&e.subgroups.length>0&&e.subgroups.forEach(r=>{const o=[];r.items.forEach(l=>{o.push({type:l.type,prop:l.prop,title:l.title!==void 0?l.title:l.prop,value:l.value,min:l.min,max:l.max,step:l.step,options:l.options,disabled:l.disabled,onChange:(d,h)=>{r.onUpdate(d,h)}})}),s.push({three:A.three,title:r.title,expanded:r.expanded,items:o})});const n=v.createRef(),a=c.jsx(G,{three:A.three,ref:n,title:e.title,expanded:e.expanded,items:s},e.title);return A.groups.push(a),A.groupsRefs.push(n),A.groupTitles.push(e.title),setTimeout(()=>{A.instance?.setState({lastUpdate:Date.now()})},0),n}static removeEditorGroup(e){const t=A.groupTitles.length;for(let s=0;s<t;s++)if(e===A.groupTitles[s]){A.groups.splice(s,1),A.groupTitles.splice(s,1),A.instance?.setState({lastUpdate:Date.now()});return}}static removeAllGroups(){A.groups=[],A.groupTitles=[],A.groupsRefs=[],A.instance?.setState({lastUpdate:Date.now()})}}function We(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function Zi(i,e){function t(){return`${e.name}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const o in i.perspectiveCameraInfo)r.push({title:We(o),prop:o,type:"number",step:.01,value:i.perspectiveCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(I(u,l,d),u.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const o in i.orthographicCameraInfo)r.push({title:We(o),prop:o,type:"number",step:.01,value:i.orthographicCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(I(u,l,d),u.updateProjectionMatrix())}}});return c.jsx(G,{three:e,title:"Camera",items:r,expanded:n,onToggle:o=>{a(o)}})}const ge=i=>{const[e,t]=v.useState(i.options[i.index]),s=()=>{i.onToggle(!i.open)},n=r=>{r!==e&&(i.onSelect(r),t(r)),i.onToggle(!1)},a=i.open?`${i.options.length*31-1}px`:"0px";return c.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),c.jsx("ul",{className:"dropdown-menu",style:{height:a},children:i.options.map(r=>c.jsx("li",{onClick:()=>n(r),children:r},r))})]})},$=v.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=v.useState("Renderer"),[r,o]=v.useState(!1),[l,d]=v.useState(!1),[h,u]=v.useState(!1);return c.jsxs("div",{className:`CameraWindow ${e.name}`,children:[c.jsx("div",{ref:t,className:"clickable",onClick:()=>{h&&u(!1)}}),c.jsxs("div",{className:"options",children:[e.camera!==null&&c.jsx(ge,{title:"Camera",index:e.options.indexOf(e.camera.name),open:h,options:e.options,onSelect:e.onSelectCamera,onToggle:m=>{m&&l&&d(!1),u(m)},up:!0}),c.jsx(ge,{title:"Mode",index:s.indexOf(n),open:l,options:s,onSelect:m=>{if(m===n)return;const f=m;e.onSelectRenderMode(f),a(f)},onToggle:m=>{m&&h&&u(!1),r&&o(!1),d(m)},up:!0})]})]})}),es=`out vec3 worldPosition;
15
+ C11,8.22,10.74,8,10.43,8z`})});function it(i){return c.jsx("li",{className:`reorder-item ${i.draggingIndex===i.index?"dragging":""}`,draggable:!0,onDragStart:()=>i.onDragStart(i.index),onDragOver:e=>{e.preventDefault(),i.onDragOver(i.index)},onDragEnd:i.onDragEnd,children:c.jsxs("div",{children:[Oi,c.jsx("span",{children:i.title}),c.jsx("button",{className:"closeIcon",onClick:()=>i.onDelete(i.index),children:Ai})]})})}function st(i){const[e,t]=v.useState(!1),[s,n]=v.useState(i.options),[a,r]=v.useState(null),o=f=>{i.onDragComplete(f),n(f)},l=f=>{const y=[...s];y.splice(f,1),o(y)},d=f=>{r(f)},h=f=>{if(a===f||a===null)return;const y=[...s],g=y.splice(a,1)[0];y.splice(f,0,g),r(f),n(y)},u=()=>{i.onDragComplete(s),r(null)};let m="dropdown draggable";return i.subdropdown&&(m+=" subdropdown"),c.jsxs("div",{className:m,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(Te,{title:i.title}),c.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((f,y)=>c.jsx(it,{title:f,index:y,draggingIndex:a,onDelete:l,onDragStart:d,onDragOver:h,onDragEnd:u},f))})]})}function nt(i){const[e,t]=v.useState(!1),s=[];i.options.map((a,r)=>{i.onSelect!==void 0&&(a.onSelect=i.onSelect),s.push(c.jsx(rt,{option:a},r))});let n="dropdown";return i.subdropdown&&(n+=" subdropdown"),c.jsxs("div",{className:n,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[c.jsx(Te,{title:i.title}),c.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function rt(i){const{option:e}=i,[t,s]=v.useState("");let n;switch(e.type){case"draggable":n=c.jsx(st,{title:e.title,options:e.value,onDragComplete:a=>{e.onDragComplete!==void 0&&e.onDragComplete(a)},subdropdown:!0});break;case"dropdown":n=c.jsx(nt,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":n=c.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return c.jsx("li",{className:t===e.title?"selected":"",children:n},k())}function ee(i){const[e,t]=v.useState(i.open!==void 0?i.open:!1),[s,n]=v.useState(i.visible!==void 0?i.visible:!1),a=!e||i.children===void 0,r=()=>{i.three.dispatchEvent({type:w.REMOVE_SCENE,value:i.scene})};return c.jsxs("div",{className:`accordion ${a?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const o=!e;i.onToggle!==void 0&&i.onToggle(o),t(o)},children:[c.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:oe(i.label)})]}),i.onRefresh?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"visibility",style:{opacity:s?1:.25},onClick:()=>{const l=i.three.getScene(i.scene.uuid);if(l){const d=!l.visible;l.visible=d,n(d)}}}),c.jsx("button",{className:"refresh",onClick:i.onRefresh}),c.jsx("button",{className:"remove",onClick:r})]}):null,i.button,c.jsx("div",{className:e?"open":"",children:c.jsx("div",{children:i.children})})]})}function Ri(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 at(i){const e={name:i.name,type:i.type,uuid:i.uuid,children:[]};return i.children.forEach(t=>{e.children.push(at(t))}),e}function Le(i){return{src:i.image?.src??"",offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}}const _e={src:"",offset:[0,0],repeat:[1,1]};function Ii(i){const e={};for(const t in i){const s=i[t];if(s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")){const a=s.value;a==null?e[t]={value:_e}:a.isTexture?e[t]={value:Le(a)}:e[t]={value:a}}else s==null?e[t]=_e:s.isTexture?e[t]=Le(s):e[t]=s}return e}function Ti(i){switch(i){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function X(i){const e={};for(const t in i){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||Ti(t))continue;const s=typeof i[t],n=i[t];switch(s){case"boolean":case"number":case"string":e[t]=n;break;case"object":if(n!==null)if(n.isTexture)e[t]={src:B.renderToBlob(n),offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]};else if(n.isUniformNode){const a=n.value;e[t]={__isUniform:!0,value:a?.isTexture?{src:B.renderToBlob(a),offset:[a.offset.x,a.offset.y],repeat:[a.repeat.x,a.repeat.y]}:a}}else t==="uniforms"?e[t]=Ii(n):t.search("Node")>-1||(e[t]=n);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(e[t]={src:"",offset:[0,0],repeat:[1,1]});break}}return i.anisotropy!==void 0&&(e.anisotropy=i.anisotropy),i.clearcoat!==void 0&&(e.clearcoat=i.clearcoat),i.iridescence!==void 0&&(e.iridescence=i.iridescence),i.dispersion!==void 0&&(e.dispersion=i.dispersion),i.sheen!==void 0&&(e.sheen=i.sheen),i.transmission!==void 0&&(e.transmission=i.transmission),i.transmission!==void 0&&(e.transmission=i.transmission),e}function Pi(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(X(a))}),e.material=n}else e.material=X(s.material)}else if(t.search("points")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(X(a))}),e.material=n}else e.material=X(s.material)}else if(t.search("line")>-1){const s=i;if(Array.isArray(s.material)){const n=[];s.material.forEach(a=>{n.push(X(a))}),e.material=n}else e.material=X(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 ki(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 Di(i,e){for(const t in e)i[t]=e[t]}function T(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?Di(r,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function ot(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>{const n=new p.Texture(s);n.wrapS=p.RepeatWrapping,n.wrapT=p.RepeatWrapping,n.needsUpdate=!0,e(n)},s.onerror=t,s.src=i})}function Pe(i){if(i.child===void 0)return console.log("Hermes - No child attached"),null;const e=v.useRef(null),[t,s]=v.useState(!1),n=i.child.children.length>0,a=[];return i.child.children.length>0&&i.child.children.map((r,o)=>{a.push(c.jsx(Pe,{child:r,three:i.three},o))}),v.useEffect(()=>{if(i.child){const r=i.child.uuid.split(".")[0],o=i.three.getScene(r);if(o!==null)try{const l=o.getObjectByProperty("uuid",i.child.uuid);l!==void 0?e.current.style.opacity=l.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${i.child.uuid}`)}catch(l){console.log("Error looking for child:",l),console.log(i.child),console.log(i.three.scenes),console.log(o)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${r} with child UUID: ${i.child.uuid}`,i.three.scenes,i.three.scene,o)}},[t]),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[n?c.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,c.jsx("button",{className:"name",style:{left:n?"20px":"5px"},onClick:()=>{i.child!==void 0?(i.three.getObject(i.child.uuid),!t&&n&&s(!0)):console.log("Hermes - No child attached...")},children:i.child.name.length>0?`${i.child.name} (${i.child.type})`:`${i.child.type}::${i.child.uuid}`}),c.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(i.child){const r=i.three.getScene(i.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",i.child.uuid);if(o!==void 0){const l="visible",d=!o.visible;e.current.style.opacity=d?"1":"0.25",i.three.updateObject(i.child.uuid,l,d),T(o,l,d)}else console.log(`Hermes - Couldn't find object: ${i.child.uuid}`,r)}else console.log(`Hermes - Couldn't find object in scene: ${i.child.uuid}, ${i.child.name}`)}}}),c.jsx("div",{className:`icon ${Ri(i.child)}`})]}),c.jsx("div",{className:t?"open":"",children:c.jsx("div",{className:"container",children:a})})]})}function he(i){const e=[];return i.child?.children.map((t,s)=>{e.push(c.jsx(Pe,{child:t,scene:i.scene,three:i.three},s))}),c.jsx("div",{className:`scene ${i.class!==void 0?i.class:""}`,children:e})}function ne(i){const[e,t]=v.useState(i.defaultValue);return v.useEffect(()=>{let s=!1,n=-1,a=0,r=i.defaultValue,o=!1;const l=f=>{o=f.ctrlKey},d=f=>{s=!0,a=Number(i.input.current?.value),n=f.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=f=>{if(!s)return;const y=i.step!==void 0?i.step:1,g=(f.clientX-n)*y*(o?10:1);r=Number((a+g).toFixed(4)),i.min!==void 0&&(r=Math.max(r,i.min)),i.max!==void 0&&(r=Math.min(r,i.max)),i.onChange!==void 0&&i.onChange(r),t(r)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},m=f=>{const y=Number(f.target.value);i.onChange!==void 0&&i.onChange(y),t(y)};return i.label.current?.addEventListener("mousedown",d,!1),i.sliderRef!==void 0&&i.sliderRef.current?.addEventListener("input",m),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{i.label.current?.removeEventListener("mousedown",d),i.sliderRef!==void 0&&i.sliderRef.current?.removeEventListener("input",m),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function $(i){const e=v.useRef(null),t=v.useRef(null),[s,n]=v.useState(i.value);return ne({label:i.labelRef,input:e,sliderRef:t,defaultValue:s,min:i.min,max:i.max,step:i.step,onChange:a=>{n(a),i.onChange!==void 0&&i.onChange(i.prop,a)}}),c.jsxs(c.Fragment,{children:[i.type==="number"&&c.jsx("input",{alt:i.alt,className:i.className,ref:e,type:"number",value:s,min:i.min,max:i.max,step:i.step,disabled:i.disabled,name:k(),onChange:a=>{if(n(a.target.value),a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||i.onChange!==void 0&&i.onChange(i.prop,r)}}),i.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:s.toString(),disabled:i.disabled,ref:e,className:"min",name:k(),onChange:a=>{if(a.target.value.length===0)return;const r=Number(a.target.value);isNaN(r)||(n(r),i.onChange!==void 0&&i.onChange(i.prop,r))}}),c.jsx("input",{disabled:i.disabled,type:"range",value:s,min:i.min,max:i.max,step:i.step,ref:t,name:k(),onChange:ae})]})]})}function ji(i){const e=v.useRef(null),t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),o=v.useRef(null),l=v.useRef(null),d=v.useRef(null),h=v.useRef(null),[u,m]=v.useState(i.value.x),[f,y]=v.useState(i.value.y),[g,S]=v.useState({min:Math.min(i.min,Math.min(i.value.x,i.value.y)),max:Math.max(i.max,Math.max(i.value.x,i.value.y))}),[O,M]=v.useState(!1);ne({label:o,input:e,defaultValue:u,min:g.min,max:g.max,step:.01,onChange:E=>{m(E),i.onChange({target:{value:{x:E,y:f}}})}}),ne({label:l,input:t,defaultValue:f,min:g.min,max:g.max,step:.01,onChange:E=>{y(E),i.onChange({target:{value:{x:u,y:E}}})}}),ne({label:d,input:s,defaultValue:g.min,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:E,max:g.max})}}),ne({label:h,input:n,defaultValue:g.max,min:g.min-1,max:g.max+1,step:.01,onChange:E=>{S({min:g.min,max:E})}});function I(){O||(window.addEventListener("mousemove",D),window.addEventListener("mouseup",R),M(!0))}function R(){window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",R),M(!1)}function D(E){const j=a.current.getBoundingClientRect(),ce=W(0,99,E.clientX-j.left)/99,bt=1-W(0,99,E.clientY-j.top)/99,De=L(te(g.min,g.max,ce),3),je=L(te(g.min,g.max,bt),3);i.onChange({target:{value:{x:De,y:je}}}),m(De),y(je)}function V(){const E=Number(s.current.value);S({min:E,max:g.max}),u<E&&m(W(E,g.max,u)),f<E&&y(W(E,g.max,f))}function H(){const E=Number(n.current.value);S({min:g.min,max:E}),u>E&&m(W(g.min,E,u)),f>E&&y(W(g.min,E,f))}v.useEffect(()=>{r.current.style.left=`${me(g.min,g.max,u)*100}%`,r.current.style.top=`${(1-me(g.min,g.max,f))*100}%`},[g,u,f]);const G=i.step!==void 0?i.step:.01;return c.jsxs("div",{className:"vector2",children:[c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{ref:o,children:"X"}),c.jsx("input",{ref:e,type:"number",value:u,min:g.min,max:g.max,step:G,name:k(),onChange:E=>{if(m(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:j,y:f}}}),j<g.min&&S({min:j,max:g.max}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:l,children:"Y"}),c.jsx("input",{ref:t,type:"number",value:f,min:g.min,max:g.max,step:G,name:k(),onChange:E=>{if(y(E.target.value),E.target.value.length===0)return;const j=Number(E.target.value);isNaN(j)||(i.onChange({target:{value:{x:u,y:j}}}),j>g.max&&S({min:g.min,max:j}))}})]}),c.jsxs("div",{children:[c.jsx("span",{ref:d,children:"Min"}),c.jsx("input",{ref:s,type:"number",value:g.min,step:G,name:k(),onChange:V})]}),c.jsxs("div",{children:[c.jsx("span",{ref:h,children:"Max"}),c.jsx("input",{ref:n,type:"number",value:g.max,step:G,name:k(),onChange:H})]})]}),c.jsxs("div",{className:"input",ref:a,onMouseDown:I,onMouseUp:R,children:[c.jsx("div",{className:"x"}),c.jsx("div",{className:"y"}),c.jsx("div",{className:"pt",ref:r})]})]})}function Fe(i){const e=i.value.x!==void 0&&i.value.y!==void 0&&i.value.z!==void 0,t=i.value.isEuler!==void 0,s=i.value.elements!==void 0,n=i.step!==void 0?i.step:.01,a=[];if(t){const r=v.useMemo(()=>i.value,[]);["_x","_y","_z"].forEach(l=>{const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("span",{ref:d,children:l.substring(1).toUpperCase()}),c.jsx($,{value:U.radToDeg(r[l]),type:"number",prop:l,step:.1,labelRef:d,onChange:(h,u)=>{r[h]=U.degToRad(u),i.onChange({target:{value:r}})}})]},l))})}else if(e){const r=v.useMemo(()=>i.value,[]),o=(d,h)=>{r[d]=h,i.onChange({target:{value:r}})};["x","y","z"].forEach(d=>{const h=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:h,children:d.toUpperCase()}),c.jsx($,{value:r[d],type:"number",prop:d,step:n,labelRef:h,onChange:o})]},d))})}else if(s){const r=v.useMemo(()=>i.value,[]),o=(l,d)=>{const h=Number(l);r.elements[h]=d,i.onChange({target:{value:r}})};for(let l=0;l<9;l++){const d=v.useRef(null);a.push(c.jsxs("div",{children:[c.jsx("label",{ref:d,children:l+1}),c.jsx($,{value:r.elements[l],type:"number",prop:l.toString(),step:n,labelRef:d,onChange:o})]},l.toString()))}}return c.jsx("div",{className:"grid3",children:a},Math.random().toString())}function Ni(i){const e=i.value.x!==void 0,t=i.step!==void 0?i.step:.01,s=[];if(e){const n=v.useMemo(()=>i.value,[]),a=(o,l)=>{n[o]=l,i.onChange({target:{value:n}})};["x","y","z","w"].forEach(o=>{const l=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("label",{ref:l,children:o.toUpperCase()}),c.jsx($,{value:n[o],type:"number",prop:o,step:t,labelRef:l,onChange:a})]},o))})}else{const n=v.useMemo(()=>i.value,[]),a=(r,o)=>{const l=Number(r);n.elements[l]=o,i.onChange({target:{value:n}})};for(let r=0;r<16;r++){const o=v.useRef(null);s.push(c.jsxs("div",{children:[c.jsx("span",{ref:o,children:r+1}),c.jsx($,{value:n.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:a})]},r.toString()))}}return c.jsx("div",{className:"grid4",children:s})}function Ui(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 Li(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 ve(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 ct(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 _i(){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 Fi=[{title:"Front",value:p.FrontSide},{title:"Back",value:p.BackSide},{title:"Double",value:p.DoubleSide}],Gi=[{title:"No Blending",value:p.NoBlending},{title:"Normal",value:p.NormalBlending},{title:"Additive",value:p.AdditiveBlending},{title:"Subtractive",value:p.SubtractiveBlending},{title:"Multiply",value:p.MultiplyBlending},{title:"Custom",value:p.CustomBlending}],Bi=[{title:"Add",value:p.AddEquation},{title:"Subtract",value:p.SubtractEquation},{title:"Reverse Subtract",value:p.ReverseSubtractEquation},{title:"Min",value:p.MinEquation},{title:"Max",value:p.MaxEquation}],Vi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:p.SrcAlphaSaturateFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}],Hi=[{title:"Zero",value:p.ZeroFactor},{title:"One",value:p.OneFactor},{title:"Src Color",value:p.SrcColorFactor},{title:"One Minus Src Color",value:p.OneMinusSrcColorFactor},{title:"Src Alpha",value:p.SrcAlphaFactor},{title:"One Minus Src Alpha",value:p.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:p.DstAlphaFactor},{title:"One Minus Dst Alpha",value:p.OneMinusDstAlphaFactor},{title:"Dst Color",value:p.DstColorFactor},{title:"One Minus Dst Color",value:p.OneMinusDstColorFactor},{title:"Constant Color",value:p.ConstantColorFactor},{title:"One Minus Constant Color",value:p.OneMinusConstantColorFactor},{title:"Constant Alpha",value:p.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:p.OneMinusConstantAlphaFactor}];function ie(i,e){i.needsUpdate=!0,i.type="option",i.options=e}function Wi(i,e,t,s){return{type:"boolean",title:ve(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);T(o,`material.${i}`,a)}}}}function zi(i,e,t,s){const n={type:"number",title:ve(i),prop:i,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(a,r)=>{s.updateObject(t.uuid,`material.${i}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);T(l,`material.${i}`,r)}}};switch(i){case"blending":ie(n,Gi);break;case"blendDst":ie(n,Hi);break;case"blendEquation":ie(n,Bi);break;case"blendSrc":ie(n,Vi);break;case"side":ie(n,Fi);break}return ct(i)&&(n.value=Number(e),n.type="range",n.min=Math.min(0,n.value),n.max=Math.max(1,n.value),n.step=.01),n}function qi(i,e,t,s){const n={type:"string",title:ve(i),prop:i,value:e,needsUpdate:!0,onChange:(r,o)=>{s.updateObject(t.uuid,`material.${i}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);T(d,`material.${i}`,o)}},onKeyDown:r=>{}};return(i==="vertexShader"||i==="fragmentShader")&&(n.type="field",n.disabled=!1,n.latest=n.value,n.onChange=(r,o)=>{n.latest=o,s.updateObject(t.uuid,`material.${i}`,o);const l=s.getScene(t.uuid);if(l!==null){const d=l.getObjectByProperty("uuid",t.uuid);T(d,`material.${i}`,o)}},n.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);T(l,"material.needsUpdate",!0)}}}),n}function $i(i){return i.x!==void 0&&i.y!==void 0&&i.z===void 0}function Ki(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w===void 0}function Yi(i){return i.x!==void 0&&i.y!==void 0&&i.z!==void 0&&i.w!==void 0}function Ae(i){i.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Q(i,e,t,s,n="",a=!1){const r=ve(i).split(".")[0].replaceAll("[","").replaceAll("]",""),o=n.length>0?`${n}.${i}`:i,l=typeof e;if(l==="object"&&e!==null&&e.__isUniform===!0)return Q(`${i}.value`,e.value,t,s,n,a);if(l==="boolean"||l==="string")return{title:r,prop:o,type:l,value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};if(l==="number"){const d={title:r,prop:o,type:"number",value:e,step:.01,disabled:a,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);T(f,`material.${o}`,u)}}};return ct(r)&&(d.type="range",d.min=0,d.max=1),d}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:a,onChange:(d,h)=>{const u=new p.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const m=s.getScene(t.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",t.uuid);T(f,`material.${o}`,u)}}};if(Array.isArray(e)){const d=[];for(const h in e){const u=e[h],m=`[${h.toString()}]`;if(u.value!==void 0){const f=Q(`${m}.value`,u.value,t,s,o,a);f!==void 0&&d.push(f)}else{const f=Q(m,u,t,s,o,a);f!==void 0&&d.push(f)}}if(d.length>0)return Ae(d),{title:r,items:d}}else{if($i(e))return{title:r,prop:o,type:"vector2",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};if(Ki(e))return{title:r,prop:o,type:"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};if(Yi(e))return{title:r,prop:o,type:"grid4",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:a,onChange:(d,h)=>{const u=Li(i),m=n.length>0?`${n}.${u}`:u;s.createTexture(t.uuid,`material.${m}`,h);const f=s.getScene(t.uuid);if(f!==null){const y=f.getObjectByProperty("uuid",t.uuid);if(y!==void 0){const g=S=>{const O=y.material,M=m.split(".");switch(M.length){case 1:O[M[0]]=S;break;case 2:O[M[0]][M[1]]=S;break;case 3:O[M[0]][M[1]][M[2]]=S;break;case 4:O[M[0]][M[1]][M[2]][M[3]]=S;break;case 5:O[M[0]][M[1]][M[2]][M[3]][M[4]]=S;break}O.needsUpdate=!0};h.src.length>0?ot(h.src).then(S=>{S.offset.set(h.offset[0],h.offset[1]),S.repeat.set(h.repeat[0],h.repeat[1]),g(S)}):g(null)}}}};if(e.elements!==void 0)return{title:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:a,onChange:(d,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",t.uuid);T(m,`material.${o}`,h)}}};{const d=[],h=i==="defines"||i==="extensions";try{for(const u in e){const m=e[u];if(m!==void 0)if(m.value!==void 0){const f=Q(`${u}.value`,m.value,t,s,o,h);f!==void 0&&d.push(f)}else{const f=Q(u,m,t,s,o,h);f!==void 0&&d.push(f)}}}catch{console.log("Hermes - Issue cycling through material object:",i,e)}if(d.length>0)return Ae(d),{title:r,items:d}}}}}function Ge(i,e,t){const s=[];for(const n in i){if(!Ui(n)||n.search("Node")>-1||i[n]instanceof b.ComputeNode)continue;const a=typeof i[n],r=i[n];if(a==="boolean")s.push(Wi(n,r,e,t));else if(a==="number")s.push(zi(n,r,e,t));else if(a==="string")s.push(qi(n,r,e,t));else if(a==="object"){const o=Q(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 Ae(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);T(a,"material.needsUpdate",!0)}}}),s}function Ji(i,e){function t(){return`${e.name}_material`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=i.material;if(Array.isArray(r)){const o=[],l=r.length;for(let d=0;d<l;d++)o.push(c.jsx(F,{three:e,title:`Material ${d}`,items:Ge(r[d],i,e)},`Material ${d}`));return c.jsx(c.Fragment,{children:o})}else return c.jsx(F,{three:e,title:"Material",items:Ge(r,i,e),expanded:n,onToggle:o=>{a(o)}})}const Be="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function Xi(i){const e=i.step!==void 0?i.step:.01,t=v.useRef(null),s=v.useRef(null),n=v.useRef(null),a=v.useRef(null),r=v.useRef(null),[o]=v.useState(i.value),[l,d]=v.useState(i.value.offset[0]),[h,u]=v.useState(i.value.offset[1]),[m,f]=v.useState(i.value.repeat[0]),[y,g]=v.useState(i.value.repeat[1]);function S(M,I,R,D,V){if(i.onChange!==void 0){const H=i.prop!==void 0?i.prop:i.title;i.onChange(H,{src:M,offset:[I,R],repeat:[D,V]})}}function O(M){const I=t.current.src,R=M.target.value;switch(M.target){case s.current:d(R),S(I,R,h,m,y);break;case n.current:u(R),S(I,l,R,m,y);break;case a.current:f(R),S(I,l,h,R,y);break;case r.current:g(R),S(I,l,h,m,R);break}}return c.jsxs("div",{className:"imageField",children:[c.jsx("img",{alt:i.title,ref:t,onClick:()=>{_i().then(M=>{t.current.src=M,S(M,l,h,m,y)})},src:o.src.length>0?o.src:Be}),c.jsxs("div",{className:"fields",children:[c.jsxs("div",{children:[c.jsx("span",{children:"Offset:"}),c.jsx("input",{ref:s,type:"number",value:l,step:e,name:k(),onChange:O}),c.jsx("input",{ref:n,type:"number",value:h,step:e,name:k(),onChange:O})]}),c.jsxs("div",{children:[c.jsx("span",{children:"Repeat:"}),c.jsx("input",{ref:a,type:"number",value:m,step:e,name:k(),onChange:O}),c.jsx("input",{ref:r,type:"number",value:y,step:e,name:k(),onChange:O})]}),c.jsx("button",{onClick:()=>{S("",l,h,m,y),t.current.src=Be},children:"Clear"})]})]})}function ue(i){let e=i.value;e!==void 0&&(e.isColor!==void 0?e=we(i.value):i.type==="color"&&(e=we(new p.Color().setStyle(i.value,p.LinearSRGBColorSpace))));const[t,s]=v.useState(e),n=v.useRef(null);v.useEffect(()=>{s(e)},[e]);const a=h=>{let u=h.target.value;if(i.type==="boolean")u=h.target.checked;else if(i.type==="option"&&(typeof i.value=="number"?u=Number(u):typeof i.value=="boolean"?u=!!u:typeof i.value=="object"&&(u=JSON.parse(u)),i.options!==void 0)){const m=i.options.length;for(let f=0;f<m&&i.options[f].value!==u;f++);}s(u),i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,u)},r={};i.disabled&&(r.opacity=.8);const o=typeof t=="string"?t:String(t??""),l=i.type==="field"||i.type==="string"&&(o.length>100||o.search(`
16
+ `)>-1),d=l||i.type==="image"||i.type==="vector2";return c.jsxs("div",{className:`field ${d?"block":""}`,style:r,children:[i.type!=="button"&&c.jsx("span",{ref:n,children:oe(i.title)},"fieldLabel"),i.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:i.disabled,onChange:a,value:t,name:k()}),(i.type==="field"||i.type==="string"&&l)&&c.jsx("textarea",{cols:50,rows:10,disabled:i.disabled!==void 0?i.disabled:!0,onChange:a,onKeyDown:h=>{i.onKeyDown!==void 0&&i.onKeyDown(h)},value:t,name:k()}),i.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:i.disabled,onChange:a,checked:t,name:k()}),i.type==="number"&&c.jsx($,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="range"&&c.jsx($,{value:t,type:i.type,prop:i.prop!==void 0?i.prop:i.title,min:i.min,max:i.max,step:i.step,disabled:i.disabled,labelRef:n,onChange:i.onChange}),i.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:t.toString(),onChange:a,disabled:i.disabled,className:"color",name:k()}),c.jsx("input",{type:"color",value:t,onChange:a,disabled:i.disabled,name:k()})]}),i.type==="button"&&c.jsx("button",{disabled:i.disabled,onClick:()=>{i.onChange!==void 0&&i.onChange(i.prop!==void 0?i.prop:i.title,!0)},children:i.title}),i.type==="image"&&c.jsx(Xi,{title:i.title,prop:i.prop,value:i.value,onChange:i.onChange}),i.type==="option"&&c.jsx(c.Fragment,{children:c.jsx("select",{onChange:a,disabled:i.disabled,value:t,name:k(),children:i.options?.map((h,u)=>c.jsx("option",{value:h.value,children:oe(h.title)},u))})}),i.type==="vector2"&&c.jsx(ji,{step:i.step,value:t,min:0,max:1,onChange:a}),i.type==="grid3"&&c.jsx(Fe,{step:i.step,value:t,onChange:a}),i.type==="grid4"&&c.jsx(Ni,{step:i.step,value:t,onChange:a}),i.type==="euler"&&c.jsx(Fe,{step:i.step,value:t,onChange:a})]})}function Qi(i){return"items"in i}class F extends v.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;three;constructor(e){super(e),this.three=e.three,this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(a=>{t.push({type:a.type,prop:a.prop,title:a.title!==void 0?a.title:a.prop,value:a.value,min:a.min,max:a.max,step:a.step,options:a.options,disabled:a.disabled,onChange:(r,o)=>{e.onUpdate(r,o)}})});const s=v.createRef(),n=c.jsx(F,{three:this.props.three,ref:s,title:e.title,expanded:e.expanded,items:t},e.title);return this.subgroupNames.push(e.title),this.subgroupElements.push(n),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const n=this.subgroupNames[s];if(e===n){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(Qi(t))e.push(c.jsx(F,{three:this.props.three,title:oe(t.title),items:t.items},t.title));else{const s=this.valueOverrides.get(t.title),n=s!==void 0?s:t.value;e.push(c.jsx(ue,{title:t.title,prop:t.prop,value:n,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(a,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(a,r))},onKeyDown:a=>{t.onKeyDown!==void 0&&t.onKeyDown(a)}},t.title))}}),this.subgroupElements.forEach(t=>e.push(t)),c.jsx(ee,{three:this.props.three,label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class A extends v.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static three;constructor(e){super(e),this.state={lastUpdate:Date.now()},A.instance=this,A.three=e.three,e.three.addEventListener(w.ADD_GROUP,this.addGroup),e.three.addEventListener(w.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){this.props.three.removeEventListener(w.ADD_GROUP,this.addGroup),this.props.three.removeEventListener(w.REMOVE_GROUP,this.removeGroup)}render(){return c.jsx("div",{className:"customGroups",children:A.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(n=>{s.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(a,r)=>{this.props.three.updateGroup(t.title,a,r)}})}),A.groups.push(c.jsx(F,{three:this.props.three,title:t.title,items:s},t.title)),A.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=A.groupTitles.length;for(let n=0;n<s;n++)if(t===A.groupTitles[n]){A.groups.splice(n,1),A.groupTitles.splice(n,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=A.groupTitles.length;for(let r=0;r<t;r++)if(A.groupTitles[r]===e.title)return A.groupsRefs[r];const s=[];e.items.forEach(r=>{s.push({type:r.type,prop:r.prop,title:r.title!==void 0?r.title:r.prop,value:r.value,min:r.min,max:r.max,step:r.step,options:r.options,disabled:r.disabled,onChange:(o,l)=>{e.onUpdate(o,l)}})}),e.subgroups&&e.subgroups.length>0&&e.subgroups.forEach(r=>{const o=[];r.items.forEach(l=>{o.push({type:l.type,prop:l.prop,title:l.title!==void 0?l.title:l.prop,value:l.value,min:l.min,max:l.max,step:l.step,options:l.options,disabled:l.disabled,onChange:(d,h)=>{r.onUpdate(d,h)}})}),s.push({three:A.three,title:r.title,expanded:r.expanded,items:o})});const n=v.createRef(),a=c.jsx(F,{three:A.three,ref:n,title:e.title,expanded:e.expanded,items:s},e.title);return A.groups.push(a),A.groupsRefs.push(n),A.groupTitles.push(e.title),setTimeout(()=>{A.instance?.setState({lastUpdate:Date.now()})},0),n}static removeEditorGroup(e){const t=A.groupTitles.length;for(let s=0;s<t;s++)if(e===A.groupTitles[s]){A.groups.splice(s,1),A.groupTitles.splice(s,1),A.instance?.setState({lastUpdate:Date.now()});return}}static removeAllGroups(){A.groups=[],A.groupTitles=[],A.groupsRefs=[],A.instance?.setState({lastUpdate:Date.now()})}}function Ve(i){switch(i){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return i}function Zi(i,e){function t(){return`${e.name}_camera`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.perspectiveCameraInfo!==void 0)for(const o in i.perspectiveCameraInfo)r.push({title:Ve(o),prop:o,type:"number",step:.01,value:i.perspectiveCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(T(u,l,d),u.updateProjectionMatrix())}}});else if(i.orthographicCameraInfo!==void 0)for(const o in i.orthographicCameraInfo)r.push({title:Ve(o),prop:o,type:"number",step:.01,value:i.orthographicCameraInfo[o],onChange:(l,d)=>{e.updateObject(i.uuid,l,d),e.requestMethod(i.uuid,"updateProjectionMatrix");const h=e.getScene(i.uuid);if(h!==null){const u=h.getObjectByProperty("uuid",i.uuid);u!==void 0&&(T(u,l,d),u.updateProjectionMatrix())}}});return c.jsx(F,{three:e,title:"Camera",items:r,expanded:n,onToggle:o=>{a(o)}})}const fe=i=>{const[e,t]=v.useState(i.options[i.index]),s=()=>{i.onToggle(!i.open)},n=r=>{r!==e&&(i.onSelect(r),t(r)),i.onToggle(!1)},a=i.open?`${i.options.length*31-1}px`:"0px";return c.jsxs("div",{className:`dropdown ${i.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:s,children:`${i.title}: ${e}`}),c.jsx("ul",{className:"dropdown-menu",style:{height:a},children:i.options.map(r=>c.jsx("li",{onClick:()=>n(r),children:r},r))})]})},q=v.forwardRef(function(e,t){const s=["Renderer","Depth","Normals","UVs","Wireframe"],[n,a]=v.useState("Renderer"),[r,o]=v.useState(!1),[l,d]=v.useState(!1),[h,u]=v.useState(!1);return c.jsxs("div",{className:`CameraWindow ${e.name}`,children:[c.jsx("div",{ref:t,className:"clickable",onClick:()=>{h&&u(!1)}}),c.jsxs("div",{className:"options",children:[e.camera!==null&&c.jsx(fe,{title:"Camera",index:e.options.indexOf(e.camera.name),open:h,options:e.options,onSelect:e.onSelectCamera,onToggle:m=>{m&&l&&d(!1),u(m)},up:!0}),c.jsx(fe,{title:"Mode",index:s.indexOf(n),open:l,options:s,onSelect:m=>{if(m===n)return;const f=m;e.onSelectRenderMode(f),a(f)},onToggle:m=>{m&&h&&u(!1),r&&o(!1),d(m)},up:!0})]})]})}),es=`out vec3 worldPosition;
17
17
  uniform float uDistance;
18
18
 
19
19
  void main() {
@@ -90,7 +90,7 @@ void main() {
90
90
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
91
91
 
92
92
  if (fragColor.a <= minAlpha) discard;
93
- }`;class dt extends p.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new p.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:p.GLSL3,side:p.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:es,fragmentShader:ts})}get color(){return this.uniforms.uColor.value}set color(e){this.uniforms.uColor.value=e}get gridOpacity(){return this.uniforms.uGridOpacity.value}set gridOpacity(e){this.uniforms.uGridOpacity.value=e}get subgridOpacity(){return this.uniforms.uSubgridOpacity.value}set subgridOpacity(e){this.uniforms.uSubgridOpacity.value=e}}class ht extends p.Mesh{gridMaterial;constructor(e){const t=new dt(e);super(new p.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}class ut extends b.NodeMaterial{uScale;uDivisions;uColor;uDistance;uSubgridOpacity;uGridOpacity;constructor(e){super(),this.name="InfiniteGrid",this.side=b.DoubleSide,this.transparent=!0,this.uScale=C.uniform(e?.scale??.1),this.uDivisions=C.uniform(e?.divisions??10),this.uColor=C.uniform(e?.color??new b.Color(16777215)),this.uDistance=C.uniform(e?.distance??1e4),this.uSubgridOpacity=C.uniform(e?.subgridOpacity??.15),this.uGridOpacity=C.uniform(e?.gridOpacity??.25);const{uScale:t,uDivisions:s,uColor:n,uDistance:a,uSubgridOpacity:r,uGridOpacity:o}=this,l=C.varyingProperty("vec3","vWorldPosition");this.positionNode=C.Fn(()=>{const h=C.positionLocal.xzy.mul(a).add(C.vec3(C.cameraPosition.x,C.float(0),C.cameraPosition.z));return l.assign(h),h})();const d=C.Fn(([h])=>{const u=l.xz.div(h),m=C.fwidth(u),f=C.abs(C.fract(u.sub(.5)).sub(.5)).div(m).div(2),y=C.min(f.x,f.y);return C.float(1).sub(C.min(y,C.float(1)))});this.outputNode=C.Fn(()=>{const h=l,u=C.max(C.float(200),C.abs(C.cameraPosition.y.sub(h.y))),m=C.float(C.distance(C.cameraPosition,h)),f=C.log(u).div(C.log(s)),y=C.pow(s,C.floor(f)),g=y.mul(s),S=g.mul(s),O=d(y.mul(t)),M=d(g.mul(t)),T=d(S.mul(t)),R=u.sub(y).div(g.sub(y)),D=C.float(.3),V=C.max(R.sub(C.float(1)).add(D),C.float(0)).div(D),H=O.mul(C.pow(C.float(1).sub(C.min(m.div(a),C.float(1))),C.float(3))),F=C.float(.5),E=H.sub(V).mul(r),j=C.mix(E,H.mul(o).sub(V.mul(o.sub(r)).mul(F)),M),le=C.float(C.mix(j,H.mul(o),T));return C.If(C.lessThanEqual(le,C.float(1/127)),()=>{C.Discard()}),C.vec4(n,le)})()}get color(){return this.uColor.value}set color(e){this.uColor.value=e}get gridOpacity(){return this.uGridOpacity.value}set gridOpacity(e){this.uGridOpacity.value=e}get subgridOpacity(){return this.uSubgridOpacity.value}set subgridOpacity(e){this.uSubgridOpacity.value=e}}class pt extends b.Mesh{gridMaterial;constructor(e){const t=new ut(e);super(new b.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}function xe(i){const[e,t]=v.useState(i.selected),s="toggle"+(e?" selected":"");return c.jsx("button",{className:s,onClick:()=>{const n=!e;t(n),i.onClick(n)},style:{backgroundImage:`url(${i.icon})`,backgroundPositionX:"center",backgroundPositionY:i.top!==void 0?`${i.top}px`:"center",backgroundSize:`${i.width!==void 0?`${i.width}px`:"26px"} ${i.height}px`}},i.name)}class mt extends $e{constructor(){super();const e=ae.remapClamp(ae.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=ae.vec4(e,e,e,1)}}class ft extends $e{constructor(){super(),this.colorNode=ae.vec4(ae.uv(),0,1)}}class P extends p.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(w.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();U(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new It.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:P.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:P.DRAG_END})}),t.addEventListener("dragging-changed",n=>{N.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),U(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return P._instance||(P._instance=new P),P._instance}}const is=new b.BoxGeometry,we=new b.Vector2;class me extends b.Object3D{curve=new b.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new b.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new b.Color(L.lerp(.5,1,Math.random()),L.lerp(.5,1,Math.random()),L.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new b.LineBasicMaterial({color:s}),this.line=new b.Line(new b.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new b.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new b.Mesh(new b.SphereGeometry(1.5),new b.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new b.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),P.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([_(t.position.x,3),_(t.position.y,3),_(t.position.z,3)])}),Ke({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new b.Mesh(is,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const a=this.points.length>1;return a&&t&&this.updateSpline(),this.line.visible=a,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new b.Vector3,s=this.addPoint(t);this.updateField(s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.updateField(t.position)}U(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new b.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new b.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!N.instance||!N.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=N.instance.currentWindow.current.getBoundingClientRect();we.x=(e.clientX-s.x)/s.width*2-1,we.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(we,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.updateField(a.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new b.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=P.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),N.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:n}],onUpdate:(a,r)=>{switch(a){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,U(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const o=this._transform?.object;o.name.search("point")>-1&&(o.position.copy(r),this.updateSpline())}break}}}),this.draggable.children.forEach(a=>{this.debugPoint(a)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let he=0;class gt extends p.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(w.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=A.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(w.ADD_SPLINE,this.onAddSpline),A.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${he+1}`,s=new me(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),he++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new p.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new p.Vector3(n[0],n[1],n[2]))});const s=new me(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s,!1),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=t.name!==void 0?t.name:`Spline ${he+1}`,n=new me(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const a=[];t.points.forEach(r=>{a.push(new p.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),he++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1;if(N.instance){const o=new p.Raycaster;o.setFromCamera(new p.Vector2(n,a),this._camera);const l=o.intersectObjects(N.instance.helpersContainer.children,!0);for(let d=0;d<l.length;d++){const h=l[d];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.updateLastPoint(r),this.currentSpline?.updateField(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const a=new p.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,d=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,m=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,f=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,y=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let g=e,S=t;h||m?g*=-1:f&&(S*=-1);const O=s/2/l,M=n/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),d||h){const T=g*O+o.position.x,R=S*M+o.position.y;a.set(T,R,0)}else if(u||m){const T=g*O+o.position.z,R=S*M+o.position.y;a.set(0,R,T)}else if(f||y){const T=g*O+o.position.x,R=S*M+o.position.z;a.set(T,0,R)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const ze=["Single","Side by Side","Stacked","Quad"],ss="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",ns="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",rs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class N extends v.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new b.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new b.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new b.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;cameraControlsStartTime=0;cameraControlsLastTime=0;debugCamera;raycaster=new b.Raycaster;pointer=new b.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(w.ADD_RENDERER,this.setupRenderer),this.scene=new b.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=v.createRef(),this.containerRef=v.createRef(),this.tlWindow=v.createRef(),this.trWindow=v.createRef(),this.blWindow=v.createRef(),this.brWindow=v.createRef();const t=e.three.name,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:b.Vector2,Vector3:b.Vector3,Vector4:b.Vector4,Quaternion:b.Quaternion,Matrix4:b.Matrix4,Spherical:b.Spherical,Box3:b.Box3,Sphere:b.Sphere,Raycaster:b.Raycaster};q.install({THREE:a});const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),N.instance=this}componentDidMount(){this.setupScene(),this.setupTools(),this.enable(),this.assignControls(),this.resize(),this.play(),P.instance.setApp(this.props.three),P.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),A.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:this.canvasRef}),c.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&c.jsx(c.Fragment,{children:c.jsx($,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx($,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),c.jsx($,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx($,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),c.jsx($,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),c.jsx($,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),c.jsx($,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(ge,{title:"View",index:ze.indexOf(this.state.mode),options:ze,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),c.jsx(ge,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),c.jsx(xe,{name:"cameraHelper",icon:ss,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),c.jsx(xe,{name:"lightHelper",icon:ns,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),c.jsx(xe,{name:"gridHelper",icon:rs,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof p.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof b.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;if(s===null){setTimeout(()=>this.props.three.requestRenderer(),100);return}this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new p.WebGLRenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),U(this.grid)),this.grid=new ht,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new b.WebGPURenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),U(this.grid)),this.grid=new pt,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial?.dispose(),this.normalsMaterial?.dispose(),this.uvMaterial?.dispose(),this.depthMaterial=new mt,this.normalsMaterial=new b.MeshNormalNodeMaterial,this.uvMaterial=new ft,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const o=new b.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=a,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(a,o),o},t=1e3;e("Top",new b.Vector3(0,t,0)),e("Bottom",new b.Vector3(0,-t,0)),e("Left",new b.Vector3(-t,0,0)),e("Right",new b.Vector3(t,0,0)),e("Front",new b.Vector3(0,0,t)),e("Back",new b.Vector3(0,0,-t)),e("Orthographic",new b.Vector3(t,t,t)),e("UI",new b.Vector3),this.debugCamera=new b.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),A.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":P.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(a,r)=>{switch(a){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(a,r)=>{switch(a){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new gt(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}clear(){this.three.dispatchEvent({type:w.CLEAR_OBJECT}),A.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,P.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:w.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:w.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(w.ADD_SCENE,this.addScene),this.three.addEventListener(w.SET_SCENE,this.sceneUpdate),this.three.addEventListener(w.REMOVE_SCENE,this.removeScene),this.three.addEventListener(w.ADD_CAMERA,this.addCamera),this.three.addEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(w.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(w.ADD_SCENE,this.addScene),this.three.removeEventListener(w.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(w.REMOVE_SCENE,this.removeScene),this.three.removeEventListener(w.ADD_CAMERA,this.addCamera),this.three.removeEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(w.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof b.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof b.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=this.scenes.get(e.value.name);if(s!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s;return}const n=new t;n.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(n),this.props.three.scene=n,this.scenes.set(e.value.name,n),this.scene.add(n)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene)),this.cameraHelpers.forEach((s,n)=>{const a=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",n)!==void 0;s.visible=this.cameraVisibility&&a})};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{U(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const a=n;this.cameras.set(s,a);const r=new b.CameraHelper(a),o=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",s)!==void 0;r.visible=this.cameraVisibility&&o,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new b.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=L.mapLinear(s,0,t.x,-1,1),this.pointer.y=L.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=L.mapLinear(s,0,a,-1,1):this.pointer.x=L.mapLinear(s,a,t.x,-1,1)},l=()=>{n<r?this.pointer.y=L.mapLinear(n,0,r,1,-1):this.pointer.y=L.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new b.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof b.Mesh||this.selectedItem instanceof b.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new q(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(L.degToRad(45),L.degToRad(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=P.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),ye.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new b.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new b.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Rt.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new b.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new b.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new Tt.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),P.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15;this.cameraControlsStartTime=performance.now(),this.cameraControlsLastTime=this.cameraControlsStartTime,this.selectedItem.getWorldPosition(e.target0);const n=()=>{const a=performance.now(),r=(a-this.cameraControlsLastTime)/1e3;this.cameraControlsLastTime=a,this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=ie(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),(a-this.cameraControlsStartTime)/1e3>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,a)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),a=this.renderer instanceof b.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const r=this.height-n;a?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,r,this.width,n,this.trCam,t)):(this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof b.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),a=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),o=Math.floor(this.height/2),l=this.height-o;let d=0,h=e?0:this.height-o;d=0,this.drawTo(d,h,r,o,this.tlCam,t),d=r,this.drawTo(d,h,r,o,this.trCam,s),h=e?l:0,d=0,this.scene.overrideMaterial=n,this.drawTo(d,h,r,o,this.blCam,n),d=r,this.drawTo(d,h,r,o,this.brCam,a)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class ye extends v.Component{static instance;matrix=new p.Matrix4;position=new p.Vector3;rotation=new p.Euler;scale=new p.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),ye.instance=this}update(){if(N.instance){const e=N.instance.selectedItem;if(e===void 0)return;this.position.x=_(e.position.x,3),this.position.y=_(e.position.y,3),this.position.z=_(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=_(e.scale.x,3),this.scale.y=_(e.scale.y,3),this.scale.z=_(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return c.jsx(G,{three:this.props.three,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);I(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function qe(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function as(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const l=i.lightInfo[o];l!==void 0&&(l.isColor!==void 0?r.push({title:qe(o),prop:o,type:"color",value:l,onChange:(d,h)=>{const u=new p.Color(h);e.updateObject(i.uuid,d,u);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);I(f,d,u)}}}):r.push({title:qe(o),prop:o,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(d,h)=>{e.updateObject(i.uuid,d,h);const u=e.getScene(i.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",i.uuid);I(m,d,h)}}}))}return c.jsx(G,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function os(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(m){localStorage.setItem(s(),m?"open":"closed")}const o=[],l=[];let d=0;e.animations.forEach(m=>{d=Math.max(d,m.duration),m.duration>0&&l.push({title:m.name,items:[{title:"Duration",type:"number",value:m.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",e.uuid);if(m!==void 0){const f=m.mixer;if(f!==void 0){const g=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(S,O)=>{f.timeScale=O,t.updateObject(e.uuid,"mixer.timeScale",O)}}];g.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:g}),h=new p.SkeletonHelper(m),N.instance?.scene.add(h)}}}return v.useEffect(()=>()=>{h!==void 0&&U(h)},[]),c.jsx(G,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:m=>{r(m)}})}const Me={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};function vt(i){const[e,t]=v.useState(Me);v.useEffect(()=>{function r(l){t(l.value)}function o(){t(Me)}return i.three.addEventListener(w.CLEAR_OBJECT,o),i.three.addEventListener(w.SET_SCENE,o),i.three.addEventListener(w.SET_OBJECT,r),()=>{i.three.removeEventListener(w.CLEAR_OBJECT,o),i.three.removeEventListener(w.SET_SCENE,o),i.three.removeEventListener(w.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return c.jsx(te,{three:i.three,label:"Inspector",button:e.uuid.length>0?c.jsx("button",{className:"remove",onClick:()=>{P.instance.remove(e.name),t(Me)}}):void 0,children:c.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(pe,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),c.jsx(pe,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),c.jsx(pe,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),c.jsxs(c.Fragment,{children:[c.jsx(ye,{object:e,three:i.three}),n?c.jsx(os,{object:e,three:i.three}):null,s.search("camera")>-1?Zi(e,i.three):null,s.search("light")>-1?as(e,i.three):null,a?Ji(e,i.three):null]})]})})},"Inspector")}function bt(i){const[e]=v.useState([]),[t]=v.useState([]),[s,n]=v.useState(0),a=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid)return;e.push(h),t.push(c.jsx(te,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(ue,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=c.jsx(te,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(ue,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},l=d=>{const h=d.value.name;for(let u=0;u<e.length;u++){const m=e[u],f=m.name===h;t[u]=c.jsx(te,{three:i.three,label:`Scene: ${m.name}`,scene:m,open:f,visible:f,onRefresh:()=>{i.three.refreshScene(m.name)},children:c.jsx(ue,{child:m,scene:m,three:i.three})},m.name)}n(Date.now())};return v.useEffect(()=>(i.three.addEventListener(w.ADD_SCENE,a),i.three.addEventListener(w.SET_SCENE,l),i.three.addEventListener(w.REFRESH_SCENE,r),i.three.addEventListener(w.REMOVE_SCENE,o),()=>{i.three.removeEventListener(w.ADD_SCENE,a),i.three.removeEventListener(w.SET_SCENE,l),i.three.removeEventListener(w.REFRESH_SCENE,r),i.three.removeEventListener(w.REMOVE_SCENE,o)}),[]),c.jsxs("div",{id:"SidePanel",children:[c.jsx("div",{className:"scenes",children:t},s),c.jsx(vt,{three:i.three}),c.jsx(A,{three:i.three})]})}const je=v.forwardRef((i,e)=>c.jsxs("div",{className:"editor",ref:e,style:i.style,children:[i.header&&c.jsx("div",{className:"header",children:i.header}),i.children,i.footer&&c.jsx("div",{className:"footer",children:i.footer})]}));je.displayName="Editor";function cs(i){return c.jsxs(je,{children:[c.jsx(N,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),c.jsx(bt,{three:i.three})]})}function ls(i){const{app:e,renderEditor:t,onLoad:s,renderLoading:n=null,children:a}=i,[r,o]=v.useState(!1);if(v.useEffect(()=>{e.detectSettings().then(()=>{s?s(e).then(()=>o(!0)):o(!0)})},[]),!r)return c.jsx(c.Fragment,{children:n});if(e.editor&&t){const l=e.components.get("three");return c.jsx(c.Fragment,{children:t(l)})}return c.jsx(c.Fragment,{children:a?.(e)})}const ds=`#include <common>
93
+ }`;class lt extends p.ShaderMaterial{constructor(e){super({extensions:{derivatives:!0},uniforms:{uScale:{value:e?.scale!==void 0?e?.scale:.1},uDivisions:{value:e?.divisions!==void 0?e?.divisions:10},uColor:{value:e?.color!==void 0?e?.color:new p.Color(16777215)},uDistance:{value:e?.distance!==void 0?e?.distance:1e4},uSubgridOpacity:{value:e?.subgridOpacity!==void 0?e?.subgridOpacity:.15},uGridOpacity:{value:e?.gridOpacity!==void 0?e?.gridOpacity:.25}},glslVersion:p.GLSL3,side:p.DoubleSide,transparent:!0,name:"InfiniteGrid",vertexShader:es,fragmentShader:ts})}get color(){return this.uniforms.uColor.value}set color(e){this.uniforms.uColor.value=e}get gridOpacity(){return this.uniforms.uGridOpacity.value}set gridOpacity(e){this.uniforms.uGridOpacity.value=e}get subgridOpacity(){return this.uniforms.uSubgridOpacity.value}set subgridOpacity(e){this.uniforms.uSubgridOpacity.value=e}}class dt extends p.Mesh{gridMaterial;constructor(e){const t=new lt(e);super(new p.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}class ht extends b.NodeMaterial{uScale;uDivisions;uColor;uDistance;uSubgridOpacity;uGridOpacity;constructor(e){super(),this.name="InfiniteGrid",this.side=b.DoubleSide,this.transparent=!0,this.uScale=C.uniform(e?.scale??.1),this.uDivisions=C.uniform(e?.divisions??10),this.uColor=C.uniform(e?.color??new b.Color(16777215)),this.uDistance=C.uniform(e?.distance??1e4),this.uSubgridOpacity=C.uniform(e?.subgridOpacity??.15),this.uGridOpacity=C.uniform(e?.gridOpacity??.25);const{uScale:t,uDivisions:s,uColor:n,uDistance:a,uSubgridOpacity:r,uGridOpacity:o}=this,l=C.varyingProperty("vec3","vWorldPosition");this.positionNode=C.Fn(()=>{const h=C.positionLocal.xzy.mul(a).add(C.vec3(C.cameraPosition.x,C.float(0),C.cameraPosition.z));return l.assign(h),h})();const d=C.Fn(([h])=>{const u=l.xz.div(h),m=C.fwidth(u),f=C.abs(C.fract(u.sub(.5)).sub(.5)).div(m).div(2),y=C.min(f.x,f.y);return C.float(1).sub(C.min(y,C.float(1)))});this.outputNode=C.Fn(()=>{const h=l,u=C.max(C.float(200),C.abs(C.cameraPosition.y.sub(h.y))),m=C.float(C.distance(C.cameraPosition,h)),f=C.log(u).div(C.log(s)),y=C.pow(s,C.floor(f)),g=y.mul(s),S=g.mul(s),O=d(y.mul(t)),M=d(g.mul(t)),I=d(S.mul(t)),R=u.sub(y).div(g.sub(y)),D=C.float(.3),V=C.max(R.sub(C.float(1)).add(D),C.float(0)).div(D),H=O.mul(C.pow(C.float(1).sub(C.min(m.div(a),C.float(1))),C.float(3))),G=C.float(.5),E=H.sub(V).mul(r),j=C.mix(E,H.mul(o).sub(V.mul(o.sub(r)).mul(G)),M),ce=C.float(C.mix(j,H.mul(o),I));return C.If(C.lessThanEqual(ce,C.float(1/127)),()=>{C.Discard()}),C.vec4(n,ce)})()}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 ut extends b.Mesh{gridMaterial;constructor(e){const t=new ht(e);super(new b.PlaneGeometry,t),this.gridMaterial=t,this.frustumCulled=!1,this.name="InfiniteGridHelper"}get color(){return this.gridMaterial.color}set color(e){this.gridMaterial.color=e}get gridOpacity(){return this.gridMaterial.gridOpacity}set gridOpacity(e){this.gridMaterial.gridOpacity=e}get subgridOpacity(){return this.gridMaterial.subgridOpacity}set subgridOpacity(e){this.gridMaterial.subgridOpacity=e}}function Ce(i){const[e,t]=v.useState(i.selected),s="toggle"+(e?" selected":"");return c.jsx("button",{className:s,onClick:()=>{const n=!e;t(n),i.onClick(n)},style:{backgroundImage:`url(${i.icon})`,backgroundPositionX:"center",backgroundPositionY:i.top!==void 0?`${i.top}px`:"center",backgroundSize:`${i.width!==void 0?`${i.width}px`:"26px"} ${i.height}px`}},i.name)}class pt extends ze{constructor(){super();const e=re.remapClamp(re.linearDepth(),.1,.5,0,1).oneMinus();this.colorNode=re.vec4(e,e,e,1)}}class mt extends ze{constructor(){super(),this.colorNode=re.vec4(re.uv(),0,1)}}class P extends p.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(w.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();_(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new It.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:P.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:P.DRAG_END})}),t.addEventListener("dragging-changed",n=>{N.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),_(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return P._instance||(P._instance=new P),P._instance}}const is=new b.BoxGeometry,Se=new b.Vector2;class pe extends b.Object3D{curve=new b.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new b.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new b.Color(U.lerp(.5,1,Math.random()),U.lerp(.5,1,Math.random()),U.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new b.LineBasicMaterial({color:s}),this.line=new b.Line(new b.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new b.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new b.Mesh(new b.SphereGeometry(1.5),new b.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new b.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),P.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([L(t.position.x,3),L(t.position.y,3),L(t.position.z,3)])}),qe({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new b.Mesh(is,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const a=this.points.length>1;return a&&t&&this.updateSpline(),this.line.visible=a,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new b.Vector3,s=this.addPoint(t);this.updateField(s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.updateField(t.position)}_(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new b.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new b.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!N.instance||!N.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=N.instance.currentWindow.current.getBoundingClientRect();Se.x=(e.clientX-s.x)/s.width*2-1,Se.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(Se,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.updateField(a.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new b.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=P.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),N.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:n}],onUpdate:(a,r)=>{switch(a){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,_(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 de=0;class ft extends p.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(w.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=A.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(w.ADD_SPLINE,this.onAddSpline),A.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${de+1}`,s=new pe(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),de++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new p.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new p.Vector3(n[0],n[1],n[2]))});const s=new pe(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 ${de+1}`,n=new pe(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const a=[];t.points.forEach(r=>{a.push(new p.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),de++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1;if(N.instance){const o=new p.Raycaster;o.setFromCamera(new p.Vector2(n,a),this._camera);const l=o.intersectObjects(N.instance.helpersContainer.children,!0);for(let d=0;d<l.length;d++){const h=l[d];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.updateLastPoint(r),this.currentSpline?.updateField(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const a=new p.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,d=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,m=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,f=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,y=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let g=e,S=t;h||m?g*=-1:f&&(S*=-1);const O=s/2/l,M=n/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),d||h){const I=g*O+o.position.x,R=S*M+o.position.y;a.set(I,R,0)}else if(u||m){const I=g*O+o.position.z,R=S*M+o.position.y;a.set(0,R,I)}else if(f||y){const I=g*O+o.position.x,R=S*M+o.position.z;a.set(I,0,R)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const He=["Single","Side by Side","Stacked","Quad"],ss="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",ns="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",rs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class N extends v.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new b.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new b.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new b.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;cameraControlsStartTime=0;cameraControlsLastTime=0;debugCamera;raycaster=new b.Raycaster;pointer=new b.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(w.ADD_RENDERER,this.setupRenderer),this.scene=new b.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=v.createRef(),this.containerRef=v.createRef(),this.tlWindow=v.createRef(),this.trWindow=v.createRef(),this.blWindow=v.createRef(),this.brWindow=v.createRef();const t=e.three.name,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:b.Vector2,Vector3:b.Vector3,Vector4:b.Vector4,Quaternion:b.Quaternion,Matrix4:b.Matrix4,Spherical:b.Spherical,Box3:b.Box3,Sphere:b.Sphere,Raycaster:b.Raycaster};z.install({THREE:a});const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),N.instance=this}componentDidMount(){this.setupScene(),this.setupTools(),this.enable(),this.assignControls(),this.resize(),this.play(),P.instance.setApp(this.props.three),P.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),A.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:this.canvasRef}),c.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&c.jsx(c.Fragment,{children:c.jsx(q,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx(q,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),c.jsx(q,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx(q,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),c.jsx(q,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),c.jsx(q,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),c.jsx(q,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(fe,{title:"View",index:He.indexOf(this.state.mode),options:He,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),c.jsx(fe,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),c.jsx(Ce,{name:"cameraHelper",icon:ss,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),c.jsx(Ce,{name:"lightHelper",icon:ns,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),c.jsx(Ce,{name:"gridHelper",icon:rs,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof p.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof b.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;if(s===null){setTimeout(()=>this.props.three.requestRenderer(),100);return}this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new p.WebGLRenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),_(this.grid)),this.grid=new dt,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new b.WebGPURenderer({canvas:s,stencil:!1}),this.grid&&(this.scene.remove(this.grid),_(this.grid)),this.grid=new ut,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial?.dispose(),this.normalsMaterial?.dispose(),this.uvMaterial?.dispose(),this.depthMaterial=new pt,this.normalsMaterial=new b.MeshNormalNodeMaterial,this.uvMaterial=new mt,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const o=new b.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=a,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(a,o),o},t=1e3;e("Top",new b.Vector3(0,t,0)),e("Bottom",new b.Vector3(0,-t,0)),e("Left",new b.Vector3(-t,0,0)),e("Right",new b.Vector3(t,0,0)),e("Front",new b.Vector3(0,0,t)),e("Back",new b.Vector3(0,0,-t)),e("Orthographic",new b.Vector3(t,t,t)),e("UI",new b.Vector3),this.debugCamera=new b.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),A.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":P.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(a,r)=>{switch(a){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(a,r)=>{switch(a){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new ft(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}clear(){this.three.dispatchEvent({type:w.CLEAR_OBJECT}),A.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,P.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:w.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:w.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(w.ADD_SCENE,this.addScene),this.three.addEventListener(w.SET_SCENE,this.sceneUpdate),this.three.addEventListener(w.REMOVE_SCENE,this.removeScene),this.three.addEventListener(w.ADD_CAMERA,this.addCamera),this.three.addEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(w.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(w.ADD_SCENE,this.addScene),this.three.removeEventListener(w.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(w.REMOVE_SCENE,this.removeScene),this.three.removeEventListener(w.ADD_CAMERA,this.addCamera),this.three.removeEventListener(w.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(w.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof b.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof b.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=this.scenes.get(e.value.name);if(s!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s;return}const n=new t;n.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(n),this.props.three.scene=n,this.scenes.set(e.value.name,n),this.scene.add(n)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene)),this.cameraHelpers.forEach((s,n)=>{const a=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",n)!==void 0;s.visible=this.cameraVisibility&&a})};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{_(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const a=n;this.cameras.set(s,a);const r=new b.CameraHelper(a),o=this.currentScene!==void 0&&this.currentScene.getObjectByProperty("uuid",s)!==void 0;r.visible=this.cameraVisibility&&o,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new b.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=U.mapLinear(s,0,t.x,-1,1),this.pointer.y=U.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=U.mapLinear(s,0,a,-1,1):this.pointer.x=U.mapLinear(s,a,t.x,-1,1)},l=()=>{n<r?this.pointer.y=U.mapLinear(n,0,r,1,-1):this.pointer.y=U.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new b.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new z(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof b.Mesh||this.selectedItem instanceof b.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new z(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 z(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 z(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 z(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 z(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(U.degToRad(45),U.degToRad(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),P.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=P.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),be.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new b.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new b.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Ot.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new b.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new b.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new Rt.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),P.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15;this.cameraControlsStartTime=performance.now(),this.cameraControlsLastTime=this.cameraControlsStartTime,this.selectedItem.getWorldPosition(e.target0);const n=()=>{const a=performance.now(),r=(a-this.cameraControlsLastTime)/1e3;this.cameraControlsLastTime=a,this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=te(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),(a-this.cameraControlsStartTime)/1e3>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,a)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),a=this.renderer instanceof b.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const r=this.height-n;a?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,r,this.width,n,this.trCam,t)):(this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof b.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),a=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),o=Math.floor(this.height/2),l=this.height-o;let d=0,h=e?0:this.height-o;d=0,this.drawTo(d,h,r,o,this.tlCam,t),d=r,this.drawTo(d,h,r,o,this.trCam,s),h=e?l:0,d=0,this.scene.overrideMaterial=n,this.drawTo(d,h,r,o,this.blCam,n),d=r,this.drawTo(d,h,r,o,this.brCam,a)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class be extends v.Component{static instance;matrix=new p.Matrix4;position=new p.Vector3;rotation=new p.Euler;scale=new p.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),be.instance=this}update(){if(N.instance){const e=N.instance.selectedItem;if(e===void 0)return;this.position.x=L(e.position.x,3),this.position.y=L(e.position.y,3),this.position.z=L(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=L(e.scale.x,3),this.scale.y=L(e.scale.y,3),this.scale.z=L(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return c.jsx(F,{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);T(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function We(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function as(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const l=i.lightInfo[o];l!==void 0&&(l.isColor!==void 0?r.push({title:We(o),prop:o,type:"color",value:l,onChange:(d,h)=>{const u=new p.Color(h);e.updateObject(i.uuid,d,u);const m=e.getScene(i.uuid);if(m!==null){const f=m.getObjectByProperty("uuid",i.uuid);T(f,d,u)}}}):r.push({title:We(o),prop:o,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(d,h)=>{e.updateObject(i.uuid,d,h);const u=e.getScene(i.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",i.uuid);T(m,d,h)}}}))}return c.jsx(F,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function os(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(m){localStorage.setItem(s(),m?"open":"closed")}const o=[],l=[];let d=0;e.animations.forEach(m=>{d=Math.max(d,m.duration),m.duration>0&&l.push({title:m.name,items:[{title:"Duration",type:"number",value:m.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const m=u.getObjectByProperty("uuid",e.uuid);if(m!==void 0){const f=m.mixer;if(f!==void 0){const g=[{title:"Time Scale",type:"range",value:f.timeScale,step:.01,min:-1,max:2,onChange:(S,O)=>{f.timeScale=O,t.updateObject(e.uuid,"mixer.timeScale",O)}}];g.push({title:"Stop All",type:"button",onChange:()=>{f.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:g}),h=new p.SkeletonHelper(m),N.instance?.scene.add(h)}}}return v.useEffect(()=>()=>{h!==void 0&&_(h)},[]),c.jsx(F,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:m=>{r(m)}})}const xe={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 gt(i){const[e,t]=v.useState(xe);v.useEffect(()=>{function r(l){t(l.value)}function o(){t(xe)}return i.three.addEventListener(w.CLEAR_OBJECT,o),i.three.addEventListener(w.SET_SCENE,o),i.three.addEventListener(w.SET_OBJECT,r),()=>{i.three.removeEventListener(w.CLEAR_OBJECT,o),i.three.removeEventListener(w.SET_SCENE,o),i.three.removeEventListener(w.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return c.jsx(ee,{three:i.three,label:"Inspector",button:e.uuid.length>0?c.jsx("button",{className:"remove",onClick:()=>{P.instance.remove(e.name),t(xe)}}):void 0,children:c.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(ue,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),c.jsx(ue,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),c.jsx(ue,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),c.jsxs(c.Fragment,{children:[c.jsx(be,{object:e,three:i.three}),n?c.jsx(os,{object:e,three:i.three}):null,s.search("camera")>-1?Zi(e,i.three):null,s.search("light")>-1?as(e,i.three):null,a?Ji(e,i.three):null]})]})})},"Inspector")}function vt(i){const[e]=v.useState([]),[t]=v.useState([]),[s,n]=v.useState(0),a=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid)return;e.push(h),t.push(c.jsx(ee,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(he,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=c.jsx(ee,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:c.jsx(he,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=d=>{const h=d.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},l=d=>{const h=d.value.name;for(let u=0;u<e.length;u++){const m=e[u],f=m.name===h;t[u]=c.jsx(ee,{three:i.three,label:`Scene: ${m.name}`,scene:m,open:f,visible:f,onRefresh:()=>{i.three.refreshScene(m.name)},children:c.jsx(he,{child:m,scene:m,three:i.three})},m.name)}n(Date.now())};return v.useEffect(()=>(i.three.addEventListener(w.ADD_SCENE,a),i.three.addEventListener(w.SET_SCENE,l),i.three.addEventListener(w.REFRESH_SCENE,r),i.three.addEventListener(w.REMOVE_SCENE,o),()=>{i.three.removeEventListener(w.ADD_SCENE,a),i.three.removeEventListener(w.SET_SCENE,l),i.three.removeEventListener(w.REFRESH_SCENE,r),i.three.removeEventListener(w.REMOVE_SCENE,o)}),[]),c.jsxs("div",{id:"SidePanel",children:[c.jsx("div",{className:"scenes",children:t},s),c.jsx(gt,{three:i.three}),c.jsx(A,{three:i.three})]})}const ke=v.forwardRef((i,e)=>c.jsxs("div",{className:"editor",ref:e,style:i.style,children:[i.header&&c.jsx("div",{className:"header",children:i.header}),i.children,i.footer&&c.jsx("div",{className:"footer",children:i.footer})]}));ke.displayName="Editor";const cs={stripObject:Pi,stripScene:at,getSubItem:ki,setItemProps:T,textureFromSrc:ot};function ls(i){return v.useEffect(()=>(i.three.setEditorUtils(cs),()=>i.three.setEditorUtils(void 0)),[i.three]),c.jsxs(ke,{children:[c.jsx(N,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),c.jsx(vt,{three:i.three})]})}function ds(i){const{app:e,renderEditor:t,onLoad:s,renderLoading:n=null,children:a}=i,[r,o]=v.useState(!1);if(v.useEffect(()=>{e.detectSettings().then(()=>{s?s(e).then(()=>o(!0)):o(!0)})},[]),!r)return c.jsx(c.Fragment,{children:n});if(e.editor&&t){const l=e.components.get("three");return c.jsx(c.Fragment,{children:t(l)})}return c.jsx(c.Fragment,{children:a?.(e)})}const hs=`#include <common>
94
94
  #include <batching_pars_vertex>
95
95
  #include <uv_pars_vertex>
96
96
  #include <color_pars_vertex>
@@ -120,7 +120,7 @@ void main() {
120
120
  #include <logdepthbuf_vertex>
121
121
  #include <clipping_planes_vertex>
122
122
  #include <worldpos_vertex>
123
- }`,hs=`
123
+ }`,us=`
124
124
  uniform float opacity;
125
125
  #include <common>
126
126
  #include <uv_pars_fragment>
@@ -130,4 +130,4 @@ void main() {
130
130
  #include <clipping_planes_fragment>
131
131
  if (opacity < 0.015) discard;
132
132
  gl_FragColor = vec4(vec3(vUv, 0.0), opacity);
133
- }`;class us extends p.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:ds,fragmentShader:hs,transparent:!0})}}exports.Accordion=te;exports.Application=xi;exports.BaseRemote=Pe;exports.ChildObject=De;exports.ContainerObject=ue;exports.DepthNodeMaterial=mt;exports.Draggable=at;exports.DraggableItem=rt;exports.Dropdown=ot;exports.DropdownItem=ct;exports.Editor=je;exports.ElementProxy=Ci;exports.ElementProxyReceiver=st;exports.ExportTexture=B;exports.HermesApp=ls;exports.ImageSequenceCapturer=Dt;exports.InfiniteGridHelper=ht;exports.InfiniteGridHelperGPU=pt;exports.InfiniteGridMaterial=dt;exports.InfiniteGridNodeMaterial=ut;exports.Inspector=vt;exports.MultiView=N;exports.NavButton=ke;exports.ProxyManager=Si;exports.RemoteTheatre=Ei;exports.RemoteThree=Pi;exports.SidePanel=bt;exports.Spline=me;exports.SplineEditor=gt;exports.ThreeEditor=cs;exports.Transform=P;exports.UVMaterial=us;exports.UVNodeMaterial=ft;exports.WebworkerEventHandlers=bi;exports.anchorGeometry=tt;exports.anchorGeometryTL=Qt;exports.animateObjectMaterial=Kt;exports.animateObjectTransform=qt;exports.applyObjectMaterial=et;exports.capitalize=ce;exports.clamp=z;exports.clearComposerGroups=li;exports.colorToHex=Ee;exports.copyToClipboard=Ke;exports.createMask=ii;exports.cubicBezier=Vt;exports.customizeTheatreElements=zt;exports.damp=Lt;exports.defaultTheatreCallback=Pt;exports.detectMaxFrameRate=Je;exports.detectSettings=Xe;exports.dispose=U;exports.disposeMaterial=Te;exports.disposeTexture=Ae;exports.distance=Nt;exports.generateCubemap=di;exports.getAngle=_t;exports.getObjectMaterialObject=Ze;exports.getObjectMaterialProps=Qe;exports.hierarchyUUID=ee;exports.inspectComposer=ci;exports.inspectComposerPass=it;exports.isColor=Ye;exports.map=jt;exports.mix=ie;exports.noop=oe;exports.normalize=fe;exports.orthoCamera=Yt;exports.parseModelLite=Jt;exports.randomID=k;exports.renderToTexture=Xt;exports.resetThreeObjects=ne;exports.rgbaToHex=Ht;exports.roundTo=_;exports.setMaterialBlendAdd=ri;exports.setMaterialBlendMultiply=ai;exports.setMaterialBlendNormal=ni;exports.setMaterialBlendScreen=oi;exports.supportsOffscreenCanvas=ti;exports.triangle=ve;exports.updateCameraOrtho=Zt;exports.updateCameraOrtho16x9=ei;exports.useMask=si;exports.useStudio=Wt;
133
+ }`;class ps extends p.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:hs,fragmentShader:us,transparent:!0})}}exports.Accordion=ee;exports.Application=Si;exports.BaseRemote=Ie;exports.ChildObject=Pe;exports.ContainerObject=he;exports.DepthNodeMaterial=pt;exports.Draggable=st;exports.DraggableItem=it;exports.Dropdown=nt;exports.DropdownItem=rt;exports.Editor=ke;exports.ElementProxy=yi;exports.ElementProxyReceiver=tt;exports.ExportTexture=B;exports.HermesApp=ds;exports.ImageSequenceCapturer=kt;exports.InfiniteGridHelper=dt;exports.InfiniteGridHelperGPU=ut;exports.InfiniteGridMaterial=lt;exports.InfiniteGridNodeMaterial=ht;exports.Inspector=gt;exports.MultiView=N;exports.NavButton=Te;exports.ProxyManager=Ci;exports.RemoteTheatre=Mi;exports.RemoteThree=Ei;exports.SidePanel=vt;exports.Spline=pe;exports.SplineEditor=ft;exports.ThreeEditor=ls;exports.Transform=P;exports.UVMaterial=ps;exports.UVNodeMaterial=mt;exports.WebworkerEventHandlers=vi;exports.anchorGeometry=Ze;exports.anchorGeometryTL=Xt;exports.animateObjectMaterial=$t;exports.animateObjectTransform=zt;exports.applyObjectMaterial=Qe;exports.capitalize=oe;exports.clamp=W;exports.clearComposerGroups=ci;exports.colorToHex=we;exports.copyToClipboard=qe;exports.createMask=ti;exports.cubicBezier=Bt;exports.customizeTheatreElements=Wt;exports.damp=Nt;exports.defaultTheatreCallback=Tt;exports.detectMaxFrameRate=Ke;exports.detectSettings=Ye;exports.dispose=_;exports.disposeMaterial=Oe;exports.disposeTexture=Me;exports.distance=jt;exports.generateCubemap=li;exports.getAngle=Ut;exports.getObjectMaterialObject=Xe;exports.getObjectMaterialProps=Je;exports.hierarchyUUID=Z;exports.inspectComposer=oi;exports.inspectComposerPass=et;exports.isColor=$e;exports.map=Dt;exports.mix=te;exports.noop=ae;exports.normalize=me;exports.orthoCamera=Kt;exports.parseModelLite=Yt;exports.randomID=k;exports.renderToTexture=Jt;exports.resetThreeObjects=se;exports.rgbaToHex=Vt;exports.roundTo=L;exports.setMaterialBlendAdd=ni;exports.setMaterialBlendMultiply=ri;exports.setMaterialBlendNormal=si;exports.setMaterialBlendScreen=ai;exports.supportsOffscreenCanvas=ei;exports.triangle=ge;exports.updateCameraOrtho=Qt;exports.updateCameraOrtho16x9=Zt;exports.useMask=ii;exports.useStudio=Ht;