@tomorrowevening/hermes 0.1.38 → 0.1.39

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
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ThreeEditor-BjAFHK3t.js","ThreeEditor-lbW0auGy.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ThreeEditor-CTkjs-SY.js","ThreeEditor-lbW0auGy.css"])))=>i.map(i=>d[i]);
2
2
  var XPe=Object.defineProperty;var KPe=(o,e,t)=>e in o?XPe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var ur=(o,e,t)=>KPe(o,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();var I0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function A4e(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var WV={exports:{}},ow={},qV={exports:{}},bi={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -10223,4 +10223,4 @@ version 0.8.2
10223
10223
  enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
10224
10224
  gl_FragColor = enc;
10225
10225
  }
10226
- `,w=m.createShader(35633),A=m.createShader(35632),N=m.createProgram();if(!(A&&w&&N))return;m.shaderSource(w,y),m.shaderSource(A,x),m.compileShader(w),m.compileShader(A),m.attachShader(N,w),m.attachShader(N,A),m.linkProgram(N),m.detachShader(N,w),m.detachShader(N,A),m.deleteShader(w),m.deleteShader(A),m.useProgram(N);const F=m.createBuffer();m.bindBuffer(34962,F),m.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const B=m.getAttribLocation(N,"aPosition");m.vertexAttribPointer(B,3,5126,!1,0,0),m.enableVertexAttribArray(B),m.clearColor(1,1,1,1),m.clear(16384),m.viewport(0,0,1,1),m.drawArrays(4,0,3);const I=new Uint8Array(4);return m.readPixels(0,0,1,1,6408,5121,I),m.deleteProgram(N),m.deleteBuffer(F),I.join("")}(o),r="801621810",i="8016218135",a="80162181161",u=v1!=null&&v1.isIpad?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["a15",r,15],["m1",r,15],["m2",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15],["a15",r,15],["a16",r,15],["a17",r,15]];let d;return n==="80162181255"?d=u.filter(([,,m])=>m>=14):(d=u.filter(([,m])=>m===n),d.length||(d=u)),d.map(([m])=>`apple ${m} gpu`)}class w4e extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const PG=[],T4e=[];function qYe(o,e){if(o===e)return 0;const t=o;o.length>e.length&&(o=e,e=t);let n=o.length,r=e.length;for(;n>0&&o.charCodeAt(~-n)===e.charCodeAt(~-r);)n--,r--;let i,a=0;for(;a<n&&o.charCodeAt(a)===e.charCodeAt(a);)a++;if(n-=a,r-=a,n===0)return r;let u,d,m=0,y=0,x=0;for(;y<n;)T4e[y]=o.charCodeAt(a+y),PG[y]=++y;for(;x<r;)for(i=e.charCodeAt(a+x),u=x++,m=x,y=0;y<n;y++)d=i===T4e[y]?u:u+1,u=PG[y],m=PG[y]=u>m?d>m?m+1:d:d>u?u+1:d;return m}function $Ye(o){return o!=null}const XYe=({mobileTiers:o=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:n,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks"}={})=>AG(void 0,void 0,void 0,function*(){const a={};if(Bye)return{tier:0,type:"SSR"};const{isIpad:u=!!(v1!=null&&v1.isIpad),isMobile:d=!!(v1!=null&&v1.isMobile),screenSize:m=window.screen,loadBenchmarks:y=ne=>AG(void 0,void 0,void 0,function*(){const ie=yield fetch(`${i}/${ne}`).then(ue=>ue.json());if(parseInt(ie.shift().split(".")[0],10)<4)throw new w4e("Detect GPU benchmark data is out of date. Please update to version 4x");return ie})}=t;let{renderer:x}=t;const w=(ne,ie,ue,V,se)=>({device:se,fps:V,gpu:ue,isMobile:d,tier:ne,type:ie});let A,N="";if(x)x=S4e(x),A=[x];else{const ne=n||function(ue,V=!1){const se={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:V,powerPreference:"high-performance",stencil:!1};ue&&delete se.powerPreference;const we=window.document.createElement("canvas"),X=we.getContext("webgl",se)||we.getContext("experimental-webgl",se);return X??void 0}(v1==null?void 0:v1.isSafari12,r);if(!ne)return w(0,"WEBGL_UNSUPPORTED");const ie=v1!=null&&v1.isFirefox?null:ne.getExtension("WEBGL_debug_renderer_info");if(x=ie?ne.getParameter(ie.UNMASKED_RENDERER_WEBGL):ne.getParameter(ne.RENDERER),!x)return w(1,"FALLBACK");N=x,x=S4e(x),A=function(ue,V,se){return V==="apple gpu"?WYe(ue,V,se):[V]}(ne,x,d)}const F=(yield Promise.all(A.map(function(ne){var ie;return AG(this,void 0,void 0,function*(){const ue=(Rt=>{const pn=d?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const gn of pn)if(Rt.includes(gn))return gn})(ne);if(!ue)return;const V=`${d?"m":"d"}-${ue}${u?"-ipad":""}.json`,se=a[V]=(ie=a[V])!==null&&ie!==void 0?ie:y(V);let we;try{we=yield se}catch(Rt){if(Rt instanceof w4e)throw Rt;return}const X=function(Rt){var pn;const gn=(Rt=Rt.replace(/\([^)]+\)/,"")).match(/\d+/)||Rt.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(pn=gn==null?void 0:gn.join("").replace(/\W|amd/g,""))!==null&&pn!==void 0?pn:""}(ne);let Ne=we.filter(([,Rt])=>Rt===X);Ne.length||(Ne=we.filter(([Rt])=>Rt.includes(ne)));const Be=Ne.length;if(Be===0)return;const He=ne.split(/[.,()\[\]/\s]/g).sort().filter((Rt,pn,gn)=>pn===0||Rt!==gn[pn-1]).join(" ");let Ge,[le,,,,Ye]=Be>1?Ne.map(Rt=>[Rt,qYe(He,Rt[2])]).sort(([,Rt],[,pn])=>Rt-pn)[0][0]:Ne[0],Ie=Number.MAX_VALUE;const{devicePixelRatio:at}=window,yt=m.width*at*m.height*at;for(const Rt of Ye){const[pn,gn]=Rt,xt=pn*gn,Lt=Math.abs(yt-xt);Lt<Ie&&(Ie=Lt,Ge=Rt)}if(!Ge)return;const[,,ke,ut]=Ge;return[Ie,ke,le,ut]})}))).filter($Ye).sort(([ne=Number.MAX_VALUE,ie],[ue=Number.MAX_VALUE,V])=>ne===ue?ie-V:ne-ue);if(!F.length){const ne=HYe.find(ie=>x.includes(ie));return ne?w(0,"BLOCKLISTED",ne):w(1,"FALLBACK",`${x} (${N})`)}const[,B,I,G]=F[0];if(B===-1)return w(0,"BLOCKLISTED",I,B,G);const ee=d?o:e;let C=0;for(let ne=0;ne<ee.length;ne++)B>=ee[ne]&&(C=ne);return w(C,"BENCHMARK",I,B,G)});function KYe(o){let e=0;const t=performance.now();function n(){e++;const r=performance.now();if(r-t>=100){const i=e/((r-t)/1e3),a=Math.round(i/30)*30;o(a)}else requestAnimationFrame(n)}requestAnimationFrame(n)}function YYe(o=!1,e=!1){return new Promise(t=>{XYe().then(n=>{let r=!1;const i=document.createElement("canvas"),a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(r="transferControlToOffscreen"in i,a){const d=navigator.userAgent.match(/version\/(\d+)/i);r=(d?parseInt(d[1]):0)>=17}const u={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:n.isMobile!==void 0?n.isMobile:!1,supportOffScreenCanvas:r,supportWebGPU:!!navigator.gpu,quality:"Low",dev:o,editor:e};n.tier===3?u.quality="High":n.tier===2&&(u.quality="Medium"),KYe(d=>{u.fps=d,t(u)})})})}class ZYe{constructor(e,t=!1){ur(this,"assets",{audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map});ur(this,"components",new Map);ur(this,"settings",{dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1});ur(this,"onUpdateCallback");ur(this,"playing",!1);ur(this,"rafID",-1);ur(this,"play",()=>{this.playing||(this.playing=!0,this.onUpdate())});ur(this,"pause",()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)});ur(this,"onUpdate",()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)});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=>{YYe(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}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}}var QYe=P4e();class Uye{constructor(e,t=!1,n=!1){ur(this,"name");ur(this,"debug");ur(this,"editor");ur(this,"broadcastChannel");ur(this,"onMessageHandler");this.name=e,this.debug=t,this.editor=n,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){var e,t;(e=this.broadcastChannel)==null||e.removeEventListener("message",this.onMessageHandler),(t=this.broadcastChannel)==null||t.close()}send(e){var n;if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{(n=this.broadcastChannel)==null||n.postMessage(e)}catch(r){console.log("Hermes - Error sending message:"),console.log(r),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}const JYe=()=>{};function BZe(o){return o.substring(0,1).toUpperCase()+o.substring(1)}function UZe(o){const e=JSON.stringify(o);return navigator.clipboard.writeText(e),e}function VZe(){return Math.round(Math.random()*1e6).toString()}function eZe(o){return o.r!==void 0&&o.g!==void 0&&o.b!==void 0}function zZe(o){const e=Math.round(o.r*255),t=Math.round(o.g*255),n=Math.round(o.b*255),r=d=>{const m=d.toString(16);return m.length===1?"0"+m:m},i=r(e),a=r(t),u=r(n);return"#"+i+a+u}function tZe(o,e,t,n,r){const i=1-o;return i*i*i*e+3*i*i*o*t+3*i*o*o*n+o*o*o*r}function nZe(o,e,t){if(o.type!=="bezier"||o.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[n,r]=o.handles,i=(t-o.position)/(e.position-o.position);return tZe(i,o.value,o.value+n,e.value+r,e.value)}class rZe extends Uye{constructor(t=!1,n=!1){super("RemoteTheatre",t,n);ur(this,"project");ur(this,"sheets",new Map);ur(this,"sheetObjects",new Map);ur(this,"sheetObjectCBs",new Map);ur(this,"sheetObjectUnsubscribe",new Map);ur(this,"activeSheet");ur(this,"studio")}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(t,n){return this.project=QYe.getProject(t,{state:n}),new Promise((r,i)=>{var a;(a=this.project)==null||a.ready.then(()=>{if(n){const u=n.sheetsById;for(const d in u)this.sheet(d)}r()}).catch(()=>i())})}getSheetInstance(t,n){return n!==void 0?`${t}-${n}`:t}sheet(t,n){var a;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.getSheetInstance(t,n);let i=this.sheets.get(r);return i!==void 0||(i=(a=this.project)==null?void 0:a.sheet(t,n),this.sheets.set(r,i)),i}playSheet(t,n,r){return new Promise(i=>{var a;(a=this.sheet(t,r))==null||a.sequence.play(n).then(u=>i(u)),this.send({event:"playSheet",target:"editor",data:{sheet:t,instance:r,value:n}})})}pauseSheet(t,n){var r;(r=this.sheet(t,n))==null||r.sequence.pause(),this.send({event:"pauseSheet",target:"editor",data:{sheet:t,instance:n}})}clearSheetObjects(t){this.sheetObjects.forEach((n,r)=>{r.search(`${t}_`)>-1&&this.unsubscribe(n)})}sheetObject(t,n,r,i,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const u=this.sheet(t,a);if(u===void 0)return;const m=`${this.getSheetInstance(t,a)}_${n}`;let y=this.sheetObjects.get(m),x=r;y!==void 0&&(x={...r,...y.value}),y=u.object(n,x,{reconfigure:!0}),this.sheetObjects.set(m,y),this.sheetObjectCBs.set(m,i!==void 0?i:JYe);function w(N,F,B){if(typeof B=="object")if(eZe(B))N[F]={r:B.r,g:B.g,b:B.b,a:B.a};else for(const I in B){const G=B[I];typeof G=="object"&&w(B,I,G)}}const A=y.onValuesChange(N=>{const F=this.sheetObjectCBs.get(m);if(this.editor){for(const B in N){const I=N[B];typeof I=="object"&&w(N,B,I)}this.send({event:"updateSheetObject",target:"app",data:{sheet:t,sheetObject:m,values:N}}),F&&F(N)}else F&&F(N)});return this.sheetObjectUnsubscribe.set(m,A),y}getSheetObjectKeyframes(t,n,r){const i=this.sheet(t);if(i===void 0)return[];const a=`${t}_${n}`,u=this.sheetObjects.get(a);return u===void 0?[]:i.sequence.__experimental_getKeyframes(u.props[r])}getSheetObjectVectors(t,n){const r=this.sheet(t);if(r===void 0)return[];const i=`${t}_${n}`,a=this.sheetObjects.get(i);if(a===void 0)return[];const u=[],d=r.sequence.__experimental_getKeyframes(a.props.x),m=r.sequence.__experimental_getKeyframes(a.props.y),y=r.sequence.__experimental_getKeyframes(a.props.z),x=new Set;return d.forEach(A=>x.add(A.position)),m.forEach(A=>x.add(A.position)),y.forEach(A=>x.add(A.position)),Array.from(x).sort((A,N)=>A-N).forEach(A=>{const N=(F,B)=>{const I=F.find((C,ne)=>{var ie;return C.position<=B&&(((ie=F[ne+1])==null?void 0:ie.position)||1/0)>B}),G=F.find(C=>C.position>B);if(!I)return(G==null?void 0:G.value)||0;if(!G||I.position===B)return I.value;if(I.type==="bezier")return nZe(I,G,B);const ee=(B-I.position)/(G.position-I.position);return I.value+ee*(G.value-I.value)};u.push({position:A,x:N(d,A),y:N(m,A),z:N(y,A)})}),u}update(t){}unsubscribe(t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=t.address.sheetId,r=t.address.objectKey,i=this.sheets.get(n);i==null||i.detachObject(r);const a=`${n}_${r}`,u=this.sheetObjectUnsubscribe.get(a);u!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),u())}handleApp(t){var r,i;let n;switch(t.event){case"setSheet":n=this.sheets.get(t.data.sheet),n!==void 0?(r=this.studio)==null||r.setSelection([n]):console.log(`Hermes - Can't set Sheet: ${t.data.sheet}`,n);break;case"setSheetObject":n=this.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),n!==void 0?(i=this.studio)==null||i.setSelection([n]):console.log(`Hermes - Can't set Sheet Object: ${t.data.sheet}, ${t.data.key}: ${t.data.sheet}_${t.data.key}`,n);break;case"updateSheetObject":n=this.sheets.get(t.data.sheet),n!==void 0&&n.sequence.pause(),n=this.sheetObjectCBs.get(t.data.sheetObject),n!==void 0?n(t.data.values):console.log(`Hermes - Can't update Sheet Object: ${t.data.sheetObject}, ${t.data.sheet}`,n);break;case"updateTimeline":n=this.sheets.get(t.data.sheet),n!==void 0?n.sequence.position=t.data.position:console.log(`Hermes - Can't update sheet position: ${t.data.sheet}, ${t.data.position}`);break}}handleEditor(t){var n,r;switch(t.event){case"playSheet":(n=this.sheet(t.data.sheet,t.data.instance))==null||n.sequence.play(t.data.value);break;case"pauseSheet":(r=this.sheet(t.data.sheet,t.data.instance))==null||r.sequence.pause();break}}getSheetNames(){const t=[];return this.sheets.forEach((n,r)=>{t.push(r)}),t}handleEditorApp(){var t,n,r;if(this.editor){(t=this.studio)==null||t.ui.restore(),(n=this.studio)==null||n.onSelectionChange(d=>{d.length<1||d.forEach(m=>{let y=m.address.sheetId,x="setSheet",w={};switch(m.type){case"Theatre_Sheet_PublicAPI":x="setSheet",w={sheet:m.address.sheetId},this.activeSheet=this.sheets.get(m.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":x="setSheetObject",y+=`_${m.address.objectKey}`,w={id:y,sheet:m.address.sheetId,key:m.address.objectKey},this.activeSheet=this.sheets.get(m.address.sheetId);break}this.send({event:x,target:"app",data:w})})});let i=-1;const a=()=>{if(this.activeSheet!==void 0&&i!==this.activeSheet.sequence.position){i=this.activeSheet.sequence.position;const d=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:i,sheet:d.address.sheetId}})}},u=()=>{a(),requestAnimationFrame(u)};a(),u()}else(r=this.studio)==null||r.ui.hide()}}function GZe(o){if(o.name==="cameras")return"camera";if(o.name==="interactive")return"interactive";if(o.name==="lights")return"light";if(o.name==="ui")return"ui";if(o.name==="utils")return"utils";const e=o.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function y9(o){const e={name:o.name,type:o.type,uuid:o.uuid,children:[]};return o.children.forEach(t=>{e.children.push(y9(t))}),e}function E4e(o){var e;return{src:((e=o.image)==null?void 0:e.src)??"",offset:[o.offset.x,o.offset.y],repeat:[o.repeat.x,o.repeat.y]}}const M4e={src:"",offset:[0,0],repeat:[1,1]};function iZe(o){const e={};for(const t in o){const n=o[t];if(n!==null&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"value")){const i=n.value;i==null?e[t]={value:M4e}:i.isTexture?e[t]={value:E4e(i)}:e[t]={value:i}}else n==null?e[t]=M4e:n.isTexture?e[t]=E4e(n):e[t]=n}return e}function sZe(o){switch(o){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function jy(o){const e={};for(const t in o){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||sZe(t))continue;const n=typeof o[t],r=o[t];switch(n){case"boolean":case"number":case"string":e[t]=r;break;case"object":if(r!==null)if(r.isTexture)e[t]={src:su.renderToBlob(r),offset:[r.offset.x,r.offset.y],repeat:[r.repeat.x,r.repeat.y]};else if(r.isUniformNode){const i=r.value;e[t]={__isUniform:!0,value:i!=null&&i.isTexture?{src:su.renderToBlob(i),offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}:i}}else t==="uniforms"?e[t]=iZe(r):t.search("Node")>-1||(e[t]=r);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(e[t]={src:"",offset:[0,0],repeat:[1,1]});break}}return o.anisotropy!==void 0&&(e.anisotropy=o.anisotropy),o.clearcoat!==void 0&&(e.clearcoat=o.clearcoat),o.iridescence!==void 0&&(e.iridescence=o.iridescence),o.dispersion!==void 0&&(e.dispersion=o.dispersion),o.sheen!==void 0&&(e.sheen=o.sheen),o.transmission!==void 0&&(e.transmission=o.transmission),o.transmission!==void 0&&(e.transmission=o.transmission),e}function RG(o){o.updateMatrix();const e={name:o.name,type:o.type,uuid:o.uuid,visible:o.visible,matrix:o.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};o.animations.forEach(n=>{e.animations.push({name:n.name,duration:n.duration,blendMode:n.blendMode})});const t=o.type.toLowerCase();if(t.search("mesh")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else if(t.search("points")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else if(t.search("line")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else t.search("camera")>-1?o.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:o.fov,zoom:o.zoom,near:o.near,far:o.far,focus:o.focus,aspect:o.aspect,filmGauge:o.filmGauge,filmOffset:o.filmOffset}:o.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:o.zoom,near:o.near,far:o.far,left:o.left,right:o.right,top:o.top,bottom:o.bottom}):t.search("light")>-1&&(e.lightInfo={color:o.color,intensity:o.intensity,decay:o.decay,distance:o.distance,angle:o.angle,penumbra:o.penumbra,groundColor:o.groundColor,width:o.width,height:o.height});return e}function oZe(o,e){const t=e.split(".");switch(t.length){case 1:return o[t[0]];case 2:return o[t[0]][t[1]];case 3:return o[t[0]][t[1]][t[2]];case 4:return o[t[0]][t[1]][t[2]][t[3]];case 5:return o[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return o[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function aZe(o,e){for(const t in e)o[t]=e[t]}function lZe(o,e,t){if(o===void 0){console.log(`Hermes - Can't set props: ${e}`,t);return}const n=e.split("."),r=n.length;if(typeof t!="object")switch(r){case 1:o[n[0]]=t;break;case 2:o[n[0]][n[1]]=t;break;case 3:o[n[0]][n[1]][n[2]]=t;break;case 4:o[n[0]][n[1]][n[2]][n[3]]=t;break;case 5:o[n[0]][n[1]][n[2]][n[3]][n[4]]=t;break}else{let a;switch(r){case 1:a=o[n[0]];break;case 2:a=o[n[0]][n[1]];break;case 3:a=o[n[0]][n[1]][n[2]];break;case 4:a=o[n[0]][n[1]][n[2]][n[3]];break;case 5:a=o[n[0]][n[1]][n[2]][n[3]][n[4]];break}a!=null?aZe(a,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function uZe(o){return new Promise((e,t)=>{const n=new Image;n.onload=()=>{const r=new uo(n);r.wrapS=Jc,r.wrapT=Jc,r.needsUpdate=!0,e(r)},n.onerror=t,n.src=o})}function cZe(o,e,t){return Math.min(e,Math.max(o,t))}function jZe(o,e,t){return(t-o)/(e-o)}function HZe(o,e,t){return o*(1-t)+e*t}function WZe(o,e=1){return Number(o.toFixed(e))}var dZe=(o=>(o.CUSTOM="ToolEvents::custom",o.SELECT_DROPDOWN="ToolEvents::selectDropdown",o.DRAG_UPDATE="ToolEvents::dragUpdate",o.ADD_SCENE="ToolEvents::addScene",o.REFRESH_SCENE="ToolEvents::refreshScene",o.REMOVE_SCENE="ToolEvents::removeScene",o.SET_SCENE="ToolEvents::setScene",o.SET_OBJECT="ToolEvents::setObject",o.CLEAR_OBJECT="ToolEvents::clearObject",o.ADD_CAMERA="ToolEvents::addCamera",o.REMOVE_CAMERA="ToolEvents::removeCamera",o.ADD_GROUP="ToolEvents::addGroup",o.REMOVE_GROUP="ToolEvents::removeGroup",o.ADD_SPLINE="ToolEvents::addSpline",o.ADD_RENDERER="ToolEvents::addRenderer",o.UPDATE_RENDERER="ToolEvents::updateRenderer",o))(dZe||{});class hZe extends Uye{constructor(t,n=!1,r=!1){super("RemoteThree",n,r);ur(this,"name");ur(this,"canvas",null);ur(this,"inputElement",null);ur(this,"scene");ur(this,"scenes",new Map);ur(this,"renderer");ur(this,"renderTargets",new Map);ur(this,"renderTargetsResize",new Map);ur(this,"groups",new Map);ur(this,"_listeners",{});this.name=t}dispose(){var t;this.scenes.forEach(n=>{Wb(n)}),this.scenes.clear(),this.scene&&Wb(this.scene),this.renderTargets.forEach(n=>{n.dispose()}),this.renderTargets.clear(),(t=this.renderer)==null||t.dispose()}addEventListener(t,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(n)===-1&&r[t].push(n)}hasEventListener(t,n){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(n)!==-1}removeEventListener(t,n){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(t){const n=this._listeners;if(n===void 0)return;const r=n[t.type];if(r!==void 0){const i={...t,target:this},a=r.slice(0);for(let u=0,d=a.length;u<d;u++)a[u].call(this,i)}}getObjectByUUID(t){const n=t.split(".")[0],r=this.scenes.get(n);if(r!==void 0)return r.getObjectByProperty("uuid",t)}getObject(t){if(!this.debug)return;this.renderer!==void 0&&(su.renderer=this.renderer);const n=this.getObjectByUUID(t);n&&this.setObject(n)}setObject(t){this.renderer!==void 0&&(su.renderer=this.renderer);const n=RG(t);this.dispatchEvent({type:"ToolEvents::setObject",value:n})}requestMethod(t,n,r,i){const a=this.getObjectByUUID(t);if(a)try{i!==void 0?oZe(a,i)[n](r):a[n](r)}catch(u){console.log("Hermes - Error requesting method:",t,n,r),console.log(u)}}updateObject(t,n,r){this.send({event:"updateObject",target:"app",data:{uuid:t,key:n,value:r}})}createTexture(t,n,r){this.send({event:"createTexture",target:"app",data:{uuid:t,key:n,value:r}})}onUpdateObject(t,n,r){const i=this.getObjectByUUID(t);i&&lZe(i,n,r)}onCreateTexture(t,n,r){const i=this.getObjectByUUID(t);if(i){const a=u=>{const d=n.split(".");switch(d.length){case 1:i[d[0]]=u;break;case 2:i[d[0]][d[1]]=u;break;case 3:i[d[0]][d[1]][d[2]]=u;break;case 4:i[d[0]][d[1]][d[2]][d[3]]=u;break;case 5:i[d[0]][d[1]][d[2]][d[3]][d[4]]=u;break}i.material.needsUpdate=!0};r.src.length>0?uZe(r.src).then(u=>{u.offset.set(r.offset[0],r.offset[1]),u.repeat.set(r.repeat[0],r.repeat[1]),a(u)}):a(null)}}addGroup(t){this.groups.get(t.title)===void 0&&(this.groups.set(t.title,{title:t.title,onUpdate:t.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(t)}))}removeGroup(t){this.groups.get(t)!==void 0&&(this.groups.delete(t),this.send({event:"removeGroup",target:"editor",data:t}))}updateGroup(t,n,r){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:t,prop:n,value:r})})}addSplineCurve(t){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(t.toJSON())})},1)}addSplineObject(t){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(t)})},1)}setRenderer(t,n=null){if(this.renderer=t,this.canvas=t.domElement,this.inputElement=n!==null?n:this.canvas,!this.debug)return;const r=`#${t.getClearColor(new An).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:t.autoClearColor,outputColorSpace:t.outputColorSpace,clearColor:r,clearAlpha:t.getClearAlpha(),colorManagement:Qn.enabled,toneMapping:t.toneMapping,toneMappingExposure:t.toneMappingExposure,type:t.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(t){this.send({event:"updateRenderer",target:"app",data:t})}addScene(t){if(t===void 0||(this.scenes.set(t.name,t),!this.debug))return;MN(),I9(t);const n=y9(t);this.send({event:"addScene",target:"editor",data:n})}refreshScene(t){if(!this.debug)return;const n=this.scenes.get(t);if(n!==void 0){const r=y9(n);this.send({event:"refreshScene",target:"app",data:r})}}removeScene(t){if(t===void 0||(this.scenes.delete(t.name),!this.debug))return;const n=y9(t);this.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(t=>this.removeScene(t))}getScene(t){let n=null;return this.scene!==void 0&&this.scene.uuid.search(t)>-1?this.scene:(this.scenes.forEach((r,i)=>{t.search(i)>-1&&(n=r)}),n)}setScene(t){if(t===void 0||(this.scene=t,!this.debug))return;this.renderer!==void 0&&(su.renderer=this.renderer),MN(),I9(t);const n=y9(t);this.send({event:"setScene",target:"editor",data:n})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(t){if(!this.debug)return;const n=RG(t);this.send({event:"addCamera",target:"editor",data:n})}removeCamera(t){if(!this.debug)return;const n=RG(t);this.send({event:"removeCamera",target:"editor",data:n})}handleApp(t){switch(t.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:y9(this.scenes.get(t.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=t.data.autoClearColor,this.renderer.outputColorSpace=t.data.outputColorSpace,this.renderer.setClearColor(t.data.clearColor,t.data.clearAlpha),this.renderer.toneMapping=t.data.toneMapping,this.renderer.toneMappingExposure=t.data.toneMappingExposure,Qn.enabled=t.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const n=`#${this.renderer.getClearColor(new An).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:n,clearAlpha:this.renderer.getClearAlpha(),colorManagement:Qn.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(n=>{MN(),I9(n),this.send({event:"addScene",target:"editor",data:y9(n)})}),this.scene!==void 0&&(this.renderer!==void 0&&(su.renderer=this.renderer),MN(),I9(this.scene),this.send({event:"setScene",target:"editor",data:y9(this.scene)}));break}if(t.event==="updateGroup"){const n=JSON.parse(t.data),r=this.groups.get(n.group);r==null||r.onUpdate(n.prop,n.value)}}handleEditor(t){switch(t.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:t.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:t.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:t.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:t.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:t.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:t.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:t.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:t.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:t.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:t.data})}}messageHandler(t){const n=t.data;if(n.event==="updateObject"){this.onUpdateObject(n.data.uuid,n.data.key,n.data.value);return}else if(n.event==="createTexture"){this.onCreateTexture(n.data.uuid,n.data.key,n.data.value);return}else if(n.event==="requestSize"){n.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(r=>{r.resize!==void 0&&r.resize(n.data.width,n.data.height)});return}n.target==="app"?this.handleApp(n):this.handleEditor(n)}addRT(t,n=!0,r){if(!this.renderer)return;let i;this.renderer instanceof ZW?i=new ah(32,32,r):i=new Af(32,32,r),i.texture.name=t,this.renderTargets.set(t,i),this.renderTargetsResize.set(t,n)}removeRT(t){this.renderTargets.delete(t),this.renderTargetsResize.delete(t)}resize(t,n){var a,u;const r=this.dpr;this.renderTargets.forEach((d,m)=>{this.renderTargetsResize.get(m)&&d.setSize(t*r,n*r)});const i=!(((a=this.renderer)==null?void 0:a.domElement)instanceof OffscreenCanvas);(u=this.renderer)==null||u.setSize(t,n,i)}set dpr(t){var n;(n=this.renderer)==null||n.setPixelRatio(cZe(1,2,t))}get dpr(){var t;return this.renderer!==void 0?(t=this.renderer)==null?void 0:t.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}}class fZe extends ZYe{constructor(t,n,r){super(n,r);ur(this,"theatre");ur(this,"three");this.theatre=new rZe(n,r),this.three=new hZe(t,n,r),this.addComponent("theatre",this.theatre),this.addComponent("three",this.three)}init(t){return new Promise((n,r)=>{if(this.isApp){const i=new ZW({canvas:t,stencil:!1});i.shadowMap.enabled=!0,i.setPixelRatio(Math.min(1.5,devicePixelRatio)),i.setClearColor(0),i.inspector=new yye,this.three.setRenderer(i,t),i.init().then(()=>n()).catch(()=>{console.log("Error creating WebGPU Renderer"),r()})}else r()})}}const pZe=new Map([["Scene2",Lye],["Scene3",Fye],["RTTScene",Dye]]),C4e=E9.lazy(()=>FFe(()=>import("./ThreeEditor-BjAFHK3t.js"),__vite__mapDeps([0,1]))),dI=new fZe("Hermes Example",kFe,x5e);x5e&&PN&&(PN.initialize(),dI.theatre.studio=PN,dI.theatre.handleEditorApp());function mZe(){return ia.jsx(BFe,{app:dI,onLoad:xYe,renderEditor:C4e?o=>ia.jsx(E9.Suspense,{fallback:null,children:ia.jsx(C4e,{three:o,scenes:pZe,onSceneAdd:e=>{e.setup(dI),e.init()},onSceneUpdate:e=>{e.update()}})}):void 0,children:o=>ia.jsx(jYe,{app:o})})}PN.initialize();sRe.createRoot(document.getElementById("root")).render(ia.jsx(ia.Fragment,{children:ia.jsx(ia.Fragment,{children:ia.jsx(mZe,{})})}));export{lb as $,VZe as A,Yi as B,An as C,Na as D,JYe as E,Dr as F,v2e as G,jZe as H,N0 as I,cZe as J,WZe as K,HN as L,cs as M,eo as N,HZe as O,T6 as P,zBe as Q,lZe as R,I1 as S,dZe as T,uZe as U,hu as V,Ej as W,Mj as X,Cj as Y,kg as Z,ab as _,O1 as a,Zu as a$,Aj as a0,Pj as a1,Rj as a2,Nj as a3,Ij as a4,uRe as a5,cRe as a6,dRe as a7,hRe as a8,k0 as a9,vZe as aA,UZe as aB,Gn as aC,Ky as aD,TZe as aE,vI as aF,L1 as aG,$9 as aH,o3e as aI,Cr as aJ,MZe as aK,ZW as aL,NVe as aM,Ra as aN,M6 as aO,wZe as aP,W4e as aQ,bZe as aR,FIe as aS,_Ze as aT,SZe as aU,EYe as aV,GZe as aW,xZe as aX,Es as aY,ya as aZ,Qn as a_,wj as aa,Tj as ab,k4e as ac,D4e as ad,a0 as ae,gl as af,M9 as ag,C9 as ah,A9 as ai,r6 as aj,zZe as ak,Nf as al,En as am,Ae as an,sa as ao,UIe as ap,ra as aq,yZe as ar,Fi as as,sH as at,X9 as au,uH as av,J4e as aw,v6 as ax,nd as ay,Wb as az,Yc as b,kj as b0,Dj as b1,Lj as b2,Oj as b3,Fj as b4,Bj as b5,F4e as b6,us as c,Ef as d,TT as e,PZe as f,ta as g,kZe as h,Wc as i,ia as j,IZe as k,Vw as l,_Ke as m,RZe as n,LZe as o,xG as p,FZe as q,E9 as r,NZe as s,OZe as t,Yd as u,RKe as v,DZe as w,AZe as x,BN as y,BZe as z};
10226
+ `,w=m.createShader(35633),A=m.createShader(35632),N=m.createProgram();if(!(A&&w&&N))return;m.shaderSource(w,y),m.shaderSource(A,x),m.compileShader(w),m.compileShader(A),m.attachShader(N,w),m.attachShader(N,A),m.linkProgram(N),m.detachShader(N,w),m.detachShader(N,A),m.deleteShader(w),m.deleteShader(A),m.useProgram(N);const F=m.createBuffer();m.bindBuffer(34962,F),m.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const B=m.getAttribLocation(N,"aPosition");m.vertexAttribPointer(B,3,5126,!1,0,0),m.enableVertexAttribArray(B),m.clearColor(1,1,1,1),m.clear(16384),m.viewport(0,0,1,1),m.drawArrays(4,0,3);const I=new Uint8Array(4);return m.readPixels(0,0,1,1,6408,5121,I),m.deleteProgram(N),m.deleteBuffer(F),I.join("")}(o),r="801621810",i="8016218135",a="80162181161",u=v1!=null&&v1.isIpad?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["a15",r,15],["m1",r,15],["m2",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15],["a15",r,15],["a16",r,15],["a17",r,15]];let d;return n==="80162181255"?d=u.filter(([,,m])=>m>=14):(d=u.filter(([,m])=>m===n),d.length||(d=u)),d.map(([m])=>`apple ${m} gpu`)}class w4e extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const PG=[],T4e=[];function qYe(o,e){if(o===e)return 0;const t=o;o.length>e.length&&(o=e,e=t);let n=o.length,r=e.length;for(;n>0&&o.charCodeAt(~-n)===e.charCodeAt(~-r);)n--,r--;let i,a=0;for(;a<n&&o.charCodeAt(a)===e.charCodeAt(a);)a++;if(n-=a,r-=a,n===0)return r;let u,d,m=0,y=0,x=0;for(;y<n;)T4e[y]=o.charCodeAt(a+y),PG[y]=++y;for(;x<r;)for(i=e.charCodeAt(a+x),u=x++,m=x,y=0;y<n;y++)d=i===T4e[y]?u:u+1,u=PG[y],m=PG[y]=u>m?d>m?m+1:d:d>u?u+1:d;return m}function $Ye(o){return o!=null}const XYe=({mobileTiers:o=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:t={},glContext:n,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@5.0.70/dist/benchmarks"}={})=>AG(void 0,void 0,void 0,function*(){const a={};if(Bye)return{tier:0,type:"SSR"};const{isIpad:u=!!(v1!=null&&v1.isIpad),isMobile:d=!!(v1!=null&&v1.isMobile),screenSize:m=window.screen,loadBenchmarks:y=ne=>AG(void 0,void 0,void 0,function*(){const ie=yield fetch(`${i}/${ne}`).then(ue=>ue.json());if(parseInt(ie.shift().split(".")[0],10)<4)throw new w4e("Detect GPU benchmark data is out of date. Please update to version 4x");return ie})}=t;let{renderer:x}=t;const w=(ne,ie,ue,V,se)=>({device:se,fps:V,gpu:ue,isMobile:d,tier:ne,type:ie});let A,N="";if(x)x=S4e(x),A=[x];else{const ne=n||function(ue,V=!1){const se={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:V,powerPreference:"high-performance",stencil:!1};ue&&delete se.powerPreference;const we=window.document.createElement("canvas"),X=we.getContext("webgl",se)||we.getContext("experimental-webgl",se);return X??void 0}(v1==null?void 0:v1.isSafari12,r);if(!ne)return w(0,"WEBGL_UNSUPPORTED");const ie=v1!=null&&v1.isFirefox?null:ne.getExtension("WEBGL_debug_renderer_info");if(x=ie?ne.getParameter(ie.UNMASKED_RENDERER_WEBGL):ne.getParameter(ne.RENDERER),!x)return w(1,"FALLBACK");N=x,x=S4e(x),A=function(ue,V,se){return V==="apple gpu"?WYe(ue,V,se):[V]}(ne,x,d)}const F=(yield Promise.all(A.map(function(ne){var ie;return AG(this,void 0,void 0,function*(){const ue=(Rt=>{const pn=d?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const gn of pn)if(Rt.includes(gn))return gn})(ne);if(!ue)return;const V=`${d?"m":"d"}-${ue}${u?"-ipad":""}.json`,se=a[V]=(ie=a[V])!==null&&ie!==void 0?ie:y(V);let we;try{we=yield se}catch(Rt){if(Rt instanceof w4e)throw Rt;return}const X=function(Rt){var pn;const gn=(Rt=Rt.replace(/\([^)]+\)/,"")).match(/\d+/)||Rt.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(pn=gn==null?void 0:gn.join("").replace(/\W|amd/g,""))!==null&&pn!==void 0?pn:""}(ne);let Ne=we.filter(([,Rt])=>Rt===X);Ne.length||(Ne=we.filter(([Rt])=>Rt.includes(ne)));const Be=Ne.length;if(Be===0)return;const He=ne.split(/[.,()\[\]/\s]/g).sort().filter((Rt,pn,gn)=>pn===0||Rt!==gn[pn-1]).join(" ");let Ge,[le,,,,Ye]=Be>1?Ne.map(Rt=>[Rt,qYe(He,Rt[2])]).sort(([,Rt],[,pn])=>Rt-pn)[0][0]:Ne[0],Ie=Number.MAX_VALUE;const{devicePixelRatio:at}=window,yt=m.width*at*m.height*at;for(const Rt of Ye){const[pn,gn]=Rt,xt=pn*gn,Lt=Math.abs(yt-xt);Lt<Ie&&(Ie=Lt,Ge=Rt)}if(!Ge)return;const[,,ke,ut]=Ge;return[Ie,ke,le,ut]})}))).filter($Ye).sort(([ne=Number.MAX_VALUE,ie],[ue=Number.MAX_VALUE,V])=>ne===ue?ie-V:ne-ue);if(!F.length){const ne=HYe.find(ie=>x.includes(ie));return ne?w(0,"BLOCKLISTED",ne):w(1,"FALLBACK",`${x} (${N})`)}const[,B,I,G]=F[0];if(B===-1)return w(0,"BLOCKLISTED",I,B,G);const ee=d?o:e;let C=0;for(let ne=0;ne<ee.length;ne++)B>=ee[ne]&&(C=ne);return w(C,"BENCHMARK",I,B,G)});function KYe(o){let e=0;const t=performance.now();function n(){e++;const r=performance.now();if(r-t>=100){const i=e/((r-t)/1e3),a=Math.round(i/30)*30;o(a)}else requestAnimationFrame(n)}requestAnimationFrame(n)}function YYe(o=!1,e=!1){return new Promise(t=>{XYe().then(n=>{let r=!1;const i=document.createElement("canvas"),a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);if(r="transferControlToOffscreen"in i,a){const d=navigator.userAgent.match(/version\/(\d+)/i);r=(d?parseInt(d[1]):0)>=17}const u={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:n.isMobile!==void 0?n.isMobile:!1,supportOffScreenCanvas:r,supportWebGPU:!!navigator.gpu,quality:"Low",dev:o,editor:e};n.tier===3?u.quality="High":n.tier===2&&(u.quality="Medium"),KYe(d=>{u.fps=d,t(u)})})})}class ZYe{constructor(e,t=!1){ur(this,"assets",{audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map});ur(this,"components",new Map);ur(this,"settings",{dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1});ur(this,"onUpdateCallback");ur(this,"playing",!1);ur(this,"rafID",-1);ur(this,"play",()=>{this.playing||(this.playing=!0,this.onUpdate())});ur(this,"pause",()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)});ur(this,"onUpdate",()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)});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=>{YYe(this.settings.dev,this.settings.editor).then(t=>{this.settings=t,e()})})}update(){}draw(){}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}}var QYe=P4e();class Uye{constructor(e,t=!1,n=!1){ur(this,"name");ur(this,"debug");ur(this,"editor");ur(this,"broadcastChannel");ur(this,"onMessageHandler");this.name=e,this.debug=t,this.editor=n,t&&(this.broadcastChannel=new BroadcastChannel(e),this.onMessageHandler=this.messageHandler.bind(this),this.broadcastChannel.addEventListener("message",this.onMessageHandler))}dispose(){var e,t;(e=this.broadcastChannel)==null||e.removeEventListener("message",this.onMessageHandler),(t=this.broadcastChannel)==null||t.close()}send(e){var n;if(this.editor&&e.target==="app"||!this.editor&&e.target==="editor")try{(n=this.broadcastChannel)==null||n.postMessage(e)}catch(r){console.log("Hermes - Error sending message:"),console.log(r),console.log(e)}}messageHandler(e){const t=e.data;t.target==="app"?this.handleApp(t):this.handleEditor(t)}handleApp(e){}handleEditor(e){}}const JYe=()=>{};function BZe(o){return o.substring(0,1).toUpperCase()+o.substring(1)}function UZe(o){const e=JSON.stringify(o);return navigator.clipboard.writeText(e),e}function VZe(){return Math.round(Math.random()*1e6).toString()}function eZe(o){return o.r!==void 0&&o.g!==void 0&&o.b!==void 0}function zZe(o){const e=Math.round(o.r*255),t=Math.round(o.g*255),n=Math.round(o.b*255),r=d=>{const m=d.toString(16);return m.length===1?"0"+m:m},i=r(e),a=r(t),u=r(n);return"#"+i+a+u}function tZe(o,e,t,n,r){const i=1-o;return i*i*i*e+3*i*i*o*t+3*i*o*o*n+o*o*o*r}function nZe(o,e,t){if(o.type!=="bezier"||o.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[n,r]=o.handles,i=(t-o.position)/(e.position-o.position);return tZe(i,o.value,o.value+n,e.value+r,e.value)}class rZe extends Uye{constructor(t=!1,n=!1){super("RemoteTheatre",t,n);ur(this,"project");ur(this,"sheets",new Map);ur(this,"sheetObjects",new Map);ur(this,"sheetObjectCBs",new Map);ur(this,"sheetObjectUnsubscribe",new Map);ur(this,"activeSheet");ur(this,"studio")}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}loadProject(t,n){return this.project=QYe.getProject(t,{state:n}),new Promise((r,i)=>{var a;(a=this.project)==null||a.ready.then(()=>{if(n){const u=n.sheetsById;for(const d in u)this.sheet(d)}r()}).catch(()=>i())})}getSheetInstance(t,n){return n!==void 0?`${t}-${n}`:t}sheet(t,n){var a;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const r=this.getSheetInstance(t,n);let i=this.sheets.get(r);return i!==void 0||(i=(a=this.project)==null?void 0:a.sheet(t,n),this.sheets.set(r,i)),i}playSheet(t,n,r){return new Promise(i=>{var a;(a=this.sheet(t,r))==null||a.sequence.play(n).then(u=>i(u)),this.send({event:"playSheet",target:"editor",data:{sheet:t,instance:r,value:n}})})}pauseSheet(t,n){var r;(r=this.sheet(t,n))==null||r.sequence.pause(),this.send({event:"pauseSheet",target:"editor",data:{sheet:t,instance:n}})}clearSheetObjects(t){this.sheetObjects.forEach((n,r)=>{r.search(`${t}_`)>-1&&this.unsubscribe(n)})}sheetObject(t,n,r,i,a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const u=this.sheet(t,a);if(u===void 0)return;const m=`${this.getSheetInstance(t,a)}_${n}`;let y=this.sheetObjects.get(m),x=r;y!==void 0&&(x={...r,...y.value}),y=u.object(n,x,{reconfigure:!0}),this.sheetObjects.set(m,y),this.sheetObjectCBs.set(m,i!==void 0?i:JYe);function w(N,F,B){if(typeof B=="object")if(eZe(B))N[F]={r:B.r,g:B.g,b:B.b,a:B.a};else for(const I in B){const G=B[I];typeof G=="object"&&w(B,I,G)}}const A=y.onValuesChange(N=>{const F=this.sheetObjectCBs.get(m);if(this.editor){for(const B in N){const I=N[B];typeof I=="object"&&w(N,B,I)}this.send({event:"updateSheetObject",target:"app",data:{sheet:t,sheetObject:m,values:N}}),F&&F(N)}else F&&F(N)});return this.sheetObjectUnsubscribe.set(m,A),y}getSheetObjectKeyframes(t,n,r){const i=this.sheet(t);if(i===void 0)return[];const a=`${t}_${n}`,u=this.sheetObjects.get(a);return u===void 0?[]:i.sequence.__experimental_getKeyframes(u.props[r])}getSheetObjectVectors(t,n){const r=this.sheet(t);if(r===void 0)return[];const i=`${t}_${n}`,a=this.sheetObjects.get(i);if(a===void 0)return[];const u=[],d=r.sequence.__experimental_getKeyframes(a.props.x),m=r.sequence.__experimental_getKeyframes(a.props.y),y=r.sequence.__experimental_getKeyframes(a.props.z),x=new Set;return d.forEach(A=>x.add(A.position)),m.forEach(A=>x.add(A.position)),y.forEach(A=>x.add(A.position)),Array.from(x).sort((A,N)=>A-N).forEach(A=>{const N=(F,B)=>{const I=F.find((C,ne)=>{var ie;return C.position<=B&&(((ie=F[ne+1])==null?void 0:ie.position)||1/0)>B}),G=F.find(C=>C.position>B);if(!I)return(G==null?void 0:G.value)||0;if(!G||I.position===B)return I.value;if(I.type==="bezier")return nZe(I,G,B);const ee=(B-I.position)/(G.position-I.position);return I.value+ee*(G.value-I.value)};u.push({position:A,x:N(d,A),y:N(m,A),z:N(y,A)})}),u}update(t){}unsubscribe(t){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const n=t.address.sheetId,r=t.address.objectKey,i=this.sheets.get(n);i==null||i.detachObject(r);const a=`${n}_${r}`,u=this.sheetObjectUnsubscribe.get(a);u!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),u())}handleApp(t){var r,i;let n;switch(t.event){case"setSheet":n=this.sheets.get(t.data.sheet),n!==void 0?(r=this.studio)==null||r.setSelection([n]):console.log(`Hermes - Can't set Sheet: ${t.data.sheet}`,n);break;case"setSheetObject":n=this.sheetObjects.get(`${t.data.sheet}_${t.data.key}`),n!==void 0?(i=this.studio)==null||i.setSelection([n]):console.log(`Hermes - Can't set Sheet Object: ${t.data.sheet}, ${t.data.key}: ${t.data.sheet}_${t.data.key}`,n);break;case"updateSheetObject":n=this.sheets.get(t.data.sheet),n!==void 0&&n.sequence.pause(),n=this.sheetObjectCBs.get(t.data.sheetObject),n!==void 0?n(t.data.values):console.log(`Hermes - Can't update Sheet Object: ${t.data.sheetObject}, ${t.data.sheet}`,n);break;case"updateTimeline":n=this.sheets.get(t.data.sheet),n!==void 0?n.sequence.position=t.data.position:console.log(`Hermes - Can't update sheet position: ${t.data.sheet}, ${t.data.position}`);break}}handleEditor(t){var n,r;switch(t.event){case"playSheet":(n=this.sheet(t.data.sheet,t.data.instance))==null||n.sequence.play(t.data.value);break;case"pauseSheet":(r=this.sheet(t.data.sheet,t.data.instance))==null||r.sequence.pause();break}}getSheetNames(){const t=[];return this.sheets.forEach((n,r)=>{t.push(r)}),t}handleEditorApp(){var t,n,r;if(this.editor){(t=this.studio)==null||t.ui.restore(),(n=this.studio)==null||n.onSelectionChange(d=>{d.length<1||d.forEach(m=>{let y=m.address.sheetId,x="setSheet",w={};switch(m.type){case"Theatre_Sheet_PublicAPI":x="setSheet",w={sheet:m.address.sheetId},this.activeSheet=this.sheets.get(m.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":x="setSheetObject",y+=`_${m.address.objectKey}`,w={id:y,sheet:m.address.sheetId,key:m.address.objectKey},this.activeSheet=this.sheets.get(m.address.sheetId);break}this.send({event:x,target:"app",data:w})})});let i=-1;const a=()=>{if(this.activeSheet!==void 0&&i!==this.activeSheet.sequence.position){i=this.activeSheet.sequence.position;const d=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:i,sheet:d.address.sheetId}})}},u=()=>{a(),requestAnimationFrame(u)};a(),u()}else(r=this.studio)==null||r.ui.hide()}}function GZe(o){if(o.name==="cameras")return"camera";if(o.name==="interactive")return"interactive";if(o.name==="lights")return"light";if(o.name==="ui")return"ui";if(o.name==="utils")return"utils";const e=o.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function y9(o){const e={name:o.name,type:o.type,uuid:o.uuid,children:[]};return o.children.forEach(t=>{e.children.push(y9(t))}),e}function E4e(o){var e;return{src:((e=o.image)==null?void 0:e.src)??"",offset:[o.offset.x,o.offset.y],repeat:[o.repeat.x,o.repeat.y]}}const M4e={src:"",offset:[0,0],repeat:[1,1]};function iZe(o){const e={};for(const t in o){const n=o[t];if(n!==null&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"value")){const i=n.value;i==null?e[t]={value:M4e}:i.isTexture?e[t]={value:E4e(i)}:e[t]={value:i}}else n==null?e[t]=M4e:n.isTexture?e[t]=E4e(n):e[t]=n}return e}function sZe(o){switch(o){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function jy(o){const e={};for(const t in o){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||sZe(t))continue;const n=typeof o[t],r=o[t];switch(n){case"boolean":case"number":case"string":e[t]=r;break;case"object":if(r!==null)if(r.isTexture)e[t]={src:su.renderToBlob(r),offset:[r.offset.x,r.offset.y],repeat:[r.repeat.x,r.repeat.y]};else if(r.isUniformNode){const i=r.value;e[t]={__isUniform:!0,value:i!=null&&i.isTexture?{src:su.renderToBlob(i),offset:[i.offset.x,i.offset.y],repeat:[i.repeat.x,i.repeat.y]}:i}}else t==="uniforms"?e[t]=iZe(r):t.search("Node")>-1||(e[t]=r);else t==="glslVersion"?e[t]="":t.search("Node")>-1||(e[t]={src:"",offset:[0,0],repeat:[1,1]});break}}return o.anisotropy!==void 0&&(e.anisotropy=o.anisotropy),o.clearcoat!==void 0&&(e.clearcoat=o.clearcoat),o.iridescence!==void 0&&(e.iridescence=o.iridescence),o.dispersion!==void 0&&(e.dispersion=o.dispersion),o.sheen!==void 0&&(e.sheen=o.sheen),o.transmission!==void 0&&(e.transmission=o.transmission),o.transmission!==void 0&&(e.transmission=o.transmission),e}function RG(o){o.updateMatrix();const e={name:o.name,type:o.type,uuid:o.uuid,visible:o.visible,matrix:o.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};o.animations.forEach(n=>{e.animations.push({name:n.name,duration:n.duration,blendMode:n.blendMode})});const t=o.type.toLowerCase();if(t.search("mesh")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else if(t.search("points")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else if(t.search("line")>-1){const n=o;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(jy(i))}),e.material=r}else e.material=jy(n.material)}else t.search("camera")>-1?o.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:o.fov,zoom:o.zoom,near:o.near,far:o.far,focus:o.focus,aspect:o.aspect,filmGauge:o.filmGauge,filmOffset:o.filmOffset}:o.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:o.zoom,near:o.near,far:o.far,left:o.left,right:o.right,top:o.top,bottom:o.bottom}):t.search("light")>-1&&(e.lightInfo={color:o.color,intensity:o.intensity,decay:o.decay,distance:o.distance,angle:o.angle,penumbra:o.penumbra,groundColor:o.groundColor,width:o.width,height:o.height});return e}function oZe(o,e){const t=e.split(".");switch(t.length){case 1:return o[t[0]];case 2:return o[t[0]][t[1]];case 3:return o[t[0]][t[1]][t[2]];case 4:return o[t[0]][t[1]][t[2]][t[3]];case 5:return o[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return o[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function aZe(o,e){for(const t in e)o[t]=e[t]}function lZe(o,e,t){if(o===void 0){console.log(`Hermes - Can't set props: ${e}`,t);return}const n=e.split("."),r=n.length;if(typeof t!="object")switch(r){case 1:o[n[0]]=t;break;case 2:o[n[0]][n[1]]=t;break;case 3:o[n[0]][n[1]][n[2]]=t;break;case 4:o[n[0]][n[1]][n[2]][n[3]]=t;break;case 5:o[n[0]][n[1]][n[2]][n[3]][n[4]]=t;break}else{let a;switch(r){case 1:a=o[n[0]];break;case 2:a=o[n[0]][n[1]];break;case 3:a=o[n[0]][n[1]][n[2]];break;case 4:a=o[n[0]][n[1]][n[2]][n[3]];break;case 5:a=o[n[0]][n[1]][n[2]][n[3]][n[4]];break}a!=null?aZe(a,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function uZe(o){return new Promise((e,t)=>{const n=new Image;n.onload=()=>{const r=new uo(n);r.wrapS=Jc,r.wrapT=Jc,r.needsUpdate=!0,e(r)},n.onerror=t,n.src=o})}function cZe(o,e,t){return Math.min(e,Math.max(o,t))}function jZe(o,e,t){return(t-o)/(e-o)}function HZe(o,e,t){return o*(1-t)+e*t}function WZe(o,e=1){return Number(o.toFixed(e))}var dZe=(o=>(o.CUSTOM="ToolEvents::custom",o.SELECT_DROPDOWN="ToolEvents::selectDropdown",o.DRAG_UPDATE="ToolEvents::dragUpdate",o.ADD_SCENE="ToolEvents::addScene",o.REFRESH_SCENE="ToolEvents::refreshScene",o.REMOVE_SCENE="ToolEvents::removeScene",o.SET_SCENE="ToolEvents::setScene",o.SET_OBJECT="ToolEvents::setObject",o.CLEAR_OBJECT="ToolEvents::clearObject",o.ADD_CAMERA="ToolEvents::addCamera",o.REMOVE_CAMERA="ToolEvents::removeCamera",o.ADD_GROUP="ToolEvents::addGroup",o.REMOVE_GROUP="ToolEvents::removeGroup",o.ADD_SPLINE="ToolEvents::addSpline",o.ADD_RENDERER="ToolEvents::addRenderer",o.UPDATE_RENDERER="ToolEvents::updateRenderer",o))(dZe||{});class hZe extends Uye{constructor(t,n=!1,r=!1){super("RemoteThree",n,r);ur(this,"name");ur(this,"canvas",null);ur(this,"inputElement",null);ur(this,"scene");ur(this,"scenes",new Map);ur(this,"renderer");ur(this,"renderTargets",new Map);ur(this,"renderTargetsResize",new Map);ur(this,"groups",new Map);ur(this,"_listeners",{});this.name=t}dispose(){var t;this.scenes.forEach(n=>{Wb(n)}),this.scenes.clear(),this.scene&&Wb(this.scene),this.renderTargets.forEach(n=>{n.dispose()}),this.renderTargets.clear(),(t=this.renderer)==null||t.dispose()}addEventListener(t,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(n)===-1&&r[t].push(n)}hasEventListener(t,n){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(n)!==-1}removeEventListener(t,n){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(t){const n=this._listeners;if(n===void 0)return;const r=n[t.type];if(r!==void 0){const i={...t,target:this},a=r.slice(0);for(let u=0,d=a.length;u<d;u++)a[u].call(this,i)}}getObjectByUUID(t){const n=t.split(".")[0],r=this.scenes.get(n);if(r!==void 0)return r.getObjectByProperty("uuid",t)}getObject(t){if(!this.debug)return;this.renderer!==void 0&&(su.renderer=this.renderer);const n=this.getObjectByUUID(t);n&&this.setObject(n)}setObject(t){this.renderer!==void 0&&(su.renderer=this.renderer);const n=RG(t);this.dispatchEvent({type:"ToolEvents::setObject",value:n})}requestMethod(t,n,r,i){const a=this.getObjectByUUID(t);if(a)try{i!==void 0?oZe(a,i)[n](r):a[n](r)}catch(u){console.log("Hermes - Error requesting method:",t,n,r),console.log(u)}}updateObject(t,n,r){this.send({event:"updateObject",target:"app",data:{uuid:t,key:n,value:r}})}createTexture(t,n,r){this.send({event:"createTexture",target:"app",data:{uuid:t,key:n,value:r}})}onUpdateObject(t,n,r){const i=this.getObjectByUUID(t);i&&lZe(i,n,r)}onCreateTexture(t,n,r){const i=this.getObjectByUUID(t);if(i){const a=u=>{const d=n.split(".");switch(d.length){case 1:i[d[0]]=u;break;case 2:i[d[0]][d[1]]=u;break;case 3:i[d[0]][d[1]][d[2]]=u;break;case 4:i[d[0]][d[1]][d[2]][d[3]]=u;break;case 5:i[d[0]][d[1]][d[2]][d[3]][d[4]]=u;break}i.material.needsUpdate=!0};r.src.length>0?uZe(r.src).then(u=>{u.offset.set(r.offset[0],r.offset[1]),u.repeat.set(r.repeat[0],r.repeat[1]),a(u)}):a(null)}}addGroup(t){this.groups.get(t.title)===void 0&&(this.groups.set(t.title,{title:t.title,onUpdate:t.onUpdate}),this.send({event:"addGroup",target:"editor",data:JSON.stringify(t)}))}removeGroup(t){this.groups.get(t)!==void 0&&(this.groups.delete(t),this.send({event:"removeGroup",target:"editor",data:t}))}updateGroup(t,n,r){this.send({event:"updateGroup",target:"app",data:JSON.stringify({group:t,prop:n,value:r})})}addSplineCurve(t){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(t.toJSON())})},1)}addSplineObject(t){setTimeout(()=>{this.send({event:"addSpline",target:"editor",data:JSON.stringify(t)})},1)}setRenderer(t,n=null){if(this.renderer=t,this.canvas=t.domElement,this.inputElement=n!==null?n:this.canvas,!this.debug)return;const r=`#${t.getClearColor(new An).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:t.autoClearColor,outputColorSpace:t.outputColorSpace,clearColor:r,clearAlpha:t.getClearAlpha(),colorManagement:Qn.enabled,toneMapping:t.toneMapping,toneMappingExposure:t.toneMappingExposure,type:t.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}updateRenderer(t){this.send({event:"updateRenderer",target:"app",data:t})}addScene(t){if(t===void 0||(this.scenes.set(t.name,t),!this.debug))return;MN(),I9(t);const n=y9(t);this.send({event:"addScene",target:"editor",data:n})}refreshScene(t){if(!this.debug)return;const n=this.scenes.get(t);if(n!==void 0){const r=y9(n);this.send({event:"refreshScene",target:"app",data:r})}}removeScene(t){if(t===void 0||(this.scenes.delete(t.name),!this.debug))return;const n=y9(t);this.send({event:"removeScene",target:"editor",data:n})}removeAllScenes(){this.scenes.forEach(t=>this.removeScene(t))}getScene(t){let n=null;return this.scene!==void 0&&this.scene.uuid.search(t)>-1?this.scene:(this.scenes.forEach((r,i)=>{t.search(i)>-1&&(n=r)}),n)}setScene(t){if(t===void 0||(this.scene=t,!this.debug))return;this.renderer!==void 0&&(su.renderer=this.renderer),MN(),I9(t);const n=y9(t);this.send({event:"setScene",target:"editor",data:n})}requestSize(){this.send({event:"requestSize",target:"app"})}requestRenderer(){this.send({event:"requestRenderer",target:"app"})}requestScene(){this.send({event:"requestScene",target:"app"})}addCamera(t){if(!this.debug)return;const n=RG(t);this.send({event:"addCamera",target:"editor",data:n})}removeCamera(t){if(!this.debug)return;const n=RG(t);this.send({event:"removeCamera",target:"editor",data:n})}handleApp(t){switch(t.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:y9(this.scenes.get(t.data.name))});break;case"updateRenderer":this.renderer&&(this.renderer.autoClearColor=t.data.autoClearColor,this.renderer.outputColorSpace=t.data.outputColorSpace,this.renderer.setClearColor(t.data.clearColor,t.data.clearAlpha),this.renderer.toneMapping=t.data.toneMapping,this.renderer.toneMappingExposure=t.data.toneMappingExposure,Qn.enabled=t.data.colorManagement);break;case"requestRenderer":if(this.renderer!==void 0){const n=`#${this.renderer.getClearColor(new An).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClearColor:this.renderer.autoClearColor,outputColorSpace:this.renderer.outputColorSpace,clearColor:n,clearAlpha:this.renderer.getClearAlpha(),colorManagement:Qn.enabled,toneMapping:this.renderer.toneMapping,toneMappingExposure:this.renderer.toneMappingExposure,type:this.renderer.isWebGLRenderer?"WebGLRenderer":"WebGPURenderer"}})}break;case"requestScene":this.scenes.forEach(n=>{MN(),I9(n),this.send({event:"addScene",target:"editor",data:y9(n)})}),this.scene!==void 0&&(this.renderer!==void 0&&(su.renderer=this.renderer),MN(),I9(this.scene),this.send({event:"setScene",target:"editor",data:y9(this.scene)}));break}if(t.event==="updateGroup"){const n=JSON.parse(t.data),r=this.groups.get(n.group);r==null||r.onUpdate(n.prop,n.value)}}handleEditor(t){switch(t.event){case"addScene":this.dispatchEvent({type:"ToolEvents::addScene",value:t.data});break;case"refreshScene":this.dispatchEvent({type:"ToolEvents::refreshScene",value:t.data});break;case"removeScene":this.dispatchEvent({type:"ToolEvents::removeScene",value:t.data});break;case"setScene":this.dispatchEvent({type:"ToolEvents::setScene",value:t.data});break;case"addCamera":this.dispatchEvent({type:"ToolEvents::addCamera",value:t.data});break;case"removeCamera":this.dispatchEvent({type:"ToolEvents::removeCamera",value:t.data});break;case"addGroup":this.dispatchEvent({type:"ToolEvents::addGroup",value:t.data});break;case"removeGroup":this.dispatchEvent({type:"ToolEvents::removeGroup",value:t.data});break;case"addSpline":this.dispatchEvent({type:"ToolEvents::addSpline",value:t.data});break;case"addRenderer":this.dispatchEvent({type:"ToolEvents::addRenderer",value:t.data})}}messageHandler(t){const n=t.data;if(n.event==="updateObject"){this.onUpdateObject(n.data.uuid,n.data.key,n.data.value);return}else if(n.event==="createTexture"){this.onCreateTexture(n.data.uuid,n.data.key,n.data.value);return}else if(n.event==="requestSize"){n.target==="app"?this.send({event:"requestSize",target:"editor",data:{width:this.width,height:this.height}}):this.scenes.forEach(r=>{r.resize!==void 0&&r.resize(n.data.width,n.data.height)});return}n.target==="app"?this.handleApp(n):this.handleEditor(n)}addRT(t,n=!0,r){if(!this.renderer)return;let i;this.renderer instanceof ZW?i=new ah(32,32,r):i=new Af(32,32,r),i.texture.name=t,this.renderTargets.set(t,i),this.renderTargetsResize.set(t,n)}removeRT(t){this.renderTargets.delete(t),this.renderTargetsResize.delete(t)}resize(t,n){var a,u;const r=this.dpr;this.renderTargets.forEach((d,m)=>{this.renderTargetsResize.get(m)&&d.setSize(t*r,n*r)});const i=!(((a=this.renderer)==null?void 0:a.domElement)instanceof OffscreenCanvas);(u=this.renderer)==null||u.setSize(t,n,i)}set dpr(t){var n;(n=this.renderer)==null||n.setPixelRatio(cZe(1,2,t))}get dpr(){var t;return this.renderer!==void 0?(t=this.renderer)==null?void 0:t.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}}class fZe extends ZYe{constructor(t,n,r){super(n,r);ur(this,"theatre");ur(this,"three");this.theatre=new rZe(n,r),this.three=new hZe(t,n,r),this.addComponent("theatre",this.theatre),this.addComponent("three",this.three)}init(t){return new Promise((n,r)=>{if(this.isApp){const i=new ZW({canvas:t,stencil:!1});i.shadowMap.enabled=!0,i.setPixelRatio(Math.min(1.5,devicePixelRatio)),i.setClearColor(0),i.inspector=new yye,this.three.setRenderer(i,t),i.init().then(()=>n()).catch(()=>{console.log("Error creating WebGPU Renderer"),r()})}else r()})}}const pZe=new Map([["Scene2",Lye],["Scene3",Fye],["RTTScene",Dye]]),C4e=E9.lazy(()=>FFe(()=>import("./ThreeEditor-CTkjs-SY.js"),__vite__mapDeps([0,1]))),dI=new fZe("Hermes Example",kFe,x5e);x5e&&PN&&(PN.initialize(),dI.theatre.studio=PN,dI.theatre.handleEditorApp());function mZe(){return ia.jsx(BFe,{app:dI,onLoad:xYe,renderEditor:C4e?o=>ia.jsx(E9.Suspense,{fallback:null,children:ia.jsx(C4e,{three:o,scenes:pZe,onSceneAdd:e=>{e.setup(dI),e.init()},onSceneUpdate:e=>{e.update()}})}):void 0,children:o=>ia.jsx(jYe,{app:o})})}PN.initialize();sRe.createRoot(document.getElementById("root")).render(ia.jsx(ia.Fragment,{children:ia.jsx(ia.Fragment,{children:ia.jsx(mZe,{})})}));export{lb as $,VZe as A,Yi as B,An as C,Na as D,JYe as E,Dr as F,v2e as G,jZe as H,N0 as I,cZe as J,WZe as K,HN as L,cs as M,eo as N,HZe as O,T6 as P,zBe as Q,lZe as R,I1 as S,dZe as T,uZe as U,hu as V,Ej as W,Mj as X,Cj as Y,kg as Z,ab as _,O1 as a,Aj as a0,Pj as a1,Rj as a2,Nj as a3,Ij as a4,uRe as a5,cRe as a6,dRe as a7,hRe as a8,k0 as a9,vZe as aA,UZe as aB,Gn as aC,Ky as aD,TZe as aE,vI as aF,L1 as aG,$9 as aH,o3e as aI,Cr as aJ,MZe as aK,ZW as aL,NVe as aM,Ra as aN,M6 as aO,wZe as aP,W4e as aQ,bZe as aR,FIe as aS,_Ze as aT,SZe as aU,EYe as aV,GZe as aW,xZe as aX,wj as aa,Tj as ab,k4e as ac,D4e as ad,a0 as ae,gl as af,M9 as ag,C9 as ah,A9 as ai,r6 as aj,zZe as ak,Nf as al,En as am,Ae as an,sa as ao,UIe as ap,ra as aq,yZe as ar,Fi as as,sH as at,X9 as au,uH as av,J4e as aw,v6 as ax,nd as ay,Wb as az,Yc as b,us as c,Ef as d,TT as e,PZe as f,ta as g,kZe as h,Wc as i,ia as j,IZe as k,Vw as l,_Ke as m,RZe as n,LZe as o,xG as p,FZe as q,E9 as r,NZe as s,OZe as t,Yd as u,RKe as v,DZe as w,AZe as x,BN as y,BZe as z};
package/dist/index.html CHANGED
@@ -8,7 +8,7 @@
8
8
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
9
9
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
10
10
  <link rel="manifest" href="/images/site.webmanifest">
11
- <script type="module" crossorigin src="/index-dfUv_VcA.js"></script>
11
+ <script type="module" crossorigin src="/index-BpKOzCuX.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/index-C92ji5gy.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "module": "./dist/hermes.esm.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "type": "module",
10
- "version": "0.1.38",
10
+ "version": "0.1.39",
11
11
  "homepage": "https://github.com/tomorrowevening/hermes#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/tomorrowevening/hermes/issues"