@tomorrowevening/hermes 0.1.23 → 0.1.24

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.
@@ -7937,7 +7937,7 @@ void main() {
7937
7937
  enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
7938
7938
  gl_FragColor = enc;
7939
7939
  }
7940
- `,S=p.createShader(35633),M=p.createShader(35632),I=p.createProgram();if(!(M&&S&&I))return;p.shaderSource(S,y),p.shaderSource(M,x),p.compileShader(S),p.compileShader(M),p.attachShader(I,S),p.attachShader(I,M),p.linkProgram(I),p.detachShader(I,S),p.detachShader(I,M),p.deleteShader(S),p.deleteShader(M),p.useProgram(I);const L=p.createBuffer();p.bindBuffer(34962,L),p.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const B=p.getAttribLocation(I,"aPosition");p.vertexAttribPointer(B,3,5126,!1,0,0),p.enableVertexAttribArray(B),p.clearColor(1,1,1,1),p.clear(16384),p.viewport(0,0,1,1),p.drawArrays(4,0,3);const A=new Uint8Array(4);return p.readPixels(0,0,1,1,6408,5121,A),p.deleteProgram(I),p.deleteBuffer(L),A.join("")}(s),r="801621810",i="8016218135",a="80162181161",c=m1!=null&&m1.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 u;return n==="80162181255"?u=c.filter(([,,p])=>p>=14):(u=c.filter(([,p])=>p===n),u.length||(u=c)),u.map(([p])=>`apple ${p} gpu`)}let V3e=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}};const JV=[],G3e=[];function bFe(s,e){if(s===e)return 0;const t=s;s.length>e.length&&(s=e,e=t);let n=s.length,r=e.length;for(;n>0&&s.charCodeAt(~-n)===e.charCodeAt(~-r);)n--,r--;let i,a=0;for(;a<n&&s.charCodeAt(a)===e.charCodeAt(a);)a++;if(n-=a,r-=a,n===0)return r;let c,u,p=0,y=0,x=0;for(;y<n;)G3e[y]=s.charCodeAt(a+y),JV[y]=++y;for(;x<r;)for(i=e.charCodeAt(a+x),c=x++,p=x,y=0;y<n;y++)u=i===G3e[y]?c:c+1,c=JV[y],p=JV[y]=c>p?u>p?p+1:u:u>c?c+1:u;return p}function SFe(s){return s!=null}const wFe=({mobileTiers:s=[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"}={})=>QV(void 0,void 0,void 0,function*(){const a={};if(Vve)return{tier:0,type:"SSR"};const{isIpad:c=!!(m1!=null&&m1.isIpad),isMobile:u=!!(m1!=null&&m1.isMobile),screenSize:p=window.screen,loadBenchmarks:y=te=>QV(void 0,void 0,void 0,function*(){const oe=yield fetch(`${i}/${te}`).then(ie=>ie.json());if(parseInt(oe.shift().split(".")[0],10)<4)throw new V3e("Detect GPU benchmark data is out of date. Please update to version 4x");return oe})}=t;let{renderer:x}=t;const S=(te,oe,ie,K,re)=>({device:re,fps:K,gpu:ie,isMobile:u,tier:te,type:oe});let M,I="";if(x)x=z3e(x),M=[x];else{const te=n||function(ie,K=!1){const re={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:K,powerPreference:"high-performance",stencil:!1};ie&&delete re.powerPreference;const se=window.document.createElement("canvas"),q=se.getContext("webgl",re)||se.getContext("experimental-webgl",re);return q??void 0}(m1==null?void 0:m1.isSafari12,r);if(!te)return S(0,"WEBGL_UNSUPPORTED");const oe=m1!=null&&m1.isFirefox?null:te.getExtension("WEBGL_debug_renderer_info");if(x=oe?te.getParameter(oe.UNMASKED_RENDERER_WEBGL):te.getParameter(te.RENDERER),!x)return S(1,"FALLBACK");I=x,x=z3e(x),M=function(ie,K,re){return K==="apple gpu"?_Fe(ie,K,re):[K]}(te,x,u)}const L=(yield Promise.all(M.map(function(te){var oe;return QV(this,void 0,void 0,function*(){const ie=(Bt=>{const ct=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Pt of ct)if(Bt.includes(Pt))return Pt})(te);if(!ie)return;const K=`${u?"m":"d"}-${ie}${c?"-ipad":""}.json`,re=a[K]=(oe=a[K])!==null&&oe!==void 0?oe:y(K);let se;try{se=yield re}catch(Bt){if(Bt instanceof V3e)throw Bt;return}const q=function(Bt){var ct;const Pt=(Bt=Bt.replace(/\([^)]+\)/,"")).match(/\d+/)||Bt.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(ct=Pt==null?void 0:Pt.join("").replace(/\W|amd/g,""))!==null&&ct!==void 0?ct:""}(te);let De=se.filter(([,Bt])=>Bt===q);De.length||(De=se.filter(([Bt])=>Bt.includes(te)));const Be=De.length;if(Be===0)return;const tt=te.split(/[.,()\[\]/\s]/g).sort().filter((Bt,ct,Pt)=>ct===0||Bt!==Pt[ct-1]).join(" ");let st,[de,,,,ft]=Be>1?De.map(Bt=>[Bt,bFe(tt,Bt[2])]).sort(([,Bt],[,ct])=>Bt-ct)[0][0]:De[0],Se=Number.MAX_VALUE;const{devicePixelRatio:rt}=window,ut=p.width*rt*p.height*rt;for(const Bt of ft){const[ct,Pt]=Bt,on=ct*Pt,Gt=Math.abs(ut-on);Gt<Se&&(Se=Gt,st=Bt)}if(!st)return;const[,,Pe,vt]=st;return[Se,Pe,de,vt]})}))).filter(SFe).sort(([te=Number.MAX_VALUE,oe],[ie=Number.MAX_VALUE,K])=>te===ie?oe-K:te-ie);if(!L.length){const te=xFe.find(oe=>x.includes(oe));return te?S(0,"BLOCKLISTED",te):S(1,"FALLBACK",`${x} (${I})`)}const[,B,A,V]=L[0];if(B===-1)return S(0,"BLOCKLISTED",A,B,V);const X=u?s:e;let P=0;for(let te=0;te<X.length;te++)B>=X[te]&&(P=te);return S(P,"BENCHMARK",A,B,V)});function EFe(s){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;s(a)}else requestAnimationFrame(n)}requestAnimationFrame(n)}function TFe(s=!1,e=!1){return new Promise(t=>{wFe().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 u=navigator.userAgent.match(/version\/(\d+)/i);r=(u?parseInt(u[1]):0)>=17}const c={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:n.isMobile!==void 0?n.isMobile:!1,supportOffScreenCanvas:r,supportWebGPU:!!navigator.gpu,quality:"Low",dev:s,editor:e};n.tier===3?c.quality="High":n.tier===2&&(c.quality="Medium"),EFe(u=>{c.fps=u,t(c)})})})}class MFe{constructor(){Xe(this,"assets",{audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map});Xe(this,"components",new Map);Xe(this,"settings",{dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1});Xe(this,"onUpdateCallback");Xe(this,"playing",!1);Xe(this,"rafID",-1);Xe(this,"play",()=>{this.playing||(this.playing=!0,this.onUpdate())});Xe(this,"pause",()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)});Xe(this,"onUpdate",()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)})}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(e=!1,t=!1){return new Promise(n=>{TFe(e,t).then(r=>{this.settings=r,n()})})}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 CFe=I8e();class Gve{constructor(e,t=!1,n=!1){Xe(this,"name");Xe(this,"_debug",!1);Xe(this,"_editor",!1);Xe(this,"broadcastChannel");this.name=e,this._debug=t,this._editor=n,t&&(this.broadcastChannel=new BroadcastChannel(e),this.broadcastChannel.addEventListener("message",this.messageHandler.bind(this)))}dispose(){var e,t;(e=this.broadcastChannel)==null||e.removeEventListener("message",this.messageHandler.bind(this)),(t=this.broadcastChannel)==null||t.close()}get debug(){return this._debug}get editor(){return this._editor}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 jve=()=>{};function vk(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function AFe(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function P0(){return Math.round(Math.random()*1e6).toString()}function PFe(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function j3e(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),n=Math.round(s.b*255),r=u=>{const p=u.toString(16);return p.length===1?"0"+p:p},i=r(e),a=r(t),c=r(n);return"#"+i+a+c}function RFe(s,e,t,n,r){const i=1-s;return i*i*i*e+3*i*i*s*t+3*i*s*s*n+s*s*s*r}function IFe(s,e,t){if(s.type!=="bezier"||s.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[n,r]=s.handles,i=(t-s.position)/(e.position-s.position);return RFe(i,s.value,s.value+n,e.value+r,e.value)}class kFe extends Gve{constructor(t=!1,n=!1){super("RemoteTheatre",t,n);Xe(this,"project");Xe(this,"sheets",new Map);Xe(this,"sheetObjects",new Map);Xe(this,"sheetObjectCBs",new Map);Xe(this,"sheetObjectUnsubscribe",new Map);Xe(this,"activeSheet");Xe(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 console.log(t,n),this.project=CFe.getProject(t,{state:n}),new Promise((r,i)=>{var a;(a=this.project)==null||a.ready.then(()=>{if(n){const c=n.sheetsById;console.log("loaded sheets",c);for(const u in c)this.sheet(u)}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(c=>i(c)),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 c=this.sheet(t,a);if(c===void 0)return;const p=`${this.getSheetInstance(t,a)}_${n}`;let y=this.sheetObjects.get(p),x=r;y!==void 0&&(x={...r,...y.value}),y=c.object(n,x,{reconfigure:!0}),this.sheetObjects.set(p,y),this.sheetObjectCBs.set(p,i!==void 0?i:jve);function S(I,L,B){if(typeof B=="object")if(PFe(B))I[L]={r:B.r,g:B.g,b:B.b,a:B.a};else for(const A in B){const V=B[A];typeof V=="object"&&S(B,A,V)}}const M=y.onValuesChange(I=>{const L=this.sheetObjectCBs.get(p);if(this.editor){for(const B in I){const A=I[B];typeof A=="object"&&S(I,B,A)}this.send({event:"updateSheetObject",target:"app",data:{sheet:t,sheetObject:p,values:I}}),L&&L(I)}else L&&L(I)});return this.sheetObjectUnsubscribe.set(p,M),y}getSheetObjectKeyframes(t,n,r){const i=this.sheet(t);if(i===void 0)return[];const a=`${t}_${n}`,c=this.sheetObjects.get(a);return c===void 0?[]:i.sequence.__experimental_getKeyframes(c.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 c=[],u=r.sequence.__experimental_getKeyframes(a.props.x),p=r.sequence.__experimental_getKeyframes(a.props.y),y=r.sequence.__experimental_getKeyframes(a.props.z),x=new Set;return u.forEach(M=>x.add(M.position)),p.forEach(M=>x.add(M.position)),y.forEach(M=>x.add(M.position)),Array.from(x).sort((M,I)=>M-I).forEach(M=>{const I=(L,B)=>{const A=L.find((P,te)=>{var oe;return P.position<=B&&(((oe=L[te+1])==null?void 0:oe.position)||1/0)>B}),V=L.find(P=>P.position>B);if(!A)return(V==null?void 0:V.value)||0;if(!V||A.position===B)return A.value;if(A.type==="bezier")return IFe(A,V,B);const X=(B-A.position)/(V.position-A.position);return A.value+X*(V.value-A.value)};c.push({position:M,x:I(u,M),y:I(p,M),z:I(y,M)})}),c}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}`,c=this.sheetObjectUnsubscribe.get(a);c!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),c())}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(u=>{u.length<1||u.forEach(p=>{let y=p.address.sheetId,x="setSheet",S={};switch(p.type){case"Theatre_Sheet_PublicAPI":x="setSheet",S={sheet:p.address.sheetId},this.activeSheet=this.sheets.get(p.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":x="setSheetObject",y+=`_${p.address.objectKey}`,S={id:y,sheet:p.address.sheetId,key:p.address.objectKey},this.activeSheet=this.sheets.get(p.address.sheetId);break}this.send({event:x,target:"app",data:S})})});let i=-1;const a=()=>{if(this.activeSheet!==void 0&&i!==this.activeSheet.sequence.position){i=this.activeSheet.sequence.position;const u=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:i,sheet:u.address.sheetId}})}},c=()=>{a(),requestAnimationFrame(c)};a(),c()}else(r=this.studio)==null||r.ui.hide()}}const JW=new rs;JW.setAttribute("position",new Er([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));JW.setAttribute("normal",new Er([0,0,1,0,0,1],3));JW.setAttribute("uv",new Er([0,0,2,0,0,2],2));new zx(-.5,.5,.5,-.5,0,100);const H3e=s=>{s==null||s.dispose()},Hve=s=>{if(s)if(Array.isArray(s))s.forEach(e=>Hve(e));else{for(const e in s){const t=s[e];t!==null&&t instanceof n0&&H3e(t)}if(s.isShaderMaterial===!0){const e=s;for(const t in e.uniforms){const n=e.uniforms[t];n.value!==null&&n.value instanceof n0&&H3e(n.value)}}s.dispose()}},od=s=>{var e;if(s){for(;s.children.length>0;){const t=s.children[0];t.type==="Audio"?(t.pause(),t.parent&&t.parent.remove(t)):od(t)}if(s.parent&&s.parent.remove(s),s.isMesh){const t=s;(e=t.geometry)==null||e.dispose(),Hve(t.material)}s.dispose!==void 0&&s.dispose()}};let PH=0;const W3e=()=>{PH=0},Vx=s=>{if(!s)return;let e=s.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${PH}`,PH++),s.parent!==null&&s.parent.uuid.length>0&&(e=`${s.parent.uuid}.${e}`),s.uuid=e,s.isMesh!==void 0){const t=s;if(Array.isArray(t.material))t.material.forEach((n,r)=>{n.uuid=`${e}.material.${r}`});else{const n=t.material;n.uuid=`${e}.material`}}s.children.forEach(t=>Vx(t))};class ml{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(),n=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 r=e.image;if(r!=null&&r.width>0){this.canvas.title=e.sourceFile;const i=this.canvas.width/r.width,a=this.renderToCanvas(e);this.context.drawImage(a,0,0,r.width*i,r.height*i)}}return e.repeat.copy(t),e.offset.copy(n),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new zx(-.5,.5,.5,-.5,0,100),this.scene=new _E,this.material=new eh;const t=new rs;t.setAttribute("position",new Er([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new Er([0,0,1,0,0,1],3)),t.setAttribute("uv",new Er([0,0,2,0,0,2],2));const n=new mn(t,this.material);this.scene.add(n)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,n=e.colorSpace;this.renderer.outputColorSpace=Ju,e.colorSpace=Ju,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=n}return this.renderer.domElement}}Xe(ml,"renderer"),Xe(ml,"canvas"),Xe(ml,"context",null),Xe(ml,"scene",null),Xe(ml,"camera",null),Xe(ml,"material",null),Xe(ml,"inited",!1),Xe(ml,"width",100),Xe(ml,"height",100);function NFe(s){if(s.name==="cameras")return"camera";if(s.name==="interactive")return"interactive";if(s.name==="lights")return"light";if(s.name==="ui")return"ui";if(s.name==="utils")return"utils";const e=s.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function rx(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(rx(t))}),e}function DFe(s){const e={};for(const t in s){const n=s[t].value;e[t]={value:n},n===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:n!==void 0&&n.isTexture&&(e[t].value={src:n.image.src,offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]})}return e}function OFe(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function k7(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||OFe(t))continue;const n=typeof s[t],r=s[t];switch(n){case"boolean":case"number":case"string":e[t]=r;break;case"object":r!==null?(e[t]=r,r.isTexture?e[t]={src:ml.renderToBlob(r),offset:[r.offset.x,r.offset.y],repeat:[r.repeat.x,r.repeat.y]}:t==="uniforms"&&(e[t]=DFe(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.clearcoat!==void 0&&(e.clearcoat=s.clearcoat),s.iridescence!==void 0&&(e.iridescence=s.iridescence),s.dispersion!==void 0&&(e.dispersion=s.dispersion),s.sheen!==void 0&&(e.sheen=s.sheen),s.transmission!==void 0&&(e.transmission=s.transmission),s.transmission!==void 0&&(e.transmission=s.transmission),e}function eG(s){s.updateMatrix();const e={name:s.name,type:s.type,uuid:s.uuid,visible:s.visible,matrix:s.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};s.animations.forEach(n=>{e.animations.push({name:n.name,duration:n.duration,blendMode:n.blendMode})});const t=s.type.toLowerCase();if(t.search("mesh")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else if(t.search("points")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else if(t.search("line")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else t.search("camera")>-1?s.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:s.fov,zoom:s.zoom,near:s.near,far:s.far,focus:s.focus,aspect:s.aspect,filmGauge:s.filmGauge,filmOffset:s.filmOffset}:s.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:s.zoom,near:s.near,far:s.far,left:s.left,right:s.right,top:s.top,bottom:s.bottom}):t.search("light")>-1&&(e.lightInfo={color:s.color,intensity:s.intensity,decay:s.decay,distance:s.distance,angle:s.angle,penumbra:s.penumbra,groundColor:s.groundColor,width:s.width,height:s.height});return e}function LFe(s,e){const t=e.split(".");switch(t.length){case 1:return s[t[0]];case 2:return s[t[0]][t[1]];case 3:return s[t[0]][t[1]][t[2]];case 4:return s[t[0]][t[1]][t[2]][t[3]];case 5:return s[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return s[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function FFe(s,e){for(const t in e)s[t]=e[t]}function Ko(s,e,t){if(s===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:s[n[0]]=t;break;case 2:s[n[0]][n[1]]=t;break;case 3:s[n[0]][n[1]][n[2]]=t;break;case 4:s[n[0]][n[1]][n[2]][n[3]]=t;break;case 5:s[n[0]][n[1]][n[2]][n[3]][n[4]]=t;break}else{let a;switch(r){case 1:a=s[n[0]];break;case 2:a=s[n[0]][n[1]];break;case 3:a=s[n[0]][n[1]][n[2]];break;case 4:a=s[n[0]][n[1]][n[2]][n[3]];break;case 5:a=s[n[0]][n[1]][n[2]][n[3]][n[4]];break}a!=null?FFe(a,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function e$(s){return new Promise((e,t)=>{const n=new Image;n.onload=()=>{const r=new n0(n);r.wrapS=Wg,r.wrapT=Wg,r.needsUpdate=!0,e(r)},n.onerror=t,n.src=s})}function rv(s,e,t){return Math.min(e,Math.max(s,t))}function $3e(s,e,t){return(t-s)/(e-s)}function RH(s,e,t){return s*(1-t)+e*t}function Rf(s,e=1){return Number(s.toFixed(e))}var li=(s=>(s.CUSTOM="ToolEvents::custom",s.SELECT_DROPDOWN="ToolEvents::selectDropdown",s.DRAG_UPDATE="ToolEvents::dragUpdate",s.ADD_SCENE="ToolEvents::addScene",s.REFRESH_SCENE="ToolEvents::refreshScene",s.REMOVE_SCENE="ToolEvents::removeScene",s.SET_SCENE="ToolEvents::setScene",s.SET_OBJECT="ToolEvents::setObject",s.CLEAR_OBJECT="ToolEvents::clearObject",s.ADD_CAMERA="ToolEvents::addCamera",s.REMOVE_CAMERA="ToolEvents::removeCamera",s.ADD_GROUP="ToolEvents::addGroup",s.REMOVE_GROUP="ToolEvents::removeGroup",s.ADD_SPLINE="ToolEvents::addSpline",s.ADD_RENDERER="ToolEvents::addRenderer",s.UPDATE_RENDERER="ToolEvents::updateRenderer",s))(li||{});class BFe extends Gve{constructor(t,n=!1,r=!1){super("RemoteThree",n,r);Xe(this,"name");Xe(this,"canvas",null);Xe(this,"inputElement",null);Xe(this,"scene");Xe(this,"scenes",new Map);Xe(this,"renderer");Xe(this,"renderTargets",new Map);Xe(this,"renderTargetsResize",new Map);Xe(this,"groups",new Map);Xe(this,"_listeners",{});this.name=t}dispose(){var t;this.scenes.forEach(n=>{od(n)}),this.scenes.clear(),this.scene&&od(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 c=0,u=a.length;c<u;c++)a[c].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&&(ml.renderer=this.renderer);const n=this.getObjectByUUID(t);n&&this.setObject(n)}setObject(t){this.renderer!==void 0&&(ml.renderer=this.renderer);const n=eG(t);this.dispatchEvent({type:"ToolEvents::setObject",value:n})}requestMethod(t,n,r,i){const a=this.getObjectByUUID(t);if(a)try{i!==void 0?LFe(a,i)[n](r):a[n](r)}catch(c){console.log("Hermes - Error requesting method:",t,n,r),console.log(c)}}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&&Ko(i,n,r)}onCreateTexture(t,n,r){const i=this.getObjectByUUID(t);if(i){const a=c=>{const u=n.split(".");switch(u.length){case 1:i[u[0]]=c;break;case 2:i[u[0]][u[1]]=c;break;case 3:i[u[0]][u[1]][u[2]]=c;break;case 4:i[u[0]][u[1]][u[2]][u[3]]=c;break;case 5:i[u[0]][u[1]][u[2]][u[3]][u[4]]=c;break}i.material.needsUpdate=!0};r.src.length>0?e$(r.src).then(c=>{c.offset.set(r.offset[0],r.offset[1]),c.repeat.set(r.repeat[0],r.repeat[1]),a(c)}):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 Pn).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClear:t.autoClear,autoClearColor:t.autoClearColor,autoClearDepth:t.autoClearDepth,autoClearStencil:t.autoClearStencil,outputColorSpace:t.outputColorSpace,localClippingEnabled:t.localClippingEnabled,clearColor:r,clearAlpha:t.getClearAlpha(),colorManagement:Gr.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;W3e(),Vx(t);const n=rx(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=rx(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=rx(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&&(ml.renderer=this.renderer),W3e(),Vx(t);const n=rx(t);this.send({event:"setScene",target:"editor",data:n})}requestSize(){this.send({event:"requestSize",target:"app"})}addCamera(t){if(!this.debug)return;const n=eG(t);this.send({event:"addCamera",target:"editor",data:n})}removeCamera(t){if(!this.debug)return;const n=eG(t);this.send({event:"removeCamera",target:"editor",data:n})}handleApp(t){switch(t.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:rx(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.localClippingEnabled=t.data.localClippingEnabled,this.renderer.setClearColor(t.data.clearColor,t.data.clearAlpha),this.renderer.toneMapping=t.data.toneMapping,this.renderer.toneMappingExposure=t.data.toneMappingExposure,Gr.enabled=t.data.colorManagement);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){const i=new bl(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,c;const r=this.dpr;this.renderTargets.forEach((u,p)=>{this.renderTargetsResize.get(p)&&u.setSize(t*r,n*r)});const i=!(((a=this.renderer)==null?void 0:a.domElement)instanceof OffscreenCanvas);(c=this.renderer)==null||c.setSize(t,n,i)}set dpr(t){var n;(n=this.renderer)==null||n.setPixelRatio(rv(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}}function UFe(s){const t=s.app.components.get("theatre");return t.studio=k8e,t.handleEditorApp(),null}function zFe(s){return Ke.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[Ke.jsx("div",{className:"header",children:s.header}),s.children,Ke.jsx("div",{className:"footer",children:s.footer})]})}class VFe{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class Lf{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let r=0;r<e.length-1;r++){const i=e[r];n.has(i)===!1&&n.set(i,new WeakMap),n=n.get(i)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}const hl=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let q3e=1234567;const sE=Math.PI/180,Gx=180/Math.PI;function Fg(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(hl[s&255]+hl[s>>8&255]+hl[s>>16&255]+hl[s>>24&255]+"-"+hl[e&255]+hl[e>>8&255]+"-"+hl[e>>16&15|64]+hl[e>>24&255]+"-"+hl[t&63|128]+hl[t>>8&255]+"-"+hl[t>>16&255]+hl[t>>24&255]+hl[n&255]+hl[n>>8&255]+hl[n>>16&255]+hl[n>>24&255]).toLowerCase()}function yi(s,e,t){return Math.max(e,Math.min(t,s))}function t$(s,e){return(s%e+e)%e}function iv(s,e,t,n,r){return n+(s-e)*(r-n)/(t-e)}function GFe(s,e,t){return s!==e?(t-s)/(e-s):0}function V3(s,e,t){return(1-t)*s+t*e}function jFe(s,e,t,n){return V3(s,e,1-Math.exp(-t*n))}function HFe(s,e=1){return e-Math.abs(t$(s,e*2)-e)}function WFe(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function $Fe(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function qFe(s,e){return s+Math.floor(Math.random()*(e-s+1))}function XFe(s,e){return s+Math.random()*(e-s)}function YFe(s){return s*(.5-Math.random())}function KFe(s){s!==void 0&&(q3e=s);let e=q3e+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function yk(s){return s*sE}function Wve(s){return s*Gx}function ZFe(s){return(s&s-1)===0&&s!==0}function QFe(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function JFe(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function eBe(s,e,t,n,r){const i=Math.cos,a=Math.sin,c=i(t/2),u=a(t/2),p=i((e+n)/2),y=a((e+n)/2),x=i((e-n)/2),S=a((e-n)/2),M=i((n-e)/2),I=a((n-e)/2);switch(r){case"XYX":s.set(c*y,u*x,u*S,c*p);break;case"YZY":s.set(u*S,c*y,u*x,c*p);break;case"ZXZ":s.set(u*x,u*S,c*y,c*p);break;case"XZX":s.set(c*y,u*I,u*M,c*p);break;case"YXY":s.set(u*M,c*y,u*I,c*p);break;case"ZYZ":s.set(u*I,u*M,c*y,c*p);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ac(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Qr(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const tBe={DEG2RAD:sE,RAD2DEG:Gx,generateUUID:Fg,clamp:yi,euclideanModulo:t$,mapLinear:iv,inverseLerp:GFe,lerp:V3,damp:jFe,pingpong:HFe,smoothstep:WFe,smootherstep:$Fe,randInt:qFe,randFloat:XFe,randFloatSpread:YFe,seededRandom:KFe,degToRad:yk,radToDeg:Wve,isPowerOfTwo:ZFe,ceilPowerOfTwo:QFe,floorPowerOfTwo:JFe,setQuaternionFromProperEuler:eBe,normalize:Qr,denormalize:ac},$ve="177",nBe=0,rBe=1,iBe=2,sBe=0,oBe=1,YI=3,Bg=0,eu=1,Sx=2,jx=0,Ug=1,xk=2,_k=3,bk=4,oE=5,Nf=100,qve=101,Xve=102,aBe=103,lBe=104,N3=200,Yve=201,Kve=202,Zve=203,Sk=204,wk=205,Qve=206,Jve=207,eye=208,tye=209,nye=210,rye=0,iye=1,sye=2,Ek=3,oye=4,aye=5,lye=6,cye=7,Xk=0,cBe=1,uBe=2,wx=0,hBe=1,dBe=2,fBe=3,pBe=4,mBe=6,gBe=7,n$=300,CE=301,Tk=302,r$=303,i$=304,IH=306,Hx=1e3,z3=1001,Wx=1002,Ca=1003,uye=1004,AE=1005,th=1006,kH=1007,zg=1008,lc=1009,aE=1010,lE=1011,dx=1012,sc=1013,Zo=1014,Zu=1015,td=1016,vBe=1017,yBe=1018,G3=1020,hye=35902,xBe=1021,s$=1022,nd=1023,S1=1026,Vg=1027,o$=1028,a$=1029,yv=1030,l$=1031,_Be=1032,c$=1033,tG=33776,KI=33777,ZI=33778,QI=33779,X3e=35840,Y3e=35841,K3e=35842,Z3e=35843,Q3e=36196,NH=37492,DH=37496,OH=37808,LH=37809,FH=37810,BH=37811,UH=37812,zH=37813,VH=37814,GH=37815,jH=37816,HH=37817,WH=37818,$H=37819,qH=37820,XH=37821,nG=36492,bBe=36283,J3e=36284,e4e=36285,t4e=36286,q3=0,SBe=1,$g="",Yu="srgb",Ex="srgb-linear",Mk="linear",Vr="srgb",wBe=0,sv=7680,EBe=7681,TBe=7682,MBe=7683,CBe=34055,ABe=34056,PBe=5386,RBe=512,IBe=513,kBe=514,NBe=515,DBe=516,OBe=517,LBe=518,YH=519,dye=512,u$=513,fye=514,pye=515,mye=516,gye=517,vye=518,yye=519,Ck=35044,fx=35048,Zc=2e3,X3=2001;class nu{constructor(e,t,n,r,i,a,c,u,p){nu.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,c,u,p)}set(e,t,n,r,i,a,c,u,p){const y=this.elements;return y[0]=e,y[1]=r,y[2]=c,y[3]=t,y[4]=i,y[5]=u,y[6]=n,y[7]=a,y[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],c=n[3],u=n[6],p=n[1],y=n[4],x=n[7],S=n[2],M=n[5],I=n[8],L=r[0],B=r[3],A=r[6],V=r[1],X=r[4],P=r[7],te=r[2],oe=r[5],ie=r[8];return i[0]=a*L+c*V+u*te,i[3]=a*B+c*X+u*oe,i[6]=a*A+c*P+u*ie,i[1]=p*L+y*V+x*te,i[4]=p*B+y*X+x*oe,i[7]=p*A+y*P+x*ie,i[2]=S*L+M*V+I*te,i[5]=S*B+M*X+I*oe,i[8]=S*A+M*P+I*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8];return t*a*y-t*c*p-n*i*y+n*c*u+r*i*p-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8],x=y*a-c*p,S=c*u-y*i,M=p*i-a*u,I=t*x+n*S+r*M;if(I===0)return this.set(0,0,0,0,0,0,0,0,0);const L=1/I;return e[0]=x*L,e[1]=(r*p-y*n)*L,e[2]=(c*n-r*a)*L,e[3]=S*L,e[4]=(y*t-r*u)*L,e[5]=(r*i-c*t)*L,e[6]=M*L,e[7]=(n*u-p*t)*L,e[8]=(a*t-n*i)*L,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,c){const u=Math.cos(i),p=Math.sin(i);return this.set(n*u,n*p,-n*(u*a+p*c)+a+e,-r*p,r*u,-r*(-p*a+u*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(rG.makeScale(e,t)),this}rotate(e){return this.premultiply(rG.makeRotation(-e)),this}translate(e,t){return this.premultiply(rG.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const rG=new nu;function xye(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function KH(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function FBe(){const s=KH("canvas");return s.style.display="block",s}const n4e={};function qg(s){s in n4e||(n4e[s]=!0,console.warn(s))}const r4e=new nu().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),i4e=new nu().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function BBe(){const s={enabled:!0,workingColorSpace:Ex,spaces:{},convert:function(r,i,a){return this.enabled===!1||i===a||!i||!a||(this.spaces[i].transfer===Vr&&(r.r=Gg(r.r),r.g=Gg(r.g),r.b=Gg(r.b)),this.spaces[i].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[i].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Vr&&(r.r=Tx(r.r),r.g=Tx(r.g),r.b=Tx(r.b))),r},workingToColorSpace:function(r,i){return this.convert(r,this.workingColorSpace,i)},colorSpaceToWorking:function(r,i){return this.convert(r,i,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===$g?Mk:this.spaces[r].transfer},getLuminanceCoefficients:function(r,i=this.workingColorSpace){return r.fromArray(this.spaces[i].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,i,a){return r.copy(this.spaces[i].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,i){return qg("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,i)},toWorkingColorSpace:function(r,i){return qg("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,i)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Ex]:{primaries:e,whitePoint:n,transfer:Mk,toXYZ:r4e,fromXYZ:i4e,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Yu},outputColorSpaceConfig:{drawingBufferColorSpace:Yu}},[Yu]:{primaries:e,whitePoint:n,transfer:Vr,toXYZ:r4e,fromXYZ:i4e,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Yu}}}),s}const Us=BBe();function Gg(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Tx(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}const _ye={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_3={h:0,s:0,l:0},YR={h:0,s:0,l:0};function iG(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Zi{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Yu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Us.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Us.workingColorSpace){return this.r=e,this.g=t,this.b=n,Us.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Us.workingColorSpace){if(e=t$(e,1),t=yi(t,0,1),n=yi(n,0,1),t===0)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,a=2*n-i;this.r=iG(a,i,e+1/3),this.g=iG(a,i,e),this.b=iG(a,i,e-1/3)}return Us.colorSpaceToWorking(this,r),this}setStyle(e,t=Yu){function n(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const a=r[1],c=r[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=r[1],a=i.length;if(a===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Yu){const n=_ye[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Gg(e.r),this.g=Gg(e.g),this.b=Gg(e.b),this}copyLinearToSRGB(e){return this.r=Tx(e.r),this.g=Tx(e.g),this.b=Tx(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yu){return Us.workingToColorSpace(dl.copy(this),e),Math.round(yi(dl.r*255,0,255))*65536+Math.round(yi(dl.g*255,0,255))*256+Math.round(yi(dl.b*255,0,255))}getHexString(e=Yu){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Us.workingColorSpace){Us.workingToColorSpace(dl.copy(this),t);const n=dl.r,r=dl.g,i=dl.b,a=Math.max(n,r,i),c=Math.min(n,r,i);let u,p;const y=(c+a)/2;if(c===a)u=0,p=0;else{const x=a-c;switch(p=y<=.5?x/(a+c):x/(2-a-c),a){case n:u=(r-i)/x+(r<i?6:0);break;case r:u=(i-n)/x+2;break;case i:u=(n-r)/x+4;break}u/=6}return e.h=u,e.s=p,e.l=y,e}getRGB(e,t=Us.workingColorSpace){return Us.workingToColorSpace(dl.copy(this),t),e.r=dl.r,e.g=dl.g,e.b=dl.b,e}getStyle(e=Yu){Us.workingToColorSpace(dl.copy(this),e);const t=dl.r,n=dl.g,r=dl.b;return e!==Yu?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(_3),this.setHSL(_3.h+e,_3.s+t,_3.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_3),e.getHSL(YR);const n=V3(_3.h,YR.h,t),r=V3(_3.s,YR.s,t),i=V3(_3.l,YR.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const dl=new Zi;Zi.NAMES=_ye;class Yk{constructor(e,t,n,r){Yk.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}}class i_{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,c){let u=n[r+0],p=n[r+1],y=n[r+2],x=n[r+3];const S=i[a+0],M=i[a+1],I=i[a+2],L=i[a+3];if(c===0){e[t+0]=u,e[t+1]=p,e[t+2]=y,e[t+3]=x;return}if(c===1){e[t+0]=S,e[t+1]=M,e[t+2]=I,e[t+3]=L;return}if(x!==L||u!==S||p!==M||y!==I){let B=1-c;const A=u*S+p*M+y*I+x*L,V=A>=0?1:-1,X=1-A*A;if(X>Number.EPSILON){const te=Math.sqrt(X),oe=Math.atan2(te,A*V);B=Math.sin(B*oe)/te,c=Math.sin(c*oe)/te}const P=c*V;if(u=u*B+S*P,p=p*B+M*P,y=y*B+I*P,x=x*B+L*P,B===1-c){const te=1/Math.sqrt(u*u+p*p+y*y+x*x);u*=te,p*=te,y*=te,x*=te}}e[t]=u,e[t+1]=p,e[t+2]=y,e[t+3]=x}static multiplyQuaternionsFlat(e,t,n,r,i,a){const c=n[r],u=n[r+1],p=n[r+2],y=n[r+3],x=i[a],S=i[a+1],M=i[a+2],I=i[a+3];return e[t]=c*I+y*x+u*M-p*S,e[t+1]=u*I+y*S+p*x-c*M,e[t+2]=p*I+y*M+c*S-u*x,e[t+3]=y*I-c*x-u*S-p*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,i=e._z,a=e._order,c=Math.cos,u=Math.sin,p=c(n/2),y=c(r/2),x=c(i/2),S=u(n/2),M=u(r/2),I=u(i/2);switch(a){case"XYZ":this._x=S*y*x+p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x-S*M*I;break;case"YXZ":this._x=S*y*x+p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x+S*M*I;break;case"ZXY":this._x=S*y*x-p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x-S*M*I;break;case"ZYX":this._x=S*y*x-p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x+S*M*I;break;case"YZX":this._x=S*y*x+p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x-S*M*I;break;case"XZY":this._x=S*y*x-p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x+S*M*I;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],c=t[5],u=t[9],p=t[2],y=t[6],x=t[10],S=n+c+x;if(S>0){const M=.5/Math.sqrt(S+1);this._w=.25/M,this._x=(y-u)*M,this._y=(i-p)*M,this._z=(a-r)*M}else if(n>c&&n>x){const M=2*Math.sqrt(1+n-c-x);this._w=(y-u)/M,this._x=.25*M,this._y=(r+a)/M,this._z=(i+p)/M}else if(c>x){const M=2*Math.sqrt(1+c-n-x);this._w=(i-p)/M,this._x=(r+a)/M,this._y=.25*M,this._z=(u+y)/M}else{const M=2*Math.sqrt(1+x-n-c);this._w=(a-r)/M,this._x=(i+p)/M,this._y=(u+y)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yi(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,a=e._w,c=t._x,u=t._y,p=t._z,y=t._w;return this._x=n*y+a*c+r*p-i*u,this._y=r*y+a*u+i*c-n*p,this._z=i*y+a*p+n*u-r*c,this._w=a*y-n*c-r*u-i*p,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,i=this._z,a=this._w;let c=a*e._w+n*e._x+r*e._y+i*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;const u=1-c*c;if(u<=Number.EPSILON){const M=1-t;return this._w=M*a+t*this._w,this._x=M*n+t*this._x,this._y=M*r+t*this._y,this._z=M*i+t*this._z,this.normalize(),this}const p=Math.sqrt(u),y=Math.atan2(p,c),x=Math.sin((1-t)*y)/p,S=Math.sin(t*y)/p;return this._w=a*x+this._w*S,this._x=n*x+this._x*S,this._y=r*x+this._y*S,this._z=i*x+this._z*S,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class pt{constructor(e=0,t=0,n=0){pt.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(s4e.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(s4e.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,c=e.z,u=e.w,p=2*(a*r-c*n),y=2*(c*t-i*r),x=2*(i*n-a*t);return this.x=t+u*p+a*x-c*y,this.y=n+u*y+c*p-i*x,this.z=r+u*x+i*y-a*p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,a=t.x,c=t.y,u=t.z;return this.x=r*u-i*c,this.y=i*a-n*u,this.z=n*c-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sG.copy(this).projectOnVector(e),this.sub(sG)}reflect(e){return this.sub(sG.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const sG=new pt,s4e=new i_;class Is{constructor(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B){Is.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B)}set(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B){const A=this.elements;return A[0]=e,A[4]=t,A[8]=n,A[12]=r,A[1]=i,A[5]=a,A[9]=c,A[13]=u,A[2]=p,A[6]=y,A[10]=x,A[14]=S,A[3]=M,A[7]=I,A[11]=L,A[15]=B,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Is().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/N7.setFromMatrixColumn(e,0).length(),i=1/N7.setFromMatrixColumn(e,1).length(),a=1/N7.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),c=Math.sin(n),u=Math.cos(r),p=Math.sin(r),y=Math.cos(i),x=Math.sin(i);if(e.order==="XYZ"){const S=a*y,M=a*x,I=c*y,L=c*x;t[0]=u*y,t[4]=-u*x,t[8]=p,t[1]=M+I*p,t[5]=S-L*p,t[9]=-c*u,t[2]=L-S*p,t[6]=I+M*p,t[10]=a*u}else if(e.order==="YXZ"){const S=u*y,M=u*x,I=p*y,L=p*x;t[0]=S+L*c,t[4]=I*c-M,t[8]=a*p,t[1]=a*x,t[5]=a*y,t[9]=-c,t[2]=M*c-I,t[6]=L+S*c,t[10]=a*u}else if(e.order==="ZXY"){const S=u*y,M=u*x,I=p*y,L=p*x;t[0]=S-L*c,t[4]=-a*x,t[8]=I+M*c,t[1]=M+I*c,t[5]=a*y,t[9]=L-S*c,t[2]=-a*p,t[6]=c,t[10]=a*u}else if(e.order==="ZYX"){const S=a*y,M=a*x,I=c*y,L=c*x;t[0]=u*y,t[4]=I*p-M,t[8]=S*p+L,t[1]=u*x,t[5]=L*p+S,t[9]=M*p-I,t[2]=-p,t[6]=c*u,t[10]=a*u}else if(e.order==="YZX"){const S=a*u,M=a*p,I=c*u,L=c*p;t[0]=u*y,t[4]=L-S*x,t[8]=I*x+M,t[1]=x,t[5]=a*y,t[9]=-c*y,t[2]=-p*y,t[6]=M*x+I,t[10]=S-L*x}else if(e.order==="XZY"){const S=a*u,M=a*p,I=c*u,L=c*p;t[0]=u*y,t[4]=-x,t[8]=p*y,t[1]=S*x+L,t[5]=a*y,t[9]=M*x-I,t[2]=I*x-M,t[6]=c*y,t[10]=L*x+S}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(UBe,e,zBe)}lookAt(e,t,n){const r=this.elements;return ju.subVectors(e,t),ju.lengthSq()===0&&(ju.z=1),ju.normalize(),b3.crossVectors(n,ju),b3.lengthSq()===0&&(Math.abs(n.z)===1?ju.x+=1e-4:ju.z+=1e-4,ju.normalize(),b3.crossVectors(n,ju)),b3.normalize(),KR.crossVectors(ju,b3),r[0]=b3.x,r[4]=KR.x,r[8]=ju.x,r[1]=b3.y,r[5]=KR.y,r[9]=ju.y,r[2]=b3.z,r[6]=KR.z,r[10]=ju.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],c=n[4],u=n[8],p=n[12],y=n[1],x=n[5],S=n[9],M=n[13],I=n[2],L=n[6],B=n[10],A=n[14],V=n[3],X=n[7],P=n[11],te=n[15],oe=r[0],ie=r[4],K=r[8],re=r[12],se=r[1],q=r[5],De=r[9],Be=r[13],tt=r[2],st=r[6],de=r[10],ft=r[14],Se=r[3],rt=r[7],ut=r[11],Pe=r[15];return i[0]=a*oe+c*se+u*tt+p*Se,i[4]=a*ie+c*q+u*st+p*rt,i[8]=a*K+c*De+u*de+p*ut,i[12]=a*re+c*Be+u*ft+p*Pe,i[1]=y*oe+x*se+S*tt+M*Se,i[5]=y*ie+x*q+S*st+M*rt,i[9]=y*K+x*De+S*de+M*ut,i[13]=y*re+x*Be+S*ft+M*Pe,i[2]=I*oe+L*se+B*tt+A*Se,i[6]=I*ie+L*q+B*st+A*rt,i[10]=I*K+L*De+B*de+A*ut,i[14]=I*re+L*Be+B*ft+A*Pe,i[3]=V*oe+X*se+P*tt+te*Se,i[7]=V*ie+X*q+P*st+te*rt,i[11]=V*K+X*De+P*de+te*ut,i[15]=V*re+X*Be+P*ft+te*Pe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],c=e[5],u=e[9],p=e[13],y=e[2],x=e[6],S=e[10],M=e[14],I=e[3],L=e[7],B=e[11],A=e[15];return I*(+i*u*x-r*p*x-i*c*S+n*p*S+r*c*M-n*u*M)+L*(+t*u*M-t*p*S+i*a*S-r*a*M+r*p*y-i*u*y)+B*(+t*p*x-t*c*M-i*a*x+n*a*M+i*c*y-n*p*y)+A*(-r*c*y-t*u*x+t*c*S+r*a*x-n*a*S+n*u*y)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8],x=e[9],S=e[10],M=e[11],I=e[12],L=e[13],B=e[14],A=e[15],V=x*B*p-L*S*p+L*u*M-c*B*M-x*u*A+c*S*A,X=I*S*p-y*B*p-I*u*M+a*B*M+y*u*A-a*S*A,P=y*L*p-I*x*p+I*c*M-a*L*M-y*c*A+a*x*A,te=I*x*u-y*L*u-I*c*S+a*L*S+y*c*B-a*x*B,oe=t*V+n*X+r*P+i*te;if(oe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const ie=1/oe;return e[0]=V*ie,e[1]=(L*S*i-x*B*i-L*r*M+n*B*M+x*r*A-n*S*A)*ie,e[2]=(c*B*i-L*u*i+L*r*p-n*B*p-c*r*A+n*u*A)*ie,e[3]=(x*u*i-c*S*i-x*r*p+n*S*p+c*r*M-n*u*M)*ie,e[4]=X*ie,e[5]=(y*B*i-I*S*i+I*r*M-t*B*M-y*r*A+t*S*A)*ie,e[6]=(I*u*i-a*B*i-I*r*p+t*B*p+a*r*A-t*u*A)*ie,e[7]=(a*S*i-y*u*i+y*r*p-t*S*p-a*r*M+t*u*M)*ie,e[8]=P*ie,e[9]=(I*x*i-y*L*i-I*n*M+t*L*M+y*n*A-t*x*A)*ie,e[10]=(a*L*i-I*c*i+I*n*p-t*L*p-a*n*A+t*c*A)*ie,e[11]=(y*c*i-a*x*i-y*n*p+t*x*p+a*n*M-t*c*M)*ie,e[12]=te*ie,e[13]=(y*L*r-I*x*r+I*n*S-t*L*S-y*n*B+t*x*B)*ie,e[14]=(I*c*r-a*L*r-I*n*u+t*L*u+a*n*B-t*c*B)*ie,e[15]=(a*x*r-y*c*r+y*n*u-t*x*u-a*n*S+t*c*S)*ie,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,c=e.y,u=e.z,p=i*a,y=i*c;return this.set(p*a+n,p*c-r*u,p*u+r*c,0,p*c+r*u,y*c+n,y*u-r*a,0,p*u-r*c,y*u+r*a,i*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,a=t._y,c=t._z,u=t._w,p=i+i,y=a+a,x=c+c,S=i*p,M=i*y,I=i*x,L=a*y,B=a*x,A=c*x,V=u*p,X=u*y,P=u*x,te=n.x,oe=n.y,ie=n.z;return r[0]=(1-(L+A))*te,r[1]=(M+P)*te,r[2]=(I-X)*te,r[3]=0,r[4]=(M-P)*oe,r[5]=(1-(S+A))*oe,r[6]=(B+V)*oe,r[7]=0,r[8]=(I+X)*ie,r[9]=(B-V)*ie,r[10]=(1-(S+L))*ie,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=N7.set(r[0],r[1],r[2]).length();const a=N7.set(r[4],r[5],r[6]).length(),c=N7.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],bf.copy(this);const p=1/i,y=1/a,x=1/c;return bf.elements[0]*=p,bf.elements[1]*=p,bf.elements[2]*=p,bf.elements[4]*=y,bf.elements[5]*=y,bf.elements[6]*=y,bf.elements[8]*=x,bf.elements[9]*=x,bf.elements[10]*=x,t.setFromRotationMatrix(bf),n.x=i,n.y=a,n.z=c,this}makePerspective(e,t,n,r,i,a,c=Zc){const u=this.elements,p=2*i/(t-e),y=2*i/(n-r),x=(t+e)/(t-e),S=(n+r)/(n-r);let M,I;if(c===Zc)M=-(a+i)/(a-i),I=-2*a*i/(a-i);else if(c===X3)M=-a/(a-i),I=-a*i/(a-i);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return u[0]=p,u[4]=0,u[8]=x,u[12]=0,u[1]=0,u[5]=y,u[9]=S,u[13]=0,u[2]=0,u[6]=0,u[10]=M,u[14]=I,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,i,a,c=Zc){const u=this.elements,p=1/(t-e),y=1/(n-r),x=1/(a-i),S=(t+e)*p,M=(n+r)*y;let I,L;if(c===Zc)I=(a+i)*x,L=-2*x;else if(c===X3)I=i*x,L=-1*x;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return u[0]=2*p,u[4]=0,u[8]=0,u[12]=-S,u[1]=0,u[5]=2*y,u[9]=0,u[13]=-M,u[2]=0,u[6]=0,u[10]=L,u[14]=-I,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const N7=new pt,bf=new Is,UBe=new pt(0,0,0),zBe=new pt(1,1,1),b3=new pt,KR=new pt,ju=new pt;class ci{constructor(e=0,t=0){ci.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ri{constructor(e=0,t=0,n=0,r=1){Ri.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const u=e.elements,p=u[0],y=u[4],x=u[8],S=u[1],M=u[5],I=u[9],L=u[2],B=u[6],A=u[10];if(Math.abs(y-S)<.01&&Math.abs(x-L)<.01&&Math.abs(I-B)<.01){if(Math.abs(y+S)<.1&&Math.abs(x+L)<.1&&Math.abs(I+B)<.1&&Math.abs(p+M+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const X=(p+1)/2,P=(M+1)/2,te=(A+1)/2,oe=(y+S)/4,ie=(x+L)/4,K=(I+B)/4;return X>P&&X>te?X<.01?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(X),r=oe/n,i=ie/n):P>te?P<.01?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(P),n=oe/r,i=K/r):te<.01?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(te),n=ie/i,r=K/i),this.set(n,r,i,t),this}let V=Math.sqrt((B-I)*(B-I)+(x-L)*(x-L)+(S-y)*(S-y));return Math.abs(V)<.001&&(V=1),this.x=(B-I)/V,this.y=(x-L)/V,this.z=(S-y)/V,this.w=Math.acos((p+M+A-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this.w=yi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this.w=yi(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}function PE(s,e=0){let t=3735928559^e,n=1103547991^e;if(s instanceof Array)for(let r=0,i;r<s.length;r++)i=s[r],t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677);else for(let r=0,i;r<s.length;r++)i=s.charCodeAt(r),t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const VBe=s=>PE(s),h$=s=>PE(s),Ak=(...s)=>PE(s);function bye(s,e=!1){const t=[];s.isNode===!0&&(t.push(s.id),s=s.getSelf());for(const{property:n,childNode:r}of Pk(s))t.push(PE(n.slice(0,-4)),r.getCacheKey(e));return PE(t)}function*Pk(s,e=!1){for(const t in s){if(t.startsWith("_")===!0)continue;const n=s[t];if(Array.isArray(n)===!0)for(let r=0;r<n.length;r++){const i=n[r];i&&(i.isNode===!0||e&&typeof i.toJSON=="function")&&(yield{property:t,index:r,childNode:i})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(typeof n=="object")for(const r in n){const i=n[r];i&&(i.isNode===!0||e&&typeof i.toJSON=="function")&&(yield{property:t,index:r,childNode:i})}}}const GBe=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),o4e=new WeakMap;function jBe(s){return GBe.get(s)}function Rk(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix2===!0?"mat2":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function Sye(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new Zi(...e):t==="vec2"?new ci(...e):t==="vec3"?new pt(...e):t==="vec4"?new Ri(...e):t==="mat2"?new Yk(...e):t==="mat3"?new nu(...e):t==="mat4"?new Is(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?WBe(e[0]):null}function wye(s){let e=o4e.get(s);return e===void 0&&(e={},o4e.set(s,e)),e}function HBe(s){let e="";const t=new Uint8Array(s);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function WBe(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}let $Be=0;function qBe(s){const e=Object.keys(s);let t=Object.getPrototypeOf(s);for(;t;){const n=Object.getOwnPropertyDescriptors(t);for(const r in n)if(n[r]!==void 0){const i=n[r];i&&typeof i.get=="function"&&e.push(r)}t=Object.getPrototypeOf(t)}return e}class XBe{constructor(e,t,n,r,i,a,c,u,p,y){this.id=$Be++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=c,this.lightsNode=u,this.context=p,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=y,this.clippingContextCacheKey=y!==null?y.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const i of e){const a=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(a===void 0)continue;n.push(a);const c=a.isInterleavedBufferAttribute?a.data:a;r.add(c)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),c=this.getIndex(),u=c!==null;let p=1;if(n.isInstancedBufferGeometry===!0?p=n.instanceCount:e.count!==void 0&&(p=Math.max(0,e.count)),p===0)return null;if(a.instanceCount=p,e.isBatchedMesh===!0)return a;let y=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(y=2);let x=i.start*y,S=(i.start+i.count)*y;r!==null&&(x=Math.max(x,r.start*y),S=Math.min(S,(r.start+r.count)*y));const M=n.attributes.position;let I=1/0;u?I=c.count:M!=null&&(I=M.count),x=Math.max(x,0),S=Math.min(S,I);const L=S-x;return L<0||L===1/0?null:(a.vertexCount=L,a.firstVertex=x,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[n];t+="morph-"+n+",";for(let i=0,a=r.length;i<a;i++){const c=r[i];t+=c.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of qBe(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const i=t[r];let a;if(i!==null){const c=typeof i;c==="number"?a=i!==0?"1":"0":c==="object"?(a="{",i.isTexture&&(a+=i.mapping),a+="}"):a=String(i)}else a=String(i);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",VBe(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ak(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ak(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const H8=[];class YBe{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,c,u){const p=this.getChainMap(u);H8[0]=e,H8[1]=t,H8[2]=a,H8[3]=i;let y=p.get(H8);return y===void 0?(y=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,c,u),p.set(H8,y)):(y.updateClipping(c),y.needsGeometryUpdate&&y.setGeometry(e.geometry),(y.version!==t.version||y.needsUpdate)&&(y.initialCacheKey!==y.getCacheKey()?(y.dispose(),y=this.get(e,t,n,r,i,a,c,u)):y.version=t.version)),H8.length=0,y}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Lf)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,c,u,p,y,x){const S=this.getChainMap(x),M=new XBe(e,t,n,r,i,a,c,u,p,y);return M.onDispose=()=>{this.pipelines.delete(M),this.bindings.delete(M),this.nodes.delete(M),S.delete(M.getChainArray())},M}}class J3{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const rd={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},F3=16,KBe=211,ZBe=212;class QBe extends J3{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===rd.VERTEX?this.backend.createAttribute(e):t===rd.INDEX?this.backend.createIndexAttribute(e):t===rd.STORAGE?this.backend.createStorageAttribute(e):t===rd.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version<r.version||r.usage===fx)&&(this.backend.updateAttribute(e),n.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const Ng=JBe();function JBe(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const p=u-127;p<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):p<-14?(n[u]=1024>>-p-14,n[u|256]=1024>>-p-14|32768,r[u]=-p-1,r[u|256]=-p-1):p<=15?(n[u]=p+15<<10,n[u|256]=p+15<<10|32768,r[u]=13,r[u|256]=13):p<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const i=new Uint32Array(2048),a=new Uint32Array(64),c=new Uint32Array(64);for(let u=1;u<1024;++u){let p=u<<13,y=0;for(;(p&8388608)===0;)p<<=1,y-=8388608;p&=-8388609,y+=947912704,i[u]=p|y}for(let u=1024;u<2048;++u)i[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(c[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:i,exponentTable:a,offsetTable:c}}function Hu(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=yi(s,-65504,65504),Ng.floatView[0]=s;const e=Ng.uint32View[0],t=e>>23&511;return Ng.baseTable[t]+((e&8388607)>>Ng.shiftTable[t])}function ZR(s){const e=s>>10;return Ng.uint32View[0]=Ng.mantissaTable[Ng.offsetTable[e]+(s&1023)]+Ng.exponentTable[e],Ng.floatView[0]}const la=new pt,QR=new ci;let eUe=0;class id{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eUe++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ck,this.updateRanges=[],this.gpuType=Zu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)QR.fromBufferAttribute(this,t),QR.applyMatrix3(e),this.setXY(t,QR.x,QR.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyMatrix3(e),this.setXYZ(t,la.x,la.y,la.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyMatrix4(e),this.setXYZ(t,la.x,la.y,la.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyNormalMatrix(e),this.setXYZ(t,la.x,la.y,la.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.transformDirection(e),this.setXYZ(t,la.x,la.y,la.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ac(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ac(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ac(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ac(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ac(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array),i=Qr(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ck&&(e.usage=this.usage),e}}class Eye extends id{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Tye extends id{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mye extends id{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=ZR(this.array[e*this.itemSize]);return this.normalized&&(t=ac(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize]=Hu(t),this}getY(e){let t=ZR(this.array[e*this.itemSize+1]);return this.normalized&&(t=ac(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+1]=Hu(t),this}getZ(e){let t=ZR(this.array[e*this.itemSize+2]);return this.normalized&&(t=ac(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+2]=Hu(t),this}getW(e){let t=ZR(this.array[e*this.itemSize+3]);return this.normalized&&(t=ac(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+3]=Hu(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this.array[e+2]=Hu(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array),i=Qr(i,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this.array[e+2]=Hu(r),this.array[e+3]=Hu(i),this}}class uc extends id{constructor(e,t,n){super(new Float32Array(e),t,n)}}function Cye(s){return s.index!==null?s.index.version:s.attributes.position.version}function a4e(s){const e=[],t=s.index,n=s.attributes.position;if(t!==null){const i=t.array;for(let a=0,c=i.length;a<c;a+=3){const u=i[a+0],p=i[a+1],y=i[a+2];e.push(u,p,p,y,y,u)}}else{const i=n.array;for(let a=0,c=i.length/3-1;a<c;a+=3){const u=a+0,p=a+1,y=a+2;e.push(u,p,p,y,y,u)}}const r=new(xye(e)?Tye:Eye)(e,1);return r.version=Cye(s),r}class tUe extends J3{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const i=t.index,a=e.getAttributes();i!==null&&this.attributes.delete(i);for(const u of a)this.attributes.delete(u);const c=this.wireframes.get(t);c!==void 0&&this.attributes.delete(c),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const i of t)i.isStorageBufferAttribute||i.isStorageInstancedBufferAttribute?this.updateAttribute(i,rd.STORAGE):this.updateAttribute(i,rd.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,rd.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,rd.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const i=this.wireframes;let a=i.get(t);a===void 0?(a=a4e(t),i.set(t,a)):a.version!==Cye(t)&&(this.attributes.delete(a),a=a4e(t),i.set(t,a)),r=a}return r}}class nUe{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class Aye{constructor(e){this.cacheKey=e,this.usedTimes=0}}class rUe extends Aye{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class iUe extends Aye{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let sUe=0;class oG{constructor(e,t,n,r=null,i=null){this.id=sUe++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}}class oUe extends J3{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let c=this.programs.compute.get(a.computeShader);c===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),c=new oG(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,c),n.createProgram(c));const u=this._getComputeCacheKey(e,c);let p=this.caches.get(u);p===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),p=this._getComputePipeline(e,c,u,t)),p.usedTimes++,c.usedTimes++,r.version=e.version,r.pipeline=p}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),c=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),u=new oG(a.vertexShader,"vertex",c),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let p=this.programs.fragment.get(a.fragmentShader);p===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),p=new oG(a.fragmentShader,"fragment",c),this.programs.fragment.set(a.fragmentShader,p),n.createProgram(p));const y=this._getRenderCacheKey(e,u,p);let x=this.caches.get(y);x===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),x=this._getRenderPipeline(e,u,p,y,t)):e.pipeline=x,x.usedTimes++,u.usedTimes++,p.usedTimes++,r.pipeline=x}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new iUe(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new rUe(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class aUe extends J3{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?rd.INDIRECT:rd.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,i=!0,a=0,c=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isStorageBuffer){const p=u.attribute,y=p.isIndirectStorageBufferAttribute?rd.INDIRECT:rd.STORAGE;this.attributes.update(p,y)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const p=this.textures.get(u.texture);u.needsBindingsUpdate(p.generation)&&(r=!0);const y=u.update(),x=u.texture;y&&this.textures.updateTexture(x);const S=n.get(x);if(S.externalTexture!==void 0||p.isDefaultTexture?i=!1:(a=a*10+x.id,c+=x.version),n.isWebGPUBackend===!0&&S.texture===void 0&&S.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,y,x,u.textureNode.value,r),this.textures.updateTexture(x),r=!0),x.isStorageTexture===!0){const M=this.get(x);u.store===!0?M.needsMipmap=!0:this.textures.needsMipmaps(x)&&M.needsMipmap===!0&&(this.backend.generateMipmaps(x),M.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,i?a:0,c)}}function lUe(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?s.z-e.z:s.id-e.id}function l4e(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function c4e(s){return(s.transmission>0||s.transmissionNode)&&s.side===Sx&&s.forceSinglePass===!1}class cUe{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,c){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:c},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=i,u.group=a,u.clippingContext=c),this.renderItemsIndex++,u}push(e,t,n,r,i,a,c){const u=this.getNextRenderItem(e,t,n,r,i,a,c);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(c4e(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,i,a,c){const u=this.getNextRenderItem(e,t,n,r,i,a,c);n.transparent===!0||n.transmission>0?(c4e(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||lUe),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||l4e),this.transparent.length>1&&this.transparent.sort(t||l4e)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const n=this.renderItems[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.groupOrder=null,n.renderOrder=null,n.z=null,n.group=null,n.clippingContext=null}}}const mw=[];class uUe{constructor(e){this.lighting=e,this.lists=new Lf}get(e,t){const n=this.lists;mw[0]=e,mw[1]=t;let r=n.get(mw);return r===void 0&&(r=new cUe(this.lighting,e,t),n.set(mw,r)),mw.length=0,r}dispose(){this.lists=new Lf}}let hUe=0;class dUe{constructor(){this.id=hUe++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ri,this.scissor=!1,this.scissorValue=new Ri,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return Pye(this)}}function Pye(s){const{textures:e,activeCubeFace:t}=s,n=[t];for(const r of e)n.push(r.id);return h$(n)}let Av=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let i=0,a=r.length;i<a;i++)r[i].call(this,e);e.target=null}}};const u4e=new Is,h4e=new i_;class ad{constructor(e=0,t=0,n=0,r=ad.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],a=r[4],c=r[8],u=r[1],p=r[5],y=r[9],x=r[2],S=r[6],M=r[10];switch(t){case"XYZ":this._y=Math.asin(yi(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-y,M),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(S,p),this._z=0);break;case"YXZ":this._x=Math.asin(-yi(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(c,M),this._z=Math.atan2(u,p)):(this._y=Math.atan2(-x,i),this._z=0);break;case"ZXY":this._x=Math.asin(yi(S,-1,1)),Math.abs(S)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-a,p)):(this._y=0,this._z=Math.atan2(u,i));break;case"ZYX":this._y=Math.asin(-yi(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(S,M),this._z=Math.atan2(u,i)):(this._x=0,this._z=Math.atan2(-a,p));break;case"YZX":this._z=Math.asin(yi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-y,p),this._y=Math.atan2(-x,i)):(this._x=0,this._y=Math.atan2(c,M));break;case"XZY":this._z=Math.asin(-yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(S,p),this._y=Math.atan2(c,i)):(this._x=Math.atan2(-y,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return u4e.makeRotationFromQuaternion(e),this.setFromRotationMatrix(u4e,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return h4e.setFromEuler(this),this.setFromQuaternion(h4e,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ad.DEFAULT_ORDER="XYZ";class fUe{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let pUe=0;const d4e=new pt,D7=new i_,Eg=new Is,JR=new pt,gw=new pt,mUe=new pt,gUe=new i_,f4e=new pt(1,0,0),p4e=new pt(0,1,0),m4e=new pt(0,0,1),g4e={type:"added"},vUe={type:"removed"},O7={type:"childadded",child:null},aG={type:"childremoved",child:null};class Aa extends Av{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:pUe++}),this.uuid=Fg(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Aa.DEFAULT_UP.clone();const e=new pt,t=new ad,n=new i_,r=new pt(1,1,1);function i(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(i),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Is},normalMatrix:{value:new nu}}),this.matrix=new Is,this.matrixWorld=new Is,this.matrixAutoUpdate=Aa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fUe,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return D7.setFromAxisAngle(e,t),this.quaternion.multiply(D7),this}rotateOnWorldAxis(e,t){return D7.setFromAxisAngle(e,t),this.quaternion.premultiply(D7),this}rotateX(e){return this.rotateOnAxis(f4e,e)}rotateY(e){return this.rotateOnAxis(p4e,e)}rotateZ(e){return this.rotateOnAxis(m4e,e)}translateOnAxis(e,t){return d4e.copy(e).applyQuaternion(this.quaternion),this.position.add(d4e.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(f4e,e)}translateY(e){return this.translateOnAxis(p4e,e)}translateZ(e){return this.translateOnAxis(m4e,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Eg.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?JR.copy(e):JR.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),gw.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Eg.lookAt(gw,JR,this.up):Eg.lookAt(JR,gw,this.up),this.quaternion.setFromRotationMatrix(Eg),r&&(Eg.extractRotation(r.matrixWorld),D7.setFromRotationMatrix(Eg),this.quaternion.premultiply(D7.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(g4e),O7.child=e,this.dispatchEvent(O7),O7.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(vUe),aG.child=e,this.dispatchEvent(aG),aG.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Eg.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Eg.multiply(e.parent.matrixWorld)),e.applyMatrix4(Eg),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(g4e),O7.child=e,this.dispatchEvent(O7),O7.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gw,e,mUe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gw,gUe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>({...c})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let p=0,y=u.length;p<y;p++){const x=u[p];i(e.shapes,x)}else i(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,p=this.material.length;u<p;u++)c.push(i(e.materials,this.material[u]));r.material=c}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];r.animations.push(i(e.animations,u))}}if(t){const c=a(e.geometries),u=a(e.materials),p=a(e.textures),y=a(e.images),x=a(e.shapes),S=a(e.skeletons),M=a(e.animations),I=a(e.nodes);c.length>0&&(n.geometries=c),u.length>0&&(n.materials=u),p.length>0&&(n.textures=p),y.length>0&&(n.images=y),x.length>0&&(n.shapes=x),S.length>0&&(n.skeletons=S),M.length>0&&(n.animations=M),I.length>0&&(n.nodes=I)}return n.object=r,n;function a(c){const u=[];for(const p in c){const y=c[p];delete y.metadata,u.push(y)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Aa.DEFAULT_UP=new pt(0,1,0);Aa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class d$ extends Aa{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ad,this.environmentIntensity=1,this.environmentRotation=new ad,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class f$ extends Aa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Is,this.projectionMatrix=new Is,this.projectionMatrixInverse=new Is,this.coordinateSystem=Zc}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const vw=[],yUe=new d$,xUe=new f$;class _Ue{constructor(){this.chainMaps={}}get(e,t,n=null){vw[0]=e,vw[1]=t;let r;if(n===null)r="default";else{const c=n.texture.format;r=`${n.textures.length}:${c}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const i=this._getChainMap(r);let a=i.get(vw);return a===void 0&&(a=new dUe,i.set(vw,a)),vw.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(yUe,xUe,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Lf)}dispose(){this.chainMaps={}}}let L7;class bUe{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{L7===void 0&&(L7=KH("canvas")),L7.width=e.width,L7.height=e.height;const r=L7.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=L7}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=KH("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let a=0;a<i.length;a++)i[a]=Gg(i[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Gg(t[n]/255)*255):t[n]=Gg(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let SUe=0;class p${constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:SUe++}),this.uuid=Fg(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let i;if(Array.isArray(r)){i=[];for(let a=0,c=r.length;a<c;a++)r[a].isDataTexture?i.push(lG(r[a].image)):i.push(lG(r[a]))}else i=lG(r);n.url=i}return t||(e.images[this.uuid]=n),n}}function lG(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?bUe.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let wUe=0;const cG=new pt;class _l extends Av{constructor(e=_l.DEFAULT_IMAGE,t=_l.DEFAULT_MAPPING,n=z3,r=z3,i=th,a=zg,c=nd,u=lc,p=_l.DEFAULT_ANISOTROPY,y=$g){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wUe++}),this.uuid=Fg(),this.name="",this.source=new p$(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=p,this.format=c,this.internalFormat=null,this.type=u,this.offset=new ci(0,0),this.repeat=new ci(1,1),this.center=new ci(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new nu,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=y,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(cG).x}get height(){return this.source.getSize(cG).y}get depth(){return this.source.getSize(cG).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==n$)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Hx:e.x=e.x-Math.floor(e.x);break;case z3:e.x=e.x<0?0:1;break;case Wx:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Hx:e.y=e.y-Math.floor(e.y);break;case z3:e.y=e.y<0?0:1;break;case Wx:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}_l.DEFAULT_IMAGE=null;_l.DEFAULT_MAPPING=n$;_l.DEFAULT_ANISOTROPY=1;class w1 extends _l{constructor(e,t,n=Zo,r,i,a,c=Ca,u=Ca,p,y=S1,x=1){if(y!==S1&&y!==Vg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const S={width:e,height:t,depth:x};super(S,r,i,a,c,u,y,n,p),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new p$(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const EUe=new pt;class TUe extends J3{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||(n.depthTextureMips={}),a=e.textures,c=this.getSize(a[0]),u=c.width>>t,p=c.height>>t;let y=e.depthTexture||i[t];const x=e.depthBuffer===!0||e.stencilBuffer===!0;let S=!1;y===void 0&&x&&(y=new w1,y.format=e.stencilBuffer?Vg:S1,y.type=e.stencilBuffer?G3:Zo,y.image.width=u,y.image.height=p,y.image.depth=c.depth,y.isArrayTexture=e.multiview===!0&&c.depth>1,i[t]=y),(n.width!==c.width||c.height!==n.height)&&(S=!0,y&&(y.needsUpdate=!0,y.image.width=u,y.image.height=p,y.image.depth=y.isArrayTexture?y.image.depth:1)),n.width=c.width,n.height=c.height,n.textures=a,n.depthTexture=y||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(S=!0,y&&(y.needsUpdate=!0),n.sampleCount=r);const M={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let I=0;I<a.length;I++){const L=a[I];S&&(L.needsUpdate=!0),this.updateTexture(L,M)}y&&this.updateTexture(y,M)}if(n.initialized!==!0){n.initialized=!0;const I=()=>{e.removeEventListener("dispose",I);for(let L=0;L<a.length;L++)this._destroyTexture(a[L]);y&&this._destroyTexture(y),this.delete(e)};e.addEventListener("dispose",I)}}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&(i.destroySampler(e),i.destroyTexture(e)),e.isFramebufferTexture){const p=this.renderer.getRenderTarget();p?e.type=p.texture.type:e.type=lc}const{width:a,height:c,depth:u}=this.getSize(e);if(t.width=a,t.height=c,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,c):1,r||e.isStorageTexture===!0)i.createSampler(e),i.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&i.createSampler(e),e.version>0){const y=e.image;if(y===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(y.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const x=[];for(const S of e.images)x.push(S);t.images=x}else t.image=y;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const p=()=>{e.removeEventListener("dispose",p),this._destroyTexture(e)};e.addEventListener("dispose",p)}n.version=e.version}getSize(e,t=EUe){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.isCompressedTexture===!0||e.generateMipmaps}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class m$ extends Zi{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}const eI={VERTEX:"vertex"},pi={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Og={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},MUe=["fragment","vertex"],v4e=["setup","analyze","generate"],y4e=[...MUe,"compute"],s_=["x","y","z","w"],CUe={analyze:"setup",generate:"analyze"};let AUe=0,Xr=class extends Av{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=pi.NONE,this.updateBeforeType=pi.NONE,this.updateAfterType=pi.NONE,this.uuid=tBe.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:AUe++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,pi.FRAME)}onRenderUpdate(e){return this.onUpdate(e,pi.RENDER)}onObjectUpdate(e){return this.onUpdate(e,pi.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Pk(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Ak(bye(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(n===1){const r=e.getNodeProperties(this);for(const i of Object.values(r))i&&i.isNode===!0&&i.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const i=CUe[e.buildStage];if(i&&r.buildStages[i]!==!0){const u=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(u)}e.addNode(this),e.addChain(this);let a=null;const c=e.getBuildStage();if(c==="setup"){this.updateReference(e);const u=e.getNodeProperties(this);if(u.initialized!==!0){u.initialized=!0,u.outputNode=this.setup(e)||u.outputNode||null;for(const p of Object.values(u))if(p&&p.isNode===!0){if(p.parents===!0){const y=e.getNodeProperties(p);y.parents=y.parents||[],y.parents.push(this)}p.build(e)}}a=u.outputNode}else if(c==="analyze")this.analyze(e,t);else if(c==="generate")if(this.generate.length===1){const p=this.getNodeType(e),y=e.getDataFromNode(this);a=y.snippet,a===void 0?y.generated===void 0?(y.generated=!0,a=this.generate(e)||"",y.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):y.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,p,t)}else a=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Pk(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:i,childNode:a}of t)i!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const i in e.inputNodes[n]){const a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(c){const u=[];for(const p in c){const y=c[p];delete y.metadata,u.push(y)}return u}if(r){const c=a(e.textures),u=a(e.images),p=a(e.nodes);c.length>0&&(i.textures=c),u.length>0&&(i.images=u),p.length>0&&(i.nodes=p)}return i}};class ma extends Xr{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(i.propertyName!==void 0)return e.format(i.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),c=e.getVarFromNode(this,null,r),u=e.getPropertyName(c);return e.addLineFlowCode(`${u} = ${a}`,this),i.snippet=a,i.propertyName=u,e.format(i.propertyName,r,t)}}return super.build(e,t)}}class UE extends Xr{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class Rye extends Xr{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}}class PUe extends ma{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),c=[];let u=0;for(const y of i){if(u>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let x=y.getNodeType(e),S=e.getTypeLength(x),M;u+S>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),S=r-u,x=e.getTypeFromLength(S)),u+=S,M=y.build(e,x);const I=e.getComponentType(x);I!==a&&(M=e.format(M,I,a)),c.push(M)}const p=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(p,n,t)}}const RUe=s_.join("");class x4e extends Xr{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(s_.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===RUe.slice(0,this.components.length)?i=e.format(u,a,t):i=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class IUe extends ma{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),c=e.getTypeFromLength(n.length,a),u=r.build(e,c),p=t.build(e,i),y=e.getTypeLength(i),x=[];for(let S=0;S<y;S++){const M=s_[S];M===n[0]?(x.push(u),S+=n.length-1):x.push(p+"."+M)}return`${e.getType(i)}( ${x.join(", ")} )`}}class kUe extends ma{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),c=e.getPropertyName(a);e.addLineFlowCode(c+" = "+i,this);const u=e.getTypeLength(r),p=[];let y=0;for(let x=0;x<u;x++){const S=s_[x];S===t[y]?(p.push("1.0 - "+(c+"."+S)),y++):p.push(c+"."+S)}return`${e.getType(r)}( ${p.join(", ")} )`}}class g$ extends Xr{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Rk(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Rk(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=HBe(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Sye(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const _4e=/float|u?int/;class Kg extends g${static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return _4e.test(n)&&_4e.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class NUe extends Xr{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let $x=null;const px=new Map;function Lt(s,e){if(px.has(s)){console.warn(`THREE.TSL: Redefinition of method chaining '${s}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${s} is not a function`);px.set(s,e)}const Iye=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),b4e=s=>Iye(s).split("").sort().join(""),kye={setup(s,e){const t=e.shift();return s(Qk(t),...e)},get(s,e,t){if(typeof e=="string"&&s[e]===void 0){if(s.isStackNode!==!0&&e==="assign")return(...n)=>($x.assign(t,...n),t);if(px.has(e)){const n=px.get(e);return s.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return s;if(e.endsWith("Assign")&&px.has(e.slice(0,e.length-6))){const n=px.get(e.slice(0,e.length-6));return s.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Iye(e),sn(new x4e(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=b4e(e.slice(3).toLowerCase()),n=>sn(new IUe(s,e,sn(n)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=b4e(e.slice(4).toLowerCase()),()=>sn(new kUe(sn(s),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),sn(new x4e(s,e));if(/^\d+$/.test(e)===!0)return sn(new UE(t,new Kg(Number(e),"uint")));if(/^get$/.test(e)===!0)return n=>sn(new NUe(t,n))}}}return Reflect.get(s,e,t)},set(s,e,t,n){return typeof e=="string"&&s[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(s,e,t,n)}},uG=new WeakMap,S4e=new WeakMap,DUe=function(s,e=null){const t=Rk(s);if(t==="node"){let n=uG.get(s);return n===void 0&&(n=new Proxy(s,kye),uG.set(s,n),uG.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return sn(ZH(s,e));if(t==="shader")return en(s)}return s},OUe=function(s,e=null){for(const t in s)s[t]=sn(s[t],e);return s},LUe=function(s,e=null){const t=s.length;for(let n=0;n<t;n++)s[n]=sn(s[n],e);return s},FUe=function(s,e=null,t=null,n=null){const r=y=>sn(n!==null?Object.assign(y,n):y);let i,a=e,c,u;function p(y){let x;return a?x=/[a-z]/i.test(a)?a+"()":a:x=s.type,c!==void 0&&y.length<c?(console.error(`THREE.TSL: "${x}" parameter length is less than minimum required.`),y.concat(new Array(c-y.length).fill(0))):u!==void 0&&y.length>u?(console.error(`THREE.TSL: "${x}" parameter length exceeds limit.`),y.slice(0,u)):y}return e===null?i=(...y)=>r(new s(...Mx(p(y)))):t!==null?(t=sn(t),i=(...y)=>r(new s(e,...Mx(p(y)),t))):i=(...y)=>r(new s(e,...Mx(p(y)))),i.setParameterLength=(...y)=>(y.length===1?c=u=y[0]:y.length===2&&([c,u]=y),i),i.setName=y=>(a=y,i),i},BUe=function(s,...e){return sn(new s(...Mx(e)))};class UUe extends Xr{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(r[i])return r[i];let a=null;if(t.layout){let c=S4e.get(e.constructor);c===void 0&&(c=new WeakMap,S4e.set(e.constructor,c));let u=c.get(t);u===void 0&&(u=sn(e.buildFunctionNode(t)),c.set(t,u)),e.addInclude(u),a=sn(u.call(n))}else{const c=t.jsFunc,u=n!==null||c.length>1?c(n||[],e):c(e);a=sn(u)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null;const r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),c=this.getOutputNode(e);if(r==="setup"){const u=e.getNamespace("initialized");i[u]!==!0&&(i[u]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r==="analyze"?c.build(e,t):r==="generate"&&(n=c.build(e,t)||"");return n}}class zUe extends Xr{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Qk(e),sn(new UUe(this,e))}setup(){return this.call()}}const VUe=[!1,!0],GUe=[0,1,2,3],jUe=[-1,-2],Nye=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],v$=new Map;for(const s of VUe)v$.set(s,new Kg(s));const y$=new Map;for(const s of GUe)y$.set(s,new Kg(s,"uint"));const x$=new Map([...y$].map(s=>new Kg(s.value,"int")));for(const s of jUe)x$.set(s,new Kg(s,"int"));const Kk=new Map([...x$].map(s=>new Kg(s.value)));for(const s of Nye)Kk.set(s,new Kg(s));for(const s of Nye)Kk.set(-s,new Kg(-s));const Zk={bool:v$,uint:y$,ints:x$,float:Kk},w4e=new Map([...v$,...Kk]),ZH=(s,e)=>w4e.has(s)?w4e.get(s):s.isNode===!0?s:new Kg(s,e),HUe=s=>{try{return s.getNodeType()}catch{return}},ga=function(s,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(r=>typeof r!="object"))&&(t=[Sye(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return sn(e.get(t[0]));if(t.length===1){const r=ZH(t[0],s);return HUe(r)===s?sn(r):sn(new Rye(r,s))}const n=t.map(r=>ZH(r));return sn(new PUe(n,s))}},E4e=s=>typeof s=="object"&&s!==null?s.value:s,WUe=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function Xw(s,e){return new Proxy(new zUe(s,e),kye)}const sn=(s,e=null)=>DUe(s,e),Qk=(s,e=null)=>new OUe(s,e),Mx=(s,e=null)=>new LUe(s,e),nn=(...s)=>new FUe(...s),xn=(...s)=>new BUe(...s);let $Ue=0;const en=(s,e=null)=>{let t=null;e!==null&&(typeof e=="object"?t=e.return:(typeof e=="string"?t=e:console.error("THREE.TSL: Invalid layout type."),e=null));const n=new Xw(s,t),r=(...i)=>{let a;Qk(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?a=[...i]:a=i[0];const u=n.call(a);return t==="void"&&u.toStack(),u};if(r.shaderNode=n,r.id=n.id,r.getNodeType=(...i)=>n.getNodeType(...i),r.getCacheKey=(...i)=>n.getCacheKey(...i),r.setLayout=i=>(n.setLayout(i),r),r.once=(i=null)=>(n.once=!0,n.namespace=i,r),e!==null){if(typeof e.inputs!="object"){const i={name:"fn"+$Ue++,type:t,inputs:[]};for(const a in e)a!=="return"&&i.inputs.push({name:a,type:e[a]});e=i}r.setLayout(e)}return r},Ik=s=>{$x=s},Dye=()=>$x,Jo=(...s)=>$x.If(...s);function Oye(s){return $x&&$x.add(s),s}Lt("toStack",Oye);const qUe=new ga("color"),Ut=new ga("float",Zk.float),zs=new ga("int",Zk.ints),XUe=new ga("uint",Zk.uint),_$=new ga("bool",Zk.bool),Sn=new ga("vec2"),Ig=new ga("ivec2"),YUe=new ga("uvec2"),KUe=new ga("bvec2"),zt=new ga("vec3"),ZUe=new ga("ivec3"),QUe=new ga("uvec3"),JUe=new ga("bvec3"),$r=new ga("vec4"),eze=new ga("ivec4"),tze=new ga("uvec4"),nze=new ga("bvec4"),b$=new ga("mat2"),hc=new ga("mat3"),Cx=new ga("mat4");Lt("toColor",qUe);Lt("toFloat",Ut);Lt("toInt",zs);Lt("toUint",XUe);Lt("toBool",_$);Lt("toVec2",Sn);Lt("toIVec2",Ig);Lt("toUVec2",YUe);Lt("toBVec2",KUe);Lt("toVec3",zt);Lt("toIVec3",ZUe);Lt("toUVec3",QUe);Lt("toBVec3",JUe);Lt("toVec4",$r);Lt("toIVec4",eze);Lt("toUVec4",tze);Lt("toBVec4",nze);Lt("toMat2",b$);Lt("toMat3",hc);Lt("toMat4",Cx);const rze=nn(UE).setParameterLength(2),ize=(s,e)=>sn(new Rye(sn(s),e));Lt("element",rze);Lt("convert",ize);Lt("append",s=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),Oye(s)));class sze extends ma{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return s_.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),c=n.build(e),u=r.build(e,a),p=r.getNodeType(e),y=e.getDataFromNode(this);let x;if(y.initialized===!0)t!=="void"&&(x=c);else if(i){const S=e.getVarFromNode(this,null,a),M=e.getPropertyName(S);e.addLineFlowCode(`${M} = ${u}`,this);const I=n.node,B=I.node.context({assign:!0}).build(e);for(let A=0;A<I.components.length;A++){const V=I.components[A];e.addLineFlowCode(`${B}.${V} = ${M}[ ${A} ]`,this)}t!=="void"&&(x=c)}else x=`${c} = ${u}`,(t==="void"||p==="void")&&(e.addLineFlowCode(x,this),t!=="void"&&(x=c));return y.initialized=!0,e.format(x,a,t)}}const oze=nn(sze).setParameterLength(2);Lt("assign",oze);class T4e extends ma{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const aze=(...s)=>{let e;if(s.length===1){const t=s[0];e=new T4e(null,t.length,t)}else{const t=s[0],n=s[1];e=new T4e(t,n)}return sn(e)};Lt("toArray",(s,e)=>aze(Array(e).fill(s)));class Lye extends Xr{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lze=s=>new Lye(s),S$=(s,e=0)=>new Lye(s,!0,e),cze=S$("frame"),kr=S$("render"),Fye=lze("object");class zE extends g${static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Fye}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const i=e(r,n);i!==void 0&&(this.value=i)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);const a=i.getInputType(e),c=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(c);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const Nr=(s,e)=>{const t=WUe(e||s),n=s&&s.isNode===!0?s.node&&s.node.value||s.value:s;return sn(new zE(n,t))};class cs extends Xr{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Bye=(s,e)=>sn(new cs(s,e)),kk=(s,e)=>sn(new cs(s,e,!0)),Ki=xn(cs,"vec4","DiffuseColor"),M4e=xn(cs,"vec3","EmissiveColor"),Dg=xn(cs,"float","Roughness"),Nk=xn(cs,"float","Metalness"),QH=xn(cs,"float","Clearcoat"),Dk=xn(cs,"float","ClearcoatRoughness"),mx=xn(cs,"vec3","Sheen"),w$=xn(cs,"float","SheenRoughness"),E$=xn(cs,"float","Iridescence"),Uye=xn(cs,"float","IridescenceIOR"),zye=xn(cs,"float","IridescenceThickness"),JH=xn(cs,"float","AlphaT"),ov=xn(cs,"float","Anisotropy"),JI=xn(cs,"vec3","AnisotropyT"),Ax=xn(cs,"vec3","AnisotropyB"),qu=xn(cs,"color","SpecularColor"),Ok=xn(cs,"float","SpecularF90"),eW=xn(cs,"float","Shininess"),cE=xn(cs,"vec4","Output"),hG=xn(cs,"float","dashSize"),C4e=xn(cs,"float","gapSize"),ek=xn(cs,"float","IOR"),tW=xn(cs,"float","Transmission"),Vye=xn(cs,"float","Thickness"),Gye=xn(cs,"float","AttenuationDistance"),jye=xn(cs,"color","AttenuationColor"),Hye=xn(cs,"float","Dispersion");class uze extends ma{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(u,p)=>{const y=p.type,x=y==="pointer";let S;return x?S="&"+u.build(e):S=u.build(e,y),S};if(Array.isArray(i)){if(i.length>r.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=r.length;else if(i.length<r.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<r.length;)i.push(Ut(0));for(let u=0;u<i.length;u++)t.push(a(i[u],r[u]))}else for(const u of r){const p=i[u.name];p!==void 0?t.push(a(p,u)):(console.error(`THREE.TSL: Input '${u.name}' not found in 'Fn()'.`),t.push(a(Ut(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const hze=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Mx(e):Qk(e[0]),sn(new uze(sn(s),e)));Lt("call",hze);const dze={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class oo extends ma{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let i=new oo(e,t,n);for(let a=0;a<r.length-1;a++)i=new oo(e,i,r[a]);t=i,n=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(dze[this.op],t)}getNodeType(e){const t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i==="void"||a==="void")return"void";if(t==="%")return i;if(t==="~"||t==="&"||t==="|"||t==="^"||t===">>"||t==="<<")return e.getIntegerType(i);if(t==="!"||t==="&&"||t==="||"||t==="^^")return"bool";if(t==="=="||t==="!="||t==="<"||t===">"||t==="<="||t===">="){const c=Math.max(e.getTypeLength(i),e.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else{if(e.isMatrix(i)){if(a==="float")return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i==="float")return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){const n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e);let c=null,u=null;a!=="void"?(c=r.getNodeType(e),u=i?i.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(c)?u=c:e.isVector(u)?c=u:c!==u&&(c=u="float"):n===">>"||n==="<<"?(c=a,u=e.changeComponentType(u,"uint")):n==="%"?(c=a,u=e.isInteger(c)&&e.isInteger(u)?u:c):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):e.isMatrix(u)||(c=u=a):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):c=u=a:c=u=a):c=u=a;const p=r.build(e,c),y=i?i.build(e,u):null,x=e.getFunctionOperator(n);if(t!=="void"){const S=e.renderer.coordinateSystem===Zc;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return S?e.isVector(c)?e.format(`${this.getOperatorMethod(e,t)}( ${p}, ${y} )`,a,t):e.format(`( ${p} ${n} ${y} )`,a,t):e.format(`( ${p} ${n} ${y} )`,a,t);if(n==="%")return e.isInteger(u)?e.format(`( ${p} % ${y} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${p}, ${y} )`,a,t);if(n==="!"||n==="~")return e.format(`(${n}${p})`,c,t);if(x)return e.format(`${x}( ${p}, ${y} )`,a,t);if(e.isMatrix(c)&&u==="float")return e.format(`( ${y} ${n} ${p} )`,a,t);if(c==="float"&&e.isMatrix(u))return e.format(`${p} ${n} ${y}`,a,t);{let M=`( ${p} ${n} ${y} )`;return!S&&a==="bool"&&e.isVector(c)&&e.isVector(u)&&(M=`all${M}`),e.format(M,a,t)}}else if(c!=="void")return x?e.format(`${x}( ${p}, ${y} )`,a,t):e.isMatrix(c)&&u==="float"?e.format(`${y} ${n} ${p}`,a,t):e.format(`${p} ${n} ${y}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const dc=nn(oo,"+").setParameterLength(2,1/0).setName("add"),oc=nn(oo,"-").setParameterLength(2,1/0).setName("sub"),_i=nn(oo,"*").setParameterLength(2,1/0).setName("mul"),T1=nn(oo,"/").setParameterLength(2,1/0).setName("div"),Jk=nn(oo,"%").setParameterLength(2).setName("mod"),Wye=nn(oo,"==").setParameterLength(2).setName("equal"),fze=nn(oo,"!=").setParameterLength(2).setName("notEqual"),pze=nn(oo,"<").setParameterLength(2).setName("lessThan"),mze=nn(oo,">").setParameterLength(2).setName("greaterThan"),gze=nn(oo,"<=").setParameterLength(2).setName("lessThanEqual"),vze=nn(oo,">=").setParameterLength(2).setName("greaterThanEqual"),yze=nn(oo,"&&").setParameterLength(2,1/0).setName("and"),xze=nn(oo,"||").setParameterLength(2,1/0).setName("or"),_ze=nn(oo,"!").setParameterLength(1).setName("not"),bze=nn(oo,"^^").setParameterLength(2).setName("xor"),Sze=nn(oo,"&").setParameterLength(2).setName("bitAnd"),wze=nn(oo,"~").setParameterLength(2).setName("bitNot"),Eze=nn(oo,"|").setParameterLength(2).setName("bitOr"),Tze=nn(oo,"^").setParameterLength(2).setName("bitXor"),Mze=nn(oo,"<<").setParameterLength(2).setName("shiftLeft"),Cze=nn(oo,">>").setParameterLength(2).setName("shiftRight"),Aze=en(([s])=>(s.addAssign(1),s)),Pze=en(([s])=>(s.subAssign(1),s)),Rze=en(([s])=>{const e=zs(s).toConst();return s.addAssign(1),e}),Ize=en(([s])=>{const e=zs(s).toConst();return s.subAssign(1),e});Lt("add",dc);Lt("sub",oc);Lt("mul",_i);Lt("div",T1);Lt("mod",Jk);Lt("equal",Wye);Lt("notEqual",fze);Lt("lessThan",pze);Lt("greaterThan",mze);Lt("lessThanEqual",gze);Lt("greaterThanEqual",vze);Lt("and",yze);Lt("or",xze);Lt("not",_ze);Lt("xor",bze);Lt("bitAnd",Sze);Lt("bitNot",wze);Lt("bitOr",Eze);Lt("bitXor",Tze);Lt("shiftLeft",Mze);Lt("shiftRight",Cze);Lt("incrementBefore",Aze);Lt("decrementBefore",Pze);Lt("increment",Rze);Lt("decrement",Ize);const kze=(s,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Jk(s,e)),Nze=(s,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Jk(zs(s),zs(e)));Lt("remainder",kze);Lt("modInt",Nze);class ht extends ma{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===ht.MAX||e===ht.MIN)&&arguments.length>3){let i=new ht(e,t,n);for(let a=2;a<arguments.length-1;a++)i=new ht(e,i,arguments[a]);t=i,n=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),c=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>c?t:a>c?n:c>i?r:t}getNodeType(e){const t=this.method;return t===ht.LENGTH||t===ht.DISTANCE||t===ht.DOT?"float":t===ht.CROSS?"vec3":t===ht.ALL||t===ht.ANY?"bool":t===ht.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:r}=this;let i=null;if(r===ht.ONE_MINUS)i=oc(1,t);else if(r===ht.RECIPROCAL)i=T1(1,t);else if(r===ht.DIFFERENCE)i=Qh(oc(t,n));else if(r===ht.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=$r(zt(c),0):a=$r(zt(a),0);const u=_i(a,c).xyz;i=IE(u)}return i!==null?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const i=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,u=this.bNode,p=this.cNode,y=e.renderer.coordinateSystem;if(r===ht.NEGATE)return e.format("( - "+c.build(e,a)+" )",i,t);{const x=[];return r===ht.CROSS?x.push(c.build(e,i),u.build(e,i)):y===Zc&&r===ht.STEP?x.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):y===Zc&&(r===ht.MIN||r===ht.MAX)?x.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):r===ht.REFRACT?x.push(c.build(e,a),u.build(e,a),p.build(e,"float")):r===ht.MIX?x.push(c.build(e,a),u.build(e,a),p.build(e,e.getTypeLength(p.getNodeType(e))===1?"float":a)):(y===X3&&r===ht.ATAN&&u!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===ht.DFDX||r===ht.DFDY)&&(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),x.push(c.build(e,a)),u!==null&&x.push(u.build(e,a)),p!==null&&x.push(p.build(e,a))),e.format(`${e.getMethod(r,i)}( ${x.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}ht.ALL="all";ht.ANY="any";ht.RADIANS="radians";ht.DEGREES="degrees";ht.EXP="exp";ht.EXP2="exp2";ht.LOG="log";ht.LOG2="log2";ht.SQRT="sqrt";ht.INVERSE_SQRT="inversesqrt";ht.FLOOR="floor";ht.CEIL="ceil";ht.NORMALIZE="normalize";ht.FRACT="fract";ht.SIN="sin";ht.COS="cos";ht.TAN="tan";ht.ASIN="asin";ht.ACOS="acos";ht.ATAN="atan";ht.ABS="abs";ht.SIGN="sign";ht.LENGTH="length";ht.NEGATE="negate";ht.ONE_MINUS="oneMinus";ht.DFDX="dFdx";ht.DFDY="dFdy";ht.ROUND="round";ht.RECIPROCAL="reciprocal";ht.TRUNC="trunc";ht.FWIDTH="fwidth";ht.TRANSPOSE="transpose";ht.BITCAST="bitcast";ht.EQUALS="equals";ht.MIN="min";ht.MAX="max";ht.STEP="step";ht.REFLECT="reflect";ht.DISTANCE="distance";ht.DIFFERENCE="difference";ht.DOT="dot";ht.CROSS="cross";ht.POW="pow";ht.TRANSFORM_DIRECTION="transformDirection";ht.MIX="mix";ht.CLAMP="clamp";ht.REFRACT="refract";ht.SMOOTHSTEP="smoothstep";ht.FACEFORWARD="faceforward";const Dze=Ut(1e-6),Oze=Ut(Math.PI),Lze=nn(ht,ht.ALL).setParameterLength(1),Fze=nn(ht,ht.ANY).setParameterLength(1),Bze=nn(ht,ht.RADIANS).setParameterLength(1),Uze=nn(ht,ht.DEGREES).setParameterLength(1),$ye=nn(ht,ht.EXP).setParameterLength(1),RE=nn(ht,ht.EXP2).setParameterLength(1),qye=nn(ht,ht.LOG).setParameterLength(1),jg=nn(ht,ht.LOG2).setParameterLength(1),T$=nn(ht,ht.SQRT).setParameterLength(1),zze=nn(ht,ht.INVERSE_SQRT).setParameterLength(1),_v=nn(ht,ht.FLOOR).setParameterLength(1),M$=nn(ht,ht.CEIL).setParameterLength(1),IE=nn(ht,ht.NORMALIZE).setParameterLength(1),e4=nn(ht,ht.FRACT).setParameterLength(1),If=nn(ht,ht.SIN).setParameterLength(1),D3=nn(ht,ht.COS).setParameterLength(1),Vze=nn(ht,ht.TAN).setParameterLength(1),Gze=nn(ht,ht.ASIN).setParameterLength(1),Xye=nn(ht,ht.ACOS).setParameterLength(1),Yye=nn(ht,ht.ATAN).setParameterLength(1,2),Qh=nn(ht,ht.ABS).setParameterLength(1),Lk=nn(ht,ht.SIGN).setParameterLength(1),Hg=nn(ht,ht.LENGTH).setParameterLength(1),jze=nn(ht,ht.NEGATE).setParameterLength(1),Hze=nn(ht,ht.ONE_MINUS).setParameterLength(1),Kye=nn(ht,ht.DFDX).setParameterLength(1),Zye=nn(ht,ht.DFDY).setParameterLength(1),Wze=nn(ht,ht.ROUND).setParameterLength(1),$ze=nn(ht,ht.RECIPROCAL).setParameterLength(1),qze=nn(ht,ht.TRUNC).setParameterLength(1),Xze=nn(ht,ht.FWIDTH).setParameterLength(1),Yze=nn(ht,ht.TRANSPOSE).setParameterLength(1),Kze=(s,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),Wye(s,e)),qx=nn(ht,ht.MIN).setParameterLength(2,1/0),Sl=nn(ht,ht.MAX).setParameterLength(2,1/0),Qye=nn(ht,ht.STEP).setParameterLength(2),Zze=nn(ht,ht.REFLECT).setParameterLength(2),Qze=nn(ht,ht.DISTANCE).setParameterLength(2),Jze=nn(ht,ht.DIFFERENCE).setParameterLength(2),C$=nn(ht,ht.DOT).setParameterLength(2),Jye=nn(ht,ht.CROSS).setParameterLength(2),eN=nn(ht,ht.POW).setParameterLength(2),e6e=nn(ht,ht.POW,2).setParameterLength(1),eVe=nn(ht,ht.POW,3).setParameterLength(1),tVe=nn(ht,ht.POW,4).setParameterLength(1),nVe=nn(ht,ht.TRANSFORM_DIRECTION).setParameterLength(2),rVe=s=>_i(Lk(s),eN(Qh(s),1/3)),t6e=s=>C$(s,s),Ks=nn(ht,ht.MIX).setParameterLength(3),Xg=(s,e=0,t=1)=>sn(new ht(ht.CLAMP,sn(s),sn(e),sn(t))),n6e=s=>Xg(s),r6e=nn(ht,ht.REFRACT).setParameterLength(3),Y3=nn(ht,ht.SMOOTHSTEP).setParameterLength(3),iVe=nn(ht,ht.FACEFORWARD).setParameterLength(3),sVe=en(([s])=>{const n=43758.5453,r=C$(s.xy,Sn(12.9898,78.233)),i=Jk(r,Oze);return e4(If(i).mul(n))}),oVe=(s,e,t)=>Ks(e,t,s),aVe=(s,e,t)=>Y3(e,t,s),lVe=(s,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Yye(s,e));Lt("all",Lze);Lt("any",Fze);Lt("equals",Kze);Lt("radians",Bze);Lt("degrees",Uze);Lt("exp",$ye);Lt("exp2",RE);Lt("log",qye);Lt("log2",jg);Lt("sqrt",T$);Lt("inverseSqrt",zze);Lt("floor",_v);Lt("ceil",M$);Lt("normalize",IE);Lt("fract",e4);Lt("sin",If);Lt("cos",D3);Lt("tan",Vze);Lt("asin",Gze);Lt("acos",Xye);Lt("atan",Yye);Lt("abs",Qh);Lt("sign",Lk);Lt("length",Hg);Lt("lengthSq",t6e);Lt("negate",jze);Lt("oneMinus",Hze);Lt("dFdx",Kye);Lt("dFdy",Zye);Lt("round",Wze);Lt("reciprocal",$ze);Lt("trunc",qze);Lt("fwidth",Xze);Lt("atan2",lVe);Lt("min",qx);Lt("max",Sl);Lt("step",Qye);Lt("reflect",Zze);Lt("distance",Qze);Lt("dot",C$);Lt("cross",Jye);Lt("pow",eN);Lt("pow2",e6e);Lt("pow3",eVe);Lt("pow4",tVe);Lt("transformDirection",nVe);Lt("mix",oVe);Lt("clamp",Xg);Lt("refract",r6e);Lt("smoothstep",aVe);Lt("faceForward",iVe);Lt("difference",Jze);Lt("saturate",n6e);Lt("cbrt",rVe);Lt("transpose",Yze);Lt("rand",sVe);class cVe extends Xr{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const i=n.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(r))return i}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:i,ifNode:a,elseNode:c}=e.getNodeProperties(this),u=e.currentFunctionNode,p=t!=="void",y=p?Bye(n).build(e):"";r.nodeProperty=y;const x=i.build(e,"bool");e.addFlowCode(`
7940
+ `,S=p.createShader(35633),M=p.createShader(35632),I=p.createProgram();if(!(M&&S&&I))return;p.shaderSource(S,y),p.shaderSource(M,x),p.compileShader(S),p.compileShader(M),p.attachShader(I,S),p.attachShader(I,M),p.linkProgram(I),p.detachShader(I,S),p.detachShader(I,M),p.deleteShader(S),p.deleteShader(M),p.useProgram(I);const L=p.createBuffer();p.bindBuffer(34962,L),p.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const B=p.getAttribLocation(I,"aPosition");p.vertexAttribPointer(B,3,5126,!1,0,0),p.enableVertexAttribArray(B),p.clearColor(1,1,1,1),p.clear(16384),p.viewport(0,0,1,1),p.drawArrays(4,0,3);const A=new Uint8Array(4);return p.readPixels(0,0,1,1,6408,5121,A),p.deleteProgram(I),p.deleteBuffer(L),A.join("")}(s),r="801621810",i="8016218135",a="80162181161",c=m1!=null&&m1.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 u;return n==="80162181255"?u=c.filter(([,,p])=>p>=14):(u=c.filter(([,p])=>p===n),u.length||(u=c)),u.map(([p])=>`apple ${p} gpu`)}let V3e=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}};const JV=[],G3e=[];function bFe(s,e){if(s===e)return 0;const t=s;s.length>e.length&&(s=e,e=t);let n=s.length,r=e.length;for(;n>0&&s.charCodeAt(~-n)===e.charCodeAt(~-r);)n--,r--;let i,a=0;for(;a<n&&s.charCodeAt(a)===e.charCodeAt(a);)a++;if(n-=a,r-=a,n===0)return r;let c,u,p=0,y=0,x=0;for(;y<n;)G3e[y]=s.charCodeAt(a+y),JV[y]=++y;for(;x<r;)for(i=e.charCodeAt(a+x),c=x++,p=x,y=0;y<n;y++)u=i===G3e[y]?c:c+1,c=JV[y],p=JV[y]=c>p?u>p?p+1:u:u>c?c+1:u;return p}function SFe(s){return s!=null}const wFe=({mobileTiers:s=[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"}={})=>QV(void 0,void 0,void 0,function*(){const a={};if(Vve)return{tier:0,type:"SSR"};const{isIpad:c=!!(m1!=null&&m1.isIpad),isMobile:u=!!(m1!=null&&m1.isMobile),screenSize:p=window.screen,loadBenchmarks:y=te=>QV(void 0,void 0,void 0,function*(){const oe=yield fetch(`${i}/${te}`).then(ie=>ie.json());if(parseInt(oe.shift().split(".")[0],10)<4)throw new V3e("Detect GPU benchmark data is out of date. Please update to version 4x");return oe})}=t;let{renderer:x}=t;const S=(te,oe,ie,K,re)=>({device:re,fps:K,gpu:ie,isMobile:u,tier:te,type:oe});let M,I="";if(x)x=z3e(x),M=[x];else{const te=n||function(ie,K=!1){const re={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:K,powerPreference:"high-performance",stencil:!1};ie&&delete re.powerPreference;const se=window.document.createElement("canvas"),q=se.getContext("webgl",re)||se.getContext("experimental-webgl",re);return q??void 0}(m1==null?void 0:m1.isSafari12,r);if(!te)return S(0,"WEBGL_UNSUPPORTED");const oe=m1!=null&&m1.isFirefox?null:te.getExtension("WEBGL_debug_renderer_info");if(x=oe?te.getParameter(oe.UNMASKED_RENDERER_WEBGL):te.getParameter(te.RENDERER),!x)return S(1,"FALLBACK");I=x,x=z3e(x),M=function(ie,K,re){return K==="apple gpu"?_Fe(ie,K,re):[K]}(te,x,u)}const L=(yield Promise.all(M.map(function(te){var oe;return QV(this,void 0,void 0,function*(){const ie=(Bt=>{const ct=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce","adreno"];for(const Pt of ct)if(Bt.includes(Pt))return Pt})(te);if(!ie)return;const K=`${u?"m":"d"}-${ie}${c?"-ipad":""}.json`,re=a[K]=(oe=a[K])!==null&&oe!==void 0?oe:y(K);let se;try{se=yield re}catch(Bt){if(Bt instanceof V3e)throw Bt;return}const q=function(Bt){var ct;const Pt=(Bt=Bt.replace(/\([^)]+\)/,"")).match(/\d+/)||Bt.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return(ct=Pt==null?void 0:Pt.join("").replace(/\W|amd/g,""))!==null&&ct!==void 0?ct:""}(te);let De=se.filter(([,Bt])=>Bt===q);De.length||(De=se.filter(([Bt])=>Bt.includes(te)));const Be=De.length;if(Be===0)return;const tt=te.split(/[.,()\[\]/\s]/g).sort().filter((Bt,ct,Pt)=>ct===0||Bt!==Pt[ct-1]).join(" ");let st,[de,,,,ft]=Be>1?De.map(Bt=>[Bt,bFe(tt,Bt[2])]).sort(([,Bt],[,ct])=>Bt-ct)[0][0]:De[0],Se=Number.MAX_VALUE;const{devicePixelRatio:rt}=window,ut=p.width*rt*p.height*rt;for(const Bt of ft){const[ct,Pt]=Bt,on=ct*Pt,Gt=Math.abs(ut-on);Gt<Se&&(Se=Gt,st=Bt)}if(!st)return;const[,,Pe,vt]=st;return[Se,Pe,de,vt]})}))).filter(SFe).sort(([te=Number.MAX_VALUE,oe],[ie=Number.MAX_VALUE,K])=>te===ie?oe-K:te-ie);if(!L.length){const te=xFe.find(oe=>x.includes(oe));return te?S(0,"BLOCKLISTED",te):S(1,"FALLBACK",`${x} (${I})`)}const[,B,A,V]=L[0];if(B===-1)return S(0,"BLOCKLISTED",A,B,V);const X=u?s:e;let P=0;for(let te=0;te<X.length;te++)B>=X[te]&&(P=te);return S(P,"BENCHMARK",A,B,V)});function EFe(s){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;s(a)}else requestAnimationFrame(n)}requestAnimationFrame(n)}function TFe(s=!1,e=!1){return new Promise(t=>{wFe().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 u=navigator.userAgent.match(/version\/(\d+)/i);r=(u?parseInt(u[1]):0)>=17}const c={dpr:devicePixelRatio,fps:30,width:innerWidth,height:innerHeight,mobile:n.isMobile!==void 0?n.isMobile:!1,supportOffScreenCanvas:r,supportWebGPU:!!navigator.gpu,quality:"Low",dev:s,editor:e};n.tier===3?c.quality="High":n.tier===2&&(c.quality="Medium"),EFe(u=>{c.fps=u,t(c)})})})}class MFe{constructor(){Xe(this,"assets",{audio:new Map,image:new Map,json:new Map,model:new Map,video:new Map});Xe(this,"components",new Map);Xe(this,"settings",{dpr:1,fps:30,width:0,height:0,mobile:!1,supportOffScreenCanvas:!1,supportWebGPU:!1,quality:"Low",dev:!1,editor:!1});Xe(this,"onUpdateCallback");Xe(this,"playing",!1);Xe(this,"rafID",-1);Xe(this,"play",()=>{this.playing||(this.playing=!0,this.onUpdate())});Xe(this,"pause",()=>{this.playing&&(this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1)});Xe(this,"onUpdate",()=>{this.update(),this.isApp&&this.draw(),this.onUpdateCallback&&this.onUpdateCallback(),this.rafID=requestAnimationFrame(this.onUpdate)})}dispose(){this.pause(),this.components.forEach(e=>e.dispose()),this.components.clear()}detectSettings(e=!1,t=!1){return new Promise(n=>{TFe(e,t).then(r=>{this.settings=r,n()})})}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 CFe=I8e();class Gve{constructor(e,t=!1,n=!1){Xe(this,"name");Xe(this,"_debug",!1);Xe(this,"_editor",!1);Xe(this,"broadcastChannel");this.name=e,this._debug=t,this._editor=n,t&&(this.broadcastChannel=new BroadcastChannel(e),this.broadcastChannel.addEventListener("message",this.messageHandler.bind(this)))}dispose(){var e,t;(e=this.broadcastChannel)==null||e.removeEventListener("message",this.messageHandler.bind(this)),(t=this.broadcastChannel)==null||t.close()}get debug(){return this._debug}get editor(){return this._editor}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 jve=()=>{};function vk(s){return s.substring(0,1).toUpperCase()+s.substring(1)}function AFe(s){const e=JSON.stringify(s);return navigator.clipboard.writeText(e),e}function P0(){return Math.round(Math.random()*1e6).toString()}function PFe(s){return s.r!==void 0&&s.g!==void 0&&s.b!==void 0}function j3e(s){const e=Math.round(s.r*255),t=Math.round(s.g*255),n=Math.round(s.b*255),r=u=>{const p=u.toString(16);return p.length===1?"0"+p:p},i=r(e),a=r(t),c=r(n);return"#"+i+a+c}function RFe(s,e,t,n,r){const i=1-s;return i*i*i*e+3*i*i*s*t+3*i*s*s*n+s*s*s*r}function IFe(s,e,t){if(s.type!=="bezier"||s.handles.length!==4)throw new Error("Invalid keyframe data for Bézier interpolation.");const[n,r]=s.handles,i=(t-s.position)/(e.position-s.position);return RFe(i,s.value,s.value+n,e.value+r,e.value)}class kFe extends Gve{constructor(t=!1,n=!1){super("RemoteTheatre",t,n);Xe(this,"project");Xe(this,"sheets",new Map);Xe(this,"sheetObjects",new Map);Xe(this,"sheetObjectCBs",new Map);Xe(this,"sheetObjectUnsubscribe",new Map);Xe(this,"activeSheet");Xe(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=CFe.getProject(t,{state:n}),new Promise((r,i)=>{var a;(a=this.project)==null||a.ready.then(()=>{if(n){const c=n.sheetsById;for(const u in c)this.sheet(u)}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(c=>i(c)),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 c=this.sheet(t,a);if(c===void 0)return;const p=`${this.getSheetInstance(t,a)}_${n}`;let y=this.sheetObjects.get(p),x=r;y!==void 0&&(x={...r,...y.value}),y=c.object(n,x,{reconfigure:!0}),this.sheetObjects.set(p,y),this.sheetObjectCBs.set(p,i!==void 0?i:jve);function S(I,L,B){if(typeof B=="object")if(PFe(B))I[L]={r:B.r,g:B.g,b:B.b,a:B.a};else for(const A in B){const V=B[A];typeof V=="object"&&S(B,A,V)}}const M=y.onValuesChange(I=>{const L=this.sheetObjectCBs.get(p);if(this.editor){for(const B in I){const A=I[B];typeof A=="object"&&S(I,B,A)}this.send({event:"updateSheetObject",target:"app",data:{sheet:t,sheetObject:p,values:I}}),L&&L(I)}else L&&L(I)});return this.sheetObjectUnsubscribe.set(p,M),y}getSheetObjectKeyframes(t,n,r){const i=this.sheet(t);if(i===void 0)return[];const a=`${t}_${n}`,c=this.sheetObjects.get(a);return c===void 0?[]:i.sequence.__experimental_getKeyframes(c.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 c=[],u=r.sequence.__experimental_getKeyframes(a.props.x),p=r.sequence.__experimental_getKeyframes(a.props.y),y=r.sequence.__experimental_getKeyframes(a.props.z),x=new Set;return u.forEach(M=>x.add(M.position)),p.forEach(M=>x.add(M.position)),y.forEach(M=>x.add(M.position)),Array.from(x).sort((M,I)=>M-I).forEach(M=>{const I=(L,B)=>{const A=L.find((P,te)=>{var oe;return P.position<=B&&(((oe=L[te+1])==null?void 0:oe.position)||1/0)>B}),V=L.find(P=>P.position>B);if(!A)return(V==null?void 0:V.value)||0;if(!V||A.position===B)return A.value;if(A.type==="bezier")return IFe(A,V,B);const X=(B-A.position)/(V.position-A.position);return A.value+X*(V.value-A.value)};c.push({position:M,x:I(u,M),y:I(p,M),z:I(y,M)})}),c}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}`,c=this.sheetObjectUnsubscribe.get(a);c!==void 0&&(this.sheetObjects.delete(a),this.sheetObjectCBs.delete(a),this.sheetObjectUnsubscribe.delete(a),c())}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(u=>{u.length<1||u.forEach(p=>{let y=p.address.sheetId,x="setSheet",S={};switch(p.type){case"Theatre_Sheet_PublicAPI":x="setSheet",S={sheet:p.address.sheetId},this.activeSheet=this.sheets.get(p.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":x="setSheetObject",y+=`_${p.address.objectKey}`,S={id:y,sheet:p.address.sheetId,key:p.address.objectKey},this.activeSheet=this.sheets.get(p.address.sheetId);break}this.send({event:x,target:"app",data:S})})});let i=-1;const a=()=>{if(this.activeSheet!==void 0&&i!==this.activeSheet.sequence.position){i=this.activeSheet.sequence.position;const u=this.activeSheet;this.send({event:"updateTimeline",target:"app",data:{position:i,sheet:u.address.sheetId}})}},c=()=>{a(),requestAnimationFrame(c)};a(),c()}else(r=this.studio)==null||r.ui.hide()}}const JW=new rs;JW.setAttribute("position",new Er([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3));JW.setAttribute("normal",new Er([0,0,1,0,0,1],3));JW.setAttribute("uv",new Er([0,0,2,0,0,2],2));new zx(-.5,.5,.5,-.5,0,100);const H3e=s=>{s==null||s.dispose()},Hve=s=>{if(s)if(Array.isArray(s))s.forEach(e=>Hve(e));else{for(const e in s){const t=s[e];t!==null&&t instanceof n0&&H3e(t)}if(s.isShaderMaterial===!0){const e=s;for(const t in e.uniforms){const n=e.uniforms[t];n.value!==null&&n.value instanceof n0&&H3e(n.value)}}s.dispose()}},od=s=>{var e;if(s){for(;s.children.length>0;){const t=s.children[0];t.type==="Audio"?(t.pause(),t.parent&&t.parent.remove(t)):od(t)}if(s.parent&&s.parent.remove(s),s.isMesh){const t=s;(e=t.geometry)==null||e.dispose(),Hve(t.material)}s.dispose!==void 0&&s.dispose()}};let PH=0;const W3e=()=>{PH=0},Vx=s=>{if(!s)return;let e=s.name.replaceAll(" ","").replaceAll("/",".");if(e.length===0&&(e=`obj_${PH}`,PH++),s.parent!==null&&s.parent.uuid.length>0&&(e=`${s.parent.uuid}.${e}`),s.uuid=e,s.isMesh!==void 0){const t=s;if(Array.isArray(t.material))t.material.forEach((n,r)=>{n.uuid=`${e}.material.${r}`});else{const n=t.material;n.uuid=`${e}.material`}}s.children.forEach(t=>Vx(t))};class ml{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(),n=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 r=e.image;if(r!=null&&r.width>0){this.canvas.title=e.sourceFile;const i=this.canvas.width/r.width,a=this.renderToCanvas(e);this.context.drawImage(a,0,0,r.width*i,r.height*i)}}return e.repeat.copy(t),e.offset.copy(n),this.canvas.toDataURL("image/png")}static renderToCanvas(e){if(this.material===null){this.camera=new zx(-.5,.5,.5,-.5,0,100),this.scene=new _E,this.material=new eh;const t=new rs;t.setAttribute("position",new Er([-.5,-.5,0,1.5,-.5,0,-.5,1.5,0],3)),t.setAttribute("normal",new Er([0,0,1,0,0,1],3)),t.setAttribute("uv",new Er([0,0,2,0,0,2],2));const n=new mn(t,this.material);this.scene.add(n)}if(e.isRenderTargetTexture)this.material.map=e,this.renderer.render(this.scene,this.camera);else{const t=this.renderer.outputColorSpace,n=e.colorSpace;this.renderer.outputColorSpace=Ju,e.colorSpace=Ju,this.material.map=e,this.renderer.render(this.scene,this.camera),this.renderer.outputColorSpace=t,e.colorSpace=n}return this.renderer.domElement}}Xe(ml,"renderer"),Xe(ml,"canvas"),Xe(ml,"context",null),Xe(ml,"scene",null),Xe(ml,"camera",null),Xe(ml,"material",null),Xe(ml,"inited",!1),Xe(ml,"width",100),Xe(ml,"height",100);function NFe(s){if(s.name==="cameras")return"camera";if(s.name==="interactive")return"interactive";if(s.name==="lights")return"light";if(s.name==="ui")return"ui";if(s.name==="utils")return"utils";const e=s.type;return e.search("Helper")>-1?"icon_utils":e.search("Camera")>-1?"camera":e.search("Light")>-1?"light":"obj3D"}function rx(s){const e={name:s.name,type:s.type,uuid:s.uuid,children:[]};return s.children.forEach(t=>{e.children.push(rx(t))}),e}function DFe(s){const e={};for(const t in s){const n=s[t].value;e[t]={value:n},n===null?e[t].value={src:"",offset:[0,0],repeat:[1,1]}:n!==void 0&&n.isTexture&&(e[t].value={src:n.image.src,offset:[n.offset.x,n.offset.y],repeat:[n.repeat.x,n.repeat.y]})}return e}function OFe(s){switch(s){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function k7(s){const e={};for(const t in s){if(t.substring(0,1)==="_"||t.substring(0,2)==="is"||OFe(t))continue;const n=typeof s[t],r=s[t];switch(n){case"boolean":case"number":case"string":e[t]=r;break;case"object":r!==null?(e[t]=r,r.isTexture?e[t]={src:ml.renderToBlob(r),offset:[r.offset.x,r.offset.y],repeat:[r.repeat.x,r.repeat.y]}:t==="uniforms"&&(e[t]=DFe(e[t]))):t==="glslVersion"?e[t]="":e[t]={src:"",offset:[0,0],repeat:[1,1]};break}}return s.anisotropy!==void 0&&(e.anisotropy=s.anisotropy),s.clearcoat!==void 0&&(e.clearcoat=s.clearcoat),s.iridescence!==void 0&&(e.iridescence=s.iridescence),s.dispersion!==void 0&&(e.dispersion=s.dispersion),s.sheen!==void 0&&(e.sheen=s.sheen),s.transmission!==void 0&&(e.transmission=s.transmission),s.transmission!==void 0&&(e.transmission=s.transmission),e}function eG(s){s.updateMatrix();const e={name:s.name,type:s.type,uuid:s.uuid,visible:s.visible,matrix:s.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};s.animations.forEach(n=>{e.animations.push({name:n.name,duration:n.duration,blendMode:n.blendMode})});const t=s.type.toLowerCase();if(t.search("mesh")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else if(t.search("points")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else if(t.search("line")>-1){const n=s;if(Array.isArray(n.material)){const r=[];n.material.forEach(i=>{r.push(k7(i))}),e.material=r}else e.material=k7(n.material)}else t.search("camera")>-1?s.type==="PerspectiveCamera"?e.perspectiveCameraInfo={fov:s.fov,zoom:s.zoom,near:s.near,far:s.far,focus:s.focus,aspect:s.aspect,filmGauge:s.filmGauge,filmOffset:s.filmOffset}:s.type==="OrthographicCamera"&&(e.orthographicCameraInfo={zoom:s.zoom,near:s.near,far:s.far,left:s.left,right:s.right,top:s.top,bottom:s.bottom}):t.search("light")>-1&&(e.lightInfo={color:s.color,intensity:s.intensity,decay:s.decay,distance:s.distance,angle:s.angle,penumbra:s.penumbra,groundColor:s.groundColor,width:s.width,height:s.height});return e}function LFe(s,e){const t=e.split(".");switch(t.length){case 1:return s[t[0]];case 2:return s[t[0]][t[1]];case 3:return s[t[0]][t[1]][t[2]];case 4:return s[t[0]][t[1]][t[2]][t[3]];case 5:return s[t[0]][t[1]][t[2]][t[3]][t[4]];case 6:return s[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]}}function FFe(s,e){for(const t in e)s[t]=e[t]}function Ko(s,e,t){if(s===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:s[n[0]]=t;break;case 2:s[n[0]][n[1]]=t;break;case 3:s[n[0]][n[1]][n[2]]=t;break;case 4:s[n[0]][n[1]][n[2]][n[3]]=t;break;case 5:s[n[0]][n[1]][n[2]][n[3]][n[4]]=t;break}else{let a;switch(r){case 1:a=s[n[0]];break;case 2:a=s[n[0]][n[1]];break;case 3:a=s[n[0]][n[1]][n[2]];break;case 4:a=s[n[0]][n[1]][n[2]][n[3]];break;case 5:a=s[n[0]][n[1]][n[2]][n[3]][n[4]];break}a!=null?FFe(a,t):console.log(`Hermes - Can't set props because target isn't found: ${e}`,t)}}function e$(s){return new Promise((e,t)=>{const n=new Image;n.onload=()=>{const r=new n0(n);r.wrapS=Wg,r.wrapT=Wg,r.needsUpdate=!0,e(r)},n.onerror=t,n.src=s})}function rv(s,e,t){return Math.min(e,Math.max(s,t))}function $3e(s,e,t){return(t-s)/(e-s)}function RH(s,e,t){return s*(1-t)+e*t}function Rf(s,e=1){return Number(s.toFixed(e))}var li=(s=>(s.CUSTOM="ToolEvents::custom",s.SELECT_DROPDOWN="ToolEvents::selectDropdown",s.DRAG_UPDATE="ToolEvents::dragUpdate",s.ADD_SCENE="ToolEvents::addScene",s.REFRESH_SCENE="ToolEvents::refreshScene",s.REMOVE_SCENE="ToolEvents::removeScene",s.SET_SCENE="ToolEvents::setScene",s.SET_OBJECT="ToolEvents::setObject",s.CLEAR_OBJECT="ToolEvents::clearObject",s.ADD_CAMERA="ToolEvents::addCamera",s.REMOVE_CAMERA="ToolEvents::removeCamera",s.ADD_GROUP="ToolEvents::addGroup",s.REMOVE_GROUP="ToolEvents::removeGroup",s.ADD_SPLINE="ToolEvents::addSpline",s.ADD_RENDERER="ToolEvents::addRenderer",s.UPDATE_RENDERER="ToolEvents::updateRenderer",s))(li||{});class BFe extends Gve{constructor(t,n=!1,r=!1){super("RemoteThree",n,r);Xe(this,"name");Xe(this,"canvas",null);Xe(this,"inputElement",null);Xe(this,"scene");Xe(this,"scenes",new Map);Xe(this,"renderer");Xe(this,"renderTargets",new Map);Xe(this,"renderTargetsResize",new Map);Xe(this,"groups",new Map);Xe(this,"_listeners",{});this.name=t}dispose(){var t;this.scenes.forEach(n=>{od(n)}),this.scenes.clear(),this.scene&&od(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 c=0,u=a.length;c<u;c++)a[c].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&&(ml.renderer=this.renderer);const n=this.getObjectByUUID(t);n&&this.setObject(n)}setObject(t){this.renderer!==void 0&&(ml.renderer=this.renderer);const n=eG(t);this.dispatchEvent({type:"ToolEvents::setObject",value:n})}requestMethod(t,n,r,i){const a=this.getObjectByUUID(t);if(a)try{i!==void 0?LFe(a,i)[n](r):a[n](r)}catch(c){console.log("Hermes - Error requesting method:",t,n,r),console.log(c)}}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&&Ko(i,n,r)}onCreateTexture(t,n,r){const i=this.getObjectByUUID(t);if(i){const a=c=>{const u=n.split(".");switch(u.length){case 1:i[u[0]]=c;break;case 2:i[u[0]][u[1]]=c;break;case 3:i[u[0]][u[1]][u[2]]=c;break;case 4:i[u[0]][u[1]][u[2]][u[3]]=c;break;case 5:i[u[0]][u[1]][u[2]][u[3]][u[4]]=c;break}i.material.needsUpdate=!0};r.src.length>0?e$(r.src).then(c=>{c.offset.set(r.offset[0],r.offset[1]),c.repeat.set(r.repeat[0],r.repeat[1]),a(c)}):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 Pn).getHexString()}`;this.send({event:"addRenderer",target:"editor",data:{autoClear:t.autoClear,autoClearColor:t.autoClearColor,autoClearDepth:t.autoClearDepth,autoClearStencil:t.autoClearStencil,outputColorSpace:t.outputColorSpace,localClippingEnabled:t.localClippingEnabled,clearColor:r,clearAlpha:t.getClearAlpha(),colorManagement:Gr.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;W3e(),Vx(t);const n=rx(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=rx(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=rx(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&&(ml.renderer=this.renderer),W3e(),Vx(t);const n=rx(t);this.send({event:"setScene",target:"editor",data:n})}requestSize(){this.send({event:"requestSize",target:"app"})}addCamera(t){if(!this.debug)return;const n=eG(t);this.send({event:"addCamera",target:"editor",data:n})}removeCamera(t){if(!this.debug)return;const n=eG(t);this.send({event:"removeCamera",target:"editor",data:n})}handleApp(t){switch(t.event){case"refreshScene":this.send({event:"refreshScene",target:"editor",data:rx(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.localClippingEnabled=t.data.localClippingEnabled,this.renderer.setClearColor(t.data.clearColor,t.data.clearAlpha),this.renderer.toneMapping=t.data.toneMapping,this.renderer.toneMappingExposure=t.data.toneMappingExposure,Gr.enabled=t.data.colorManagement);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){const i=new bl(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,c;const r=this.dpr;this.renderTargets.forEach((u,p)=>{this.renderTargetsResize.get(p)&&u.setSize(t*r,n*r)});const i=!(((a=this.renderer)==null?void 0:a.domElement)instanceof OffscreenCanvas);(c=this.renderer)==null||c.setSize(t,n,i)}set dpr(t){var n;(n=this.renderer)==null||n.setPixelRatio(rv(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}}function UFe(s){const t=s.app.components.get("theatre");return t.studio=k8e,t.handleEditorApp(),null}function zFe(s){return Ke.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[Ke.jsx("div",{className:"header",children:s.header}),s.children,Ke.jsx("div",{className:"footer",children:s.footer})]})}class VFe{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class Lf{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let r=0;r<e.length-1;r++){const i=e[r];n.has(i)===!1&&n.set(i,new WeakMap),n=n.get(i)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}const hl=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let q3e=1234567;const sE=Math.PI/180,Gx=180/Math.PI;function Fg(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(hl[s&255]+hl[s>>8&255]+hl[s>>16&255]+hl[s>>24&255]+"-"+hl[e&255]+hl[e>>8&255]+"-"+hl[e>>16&15|64]+hl[e>>24&255]+"-"+hl[t&63|128]+hl[t>>8&255]+"-"+hl[t>>16&255]+hl[t>>24&255]+hl[n&255]+hl[n>>8&255]+hl[n>>16&255]+hl[n>>24&255]).toLowerCase()}function yi(s,e,t){return Math.max(e,Math.min(t,s))}function t$(s,e){return(s%e+e)%e}function iv(s,e,t,n,r){return n+(s-e)*(r-n)/(t-e)}function GFe(s,e,t){return s!==e?(t-s)/(e-s):0}function V3(s,e,t){return(1-t)*s+t*e}function jFe(s,e,t,n){return V3(s,e,1-Math.exp(-t*n))}function HFe(s,e=1){return e-Math.abs(t$(s,e*2)-e)}function WFe(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function $Fe(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function qFe(s,e){return s+Math.floor(Math.random()*(e-s+1))}function XFe(s,e){return s+Math.random()*(e-s)}function YFe(s){return s*(.5-Math.random())}function KFe(s){s!==void 0&&(q3e=s);let e=q3e+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function yk(s){return s*sE}function Wve(s){return s*Gx}function ZFe(s){return(s&s-1)===0&&s!==0}function QFe(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function JFe(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function eBe(s,e,t,n,r){const i=Math.cos,a=Math.sin,c=i(t/2),u=a(t/2),p=i((e+n)/2),y=a((e+n)/2),x=i((e-n)/2),S=a((e-n)/2),M=i((n-e)/2),I=a((n-e)/2);switch(r){case"XYX":s.set(c*y,u*x,u*S,c*p);break;case"YZY":s.set(u*S,c*y,u*x,c*p);break;case"ZXZ":s.set(u*x,u*S,c*y,c*p);break;case"XZX":s.set(c*y,u*I,u*M,c*p);break;case"YXY":s.set(u*M,c*y,u*I,c*p);break;case"ZYZ":s.set(u*I,u*M,c*y,c*p);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ac(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Qr(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const tBe={DEG2RAD:sE,RAD2DEG:Gx,generateUUID:Fg,clamp:yi,euclideanModulo:t$,mapLinear:iv,inverseLerp:GFe,lerp:V3,damp:jFe,pingpong:HFe,smoothstep:WFe,smootherstep:$Fe,randInt:qFe,randFloat:XFe,randFloatSpread:YFe,seededRandom:KFe,degToRad:yk,radToDeg:Wve,isPowerOfTwo:ZFe,ceilPowerOfTwo:QFe,floorPowerOfTwo:JFe,setQuaternionFromProperEuler:eBe,normalize:Qr,denormalize:ac},$ve="177",nBe=0,rBe=1,iBe=2,sBe=0,oBe=1,YI=3,Bg=0,eu=1,Sx=2,jx=0,Ug=1,xk=2,_k=3,bk=4,oE=5,Nf=100,qve=101,Xve=102,aBe=103,lBe=104,N3=200,Yve=201,Kve=202,Zve=203,Sk=204,wk=205,Qve=206,Jve=207,eye=208,tye=209,nye=210,rye=0,iye=1,sye=2,Ek=3,oye=4,aye=5,lye=6,cye=7,Xk=0,cBe=1,uBe=2,wx=0,hBe=1,dBe=2,fBe=3,pBe=4,mBe=6,gBe=7,n$=300,CE=301,Tk=302,r$=303,i$=304,IH=306,Hx=1e3,z3=1001,Wx=1002,Ca=1003,uye=1004,AE=1005,th=1006,kH=1007,zg=1008,lc=1009,aE=1010,lE=1011,dx=1012,sc=1013,Zo=1014,Zu=1015,td=1016,vBe=1017,yBe=1018,G3=1020,hye=35902,xBe=1021,s$=1022,nd=1023,S1=1026,Vg=1027,o$=1028,a$=1029,yv=1030,l$=1031,_Be=1032,c$=1033,tG=33776,KI=33777,ZI=33778,QI=33779,X3e=35840,Y3e=35841,K3e=35842,Z3e=35843,Q3e=36196,NH=37492,DH=37496,OH=37808,LH=37809,FH=37810,BH=37811,UH=37812,zH=37813,VH=37814,GH=37815,jH=37816,HH=37817,WH=37818,$H=37819,qH=37820,XH=37821,nG=36492,bBe=36283,J3e=36284,e4e=36285,t4e=36286,q3=0,SBe=1,$g="",Yu="srgb",Ex="srgb-linear",Mk="linear",Vr="srgb",wBe=0,sv=7680,EBe=7681,TBe=7682,MBe=7683,CBe=34055,ABe=34056,PBe=5386,RBe=512,IBe=513,kBe=514,NBe=515,DBe=516,OBe=517,LBe=518,YH=519,dye=512,u$=513,fye=514,pye=515,mye=516,gye=517,vye=518,yye=519,Ck=35044,fx=35048,Zc=2e3,X3=2001;class nu{constructor(e,t,n,r,i,a,c,u,p){nu.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,c,u,p)}set(e,t,n,r,i,a,c,u,p){const y=this.elements;return y[0]=e,y[1]=r,y[2]=c,y[3]=t,y[4]=i,y[5]=u,y[6]=n,y[7]=a,y[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],c=n[3],u=n[6],p=n[1],y=n[4],x=n[7],S=n[2],M=n[5],I=n[8],L=r[0],B=r[3],A=r[6],V=r[1],X=r[4],P=r[7],te=r[2],oe=r[5],ie=r[8];return i[0]=a*L+c*V+u*te,i[3]=a*B+c*X+u*oe,i[6]=a*A+c*P+u*ie,i[1]=p*L+y*V+x*te,i[4]=p*B+y*X+x*oe,i[7]=p*A+y*P+x*ie,i[2]=S*L+M*V+I*te,i[5]=S*B+M*X+I*oe,i[8]=S*A+M*P+I*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8];return t*a*y-t*c*p-n*i*y+n*c*u+r*i*p-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8],x=y*a-c*p,S=c*u-y*i,M=p*i-a*u,I=t*x+n*S+r*M;if(I===0)return this.set(0,0,0,0,0,0,0,0,0);const L=1/I;return e[0]=x*L,e[1]=(r*p-y*n)*L,e[2]=(c*n-r*a)*L,e[3]=S*L,e[4]=(y*t-r*u)*L,e[5]=(r*i-c*t)*L,e[6]=M*L,e[7]=(n*u-p*t)*L,e[8]=(a*t-n*i)*L,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,c){const u=Math.cos(i),p=Math.sin(i);return this.set(n*u,n*p,-n*(u*a+p*c)+a+e,-r*p,r*u,-r*(-p*a+u*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(rG.makeScale(e,t)),this}rotate(e){return this.premultiply(rG.makeRotation(-e)),this}translate(e,t){return this.premultiply(rG.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const rG=new nu;function xye(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function KH(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function FBe(){const s=KH("canvas");return s.style.display="block",s}const n4e={};function qg(s){s in n4e||(n4e[s]=!0,console.warn(s))}const r4e=new nu().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),i4e=new nu().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function BBe(){const s={enabled:!0,workingColorSpace:Ex,spaces:{},convert:function(r,i,a){return this.enabled===!1||i===a||!i||!a||(this.spaces[i].transfer===Vr&&(r.r=Gg(r.r),r.g=Gg(r.g),r.b=Gg(r.b)),this.spaces[i].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[i].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Vr&&(r.r=Tx(r.r),r.g=Tx(r.g),r.b=Tx(r.b))),r},workingToColorSpace:function(r,i){return this.convert(r,this.workingColorSpace,i)},colorSpaceToWorking:function(r,i){return this.convert(r,i,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===$g?Mk:this.spaces[r].transfer},getLuminanceCoefficients:function(r,i=this.workingColorSpace){return r.fromArray(this.spaces[i].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,i,a){return r.copy(this.spaces[i].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,i){return qg("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(r,i)},toWorkingColorSpace:function(r,i){return qg("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(r,i)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Ex]:{primaries:e,whitePoint:n,transfer:Mk,toXYZ:r4e,fromXYZ:i4e,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Yu},outputColorSpaceConfig:{drawingBufferColorSpace:Yu}},[Yu]:{primaries:e,whitePoint:n,transfer:Vr,toXYZ:r4e,fromXYZ:i4e,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Yu}}}),s}const Us=BBe();function Gg(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Tx(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}const _ye={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_3={h:0,s:0,l:0},YR={h:0,s:0,l:0};function iG(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Zi{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Yu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Us.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Us.workingColorSpace){return this.r=e,this.g=t,this.b=n,Us.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Us.workingColorSpace){if(e=t$(e,1),t=yi(t,0,1),n=yi(n,0,1),t===0)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,a=2*n-i;this.r=iG(a,i,e+1/3),this.g=iG(a,i,e),this.b=iG(a,i,e-1/3)}return Us.colorSpaceToWorking(this,r),this}setStyle(e,t=Yu){function n(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const a=r[1],c=r[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=r[1],a=i.length;if(a===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Yu){const n=_ye[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Gg(e.r),this.g=Gg(e.g),this.b=Gg(e.b),this}copyLinearToSRGB(e){return this.r=Tx(e.r),this.g=Tx(e.g),this.b=Tx(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yu){return Us.workingToColorSpace(dl.copy(this),e),Math.round(yi(dl.r*255,0,255))*65536+Math.round(yi(dl.g*255,0,255))*256+Math.round(yi(dl.b*255,0,255))}getHexString(e=Yu){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Us.workingColorSpace){Us.workingToColorSpace(dl.copy(this),t);const n=dl.r,r=dl.g,i=dl.b,a=Math.max(n,r,i),c=Math.min(n,r,i);let u,p;const y=(c+a)/2;if(c===a)u=0,p=0;else{const x=a-c;switch(p=y<=.5?x/(a+c):x/(2-a-c),a){case n:u=(r-i)/x+(r<i?6:0);break;case r:u=(i-n)/x+2;break;case i:u=(n-r)/x+4;break}u/=6}return e.h=u,e.s=p,e.l=y,e}getRGB(e,t=Us.workingColorSpace){return Us.workingToColorSpace(dl.copy(this),t),e.r=dl.r,e.g=dl.g,e.b=dl.b,e}getStyle(e=Yu){Us.workingToColorSpace(dl.copy(this),e);const t=dl.r,n=dl.g,r=dl.b;return e!==Yu?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(_3),this.setHSL(_3.h+e,_3.s+t,_3.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_3),e.getHSL(YR);const n=V3(_3.h,YR.h,t),r=V3(_3.s,YR.s,t),i=V3(_3.l,YR.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const dl=new Zi;Zi.NAMES=_ye;class Yk{constructor(e,t,n,r){Yk.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}}class i_{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,c){let u=n[r+0],p=n[r+1],y=n[r+2],x=n[r+3];const S=i[a+0],M=i[a+1],I=i[a+2],L=i[a+3];if(c===0){e[t+0]=u,e[t+1]=p,e[t+2]=y,e[t+3]=x;return}if(c===1){e[t+0]=S,e[t+1]=M,e[t+2]=I,e[t+3]=L;return}if(x!==L||u!==S||p!==M||y!==I){let B=1-c;const A=u*S+p*M+y*I+x*L,V=A>=0?1:-1,X=1-A*A;if(X>Number.EPSILON){const te=Math.sqrt(X),oe=Math.atan2(te,A*V);B=Math.sin(B*oe)/te,c=Math.sin(c*oe)/te}const P=c*V;if(u=u*B+S*P,p=p*B+M*P,y=y*B+I*P,x=x*B+L*P,B===1-c){const te=1/Math.sqrt(u*u+p*p+y*y+x*x);u*=te,p*=te,y*=te,x*=te}}e[t]=u,e[t+1]=p,e[t+2]=y,e[t+3]=x}static multiplyQuaternionsFlat(e,t,n,r,i,a){const c=n[r],u=n[r+1],p=n[r+2],y=n[r+3],x=i[a],S=i[a+1],M=i[a+2],I=i[a+3];return e[t]=c*I+y*x+u*M-p*S,e[t+1]=u*I+y*S+p*x-c*M,e[t+2]=p*I+y*M+c*S-u*x,e[t+3]=y*I-c*x-u*S-p*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,i=e._z,a=e._order,c=Math.cos,u=Math.sin,p=c(n/2),y=c(r/2),x=c(i/2),S=u(n/2),M=u(r/2),I=u(i/2);switch(a){case"XYZ":this._x=S*y*x+p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x-S*M*I;break;case"YXZ":this._x=S*y*x+p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x+S*M*I;break;case"ZXY":this._x=S*y*x-p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x-S*M*I;break;case"ZYX":this._x=S*y*x-p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x+S*M*I;break;case"YZX":this._x=S*y*x+p*M*I,this._y=p*M*x+S*y*I,this._z=p*y*I-S*M*x,this._w=p*y*x-S*M*I;break;case"XZY":this._x=S*y*x-p*M*I,this._y=p*M*x-S*y*I,this._z=p*y*I+S*M*x,this._w=p*y*x+S*M*I;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],c=t[5],u=t[9],p=t[2],y=t[6],x=t[10],S=n+c+x;if(S>0){const M=.5/Math.sqrt(S+1);this._w=.25/M,this._x=(y-u)*M,this._y=(i-p)*M,this._z=(a-r)*M}else if(n>c&&n>x){const M=2*Math.sqrt(1+n-c-x);this._w=(y-u)/M,this._x=.25*M,this._y=(r+a)/M,this._z=(i+p)/M}else if(c>x){const M=2*Math.sqrt(1+c-n-x);this._w=(i-p)/M,this._x=(r+a)/M,this._y=.25*M,this._z=(u+y)/M}else{const M=2*Math.sqrt(1+x-n-c);this._w=(a-r)/M,this._x=(i+p)/M,this._y=(u+y)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yi(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,a=e._w,c=t._x,u=t._y,p=t._z,y=t._w;return this._x=n*y+a*c+r*p-i*u,this._y=r*y+a*u+i*c-n*p,this._z=i*y+a*p+n*u-r*c,this._w=a*y-n*c-r*u-i*p,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,i=this._z,a=this._w;let c=a*e._w+n*e._x+r*e._y+i*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;const u=1-c*c;if(u<=Number.EPSILON){const M=1-t;return this._w=M*a+t*this._w,this._x=M*n+t*this._x,this._y=M*r+t*this._y,this._z=M*i+t*this._z,this.normalize(),this}const p=Math.sqrt(u),y=Math.atan2(p,c),x=Math.sin((1-t)*y)/p,S=Math.sin(t*y)/p;return this._w=a*x+this._w*S,this._x=n*x+this._x*S,this._y=r*x+this._y*S,this._z=i*x+this._z*S,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class pt{constructor(e=0,t=0,n=0){pt.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(s4e.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(s4e.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,c=e.z,u=e.w,p=2*(a*r-c*n),y=2*(c*t-i*r),x=2*(i*n-a*t);return this.x=t+u*p+a*x-c*y,this.y=n+u*y+c*p-i*x,this.z=r+u*x+i*y-a*p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,a=t.x,c=t.y,u=t.z;return this.x=r*u-i*c,this.y=i*a-n*u,this.z=n*c-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sG.copy(this).projectOnVector(e),this.sub(sG)}reflect(e){return this.sub(sG.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const sG=new pt,s4e=new i_;class Is{constructor(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B){Is.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B)}set(e,t,n,r,i,a,c,u,p,y,x,S,M,I,L,B){const A=this.elements;return A[0]=e,A[4]=t,A[8]=n,A[12]=r,A[1]=i,A[5]=a,A[9]=c,A[13]=u,A[2]=p,A[6]=y,A[10]=x,A[14]=S,A[3]=M,A[7]=I,A[11]=L,A[15]=B,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Is().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/N7.setFromMatrixColumn(e,0).length(),i=1/N7.setFromMatrixColumn(e,1).length(),a=1/N7.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),c=Math.sin(n),u=Math.cos(r),p=Math.sin(r),y=Math.cos(i),x=Math.sin(i);if(e.order==="XYZ"){const S=a*y,M=a*x,I=c*y,L=c*x;t[0]=u*y,t[4]=-u*x,t[8]=p,t[1]=M+I*p,t[5]=S-L*p,t[9]=-c*u,t[2]=L-S*p,t[6]=I+M*p,t[10]=a*u}else if(e.order==="YXZ"){const S=u*y,M=u*x,I=p*y,L=p*x;t[0]=S+L*c,t[4]=I*c-M,t[8]=a*p,t[1]=a*x,t[5]=a*y,t[9]=-c,t[2]=M*c-I,t[6]=L+S*c,t[10]=a*u}else if(e.order==="ZXY"){const S=u*y,M=u*x,I=p*y,L=p*x;t[0]=S-L*c,t[4]=-a*x,t[8]=I+M*c,t[1]=M+I*c,t[5]=a*y,t[9]=L-S*c,t[2]=-a*p,t[6]=c,t[10]=a*u}else if(e.order==="ZYX"){const S=a*y,M=a*x,I=c*y,L=c*x;t[0]=u*y,t[4]=I*p-M,t[8]=S*p+L,t[1]=u*x,t[5]=L*p+S,t[9]=M*p-I,t[2]=-p,t[6]=c*u,t[10]=a*u}else if(e.order==="YZX"){const S=a*u,M=a*p,I=c*u,L=c*p;t[0]=u*y,t[4]=L-S*x,t[8]=I*x+M,t[1]=x,t[5]=a*y,t[9]=-c*y,t[2]=-p*y,t[6]=M*x+I,t[10]=S-L*x}else if(e.order==="XZY"){const S=a*u,M=a*p,I=c*u,L=c*p;t[0]=u*y,t[4]=-x,t[8]=p*y,t[1]=S*x+L,t[5]=a*y,t[9]=M*x-I,t[2]=I*x-M,t[6]=c*y,t[10]=L*x+S}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(UBe,e,zBe)}lookAt(e,t,n){const r=this.elements;return ju.subVectors(e,t),ju.lengthSq()===0&&(ju.z=1),ju.normalize(),b3.crossVectors(n,ju),b3.lengthSq()===0&&(Math.abs(n.z)===1?ju.x+=1e-4:ju.z+=1e-4,ju.normalize(),b3.crossVectors(n,ju)),b3.normalize(),KR.crossVectors(ju,b3),r[0]=b3.x,r[4]=KR.x,r[8]=ju.x,r[1]=b3.y,r[5]=KR.y,r[9]=ju.y,r[2]=b3.z,r[6]=KR.z,r[10]=ju.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],c=n[4],u=n[8],p=n[12],y=n[1],x=n[5],S=n[9],M=n[13],I=n[2],L=n[6],B=n[10],A=n[14],V=n[3],X=n[7],P=n[11],te=n[15],oe=r[0],ie=r[4],K=r[8],re=r[12],se=r[1],q=r[5],De=r[9],Be=r[13],tt=r[2],st=r[6],de=r[10],ft=r[14],Se=r[3],rt=r[7],ut=r[11],Pe=r[15];return i[0]=a*oe+c*se+u*tt+p*Se,i[4]=a*ie+c*q+u*st+p*rt,i[8]=a*K+c*De+u*de+p*ut,i[12]=a*re+c*Be+u*ft+p*Pe,i[1]=y*oe+x*se+S*tt+M*Se,i[5]=y*ie+x*q+S*st+M*rt,i[9]=y*K+x*De+S*de+M*ut,i[13]=y*re+x*Be+S*ft+M*Pe,i[2]=I*oe+L*se+B*tt+A*Se,i[6]=I*ie+L*q+B*st+A*rt,i[10]=I*K+L*De+B*de+A*ut,i[14]=I*re+L*Be+B*ft+A*Pe,i[3]=V*oe+X*se+P*tt+te*Se,i[7]=V*ie+X*q+P*st+te*rt,i[11]=V*K+X*De+P*de+te*ut,i[15]=V*re+X*Be+P*ft+te*Pe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],c=e[5],u=e[9],p=e[13],y=e[2],x=e[6],S=e[10],M=e[14],I=e[3],L=e[7],B=e[11],A=e[15];return I*(+i*u*x-r*p*x-i*c*S+n*p*S+r*c*M-n*u*M)+L*(+t*u*M-t*p*S+i*a*S-r*a*M+r*p*y-i*u*y)+B*(+t*p*x-t*c*M-i*a*x+n*a*M+i*c*y-n*p*y)+A*(-r*c*y-t*u*x+t*c*S+r*a*x-n*a*S+n*u*y)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],c=e[5],u=e[6],p=e[7],y=e[8],x=e[9],S=e[10],M=e[11],I=e[12],L=e[13],B=e[14],A=e[15],V=x*B*p-L*S*p+L*u*M-c*B*M-x*u*A+c*S*A,X=I*S*p-y*B*p-I*u*M+a*B*M+y*u*A-a*S*A,P=y*L*p-I*x*p+I*c*M-a*L*M-y*c*A+a*x*A,te=I*x*u-y*L*u-I*c*S+a*L*S+y*c*B-a*x*B,oe=t*V+n*X+r*P+i*te;if(oe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const ie=1/oe;return e[0]=V*ie,e[1]=(L*S*i-x*B*i-L*r*M+n*B*M+x*r*A-n*S*A)*ie,e[2]=(c*B*i-L*u*i+L*r*p-n*B*p-c*r*A+n*u*A)*ie,e[3]=(x*u*i-c*S*i-x*r*p+n*S*p+c*r*M-n*u*M)*ie,e[4]=X*ie,e[5]=(y*B*i-I*S*i+I*r*M-t*B*M-y*r*A+t*S*A)*ie,e[6]=(I*u*i-a*B*i-I*r*p+t*B*p+a*r*A-t*u*A)*ie,e[7]=(a*S*i-y*u*i+y*r*p-t*S*p-a*r*M+t*u*M)*ie,e[8]=P*ie,e[9]=(I*x*i-y*L*i-I*n*M+t*L*M+y*n*A-t*x*A)*ie,e[10]=(a*L*i-I*c*i+I*n*p-t*L*p-a*n*A+t*c*A)*ie,e[11]=(y*c*i-a*x*i-y*n*p+t*x*p+a*n*M-t*c*M)*ie,e[12]=te*ie,e[13]=(y*L*r-I*x*r+I*n*S-t*L*S-y*n*B+t*x*B)*ie,e[14]=(I*c*r-a*L*r-I*n*u+t*L*u+a*n*B-t*c*B)*ie,e[15]=(a*x*r-y*c*r+y*n*u-t*x*u-a*n*S+t*c*S)*ie,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,c=e.y,u=e.z,p=i*a,y=i*c;return this.set(p*a+n,p*c-r*u,p*u+r*c,0,p*c+r*u,y*c+n,y*u-r*a,0,p*u-r*c,y*u+r*a,i*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,a=t._y,c=t._z,u=t._w,p=i+i,y=a+a,x=c+c,S=i*p,M=i*y,I=i*x,L=a*y,B=a*x,A=c*x,V=u*p,X=u*y,P=u*x,te=n.x,oe=n.y,ie=n.z;return r[0]=(1-(L+A))*te,r[1]=(M+P)*te,r[2]=(I-X)*te,r[3]=0,r[4]=(M-P)*oe,r[5]=(1-(S+A))*oe,r[6]=(B+V)*oe,r[7]=0,r[8]=(I+X)*ie,r[9]=(B-V)*ie,r[10]=(1-(S+L))*ie,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=N7.set(r[0],r[1],r[2]).length();const a=N7.set(r[4],r[5],r[6]).length(),c=N7.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],bf.copy(this);const p=1/i,y=1/a,x=1/c;return bf.elements[0]*=p,bf.elements[1]*=p,bf.elements[2]*=p,bf.elements[4]*=y,bf.elements[5]*=y,bf.elements[6]*=y,bf.elements[8]*=x,bf.elements[9]*=x,bf.elements[10]*=x,t.setFromRotationMatrix(bf),n.x=i,n.y=a,n.z=c,this}makePerspective(e,t,n,r,i,a,c=Zc){const u=this.elements,p=2*i/(t-e),y=2*i/(n-r),x=(t+e)/(t-e),S=(n+r)/(n-r);let M,I;if(c===Zc)M=-(a+i)/(a-i),I=-2*a*i/(a-i);else if(c===X3)M=-a/(a-i),I=-a*i/(a-i);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return u[0]=p,u[4]=0,u[8]=x,u[12]=0,u[1]=0,u[5]=y,u[9]=S,u[13]=0,u[2]=0,u[6]=0,u[10]=M,u[14]=I,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,i,a,c=Zc){const u=this.elements,p=1/(t-e),y=1/(n-r),x=1/(a-i),S=(t+e)*p,M=(n+r)*y;let I,L;if(c===Zc)I=(a+i)*x,L=-2*x;else if(c===X3)I=i*x,L=-1*x;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return u[0]=2*p,u[4]=0,u[8]=0,u[12]=-S,u[1]=0,u[5]=2*y,u[9]=0,u[13]=-M,u[2]=0,u[6]=0,u[10]=L,u[14]=-I,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const N7=new pt,bf=new Is,UBe=new pt(0,0,0),zBe=new pt(1,1,1),b3=new pt,KR=new pt,ju=new pt;class ci{constructor(e=0,t=0){ci.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ri{constructor(e=0,t=0,n=0,r=1){Ri.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const u=e.elements,p=u[0],y=u[4],x=u[8],S=u[1],M=u[5],I=u[9],L=u[2],B=u[6],A=u[10];if(Math.abs(y-S)<.01&&Math.abs(x-L)<.01&&Math.abs(I-B)<.01){if(Math.abs(y+S)<.1&&Math.abs(x+L)<.1&&Math.abs(I+B)<.1&&Math.abs(p+M+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const X=(p+1)/2,P=(M+1)/2,te=(A+1)/2,oe=(y+S)/4,ie=(x+L)/4,K=(I+B)/4;return X>P&&X>te?X<.01?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(X),r=oe/n,i=ie/n):P>te?P<.01?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(P),n=oe/r,i=K/r):te<.01?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(te),n=ie/i,r=K/i),this.set(n,r,i,t),this}let V=Math.sqrt((B-I)*(B-I)+(x-L)*(x-L)+(S-y)*(S-y));return Math.abs(V)<.001&&(V=1),this.x=(B-I)/V,this.y=(x-L)/V,this.z=(S-y)/V,this.w=Math.acos((p+M+A-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this.w=yi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this.w=yi(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}function PE(s,e=0){let t=3735928559^e,n=1103547991^e;if(s instanceof Array)for(let r=0,i;r<s.length;r++)i=s[r],t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677);else for(let r=0,i;r<s.length;r++)i=s.charCodeAt(r),t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const VBe=s=>PE(s),h$=s=>PE(s),Ak=(...s)=>PE(s);function bye(s,e=!1){const t=[];s.isNode===!0&&(t.push(s.id),s=s.getSelf());for(const{property:n,childNode:r}of Pk(s))t.push(PE(n.slice(0,-4)),r.getCacheKey(e));return PE(t)}function*Pk(s,e=!1){for(const t in s){if(t.startsWith("_")===!0)continue;const n=s[t];if(Array.isArray(n)===!0)for(let r=0;r<n.length;r++){const i=n[r];i&&(i.isNode===!0||e&&typeof i.toJSON=="function")&&(yield{property:t,index:r,childNode:i})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(typeof n=="object")for(const r in n){const i=n[r];i&&(i.isNode===!0||e&&typeof i.toJSON=="function")&&(yield{property:t,index:r,childNode:i})}}}const GBe=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),o4e=new WeakMap;function jBe(s){return GBe.get(s)}function Rk(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix2===!0?"mat2":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function Sye(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new Zi(...e):t==="vec2"?new ci(...e):t==="vec3"?new pt(...e):t==="vec4"?new Ri(...e):t==="mat2"?new Yk(...e):t==="mat3"?new nu(...e):t==="mat4"?new Is(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?WBe(e[0]):null}function wye(s){let e=o4e.get(s);return e===void 0&&(e={},o4e.set(s,e)),e}function HBe(s){let e="";const t=new Uint8Array(s);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function WBe(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}let $Be=0;function qBe(s){const e=Object.keys(s);let t=Object.getPrototypeOf(s);for(;t;){const n=Object.getOwnPropertyDescriptors(t);for(const r in n)if(n[r]!==void 0){const i=n[r];i&&typeof i.get=="function"&&e.push(r)}t=Object.getPrototypeOf(t)}return e}class XBe{constructor(e,t,n,r,i,a,c,u,p,y){this.id=$Be++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=c,this.lightsNode=u,this.context=p,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=y,this.clippingContextCacheKey=y!==null?y.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const i of e){const a=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(a===void 0)continue;n.push(a);const c=a.isInterleavedBufferAttribute?a.data:a;r.add(c)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),c=this.getIndex(),u=c!==null;let p=1;if(n.isInstancedBufferGeometry===!0?p=n.instanceCount:e.count!==void 0&&(p=Math.max(0,e.count)),p===0)return null;if(a.instanceCount=p,e.isBatchedMesh===!0)return a;let y=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(y=2);let x=i.start*y,S=(i.start+i.count)*y;r!==null&&(x=Math.max(x,r.start*y),S=Math.min(S,(r.start+r.count)*y));const M=n.attributes.position;let I=1/0;u?I=c.count:M!=null&&(I=M.count),x=Math.max(x,0),S=Math.min(S,I);const L=S-x;return L<0||L===1/0?null:(a.vertexCount=L,a.firstVertex=x,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[n];t+="morph-"+n+",";for(let i=0,a=r.length;i<a;i++){const c=r[i];t+=c.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of qBe(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const i=t[r];let a;if(i!==null){const c=typeof i;c==="number"?a=i!==0?"1":"0":c==="object"?(a="{",i.isTexture&&(a+=i.mapping),a+="}"):a=String(i)}else a=String(i);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",VBe(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ak(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ak(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const H8=[];class YBe{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,c,u){const p=this.getChainMap(u);H8[0]=e,H8[1]=t,H8[2]=a,H8[3]=i;let y=p.get(H8);return y===void 0?(y=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,c,u),p.set(H8,y)):(y.updateClipping(c),y.needsGeometryUpdate&&y.setGeometry(e.geometry),(y.version!==t.version||y.needsUpdate)&&(y.initialCacheKey!==y.getCacheKey()?(y.dispose(),y=this.get(e,t,n,r,i,a,c,u)):y.version=t.version)),H8.length=0,y}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Lf)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,c,u,p,y,x){const S=this.getChainMap(x),M=new XBe(e,t,n,r,i,a,c,u,p,y);return M.onDispose=()=>{this.pipelines.delete(M),this.bindings.delete(M),this.nodes.delete(M),S.delete(M.getChainArray())},M}}class J3{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const rd={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},F3=16,KBe=211,ZBe=212;class QBe extends J3{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===rd.VERTEX?this.backend.createAttribute(e):t===rd.INDEX?this.backend.createIndexAttribute(e):t===rd.STORAGE?this.backend.createStorageAttribute(e):t===rd.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version<r.version||r.usage===fx)&&(this.backend.updateAttribute(e),n.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const Ng=JBe();function JBe(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const p=u-127;p<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):p<-14?(n[u]=1024>>-p-14,n[u|256]=1024>>-p-14|32768,r[u]=-p-1,r[u|256]=-p-1):p<=15?(n[u]=p+15<<10,n[u|256]=p+15<<10|32768,r[u]=13,r[u|256]=13):p<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const i=new Uint32Array(2048),a=new Uint32Array(64),c=new Uint32Array(64);for(let u=1;u<1024;++u){let p=u<<13,y=0;for(;(p&8388608)===0;)p<<=1,y-=8388608;p&=-8388609,y+=947912704,i[u]=p|y}for(let u=1024;u<2048;++u)i[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(c[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:i,exponentTable:a,offsetTable:c}}function Hu(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=yi(s,-65504,65504),Ng.floatView[0]=s;const e=Ng.uint32View[0],t=e>>23&511;return Ng.baseTable[t]+((e&8388607)>>Ng.shiftTable[t])}function ZR(s){const e=s>>10;return Ng.uint32View[0]=Ng.mantissaTable[Ng.offsetTable[e]+(s&1023)]+Ng.exponentTable[e],Ng.floatView[0]}const la=new pt,QR=new ci;let eUe=0;class id{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eUe++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ck,this.updateRanges=[],this.gpuType=Zu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)QR.fromBufferAttribute(this,t),QR.applyMatrix3(e),this.setXY(t,QR.x,QR.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyMatrix3(e),this.setXYZ(t,la.x,la.y,la.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyMatrix4(e),this.setXYZ(t,la.x,la.y,la.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.applyNormalMatrix(e),this.setXYZ(t,la.x,la.y,la.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)la.fromBufferAttribute(this,t),la.transformDirection(e),this.setXYZ(t,la.x,la.y,la.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ac(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ac(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ac(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ac(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ac(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array),i=Qr(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ck&&(e.usage=this.usage),e}}class Eye extends id{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Tye extends id{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mye extends id{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=ZR(this.array[e*this.itemSize]);return this.normalized&&(t=ac(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize]=Hu(t),this}getY(e){let t=ZR(this.array[e*this.itemSize+1]);return this.normalized&&(t=ac(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+1]=Hu(t),this}getZ(e){let t=ZR(this.array[e*this.itemSize+2]);return this.normalized&&(t=ac(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+2]=Hu(t),this}getW(e){let t=ZR(this.array[e*this.itemSize+3]);return this.normalized&&(t=ac(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qr(t,this.array)),this.array[e*this.itemSize+3]=Hu(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this.array[e+2]=Hu(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Qr(t,this.array),n=Qr(n,this.array),r=Qr(r,this.array),i=Qr(i,this.array)),this.array[e+0]=Hu(t),this.array[e+1]=Hu(n),this.array[e+2]=Hu(r),this.array[e+3]=Hu(i),this}}class uc extends id{constructor(e,t,n){super(new Float32Array(e),t,n)}}function Cye(s){return s.index!==null?s.index.version:s.attributes.position.version}function a4e(s){const e=[],t=s.index,n=s.attributes.position;if(t!==null){const i=t.array;for(let a=0,c=i.length;a<c;a+=3){const u=i[a+0],p=i[a+1],y=i[a+2];e.push(u,p,p,y,y,u)}}else{const i=n.array;for(let a=0,c=i.length/3-1;a<c;a+=3){const u=a+0,p=a+1,y=a+2;e.push(u,p,p,y,y,u)}}const r=new(xye(e)?Tye:Eye)(e,1);return r.version=Cye(s),r}class tUe extends J3{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const i=t.index,a=e.getAttributes();i!==null&&this.attributes.delete(i);for(const u of a)this.attributes.delete(u);const c=this.wireframes.get(t);c!==void 0&&this.attributes.delete(c),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const i of t)i.isStorageBufferAttribute||i.isStorageInstancedBufferAttribute?this.updateAttribute(i,rd.STORAGE):this.updateAttribute(i,rd.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,rd.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,rd.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const i=this.wireframes;let a=i.get(t);a===void 0?(a=a4e(t),i.set(t,a)):a.version!==Cye(t)&&(this.attributes.delete(a),a=a4e(t),i.set(t,a)),r=a}return r}}class nUe{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class Aye{constructor(e){this.cacheKey=e,this.usedTimes=0}}class rUe extends Aye{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class iUe extends Aye{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let sUe=0;class oG{constructor(e,t,n,r=null,i=null){this.id=sUe++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}}class oUe extends J3{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let c=this.programs.compute.get(a.computeShader);c===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),c=new oG(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,c),n.createProgram(c));const u=this._getComputeCacheKey(e,c);let p=this.caches.get(u);p===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),p=this._getComputePipeline(e,c,u,t)),p.usedTimes++,c.usedTimes++,r.version=e.version,r.pipeline=p}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),c=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),u=new oG(a.vertexShader,"vertex",c),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let p=this.programs.fragment.get(a.fragmentShader);p===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),p=new oG(a.fragmentShader,"fragment",c),this.programs.fragment.set(a.fragmentShader,p),n.createProgram(p));const y=this._getRenderCacheKey(e,u,p);let x=this.caches.get(y);x===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),x=this._getRenderPipeline(e,u,p,y,t)):e.pipeline=x,x.usedTimes++,u.usedTimes++,p.usedTimes++,r.pipeline=x}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new iUe(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new rUe(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class aUe extends J3{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?rd.INDIRECT:rd.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,i=!0,a=0,c=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isStorageBuffer){const p=u.attribute,y=p.isIndirectStorageBufferAttribute?rd.INDIRECT:rd.STORAGE;this.attributes.update(p,y)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const p=this.textures.get(u.texture);u.needsBindingsUpdate(p.generation)&&(r=!0);const y=u.update(),x=u.texture;y&&this.textures.updateTexture(x);const S=n.get(x);if(S.externalTexture!==void 0||p.isDefaultTexture?i=!1:(a=a*10+x.id,c+=x.version),n.isWebGPUBackend===!0&&S.texture===void 0&&S.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,y,x,u.textureNode.value,r),this.textures.updateTexture(x),r=!0),x.isStorageTexture===!0){const M=this.get(x);u.store===!0?M.needsMipmap=!0:this.textures.needsMipmaps(x)&&M.needsMipmap===!0&&(this.backend.generateMipmaps(x),M.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,i?a:0,c)}}function lUe(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?s.z-e.z:s.id-e.id}function l4e(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function c4e(s){return(s.transmission>0||s.transmissionNode)&&s.side===Sx&&s.forceSinglePass===!1}class cUe{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,c){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:c},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=i,u.group=a,u.clippingContext=c),this.renderItemsIndex++,u}push(e,t,n,r,i,a,c){const u=this.getNextRenderItem(e,t,n,r,i,a,c);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(c4e(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,i,a,c){const u=this.getNextRenderItem(e,t,n,r,i,a,c);n.transparent===!0||n.transmission>0?(c4e(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||lUe),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||l4e),this.transparent.length>1&&this.transparent.sort(t||l4e)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const n=this.renderItems[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.groupOrder=null,n.renderOrder=null,n.z=null,n.group=null,n.clippingContext=null}}}const mw=[];class uUe{constructor(e){this.lighting=e,this.lists=new Lf}get(e,t){const n=this.lists;mw[0]=e,mw[1]=t;let r=n.get(mw);return r===void 0&&(r=new cUe(this.lighting,e,t),n.set(mw,r)),mw.length=0,r}dispose(){this.lists=new Lf}}let hUe=0;class dUe{constructor(){this.id=hUe++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ri,this.scissor=!1,this.scissorValue=new Ri,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return Pye(this)}}function Pye(s){const{textures:e,activeCubeFace:t}=s,n=[t];for(const r of e)n.push(r.id);return h$(n)}let Av=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let i=0,a=r.length;i<a;i++)r[i].call(this,e);e.target=null}}};const u4e=new Is,h4e=new i_;class ad{constructor(e=0,t=0,n=0,r=ad.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],a=r[4],c=r[8],u=r[1],p=r[5],y=r[9],x=r[2],S=r[6],M=r[10];switch(t){case"XYZ":this._y=Math.asin(yi(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-y,M),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(S,p),this._z=0);break;case"YXZ":this._x=Math.asin(-yi(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(c,M),this._z=Math.atan2(u,p)):(this._y=Math.atan2(-x,i),this._z=0);break;case"ZXY":this._x=Math.asin(yi(S,-1,1)),Math.abs(S)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-a,p)):(this._y=0,this._z=Math.atan2(u,i));break;case"ZYX":this._y=Math.asin(-yi(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(S,M),this._z=Math.atan2(u,i)):(this._x=0,this._z=Math.atan2(-a,p));break;case"YZX":this._z=Math.asin(yi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-y,p),this._y=Math.atan2(-x,i)):(this._x=0,this._y=Math.atan2(c,M));break;case"XZY":this._z=Math.asin(-yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(S,p),this._y=Math.atan2(c,i)):(this._x=Math.atan2(-y,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return u4e.makeRotationFromQuaternion(e),this.setFromRotationMatrix(u4e,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return h4e.setFromEuler(this),this.setFromQuaternion(h4e,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ad.DEFAULT_ORDER="XYZ";class fUe{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let pUe=0;const d4e=new pt,D7=new i_,Eg=new Is,JR=new pt,gw=new pt,mUe=new pt,gUe=new i_,f4e=new pt(1,0,0),p4e=new pt(0,1,0),m4e=new pt(0,0,1),g4e={type:"added"},vUe={type:"removed"},O7={type:"childadded",child:null},aG={type:"childremoved",child:null};class Aa extends Av{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:pUe++}),this.uuid=Fg(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Aa.DEFAULT_UP.clone();const e=new pt,t=new ad,n=new i_,r=new pt(1,1,1);function i(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(i),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Is},normalMatrix:{value:new nu}}),this.matrix=new Is,this.matrixWorld=new Is,this.matrixAutoUpdate=Aa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fUe,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return D7.setFromAxisAngle(e,t),this.quaternion.multiply(D7),this}rotateOnWorldAxis(e,t){return D7.setFromAxisAngle(e,t),this.quaternion.premultiply(D7),this}rotateX(e){return this.rotateOnAxis(f4e,e)}rotateY(e){return this.rotateOnAxis(p4e,e)}rotateZ(e){return this.rotateOnAxis(m4e,e)}translateOnAxis(e,t){return d4e.copy(e).applyQuaternion(this.quaternion),this.position.add(d4e.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(f4e,e)}translateY(e){return this.translateOnAxis(p4e,e)}translateZ(e){return this.translateOnAxis(m4e,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Eg.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?JR.copy(e):JR.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),gw.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Eg.lookAt(gw,JR,this.up):Eg.lookAt(JR,gw,this.up),this.quaternion.setFromRotationMatrix(Eg),r&&(Eg.extractRotation(r.matrixWorld),D7.setFromRotationMatrix(Eg),this.quaternion.premultiply(D7.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(g4e),O7.child=e,this.dispatchEvent(O7),O7.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(vUe),aG.child=e,this.dispatchEvent(aG),aG.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Eg.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Eg.multiply(e.parent.matrixWorld)),e.applyMatrix4(Eg),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(g4e),O7.child=e,this.dispatchEvent(O7),O7.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gw,e,mUe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gw,gUe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>({...c})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let p=0,y=u.length;p<y;p++){const x=u[p];i(e.shapes,x)}else i(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,p=this.material.length;u<p;u++)c.push(i(e.materials,this.material[u]));r.material=c}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];r.animations.push(i(e.animations,u))}}if(t){const c=a(e.geometries),u=a(e.materials),p=a(e.textures),y=a(e.images),x=a(e.shapes),S=a(e.skeletons),M=a(e.animations),I=a(e.nodes);c.length>0&&(n.geometries=c),u.length>0&&(n.materials=u),p.length>0&&(n.textures=p),y.length>0&&(n.images=y),x.length>0&&(n.shapes=x),S.length>0&&(n.skeletons=S),M.length>0&&(n.animations=M),I.length>0&&(n.nodes=I)}return n.object=r,n;function a(c){const u=[];for(const p in c){const y=c[p];delete y.metadata,u.push(y)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Aa.DEFAULT_UP=new pt(0,1,0);Aa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class d$ extends Aa{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ad,this.environmentIntensity=1,this.environmentRotation=new ad,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class f$ extends Aa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Is,this.projectionMatrix=new Is,this.projectionMatrixInverse=new Is,this.coordinateSystem=Zc}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const vw=[],yUe=new d$,xUe=new f$;class _Ue{constructor(){this.chainMaps={}}get(e,t,n=null){vw[0]=e,vw[1]=t;let r;if(n===null)r="default";else{const c=n.texture.format;r=`${n.textures.length}:${c}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const i=this._getChainMap(r);let a=i.get(vw);return a===void 0&&(a=new dUe,i.set(vw,a)),vw.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(yUe,xUe,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Lf)}dispose(){this.chainMaps={}}}let L7;class bUe{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{L7===void 0&&(L7=KH("canvas")),L7.width=e.width,L7.height=e.height;const r=L7.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=L7}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=KH("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let a=0;a<i.length;a++)i[a]=Gg(i[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Gg(t[n]/255)*255):t[n]=Gg(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let SUe=0;class p${constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:SUe++}),this.uuid=Fg(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let i;if(Array.isArray(r)){i=[];for(let a=0,c=r.length;a<c;a++)r[a].isDataTexture?i.push(lG(r[a].image)):i.push(lG(r[a]))}else i=lG(r);n.url=i}return t||(e.images[this.uuid]=n),n}}function lG(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?bUe.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let wUe=0;const cG=new pt;class _l extends Av{constructor(e=_l.DEFAULT_IMAGE,t=_l.DEFAULT_MAPPING,n=z3,r=z3,i=th,a=zg,c=nd,u=lc,p=_l.DEFAULT_ANISOTROPY,y=$g){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wUe++}),this.uuid=Fg(),this.name="",this.source=new p$(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=p,this.format=c,this.internalFormat=null,this.type=u,this.offset=new ci(0,0),this.repeat=new ci(1,1),this.center=new ci(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new nu,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=y,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(cG).x}get height(){return this.source.getSize(cG).y}get depth(){return this.source.getSize(cG).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==n$)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Hx:e.x=e.x-Math.floor(e.x);break;case z3:e.x=e.x<0?0:1;break;case Wx:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Hx:e.y=e.y-Math.floor(e.y);break;case z3:e.y=e.y<0?0:1;break;case Wx:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}_l.DEFAULT_IMAGE=null;_l.DEFAULT_MAPPING=n$;_l.DEFAULT_ANISOTROPY=1;class w1 extends _l{constructor(e,t,n=Zo,r,i,a,c=Ca,u=Ca,p,y=S1,x=1){if(y!==S1&&y!==Vg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const S={width:e,height:t,depth:x};super(S,r,i,a,c,u,y,n,p),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new p$(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const EUe=new pt;class TUe extends J3{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||(n.depthTextureMips={}),a=e.textures,c=this.getSize(a[0]),u=c.width>>t,p=c.height>>t;let y=e.depthTexture||i[t];const x=e.depthBuffer===!0||e.stencilBuffer===!0;let S=!1;y===void 0&&x&&(y=new w1,y.format=e.stencilBuffer?Vg:S1,y.type=e.stencilBuffer?G3:Zo,y.image.width=u,y.image.height=p,y.image.depth=c.depth,y.isArrayTexture=e.multiview===!0&&c.depth>1,i[t]=y),(n.width!==c.width||c.height!==n.height)&&(S=!0,y&&(y.needsUpdate=!0,y.image.width=u,y.image.height=p,y.image.depth=y.isArrayTexture?y.image.depth:1)),n.width=c.width,n.height=c.height,n.textures=a,n.depthTexture=y||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(S=!0,y&&(y.needsUpdate=!0),n.sampleCount=r);const M={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let I=0;I<a.length;I++){const L=a[I];S&&(L.needsUpdate=!0),this.updateTexture(L,M)}y&&this.updateTexture(y,M)}if(n.initialized!==!0){n.initialized=!0;const I=()=>{e.removeEventListener("dispose",I);for(let L=0;L<a.length;L++)this._destroyTexture(a[L]);y&&this._destroyTexture(y),this.delete(e)};e.addEventListener("dispose",I)}}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&(i.destroySampler(e),i.destroyTexture(e)),e.isFramebufferTexture){const p=this.renderer.getRenderTarget();p?e.type=p.texture.type:e.type=lc}const{width:a,height:c,depth:u}=this.getSize(e);if(t.width=a,t.height=c,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,c):1,r||e.isStorageTexture===!0)i.createSampler(e),i.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&i.createSampler(e),e.version>0){const y=e.image;if(y===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(y.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const x=[];for(const S of e.images)x.push(S);t.images=x}else t.image=y;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const p=()=>{e.removeEventListener("dispose",p),this._destroyTexture(e)};e.addEventListener("dispose",p)}n.version=e.version}getSize(e,t=EUe){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.isCompressedTexture===!0||e.generateMipmaps}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class m$ extends Zi{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}const eI={VERTEX:"vertex"},pi={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Og={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},MUe=["fragment","vertex"],v4e=["setup","analyze","generate"],y4e=[...MUe,"compute"],s_=["x","y","z","w"],CUe={analyze:"setup",generate:"analyze"};let AUe=0,Xr=class extends Av{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=pi.NONE,this.updateBeforeType=pi.NONE,this.updateAfterType=pi.NONE,this.uuid=tBe.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:AUe++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,pi.FRAME)}onRenderUpdate(e){return this.onUpdate(e,pi.RENDER)}onObjectUpdate(e){return this.onUpdate(e,pi.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Pk(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Ak(bye(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(n===1){const r=e.getNodeProperties(this);for(const i of Object.values(r))i&&i.isNode===!0&&i.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const i=CUe[e.buildStage];if(i&&r.buildStages[i]!==!0){const u=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(u)}e.addNode(this),e.addChain(this);let a=null;const c=e.getBuildStage();if(c==="setup"){this.updateReference(e);const u=e.getNodeProperties(this);if(u.initialized!==!0){u.initialized=!0,u.outputNode=this.setup(e)||u.outputNode||null;for(const p of Object.values(u))if(p&&p.isNode===!0){if(p.parents===!0){const y=e.getNodeProperties(p);y.parents=y.parents||[],y.parents.push(this)}p.build(e)}}a=u.outputNode}else if(c==="analyze")this.analyze(e,t);else if(c==="generate")if(this.generate.length===1){const p=this.getNodeType(e),y=e.getDataFromNode(this);a=y.snippet,a===void 0?y.generated===void 0?(y.generated=!0,a=this.generate(e)||"",y.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):y.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,p,t)}else a=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Pk(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:i,childNode:a}of t)i!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const i in e.inputNodes[n]){const a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(c){const u=[];for(const p in c){const y=c[p];delete y.metadata,u.push(y)}return u}if(r){const c=a(e.textures),u=a(e.images),p=a(e.nodes);c.length>0&&(i.textures=c),u.length>0&&(i.images=u),p.length>0&&(i.nodes=p)}return i}};class ma extends Xr{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(i.propertyName!==void 0)return e.format(i.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),c=e.getVarFromNode(this,null,r),u=e.getPropertyName(c);return e.addLineFlowCode(`${u} = ${a}`,this),i.snippet=a,i.propertyName=u,e.format(i.propertyName,r,t)}}return super.build(e,t)}}class UE extends Xr{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class Rye extends Xr{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}}class PUe extends ma{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),c=[];let u=0;for(const y of i){if(u>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let x=y.getNodeType(e),S=e.getTypeLength(x),M;u+S>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),S=r-u,x=e.getTypeFromLength(S)),u+=S,M=y.build(e,x);const I=e.getComponentType(x);I!==a&&(M=e.format(M,I,a)),c.push(M)}const p=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(p,n,t)}}const RUe=s_.join("");class x4e extends Xr{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(s_.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===RUe.slice(0,this.components.length)?i=e.format(u,a,t):i=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class IUe extends ma{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),c=e.getTypeFromLength(n.length,a),u=r.build(e,c),p=t.build(e,i),y=e.getTypeLength(i),x=[];for(let S=0;S<y;S++){const M=s_[S];M===n[0]?(x.push(u),S+=n.length-1):x.push(p+"."+M)}return`${e.getType(i)}( ${x.join(", ")} )`}}class kUe extends ma{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),c=e.getPropertyName(a);e.addLineFlowCode(c+" = "+i,this);const u=e.getTypeLength(r),p=[];let y=0;for(let x=0;x<u;x++){const S=s_[x];S===t[y]?(p.push("1.0 - "+(c+"."+S)),y++):p.push(c+"."+S)}return`${e.getType(r)}( ${p.join(", ")} )`}}class g$ extends Xr{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Rk(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Rk(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=HBe(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Sye(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const _4e=/float|u?int/;class Kg extends g${static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return _4e.test(n)&&_4e.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class NUe extends Xr{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let $x=null;const px=new Map;function Lt(s,e){if(px.has(s)){console.warn(`THREE.TSL: Redefinition of method chaining '${s}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${s} is not a function`);px.set(s,e)}const Iye=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),b4e=s=>Iye(s).split("").sort().join(""),kye={setup(s,e){const t=e.shift();return s(Qk(t),...e)},get(s,e,t){if(typeof e=="string"&&s[e]===void 0){if(s.isStackNode!==!0&&e==="assign")return(...n)=>($x.assign(t,...n),t);if(px.has(e)){const n=px.get(e);return s.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return s;if(e.endsWith("Assign")&&px.has(e.slice(0,e.length-6))){const n=px.get(e.slice(0,e.length-6));return s.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Iye(e),sn(new x4e(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=b4e(e.slice(3).toLowerCase()),n=>sn(new IUe(s,e,sn(n)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=b4e(e.slice(4).toLowerCase()),()=>sn(new kUe(sn(s),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),sn(new x4e(s,e));if(/^\d+$/.test(e)===!0)return sn(new UE(t,new Kg(Number(e),"uint")));if(/^get$/.test(e)===!0)return n=>sn(new NUe(t,n))}}}return Reflect.get(s,e,t)},set(s,e,t,n){return typeof e=="string"&&s[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(s,e,t,n)}},uG=new WeakMap,S4e=new WeakMap,DUe=function(s,e=null){const t=Rk(s);if(t==="node"){let n=uG.get(s);return n===void 0&&(n=new Proxy(s,kye),uG.set(s,n),uG.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return sn(ZH(s,e));if(t==="shader")return en(s)}return s},OUe=function(s,e=null){for(const t in s)s[t]=sn(s[t],e);return s},LUe=function(s,e=null){const t=s.length;for(let n=0;n<t;n++)s[n]=sn(s[n],e);return s},FUe=function(s,e=null,t=null,n=null){const r=y=>sn(n!==null?Object.assign(y,n):y);let i,a=e,c,u;function p(y){let x;return a?x=/[a-z]/i.test(a)?a+"()":a:x=s.type,c!==void 0&&y.length<c?(console.error(`THREE.TSL: "${x}" parameter length is less than minimum required.`),y.concat(new Array(c-y.length).fill(0))):u!==void 0&&y.length>u?(console.error(`THREE.TSL: "${x}" parameter length exceeds limit.`),y.slice(0,u)):y}return e===null?i=(...y)=>r(new s(...Mx(p(y)))):t!==null?(t=sn(t),i=(...y)=>r(new s(e,...Mx(p(y)),t))):i=(...y)=>r(new s(e,...Mx(p(y)))),i.setParameterLength=(...y)=>(y.length===1?c=u=y[0]:y.length===2&&([c,u]=y),i),i.setName=y=>(a=y,i),i},BUe=function(s,...e){return sn(new s(...Mx(e)))};class UUe extends Xr{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(r[i])return r[i];let a=null;if(t.layout){let c=S4e.get(e.constructor);c===void 0&&(c=new WeakMap,S4e.set(e.constructor,c));let u=c.get(t);u===void 0&&(u=sn(e.buildFunctionNode(t)),c.set(t,u)),e.addInclude(u),a=sn(u.call(n))}else{const c=t.jsFunc,u=n!==null||c.length>1?c(n||[],e):c(e);a=sn(u)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null;const r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),c=this.getOutputNode(e);if(r==="setup"){const u=e.getNamespace("initialized");i[u]!==!0&&(i[u]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r==="analyze"?c.build(e,t):r==="generate"&&(n=c.build(e,t)||"");return n}}class zUe extends Xr{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Qk(e),sn(new UUe(this,e))}setup(){return this.call()}}const VUe=[!1,!0],GUe=[0,1,2,3],jUe=[-1,-2],Nye=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],v$=new Map;for(const s of VUe)v$.set(s,new Kg(s));const y$=new Map;for(const s of GUe)y$.set(s,new Kg(s,"uint"));const x$=new Map([...y$].map(s=>new Kg(s.value,"int")));for(const s of jUe)x$.set(s,new Kg(s,"int"));const Kk=new Map([...x$].map(s=>new Kg(s.value)));for(const s of Nye)Kk.set(s,new Kg(s));for(const s of Nye)Kk.set(-s,new Kg(-s));const Zk={bool:v$,uint:y$,ints:x$,float:Kk},w4e=new Map([...v$,...Kk]),ZH=(s,e)=>w4e.has(s)?w4e.get(s):s.isNode===!0?s:new Kg(s,e),HUe=s=>{try{return s.getNodeType()}catch{return}},ga=function(s,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(r=>typeof r!="object"))&&(t=[Sye(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return sn(e.get(t[0]));if(t.length===1){const r=ZH(t[0],s);return HUe(r)===s?sn(r):sn(new Rye(r,s))}const n=t.map(r=>ZH(r));return sn(new PUe(n,s))}},E4e=s=>typeof s=="object"&&s!==null?s.value:s,WUe=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function Xw(s,e){return new Proxy(new zUe(s,e),kye)}const sn=(s,e=null)=>DUe(s,e),Qk=(s,e=null)=>new OUe(s,e),Mx=(s,e=null)=>new LUe(s,e),nn=(...s)=>new FUe(...s),xn=(...s)=>new BUe(...s);let $Ue=0;const en=(s,e=null)=>{let t=null;e!==null&&(typeof e=="object"?t=e.return:(typeof e=="string"?t=e:console.error("THREE.TSL: Invalid layout type."),e=null));const n=new Xw(s,t),r=(...i)=>{let a;Qk(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?a=[...i]:a=i[0];const u=n.call(a);return t==="void"&&u.toStack(),u};if(r.shaderNode=n,r.id=n.id,r.getNodeType=(...i)=>n.getNodeType(...i),r.getCacheKey=(...i)=>n.getCacheKey(...i),r.setLayout=i=>(n.setLayout(i),r),r.once=(i=null)=>(n.once=!0,n.namespace=i,r),e!==null){if(typeof e.inputs!="object"){const i={name:"fn"+$Ue++,type:t,inputs:[]};for(const a in e)a!=="return"&&i.inputs.push({name:a,type:e[a]});e=i}r.setLayout(e)}return r},Ik=s=>{$x=s},Dye=()=>$x,Jo=(...s)=>$x.If(...s);function Oye(s){return $x&&$x.add(s),s}Lt("toStack",Oye);const qUe=new ga("color"),Ut=new ga("float",Zk.float),zs=new ga("int",Zk.ints),XUe=new ga("uint",Zk.uint),_$=new ga("bool",Zk.bool),Sn=new ga("vec2"),Ig=new ga("ivec2"),YUe=new ga("uvec2"),KUe=new ga("bvec2"),zt=new ga("vec3"),ZUe=new ga("ivec3"),QUe=new ga("uvec3"),JUe=new ga("bvec3"),$r=new ga("vec4"),eze=new ga("ivec4"),tze=new ga("uvec4"),nze=new ga("bvec4"),b$=new ga("mat2"),hc=new ga("mat3"),Cx=new ga("mat4");Lt("toColor",qUe);Lt("toFloat",Ut);Lt("toInt",zs);Lt("toUint",XUe);Lt("toBool",_$);Lt("toVec2",Sn);Lt("toIVec2",Ig);Lt("toUVec2",YUe);Lt("toBVec2",KUe);Lt("toVec3",zt);Lt("toIVec3",ZUe);Lt("toUVec3",QUe);Lt("toBVec3",JUe);Lt("toVec4",$r);Lt("toIVec4",eze);Lt("toUVec4",tze);Lt("toBVec4",nze);Lt("toMat2",b$);Lt("toMat3",hc);Lt("toMat4",Cx);const rze=nn(UE).setParameterLength(2),ize=(s,e)=>sn(new Rye(sn(s),e));Lt("element",rze);Lt("convert",ize);Lt("append",s=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),Oye(s)));class sze extends ma{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return s_.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),c=n.build(e),u=r.build(e,a),p=r.getNodeType(e),y=e.getDataFromNode(this);let x;if(y.initialized===!0)t!=="void"&&(x=c);else if(i){const S=e.getVarFromNode(this,null,a),M=e.getPropertyName(S);e.addLineFlowCode(`${M} = ${u}`,this);const I=n.node,B=I.node.context({assign:!0}).build(e);for(let A=0;A<I.components.length;A++){const V=I.components[A];e.addLineFlowCode(`${B}.${V} = ${M}[ ${A} ]`,this)}t!=="void"&&(x=c)}else x=`${c} = ${u}`,(t==="void"||p==="void")&&(e.addLineFlowCode(x,this),t!=="void"&&(x=c));return y.initialized=!0,e.format(x,a,t)}}const oze=nn(sze).setParameterLength(2);Lt("assign",oze);class T4e extends ma{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const aze=(...s)=>{let e;if(s.length===1){const t=s[0];e=new T4e(null,t.length,t)}else{const t=s[0],n=s[1];e=new T4e(t,n)}return sn(e)};Lt("toArray",(s,e)=>aze(Array(e).fill(s)));class Lye extends Xr{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lze=s=>new Lye(s),S$=(s,e=0)=>new Lye(s,!0,e),cze=S$("frame"),kr=S$("render"),Fye=lze("object");class zE extends g${static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Fye}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const i=e(r,n);i!==void 0&&(this.value=i)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);const a=i.getInputType(e),c=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(c);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const Nr=(s,e)=>{const t=WUe(e||s),n=s&&s.isNode===!0?s.node&&s.node.value||s.value:s;return sn(new zE(n,t))};class cs extends Xr{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Bye=(s,e)=>sn(new cs(s,e)),kk=(s,e)=>sn(new cs(s,e,!0)),Ki=xn(cs,"vec4","DiffuseColor"),M4e=xn(cs,"vec3","EmissiveColor"),Dg=xn(cs,"float","Roughness"),Nk=xn(cs,"float","Metalness"),QH=xn(cs,"float","Clearcoat"),Dk=xn(cs,"float","ClearcoatRoughness"),mx=xn(cs,"vec3","Sheen"),w$=xn(cs,"float","SheenRoughness"),E$=xn(cs,"float","Iridescence"),Uye=xn(cs,"float","IridescenceIOR"),zye=xn(cs,"float","IridescenceThickness"),JH=xn(cs,"float","AlphaT"),ov=xn(cs,"float","Anisotropy"),JI=xn(cs,"vec3","AnisotropyT"),Ax=xn(cs,"vec3","AnisotropyB"),qu=xn(cs,"color","SpecularColor"),Ok=xn(cs,"float","SpecularF90"),eW=xn(cs,"float","Shininess"),cE=xn(cs,"vec4","Output"),hG=xn(cs,"float","dashSize"),C4e=xn(cs,"float","gapSize"),ek=xn(cs,"float","IOR"),tW=xn(cs,"float","Transmission"),Vye=xn(cs,"float","Thickness"),Gye=xn(cs,"float","AttenuationDistance"),jye=xn(cs,"color","AttenuationColor"),Hye=xn(cs,"float","Dispersion");class uze extends ma{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(u,p)=>{const y=p.type,x=y==="pointer";let S;return x?S="&"+u.build(e):S=u.build(e,y),S};if(Array.isArray(i)){if(i.length>r.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=r.length;else if(i.length<r.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<r.length;)i.push(Ut(0));for(let u=0;u<i.length;u++)t.push(a(i[u],r[u]))}else for(const u of r){const p=i[u.name];p!==void 0?t.push(a(p,u)):(console.error(`THREE.TSL: Input '${u.name}' not found in 'Fn()'.`),t.push(a(Ut(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const hze=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Mx(e):Qk(e[0]),sn(new uze(sn(s),e)));Lt("call",hze);const dze={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class oo extends ma{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let i=new oo(e,t,n);for(let a=0;a<r.length-1;a++)i=new oo(e,i,r[a]);t=i,n=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(dze[this.op],t)}getNodeType(e){const t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i==="void"||a==="void")return"void";if(t==="%")return i;if(t==="~"||t==="&"||t==="|"||t==="^"||t===">>"||t==="<<")return e.getIntegerType(i);if(t==="!"||t==="&&"||t==="||"||t==="^^")return"bool";if(t==="=="||t==="!="||t==="<"||t===">"||t==="<="||t===">="){const c=Math.max(e.getTypeLength(i),e.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else{if(e.isMatrix(i)){if(a==="float")return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i==="float")return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){const n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e);let c=null,u=null;a!=="void"?(c=r.getNodeType(e),u=i?i.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(c)?u=c:e.isVector(u)?c=u:c!==u&&(c=u="float"):n===">>"||n==="<<"?(c=a,u=e.changeComponentType(u,"uint")):n==="%"?(c=a,u=e.isInteger(c)&&e.isInteger(u)?u:c):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):e.isMatrix(u)||(c=u=a):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):c=u=a:c=u=a):c=u=a;const p=r.build(e,c),y=i?i.build(e,u):null,x=e.getFunctionOperator(n);if(t!=="void"){const S=e.renderer.coordinateSystem===Zc;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return S?e.isVector(c)?e.format(`${this.getOperatorMethod(e,t)}( ${p}, ${y} )`,a,t):e.format(`( ${p} ${n} ${y} )`,a,t):e.format(`( ${p} ${n} ${y} )`,a,t);if(n==="%")return e.isInteger(u)?e.format(`( ${p} % ${y} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${p}, ${y} )`,a,t);if(n==="!"||n==="~")return e.format(`(${n}${p})`,c,t);if(x)return e.format(`${x}( ${p}, ${y} )`,a,t);if(e.isMatrix(c)&&u==="float")return e.format(`( ${y} ${n} ${p} )`,a,t);if(c==="float"&&e.isMatrix(u))return e.format(`${p} ${n} ${y}`,a,t);{let M=`( ${p} ${n} ${y} )`;return!S&&a==="bool"&&e.isVector(c)&&e.isVector(u)&&(M=`all${M}`),e.format(M,a,t)}}else if(c!=="void")return x?e.format(`${x}( ${p}, ${y} )`,a,t):e.isMatrix(c)&&u==="float"?e.format(`${y} ${n} ${p}`,a,t):e.format(`${p} ${n} ${y}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const dc=nn(oo,"+").setParameterLength(2,1/0).setName("add"),oc=nn(oo,"-").setParameterLength(2,1/0).setName("sub"),_i=nn(oo,"*").setParameterLength(2,1/0).setName("mul"),T1=nn(oo,"/").setParameterLength(2,1/0).setName("div"),Jk=nn(oo,"%").setParameterLength(2).setName("mod"),Wye=nn(oo,"==").setParameterLength(2).setName("equal"),fze=nn(oo,"!=").setParameterLength(2).setName("notEqual"),pze=nn(oo,"<").setParameterLength(2).setName("lessThan"),mze=nn(oo,">").setParameterLength(2).setName("greaterThan"),gze=nn(oo,"<=").setParameterLength(2).setName("lessThanEqual"),vze=nn(oo,">=").setParameterLength(2).setName("greaterThanEqual"),yze=nn(oo,"&&").setParameterLength(2,1/0).setName("and"),xze=nn(oo,"||").setParameterLength(2,1/0).setName("or"),_ze=nn(oo,"!").setParameterLength(1).setName("not"),bze=nn(oo,"^^").setParameterLength(2).setName("xor"),Sze=nn(oo,"&").setParameterLength(2).setName("bitAnd"),wze=nn(oo,"~").setParameterLength(2).setName("bitNot"),Eze=nn(oo,"|").setParameterLength(2).setName("bitOr"),Tze=nn(oo,"^").setParameterLength(2).setName("bitXor"),Mze=nn(oo,"<<").setParameterLength(2).setName("shiftLeft"),Cze=nn(oo,">>").setParameterLength(2).setName("shiftRight"),Aze=en(([s])=>(s.addAssign(1),s)),Pze=en(([s])=>(s.subAssign(1),s)),Rze=en(([s])=>{const e=zs(s).toConst();return s.addAssign(1),e}),Ize=en(([s])=>{const e=zs(s).toConst();return s.subAssign(1),e});Lt("add",dc);Lt("sub",oc);Lt("mul",_i);Lt("div",T1);Lt("mod",Jk);Lt("equal",Wye);Lt("notEqual",fze);Lt("lessThan",pze);Lt("greaterThan",mze);Lt("lessThanEqual",gze);Lt("greaterThanEqual",vze);Lt("and",yze);Lt("or",xze);Lt("not",_ze);Lt("xor",bze);Lt("bitAnd",Sze);Lt("bitNot",wze);Lt("bitOr",Eze);Lt("bitXor",Tze);Lt("shiftLeft",Mze);Lt("shiftRight",Cze);Lt("incrementBefore",Aze);Lt("decrementBefore",Pze);Lt("increment",Rze);Lt("decrement",Ize);const kze=(s,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Jk(s,e)),Nze=(s,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Jk(zs(s),zs(e)));Lt("remainder",kze);Lt("modInt",Nze);class ht extends ma{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===ht.MAX||e===ht.MIN)&&arguments.length>3){let i=new ht(e,t,n);for(let a=2;a<arguments.length-1;a++)i=new ht(e,i,arguments[a]);t=i,n=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),c=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>c?t:a>c?n:c>i?r:t}getNodeType(e){const t=this.method;return t===ht.LENGTH||t===ht.DISTANCE||t===ht.DOT?"float":t===ht.CROSS?"vec3":t===ht.ALL||t===ht.ANY?"bool":t===ht.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:r}=this;let i=null;if(r===ht.ONE_MINUS)i=oc(1,t);else if(r===ht.RECIPROCAL)i=T1(1,t);else if(r===ht.DIFFERENCE)i=Qh(oc(t,n));else if(r===ht.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=$r(zt(c),0):a=$r(zt(a),0);const u=_i(a,c).xyz;i=IE(u)}return i!==null?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const i=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,u=this.bNode,p=this.cNode,y=e.renderer.coordinateSystem;if(r===ht.NEGATE)return e.format("( - "+c.build(e,a)+" )",i,t);{const x=[];return r===ht.CROSS?x.push(c.build(e,i),u.build(e,i)):y===Zc&&r===ht.STEP?x.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):y===Zc&&(r===ht.MIN||r===ht.MAX)?x.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):r===ht.REFRACT?x.push(c.build(e,a),u.build(e,a),p.build(e,"float")):r===ht.MIX?x.push(c.build(e,a),u.build(e,a),p.build(e,e.getTypeLength(p.getNodeType(e))===1?"float":a)):(y===X3&&r===ht.ATAN&&u!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===ht.DFDX||r===ht.DFDY)&&(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),x.push(c.build(e,a)),u!==null&&x.push(u.build(e,a)),p!==null&&x.push(p.build(e,a))),e.format(`${e.getMethod(r,i)}( ${x.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}ht.ALL="all";ht.ANY="any";ht.RADIANS="radians";ht.DEGREES="degrees";ht.EXP="exp";ht.EXP2="exp2";ht.LOG="log";ht.LOG2="log2";ht.SQRT="sqrt";ht.INVERSE_SQRT="inversesqrt";ht.FLOOR="floor";ht.CEIL="ceil";ht.NORMALIZE="normalize";ht.FRACT="fract";ht.SIN="sin";ht.COS="cos";ht.TAN="tan";ht.ASIN="asin";ht.ACOS="acos";ht.ATAN="atan";ht.ABS="abs";ht.SIGN="sign";ht.LENGTH="length";ht.NEGATE="negate";ht.ONE_MINUS="oneMinus";ht.DFDX="dFdx";ht.DFDY="dFdy";ht.ROUND="round";ht.RECIPROCAL="reciprocal";ht.TRUNC="trunc";ht.FWIDTH="fwidth";ht.TRANSPOSE="transpose";ht.BITCAST="bitcast";ht.EQUALS="equals";ht.MIN="min";ht.MAX="max";ht.STEP="step";ht.REFLECT="reflect";ht.DISTANCE="distance";ht.DIFFERENCE="difference";ht.DOT="dot";ht.CROSS="cross";ht.POW="pow";ht.TRANSFORM_DIRECTION="transformDirection";ht.MIX="mix";ht.CLAMP="clamp";ht.REFRACT="refract";ht.SMOOTHSTEP="smoothstep";ht.FACEFORWARD="faceforward";const Dze=Ut(1e-6),Oze=Ut(Math.PI),Lze=nn(ht,ht.ALL).setParameterLength(1),Fze=nn(ht,ht.ANY).setParameterLength(1),Bze=nn(ht,ht.RADIANS).setParameterLength(1),Uze=nn(ht,ht.DEGREES).setParameterLength(1),$ye=nn(ht,ht.EXP).setParameterLength(1),RE=nn(ht,ht.EXP2).setParameterLength(1),qye=nn(ht,ht.LOG).setParameterLength(1),jg=nn(ht,ht.LOG2).setParameterLength(1),T$=nn(ht,ht.SQRT).setParameterLength(1),zze=nn(ht,ht.INVERSE_SQRT).setParameterLength(1),_v=nn(ht,ht.FLOOR).setParameterLength(1),M$=nn(ht,ht.CEIL).setParameterLength(1),IE=nn(ht,ht.NORMALIZE).setParameterLength(1),e4=nn(ht,ht.FRACT).setParameterLength(1),If=nn(ht,ht.SIN).setParameterLength(1),D3=nn(ht,ht.COS).setParameterLength(1),Vze=nn(ht,ht.TAN).setParameterLength(1),Gze=nn(ht,ht.ASIN).setParameterLength(1),Xye=nn(ht,ht.ACOS).setParameterLength(1),Yye=nn(ht,ht.ATAN).setParameterLength(1,2),Qh=nn(ht,ht.ABS).setParameterLength(1),Lk=nn(ht,ht.SIGN).setParameterLength(1),Hg=nn(ht,ht.LENGTH).setParameterLength(1),jze=nn(ht,ht.NEGATE).setParameterLength(1),Hze=nn(ht,ht.ONE_MINUS).setParameterLength(1),Kye=nn(ht,ht.DFDX).setParameterLength(1),Zye=nn(ht,ht.DFDY).setParameterLength(1),Wze=nn(ht,ht.ROUND).setParameterLength(1),$ze=nn(ht,ht.RECIPROCAL).setParameterLength(1),qze=nn(ht,ht.TRUNC).setParameterLength(1),Xze=nn(ht,ht.FWIDTH).setParameterLength(1),Yze=nn(ht,ht.TRANSPOSE).setParameterLength(1),Kze=(s,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),Wye(s,e)),qx=nn(ht,ht.MIN).setParameterLength(2,1/0),Sl=nn(ht,ht.MAX).setParameterLength(2,1/0),Qye=nn(ht,ht.STEP).setParameterLength(2),Zze=nn(ht,ht.REFLECT).setParameterLength(2),Qze=nn(ht,ht.DISTANCE).setParameterLength(2),Jze=nn(ht,ht.DIFFERENCE).setParameterLength(2),C$=nn(ht,ht.DOT).setParameterLength(2),Jye=nn(ht,ht.CROSS).setParameterLength(2),eN=nn(ht,ht.POW).setParameterLength(2),e6e=nn(ht,ht.POW,2).setParameterLength(1),eVe=nn(ht,ht.POW,3).setParameterLength(1),tVe=nn(ht,ht.POW,4).setParameterLength(1),nVe=nn(ht,ht.TRANSFORM_DIRECTION).setParameterLength(2),rVe=s=>_i(Lk(s),eN(Qh(s),1/3)),t6e=s=>C$(s,s),Ks=nn(ht,ht.MIX).setParameterLength(3),Xg=(s,e=0,t=1)=>sn(new ht(ht.CLAMP,sn(s),sn(e),sn(t))),n6e=s=>Xg(s),r6e=nn(ht,ht.REFRACT).setParameterLength(3),Y3=nn(ht,ht.SMOOTHSTEP).setParameterLength(3),iVe=nn(ht,ht.FACEFORWARD).setParameterLength(3),sVe=en(([s])=>{const n=43758.5453,r=C$(s.xy,Sn(12.9898,78.233)),i=Jk(r,Oze);return e4(If(i).mul(n))}),oVe=(s,e,t)=>Ks(e,t,s),aVe=(s,e,t)=>Y3(e,t,s),lVe=(s,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Yye(s,e));Lt("all",Lze);Lt("any",Fze);Lt("equals",Kze);Lt("radians",Bze);Lt("degrees",Uze);Lt("exp",$ye);Lt("exp2",RE);Lt("log",qye);Lt("log2",jg);Lt("sqrt",T$);Lt("inverseSqrt",zze);Lt("floor",_v);Lt("ceil",M$);Lt("normalize",IE);Lt("fract",e4);Lt("sin",If);Lt("cos",D3);Lt("tan",Vze);Lt("asin",Gze);Lt("acos",Xye);Lt("atan",Yye);Lt("abs",Qh);Lt("sign",Lk);Lt("length",Hg);Lt("lengthSq",t6e);Lt("negate",jze);Lt("oneMinus",Hze);Lt("dFdx",Kye);Lt("dFdy",Zye);Lt("round",Wze);Lt("reciprocal",$ze);Lt("trunc",qze);Lt("fwidth",Xze);Lt("atan2",lVe);Lt("min",qx);Lt("max",Sl);Lt("step",Qye);Lt("reflect",Zze);Lt("distance",Qze);Lt("dot",C$);Lt("cross",Jye);Lt("pow",eN);Lt("pow2",e6e);Lt("pow3",eVe);Lt("pow4",tVe);Lt("transformDirection",nVe);Lt("mix",oVe);Lt("clamp",Xg);Lt("refract",r6e);Lt("smoothstep",aVe);Lt("faceForward",iVe);Lt("difference",Jze);Lt("saturate",n6e);Lt("cbrt",rVe);Lt("transpose",Yze);Lt("rand",sVe);class cVe extends Xr{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const i=n.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(r))return i}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:i,ifNode:a,elseNode:c}=e.getNodeProperties(this),u=e.currentFunctionNode,p=t!=="void",y=p?Bye(n).build(e):"";r.nodeProperty=y;const x=i.build(e,"bool");e.addFlowCode(`
7941
7941
  ${e.tab}if ( ${x} ) {
7942
7942
 
7943
7943
  `).addFlowTab();let S=a.build(e,n);if(S&&(p?S=y+" = "+S+";":(S="return "+S+";",u===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),S="// "+S))),e.removeFlowTab().addFlowCode(e.tab+" "+S+`