@needle-tools/engine 3.37.5-alpha → 3.37.6-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/needle-engine.js +45 -29
- package/dist/needle-engine.light.js +232 -216
- package/dist/needle-engine.light.min.js +5 -5
- package/dist/needle-engine.light.umd.cjs +113 -113
- package/dist/needle-engine.min.js +5 -5
- package/dist/needle-engine.umd.cjs +5 -5
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -0
- package/lib/engine/extensions/NEEDLE_progressive.js +7 -1
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +31 -3
- package/lib/engine-components/DropListener.js +30 -2
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +5 -3
- package/lib/engine-components/VideoPlayer.js +26 -14
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.js +8 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/extensions/NEEDLE_progressive.ts +9 -1
- package/src/engine-components/DropListener.ts +30 -2
- package/src/engine-components/VideoPlayer.ts +25 -13
- package/src/engine-components/webxr/WebARCameraBackground.ts +9 -0
|
@@ -4340,7 +4340,7 @@ void main() {
|
|
|
4340
4340
|
}`),n(ws,"blipMaterial"),n(ws,"mesh");function Jx(t){return ws.copyTexture(t)}function W9(t,A=!1){return ws.textureToCanvas(t,A)}function Z9(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&t instanceof ImageBitmap}let ow=!1;H5((...t)=>{var A;re()&&(A=et.Current)!=null&&A.isInXR&&(IE(!0),vx("error",...t))});function IE(t){if(t){if(ow)return;ow=!0,z9()}else{if(!ow)return;ow=!1,X9()}}const zc={log:void 0,warn:void 0,error:void 0};class V9{constructor(){n(this,"familyName","needle-xr"),n(this,"root",null),n(this,"context",null),n(this,"defaultFontSize",.06),n(this,"targetObject",new uA),n(this,"userForwardViewPoint",new S),n(this,"oneEuroFilter",new KG(90,.8)),n(this,"_lastElementRemoveTime",0),n(this,"onBeforeRender",()=>{var A,e;const i=(A=this.context)==null?void 0:A.mainCamera;if(this.context&&i instanceof xe){const g=this.getRoot();Number.isNaN(g.position.x)&&g.position.set(0,0,0),Number.isNaN(g.quaternion.x)&&g.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const I=((e=this.context.xr)==null?void 0:e.rigScale)??1,o=3.5*I,s=i.worldForward;s.y=0,s.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(i.worldPosition).sub(s),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*I&&(this.targetObject.position.copy(this.userForwardViewPoint),jc(this.targetObject,i,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,g.position,this.context.time.time);const C=this.context.time.deltaTime;if(g.quaternion.slerp(this.targetObject.quaternion,C*5),g.scale.setScalar(I),this.targetObject.removeFromParent(),this.context.scene.add(g),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const a=Date.now();for(let r=0;r<this._activeTexts.length;r++){const B=this._activeTexts[r];if(B instanceof Ft.Text&&a-B._activatedTime>2e4){B.removeFromParent(),this._textBuffer.push(B),this._activeTexts.splice(r,1);break}}}}}),n(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025}),n(this,"_textBuffer",[]),n(this,"_activeTexts",[]),this.ensureFont()}onEnable(){this.context=et.Current||et.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var A,e,i;(e=this.context)==null||e.pre_render_callbacks.splice((A=this.context)==null?void 0:A.pre_render_callbacks.indexOf(this.onBeforeRender),1),(i=this.root)==null||i.removeFromParent()}addLog(A,e){const i=this.getRoot(),g=this.getText();let I=16777215,o=0;switch(A){case"log":I=16777215,o=0;break;case"warn":I=16772761,o=4465152;break;case"error":I=16755370,o=7798784;break}e.length>1e3&&(e=e.substring(0,1e3)+"...");const s=new Date().toISOString().split("T")[1].split(".")[0];g.textContent="["+s+"] "+e,g.visible=!0,g._activatedTime=Date.now(),i.add(g),this._activeTexts.push(g),this.context&&this.context.scene.add(i),g.set({backgroundColor:I,color:o}),Ft.update()}ensureFont(){let A=Ft.FontLibrary.getFontFamily(this.familyName);if(!A){A=Ft.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e?.addEventListener("ready",()=>{Ft.update()})}}getText(){const A=this.getRoot();if(this._textBuffer.length>0){const i=this._textBuffer.pop();return i.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(i),100),i}if(A.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const e=new Ft.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(e),500),setTimeout(()=>this.disableDepthTestRecursive(e),1500),e}disableDepthTestRecursive(A,e=0){for(let g=0;g<A.children.length;g++){const I=A.children[g];I instanceof uA&&this.disableDepthTestRecursive(I,e+1)}A.renderOrder=10*e,A.layers.set(2);const i=A.material;i&&(i.depthWrite=!1,i.depthTest=!1,i.transparent=!0),e===0&&Ft.update()}getRoot(){if(this.root)return this.root;const A=this.defaultFontSize,e={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:A,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Ft.Block(e),this.root}}let ys=null;function z9(){ys||(ys=new V9),ys.onEnable();for(const t in zc){zc[t]=console[t];let A=!1;console[t]=function(){var e;if((e=zc[t])==null||e.apply(console,arguments),!A)try{A=!0,vx(t,...arguments)}finally{A=!1}}}}function X9(){ys?.onDisable();for(const t in zc)console[t]=zc[t]}const Xc=new Map;function vx(t,...A){try{switch(Xc.clear(),t){case"log":ys?.addLog("log",e());break;case"warn":ys?.addLog("warn",e());break;case"error":ys?.addLog("error",e());break}}catch(I){console.error("Error in spatial console",I)}finally{Xc.clear()}function e(){let I="";for(let o=0;o<A.length;o++){const s=A[o];I+=i(s),o<A.length-1&&(I+=", ")}return I}function i(I,o=0){if(typeof I=="string")return'"'+I+'"';if(typeof I=="number"){if(I%1!==0){const s=I.toFixed(5),C=s.indexOf(".");let a=s.length-1;for(;a>C&&s[a]==="0";)a--;return s.substring(0,a+1)}return I.toString()}else if(Array.isArray(I)){let s="[";for(let C=0;C<I.length;C++){const a=I[C];s+=i(a,o+1),C<I.length-1&&(s+=", ")}return s+="]",s}else{if(I===null)return"null";if(I===void 0)return"undefined";if(typeof I=="function")return I.name+"()"}if(I instanceof eA)return`(${i(I.x)}, ${i(I.y)})`;if(I instanceof S)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)})`;if(I instanceof zA)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)}, ${i(I.w)})`;if(I instanceof RA)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)}, ${i(I.w)})`;if(I instanceof Re||I instanceof le)return I.name;if(I instanceof Je)return`[${I.elements.join(", ")}]`;if(I instanceof MA)return`[${I.elements.join(", ")}]`;if(I instanceof $g)return I.mask.toString();if(typeof I=="object"){if(Xc.has(I))return"*";let s=`{
|
|
4341
4341
|
`;s+=g(o);const C=Object.keys(I);let a="";for(let r=0;r<C.length;r++){const B=C[r],Q=I[B];if(Xc.has(Q)){a+="";continue}Xc.set(Q,!0),a+=B+":"+i(Q,o+1),r<C.length-1&&(a+=", "),a.length>=60&&(a+=`
|
|
4342
4342
|
`,a+=g(o),s+=a,a="")}return s+=a,s+=`
|
|
4343
|
-
}`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const $9=tA("nodevlogs");function Xt(t,A=Co.Log){$s(A,t)}function Ci(t){Xt(t,Co.Warn)}function _G(t){Xt(t,Co.Error)}let HG;function re(){return $9?!1:HG!==void 0?HG:Ao()}function A6(t){HG=t}const bx=tA("debugdefines");oE('if(!globalThis[""3.37.
|
|
4343
|
+
}`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const $9=tA("nodevlogs");function Xt(t,A=Co.Log){$s(A,t)}function Ci(t){Xt(t,Co.Warn)}function _G(t){Xt(t,Co.Error)}let HG;function re(){return $9?!1:HG!==void 0?HG:Ao()}function A6(t){HG=t}const bx=tA("debugdefines");oE('if(!globalThis[""3.37.6-alpha""]) globalThis[""3.37.6-alpha""] = "0.0.0";'),oE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),oE('if(!globalThis[""Wed Apr 24 2024 17:26:38 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 24 2024 17:26:38 GMT+0200 (Central European Summer Time)""] = "unknown";'),oE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.6-alpha";'),oE('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),oE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 24 2024 17:26:38 GMT+0200 (Central European Summer Time)";');const ea="3.37.6-alpha",sw="undefined",TG="Wed Apr 24 2024 17:26:38 GMT+0200 (Central European Summer Time)";bx&&console.log(`Engine version: ${ea} (generator: ${sw})
|
|
4344
4344
|
Project built at ${TG}`);const ta="needle_isActiveInHierarchy",zr="builtin_components",$c="needle_editor_guid";function oE(t){try{(0,eval)(t)}catch(A){bx&&console.error(A)}}const e6='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',t6=btoa(e6),i6="data:image/svg+xml;base64,"+t6,g6=i6,I6=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(I6);const o6='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',s6=btoa(o6),C6="data:image/svg+xml;charset=utf-8;base64,"+s6,a6=C6,Ho=tA("debuglicense");let Xr="basic";Ho&&console.log("License Type: "+Xr);function Ss(){switch(Xr){case"pro":case"enterprise":return!0}return!1}function OG(){switch(Xr){case"indie":return!0}return!1}function sE(){return Ss()||OG()}const qx=[];function n6(t){if(Ss()||OG())return t(!0);qx.push(t)}function r6(t){for(const A of qx)try{A(t)}catch{}}et.registerCallback(si.ContextRegistered,t=>{E6(t.context),c6(),Q6(t.context)});let $r,PG=!1,Cw="";async function B6(){if($r)return $r;if(Xr==="basic")try{const t="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+ea+"&generator="+encodeURIComponent(sw),A=await fetch(t,{method:"GET"}).catch(e=>{Ho&&console.error("License check failed",e)});A?.status===200?(PG=!1,Ho&&console.log("License check succeeded"),Xr="pro",r6(!0)):A?.status===403?(PG=!0,Cw=await A.text()):Ho&&console.log("License check failed with status "+A?.status)}catch(t){Ho&&console.error("License check failed",t)}else Ho&&console.log('Runtime license check is skipped because license is already applied as "'+Xr+'"')}$r=B6();async function Q6(t){function A(){const g=document.createElement("div");g.className="needle-forbidden",g.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5506,8 +5506,8 @@ Could not find method ${r.method} on object ${Q.name}. Please rename ${r.method}
|
|
|
5506
5506
|
Could not find method ${r.method} on object ${Q.name}`,Q,typeof Q[r.method])};if(typeof Q[r.method]!="function"){let p=!1,u=Q;for(;u;){const D=Object.getOwnPropertyDescriptor(u,r.method);if(D&&(D.writable===!0||D.set)){p=!0;break}u=Object.getPrototypeOf(u)}!p&&(re()||Rg)&&c()}}let h=r.argument;h!==void 0?h=B(h):r.arguments!==void 0&&(h=r.arguments.map(B));const d=E?this.createEventMethod(Q,r.method,h):void 0,l=new xE(d,r.enabled);if(l.method||(l[agA]=(o=e.object)==null?void 0:o.name),!Q||!l.method){const c=e.object?"Current object: "+e.object.name+", "+e.object.guid:null;Q?console.warn('EventList method not found: "'+r.method+'" on',Q):console.warn("EventList is missing target - will be ignored",r.target,c,A)}else s.push(l)}const C=new tg(s);Rg&&console.log(C);const a=e.target;return a!==void 0&&e.path!==void 0&&C.setEventTarget(e.path,a),C}}createEventMethod(A,e,i){return(...g)=>{const I=A[e];typeof I=="function"?i!==void 0?Array.isArray(i)?I?.call(A,...i):I?.call(A,i):I?.call(A,...g):A[e]=i}}}const rgA=new ngA;class WT extends gC{constructor(){super([bE,Pe])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof le&&e.type===bE){const i=A,g=new bE(i.image.width,i.image.height,{colorSpace:lt});return g.texture=i,i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof Zs&&(i.isCompressedTexture=!1,i.format=RGBAFormat),g}}}new WT;class ZT extends gC{constructor(){super([URL])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"&&A.length>0)return XC(e.gltfId,A)}}new ZT;var BgA=Object.defineProperty,QgA=Object.getOwnPropertyDescriptor,EgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?QgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BgA(A,e,g),g};class ed extends FA{awake(){Xo.createIfNoneExists(this.context)}onEnable(){var A;(A=Xo.get(this.context))==null||A.register(this)}onDisable(){var A;(A=Xo.get(this.context))==null||A.unregister(this)}}class Qo extends ed{constructor(){super(...arguments),n(this,"targets",null),n(this,"raycastHits",[]),n(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(A=null){if(!this.targets)return null;A??(A=new Zo),A.targets=this.targets,A.results=this.raycastHits;const e=A.testObject;this.ignoreSkinnedMeshes&&(A.testObject=g=>g instanceof go?"continue in children":e?e(g):!0);const i=this.context.physics.raycast(A);return A.testObject=e,i}}EgA([w()],Qo.prototype,"ignoreSkinnedMeshes",2);class Ry extends Qo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class td extends ed{performRaycast(A){if(!we.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,i=.01;return this.context.physics.sphereOverlap(e,i)}}class Ny{static getObject(A){const e=A[zo];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const i=this.tryFindCanvasGroup(A);if(i?.isCanvasGroup===!0&&(e&&(e.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const g=hB(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&g?.isGraphic===!0&&(e.graphic=g),!(g?.raycastTarget===!1||g?.layer===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=hB(A,i=>{const g=i;if(g.blocksRaycasts!==void 0&&g.interactable!==void 0)return g},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function ER(t){return t[zo]||(t.parent?ER(t.parent):null)}function hgA(t){return t.isUI===!0||typeof t[zo]=="object"}function Fy(t,A){if(!t)return;const e=t.material;if(e?.isMaterial===!0){const i=t.parent;i&&i.isText,e.side=A.doubleSided??!0?Qt:Dg,e.shadowSide=A.doubleSided?Qt:Dg,t.castShadow=A.castShadows?A.castShadows:!1,t.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const i of t.children)Fy(i,A)}function LE(t,A,e){t[A]===void 0&&console.warn("Field",A,"is undefined on",t);const i=Proxy.revocable(t[A],{set(o,s,C,a){const r=o[s],B=Reflect.set(o,s,C,a);return e(C,r),B}}),g=i.revoke,I=t[A];return i.revoke=()=>{t[A]=I,g()},t[A]=i.proxy,i}const VT=Symbol("Scheduled action");function cgA(t,A,e=Ot.OnBeforeRender){let i=t[VT];i||(i=t[VT]={});const g=A.name;i[e]||(i[e]={});const I=i[e];if(I[g])return;function*o(){A?.call(t),I[g]=null}const s=t.startCoroutine(o(),e);I[g]=s}const ha=tA("debugeventsystem");var hR=(t=>(t.BeforeHandleInput="BeforeHandleInput",t.AfterHandleInput="AfterHandleInput",t))(hR||{});const ca=class extends FA{constructor(){super(),n(this,"raycaster",[]),n(this,"_handleInputFn"),n(this,"pressedByID",new Map),n(this,"hoveredByID",new Map),n(this,"_sortedHits",[]),n(this,"_testObjectsCache",new Map),n(this,"_currentlyActiveRaycaster",null),n(this,"_currentPointerEventName",null),n(this,"shouldRaycastObject",t=>{var A;let e=null;if(hgA(t)&&(e=(A=t[zo])==null?void 0:A.gameObject),this._testObjectsCache.has(t)||e&&this._testObjectsCache.has(e))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let i=QR(t,this._currentPointerEventName);if(!i&&e&&(i=QR(e,this._currentPointerEventName)),i){this._testObjectsCache.set(t,!0);for(const g of t.children)this.shouldRaycastObject_AddToYesCache(g);return!0}return this._testObjectsCache.set(t,!1),"continue in children"}}),n(this,"_sortingBuffer",[]),n(this,"_noDepthTestingResults",[]),n(this,"out",{}),n(this,"_capturedPointer",{}),n(this,"pointerEnterSymbol",Symbol("pointerEnter")),n(this,"pointerExitSymbol",Symbol("pointerExit")),n(this,"currentActiveMeshUIComponents",[]),ca.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,ca.systems.length<=0&&ca.systems.push(...CA.findObjectsOfType(ca,t)));for(const e of ca.systems)if(e.context===t)return;const A=new uA;CA.addNewComponent(A,ca),t.scene.add(A)}static get systems(){const t=be.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const A=this._eventSystemMap.get(t);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,A,e=!1){bn.update(t,A,e)}static markUIDirty(t){bn.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){ca.systems.splice(ca.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!CA.findObjectOfType(ed,this.context)){const t=CA.addNewComponent(this.context.scene,Qo);this.raycaster.push(t),(re()||ha)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var A;t&&this.raycaster&&!this.raycaster.includes(t)&&((A=this.raycaster)==null||A.push(t))}unregister(t){var A,e;const i=(A=this.raycaster)==null?void 0:A.indexOf(t);i!==void 0&&i!==-1&&((e=this.raycaster)==null||e.splice(i,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(ei.PointerDown,this._handleInputFn),this.context.input.addEventListener(ei.PointerUp,this._handleInputFn),this.context.input.addEventListener(ei.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(ei.PointerDown,this._handleInputFn),this.context.input.removeEventListener(ei.PointerUp,this._handleInputFn),this.context.input.removeEventListener(ei.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0||t.propagationStopped)return;const A=new Lh(this.context.input,t);this._currentPointerEventName=t.type,A.inputSource=this.context.input,A.isClick=t.isClick,A.isDoubleClick=t.isDoubleClick,A.isDown=t.type==ei.PointerDown,A.isUp=t.type==ei.PointerUp,A.isPressed=this.context.input.getPointerPressed(t.pointerId),ha&&(A.isDown?console.log("DOWN",A.pointerId):A.isUp&&console.log("UP",A.pointerId),A.isClick&&console.log("CLICK",A.pointerId));const e=new Zo;t.hasRay?e.ray=t.ray:e.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const i=this.performRaycast(e);if(i)for(const I of i)I.event=t,t.intersections.push(I);ha&&A.isClick&&Xt("EventSystem: "+A.pointerId+" - "+this.context.time.frame+" - Up:"+A.isUp+", Down:"+A.isDown);const g={sender:this,args:A,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:g})),this.handleIntersections(i,A),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:g}))}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const A of t.children)this.shouldRaycastObject_AddToYesCache(A)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new Zo),t.testObject=this.shouldRaycastObject;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;this._currentlyActiveRaycaster=A;const e=A.performRaycast(t);this._currentlyActiveRaycaster=null,e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}assignHitInformation(t,A){A?(t.intersection=A,t.point=A.point,t.normal=A.normal,t.face=A.face,t.distance=A.distance,t.instanceId=A.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,A){var e;if(t!=null&&t.length){t=this.sortCandidates(t);for(const g of t){if(A.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(A,g),this.handleEventOnObject(g.object,A))return!0}}this.assignHitInformation(A,t?.[0]),this.invokePointerCapture(A);const i=this.hoveredByID.get(A.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(A.pointerId),A.isUp&&((e=this.pressedByID.get(A.pointerId))==null||e.handlers.forEach(g=>this.invokeOnPointerUp(A,g)),this.pressedByID.delete(A.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<t.length;A++){const e=t[A],i=e.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEventOnObject(t,A){if(!this.testIsVisible(t))return A.isClick&&ha&&console.log("not allowed",t),!1;if(A.pointerId===void 0)return ha&&console.error("Event without pointer can't be handled",A),!1;A.object=t;const e=t.parent,i=A.isClick??!1;let g=null;if(e&&e.isUI){const C=(A.isPressed||A.isClick)??!1;if(e[zo]){const a=e[zo].gameObject;if(a){if(!Ny.isInteractable(a,this.out))return!1;g=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,C),t=a}}}i&&ha&&console.log(this.context.time.frame,t);const I=this.hoveredByID.get(A.pointerId),o=I?.obj;o!==t&&o&&this.propagatePointerExit(o,I.data,t);const s=this.hoveredByID.get(A.pointerId);if(s?(s.obj=t,s.data=A):this.hoveredByID.set(A.pointerId,{obj:t,data:A}),A.isDown){const C=this.pressedByID.get(A.pointerId);C?(C.obj=t,C.data=A):this.pressedByID.set(A.pointerId,{obj:t,data:A,handlers:new Set})}return(g===null||g.interactable)&&this.handleMainInteraction(t,A,o??null),!0}propagate(t,A){for(;t;)CA.foreachComponent(t,e=>{A(e)},!1),t=t.parent}handleMainInteraction(t,A,e){const i=this.pressedByID.get(A.pointerId),g=e!==t;let I=!0;switch(A.event.pointerType){case"mouse":case"touch":const o=this.context.input.getPointerPositionLastFrame(A.pointerId),s=this.context.input.getPointerPosition(A.pointerId);I=o&&!Ae.approximately(o,s);break}this.propagate(t,o=>{var s;const C=o;C.interactable!==!1&&(!C.activeAndEnabled||!C.enabled||(C.onPointerEnter&&g&&this.handlePointerEnter(C,A),A.isDown&&C.onPointerDown&&(C.onPointerDown(A),i?.handlers.add(C),this.handlePointerCapture(A,C)),C.onPointerMove&&(I&&C.onPointerMove(A),this.handlePointerCapture(A,C)),A.isUp&&(C.onPointerUp&&(this.invokeOnPointerUp(A,C),i?.handlers.delete(C)),C.onPointerExit&&((s=A.event)==null?void 0:s.pointerType)===Ow.Touch&&(this.handlePointerExit(C,A),this.hoveredByID.delete(A.pointerId))),A.isClick&&C.onPointerClick&&C.onPointerClick(A)))}),A.isUp&&(i?.handlers.forEach(o=>{this.invokeOnPointerUp(A,o)}),this.pressedByID.delete(A.pointerId))}propagatePointerExit(t,A,e){this.propagate(t,i=>{if(!i.gameObject||i.destroyed)return;const g=i;if(g.onPointerExit){if(e&&this.isChild(e,i.gameObject))return;this.handlePointerExit(g,A)}})}invokeOnPointerUp(t,A){var e;(e=A.onPointerUp)==null||e.call(A,t),this.releasePointerCapture(t,A)}handlePointerEnter(t,A){t.onPointerEnter&&this.updatePointerState(t,A.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(A),this.updatePointerState(t,A.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,A){t.onPointerExit&&this.updatePointerState(t,A.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(A),this.updatePointerState(t,A.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,A,e,i){let g=t[e];if(i)return g&&g.includes(A)?!1:(g=g||[],g.push(A),t[e]=g,!0);{if(!g||!g.includes(A))return!1;const I=g.indexOf(A);return I!==-1&&g.splice(I,1),!0}}handlePointerCapture(t,A){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const e=t.pointerId;if(A.onPointerMove){const i=this._capturedPointer[e]||[];i.push(A),this._capturedPointer[e]=i}else re()&&!A.z__warned_no_pointermove&&(A.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,A))}releasePointerCapture(t,A){const e=t.pointerId;if(this._capturedPointer[e]){const i=this._capturedPointer[e].indexOf(A);i!==-1&&(this._capturedPointer[e].splice(i,1),ha&&console.log("released pointer capture",e,A,this._capturedPointer))}}invokePointerCapture(t){var A;if(t.event.type===ei.PointerMove){const e=t.pointerId,i=this._capturedPointer[e];if(i){ha&&console.log("Captured",e,i);for(let g=0;g<i.length;g++){const I=i[g];if(I.destroyed){i.splice(g,1),g--;continue}(A=I.onPointerMove)==null||A.call(I,t)}}}}isChild(t,A){return!t||!A?!1:t===A?!0:t.parent?this.isChild(t.parent,A):!1}handleMeshUiObjectWithoutShadowDom(t,A){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,A)}handleMeshUIIntersection(t,A){const e=bn.updateState(t,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&bn.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const A=this.currentActiveMeshUIComponents[t];bn.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?CA.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let Xo=ca;n(Xo,"_eventSystemMap",new Map),n(Xo,"didSearchEventSystem",!1);class bn{static markDirty(){this.needsUpdate=!0}static update(A,e,i=!1){if(i){A.update();return}const g=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(g===I.frame)return;I.frame=g;let o=this.needsUpdate||g<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(ha&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:g,nextUpdate:g}],A.update()}static updateState(A,e){let i=null;if(A&&(i=this.findBlockInParent(A),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}n(bn,"lastSelected",null),n(bn,"lastUpdateFrame",[]),n(bn,"needsUpdate",!1);var lgA=Object.defineProperty,dgA=Object.getOwnPropertyDescriptor,yi=(t,A,e,i)=>{for(var g=i>1?void 0:i?dgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lgA(A,e,g),g};const pgA=tA("debugorbit"),Ky=tA("freecam"),id=tA("debugcamerafit"),Jy=tA("smoothcam"),ugA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let cR;class gd extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class ft extends FA{constructor(){super(...arguments),n(this,"autoTarget",!0),n(this,"autoFit",!1),n(this,"enableRotate",!0),n(this,"autoRotate",!1),n(this,"autoRotateSpeed",1),n(this,"minAzimuthAngle",1/0),n(this,"maxAzimuthAngle",1/0),n(this,"minPolarAngle",0),n(this,"maxPolarAngle",Math.PI),n(this,"enableKeys",!0),n(this,"enableDamping",!0),n(this,"dampingFactor",.1),n(this,"enableZoom",!0),n(this,"minZoom",0),n(this,"maxZoom",1/0),n(this,"enablePan",!0),n(this,"lookAtConstraint",null),n(this,"lookAtConstraint01",1),n(this,"allowInterrupt",!0),n(this,"middleClickToFocus",!0),n(this,"doubleClickToFocus",!0),n(this,"useSlerp",!0),n(this,"debugLog",!1),n(this,"targetLerpDuration",1),n(this,"_controls",null),n(this,"_cameraObject",null),n(this,"_lookTargetLerpActive",!1),n(this,"_lookTargetStartPosition",new S),n(this,"_lookTargetEndPosition",new S),n(this,"_lookTargetLerp01",0),n(this,"_lookTargetLerpDuration",0),n(this,"_cameraLerpActive",!1),n(this,"_cameraStartPosition",new S),n(this,"_cameraEndPosition",new S),n(this,"_cameraLerp01",0),n(this,"_cameraLerpDuration",0),n(this,"_inputs",0),n(this,"_enableTime",0),n(this,"_startedListeningToKeyEvents",!1),n(this,"_eventSystem"),n(this,"_afterHandleInputFn"),n(this,"_camera",null),n(this,"_syncedTransform"),n(this,"_didStart",!1),n(this,"_didSetTarget",!1),n(this,"targetElement",null),n(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),n(this,"_shouldDisable",!1),n(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Xo.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(hR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(hR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=CA.getComponent(this.gameObject,xt);this._camera=A;let e=A?.cam;if(!e&&this.gameObject instanceof xe&&(e=this.gameObject),e&&sR(e,this,!0),!this._controls&&e instanceof xe){this._cameraObject=e;const i=this.targetElement??this.context.renderer.domElement,g=e?.quaternion.clone();this._controls=new OiA(e,i),e?.quaternion.copy(g),cR===void 0&&(cR={...this._controls.keys})}this._controls&&(Ky&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,so()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?Ky||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Ky||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=CA.getComponent(this.gameObject,vn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&sR(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}this._controls.enabled=!0,this.__handleSetTargetWhenBecomingActiveTheFirstTime(),(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.length()||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let i=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(i||(i=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),i&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new gd(this,"camera"));else{const g=Ae.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,g)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new gd(this,"lookat"));else{const g=Ae.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,g)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?cR:ugA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,typeof Jy=="number"||Jy===!0){this._controls.enableDamping=!0;const g=typeof Jy=="number"?Jy:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,g))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Ky&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),pgA&&ue.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const A=CA.getComponent(this.gameObject,xt);if(A&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const e=Fe(A.cam).length(),i=new S(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setLookTargetPosition(i,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const e=new Zo;e.screenPoint=new eA(0,0),e.lineThreshold=.1;const i=this.context.physics.raycast(e);i.length>0&&this.setLookTargetPosition(i[0].point,!0),id&&console.log("OrbitControls hits",...i)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(A){if(!A||!(A instanceof uA))return;const e=Fe(A),i=qG(A);this.setTargetFromRaycast(new HI(e,i)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var i,g;A&&(A instanceof uA&&(A=Fe(A)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((g=this._cameraObject)==null?void 0:g.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof uA&&(A=Fe(A)),this._lookTargetEndPosition.copy(A),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){if(!this.controls)return;const e=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const i of e)if(i.distance>0&&CA.isActiveInHierarchy(i.object)){const g=ER(i.object);if(g){const I=g.canvas;if(I!=null&&I.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(A,e=void 0,i=!0){if(this.context.isInXR)return;e==null&&(e=1.1);const g=this._cameraObject,I=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0){console.warn("No objects to fit camera to...");return}if(!g||!I){console.warn("No camera or controls found to fit camera to objects...");return}const o=new S,s=new S,C=new pt;C.makeEmpty();const a=[];function r(k){let U=!0;if(k.visible&&_T(k)!==!1&&!(k.type==="TransformControlsGizmo"||k.type==="TransformControlsPlane")&&(k instanceof qk&&(U=!1),k instanceof JD&&(U=!1),k instanceof LT&&(U=!1),k.material instanceof wD&&(U=!1),k instanceof hA||(U=!1),k!==g&&k.isUI!==!0)){if(U){id&&console.log(k.name,k.type,k);const M=k.children;k.children=a;const G=k.position,K=k.scale;if(Number.isNaN(G.x)||Number.isNaN(G.y)||Number.isNaN(G.z)){console.warn(`Object "${k.name}" has NaN values in position or scale.... will ignore it`,G,K);return}C.expandByObject(k,!0),k.children=M}for(const M of k.children)r(M)}}let B=!1;for(const k of A)k&&(B=!0,k.updateMatrixWorld(),r(k));if(!B){console.warn("No objects to fit camera to...");return}if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",g,C,[...A]);return}if(o.length()<=1e-10){id&&console.warn("Camera fit size is zero",C,[...A]);return}const Q=g.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*g.aspect)/Math.PI*360,h=o.y/(2*Math.atan(Math.PI*Q/360)),d=o.x/(2*Math.atan(Math.PI*E/360)),l=e*Math.max(h,d)+o.z/2;id&&console.log("Fit camera to objects",h,d,"distance",l),I.maxDistance=l*10,I.minDistance=l*.01;const c=.05,p=s.clone();p.y-=o.y*c,this.setLookTargetPosition(p,i),this.autoTarget=!1,g.near=l/1e3,g.far=l*100,g.updateMatrixWorld(),g.updateProjectionMatrix();const u=Fe(g),D=s.clone();if(D.sub(u),D.y=0,D.normalize(),D.multiplyScalar(l),D.y+=-c*4*o.y,g.parent){const k=g.parent.worldToLocal(s.clone().sub(D));this.setCameraTargetPosition(k,i)}else console.error(`Can not fit camera ${g.name} because it has no parent`);if(id){const k=new qk(C);this.context.scene.add(k),YG(k,Zc(g)),setTimeout(()=>{this.context.scene.remove(k)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",U=>{U.code==="KeyF"&&this.fitCamera(A,e,i)}))}I.update()}}yi([w()],ft.prototype,"autoTarget",2),yi([w()],ft.prototype,"autoFit",2),yi([w()],ft.prototype,"enableRotate",2),yi([w()],ft.prototype,"autoRotate",2),yi([w()],ft.prototype,"autoRotateSpeed",2),yi([w()],ft.prototype,"minAzimuthAngle",2),yi([w()],ft.prototype,"maxAzimuthAngle",2),yi([w()],ft.prototype,"minPolarAngle",2),yi([w()],ft.prototype,"maxPolarAngle",2),yi([w()],ft.prototype,"enableKeys",2),yi([w()],ft.prototype,"enableDamping",2),yi([w()],ft.prototype,"dampingFactor",2),yi([w()],ft.prototype,"enableZoom",2),yi([w()],ft.prototype,"minZoom",2),yi([w()],ft.prototype,"maxZoom",2),yi([w()],ft.prototype,"enablePan",2),yi([w(uB)],ft.prototype,"lookAtConstraint",2),yi([w()],ft.prototype,"lookAtConstraint01",2),yi([w()],ft.prototype,"allowInterrupt",2),yi([w()],ft.prototype,"middleClickToFocus",2),yi([w()],ft.prototype,"doubleClickToFocus",2),yi([w()],ft.prototype,"targetLerpDuration",2);var DgA=Object.defineProperty,wgA=Object.getOwnPropertyDescriptor,WI=(t,A,e,i)=>{for(var g=i>1?void 0:i?wgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DgA(A,e,g),g},wB=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(wB||{});const la=tA("debugcam"),zT=tA("debugscreenpointtoray");var vy;const Id=(vy=class extends FA{constructor(){super(...arguments),n(this,"_nearClipPlane",.1),n(this,"_farClipPlane",1e3),n(this,"orthographic",!1),n(this,"orthographicSize",5),n(this,"ARBackgroundAlpha",0),n(this,"_cullingMask",4294967295),n(this,"_backgroundBlurriness",0),n(this,"_backgroundIntensity",1),n(this,"_environmentIntensity"),n(this,"_targetTexture",null),n(this,"_backgroundColor"),n(this,"_fov"),n(this,"_cam",null),n(this,"_clearFlags",2),n(this,"_skybox"),n(this,"_frustum"),n(this,"_projScreenMatrix",new MA)}get isCamera(){return!0}get aspect(){return this._cam instanceof xe?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(t){this._cam instanceof xe&&this._cam.aspect!==t&&(this._cam.aspect=t,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof xe?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof xe){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){const i=this.cam,g=Id._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),zT&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=Id._direction.set(g.x,g.y,g.z),o=Fe(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new HI(o.clone(),I.clone())}getFrustum(){return this._frustum||(this._frustum=new Gr,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Gr),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(t,A){return A&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),t===this._projScreenMatrix?t:t.copy(this._projScreenMatrix)}awake(){zT&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);ue.DrawRay(i.origin,i.direction,g,10)})}onEnable(){la&&console.log(`Camera enabled: "${this.name}". ClearFlags=${wB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),SgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;if(t){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof xe&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof xe&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new xe(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new jC(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){la&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,la){const t=`Camera "${this.name}" clear flags: ${wB[this._clearFlags]}`;console.debug(t)}switch(this._clearFlags){case 1:if(Id.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:la&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:la&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;Id.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}else la&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new ygA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;if(typeof I._transparent=="boolean")return I._transparent;const o=I.environmentBlendMode;la&&Xt("Environment blend mode: "+o+" on "+navigator.userAgent);let s=o==="additive"||o==="alpha-blend";return t.isInAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))&&(s=!0),I._transparent=s,s}},n(vy,"_origin",new S),n(vy,"_direction",new S),vy);let xt=Id;WI([w()],xt.prototype,"aspect",1),WI([w()],xt.prototype,"fieldOfView",1),WI([w()],xt.prototype,"nearClipPlane",1),WI([w()],xt.prototype,"farClipPlane",1),WI([w()],xt.prototype,"clearFlags",1),WI([w()],xt.prototype,"orthographic",2),WI([w()],xt.prototype,"orthographicSize",2),WI([w()],xt.prototype,"ARBackgroundAlpha",2),WI([w()],xt.prototype,"cullingMask",1),WI([w()],xt.prototype,"backgroundBlurriness",1),WI([w()],xt.prototype,"backgroundIntensity",1),WI([w()],xt.prototype,"environmentIntensity",1),WI([w(St)],xt.prototype,"backgroundColor",1),WI([w(bE)],xt.prototype,"targetTexture",1);class ygA{constructor(A){n(this,"_camera"),n(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(la&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Ko,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(la||re())&&Ci(`Camera "${this._camera.name}" has no skybox texture`))}}function SgA(t){tA("freecam")&&t.context.mainCameraComponent===t&&CA.getOrAddComponent(t.gameObject,ft)}class qn extends FA{constructor(){super(...arguments),n(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Tb),this._listener}awake(){ai.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=this.context.mainCameraComponent||CA.getComponentInParent(this.gameObject,xt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A)})}}var fgA=Object.defineProperty,mgA=Object.getOwnPropertyDescriptor,by=(t,A,e,i)=>{for(var g=i>1?void 0:i?mgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&fgA(A,e,g),g};const kgA=tA("debugsignals");class od{constructor(){n(this,"guid")}}by([w()],od.prototype,"guid",2);class YE{constructor(){n(this,"signal"),n(this,"reaction")}}by([w(od)],YE.prototype,"signal",2),by([w(tg)],YE.prototype,"reaction",2);var lR;const da=(lR=class extends FA{constructor(){super(...arguments),n(this,"events")}static invoke(t){if(da.receivers[t]){const A=da.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){kgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)da.receivers[t.signal.guid]||(da.receivers[t.signal.guid]=[]),da.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(da.receivers[t.signal.guid]){const A=da.receivers[t.signal.guid].indexOf(this);A>=0&&da.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;const A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},n(lR,"receivers",{}),lR);let _E=da;by([w(YE)],_E.prototype,"events",2);var Eo=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(Eo||{}),rC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(rC||{}),dR=(t=>(t.Signal="SignalEmitter",t))(dR||{});const BC=tA("debugtimeline");class sd{constructor(){n(this,"director"),n(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class GgA{constructor(A){n(this,"clip"),n(this,"rootPositionOffset"),n(this,"rootQuaternionOffset"),n(this,"rootStartPosition"),n(this,"rootEndPosition"),n(this,"rootStartQuaternion"),n(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";BC&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),BC&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new RA().fromArray(o.values,0),this.rootEndQuaternion=new RA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),BC)){const s=new jt().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class qy extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"trackOffset"),n(this,"target"),n(this,"mixer"),n(this,"clips",[]),n(this,"actions",[]),n(this,"_actionOffsets",[]),n(this,"_didBind",!1),n(this,"_animator",null),n(this,"_useclipOffsets",!0),n(this,"_totalOffsetPosition",new S),n(this,"_totalOffsetRotation",new RA),n(this,"_totalOffsetPosition2",new S),n(this,"_totalOffsetRotation2",new RA),n(this,"_summedPos",new S),n(this,"_tempPos",new S),n(this,"_summedRot",new RA),n(this,"_tempRot",new RA),n(this,"_clipRotQuat",new RA)}onStateChanged(){this._animator&&XT(this._animator.gameObject,this,this.director.isPlaying)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,r=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(r=!0,this.createRotationInterpolant(e,A,B));if(!a||!r){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),d=h.substring(h.lastIndexOf(".")+1),l=B.getObjectByName(d);if(l)if(a){if(!r){const c=e.tracks[0].name.substring(0,E)+".quaternion";BC&&console.warn("Create quaternion track",d,l);const p=l.quaternion,u=new Vs(c,[0,e.duration],[p.x,p.y,p.z,p.w,p.x,p.y,p.z,p.w]);e.tracks.push(u),this.createRotationInterpolant(e,A,u)}}else{const c=h+".position";BC&&console.warn("Create position track",d,l);const p=l.position,u=new ZC(c,[0,e.duration],[p.x,p.y,p.z,p.x,p.y,p.z]);e.tracks.push(u),this.createPositionInterpolant(e,A,u)}}}bind(){if(!this._didBind){this._didBind=!0,BC&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new GgA(A);this._actionOffsets.push(e)}this.target&&(this._animator=CA.getComponent(this.target,bg)??null,this._animator&&XT(this._animator.gameObject,this,!0));for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new S(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new RA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new S(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new RA(e.x,e.y,e.z,e.w)))}}evaluate(A){var e,i,g,I,o,s,C;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let a=0,r=0,B=!1,Q=!1,E=0;for(let h=0;h<this.clips.length;h++){const d=this.models[h],l=this.actions[h],c=d.asset;l.weight=0;const p=A>=d.start&&A<=d.end,u=d.preExtrapolationMode,D=d.postExtrapolationMode,k=h<this.clips.length-1?this.models[h+1]:null;let U=p,M=!1;if(!U&&!B&&d.end<A&&D!==rC.None?(!k||k.start>A)&&(U=!0,B=!0):h==0&&!U&&!Q&&d.start>A&&u!==rC.None&&(!k||k.start<A)&&(U=!0,M=!0,Q=!0),U){let G=1;G*=this.evaluateWeight(A,h,this.models,U),G*=this.director.weight;let K=p;if(M)switch(u){case rC.Hold:break;case rC.Loop:A+=d.start,K=!0;break;default:A+=d.start,K=!0;break}let f=this.getClipTime(A,d),N=0;const _=c.duration;if(M&&u===rC.Hold&&(f=0),K){if(c.loop)for(N+=Math.floor(f/(_+1e-6));f>_;)f-=_}else if(!p&&B)switch(D){case rC.Hold:f=this.getClipTime(d.end,d);break;case rC.Loop:f%=_;break;case rC.PingPong:const v=Math.floor(f/_)%2!==0;f%=_,v&&(f=_-f);break}d.reversed===!0?l.time=l.getClip().duration-f:l.time=f,l.timeScale=0;const T=Math.max(0,G);if(l.weight=T,E+=T,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const v=a==0?this._totalOffsetPosition:this._totalOffsetPosition2,j=a==0?this._totalOffsetRotation:this._totalOffsetRotation2;a<1&&(r=1-G),a+=1;const b=this._summedPos.set(0,0,0),x=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),AA=this._tempRot.identity(),$=c.rotation;$&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp($,G));const aA=this._actionOffsets[h];if(aA.hasOffsets)for(let wA=0;wA<N;wA++)aA.rootPositionOffset?x.copy(aA.rootPositionOffset):x.set(0,0,0),x.applyQuaternion(Y),this._clipRotQuat&&x.applyQuaternion(this._clipRotQuat),aA.rootQuaternionOffset&&(AA.copy(aA.rootQuaternionOffset),Y.multiply(AA)),b.add(x);this._clipRotQuat&&j.multiply(this._clipRotQuat),j.multiply(Y),c.position&&b.add(c.position),v.add(b)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,r),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,r)),this.__mixerError===void 0&&(BC||re())&&(i=(e=this._animator)==null?void 0:e.runtimeAnimatorController)!=null&&i.mixer&&this.mixer!==((I=(g=this._animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const h=Math.max(0,1-E);(C=(s=this._animator)==null?void 0:s.runtimeAnimatorController)==null||C.update(h)}else this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new RA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=r=>{var B;const Q=a(r);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(B=E?.onTimelineRotation)==null||B.call(E,this.director,this.target,r,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new S;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let r;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,d,l;const c=Q(E);if(s.set(c[0],c[1],c[2]),e.removeStartOffset&&(r===void 0?(r=null,r=(d=(h=this._actionOffsets.find(p=>p.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:d.clone()):r!=null&&r.isVector3&&s.sub(r)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),this.director.animationCallbackReceivers)for(const p of this.director.animationCallbackReceivers)(l=p?.onTimelinePosition)==null||l.call(p,this.director,this.target,E,s);return c[0]=s.x,c[1]=s.y,c[2]=s.z,c},B}}}const MgA=tA("mutetimeline"),Cd=class extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"listener"),n(this,"audio",[]),n(this,"audioContextTimeOffset",[]),n(this,"lastTime",0),n(this,"audioSource"),n(this,"_audioLoader",null),n(this,"_playableDirectorResumed",!1)}getAudioFilePath(t){const A=this.director.sourceId;return XC(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new Uk(this.listener);this.audio.push(A);const e=t;e._didTriggerPlay=!1,this.models.push(e)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop();for(const t of this.models)t._didTriggerPlay=!1}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}for(const t of this.models)t._didTriggerPlay=!1}onPauseChanged(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(t){if(MgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=this._playableDirectorResumed;this._playableDirectorResumed=!1;const i=A?.1:0;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.audio[g],s=I.asset;if((!o||!o.buffer)&&this.isInTimeRange(I,t-1,t+1)&&this.handleAudioLoading(I,o),ai.userInteractionRegistered!==!1&&!(o===null||!o.buffer))if(o.playbackRate=this.director.context.time.timeScale*this.director.speed,o.loop=s.loop,t>=I.start&&t<=I.end&&t<this.director.duration){if(!o.isPlaying||!this.director.isPlaying)(e||!I._didTriggerPlay&&this.lastTime<t)&&(I.duration*I.timeScale>.3?o.offset=I.clipIn+(t-I.start)*I.timeScale:o.offset=0,BC&&console.log("Timeline Audio ("+this.track.name+") play with offset "+o.offset+" - "+I.asset.clip),o.play(i),I._didTriggerPlay=!0);else{const a=I.clipIn+(t-I.start)*I.timeScale,r=o.context.currentTime-o._startedAt+o.offset;Math.abs(a-r)>.3&&(o.offset=a,o.stop(),o.play(i))}let C=s.volume;if(this.track.volume!==void 0&&(C*=this.track.volume),A&&(C=0),I.easeInDuration>0){const a=Math.min((t-I.start)/I.easeInDuration,1);C*=a}if(I.easeOutDuration>0){const a=Math.min((I.end-t)/I.easeOutDuration,1);C*=a}o.setVolume(C*this.director.weight)}else I._didTriggerPlay=!1,this.director.isPlaying&&o.isPlaying&&o.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Cd._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new UD);const e=this.getAudioFilePath(t.asset.clip);if(Cd._audioBuffers.get(e)){const g=Cd._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}BC&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Cd._audioBuffers.set(e,i),i}};let ad=Cd;n(ad,"_audioBuffers",new Map);class nd extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"didTrigger",[]),n(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);(a===0||a>=1e-5&&a<i)&&(C=!0)}if(C){if(!o)if(BC&&console.log("Trigger signal",A,I.time,I),this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)_E.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class xy extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"timelines",[]),n(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=CA.getComponent(i.sourceObject,yB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}const HE=tA("debugtimeline"),pR=class extends FA{constructor(){super(...arguments),n(this,"playableAsset"),n(this,"playOnAwake"),n(this,"extrapolationMode",1),n(this,"waitForAudio",!0),n(this,"_visibilityChangeEvt"),n(this,"_clonedPlayableAsset",!1),n(this,"_speed",1),n(this,"_guidsMap"),n(this,"_isPlaying",!1),n(this,"_internalUpdateRoutine"),n(this,"_isPaused",!1),n(this,"_isStopping",!1),n(this,"_time",0),n(this,"_duration",0),n(this,"_weight",1),n(this,"_animationTracks",[]),n(this,"_audioTracks",[]),n(this,"_signalTracks",[]),n(this,"_controlTracks",[]),n(this,"_customTracks",[]),n(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),n(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(HE||Ao())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;HE&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A,e;for(const i of this._audioTracks)(t=i.onEnable)==null||t.call(i);for(const i of this._customTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onEnable)==null||e.call(i);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A,e;this.stop();for(const i of this._audioTracks)(t=i.onDisable)==null||t.call(i);for(const i of this._customTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onDisable)==null||e.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,t&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!ai.userInteractionRegistered&&this.waitForAudio;)await us(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ot.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),A&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}invokeStateChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onStateChanged)==null||t.call(A,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let A=this._time;switch(this.extrapolationMode){case 0:this._speed>0?A=Math.min(A,this._duration):this._speed<0&&(A=Math.max(A,0)),this._time=A;break;case 1:A%=this._duration,this._time=A;break;case 2:if(A>this._duration){this.stop();return}break}const e=this._time;for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Eo.Activation:if(!t&&!this._isPlaying)continue;for(let g=0;g<i.outputs.length;g++){const I=i.outputs[g];if(typeof I=="object"){let o=!1;if(i.clips)for(const C of i.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&s.visible!==o&&(s.visible=o,HE&&console.warn(this.name,"set ActivationTrack-"+g,s.name,o,e))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(e);for(const i of this._audioTracks)i.evaluate(e);for(const i of this._signalTracks)i.evaluate(e);for(const i of this._controlTracks)i.evaluate(e);for(const i of this._customTracks)i.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Lc(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=CA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(HE&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),pR.createTrackFunctions[A.type])continue;A.type!==Eo.Audio&&A.type!==Eo.Control&&A.type!==Eo.Marker&&A.type!==Eo.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===Eo.Control&&A.clips)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=CA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(HE&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);if(t.markers)for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let i=CA.findObjectOfType(qn,this.context);for(const g of this.playableAsset.tracks){const I=g.type,o=pR.createTrackFunctions[I];if(o!=null){const s=o(this,g);if(typeof s.evaluate=="function"){s.director=this,s.track=g,this._customTracks.push(s);continue}}if(g.type===Eo.Animation){if(!g.clips||g.clips.length<=0){HE&&console.warn("Animation track has no clips",g);continue}for(let s=g.outputs.length-1;s>=0;s--){let C=g.outputs[s];if(C instanceof uA){const r=CA.getOrAddComponent(C,bg);r&&(C=r)}const a=(t=C?.gameObject)==null?void 0:t.animations;if(a){const r=new qy;r.trackOffset=g.trackOffset,r.director=this,r.track=g;for(let B=0;B<g.clips.length;B++){const Q=g.clips[B],E=Q.asset;if(!E){console.error(`Timeline ${this.name}: clip #${B} on track "${g.name}" has no animation data`);continue}const h=E.clip;let d=h;if((typeof d=="string"||typeof d=="number")&&(d=a.find(c=>c.name===h)),!d){console.warn("Could not find animationClip for model",Q,g.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}C instanceof bg&&C.runtimeAnimatorController&&(C.__internalDidAwakeAndStart||C.initializeRuntimeAnimatorController(),C.runtimeAnimatorController.mixer||C.runtimeAnimatorController.bind(C),r.mixer=C.runtimeAnimatorController.mixer),r.mixer||(r.mixer=new RD(C.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(Q.asset,d);const l=r.mixer.clipAction(d);r.actions.push(l),r.models.push(Q)}this._animationTracks.push(r)}}}else if(g.type===Eo.Audio){if(!g.clips||g.clips.length<=0)continue;const s=new ad;s.director=this,s.track=g,s.audioSource=g.outputs.find(C=>C instanceof ai),this._audioTracks.push(s),i||(i=(e=this.context.mainCameraComponent)==null?void 0:e.gameObject.addNewComponent(qn)),s.listener=i.listener;for(let C=0;C<g.clips.length;C++){const a=g.clips[C];s.addModel(a)}}else if(g.type===Eo.Marker){const s=new nd;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)switch(C.type){case dR.Signal:s.models.push(C),s.didTrigger.push(!1);break}if(s!==null&&s.models.length>0){const C=CA.getComponent(this.gameObject,_E);C&&(s.receivers.push(C),this._signalTracks.push(s))}}else if(g.type===Eo.Signal){const s=new nd;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)s.models.push(C),s.didTrigger.push(!1);for(const C of g.outputs)s.receivers.push(C);this._signalTracks.push(s)}else if(g.type===Eo.Control){const s=new xy;if(s.director=this,s.track=g,g.clips)for(const C of g.clips)s.models.push(C);s.resolveSourceObjects(this.context),this._controlTracks.push(s)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const A=this.animationCallbackReceivers.indexOf(t);A!==-1&&this.animationCallbackReceivers.splice(A,1)}};let yB=pR;n(yB,"createTrackFunctions",{});const Ly=Symbol("objectIsAnimatedData");function XT(t,A,e){if(!t)return;if(t[Ly]===void 0){if(!e)return;t[Ly]=new Set}const i=t[Ly];e?i.add(A):i.has(A)&&i.delete(A)}function UgA(t){if(!t)return!1;const A=t[Ly];return A!==void 0&&A.size>0}et.registerCallback(si.ContextCreated,t=>{const A=t.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&t.files)for(const e of t.files)CA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof UI&&i.playAutomatically||i instanceof bg||i instanceof yB&&i.playOnAwake===!0)return!0;if(i instanceof UI)return i.playAutomatically=!0,!0;if(i instanceof yB)return i.playOnAwake=!0,!0}},!0)!==!0&&RgA(e.file)});function RgA(t){if(!t||!t.animations)return;for(let e=0;e<t.animations.length;e++){const i=t.animations[e];if(!(!i.tracks||i.tracks.length<=0))for(const g in i.tracks){const I=i.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=t.scene.getObjectByName(o);if(!s&&(s=t.scene.getObjectByProperty("uuid",o),!s))continue;let C=A(s);C||(C=Rn(t.scene,new UI));const a=C.animations=C.animations||[];i.name_animator=C.name,a.indexOf(i)<0&&a.push(i)}}function A(e){var i;if(!e)return;const g=(i=e.userData)==null?void 0:i.components;if(g&&g.length>0)for(let I=0;I<g.length;I++){const o=g[I];if(o instanceof bg||o instanceof UI)return e}return A(e.parent)}}class NgA{constructor(){n(this,"_context")}get context(){return this._context??be.Current}get isStateMachineBehaviour(){return!0}}class rd{constructor(A,e,i,g){n(this,"name"),n(this,"nameHash"),n(this,"normalizedTime"),n(this,"length"),n(this,"speed"),n(this,"action"),this.name=A.name,this.nameHash=A.hash,this.normalizedTime=e,this.length=i,this.speed=g,this.action=A.motion.action||null}}function $T(t,A){return{name:"",isLooping:!1,guid:A?.generateUUID()??zi.generateUUID(),index:-1,clip:new wI(t,1,[])}}var xn=(t=>(t[t.If=1]="If",t[t.IfNot=2]="IfNot",t[t.Greater=3]="Greater",t[t.Less=4]="Less",t[t.Equals=6]="Equals",t[t.NotEqual=7]="NotEqual",t))(xn||{}),uR=(t=>(t[t.Float=1]="Float",t[t.Int=3]="Int",t[t.Bool=4]="Bool",t[t.Trigger=9]="Trigger",t))(uR||{});const RI=tA("debuganimatorcontroller"),Yy=tA("debugrootmotion");class Ro{constructor(A){n(this,"_speed",1),n(this,"normalizedStartOffset",0),n(this,"animator"),n(this,"model"),n(this,"_mixer"),n(this,"_activeState"),n(this,"_activeStates",[]),n(this,"rootMotionHandler"),this.model=A,RI&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let I=0;I<A.length;I++){const o=A[I],s=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,r=a/o.duration;let B=I;(e.autoTransition===void 0||e.autoTransition===!0)&&(B=(I+1)%A.length),s.push({exitTime:1-r,offset:0,duration:a,hasExitTime:!0,destinationState:B,conditions:[]})}const C={name:o.name,hash:I,motion:{name:o.name,clip:o,isLooping:e?.looping??!1},transitions:s,behaviours:[]};i.push(C)}const g={name:"AnimatorController",guid:new pg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new Ro(g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const I=this.model.layers[e].stateMachine;for(const o of I.states)if(o.name===A||o.hash===A){RI&&console.log("transition to ",o),this.transitionTo(o,g,i);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var i,g;const I=typeof A=="string"?"name":"hash";return(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=e)}getBool(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??!1}setFloat(A,e){var i,g;const I=typeof A=="string"?"name":"hash",o=(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(s=>s[I]===A);return o.forEach(s=>s.value=e),o?.length>0}getFloat(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??0}setInteger(A,e){var i,g;const I=typeof A=="string"?"name":"hash";return(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=e)}getInteger(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??0}setTrigger(A){var e,i;RI&&console.log("SET TRIGGER",A);const g=typeof A=="string"?"name":"hash";return(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.filter(I=>I[g]===A).forEach(I=>I.value=!0)}resetTrigger(A){var e,i;const g=typeof A=="string"?"name":"hash";return(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.filter(I=>I[g]===A).forEach(I=>I.value=!1)}getTrigger(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const i of e.stateMachine.states)if(i.name===A||i.hash==A)return i}return null}getCurrentStateInfo(){if(!this._activeState)return null;const A=this._activeState.motion.action;if(!A)return null;const e=this._activeState.motion.clip.duration,i=e<=0?0:Math.abs(A.time/e);return new rd(this._activeState,i,e,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}bind(A){A?this.animator!==A&&(this.animator=A,this._mixer=new RD(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;RI&&console.warn("AnimatorController clone()",this.model);const A=Lc(this.model,(e,i,g)=>g==null?!0:!(g.type==="Object3D"||g.isObject3D===!0||Kx(g)||g.tracks!==void 0||g instanceof Ro));return console.assert(A!==this.model),new Ro(A)}update(A){var e,i;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const g=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((e=this.rootMotionHandler)==null||e.onBeforeUpdate(A)),this._mixer.update(g),this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const i=this._activeStates[e],g=i.motion;if(!g.action)this._activeStates.splice(e,1),e--;else{const I=g.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(RI&&console.debug("REMOVE",i.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){for(const A of this.model.layers){const e=A.stateMachine;e.defaultState===void 0&&(RI&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",A),e.defaultState=0);const i=e.states[e.defaultState];this.transitionTo(i,0,this.normalizedStartOffset)}}evaluateTransitions(){var A;let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const i=this._activeState,g=i.motion.action;for(const o of i.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const C of o.conditions)if(!this.evaluateCondition(C)){s=!1;break}if(s)if(g){const C=i.motion.clip.duration,a=C<=0?1:Math.abs(g.time/C);let r=!1;if(o.hasExitTime?g.timeScale>0?r=a>=o.exitTime:g.timeScale<0&&(r=1-a>=o.exitTime):r=!0,r){for(const B of o.conditions){const Q=this.model.parameters.find(E=>E.name===B.parameter);Q?.type===uR.Trigger&&Q.value&&(Q.value=!1)}g.clampWhenFinished=!0,RI&&console.log("transition to "+o.destinationState,o,a,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(g){let o=i.speed??1;i.speedParameter&&(o*=this.getFloat(i.speedParameter)),o!==void 0&&(g.timeScale=o*this._speed)}let I=!1;if(i.motion.isLooping&&g&&(g.time>=g.getClip().duration?(I=!0,g.reset(),g.time=0,g.play()):g.time<=0&&g.timeScale<0&&(I=!0,g.reset(),g.time=g.getClip().duration,g.play())),!I&&i&&!e&&g&&this.animator&&i.behaviours){const o=g?.getClip().duration,s=g.time/o,C=new rd(this._activeState,s,o,this._speed);for(const a of i.behaviours)a.instance&&((A=a.instance.onStateUpdate)==null||A.call(a.instance,this.animator,C,0))}}getState(A,e){return typeof A=="number"&&(A==-1&&(A=this.model.layers[e].stateMachine.defaultState,A===void 0&&(RI&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+e),A=0)),A=this.model.layers[e].stateMachine.states[A]),A}transitionTo(A,e,i){var g,I,o,s,C,a,r,B;if(!this.animator)return;const Q=0;if(A=this.getState(A,Q),!(A!=null&&A.motion)||!A.motion.clip||!(A.motion.clip instanceof wI))return;const E=this._activeState===A;if(E){const c=A.motion;if(!c.action_loopback&&c.clip){const p=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(c.clip,this.animator.gameObject),p&&p.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),c.action_loopback=this.createAction(c.clip)}}if((g=this._activeState)!=null&&g.behaviours&&this._activeState.motion.action){const c=(I=this._activeState)==null?void 0:I.motion.clip.duration,p=this._activeState.motion.action.time/c,u=new rd(this._activeState,p,c,this._speed);for(const D of this._activeState.behaviours)(s=(o=D.instance)==null?void 0:o.onStateExit)==null||s.call(D.instance,this.animator,u,Q)}const h=(C=this._activeState)==null?void 0:C.motion.action;h&&h.fadeOut(e),E&&(A.motion.action=A.motion.action_loopback,A.motion.action_loopback=h);const d=this._activeState;this._activeState=A;const l=(a=A.motion)==null?void 0:a.action;if(l){if(i=Math.max(0,Math.min(1,i)),A.cycleOffsetParameter){let p=this.getFloat(A.cycleOffsetParameter);typeof p=="number"?(p<0&&(p+=1),i+=p,i%=1):RI&&console.warn("AnimatorController cycle offset parameter is not a number",A.cycleOffsetParameter)}else typeof A.cycleOffset=="number"&&(i+=A.cycleOffset,i%=1);l.isRunning()&&l.stop(),l.reset(),l.enabled=!0;const c=A.motion.clip.duration;if(l.time=E?0:i*c,l.timeScale<0&&(l.time=c-l.time),l.clampWhenFinished=!0,l.setLoop(ic,0),e>0?l.fadeIn(e):l.weight=1,l.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(l),this._activeStates.includes(A)||this._activeStates.push(A),this._activeState.behaviours){const p=new rd(A,i,c,this._speed);for(const u of this._activeState.behaviours)(B=(r=u.instance)==null?void 0:r.onStateEnter)==null||B.call(u.instance,this.animator,p,Q)}}else RI&&(A.__warned_no_motion||(A.__warned_no_motion=!0,console.warn("No action",A.motion,this)));RI&&console.log("TRANSITION FROM "+d?.name+" TO "+A.name,e,h,l,l?.getEffectiveTimeScale(),l?.getEffectiveWeight(),l?.isRunning(),l?.isScheduled(),l?.paused)}createAction(A){var e,i;if(this._mixer.existingAction(A)&&this._mixer.uncacheAction(A,(e=this.animator)==null?void 0:e.gameObject),(i=this.animator)!=null&&i.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new FgA(this));const g=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,g,A)}else return this._mixer.clipAction(A)}evaluateCondition(A){const e=this.model.parameters.find(i=>i.name===A.parameter);if(!e)return!1;switch(A.mode){case xn.If:return e.value===!0;case xn.IfNot:return e.value===!1;case xn.Greater:return e.value>A.threshold;case xn.Less:return e.value<A.threshold;case xn.Equals:return e.value===A.threshold;case xn.NotEqual:return e.value!==A.threshold}return!1}createActions(A){var e,i,g,I;RI&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const s=o.stateMachine;for(let C=0;C<s.states.length;C++){const a=s.states[C];a.transitions||(a.transitions=[]);for(const r of a.transitions)r.conditions||(r.conditions=[]);if(a.motion||(a.motion=$T(a.name)),this.animator&&a.motion.clips){const r=(e=a.motion.clips)==null?void 0:e.find(B=>{var Q,E;return B.node.name===((E=(Q=this.animator)==null?void 0:Q.gameObject)==null?void 0:E.name)});r?a.motion.clip=r.clip:(RI||re())&&console.warn('Could not find clip for animator "'+((g=(i=this.animator)==null?void 0:i.gameObject)==null?void 0:g.name)+'"',a.motion.clips.map(B=>B.node.name))}if(!a.motion.clip){const r=new wI(void 0,void 0,[]);a.motion.clip=r}if((I=a.motion)!=null&&I.clip){const r=a.motion.clip;if(r instanceof wI){const B=this.createAction(r);a.motion.action=B}else(RI||re())&&console.warn("No valid animationclip assigned",a)}if(a.behaviours&&Array.isArray(a.behaviours))for(const r of a.behaviours){if(!(r!=null&&r.typeName))continue;const B=W.get(r.typeName),Q=new B;Q.isStateMachineBehaviour&&(Q._context=this.context??void 0,wE(Q,r.properties),r.instance=Q),RI&&console.log("Created animator controller behaviour",a.name,r.typeName,r.properties,Q)}}}}*enumerateActions(){if(this.model.layers)for(const A of this.model.layers){const e=A.stateMachine;for(let i=0;i<e.states.length;i++){const g=e.states[i];g!=null&&g.motion&&(g.motion.action&&(yield g.motion.action),g.motion.action_loopback&&(yield g.motion.action_loopback))}}}}class A2{constructor(A,e){n(this,"track"),n(this,"createdInterpolant"),n(this,"originalEvaluate"),n(this,"customEvaluate"),this.track=A;const i=A,g=i.createInterpolant.bind(A);i.createInterpolant=()=>(i.createInterpolant=g,this.createdInterpolant=g(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=I=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(I);return e(I,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const hg=class{constructor(t,A,e,i,g){if(n(this,"_action"),n(this,"root"),n(this,"clip"),n(this,"positionWrapper",null),n(this,"rotationWrapper",null),n(this,"context"),n(this,"positionChange",new S),n(this,"rotationChange",new RA),n(this,"_prevTime",0),this.context=t,this.root=A,this.clip=e,hg.firstKeyframeRotation[this.cacheId]||(hg.firstKeyframeRotation[this.cacheId]=new RA),g){const I=g.values;hg.firstKeyframeRotation[this.cacheId].set(I[0],I[1],I[2],I[3])}hg.spaceRotation[this.cacheId]||(hg.spaceRotation[this.cacheId]=new RA),hg.effectiveSpaceRotation[this.cacheId]||(hg.effectiveSpaceRotation[this.cacheId]=new RA),hg.clipOffsetRotation[this.cacheId]=new RA,g&&hg.clipOffsetRotation[this.cacheId].set(g.values[0],g.values[1],g.values[2],g.values[3]).invert(),this.handlePosition(e,i),this.handleRotation(e,g)}set action(t){this._action=t}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(t){if(t.getClip()!==this.clip)return;hg.lastObjRotation[this.cacheId]||(hg.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const A=hg.lastObjRotation[this.cacheId];if(hg.spaceRotation[this.cacheId].copy(A),Yy){const e=new jt().setFromQuaternion(A);console.log("START",this.clip.name,Ae.toDegrees(e.y),this.root.position.z)}}getClipRotationOffset(){return hg.clipOffsetRotation[this.cacheId]}handlePosition(t,A){if(A){const e=this.root;Yy&&e.add(new bo),hg.lastObjPosition[this.cacheId]||(hg.lastObjPosition[this.cacheId]=this.root.position.clone());const i=new S,g=new S;this.positionWrapper=new A2(A,(I,o)=>{const s=this.action.getEffectiveWeight();return Yy&&e.position.length()>8&&e.position.set(0,e.position.y,0),I>this._prevTime&&(i.set(o[0],o[1],o[2]),i.sub(g),i.multiplyScalar(s),i.applyQuaternion(this.getClipRotationOffset()),i.applyQuaternion(e.quaternion),this.positionChange.copy(i)),g.fromArray(o),this._prevTime=I,o[0]=0,o[1]=0,o[2]=0,o})}}handleRotation(t,A){if(A){if(Yy){const I=A.values,o=new jt().setFromQuaternion(new RA(I[0],I[1],I[2],I[3]));console.log(t.name,A.name,"FIRST ROTATION IN TRACK",Ae.toDegrees(o.y));const s=A.values.length-4,C=new RA().set(I[s],I[s+1],I[s+2],I[s+3]),a=new jt().setFromQuaternion(C);console.log(t.name,A.name,"LAST ROTATION IN TRACK",Ae.toDegrees(a.y))}let e=0;const i=new RA,g=new RA;this.rotationWrapper=new A2(A,(I,o)=>(I>e&&(g.set(o[0],o[1],o[2],o[3]),i.invert(),g.multiply(i),this.rotationChange.copy(g)),i.fromArray(o),e=I,o[0]=0,o[1]=0,o[2]=0,o[3]=1,o))}}onBeforeUpdate(t){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(t){return!this.action||(t*=this.action.getEffectiveWeight(),t<=0)?!1:(this.positionChange.multiplyScalar(t),this.rotationChange.slerp(hg.identityQuaternion,1-t),!0)}};let Ln=hg;n(Ln,"lastObjPosition",{}),n(Ln,"lastObjRotation",{}),n(Ln,"firstKeyframeRotation",{}),n(Ln,"spaceRotation",{}),n(Ln,"effectiveSpaceRotation",{}),n(Ln,"clipOffsetRotation",{}),n(Ln,"identityQuaternion",new RA);class FgA{constructor(A){n(this,"controller"),n(this,"handler",[]),n(this,"root"),n(this,"basePosition",new S),n(this,"baseQuaternion",new RA),n(this,"baseRotation",new jt),n(this,"summedPosition",new S),n(this,"summedRotation",new RA),this.controller=A}createClip(A,e,i){this.root=e,e&&"name"in e&&e.name;const g=this.findRootTrack(i,".position"),I=this.findRootTrack(i,".quaternion"),o=new Ln(this.controller.context,e,i,g,I);this.handler.push(o);const s=A.clipAction(i);return o.action=s,s}onStart(A){for(const e of this.handler)e.onStart(A)}onBeforeUpdate(A){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const e of this.handler)e.onBeforeUpdate(A)}onAfterUpdate(A){if(!(A<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const e of this.handler)e.onAfterUpdate(A)&&(this.summedPosition.add(e.positionChange),this.summedRotation.multiply(e.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(A,e){const i=A.tracks;if(!i)return null;for(const g of i)if(g.name.endsWith(e))return g;return null}}class KgA extends gC{onSerialize(A,e){}onDeserialize(A,e){if(e.type===Ro&&A?.__type==="AnimatorController")return new Ro(A)}}new KgA(Ro);var JgA=Object.defineProperty,vgA=Object.getOwnPropertyDescriptor,_y=(t,A,e,i)=>{for(var g=i>1?void 0:i?vgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JgA(A,e,g),g};const $o=tA("debuganimator");class bg extends FA{constructor(){super(...arguments),n(this,"applyRootMotion",!1),n(this,"hasRootMotion",!1),n(this,"keepAnimatorControllerStateOnDisable",!1),n(this,"_parametersAreDirty",!1),n(this,"_isDirty",!1),n(this,"_speed",1),n(this,"_normalizedStartOffset",0),n(this,"_animatorController",null),n(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(A){var e;this._animatorController&&this._animatorController.model===A||(A?A instanceof Ro?(A.animator&&A.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(e=A.model)==null?void 0:e.name),A.model||console.error("AnimatorController has no model"),A=new Ro(A.model)),this._animatorController=A,this._animatorController.bind(this)):($o&&console.log("Assign animator controller",A,this),this._animatorController=new Ro(A),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var A;return(A=this.runtimeAnimatorController)==null?void 0:A.getCurrentStateInfo()}get currentAction(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){this.play(A,e,i,g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){var I;(I=this.runtimeAnimatorController)==null||I.play(A,e,i,g),this._isDirty=!0}Reset(){this.reset()}reset(){var A;(A=this._animatorController)==null||A.reset(),this._isDirty=!0}SetBool(A,e){this.setBool(A,e)}setBool(A,e){var i,g;$o&&console.log("setBool",A,e),((i=this.runtimeAnimatorController)==null?void 0:i.getBool(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setBool(A,e)}GetBool(A){return this.getBool(A)}getBool(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getBool(A))??!1;return $o&&console.log("getBool",A,i),i}toggleBool(A){this.setBool(A,!this.getBool(A))}SetFloat(A,e){this.setFloat(A,e)}setFloat(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(A))!==e&&(this._parametersAreDirty=!0),$o&&console.log("setFloat",A,e),(g=this.runtimeAnimatorController)==null||g.setFloat(A,e)}GetFloat(A){return this.getFloat(A)}getFloat(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getFloat(A))??-1;return $o&&console.log("getFloat",A,i),i}SetInteger(A,e){this.setInteger(A,e)}setInteger(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(A))!==e&&(this._parametersAreDirty=!0),$o&&console.log("setInteger",A,e),(g=this.runtimeAnimatorController)==null||g.setInteger(A,e)}GetInteger(A){return this.getInteger(A)}getInteger(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getInteger(A))??-1;return $o&&console.log("getInteger",A,i),i}SetTrigger(A){this.setTrigger(A)}setTrigger(A){var e;this._parametersAreDirty=!0,$o&&console.log("setTrigger",A),(e=this.runtimeAnimatorController)==null||e.setTrigger(A)}ResetTrigger(A){this.resetTrigger(A)}resetTrigger(A){var e;this._parametersAreDirty=!0,$o&&console.log("resetTrigger",A),(e=this.runtimeAnimatorController)==null||e.resetTrigger(A)}GetTrigger(A){this.getTrigger(A)}getTrigger(A){var e;const i=(e=this.runtimeAnimatorController)==null?void 0:e.getTrigger(A);return $o&&console.log("getTrigger",A,i),i}IsInTransition(){return this.isInTransition()}isInTransition(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.isInTransition())??!1}SetSpeed(A){return this.setSpeed(A)}setSpeed(A){var e;A!==this._speed&&($o&&console.log("setSpeed",A),this._speed=A,((e=this._animatorController)==null?void 0:e.animator)==this&&this._animatorController.setSpeed(A))}set minMaxSpeed(A){var e;this._speed=Ae.lerp(A.x,A.y,Math.random()),((e=this._animatorController)==null?void 0:e.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(A){var e;this._normalizedStartOffset=Ae.lerp(A.x,A.y,Math.random()),((e=this.runtimeAnimatorController)==null?void 0:e.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){$o&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(A=!1){const e=A||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&e){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this._speed),this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var A;this.keepAnimatorControllerStateOnDisable||(A=this._animatorController)==null||A.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!UgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}_y([w()],bg.prototype,"applyRootMotion",2),_y([w()],bg.prototype,"hasRootMotion",2),_y([w()],bg.prototype,"keepAnimatorControllerStateOnDisable",2),_y([w()],bg.prototype,"runtimeAnimatorController",1);const SB=tA("debugusdzanimation"),DR=tA("debugusdzanimationserialization");class Hy{constructor(A,e,i){n(this,"_start"),n(this,"ext"),n(this,"root"),n(this,"clip"),this.ext=A,this.root=e,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}const e2=class{constructor(t,A,e){n(this,"clip"),n(this,"pos"),n(this,"rot"),n(this,"scale"),n(this,"root"),n(this,"target"),n(this,"duration",0),n(this,"useRootMotion",!1),this.root=t,this.target=A,this.clip=e,e?this.duration=e.duration:this.duration=e2.restPoseClipDuration;const i=CA.getComponent(t,bg);i&&(this.useRootMotion=i.applyRootMotion)}get frameRate(){return 60}addTrack(t){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}t.name.endsWith("position")&&(this.pos=t),t.name.endsWith("quaternion")&&(this.rot=t),t.name.endsWith("scale")&&(this.scale=t)}getFrames(){var t,A,e,i,g,I;return this.clip?Math.max(((A=(t=this.pos)==null?void 0:t.times)==null?void 0:A.length)??0,((i=(e=this.rot)==null?void 0:e.times)==null?void 0:i.length)??0,((I=(g=this.scale)==null?void 0:g.times)==null?void 0:I.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(t=!0,A=!0,e=!0){var i,g,I;if(!this.clip)return[0,this.duration];const o=(i=this.pos)==null?void 0:i.times,s=(g=this.rot)==null?void 0:g.times,C=(I=this.scale)==null?void 0:I.times,a=[];if(t&&o)for(const r of o)a.push(r);if(A&&s)for(const r of s)a.push(r);if(e&&C)for(const r of C)a.push(r);return a.includes(0)||a.push(0),a.sort((r,B)=>r-B),[...new Set(a)]}*getValues(t,A=!0,e=!0,i=!0){var g,I,o;const s=new S,C=new RA,a=new S(1,1,1),r=this.target,B=A?(g=this.pos)==null?void 0:g.createInterpolant():void 0,Q=e?(I=this.rot)==null?void 0:I.createInterpolant():void 0,E=i?(o=this.scale)==null?void 0:o.createInterpolant():void 0;B||s.set(r.position.x,r.position.y,r.position.z),Q||C.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),E||a.set(r.scale.x,r.scale.y,r.scale.z);for(let h=0;h<t.length;h++){const d=t[h];if(B){const l=B.evaluate(d);s.set(l[0],l[1],l[2])}if(Q){const l=Q.evaluate(d);C.set(l[0],l[1],l[2],l[3])}if(E){const l=E.evaluate(d);a.set(l[0],l[1],l[2])}if(this.useRootMotion&&r===this.root){const l=new MA;l.compose(s,C,a),l.multiply(r.matrix),l.decompose(s,C,a)}yield{time:d,translation:s,rotation:C,scale:a,index:h}}}};let CI=e2;n(CI,"animationDurationPadding",1/60),n(CI,"restPoseClipDuration",1/60);class Bd{constructor(A){n(this,"dict",new Map),n(this,"rootTargetMap",new Map),n(this,"rootAndClipToRegisteredAnimationMap",new Map),n(this,"rootToRegisteredClipCount",new Map),n(this,"serializers",[]),n(this,"injectRestPoses",!1),n(this,"injectImplicitBehaviours",!1),this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(CI.restPoseClipDuration+CI.animationDurationPadding)*60}getEndTimeCode(){let A=0;for(const[e,i]of this.rootAndClipToRegisteredAnimationMap){const g=i.start+i.duration;g>A&&(A=g)}return A*60}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const i=this.rootTargetMap.get(A);if(!i)return 0;const g=this.dict.get(i[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+CI.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const i=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);SB&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const a of e.tracks){const r=Oe.parseTrackName(a.name),B=Oe.findNode(A,r.nodeName);if(!B){console.warn("no object found for track",a.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q){console.warn("no transform data found for target ",B,"at slot "+I+", this is likely a bug");continue}if(s.delete(B),this.injectRestPoses&&!Q[0]){const h=new CI(null,B,void 0);Q[0]=h}let E=Q[I];E||(E=new CI(A,B,e),Q[I]=E),E.addTrack(a),o!=null&&o.includes(B)||o==null||o.push(B)}for(const a of s){const r=this.dict.get(a);if(!r)continue;if(this.injectRestPoses&&!r[0]){const Q=new CI(null,a,void 0);r[0]=Q}let B=r[I];B||(SB&&console.log("Adding padding clip for ",a,e,"at slot",I),B=new CI(A,a,e),r[I]=B)}const C=new Hy(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(i,C),this.rootToRegisteredClipCount.set(A,I+1),C}onAfterHierarchy(A){SB&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,i;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=I?.isDynamic===!0;DR&&console.log(o,(i=g.model)==null?void 0:i.parent),o&&g.registerCallback(I)}}onExportObject(A,e,i){CA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,i)},!1);const g=new bgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class bgA{constructor(A,e){n(this,"object"),n(this,"dict"),n(this,"model"),n(this,"callback"),this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),DR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){var i;const g=this.model,I=this.dict;if(g&&g.skinnedMesh){let o=function(G){const K=[];for(const[f,N]of G){let _=`${f} : [`;const T=[];for(const v of N)T.push(`(${rg(v.x)}, ${rg(v.y)}, ${rg(v.z)})`);_=_.concat(T.join(", ")),_=_.concat("],"),K.push(_)}return K},s=function(G){const K=[];for(const[f,N]of G){let _=`${f} : [`;const T=[];for(const v of N)T.push(`(${rg(v.w)}, ${rg(v.x)}, ${rg(v.y)}, ${rg(v.z)})`);_=_.concat(T.join(", ")),_=_.concat("],"),K.push(_)}return K},C=function(G){let K,f=!0;const N=new Map;for(const[T,v]of G){K===void 0&&(K=v.length),K!==v.length&&(f=!1);let j=0;for(const b of v)j++,b||(N.has(T)||N.set(T,[]),N.get(T).push(j))}SB&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",K,"Undefined bone entries: ",N),console.assert(f,"All bones should have the same number of TransformData entries",G),console.assert(N.size===0,"All TransformData entries should be set",N);const _=[];for(const[T,v]of G){const j=new Array;let b=0;for(let x=0;x<v.length;x++)j.push(b),b+=v[x].getDuration()+CI.animationDurationPadding;for(let x=0;x<v.length;x++){const Y=v[x],AA=j[x];_.length<=x&&_.push({pos:[],rot:[],scale:[],timeOffset:AA});const $=_[x];$.pos.push(...Y.getSortedTimesArray(!0,!1,!1)),$.rot.push(...Y.getSortedTimesArray(!1,!0,!1)),$.scale.push(...Y.getSortedTimesArray(!1,!1,!0))}}for(const T of _)T.pos.sort((v,j)=>v-j),T.rot.sort((v,j)=>v-j),T.scale.sort((v,j)=>v-j),T.pos=[...new Set(T.pos)],T.rot=[...new Set(T.rot)],T.scale=[...new Set(T.scale)];return _},a=function(G,K,f){const N=new Map,_=new Map,T=new Map,v=K.length;for(const j of f){const b=G.get(j);let x;b?console.assert(b.length===v,"We should have the same number of TransformData entries for each bone",b,K):x=new CI(null,j,void 0);for(let Y=0;Y<v;Y++){const AA=b?b[Y]:x,$=K[Y];for(const{time:aA,translation:wA}of AA.getValues($.pos,!0,!1,!1)){const KA=(aA+$.timeOffset)*60;N.has(KA)||N.set(KA,new Array),N.get(KA).push(wA.clone())}for(const{time:aA,rotation:wA}of AA.getValues($.rot,!1,!0,!1)){const KA=(aA+$.timeOffset)*60;_.has(KA)||_.set(KA,new Array),_.get(KA).push(wA.clone())}for(const{time:aA,scale:wA}of AA.getValues($.scale,!1,!1,!0)){const KA=(aA+$.timeOffset)*60;T.has(KA)||T.set(KA,new Array),T.get(KA).push(wA.clone())}}}return{position:N.size==0?void 0:N,quaternion:_.size==0?void 0:_,scale:T.size==0?void 0:T}},r=function(G){const K=[];for(const f of G)K.push(`(${rg(f.x)}, ${rg(f.y)}, ${rg(f.z)})`);return K.join(", ")},B=function(G){const K=[];for(const f of G)K.push(`(${rg(f.w)}, ${rg(f.x)}, ${rg(f.y)}, ${rg(f.z)})`);return K.join(", ")},Q=function(G){const K=new Map;if(SB){const f=new Array;for(const[N,_]of I)f.push(N.uuid+": "+_.length+" "+_.map(T=>{var v;return(v=T.clip)==null?void 0:v.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+f.join(`
|
|
5508
5508
|
`))}for(const f of G){const N=I.get(f);N&&K.set(f,N)}return K},E=function(G){const K=Q(G),f=C(K);return a(K,f,G)};const h=g.skinnedMesh.skeleton,d=new Array;for(const G in h.bones){const K=h.bones[G],f=h.boneInverses[G];d.push({bone:K,inverse:f})}for(const G of NL(h.bones))d.push({bone:G,inverse:G.matrixWorld.clone().invert()});const l=d[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",g.skinnedMesh),d.sort((G,K)=>hE(G.bone,l)>hE(K.bone,l)?1:-1);const c=[],p=[],u=[],D=[];for(const{bone:G}of d)c.push(G.matrix.clone()),p.push(G.position),u.push(G.quaternion),D.push(G.scale);const k=d.map(G=>'"'+hE(G.bone,l)+'"').join(", "),U=d.map(G=>cE(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${U}]`),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${c.map(G=>cE(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${cE(new MA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=E(d.map(G=>G.bone));if(SB){let G=1e7,K=0;for(const f of((i=M.position)==null?void 0:i.keys())??[])G=Math.min(G,f),K=Math.max(K,f);console.log("Time samples",G,K,M)}if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine(`quatf[] rotations = [${B(u)}]`),M&&M.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=s(M.quaternion);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`half3[] scales = [${r(D)}]`),M&&M.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=o(M.scale);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`float3[] translations = [${r(p)}]`),M&&M.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=o(M.position);for(const K of G)A.appendLine(K);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var i;if(!this.model)return;const g=this.dict.get(this.object);if(g)for(let r=0;r<g.length;r++)g[r]===void 0&&(g[r]=new CI(null,this.object,void 0));this.skinnedMeshExport(A,e);const I=this.object,o=this.dict.get(I);if(!o||I.isSkinnedMesh)return;DR&&console.log("SERIALIZE",this.model.name,this.object.type,o);const s=new MA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const C=new Array;let a=0;for(let r=0;r<o.length;r++){if(C.push(a),o[r]===void 0){console.error("Got an undefined transform data, this is likely a bug.",I,o);continue}a+=o[r].getDuration()+CI.animationDurationPadding}for(let r=0;r<o.length;r++){const B=o[r];if(!B)continue;const Q=C[r];{const E=B.getSortedTimesArray();if(!E||E.length===0){console.error("got an animated object but no time values?",I,B);continue}if(SB){const h=((i=B.clip)==null?void 0:i.name)??"rest",d=B.getDuration();console.log("Write .timeSamples:",h,Q,d,o),A.appendLine("# "+h+": start="+(Q*B.frameRate).toFixed(3)+", length="+(d*B.frameRate).toFixed(3)+", frames="+B.getFrames())}for(const{time:h,translation:d,rotation:l,scale:c}of B.getValues(E)){s.compose(d,l,c);const p=`${(Q+h)*B.frameRate}: ${cE(s)},`;A.appendLine(p)}}}A.indent--,A.appendLine("}")}}var qgA=Object.defineProperty,xgA=Object.getOwnPropertyDescriptor,t2=(t,A,e,i)=>{for(var g=i>1?void 0:i?xgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&qgA(A,e,g),g};const i2=tA("debugpost");class Ne{constructor(A){n(this,"_active",!0),n(this,"_value"),n(this,"_valueRaw"),n(this,"_defaultValue"),n(this,"valueProcessor"),n(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;if(i2){let g=!0;if(typeof i=="number"&&typeof A=="number"){const I=i?.toFixed(4),o=A?.toFixed(4);I!=o?g=!0:g=!1}g&&console.log("VolumeParameter: value changed from",i,"to",A)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,i,this):i2&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}t2([w()],Ne.prototype,"overrideState",1),t2([w()],Ne.prototype,"value",1);var LgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,_gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?YgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&LgA(A,e,g),g};const HgA=tA("debugpost");class aI extends FA{constructor(A=void 0){if(super(),n(this,"active",!0),n(this,"_result"),n(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof Ne&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){HgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof Ne&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===Ne){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof Ne){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===Ne&&(this[e]||(this[e]=new Ne))}}_gA([w()],aI.prototype,"active",2);var TgA=Object.defineProperty,OgA=Object.getOwnPropertyDescriptor,PgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?OgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&TgA(A,e,g),g};const jgA=tA("debugpost"),wR={};function As(t,A){wR[t]=A}function WgA(t){return t.__type in wR?wR[t.__type]:(jgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),aI)}class Qd{constructor(){n(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}PgA([dE([t=>WgA(t),aI])],Qd.prototype,"components",2);var ZgA=Object.defineProperty,VgA=Object.getOwnPropertyDescriptor,zgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?VgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZgA(A,e,g),g};class Ed extends aI{constructor(){super(...arguments),n(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new xY({preset:DE.HIGH,edgeDetectionMode:XM.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}zgA([w(Ne)],Ed.prototype,"preset",2),As("Antialiasing",Ed);const XgA=tA("debugusdz");class nr{constructor(){n(this,"files",new Array)}static getName(A){var e;const i=A.split(".").pop();let g=(e=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:e.replace(".","_");return g||(g="Audio_"+Math.random().toString(36).substring(2,15)),Ia(g)+"."+i}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=CA.getComponents(A,ai);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop()||"Audio",s=nr.getName(I.clip),C=Ia(s);this.files.some(a=>a.path===I.clip)||this.files.push({path:I.clip,name:s}),i.quickLookCompatible||e.addEventListener("serialize",(a,r)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${C}"`,"(",!1),a.appendLine(`displayName = "${o}"`),a.closeBlock(")"),a.beginBlock(),a.appendLine(`uniform asset filePath = @audio/${s}@`),a.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${I.volume}`),a.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i="audio/"+e.name;if(A.files[i]){XgA&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const g=await(await(await fetch(e.path)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files[i]=I}}}const fB=tA("debugautosync"),yR=Symbol("syncerId");class $gA{constructor(){n(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new AIA(A);return e[yR]=A.guid,this._syncers[e[yR]]=e,e}removeSyncer(A){delete this._syncers[A[yR]]}}const SR=new $gA;class AIA{constructor(A){n(this,"comp"),n(this,"hasChanges",!1),n(this,"changedProperties",{}),n(this,"data",{}),n(this,"_boundEvent"),n(this,"_handleReceivingMethod"),n(this,"_isReceiving",!1),n(this,"_isInit",!1),this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this._boundEvent=this.onHandleSending.bind(this),this.comp.context.post_render_callbacks.push(this._boundEvent),this._handleReceivingMethod=this.onHandleReceiving.bind(this),this.comp.context.connection.beginListen(this.networkingKey,this._handleReceivingMethod);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this._boundEvent&&this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this._boundEvent),1),this._handleReceivingMethod&&this.comp.context.connection.stopListen(this.networkingKey,this._handleReceivingMethod),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(fB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const i=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=i}A.send(this.networkingKey,this.data)}onHandleReceiving(A){if(fB&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){fB&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const i in A){if(i==="guid")continue;const g=A[i];this.comp[i]=g,fB&&console.log("SET",i,g)}}catch(i){console.error(i)}finally{this._isReceiving=!1}}}}function eIA(t,A){let e=A!==t;return!e&&t&&A&&(Array.isArray(t)&&Array.isArray(A)||typeof t=="object"&&typeof A=="object")&&(e=!0),e}const hd=Symbol("AutoSyncHandler");function tIA(t){if(t[hd])return t[hd];const A=SR.getOrCreateSyncer(t);return A?.init(t),t[hd]=A,A}function iIA(t){const A=t[hd];A&&(SR.removeSyncer(A),A.destroy(),delete t[hd])}const fR=function(t){return function(A,e){var i;let g="";typeof e=="string"?g=e:g=e.name;let I=null,o;typeof t=="string"?o=A[t]:typeof t=="function"&&(o=t);const s=A,C=s.__internalAwake;if(typeof C!="function"){(fB||re())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((i=A?.constructor)==null?void 0:i.name)+'" is not supported',A);return}fB&&console.log(g);const a=Symbol(g);s.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[g],I=SR.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,g);if(B?.set===void 0){let Q=!1;Object.defineProperty(this,g,{set:function(E){var h;const d=this[a];if(this[a]=E,Q){re()&&console.warn("Recursive call detected",g);return}Q=!0;try{const l=eIA(E,d);fB&&console.log("SyncField assignment",g,"changed?",l,E),l&&o?.call(this,E,d)!==!1&&((h=tIA(this))==null||h.notifyChanged(g,E))}finally{Q=!1}},get:function(){return this[a]},configurable:!0,enumerable:!0})}I?.init(this),C.call(this)};const r=s.__internalDestroy;s.__internalDestroy=function(){iIA(this),r.call(this)}}};var gIA=Object.defineProperty,IIA=Object.getOwnPropertyDescriptor,Ty=(t,A,e,i)=>{for(var g=i>1?void 0:i?IIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&gIA(A,e,g),g};const ho=tA("debugplayersync");class TE extends FA{constructor(){super(...arguments),n(this,"autoSync",!0),n(this,"asset"),n(this,"onPlayerSpawned"),n(this,"_localInstance"),n(this,"onJoinedRoom",()=>{ho&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new tg)}onEnable(){this.context.connection.beginListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom)}async getInstance(){var A,e,i,g,I,o;if(this._localInstance)return this._localInstance;if(ho&&console.log("PlayerSync.createInstance",(A=this.asset)==null?void 0:A.uri),!((e=this.asset)!=null&&e.asset)&&!((i=this.asset)!=null&&i.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(g=this.asset)==null?void 0:g.instantiateSynced({parent:this.gameObject},!0);const s=await this._localInstance;if(s){const C=CA.getComponent(s,es);C?(C.owner=this.context.connection.connectionId,(I=this.onPlayerSpawned)==null||I.invoke(s)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.uri)+"</strong>: please make sure the asset has a PlayerState component!"),CA.destroySynced(s))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var A;(A=this._localInstance)==null||A.then(e=>(ho&&console.log("PlayerSync.destroyInstance",e),CA.destroySynced(e))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",A=>{if(document.visibilityState==="visible")for(let e=es.all.length-1;e>=0;e--){const i=es.all[e];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}}Ty([w()],TE.prototype,"autoSync",2),Ty([w(tt)],TE.prototype,"asset",2),Ty([w(tg)],TE.prototype,"onPlayerSpawned",2);var g2=(t=>(t.OwnerChanged="ownerChanged",t))(g2||{}),cd;const qg=(cd=class extends FA{constructor(){super(...arguments),n(this,"onOwnerChangeEvent",new tg),n(this,"onFirstOwnerChangeEvent",new tg),n(this,"hasOwner",!1),n(this,"owner"),n(this,"dontDestroy",!1),n(this,"onUserLeftRoom",t=>{if(t.userId===this.owner){ho&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return qg._all}static get local(){return qg._local}static getFor(t){if(t instanceof uA)return CA.getComponentInParent(t,qg);if(t instanceof FA)return CA.getComponentInParent(t.gameObject,qg)}static isLocalPlayer(t){const A=qg.getFor(t);return A?.isLocalPlayer??!1}static addEventListener(t,A){return this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(A),A}static removeEventListener(t,A){if(!this._callbacks[t])return;const e=this._callbacks[t].indexOf(A);e>=0&&this._callbacks[t].splice(e,1)}static dispatchEvent(t,A){if(this._callbacks[t])for(const e of this._callbacks[t])e(A)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(t,A){var e,i;ho&&console.log("PlayerSync.onOwnerChange",this,"newOwner",t,"oldOwner",A);const g=qg._local.indexOf(this);g>=0&&qg._local.splice(g,1);const I={playerState:this,oldValue:A,newValue:t};if(this.hasOwner||(this.hasOwner=!0,(e=this.onFirstOwnerChangeEvent)==null||e.invoke(I)),(i=this.onOwnerChangeEvent)==null||i.invoke(I),this.owner===this.context.connection.connectionId){qg._local.push(this);const s=new CustomEvent("local-owner-changed",{detail:I});this.dispatchEvent(s)}const o=new CustomEvent("owner-changed",{detail:I});this.dispatchEvent(o),qg.dispatchEvent("ownerChanged",o)}awake(){qg.all.push(this),ho&&console.log("Registered new PlayerState",this.guid,qg.all.length-1,qg.all),this.context.connection.beginListen(At.UserLeftRoom,this.onUserLeftRoom)}async start(){ho&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await us(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ho&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ho&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ho&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(ho&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ho&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){ho&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),ly(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeftRoom),qg.all.splice(qg.all.indexOf(this),1),this.isLocalPlayer){const t=qg._local.indexOf(this);t>=0&&qg._local.splice(t,1)}}},n(cd,"_all",[]),n(cd,"_local",[]),n(cd,"_callbacks",{}),cd);let es=qg;Ty([fR(es.prototype.onOwnerChange)],es.prototype,"owner",2);const oIA=tA("debugavatar"),QC=class extends FA{constructor(){super(...arguments),n(this,"connectionId"),n(this,"avatar")}static getAvatar(t){return t>=0&&t<QC.instances.length?QC.instances[t]:null}static onAvatarMarkerCreated(t){return QC._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return QC._onAvatarMarkerDestroyed.push(t),t}awake(){QC.instances.push(this),oIA&&console.log(this);for(const t of QC._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){QC.instances.splice(QC.instances.indexOf(this),1);for(const t of QC._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let xg=QC;n(xg,"instances",[]),n(xg,"_onNewAvatarMarkerAdded",[]),n(xg,"_onAvatarMarkerDestroyed",[]);var sIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,aIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?CIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&sIA(A,e,g),g};const OE=tA("debugxrflags"),I2=tA("disablexrflags");I2&&console.warn("XRFlags are disabled");var EC=(t=>(t[t.Never=0]="Never",t[t.Browser=1]="Browser",t[t.AR=2]="AR",t[t.VR=4]="VR",t[t.FirstPerson=8]="FirstPerson",t[t.ThirdPerson=16]="ThirdPerson",t[t.All=4294967295]="All",t))(EC||{});const o2=class{constructor(){n(this,"Mask",17)}Has(t){return(this.Mask&t)!==0}Set(t){OE&&console.warn("Set XR flag state to",t),this.Mask=t,co.Apply()}Enable(t){this.Mask|=t,co.Apply()}Disable(t){this.Mask&=~t,co.Apply()}Toggle(t){this.Mask^=t,co.Apply()}EnableAll(){this.Mask=-1,co.Apply()}DisableAll(){this.Mask=0,co.Apply()}};let NI=o2;n(NI,"Global",new o2);var ld;const pa=(ld=class extends FA{constructor(){super(...arguments),n(this,"visibleIn")}static Apply(){for(const t of this.registry)t.UpdateVisible(NI.Global)}awake(){pa.registry.push(this)}onEnable(){pa.firstApply?this.UpdateVisible(NI.Global):(pa.firstApply=!0,pa.Apply())}onDestroy(){const t=pa.registry.indexOf(this);t>=0&&pa.registry.splice(t,1)}get isOn(){return this.gameObject.visible}UpdateVisible(t=null){if(I2)return;let A;const e=t;if(e&&typeof e=="number"&&(console.assert(typeof e=="number","XRFlag.UpdateVisible: state must be a number",e),OE&&console.log(e),pa.buffer.Mask=e,t=pa.buffer),t instanceof NI?(OE&&console.warn(this.name,"use passed in mask",t.Mask,this.visibleIn),A=t.Has(this.visibleIn)):(OE&&console.log(this.name,"use global mask"),NI.Global.Has(this.visibleIn)),A!==void 0)if(A)OE&&console.log(this.name,"is visible",this.gameObject.uuid),CA.setActive(this.gameObject,!0);else{if(OE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},n(ld,"registry",[]),n(ld,"firstApply"),n(ld,"buffer",new NI),ld);let co=pa;aIA([w()],co.prototype,"visibleIn",2);var nIA=Object.defineProperty,rIA=Object.getOwnPropertyDescriptor,mR=(t,A,e,i)=>{for(var g=i>1?void 0:i?rIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&nIA(A,e,g),g};const dd=tA("debugwebxr"),s2=new RA().setFromAxisAngle(new S(0,1,0),Math.PI);class mB extends FA{constructor(){super(...arguments),n(this,"head"),n(this,"leftHand"),n(this,"rightHand"),n(this,"_syncTransforms")}async onEnterXR(A){if(!this.activeAndEnabled)return;dd&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const e=es.getFor(this);if(e!=null&&e.owner){const i=this.gameObject.addNewComponent(xg);i.avatar=this.gameObject,i.connectionId=e.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):e&&!this.context.connection.isConnected&&(e.dontDestroy=!0)}onLeaveXR(A){const e=this.gameObject.getComponent(xg);e&&e.destroy()}onUpdateXR(A){var e,i;if(!this.activeAndEnabled)return;const g=es.isLocalPlayer(this);if(!g)return;const I=A.xr;if(I.rig&&I.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),I.rig.gameObject.add(this.gameObject)),this._syncTransforms&&g)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const r=CA.getComponentsInChildren(this.head.asset,co);for(const B of r)B.enabled=!1,B.gameObject.visible=!1}}const o=A.xr.leftController,s=(e=this.leftHand)==null?void 0:e.asset;o&&s&&(s.position.copy(o.gripPosition),s.quaternion.copy(o.gripQuaternion),s.quaternion.multiply(s2),s.visible=o.isTracking);const C=A.xr.rightController;if(C&&(i=this.rightHand)!=null&&i.asset){const a=this.rightHand.asset;a.position.copy(C.gripPosition),a.quaternion.copy(C.gripQuaternion),a.quaternion.multiply(s2),a.visible=C.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var A,e,i;if(this.context.connection.isConnected){const g=es.getFor(this);if(g&&g.isLocalPlayer==!1){const I=we.getXRSync(this.context);if(I&&I.hasState(g.owner)){this.tryFindAvatarObjectsIfMissing();const o=(A=this.leftHand)==null?void 0:A.asset;o&&(o.visible=I?.isTracking(g.owner,"left")??!1);const s=(e=this.rightHand)==null?void 0:e.asset;s&&(s.visible=I?.isTracking(g.owner,"right")??!1)}if((i=this.head)!=null&&i.asset){const o=CA.getComponentsInChildren(this.head.asset,co);for(const s of o)s.enabled=!1,s.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const A={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};xH.tryFindAvatarObjects(this.gameObject,this.sourceId||"",A),A.head&&(this.head=A.head),A.leftHand&&(this.leftHand=A.leftHand),A.rightHand&&(this.rightHand=A.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new tt("",this.sourceId,this.head));else{const A=new uA;A.name="Head";const e=ql.createPrimitive(QB.Cube);A.add(e),this.gameObject.add(A),this.head=new tt("",this.sourceId,A),dd&&console.log("Create head",A)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new tt("",this.sourceId,this.rightHand));else{const A=new uA;A.name="Right Hand",this.gameObject.add(A),this.rightHand=new tt("",this.sourceId,A),dd&&console.log("Create right hand",A)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new tt("",this.sourceId,this.leftHand));else{const A=new uA;A.name="Left Hand",this.gameObject.add(A),this.leftHand=new tt("",this.sourceId,A),dd&&console.log("Create left hand",A)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),es.isLocalPlayer(this.gameObject)&&(this._syncTransforms=CA.getComponentsInChildren(this.gameObject,vn))}async loadAvatarObjects(A,e,i){const g=A.loadAssetAsync(),I=e.loadAssetAsync(),o=i.loadAssetAsync(),s=new Array;g&&s.push(g),I&&s.push(I),o&&s.push(o);const C=await Yc(s);dd&&console.log("Avatar loaded results:",C)}}mR([w(tt)],mB.prototype,"head",2),mR([w(tt)],mB.prototype,"leftHand",2),mR([w(tt)],mB.prototype,"rightHand",2);class hC{static Add(A,e,i=null){if(e){for(const g of this.Pois)if(g.obj===e)return;this.Pois.push({obj:e,avatar:i}),this.LastChangeTime=A.time.time}}static Remove(A,e){var i;if(e){for(const g of this.Pois)if(g.obj===e){this.Pois.splice(this.Pois.indexOf(g),1),this.LastChangeTime=A?.time.time??((i=be.Current)==null?void 0:i.time.time);return}}}}n(hC,"Pois",[]),n(hC,"LastChangeTime",0);class BIA{constructor(){n(this,"guid"),n(this,"position",new S)}}class pd extends FA{constructor(){super(...arguments),n(this,"target",null),n(this,"avatar",null),n(this,"_model",null),n(this,"_targetModel",new BIA),n(this,"_currentTargetObject",null),n(this,"_lastUpdateTime",0),n(this,"_lookDuration",0),n(this,"_lastPoiChangedTime",0)}set controlledTarget(A){this.target=A;const e=W.get("MoveRandom");if(e&&this.target){const i=CA.getComponent(this.target,e);i&&i.destroy()}}awake(){if(this.avatar=CA.getComponentInParent(this.gameObject,xg),this.avatar){const A=CA.getComponentInParent(this.gameObject,xg);this._model=new _U(this.context.connection,this.guid),A!=null&&A.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",A=>{var e;this.target&&A&&A.guid===((e=this.avatar)==null?void 0:e.guid)&&iI(this.target,A.position)})}update(){var A;if((!this.context.connection.isConnected||(A=this._model)!=null&&A.hasOwnership)&&(hC.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=hC.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const e=Fe(this._currentTargetObject);iI(this.target,e),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(e))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const A=hC.Pois;if(A.length>0){const e=A[Math.floor(Math.random()*A.length)];if(e&&e.obj){if(e.avatar&&e.avatar===this.avatar)return;this._currentTargetObject=e.obj}}}}}const PE=tA("debugnetworkingstreams");var cC=(t=>(t.Connected="peer-user-connected",t.StreamReceived="receive-stream",t.StreamEnded="call-ended",t.Disconnected="peer-user-disconnected",t.UserJoined="user-joined",t))(cC||{});class C2{constructor(A,e){n(this,"type","call-ended"),n(this,"userId"),n(this,"direction"),this.userId=A,this.direction=e}}class a2{constructor(A,e){n(this,"type","receive-stream"),n(this,"stream"),n(this,"target"),this.stream=A,this.target=e}}class QIA{constructor(A,e){n(this,"guid"),n(this,"peerId"),n(this,"dontSave",!0),this.guid=A.id,this.peerId=e}}var n2=(t=>(t.Incoming="incoming",t.Outgoing="outgoing",t))(n2||{});class EIA extends ag{constructor(A,e,i){super(),n(this,"userId"),n(this,"direction"),n(this,"call"),n(this,"_stream",null),n(this,"_isDisposed",!1),this.userId=A,this.call=e,this.direction=i,this._stream=null,e.on("stream",g=>{if(PE&&console.log("Receive video",g.getAudioTracks(),g.getVideoTracks()),this._stream=g,i==="incoming"){const I=new a2(g,this);this.dispatchEvent(I)}}),e.on("close",()=>{this.dispatchEvent(new C2(A,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),ua(this._stream))}get isOpen(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connected"}get isOpening(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const ud=class extends ag{constructor(t,A){super(),n(this,"id"),n(this,"context"),n(this,"_peer"),n(this,"_incomingCalls",[]),n(this,"_outgoingCalls",[]),n(this,"_enabled",!1),n(this,"_enabledPeer",!1),n(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),n(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),n(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=t,this.id=A,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,A){if(ud.instances.has(A))return ud.instances.get(A);const e=new ud(t,A);return ud.instances.set(A,e),e}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,A){var e;const i={metadata:{userId:this.context.connection.connectionId}},g=(e=this._peer)==null?void 0:e.call(t,A,i);if(g)return this.registerCall(g,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(At.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(At.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=kH(t):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(t){PE&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new QIA(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,A){const e=t.metadata;(!e||!e.userId)&&console.error("Missing call metadata",t);const i=e.userId;A==="incoming"&&PE?console.log("Receive call from",t.metadata):PE&&console.log("Make call to",t.metadata);const g=A==="incoming"?this._incomingCalls:this._outgoingCalls,I=new EIA(i,t,A);return g.push(I),t.on("error",o=>{console.error("Call error",o)}),t.on("close",()=>{PE&&console.log("Call ended",t.metadata),t.close();const o=g.indexOf(I);o!==-1&&g.splice(o,1)}),I.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),A==="incoming"&&(I.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),t.on("stream",()=>{let o=0;const s=setInterval(()=>{const C=o===0;!I.isOpen&&C&&(o+=1,clearInterval(s),I.close())},2e3)})),I}};let Oy=ud;n(Oy,"instances",new Map);class jp extends ag{constructor(A,e){super(),n(this,"context"),n(this,"peer"),n(this,"_sendingStreams",new Map),n(this,"debug",!1),n(this,"onJoinedRoom",i=>{this.debug&&console.log(`${i.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),n(this,"onReceiveStream",i=>{this.debug&&console.log("RECEIVE STREAM",i),this.dispatchEvent({type:"receive-stream",target:this,stream:i.stream,userId:i.userId})}),n(this,"onCallEnded",i=>{this.dispatchEvent(i)}),n(this,"onUserConnected",i=>{if(this.peer.id===i.guid){this.debug&&console.log("USER CONNECTED",i.guid,i);const g=this._sendingStreams.keys().next().value;this.peer.makeCall(i.peerId,g)}}),n(this,"onUserLeft",i=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=A,this.peer=e,PE&&(this.debug=!0)}static create(A){const e=Oy.getOrCreate(A.context,A.context.connection.connectionId);return new jp(A.context,e)}startSendingStream(A){this._sendingStreams.has(A)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(A,[]),this.updateSendingCalls())}stopSendingStream(A){if(A){const e=this._sendingStreams.get(A);if(e){this.debug&&console.log("Closing calls",e);for(const i of e)i.close()}this._sendingStreams.delete(A),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var A;let e=!1;const i=this.context.connection.connectionId;for(const g of this._sendingStreams.keys()){const I=this._sendingStreams.get(g)||[];for(const o of this.context.connection.usersInRoom()){if(o===i)continue;const s=I.find(C=>C.userId===o);if(!s||((A=s.stream)==null?void 0:A.active)===!1){this.debug&&console.log("Starting call to",o,i);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),g);C&&(e=!0,I.push(C))}}this._sendingStreams.set(g,I)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const A of this._sendingStreams.keys()){const e=this._sendingStreams.get(A);if(e)for(let i=e.length-1;i>=0;i--){const g=e[i];this.context.connection.userIsInRoom(g.userId)||(g.close(),e.splice(i,1))}}}}function ua(t){if(t&&t instanceof MediaStream)for(const A of t.getTracks())A.stop()}var hIA=Object.defineProperty,cIA=Object.getOwnPropertyDescriptor,r2=(t,A,e,i)=>{for(var g=i>1?void 0:i?cIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&hIA(A,e,g),g};const lIA="noVoip",dIA=tA("debugvoip");class kB extends FA{constructor(){super(...arguments),n(this,"autoConnect",!1),n(this,"runInBackground",!0),n(this,"debug",!1),n(this,"_net"),n(this,"_outputStream",null),n(this,"onJoinedRoom",async()=>{await us(300),this.autoConnect&&!this.isSending&&this.connect()}),n(this,"_incomingStreams",new Map),n(this,"onReceiveStream",A=>{const e=A.target.userId,i=A.stream,g=this._incomingStreams.get(e);if(g)g.srcObject=i,g.setAttribute("autoplay","true");else{const I=new Audio;this._incomingStreams.set(e,I),I.setAttribute("autoplay","true"),I.srcObject=i}}),n(this,"onStreamEnded",A=>{const e=this._incomingStreams.get(A.userId);ua(e?.srcObject),this._incomingStreams.delete(A.userId)}),n(this,"onEnabledChanged",()=>{for(const A of this._incomingStreams){const e=A[1];e.muted=!this.enabled}}),n(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const A=document.visibilityState!=="visible";this.setMuted(A);for(const e of this._incomingStreams){const i=e[1];i.muted=A}})}awake(){dIA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async A=>{A.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=jp.create(this)),this._net.addEventListener(cC.StreamReceived,this.onReceiveStream),this._net.addEventListener(cC.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var A;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(cC.StreamReceived,this.onReceiveStream),this._net.removeEventListener(cC.StreamEnded,this.onStreamEnded),(A=this._net)==null||A.disable(),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(A){if(this.context.connection.isConnected){if(!await Pk())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),ua(this._outputStream),this._outputStream=await this.getAudioStream(A),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await Pk()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):_G("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),ua(this._outputStream),this._outputStream=null}setMuted(A){var e;const i=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(i)for(const g of i)g.enabled=!A}get isMuted(){var A;if(this._outputStream===null)return!1;const e=(A=this._outputStream)==null?void 0:A.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(A){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,re()&&Ci("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(A){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:A??!0,video:!1}).catch(e=>(console.warn("VOIP failed getting audio stream",e),null)):(console.error("No getDisplayMedia support"),null)}}r2([w()],kB.prototype,"autoConnect",2),r2([w()],kB.prototype,"runInBackground",2);var pIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,B2=(t,A,e,i)=>{for(var g=i>1?void 0:i?uIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&pIA(A,e,g),g};const DIA=tA("debugmouth");class Dd extends FA{constructor(){super(...arguments),n(this,"idle",[]),n(this,"talking",[]),n(this,"marker",null),n(this,"voip",null),n(this,"lastMouthChangeTime",0),n(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=CA.findObjectOfType(kB,this.context),this.marker||(this.marker=CA.getComponentInParent(this.gameObject,xg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){DIA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}B2([w(uA)],Dd.prototype,"idle",2),B2([w(uA)],Dd.prototype,"talking",2);class kR extends FA{constructor(){super(...arguments),n(this,"voip",null),n(this,"marker",null),n(this,"_startPosition",null)}awake(){this.voip=CA.findObjectOfType(kB,this.context),this.marker=CA.getComponentInParent(this.gameObject,xg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var wIA=Object.defineProperty,yIA=Object.getOwnPropertyDescriptor,Py=(t,A,e,i)=>{for(var g=i>1?void 0:i?yIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&wIA(A,e,g),g};class GB extends FA{constructor(){super(...arguments),n(this,"eyes",[]),n(this,"lastBlinkTime",0),n(this,"blinkLength",0),n(this,"eyesOpen",!0),n(this,"state",null)}awake(){this.state=CA.getComponentInParent(this.gameObject,co)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const A of this.eyes)A&&(A.visible=this.eyesOpen)}}}Py([w(uA)],GB.prototype,"eyes",2),Py([w()],GB.prototype,"lastBlinkTime",2),Py([w()],GB.prototype,"blinkLength",2),Py([w()],GB.prototype,"eyesOpen",2);var SIA=Object.defineProperty,fIA=Object.getOwnPropertyDescriptor,GR=(t,A,e,i)=>{for(var g=i>1?void 0:i?fIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SIA(A,e,g),g},MR;const Q2=(MR=class extends FA{constructor(){super(...arguments),n(this,"head",null),n(this,"eyes",null),n(this,"target",null),n(this,"brain",null),n(this,"vec",new S),n(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=CA.getComponentInParent(this.gameObject,pd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=CA.addNewComponent(this.gameObject,pd)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=Fe(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=Fe(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=Q2.forward;if(I.set(0,0,1),I.applyQuaternion(Gt(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},n(MR,"forward",new S(0,0,1)),MR);let jE=Q2;GR([w(uA)],jE.prototype,"head",2),GR([w(uA)],jE.prototype,"eyes",2),GR([w(uA)],jE.prototype,"target",2);const wd=tA("debugavatar");class jy{constructor(A,e,i,g){n(this,"root"),n(this,"head"),n(this,"leftHand"),n(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=i,this.rigthHand=g,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class UR{constructor(){n(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof e=="string"){if(i=await this.loadAvatar(A,e),!i){const I=new Ys;i=CA.instantiate(AE(e,A.scene),I)}}else i=e;if(!i)return null;const g=this.findAvatar(i);return g.isValid?(wd&&console.log("[Custom Avatar] valid config",e,wd?g:""),g):(console.warn("[Custom Avatar] config isn't valid",e,wd?g:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(wd&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const g=await fetch("./"+e);let I=null;if(g.ok){const s=await g.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await EU(e,e,0,"no url here go away",!0),!I))return null;const o=await Bs().parseSync(A,I,null,0);return o?.scene??null}const i=new aE;return Il(i,A),new Promise((g,I)=>{const o=this.avatarRegistryUrl+"/"+e;i.load(o,async s=>{await Bs().createBuiltinComponents(A,o,s,null,void 0),g(s.scene)},s=>{wd&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),g(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let i=e;i.children.length==1&&(i=A.children[0]);let g=this.findAvatarPart(i,["head"]);const I=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!g){g=e;const s=new S;new pt().setFromObject(g).getSize(s);const C=Math.max(s.x,s.y,s.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&g.scale.multiplyScalar(1/C*.3)}return new jy(e,g,I,o)}findAvatarPart(A,e){const i=A.name.toLowerCase();let g=!0;for(const I of e){if(!g)break;i.indexOf(I)===-1&&(g=!1)}if(g)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var mIA=Object.defineProperty,kIA=Object.getOwnPropertyDescriptor,RR=(t,A,e,i)=>{for(var g=i>1?void 0:i?kIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&mIA(A,e,g),g};class WE extends FA{constructor(){super(...arguments),n(this,"length",1),n(this,"depthTest",!0),n(this,"isGizmo",!0),n(this,"_axes",null)}onEnable(){if(this.isGizmo&&!fl)return;this._axes||(this._axes=new bo(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}RR([w()],WE.prototype,"length",2),RR([w()],WE.prototype,"depthTest",2),RR([w()],WE.prototype,"isGizmo",2);class NR extends FA{constructor(){super(...arguments),n(this,"from"),n(this,"to"),n(this,"hint"),n(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const A=Fe(this.to).clone(),e=Fe(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);const I=e.clone();I.add(A),I.multiplyScalar(.5);const o=Fe(this.hint).clone();o.sub(I);const s=new S;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),r=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(r),B.add(I),iI(this.gameObject,B);const Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}const GIA=tA("debugusdzbehaviours");class Wy{constructor(){n(this,"behaviours",[]),n(this,"behaviourComponents",[]),n(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{CA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){GIA&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var MIA=Object.defineProperty,UIA=Object.getOwnPropertyDescriptor,FR=(t,A,e,i)=>{for(var g=i>1?void 0:i?UIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MIA(A,e,g),g},KR;const E2=(KR=class extends aI{constructor(){super(...arguments),n(this,"threshold"),n(this,"intensity"),n(this,"scatter"),n(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom==null&&(this.selectiveBloom=E2.useSelectiveBloom),this.selectiveBloom){const A=t=new vY(this.context.scene,this.context.mainCamera,{blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});A.inverted=!0}else t=new iU({blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=A=>{t.intensity=A},this.threshold.onValueChanged=A=>{t.luminanceMaterial.threshold=A},this.scatter.onValueChanged=A=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=A},t}},n(KR,"useSelectiveBloom",!1),KR);let MB=E2;FR([w(Ne)],MB.prototype,"threshold",2),FR([w(Ne)],MB.prototype,"intensity",2),FR([w(Ne)],MB.prototype,"scatter",2),As("Bloom",MB);const ZE="NEEDLE_progressive",nI=tA("debugprogressive"),JR=Symbol("needle-progressive-texture"),VE=new Map;if(nI){let t=function(){A+=1,Xt(`Toggle LOD level: ${A}<br/>Registered objects: ${VE.size}`),console.log("Toggle LOD level",A,VE);const i=et.Current;VE.forEach((g,I)=>{for(const o of g.keys){const s=I[o];if(s instanceof he){const C=Jt.getMeshLODInformation(s),a=C?Math.min(A,C.lods.length):0;I["DEBUG:LOD"]=a,Jt.assignMeshLOD(i,g.sourceId,I,a),C&&(e=Math.max(e,C.lods.length-1))}else if(I instanceof Re){Jt.assignTextureLOD(i,g.sourceId,I,A);break}}}),A>=e&&(A=-1)},A=-1,e=2;window.addEventListener("keyup",i=>{i.key==="p"&&t()}),et.registerCallback(si.ContextCreated,i=>{const g=document.createElement("button");g.innerText="Toggle Progressive",g.onclick=t,i.context.menu.appendChild(g)})}function h2(t,A,e){var i;if(!nI)return;VE.has(t)||VE.set(t,{keys:[],sourceId:e});const g=VE.get(t);((i=g?.keys)==null?void 0:i.includes(A))==!1&&g.keys.push(A)}const lo=class{constructor(t,A,e){n(this,"parser"),n(this,"sourceId"),n(this,"context"),this.parser=t,this.sourceId=A,this.context=e}get name(){return ZE}static getMeshLODInformation(t){const A=this.getAssignedLODInformation(t);return A!=null&&A.key?this.lodInfos.get(A.key):null}static hasLODLevelAvailable(t,A){var e;if(t instanceof Re){for(const I of Object.keys(t)){const o=t[I];if(o instanceof le&&this.hasLODLevelAvailable(o,A))return!0}return!1}else if(t instanceof pI){for(const I of t.children)if(I instanceof hA&&this.hasLODLevelAvailable(I,A))return!0}let i,g;if(t instanceof hA?i=t.geometry:t instanceof le&&(i=t),i&&(e=i?.userData)!=null&&e.LODS){const I=i.userData.LODS;if(g=this.lodInfos.get(I.key),A===void 0)return g!=null;if(g)return Array.isArray(g.lods)?A<g.lods.length:A===0}return!1}static assignMeshLOD(t,A,e,i){if(!e)return Promise.resolve(null);if(e instanceof hA){const g=e.geometry,I=this.getAssignedLODInformation(g);if(!I)return Promise.resolve(null);Yl(e)||ay(e,e.geometry);const o=this.onProgressiveLoadStart(t,A,e,null);return e["LOD:requested level"]=i,lo.getOrLoadLOD(t,A,g,i).then(s=>{if(e["LOD:requested level"]===i){if(delete e["LOD:requested level"],Array.isArray(s)){const C=I.index||0;s=s[C]}s&&g!=s&&(nI=="verbose"&&console.log("Progressive Mesh "+e.name+" loaded",g,"\u2192",s,`
|
|
5509
|
-
`,e),s instanceof he&&(e.geometry=s,nI&&h2(e,"geometry",A)))}return this.onProgressiveLoadEnd(o),s}).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",e,s),null))}else nI&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(t,A,e,i=0){if(!e)return Promise.resolve(null);if(e instanceof Re){const g=e,I=[],o=new Array;if(g instanceof Jc)for(const s of Object.keys(g.uniforms)){const C=g.uniforms[s].value;if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}else for(const s of Object.keys(g)){const C=g[s];if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}return Yc(I).then(s=>{const C=new Array;for(let a=0;a<s.results.length;a++){const r=s.results[a],B=o[a];r instanceof le?C.push({material:g,slot:B,texture:r,level:i}):C.push({material:g,slot:B,texture:null,level:i})}return C})}if(e instanceof le){const g=e;return this.assignTextureLODForSlot(t,A,g,i,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(t,A,e,i,g,I){if(e?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(t,A,g,I);return lo.getOrLoadLOD(t,A,e,i).then(s=>Array.isArray(s)?null:s?.isTexture===!0?(s!=e&&(g&&I&&(g[I]=s),nI&&I&&g&&h2(g,I,A)),this.onProgressiveLoadEnd(o),s):(nI=="verbose"&&console.warn("No LOD found for",e,i),this.onProgressiveLoadEnd(o),null)).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",e,s),null))}afterRoot(t){var A,e;nI&&console.log("AFTER",this.sourceId,t),(A=this.parser.json.textures)==null||A.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o){for(const s of this.parser.associations.keys())if(s instanceof le&&this.parser.associations.get(s).textures===I){const C=s;nI&&console.log("> Progressive: register texture",I,C.name,C.uuid,C,o),C.source&&(C.source[JR]=o);const a=C.uuid;lo.assignLODInformation(C,a,0,0,void 0),lo.lodInfos.set(a,o),lo.lowresCache.set(a,C)}}}});const i=(g,I,o,s,C)=>{const a=I.geometry;a["needle:raycast-mesh"]=!0,a&&!Yl(I)&&(nI&&console.log("Set raycast mesh",I.name,I.uuid,a),ay(I,a),kw(a,!0).forEach(r=>{r instanceof hA&&ay(r,a)})),a.userData||(a.userData={}),lo.assignLODInformation(a,g,o,s,C.density),lo.lodInfos.set(g,C)};return(e=this.parser.json.meshes)==null||e.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o&&o.lods){for(const s of this.parser.associations.keys())if(s instanceof hA){const C=this.parser.associations.get(s);if(C.meshes===I){const a=s;nI&&console.log("> Progressive: register mesh",I,a.name,o,a.uuid,a);const r=a.uuid,B=o.lods.length;if(a instanceof hA){i(r,a,B,C.primitives,o);let Q=lo.lowresCache.get(r);Q?Q.push(a.geometry):Q=[a.geometry],lo.lowresCache.set(r,Q)}}}}}}),null}static async getOrLoadLOD(t,A,e,i){var g,I,o;const s=nI=="verbose",C=e.userData.LODS;if(!C)return null;const a=C?.key;let r;if(e instanceof le&&e.source&&e.source[JR]&&(r=e.source[JR]),r||(r=lo.lodInfos.get(a)),r){if(i>0){let E=!1;const h=Array.isArray(r.lods);if(h&&i>=r.lods.length?E=!0:h||(E=!0),E)return this.lowresCache.get(a)}const B=Array.isArray(r.lods)?r.lods[i].path:r.lods;if(!B)return nI&&!r["missing:uri"]&&(r["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+i,r)),null;
|
|
5510
|
-
`,u),null)),p=!1;if(c==null||(c instanceof le&&e instanceof le?(g=c.image)!=null&&g.data||(I=c.source)!=null&&I.data?c=this.copySettings(e,c):(p=!0,this.previouslyLoaded.delete(E)):c instanceof he&&e instanceof he&&((o=c.attributes.position)!=null&&o.array||(p=!0,this.previouslyLoaded.delete(E)))),!p)return c}const d=r,l=new Promise(async(c,p)=>{const u=new aE;Il(u,t),nI&&(await us(Math.random()*1e3),s&&console.warn("Start loading (delayed) "+Q,d.guid));const D=await u.loadAsync(Q).catch(M=>(console.error(`Error loading LOD ${i} from ${Q}
|
|
5509
|
+
`,e),s instanceof he&&(e.geometry=s,nI&&h2(e,"geometry",A)))}return this.onProgressiveLoadEnd(o),s}).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",e,s),null))}else nI&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(t,A,e,i=0){if(!e)return Promise.resolve(null);if(e instanceof Re){const g=e,I=[],o=new Array;if(g instanceof Jc)for(const s of Object.keys(g.uniforms)){const C=g.uniforms[s].value;if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}else for(const s of Object.keys(g)){const C=g[s];if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}return Yc(I).then(s=>{const C=new Array;for(let a=0;a<s.results.length;a++){const r=s.results[a],B=o[a];r instanceof le?C.push({material:g,slot:B,texture:r,level:i}):C.push({material:g,slot:B,texture:null,level:i})}return C})}if(e instanceof le){const g=e;return this.assignTextureLODForSlot(t,A,g,i,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(t,A,e,i,g,I){if(e?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(t,A,g,I);return lo.getOrLoadLOD(t,A,e,i).then(s=>Array.isArray(s)?null:s?.isTexture===!0?(s!=e&&(g&&I&&(g[I]=s),nI&&I&&g&&h2(g,I,A)),this.onProgressiveLoadEnd(o),s):(nI=="verbose"&&console.warn("No LOD found for",e,i),this.onProgressiveLoadEnd(o),null)).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",e,s),null))}afterRoot(t){var A,e;nI&&console.log("AFTER",this.sourceId,t),(A=this.parser.json.textures)==null||A.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o){for(const s of this.parser.associations.keys())if(s instanceof le&&this.parser.associations.get(s).textures===I){const C=s;nI&&console.log("> Progressive: register texture",I,C.name,C.uuid,C,o),C.source&&(C.source[JR]=o);const a=C.uuid;lo.assignLODInformation(C,a,0,0,void 0),lo.lodInfos.set(a,o),lo.lowresCache.set(a,C)}}}});const i=(g,I,o,s,C)=>{const a=I.geometry;a["needle:raycast-mesh"]=!0,a&&!Yl(I)&&(nI&&console.log("Set raycast mesh",I.name,I.uuid,a),ay(I,a),kw(a,!0).forEach(r=>{r instanceof hA&&ay(r,a)})),a.userData||(a.userData={}),lo.assignLODInformation(a,g,o,s,C.density),lo.lodInfos.set(g,C)};return(e=this.parser.json.meshes)==null||e.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o&&o.lods){for(const s of this.parser.associations.keys())if(s instanceof hA){const C=this.parser.associations.get(s);if(C.meshes===I){const a=s;nI&&console.log("> Progressive: register mesh",I,a.name,o,a.uuid,a);const r=a.uuid,B=o.lods.length;if(a instanceof hA){i(r,a,B,C.primitives,o);let Q=lo.lowresCache.get(r);Q?Q.push(a.geometry):Q=[a.geometry],lo.lowresCache.set(r,Q)}}}}}}),null}static async getOrLoadLOD(t,A,e,i){var g,I,o;const s=nI=="verbose",C=e.userData.LODS;if(!C)return null;const a=C?.key;let r;if(e instanceof le&&e.source&&e.source[JR]&&(r=e.source[JR]),r||(r=lo.lodInfos.get(a)),r){if(i>0){let E=!1;const h=Array.isArray(r.lods);if(h&&i>=r.lods.length?E=!0:h||(E=!0),E)return this.lowresCache.get(a)}const B=Array.isArray(r.lods)?r.lods[i].path:r.lods;if(!B)return nI&&!r["missing:uri"]&&(r["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+i,r)),null;let Q=XC(A,B);if(Q.endsWith(".glb")||Q.endsWith(".gltf")){if(!r.guid)return console.warn("missing pointer for glb/gltf texture",r),null;const E=Q+"_"+r.guid,h=this.previouslyLoaded.get(E);if(h!==void 0){s&&console.log(`LOD ${i} was already loading/loaded: ${E}`);let c=await h.catch(u=>(console.error(`Error loading LOD ${i} from ${Q}
|
|
5510
|
+
`,u),null)),p=!1;if(c==null||(c instanceof le&&e instanceof le?(g=c.image)!=null&&g.data||(I=c.source)!=null&&I.data?c=this.copySettings(e,c):(p=!0,this.previouslyLoaded.delete(E)):c instanceof he&&e instanceof he&&((o=c.attributes.position)!=null&&o.array||(p=!0,this.previouslyLoaded.delete(E)))),!p)return c}const d=r,l=new Promise(async(c,p)=>{const u=new aE;if(Il(u,t),r&&Array.isArray(r.lods)){const M=r.lods[i];M.hash&&(Q+="?v="+M.hash)}nI&&(await us(Math.random()*1e3),s&&console.warn("Start loading (delayed) "+Q,d.guid));const D=await u.loadAsync(Q).catch(M=>(console.error(`Error loading LOD ${i} from ${Q}
|
|
5511
5511
|
`,M),null));if(!D)return null;const k=D.parser;s&&console.log("Loading finished "+Q,d.guid);let U=0;if(D.parser.json.textures){let M=!1;for(const G of D.parser.json.textures){if(G!=null&&G.extensions){const K=G?.extensions[ZE];if(K!=null&&K.guid&&K.guid===d.guid){M=!0;break}}U++}if(M){let G=await k.getDependency("texture",U);return s&&console.log('change "'+e.name+'" \u2192 "'+G.name+'"',Q,U,G,E),e instanceof le&&(G=this.copySettings(e,G)),G&&(G.guid=d.guid),c(G)}}if(U=0,D.parser.json.meshes){let M=!1;for(const G of D.parser.json.meshes){if(G!=null&&G.extensions){const K=G?.extensions[ZE];if(K!=null&&K.guid&&K.guid===d.guid){M=!0;break}}U++}if(M){const G=await k.getDependency("mesh",U),K=d;if(s&&console.log(`Loaded Mesh "${G.name}"`,Q,U,G,E),G instanceof hA){const f=G.geometry;return lo.assignLODInformation(f,a,i,void 0,K.density),c(f)}else{const f=new Array;for(let N=0;N<G.children.length;N++){const _=G.children[N];if(_ instanceof hA){const T=_.geometry;lo.assignLODInformation(T,a,i,N,K.density),f.push(T)}}return c(f)}}}return c(null)});return this.previouslyLoaded.set(E,l),await l}else if(e instanceof le){s&&console.log("Load texture from uri: "+Q);const E=await new zs().loadAsync(Q);return E?(E.guid=r.guid,E.flipY=!1,E.needsUpdate=!0,E.colorSpace=e.colorSpace,s&&console.log(r,E)):nI&&console.warn("failed loading",Q),E}}else nI&&console.warn(`Can not load LOD ${i}: no LOD info found for "${a}" ${e.name}`,e.type);return null}static assignLODInformation(t,A,e,i,g){if(!t)return;t.userData||(t.userData={});const I=new RIA(A,e,i,g);t.userData.LODS=I,t.userData.LOD=e}static getAssignedLODInformation(t){var A;return((A=t?.userData)==null?void 0:A.LODS)||null}static copySettings(t,A){return this._copiedTextures.get(t)||(A=A.clone(),this._copiedTextures.set(t,A),A.offset=t.offset,A.repeat=t.repeat,A.colorSpace=t.colorSpace,A)}static beginListenStart(t,A){this._progressiveEventListeners.has(t)||this._progressiveEventListeners.set(t,new l2),this._progressiveEventListeners.get(t).start.push(A)}static stopListenStart(t,A){if(!this._progressiveEventListeners.has(t))return;const e=this._progressiveEventListeners.get(t).start,i=e.indexOf(A);i>=0&&e.splice(i,1)}static beginListenEnd(t,A){this._progressiveEventListeners.has(t)||this._progressiveEventListeners.set(t,new l2),this._progressiveEventListeners.get(t).end.push(A)}static stopListenEnd(t,A){if(!this._progressiveEventListeners.has(t))return;const e=this._progressiveEventListeners.get(t).end,i=e.indexOf(A);i>=0&&e.splice(i,1)}static onProgressiveLoadStart(t,A,e,i){this._currentProgressiveLoadingInfo.has(t)||this._currentProgressiveLoadingInfo.set(t,[]);const g=new c2(t,A,e,i),I=this._currentProgressiveLoadingInfo.get(t),o=this._progressiveEventListeners.get(t);return o&&o.onStart(g),I.push(g),g}static onProgressiveLoadEnd(t){if(!t)return;const A=t.context;if(!this._currentProgressiveLoadingInfo.has(A))return;const e=this._currentProgressiveLoadingInfo.get(A),i=e.indexOf(t);if(i<0)return;e.splice(i,1);const g=this._progressiveEventListeners.get(A);g&&g.onEnd(t)}};let Jt=lo;n(Jt,"lodInfos",new Map),n(Jt,"previouslyLoaded",new Map),n(Jt,"lowresCache",new Map),n(Jt,"_copiedTextures",new Map),n(Jt,"_progressiveEventListeners",new Map),n(Jt,"_currentProgressiveLoadingInfo",new Map);class RIA{constructor(A,e,i,g){n(this,"key"),n(this,"level"),n(this,"index"),n(this,"density"),this.key=A,this.level=e,i!=null&&(this.index=i),g!=null&&(this.density=g)}}class c2{constructor(A,e,i,g){n(this,"context"),n(this,"source"),n(this,"material"),n(this,"slot"),n(this,"mesh"),this.context=A,this.source=e,i instanceof hA?this.mesh=i:this.material=i,this.slot=g}}class l2{constructor(){n(this,"start",[]),n(this,"end",[])}onStart(A){for(const e of this.start)e(A)}onEnd(A){for(const e of this.end)e(A)}}var NIA=Object.defineProperty,FIA=Object.getOwnPropertyDescriptor,ZI=(t,A,e,i)=>{for(var g=i>1?void 0:i?FIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&NIA(A,e,g),g};class po extends FA{constructor(){super(...arguments),n(this,"attachedRigidbody",null),n(this,"isTrigger",!1),n(this,"sharedMaterial"),n(this,"membership",[0]),n(this,"filter"),n(this,"updateProperties",()=>{var A;(A=this.context.physics.engine)==null||A.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}onDisable(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}get body(){var A;return(A=this.context.physics.engine)==null?void 0:A.getBody(this)}updatePhysicsMaterial(){var A;(A=this.context.physics.engine)==null||A.updatePhysicsMaterial(this)}}ZI([w(Ut)],po.prototype,"attachedRigidbody",2),ZI([w()],po.prototype,"isTrigger",2),ZI([w()],po.prototype,"sharedMaterial",2),ZI([w()],po.prototype,"membership",2),ZI([w()],po.prototype,"filter",2);class zE extends po{constructor(){super(...arguments),n(this,"radius",.5),n(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addSphereCollider(this),_D(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),Ok(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}ZI([vg(),w()],zE.prototype,"radius",2),ZI([w(S)],zE.prototype,"center",2);class XE extends po{constructor(){super(...arguments),n(this,"size",new S(1,1,1)),n(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addBoxCollider(this,this.size),_D(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),Ok(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}ZI([vg(),w(S)],XE.prototype,"size",2),ZI([w(S)],XE.prototype,"center",2);class UB extends po{constructor(){super(...arguments),n(this,"sharedMesh"),n(this,"convex",!1)}onEnable(){var A,e,i;if(super.onEnable(),!this.context.physics.engine)return;(A=this.sharedMesh)!=null&&A.isMesh||this.gameObject instanceof hA&&(this.sharedMesh=this.gameObject);const g=0;if((e=this.sharedMesh)!=null&&e.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Tt(this.gameObject)),Jt.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,g).then(I=>{I&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=I,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Tt(this.gameObject)))});else{const I=this.sharedMesh;if(I!=null&&I.isGroup){console.warn(`MeshCollider mesh is a group "${((i=this.sharedMesh)==null?void 0:i.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const o=new Array;for(const s in I.children){const C=I.children[s];C.isMesh&&(this.context.physics.engine.addMeshCollider(this,C,this.convex,Tt(this.gameObject)),o.push(Jt.assignMeshLOD(this.context,this.sourceId,C,g)))}Promise.all(o).then(s=>{var C,a;if(s.some(B=>B)==!1)return;(C=this.context.physics.engine)==null||C.removeBody(this);const r=new hA;for(const B of s)B&&this.activeAndEnabled&&(r.geometry=B,(a=this.context.physics.engine)==null||a.addMeshCollider(this,r,this.convex,Tt(this.gameObject)))})}}}}ZI([w(hA)],UB.prototype,"sharedMesh",2),ZI([w()],UB.prototype,"convex",2);class Da extends po{constructor(){super(...arguments),n(this,"center",new S(0,0,0)),n(this,"radius",.5),n(this,"height",2)}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addCapsuleCollider(this,this.height,this.radius)}}ZI([w(S)],Da.prototype,"center",2),ZI([w()],Da.prototype,"radius",2),ZI([w()],Da.prototype,"height",2);var KIA=Object.defineProperty,JIA=Object.getOwnPropertyDescriptor,vR=(t,A,e,i)=>{for(var g=i>1?void 0:i?JIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&KIA(A,e,g),g};class RB extends FA{constructor(){super(...arguments),n(this,"objectBounds",!1),n(this,"color"),n(this,"isGizmo",!0),n(this,"_gizmoObject",null),n(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!fl||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new bk(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=lU(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ot.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var A;this._boxHelper;)(A=this._boxHelper)==null||A.update(),yield}}vR([w()],RB.prototype,"objectBounds",2),vR([w(GA)],RB.prototype,"color",2),vR([w()],RB.prototype,"isGizmo",2);const vIA=tA("gizmos"),bIA=tA("debugboxhelper"),Ns=class extends FA{constructor(){super(...arguments),n(this,"box",null),n(this,"_lastMatrixUpdateFrame",-1),n(this,"_helper",null),n(this,"_color",null)}isInBox(t,A){var e;if(!t)return;if(this.box||(this.box=new pt),t.type==="Mesh")Ns.testBox.setFromObject(t);else if(t.type==="Group"){if(Ns.testBox.makeEmpty(),t.children.length>0)for(let g=0;g<t.children.length;g++)t.children[g].type==="Mesh"&&Ns.testBox.expandByObject(t)}else{const g=Fe(t,Ns._position),I=Tt(t,Ns._size);A!==void 0&&I.multiplyScalar(A),Ns.testBox.setFromCenterAndSize(g,I)}this.updateBox();const i=(e=this.box)==null?void 0:e.intersectsBox(Ns.testBox);return i&&bIA&&ue.DrawWireBox3(Ns.testBox,16711680,5),i}intersects(t){return t?this.updateBox(!1).intersectsBox(t):!1}updateBox(t=!1){if(this.box||(this.box=new pt),t||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const A=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const e=A,i=Fe(this.gameObject,Ns._position,e),g=Tt(this.gameObject,Ns._size);this.box.setFromCenterAndSize(i,g)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(t=null,A=!1){var e;if(!(!vIA&&!A)){if(this._helper){t&&((e=this._color)==null||e.set(t)),this.gameObject.add(this._helper);return}this._helper=lU(t),this.gameObject.add(this._helper)}}};let lC=Ns;n(lC,"testBox",new pt),n(lC,"_position",new S),n(lC,"_size",new S(.01,.01,.01));class qIA extends fx{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const i in e)for(const g in e[i])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(i);for(const i of A._components)A._simpleState__statesProperties[i.id]&&(A._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const i=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],i.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)i.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const i in A)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=A[i]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var xIA=Object.defineProperty,LIA=Object.getOwnPropertyDescriptor,d2=(t,A,e,i)=>{for(var g=i>1?void 0:i?LIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&xIA(A,e,g),g};class $E extends FA{constructor(){super(...arguments),n(this,"effectColor"),n(this,"effectDistance")}}d2([w(St)],$E.prototype,"effectColor",2),d2([w(eA)],$E.prototype,"effectDistance",2);var YIA=Object.defineProperty,_IA=Object.getOwnPropertyDescriptor,yd=(t,A,e,i)=>{for(var g=i>1?void 0:i?_IA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&YIA(A,e,g),g};const bR=tA("debugui"),qR=tA("debuguilayout");class xR{constructor(){n(this,"width"),n(this,"height")}}class LR{constructor(){n(this,"x"),n(this,"y"),n(this,"width"),n(this,"height")}}const Fs=new S,Sd=new MA,Zy=new RA,p2=class extends _s{constructor(){super(...arguments),n(this,"_anchoredPosition"),n(this,"sizeDelta",new eA(100,100)),n(this,"pivot",new eA(.5,.5)),n(this,"anchorMin",new eA(0,0)),n(this,"anchorMax",new eA(1,1)),n(this,"minWidth"),n(this,"minHeight"),n(this,"lastMatrix"),n(this,"rectBlock"),n(this,"_transformNeedsUpdate",!1),n(this,"_initialPosition"),n(this,"_parentRectTransform"),n(this,"_lastUpdateFrame",-1),n(this,"_lastAnchoring"),n(this,"_createdBlocks",[]),n(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new eA),this._anchoredPosition}set anchoredPosition(t){this._anchoredPosition=t}get width(){let t=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const A=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;t=A*e,t+=this.sizeDelta.x}return this.minWidth!==void 0&&t<this.minWidth?this.minWidth:t}get height(){let t=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const A=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;t=A*e,t+=this.sizeDelta.y}return this.minHeight!==void 0&&t<this.minHeight?this.minHeight:t}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new eA),this.lastMatrix=new MA,this.rectBlock=new uA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,LE(this,"_anchoredPosition",()=>{this.markDirty()}),LE(this,"sizeDelta",()=>{this.markDirty()}),LE(this,"pivot",()=>{this.markDirty()}),LE(this,"anchorMin",()=>{this.markDirty()}),LE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var t;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(t=this.Canvas)==null||t.registerTransform(this)}onDisable(){var t;super.onDisable(),this.removeShadowComponent(),(t=this.Canvas)==null||t.unregisterTransform(this)}onParentRectTransformChanged(t){this._transformNeedsUpdate||this.onApplyTransform(qR?`${t.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(qR&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(t){var A;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=CA.getComponentInParent(this.gameObject.parent,p2):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,qR&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+t),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Fs.set(0,0,0),this.applyPivot(Fs),e.matrix.setPosition(Fs.x,Fs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Zy.copy(this.gameObject.quaternion),Zy.x*=-1,Zy.z*=-1,Sd.makeRotationFromQuaternion(Zy),e.matrix.premultiply(Sd)),Fs.set(0,0,0),this.applyAnchoring(Fs),(A=this.Canvas)!=null&&A.screenspace?Fs.z+=.1:Fs.z+=.01,Sd.identity(),Sd.setPosition(Fs.x,Fs.y,Fs.z),e.matrix.premultiply(Sd),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const g of iR(this.gameObject,_s,i,1)){if(g===this||!g.activeAndEnabled)continue;const I=g;I.onParentRectTransformChanged&&I.onParentRectTransformChanged(this)}}applyAnchoring(t){this._lastAnchoring||(this._lastAnchoring=new eA);const A=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=A.x,this.gameObject.position.y+=A.y,this._lastAnchoring.copy(this._anchoredPosition),t.x+=this._initialPosition.x-this.gameObject.position.x,t.y+=this._initialPosition.y-this.gameObject.position.y,t.z+=this._initialPosition.z-this.gameObject.position.z;const e=this._parentRectTransform;if(e){let i=0;const g=1-this.anchorMax.y-this.anchorMin.y;i-=e.height*.5*g,t.y+=i;let I=0;const o=1-this.anchorMax.x-this.anchorMin.x;I-=e.width*.5*o,t.x+=I}}applyPivot(t){if(this.pivot&&!this.isRoot()){const A=this.pivot.x-.5;t.x-=A*this.sizeDelta.x*this.gameObject.scale.x;const e=this.pivot.y-.5;t.y-=e*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const t={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(t),t}ensureValidSize(t,A=1e-4){return t.width<=0&&(t.width=A),t.height<=0&&(t.height=1e-4),t}createNewBlock(t){t={...this.getBasicOptions(),...t},bR&&console.log(this.name,t);const A=new RG(t);return this._createdBlocks.push(A),A}createNewText(t){bR&&console.log(t),t={...this.getBasicOptions(),...t},bR&&console.log(this.name,t);const A=new FG(t);return this._createdTextBlocks.push(A),A}};let FI=p2;yd([w(eA)],FI.prototype,"anchoredPosition",1),yd([w(eA)],FI.prototype,"sizeDelta",2),yd([w(eA)],FI.prototype,"pivot",2),yd([w(eA)],FI.prototype,"anchorMin",2),yd([w(eA)],FI.prototype,"anchorMax",2);var HIA=Object.defineProperty,TIA=Object.getOwnPropertyDescriptor,u2=(t,A,e,i)=>{for(var g=i>1?void 0:i?TIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HIA(A,e,g),g};const Vy={backgroundColor:new GA(1,1,1),backgroundOpacity:1,borderColor:new GA(1,1,1),borderOpacity:1};var YR;const zy=(YR=class extends _s{constructor(){super(...arguments),n(this,"_alphaFactor",1),n(this,"sRGBColor",new GA(1,0,1)),n(this,"raycastTarget",!0),n(this,"uiObject",null),n(this,"_color",null),n(this,"_rect",null),n(this,"_stateManager",null),n(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new St(1,1,1,1)),this._color}set color(t){(!this._color||this._color.r!==t.r||this._color.g!==t.g||this._color.b!==t.b||this._color.alpha!==t.alpha)&&(this._color||(this._color=new St(1,1,1,1)),this._color.copy(t),this.onColorChanged())}setAlphaFactor(t){this._alphaFactor=t,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),Vy.backgroundColor=this.sRGBColor,Vy.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Vy,this._alphaFactor),this.uiObject.set(Vy),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=CA.getComponent(this.gameObject,FI)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var t;(t=this.uiObject)==null||t.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(t){return super.__internalNewInstanceCreated(t),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(t){this.makePanel(),this.uiObject&&(this.uiObject.setState(t),this==null||this.markDirty())}setupState(t){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new qIA(this.uiObject)),this.uiObject.setupState(t.state,t.attributes))}setOptions(t){this.makePanel(),this.uiObject&&this.uiObject.set(t)}awake(){super.awake(),this.makePanel(),LE(this,"_color",()=>cgA(this,this.onColorChanged))}onEnable(){var t;super.onEnable(),this.uiObject&&((t=this.rectTransform.shadowComponent)==null||t.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const t=.015,A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:t};this.onBeforeCreate(A),this.applyEffects(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(t){}onCreate(t){this.uiObject=this.rectTransform.createNewBlock(t),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(t,A=1){var e;const i=(e=this.gameObject)==null?void 0:e.getComponent($E);i&&(i.effectDistance&&(t.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(t.borderColor=i.effectColor,t.borderOpacity=i.effectColor.alpha*A))}async setTexture(t){if(this.setOptions({backgroundOpacity:0}),t){if(zy.textureCache.has(t))t=zy.textureCache.get(t);else if(!t.isRenderTargetTexture){const A=t.clone();A.colorSpace=lt,zy.textureCache.set(t,A),t=A}this.setOptions({backgroundImage:t,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Jt.assignTextureLOD(this.context,this.sourceId,t,0).then(A=>{A instanceof le&&this.setOptions({backgroundImage:A})})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},n(YR,"textureCache",new Map),YR);let NB=zy;u2([w(St)],NB.prototype,"color",1),u2([w()],NB.prototype,"raycastTarget",2);class fd extends NB{constructor(){super(...arguments),n(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var OIA=Object.defineProperty,PIA=Object.getOwnPropertyDescriptor,Xy=(t,A,e,i)=>{for(var g=i>1?void 0:i?PIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&OIA(A,e,g),g};let _R=class{constructor(){n(this,"texture",null),n(this,"rect")}};Xy([w(le)],_R.prototype,"texture",2);let Ah=class extends fd{constructor(){super(...arguments),n(this,"_sprite"),n(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new _R),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,A,e,i,g,I,o;const s=this.sprite;switch((t=s?.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((e=(A=s?.texture)==null?void 0:A.name)!=null&&e.length)&&((g=(i=s?.texture)==null?void 0:i.image)==null?void 0:g.width)===32&&((o=(I=s?.texture)==null?void 0:I.image)==null?void 0:o.height)===32}onBeforeCreate(t){var A,e;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((e=(A=this.sprite)==null?void 0:A.texture)==null?void 0:e.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Xy([w(_R)],Ah.prototype,"sprite",1),Xy([w()],Ah.prototype,"pixelsPerUnitMultiplier",2);class $y extends fd{constructor(){super(...arguments),n(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Xy([w(le)],$y.prototype,"mainTexture",1);var jIA=Object.defineProperty,WIA=Object.getOwnPropertyDescriptor,uo=(t,A,e,i)=>{for(var g=i>1?void 0:i?WIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&jIA(A,e,g),g};const FB=tA("debugbutton");class Yn{constructor(){n(this,"colorMultiplier"),n(this,"disabledColor"),n(this,"fadeDuration"),n(this,"highlightedColor"),n(this,"normalColor"),n(this,"pressedColor"),n(this,"selectedColor")}}uo([w()],Yn.prototype,"colorMultiplier",2),uo([w(St)],Yn.prototype,"disabledColor",2),uo([w()],Yn.prototype,"fadeDuration",2),uo([w(St)],Yn.prototype,"highlightedColor",2),uo([w(St)],Yn.prototype,"normalColor",2),uo([w(St)],Yn.prototype,"pressedColor",2),uo([w(St)],Yn.prototype,"selectedColor",2);class ZIA{constructor(){n(this,"disabledTrigger"),n(this,"highlightedTrigger"),n(this,"normalTrigger"),n(this,"pressedTrigger"),n(this,"selectedTrigger")}}class wa extends FA{constructor(){super(...arguments),n(this,"onClick"),n(this,"_isHovered",0),n(this,"colors"),n(this,"transition"),n(this,"animationTriggers"),n(this,"animator"),n(this,"_interactable",!0),n(this,"_requestedAnimatorTrigger"),n(this,"_isInit",!1),n(this,"_image")}onPointerEnter(A){var e,i;const g=A.event.pointerType==="mouse"&&A.button===0;g&&(this._isHovered+=1),FB&&console.warn("Button Enter",g,this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("hovered")),g&&this.context.input.setCursorPointer())}onPointerExit(){var A,e;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),FB&&console.log("Button Exit",this._isHovered,(A=this.animationTriggers)==null?void 0:A.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((e=this._image)==null||e.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(A){var e,i;FB&&console.log("Button Down",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(A){var e,i;FB&&console.warn("Button Up",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(A){if(this.interactable&&!(A.button!==0&&A.event.pointerType===Ow.Mouse)&&(FB&&(console.warn("Button Click",this.onClick),Xt("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),A.use(),FB))){const e=this.gameObject.worldPosition;e.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),ue.DrawLabel(e,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(A){this.interactable=A}awake(){super.awake(),FB&&console.log(this),this._isInit=!1,this.init()}start(){var A;(A=this._image)==null||A.setInteractable(this.interactable),this.gameObject.getComponentInParent(ed)||this.gameObject.addComponent(Ry)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(A){var e;this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&((e=this.animator)==null||e.SetTrigger(A))}init(){this._isInit||(this._isInit=!0,this._image=CA.getComponent(this.gameObject,Ah),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){var e,i,g,I,o;A.setInteractable(this.interactable);const s=this.getFinalColor(A.color,(e=this.colors)==null?void 0:e.normalColor),C={state:"normal",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};A.setupState(C);const a=this.getFinalColor(A.color,(i=this.colors)==null?void 0:i.highlightedColor),r={state:"hovered",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};A.setupState(r);const B=this.getFinalColor(A.color,(g=this.colors)==null?void 0:g.pressedColor),Q={state:"pressed",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};A.setupState(Q);const E=this.getFinalColor(A.color,(I=this.colors)==null?void 0:I.selectedColor),h={state:"selected",attributes:{backgroundColor:E,backgroundOpacity:E.alpha}};A.setupState(h);const d=this.getFinalColor(A.color,(o=this.colors)==null?void 0:o.disabledColor),l={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};A.setupState(l)}getFinalColor(A,e){return e?A.clone().multiply(e).convertLinearToSRGB():A.clone().convertLinearToSRGB()}}uo([w(tg)],wa.prototype,"onClick",2),uo([w(Yn)],wa.prototype,"colors",2),uo([w()],wa.prototype,"transition",2),uo([w(ZIA)],wa.prototype,"animationTriggers",2),uo([w(bg)],wa.prototype,"animator",2),uo([w()],wa.prototype,"interactable",1);var VIA=Object.defineProperty,zIA=Object.getOwnPropertyDescriptor,Hi=(t,A,e,i)=>{for(var g=i>1?void 0:i?zIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&VIA(A,e,g),g};const D2=tA("debuguilayout");class _n{constructor(){n(this,"left",0),n(this,"right",0),n(this,"top",0),n(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Hi([w()],_n.prototype,"left",2),Hi([w()],_n.prototype,"right",2),Hi([w()],_n.prototype,"top",2),Hi([w()],_n.prototype,"bottom",2);class Do extends FA{constructor(){super(...arguments),n(this,"_rectTransform",null),n(this,"_needsUpdate",!1),n(this,"childAlignment",0),n(this,"reverseArrangement",!1),n(this,"spacing",0),n(this,"padding"),n(this,"minWidth",0),n(this,"minHeight",0),n(this,"flexibleHeight",0),n(this,"flexibleWidth",0),n(this,"preferredHeight",0),n(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(A){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(D2&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){D2&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(FI);const A=this.gameObject.getComponentInParent(Lg);A&&A.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const A=this.gameObject.getComponentInParent(Lg);A&&A.unregisterLayoutGroup(this)}set m_Spacing(A){A!==this.spacing&&(this._needsUpdate=!0,this.spacing=A)}get m_Spacing(){return this.spacing}}Hi([w()],Do.prototype,"childAlignment",2),Hi([w()],Do.prototype,"reverseArrangement",2),Hi([w()],Do.prototype,"spacing",2),Hi([w(_n)],Do.prototype,"padding",2),Hi([w()],Do.prototype,"minWidth",2),Hi([w()],Do.prototype,"minHeight",2),Hi([w()],Do.prototype,"flexibleHeight",2),Hi([w()],Do.prototype,"flexibleWidth",2),Hi([w()],Do.prototype,"preferredHeight",2),Hi([w()],Do.prototype,"preferredWidth",2);class Hn extends Do{constructor(){super(...arguments),n(this,"childControlHeight",!0),n(this,"childControlWidth",!0),n(this,"childForceExpandHeight",!1),n(this,"childForceExpandWidth",!1),n(this,"childScaleHeight",!1),n(this,"childScaleWidth",!1)}onCalculateLayout(A){var e;const i=this.primaryAxis,g=A.width;let I=g;const o=A.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const C=i==="x",a=C?"y":"x",r=C?this.childControlWidth:this.childControlHeight,B=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,d=C?g:o,l=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let p=0,u=0;for(let G=0;G<this.gameObject.children.length;G++){const K=this.gameObject.children[G],f=CA.getComponent(K,FI);f!=null&&f.activeAndEnabled&&(u+=1,C?p+=f.width:p+=f.height)}let D=0;const k=this.spacing*(u-1);if(Q||r){let G=0;C?G=I-=k:G=s-=k,u>0&&(D=G/u)}let U=0;U+=this.padding.left,U-=this.padding.right,l!==0&&(c=d-p,c*=l,c-=k*l,C?(c-=this.padding.right*l,c+=this.padding.left*(1-l),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*l,c+=this.padding.top*(1-l),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let G=0;G<this.gameObject.children.length;G++){const K=this.gameObject.children[G],f=CA.getComponent(K,FI);if(f!=null&&f.activeAndEnabled){(e=f.pivot)==null||e.set(.5,.5),f.anchorMin.set(0,1),f.anchorMax.set(0,1);const N=g*.5+U*.5;f.anchoredPosition.x!==N&&(f.anchoredPosition.x=N);const _=o*-.5;f.anchoredPosition.y!==_&&(f.anchoredPosition.y=_),E&&B&&f.sizeDelta[a]!==h&&(f.sizeDelta[a]=h),Q&&r&&f.sizeDelta[i]!==D&&(f.sizeDelta[i]=D);const T=C?f.width:f.height,v=T*.5;if(c+=v,Q){const b=D*M-D*.5;b>c&&(c=b-D*.5+T+this.padding.left,c-=v)}let j=c;i==="y"&&(j=-j),f.anchoredPosition[i]!==j&&(f.anchoredPosition[i]=j),c+=v,c+=this.spacing,M+=1}}}}Hi([w()],Hn.prototype,"childControlHeight",2),Hi([w()],Hn.prototype,"childControlWidth",2),Hi([w()],Hn.prototype,"childForceExpandHeight",2),Hi([w()],Hn.prototype,"childForceExpandWidth",2),Hi([w()],Hn.prototype,"childScaleHeight",2),Hi([w()],Hn.prototype,"childScaleWidth",2);class HR extends Hn{get primaryAxis(){return"y"}}class TR extends Hn{get primaryAxis(){return"x"}}class OR extends Do{onCalculateLayout(){}}var XIA=Object.defineProperty,$IA=Object.getOwnPropertyDescriptor,dC=(t,A,e,i)=>{for(var g=i>1?void 0:i?$IA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&XIA(A,e,g),g},w2=(t=>(t[t.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",t[t.ScreenSpaceCamera=1]="ScreenSpaceCamera",t[t.WorldSpace=2]="WorldSpace",t[t.Undefined=-1]="Undefined",t))(w2||{});const PR=tA("debuguilayout"),y2=class extends Ad{constructor(){super(...arguments),n(this,"_renderOnTop"),n(this,"_depthWrite",!1),n(this,"_doubleSided",!0),n(this,"_castShadows",!1),n(this,"_receiveShadows",!1),n(this,"_renderMode",-1),n(this,"_rootCanvas"),n(this,"_scaleFactor",1),n(this,"worldCamera"),n(this,"planeDistance",-1),n(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),n(this,"previousParent",null),n(this,"_lastMatrixWorld",null),n(this,"_rectTransforms",[]),n(this,"_layoutGroups",new Map),n(this,"_receivers",[]),n(this,"onBeforeRenderRoutine",()=>{var t,A,e,i;if(this.previousParent=this.gameObject.parent,((t=this.context.xr)!=null&&t.isVR||(A=this.context.xr)!=null&&A.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Xo.ensureUpdateMeshUI(kx,this.context))}),n(this,"onAfterRenderRoutine",()=>{var t,A,e,i,g;if(((t=this.context.xr)!=null&&t.isVR||(A=this.context.xr)!=null&&A.isPassThrough)&&this.screenspace){(e=this.previousParent)==null||e.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const s=this.context.mainCamera;s?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const I=this.context.renderer.autoClear,o=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Xo.ensureUpdateMeshUI(kx,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=I,this.context.renderer.autoClearColor=o,this.previousParent.add(this.gameObject)}(g=this._lastMatrixWorld)==null||g.copy(this.gameObject.matrixWorld)}),n(this,"_updateRenderSettingsRoutine"),n(this,"_activeRenderMode",-1),n(this,"_lastWidth",-1),n(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(t){t!==this._renderOnTop&&(this._renderOnTop=t,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(t){this._depthWrite!==t&&(this._depthWrite=t,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(t){this._doubleSided!==t&&(this._doubleSided=t,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(t){this._castShadows!==t&&(this._castShadows=t,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(t){this._receiveShadows!==t&&(this._receiveShadows=t,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode!==t&&(this._renderMode=t,this.onRenderSettingsChanged())}set rootCanvas(t){this._rootCanvas instanceof y2||(this._rootCanvas=t)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(t){this._scaleFactor=t}awake(){var t;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,PR&&console.log("Canvas.Awake()",((t=this.previousParent)==null?void 0:t.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new MA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);t!==-1&&this.context.pre_render_callbacks.splice(t,1);const A=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);A!==-1&&this.context.post_render_callbacks.splice(A,1)}registerTransform(t){this._rectTransforms.push(t)}unregisterTransform(t){const A=this._rectTransforms.indexOf(t);A!==-1&&this._rectTransforms.splice(A,1)}registerLayoutGroup(t){const A=t.gameObject;this._layoutGroups.set(A,t)}unregisterLayoutGroup(t){const A=t.gameObject;this._layoutGroups.delete(A)}registerEventReceiver(t){this._receivers.push(t)}unregisterEventReceiver(t){const A=this._receivers.indexOf(t);A!==-1&&this._receivers.splice(A,1)}async onEnterXR(t){this.screenspace?(t.xr.isVR||t.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await Eq(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(t){this.screenspace&&(t.xr.isVR||t.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var t;for(const A of this._receivers)(t=A.onBeforeCanvasRender)==null||t.call(A,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new MA);const t=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);PR&&t&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const A=!1;for(const e of this._rectTransforms){t&&e.markDirty();let i=this._layoutGroups.get(e.gameObject);e.isDirty&&!i&&(i=e.gameObject.getComponentInParent(Do)),(e.isDirty||i!=null&&i.isDirty)&&(PR&&!A&&console.log("CANVAS UPDATE ### "+e.name+" ##################################### "+this.context.time.frame),i?.updateLayout(),e.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ot.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Fy(this.shadowComponent,this);for(const t of CA.getComponentsInChildren(this.gameObject,_s))Fy(t.shadowComponent,this)}}onUpdateRenderMode(t=!1){if(!t&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let A=this.context.mainCameraComponent,e=10;switch(A&&A.nearClipPlane>0&&A.farClipPlane>0&&(e=Ae.lerp(A.nearClipPlane,A.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(A=this.worldCamera),this.planeDistance>0&&(e=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!A)return;const i=e+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const g=this.gameObject.getComponent(FI);let I=!1;g.sizeDelta.x!==this.context.domWidth&&(I=!0),g.sizeDelta.y!==this.context.domHeight&&(I=!0);const o=A.fieldOfView*Math.PI/180,s=2*Math.tan(o/2)*Math.abs(i);this.gameObject.scale.x=s/this.context.domHeight,this.gameObject.scale.y=s/this.context.domHeight,this.gameObject.scale.z=.01,I&&(g.sizeDelta.x=this.context.domWidth,g.sizeDelta.y=this.context.domHeight,g?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Lg=y2;dC([w()],Lg.prototype,"renderOnTop",1),dC([w()],Lg.prototype,"depthWrite",1),dC([w()],Lg.prototype,"doubleSided",1),dC([w()],Lg.prototype,"castShadows",1),dC([w()],Lg.prototype,"receiveShadows",1),dC([w()],Lg.prototype,"renderMode",1),dC([w(Lg)],Lg.prototype,"rootCanvas",1),dC([w()],Lg.prototype,"scaleFactor",1),dC([w(xt)],Lg.prototype,"worldCamera",2),dC([w()],Lg.prototype,"planeDistance",2);var AoA=Object.defineProperty,eoA=Object.getOwnPropertyDescriptor,jR=(t,A,e,i)=>{for(var g=i>1?void 0:i?eoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&AoA(A,e,g),g};class Tn extends FA{constructor(){super(...arguments),n(this,"_alpha",1),n(this,"interactable",!0),n(this,"blocksRaycasts",!0),n(this,"_isDirty",!1),n(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ot.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const A of CA.getComponentsInChildren(this.gameObject,_s,this._buffer)){const e=A;e.setAlphaFactor&&e.setAlphaFactor(this._alpha)}}}jR([w()],Tn.prototype,"alpha",1),jR([w()],Tn.prototype,"interactable",2),jR([w()],Tn.prototype,"blocksRaycasts",2);var toA=Object.defineProperty,ioA=Object.getOwnPropertyDescriptor,ni=(t,A,e,i)=>{for(var g=i>1?void 0:i?ioA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&toA(A,e,g),g};const S2=tA("debugusdzbehaviours");function md(t){t&&(t.getComponentInParent(ed)||(re()&&console.warn("Create Raycaster on "+t.name+" because no raycaster was found in the hierarchy"),t.addNewComponent(Qo)))}class KB extends FA{constructor(){super(...arguments),n(this,"object"),n(this,"target"),n(this,"duration",1),n(this,"relativeMotion",!1),n(this,"coroutine",null),n(this,"targetPos",new S),n(this,"targetRot",new RA),n(this,"targetScale",new S)}start(){md(this.gameObject)}onPointerClick(A){A.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const A=Fe(this.object).clone(),e=Fe(this.target).clone(),i=Gt(this.object).clone(),g=Gt(this.target).clone(),I=Tt(this.object).clone(),o=Tt(this.target).clone(),s=A.distanceTo(e),C=i.angleTo(g),a=I.distanceTo(o);if(s<.01&&C<.01&&a<.01){iI(this.object,e),_o(this.object,g),Wc(this.object,o),this.coroutine=null;return}let r=0,B=0;for(;r<1;)r+=this.context.time.deltaTime/this.duration,r>1&&(r=1),B=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,this.targetPos.lerpVectors(A,e,B),this.targetRot.slerpQuaternions(i,g,B),this.targetScale.lerpVectors(I,o,B),iI(this.object,this.targetPos),_o(this.object,this.targetRot),Wc(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const A=this.object.position.clone(),e=this.object.quaternion.clone(),i=this.object.scale.clone(),g=this.target.position.clone(),I=this.target.quaternion.clone(),o=this.target.scale.clone();g.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(g),this.targetRot.copy(this.object.quaternion).multiply(I),this.targetScale.copy(this.object.scale).multiply(o);let s=0,C=0;for(;s<1;)s+=this.context.time.deltaTime/this.duration,s>1&&(s=1),C=s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,this.object.position.lerpVectors(A,this.targetPos,C),this.object.quaternion.slerpQuaternions(e,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(A){var e;if(this.target&&this.object&&this.gameObject){const i=new mg("Move to "+((e=this.target)==null?void 0:e.name),kg.tapTrigger(this.gameObject),rt.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));A.addBehavior(i)}}}ni([w(uA)],KB.prototype,"object",2),ni([w(uA)],KB.prototype,"target",2),ni([w()],KB.prototype,"duration",2),ni([w()],KB.prototype,"relativeMotion",2);var A0;const ya=(A0=class extends FA{constructor(){super(...arguments),n(this,"materialToSwitch"),n(this,"variantMaterial"),n(this,"fadeDuration",0),n(this,"_objectsWithThisMaterial",null),n(this,"selfModel"),n(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,md(this.gameObject)}onPointerClick(t){if(t.use(),!!this.variantMaterial)for(let A=0;A<this.objectsWithThisMaterial.length;A++){const e=this.objectsWithThisMaterial[A];e.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(t=>{if(t instanceof hA)if(Array.isArray(t.material)){for(const A of t.material)if(A===this.materialToSwitch){this.objectsWithThisMaterial.push(t);break}}else t.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(t)}),this._objectsWithThisMaterial)}async beforeCreateDocument(t,A){this.targetModels=[],ya._materialTriggersPerId={},ya.variantSwitchIndex=0,this.materialToSwitch&&await Jt.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Jt.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(t,A,e){this.objectsWithThisMaterial.find(i=>i.uuid===A.uuid)&&this.targetModels.push(A),this.gameObject.uuid===A.uuid&&(this.selfModel=A,this.materialToSwitch&&(ya._materialTriggersPerId[this.materialToSwitch.uuid]||(ya._materialTriggersPerId[this.materialToSwitch.uuid]=[]),ya._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(t,A){if(!this.materialToSwitch)return;const e=ya._materialTriggersPerId[this.materialToSwitch.uuid];if(e){const i={};for(const g of e){const I=g.createVariants();I&&I.length>0&&(i[g.selfModel.uuid]=I)}for(const g of e){const I=[];for(const o in i)o!==g.selfModel.uuid&&I.push(...i[o]);g.createAndAttachBehaviors(t,i[g.selfModel.uuid],I)}}delete ya._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(t,A,e){const i=[],g=[],I=Math.max(0,this.fadeDuration);g.push(rt.fadeAction([...this.targetModels,...e],I,!1)),i.push(rt.fadeAction(A,I,!1)),g.push(rt.fadeAction(A,I,!0)),t.addBehavior(new mg("Select_"+this.selfModel.name,kg.tapTrigger(this.selfModel),rt.parallel(...g))),t.addBehavior(new mg("StartHidden_"+this.selfModel.name,kg.sceneStartTrigger(),rt.parallel(...i)))}createVariants(){if(!this.variantMaterial)return null;const t=[];for(const A of this.targetModels){const e=A.clone();e.name+=" variant_"+this.variantMaterial.name+"_"+ya.variantSwitchIndex++,e.name=e.name.replace(/\s/g,"_"),e.material=this.variantMaterial,e.geometry=A.geometry,e.matrix=A.matrix,(!A.parent||!A.parent.isEmpty())&&Oo.createEmptyParent(A),A.parent&&A.parent.add(e),t.push(e)}return t}},n(A0,"_materialTriggersPerId",{}),n(A0,"variantSwitchIndex",0),A0);let eh=ya;ni([w(Re)],eh.prototype,"materialToSwitch",2),ni([w(Re)],eh.prototype,"variantMaterial",2),ni([w()],eh.prototype,"fadeDuration",2);var th;const ri=(th=class extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"toggleOnClick",!1),n(this,"targetState",!0),n(this,"hideSelf",!0),n(this,"selfModel"),n(this,"selfModelClone"),n(this,"targetModel"),n(this,"toggleModel"),n(this,"stateBeforeCreatingDocument",!1),n(this,"targetStateBeforeCreatingDocument",!1)}start(){md(this.gameObject)}onPointerClick(t){t.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A,this.selfModelClone=A.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ri.wasVisible]===void 0&&(this.gameObject[ri.wasVisible]=this.gameObject.activeSelf),this.target[ri.wasVisible]===void 0&&(this.target[ri.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ri.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ri.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(t,A){if(!this.target)return;this.targetModel=A.document.findById(this.target.uuid);const e=this.selfModel;if(this.selfModel&&this.targetModel){let i=this.selfModel,g=this.targetState;if(this.toggleOnClick)if(g=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&FL.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ri.toggleClone]){const s=this.selfModelClone.clone();s.matrix.identity(),s.name+="_toggle"+ri.clonedToggleIndex++,e.add(s),this.gameObject[ri.toggleClone]=s,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const o=this.gameObject[ri.toggleClone];if(!this.gameObject[ri.reverseToggleClone]){const s=this.selfModelClone.clone();s.matrix.identity(),s.name+="_toggleReverse"+ri.clonedToggleIndex++,e.add(s),this.gameObject[ri.reverseToggleClone]=s}this.toggleModel=this.gameObject[ri.reverseToggleClone],(!this.toggleModel.geometry||!o.geometry)&&console.error("triggers without childs and without geometry won't work!",this,e.geometry),i=o,e.geometry=null,e.material=null}if(this.toggleModel){if(this.toggleOnClick){const o=[];o.push(rt.fadeAction(i,0,!1)),o.push(rt.fadeAction(this.toggleModel,0,!0)),o.push(rt.fadeAction(this.targetModel,0,g)),t.addBehavior(new mg("Toggle_"+i.name+"_toggleTo"+(g?"On":"Off"),kg.tapTrigger(i),rt.parallel(...o)));const s=[];s.push(rt.fadeAction(this.toggleModel,0,!1)),s.push(rt.fadeAction(i,0,!0)),s.push(rt.fadeAction(this.targetModel,0,!g)),t.addBehavior(new mg("Toggle_"+i.name+"_toggleTo"+(g?"Off":"On"),kg.tapTrigger(this.toggleModel),rt.parallel(...s)))}}else{const o=[];this.hideSelf&&o.push(rt.fadeAction(i,0,!1)),o.push(rt.fadeAction(this.targetModel,0,g)),t.addBehavior(new mg("Toggle_"+i.name+"_toggleTo"+(g?"On":"Off"),kg.tapTrigger(i),rt.parallel(...o)))}const I=new Array;this.targetStateBeforeCreatingDocument||I.push(this.targetModel),this.stateBeforeCreatingDocument||I.push(e),this.toggleModel&&I.push(this.toggleModel),t.addBehavior(new mg("HideOnStart_"+this.gameObject.name,kg.sceneStartTrigger(),rt.fadeAction(I,0,!1)))}}afterSerialize(t,A){this.gameObject[ri.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ri.wasVisible],delete this.gameObject[ri.wasVisible]),this.target&&this.target[ri.wasVisible]!==void 0&&(this.target.visible=this.target[ri.wasVisible],delete this.target[ri.wasVisible]),delete this.gameObject[ri.toggleClone],delete this.gameObject[ri.reverseToggleClone]}},n(th,"clonedToggleIndex",0),n(th,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),n(th,"toggleClone",Symbol("clone for toggling")),n(th,"reverseToggleClone",Symbol("clone for reverse toggling")),th);let JB=ri;ni([w(uA)],JB.prototype,"target",2),ni([w()],JB.prototype,"toggleOnClick",2),ni([w()],JB.prototype,"targetState",2),ni([w()],JB.prototype,"hideSelf",2);class WR extends FA{start(){this.gameObject.visible=!1}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&A.addBehavior(new mg("HideOnStart_"+this.gameObject.name,kg.sceneStartTrigger(),rt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class ih extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"duration",.5),n(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(A,e,i){if(this.target&&e.uuid===this.gameObject.uuid){const g=new mg("emphasize "+this.name,kg.tapTrigger(this.gameObject),rt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));A.addBehavior(g)}}afterCreateDocument(A,e){}}ni([w()],ih.prototype,"target",2),ni([w()],ih.prototype,"duration",2),ni([w()],ih.prototype,"motionType",2);class On extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"clip",""),n(this,"toggleOnClick",!1)}start(){md(this.gameObject)}ensureAudioSource(){if(!this.target){const A=this.gameObject.addNewComponent(ai);A&&(this.target=A,A.spatialBlend=1,A.volume=1,A.loop=!1)}}onPointerClick(A){var e;A.use(),!(!((e=this.target)!=null&&e.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(A,e,i){if(!(!this.target&&!this.clip)&&e.uuid===this.gameObject.uuid){const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=this.target?this.target.gameObject:this.gameObject,o=nr.getName(g),s=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let a=!1;if(this.gameObject.traverse(r=>{r instanceof hA&&r.visible&&(a=!0)}),a=!0,a){let r=rt.playAudioAction(I,"audio/"+o,"play",s,C);this.toggleOnClick&&(r.multiplePerformOperation="stop"),this.target&&this.target.loop&&(r=rt.sequence(r).makeLooping());const B=new mg("playAudio "+this.name,kg.tapTrigger(this.gameObject),r);A.addBehavior(B)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let r=rt.playAudioAction(I,"audio/"+o,"play",s,C);this.target.loop&&(r=rt.sequence(r).makeLooping());const B=new mg("playAudioOnStart"+(this.name?"_"+this.name:""),kg.sceneStartTrigger(),r);A.addBehavior(B)}}}async afterSerialize(A,e){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i||typeof i!="string")return;const g="audio/"+nr.getName(i);if(e.files[g])return;const I=await(await(await fetch(i)).blob()).arrayBuffer(),o=new Uint8Array(I);e.files[g]=o}}ni([w(ai)],On.prototype,"target",2),ni([w(URL)],On.prototype,"clip",2),ni([w()],On.prototype,"toggleOnClick",2);var e0;const Pn=(e0=class extends FA{constructor(){super(...arguments),n(this,"animator"),n(this,"stateName"),n(this,"trigger","tap"),n(this,"animation"),n(this,"selfModel"),n(this,"stateAnimationModel"),n(this,"animationSequence",new Array),n(this,"animationLoopAfterSequence",new Array)}get target(){var t,A;return((t=this.animator)==null?void 0:t.gameObject)||((A=this.animation)==null?void 0:A.gameObject)}start(){md(this.gameObject)}onPointerClick(t){var A;t.use(),this.target&&this.stateName&&((A=this.animator)==null||A.play(this.stateName,0,0,.1))}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A)}afterSerialize(){if(Pn.rootsWithExclusivePlayback.size>1){const t='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';re()&&Ci(t),console.warn(t,...Pn.rootsWithExclusivePlayback)}Pn.animationActions=[],Pn.rootsWithExclusivePlayback=new Set}afterCreateDocument(t,A){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const e=A.document,i=A.extensions.find(o=>o instanceof Bd);if(!i)return;const g=i.getClipCount(this.target)>1;g&&(re()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+i.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Pn.rootsWithExclusivePlayback.add(this.target));const I=(o,s)=>{let C=Pn.animationActions.find(a=>a.affectedObjects==o&&a.start==s.start&&a.duration==s.duration);return C||(C=rt.startAnimationAction(o,s.start,s.duration),Pn.animationActions.push(C)),C};e.traverse(o=>{var s,C;if(o.uuid===((s=this.target)==null?void 0:s.uuid)){const a=rt.sequence();if(this.animationSequence!==void 0)for(const B of this.animationSequence)a.addAction(I(o,B));if(this.animationLoopAfterSequence!==void 0){const B=a.actions.length==0?a:rt.sequence();for(const Q of this.animationLoopAfterSequence)B.addAction(I(o,Q));B.makeLooping(),a!==B&&a.addAction(B)}const r=new mg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?kg.tapTrigger(this.selfModel):kg.sceneStartTrigger(),a);g&&r.makeExclusive(!0),t.addBehavior(r)}})}createAnimation(t,A,e){var i,g,I,o;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=A,this.animation&&this.animation.clip){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const Q=t.registerAnimation(this.target,this.animation.clip);Q&&this.animationLoopAfterSequence.push(Q);return}const s=(i=this.animator)==null?void 0:i.runtimeAnimatorController;let C=s?.findState(this.stateName),a=[],r=[];if(s&&C){const Q=new Array;Q.push(C);let E=!1;for(;Q.length<100;){if(!C||C===null||!C.transitions||C.transitions.length===0){(g=C.motion)!=null&&g.isLooping&&(E=!0);break}const h=C.transitions.find(l=>l.conditions.length===0),d=h?s.getState(h.destinationState,0):null;if(d&&Q.includes(d)){C=d,E=!0;break}else if(h){if(C=d,!C)break;Q.push(C)}else{E=((I=C.motion)==null?void 0:I.isLooping)??!1;break}}if(E&&C){const h=Q.indexOf(C);a=Q.slice(0,h),r=Q.slice(h),S2&&console.log("found loop from "+this.stateName,"states until loop",a,"states looping",r)}else a=Q,r=[],S2&&console.log("found no loop from "+this.stateName,"states",a)}if(a=a.filter(Q=>{var E,h,d;return((E=Q.motion)==null?void 0:E.clip)&&((d=(h=Q.motion)==null?void 0:h.clip.tracks)==null?void 0:d.length)>0}),r=r.filter(Q=>{var E,h,d;return((E=Q.motion)==null?void 0:E.clip)&&((d=(h=Q.motion)==null?void 0:h.clip.tracks)==null?void 0:d.length)>0}),a.length===0&&r.length===0){console.warn("No clips found for state "+this.stateName+" on "+((o=this.animator)==null?void 0:o.name)+", can't export animation data");return}const B=(Q,E)=>{var h,d,l;if(!this.target)return;if(!((h=Q.motion)!=null&&h.clip)){console.warn("No clip found for state "+Q.name+" on "+((d=this.animator)==null?void 0:d.name)+", can't export animation data");return}const c=t.registerAnimation(this.target,Q.motion.clip);c?E.push(c):console.warn("Couldn't register animation for state "+Q.name+" on "+((l=this.animator)==null?void 0:l.name))};if(a.length>0){this.animationSequence=new Array;for(const Q of a)B(Q,this.animationSequence)}if(r.length>0){this.animationLoopAfterSequence=new Array;for(const Q of r)B(Q,this.animationLoopAfterSequence)}}},n(e0,"animationActions",[]),n(e0,"rootsWithExclusivePlayback",new Set),e0);let vB=Pn;ni([w(bg)],vB.prototype,"animator",2),ni([w()],vB.prototype,"stateName",2);class gh extends FA{constructor(){super(...arguments),n(this,"target")}getType(){}getDuration(){}}ni([w(uA)],gh.prototype,"target",2);class kd extends FA{constructor(){super(...arguments),n(this,"target")}}ni([w(gh)],kd.prototype,"target",2);class Gd extends gh{constructor(){super(...arguments),n(this,"type",1),n(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ni([w()],Gd.prototype,"type",2),ni([w()],Gd.prototype,"duration",2);class ZR extends kd{}var goA=Object.defineProperty,IoA=Object.getOwnPropertyDescriptor,Sa=(t,A,e,i)=>{for(var g=i>1?void 0:i?IoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&goA(A,e,g),g};const f2=tA("debugcharactercontroller");class bB extends FA{constructor(){super(...arguments),n(this,"center",new S(0,0,0)),n(this,"radius",.5),n(this,"height",2),n(this,"_rigidbody",null),n(this,"_activeGroundCollisions"),n(this,"_contactVelocity",new S)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ut),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Ut)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const A=this.rigidbody;let e=this.gameObject.getComponent(Da);e||(e=this.gameObject.addNewComponent(Da)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height;const i=new S(0,0,1),g=new S(1,0,0),I=new S(0,1,0),o=this.gameObject.getWorldDirection(new S);o.y=0;const s=g.dot(o)<0?-1:1,C=i.angleTo(o)*s;this.gameObject.setRotationFromAxisAngle(I,C),A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}onCollisionEnter(A){(A.contacts.length==0||A.contacts.some(e=>e.normal.y>.2))&&(this._activeGroundCollisions.add(A),f2&&console.log(`Collision(${this._activeGroundCollisions.size}): ${A.contacts.map(e=>e.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(A){this._activeGroundCollisions.delete(A),f2&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var A;this._contactVelocity.set(0,0,0);for(const e of this._activeGroundCollisions){const i=(A=this.context.physics.engine)==null?void 0:A.getLinearVelocity(e.collider);i&&(this._contactVelocity.x+=i.x,this._contactVelocity.y+=i.y,this._contactVelocity.z+=i.z)}return this._contactVelocity}}Sa([w(S)],bB.prototype,"center",2),Sa([w()],bB.prototype,"radius",2),Sa([w()],bB.prototype,"height",2);class fa extends FA{constructor(){super(...arguments),n(this,"controller"),n(this,"movementSpeed",2),n(this,"rotationSpeed",2),n(this,"jumpForce",1),n(this,"doubleJumpForce",2),n(this,"animator"),n(this,"lookForward",!0),n(this,"lookInput",new eA(0,0)),n(this,"moveInput",new eA(0,0)),n(this,"jumpInput",!1),n(this,"_currentSpeed",new S(0,0,0)),n(this,"_currentAngularSpeed",new S(0,0,0)),n(this,"_temp",new S(0,0,0)),n(this,"_jumpCount",0),n(this,"_currentRotation"),n(this,"_raycastOptions",new Zo)}awake(){this._currentRotation=new RA}update(){const A=this.context.input;A.isKeyPressed("KeyW")?this.moveInput.y+=1:A.isKeyPressed("KeyS")&&(this.moveInput.y-=1),A.isKeyPressed("KeyD")?this.lookInput.x+=1:A.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=A.isKeyDown("Space"))}move(A){this.moveInput.add(A)}look(A){this.lookInput.add(A)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(A,e,i){var g,I,o,s,C,a,r,B,Q,E,h;if((g=this.controller)!=null&&g.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((I=this.animator)==null||I.setBool("doubleJump",!1))),this._currentSpeed.z+=A.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",A.length()>.01),(C=this.animator)==null||C.setBool("jumping",((s=this.controller)==null?void 0:s.isGrounded)===!0&&i),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=Ae.toRadians(-e.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const d=this.context.mainCameraComponent.forward;d.y=0,d.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),d),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&i&&this.jumpForce>0){let d=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((r=this.controller)!=null&&r.isGrounded)&&this._jumpCount===1&&(d=!0,(B=this.animator)==null||B.setBool("doubleJump",!0)),d){this._jumpCount+=1;const l=this.controller.rigidbody,c=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new S(0,1,0).multiplyScalar(c))}}if(this.controller){const d=(Q=this.controller)==null?void 0:Q.rigidbody.getVelocity().y;if(d<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new HI),this._raycastOptions.ray.origin.copy(Fe(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const c=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(c.length&&c[0].distance>2||d<-10)&&((E=this.animator)==null||E.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}Sa([w(bB)],fa.prototype,"controller",2),Sa([w()],fa.prototype,"movementSpeed",2),Sa([w()],fa.prototype,"rotationSpeed",2),Sa([w()],fa.prototype,"jumpForce",2),Sa([w()],fa.prototype,"doubleJumpForce",2),Sa([w(bg)],fa.prototype,"animator",2);var ooA=Object.defineProperty,soA=Object.getOwnPropertyDescriptor,CoA=(t,A,e,i)=>{for(var g=i>1?void 0:i?soA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ooA(A,e,g),g};class Md extends aI{constructor(){super(...arguments),n(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const A=new NY;return A.offset=new eA(0,0),A.radialModulation=!0,A.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=e=>{A.offset.x=-e,A.offset.y=e},A}}CoA([w(Ne)],Md.prototype,"intensity",2),As("ChromaticAberration",Md);const Ud=new he;Ud.setAttribute("position",new ee(new Float32Array([-1,-1,3,-1,-1,3]),2)),Ud.setAttribute("uv",new ee(new Float32Array([0,0,2,0,0,2]),2)),Ud.boundingSphere=new Di,Ud.computeBoundingSphere=function(){};const aoA=new jC;class qB{constructor(A){this._mesh=new hA(Ud,A),this._mesh.frustumCulled=!1}render(A){A.render(this._mesh,aoA)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const noA={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new MA},viewMat:{value:new MA},projViewMat:{value:new MA},projectionMatrixInv:{value:new MA},viewMatrixInv:{value:new MA},cameraPos:{value:new S},resolution:{value:new eA},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|
|
5512
5512
|
varying vec2 vUv;
|
|
5513
5513
|
void main() {
|
|
@@ -6951,7 +6951,7 @@ void main() {
|
|
|
6951
6951
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
6952
6952
|
|
|
6953
6953
|
#include <fog_vertex>
|
|
6954
|
-
}`);new S(0,0,1);var faA=function(t){Dh(e,t);var A=wh(e);function e(i){var g;return ye(this,e),g=A.call(this,i),z(it(g),"positionBuffer",void 0),z(it(g),"previousBuffer",void 0),z(it(g),"nextBuffer",void 0),z(it(g),"uvBuffer",void 0),z(it(g),"sideBuffer",void 0),z(it(g),"widthBuffer",void 0),z(it(g),"colorBuffer",void 0),z(it(g),"indexBuffer",void 0),z(it(g),"vector_",new S),z(it(g),"vector2_",new S),z(it(g),"vector3_",new S),z(it(g),"quaternion_",new RA),g.maxParticles=1e4,g.setupBuffers(),g.rebuildMaterial(),g}return Se(e,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new he,this.indexBuffer=new ee(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(zg),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(zg),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(zg),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(zg),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ee(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(zg),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ee(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(zg),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ee(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(zg),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ee(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(zg),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(i){for(;i>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var i={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new eA(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new eA(1,1)}},g={};if(g.USE_UV="",g.USE_COLOR_ALPHA="",this.settings.material.map&&(g.USE_MAP="",g.MAP_UV=XN(this.settings.material.map.channel),i.map=new SA(this.settings.material.map),i.mapTransform=new SA(new Je().copy(this.settings.material.map.matrix))),this.settings.renderMode===ie.Trail)this.material=new Me({uniforms:i,defines:g,vertexShader:SaA,fragmentShader:yaA,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||cr});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var i=this,g=0,I=0,o=0;this.systems.forEach(function(s){for(var C=0;C<s.particleNum;C++)o+=s.particles[C].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(s){var C=i.quaternion_,a=i.vector2_,r=i.vector3_;s.emitter.matrixWorld.decompose(a,C,r);for(var B=s.particles,Q=s.particleNum,E=i.settings.uTileCount,h=i.settings.vTileCount,d=1/E,l=1/h,c=0;c<Q;c++){var p=B[c],u=p.uvTile%h,D=Math.floor(p.uvTile/h),k=p.previous.values(),U=k.next(),M=U.value,G=M;U.done||(U=k.next());var K=void 0;U.value!==void 0?K=U.value:K=G;for(var f=0;f<p.previous.length;f++,g+=2){if(i.positionBuffer.setXYZ(g,G.position.x,G.position.y,G.position.z),i.positionBuffer.setXYZ(g+1,G.position.x,G.position.y,G.position.z),s.worldSpace?(i.positionBuffer.setXYZ(g,G.position.x,G.position.y,G.position.z),i.positionBuffer.setXYZ(g+1,G.position.x,G.position.y,G.position.z)):(p.parentMatrix?i.vector_.copy(G.position).applyMatrix4(p.parentMatrix):i.vector_.copy(G.position).applyMatrix4(s.emitter.matrixWorld),i.positionBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.positionBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),s.worldSpace?(i.previousBuffer.setXYZ(g,M.position.x,M.position.y,M.position.z),i.previousBuffer.setXYZ(g+1,M.position.x,M.position.y,M.position.z)):(p.parentMatrix?i.vector_.copy(M.position).applyMatrix4(p.parentMatrix):i.vector_.copy(M.position).applyMatrix4(s.emitter.matrixWorld),i.previousBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.previousBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),s.worldSpace?(i.nextBuffer.setXYZ(g,K.position.x,K.position.y,K.position.z),i.nextBuffer.setXYZ(g+1,K.position.x,K.position.y,K.position.z)):(p.parentMatrix?i.vector_.copy(K.position).applyMatrix4(p.parentMatrix):i.vector_.copy(K.position).applyMatrix4(s.emitter.matrixWorld),i.nextBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.nextBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),i.sideBuffer.setX(g,-1),i.sideBuffer.setX(g+1,1),s.worldSpace)i.widthBuffer.setX(g,G.size),i.widthBuffer.setX(g+1,G.size);else if(p.parentMatrix)i.widthBuffer.setX(g,G.size),i.widthBuffer.setX(g+1,G.size);else{var N=(Math.abs(r.x)+Math.abs(r.y)+Math.abs(r.z))/3;i.widthBuffer.setX(g,G.size*N),i.widthBuffer.setX(g+1,G.size*N)}i.uvBuffer.setXY(g,(f/p.previous.length+u)*d,(h-D-1)*l),i.uvBuffer.setXY(g+1,(f/p.previous.length+u)*d,(h-D)*l),i.colorBuffer.setXYZW(g,G.color.x,G.color.y,G.color.z,G.color.w),i.colorBuffer.setXYZW(g+1,G.color.x,G.color.y,G.color.z,G.color.w),f+1<p.previous.length&&(i.indexBuffer.setX(I*3,g),i.indexBuffer.setX(I*3+1,g+1),i.indexBuffer.setX(I*3+2,g+2),I++,i.indexBuffer.setX(I*3,g+2),i.indexBuffer.setX(I*3+1,g+1),i.indexBuffer.setX(I*3+2,g+3),I++),M=G,G=K,U.done||(U=k.next(),U.value!==void 0&&(K=U.value))}}}),this.positionBuffer.updateRange.count=g*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=g*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=g*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=g,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=g,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=g*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=g*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=I*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,I*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),e}(zO),maA=function(t){Dh(e,t);var A=wh(e);function e(){var i;return ye(this,e),i=A.call(this),z(it(i),"batches",[]),z(it(i),"systemToBatchIndex",new Map),z(it(i),"type","BatchedRenderer"),i}return Se(e,[{key:"addSystem",value:function(i){i._renderer=this;for(var g=i.getRendererSettings(),I=0;I<this.batches.length;I++)if(e.equals(this.batches[I].settings,g)){this.batches[I].addSystem(i),this.systemToBatchIndex.set(i,I);return}var o;switch(g.renderMode){case ie.Trail:o=new faA(g);break;case ie.Mesh:case ie.BillBoard:case ie.VerticalBillBoard:case ie.HorizontalBillBoard:case ie.StretchedBillBoard:o=new waA(g);break}o.addSystem(i),this.batches.push(o),this.systemToBatchIndex.set(i,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(i){var g=this.systemToBatchIndex.get(i);g!=null&&(this.batches[g].removeSystem(i),this.systemToBatchIndex.delete(i))}},{key:"updateSystem",value:function(i){this.deleteSystem(i),this.addSystem(i)}},{key:"update",value:function(i){this.systemToBatchIndex.forEach(function(I,o){o.update(i)});for(var g=0;g<this.batches.length;g++)this.batches[g].update()}}],[{key:"equals",value:function(i,g){return i.material.side===g.material.side&&i.material.blending===g.material.blending&&i.material.transparent===g.material.transparent&&i.material.type===g.material.type&&i.material.alphaTest===g.material.alphaTest&&i.material.map===g.material.map&&i.renderMode===g.renderMode&&i.uTileCount===g.uTileCount&&i.vTileCount===g.vTileCount&&i.instancingGeometry===g.instancingGeometry&&i.renderOrder===g.renderOrder&&i.layers.mask===g.layers.mask}}]),e}(uA),kaA=maA,$O=function(){function t(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new S;ye(this,t),z(this,"locations",[]),this.scaleX=A,this.scaleY=e,this.position=i}return Se(t,[{key:"transform",value:function(A,e){A.x=this.locations[e%this.locations.length].x*this.scaleX+this.position.x,A.y=this.locations[e%this.locations.length].y*this.scaleY+this.position.y,A.z=this.position.z}},{key:"clone",value:function(){var A=new t(this.scaleX,this.scaleY,this.position.clone());return A.locations=this.locations.map(function(e){return e.clone()}),A}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(A){return{x:A.x,y:A.y}})}}},{key:"fromImage",value:function(A,e){var i=document.createElement("canvas");i.width=A.width,i.height=A.height;var g=i.getContext("2d");if(g){g.drawImage(A,0,0);var I=g.getImageData(0,0,i.width,i.height,{colorSpace:"srgb"});i.remove(),this.locations.length=0;for(var o=0;o<I.height;o++)for(var s=0;s<I.width;s++)I.data[(o*I.width+s)*4+3]>e&&this.locations.push(new eA(s,I.height-o))}}}],[{key:"fromJSON",value:function(A){var e=new t(A.scaleX,A.scaleY,new S(A.position[0],A.position[1],A.position[2]));return e.locations=A.locations.map(function(i){return new eA(i.x,i.y)}),e}}]),t}();function GaA(t){switch(t.type){case"TextureSequencer":return $O.fromJSON(t);default:return new $O}}var MaA=function(){function t(A){ye(this,t),z(this,"type","ApplySequences"),z(this,"sequencers",[]),z(this,"time",0),z(this,"index",0),z(this,"pCount",0),z(this,"delay",void 0),z(this,"tempV",new S),this.delay=A}return Se(t,[{key:"initialize",value:function(A){A.id=this.pCount,A.dst=new S,A.begin=new S,A.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(A,e){var i=this.sequencers[this.index],g=A.id*this.delay;this.time>=i[0].a+g&&this.time<=i[0].b+g?(A.inMotion||(A.inMotion=!0,A.begin.copy(A.position),i[1].transform(A.dst,A.id)),A.position.lerpVectors(A.begin,A.dst,t.BEZIER.genValue((this.time-i[0].a-g)/(i[0].b-i[0].a)))):this.time>i[0].b+g&&(A.inMotion=!1)}},{key:"frameUpdate",value:function(A){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=A}},{key:"appendSequencer",value:function(A,e){this.sequencers.push([A,e])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(A){var e=yh(A,2),i=e[0],g=e[1];return{range:i.toJSON(),sequencer:g.toJSON()}})}}},{key:"clone",value:function(){var A=new t(this.delay);return A.sequencers=this.sequencers.map(function(e){return[e[0].clone(),e[1].clone()]}),A}}],[{key:"fromJSON",value:function(A){var e=new t(A.delay);return A.sequencers.forEach(function(i){e.sequencers.push([Lt(i.range),GaA(i.sequencer)])}),e}}]),t}();z(MaA,"BEZIER",new TN(0,0,1,1));var EA=function(t){return t[t.Number=0]="Number",t[t.Vec2=1]="Vec2",t[t.Vec3=2]="Vec3",t[t.Vec4=3]="Vec4",t[t.Boolean=4]="Boolean",t[t.AnyType=5]="AnyType",t}({}),A1=Se(function t(A,e,i,g){ye(this,t),z(this,"input",void 0),z(this,"inputIndex",void 0),z(this,"output",void 0),z(this,"outputIndex",void 0),this.input=A,this.inputIndex=e,this.input.outputs[e].push(this),this.output=i,this.outputIndex=g,this.output.inputs[g]=this}),UaA=function(){function t(){ye(this,t),z(this,"visited",new Set),z(this,"graph_",void 0),z(this,"context_",void 0),t.Instance=this}return Se(t,[{key:"traverse",value:function(A){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(A.id);for(var e=[],i=0;i<A.inputs.length;i++)if(A.inputs[i]instanceof A1){var g=A.inputs[i].input;this.visited.has(g.id)||this.traverse(g),e.push(g.outputValues[A.inputs[i].inputIndex])}else e.push(A.inputs[i].getValue(this.context_));A.func(this.context_,e,A.outputValues),this.graph_.nodesInOrder.push(A)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var A=this.graph_.nodesInOrder,e=0;e<A.length;e++){for(var i=[],g=A[e],I=0;I<g.inputs.length;I++)if(g.inputs[I]instanceof A1)i.push(g.inputs[I].input.outputValues[g.inputs[I].inputIndex]);else if(g.inputs[I]!==void 0)i.push(g.inputs[I].getValue(this.context_));else throw new Error("miss input for node ".concat(g.id));g.func(this.context_,i,g.outputValues)}}},{key:"run",value:function(A,e){if(this.graph_=A,this.context_=e,A.compiled)this.executeCompiledGraph();else{A.nodesInOrder.length=0,this.visited.clear();for(var i=0;i<A.outputNodes.length;i++){var g=A.outputNodes[i];this.traverse(g)}A.compiled=!0}}}]),t}();z(UaA,"Instance",void 0);var nt=function(){function t(A){ye(this,t),z(this,"name",void 0),z(this,"nodeTypeSignatures",[]),this.name=A}return Se(t,[{key:"addSignature",value:function(A,e,i){this.nodeTypeSignatures.push({inputTypes:A,outputTypes:e,func:i})}}]),t}(),L0=new nt("add");L0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]+e[1]}),L0.addSignature([EA.Vec2,EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].addVectors(e[0],e[1])}),L0.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].addVectors(e[0],e[1])}),L0.addSignature([EA.Vec4,EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].addVectors(e[0],e[1])});var Y0=new nt("sub");Y0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]-e[1]}),Y0.addSignature([EA.Vec2,EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].subVectors(e[0],e[1])}),Y0.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].subVectors(e[0],e[1])}),Y0.addSignature([EA.Vec4,EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].subVectors(e[0],e[1])});var _0=new nt("mul");_0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]*e[1]}),_0.addSignature([EA.Vec2,EA.Number],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])}),_0.addSignature([EA.Vec3,EA.Number],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])}),_0.addSignature([EA.Vec4,EA.Number],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])});var H0=new nt("div");H0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]/e[1]}),H0.addSignature([EA.Vec2,EA.Number],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])}),H0.addSignature([EA.Vec3,EA.Number],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])}),H0.addSignature([EA.Vec4,EA.Number],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])});var RaA=new nt("sin");RaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.sin(e[0])});var NaA=new nt("cos");NaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.cos(e[0])});var FaA=new nt("tan");FaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.tan(e[0])});var KaA=new nt("abs");KaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.abs(e[0])});var JaA=new nt("min");JaA.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.min(e[0],e[1])});var vaA=new nt("max");vaA.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.max(e[0],e[1])});var $N=new nt("dot");$N.addSignature([EA.Vec2,EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])}),$N.addSignature([EA.Vec3,EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])}),$N.addSignature([EA.Vec4,EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])});var baA=new nt("cross");baA.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].crossVectors(e[0],e[1])});var AF=new nt("length");AF.addSignature([EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].length()}),AF.addSignature([EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].length()}),AF.addSignature([EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].length()});var eF=new nt("lengthSq");eF.addSignature([EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()}),eF.addSignature([EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()}),eF.addSignature([EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()});var tF=new nt("normalize");tF.addSignature([EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).normalize()}),tF.addSignature([EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).normalize()}),tF.addSignature([EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).normalize()});var e1=new nt("distance");e1.addSignature([EA.Vec2,EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].distanceTo(e[1])}),e1.addSignature([EA.Vec3,EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].distanceTo(e[1])});var qaA=new nt("and");qaA.addSignature([EA.Boolean,EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]&&e[1]});var xaA=new nt("or");xaA.addSignature([EA.Boolean,EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]||e[1]});var LaA=new nt("not");LaA.addSignature([EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=!e[0]});var T0=new nt("equal");T0.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]===e[1]}),T0.addSignature([EA.Vec2,EA.Vec2],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])}),T0.addSignature([EA.Vec3,EA.Vec3],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])}),T0.addSignature([EA.Vec4,EA.Vec4],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])});var YaA=new nt("lessThan");YaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]<e[1]});var _aA=new nt("greaterThan");_aA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]>e[1]});var HaA=new nt("lessThanOrEqual");HaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]<=e[1]});var TaA=new nt("greaterThanOrEqual");TaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]>=e[1]});var OaA=new nt("if");OaA.addSignature([EA.Boolean,EA.AnyType,EA.AnyType],[EA.AnyType],function(t,A,e,i){i[0]=e[0]?e[1]:e[2]});var PaA=new nt("number");PaA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=A.value});var jaA=new nt("vec2");jaA.addSignature([],[EA.Vec2],function(t,A,e,i){i[0]=A.value});var WaA=new nt("vec3");WaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=A.value});var ZaA=new nt("vec4");ZaA.addSignature([],[EA.Vec4],function(t,A,e,i){i[0]=A.value});var VaA=new nt("bool");VaA.addSignature([],[EA.Boolean],function(t,A,e,i){i[0]=A.value});var zaA=new nt("particlePosition");zaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=t.particle[A.property]});var XaA=new nt("particleVelocity");XaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=t.particle[A.property]});var $aA=new nt("particleRotation");$aA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=t.particle[A.property]});var AnA=new nt("particleAge");AnA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=t.particle[A.property]});var Cp=new nt("output");Cp.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var enA=Object.defineProperty,tnA=Object.getOwnPropertyDescriptor,hi=(t,A,e,i)=>{for(var g=i>1?void 0:i?tnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&enA(A,e,g),g};const ap=tA("debugparticles"),inA=tA("noprogressive"),gnA=tA("debugprogressive");var iF=(t=>(t[t.Birth=0]="Birth",t[t.Collision=1]="Collision",t[t.Death=2]="Death",t[t.Trigger=3]="Trigger",t[t.Manual=4]="Manual",t))(iF||{});class gs extends FA{constructor(){super(...arguments),n(this,"renderMode"),n(this,"particleMaterial"),n(this,"trailMaterial"),n(this,"particleMesh"),n(this,"maxParticleSize"),n(this,"minParticleSize"),n(this,"velocityScale"),n(this,"cameraVelocityScale"),n(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&re()){const A=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(A)}}get transparent(){var A;return((A=this.particleMaterial)==null?void 0:A.transparent)??!1}getMaterial(A=!1){let e=A===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return e&&A&&e.side===Dg&&(e=e.clone(),e.side=pi,A?this.trailMaterial=e:this.particleMaterial=e),e&&!inA&&e._didRequestTextureLOD===void 0&&(e._didRequestTextureLOD=0,gnA&&console.log("Load material LOD",e.name),Jt.assignTextureLOD(this.context,this.sourceId,e)),e}getMesh(A){let e=null;if(!e&&(this.particleMesh instanceof hA&&(e=this.particleMesh.geometry),e===null)){e=new Zi(1,1);const i=e.attributes.uv;for(let g=0;g<i.count;g++)i.setX(g,1-i.getX(g))}return new hA(e,this.getMaterial())}}hi([w()],gs.prototype,"renderMode",2),hi([w(Re)],gs.prototype,"particleMaterial",2),hi([w(Re)],gs.prototype,"trailMaterial",2),hi([w()],gs.prototype,"maxParticleSize",2),hi([w()],gs.prototype,"minParticleSize",2),hi([w()],gs.prototype,"velocityScale",2),hi([w()],gs.prototype,"cameraVelocityScale",2),hi([w()],gs.prototype,"lengthScale",2);class O0{constructor(A,e=1){n(this,"_curve"),n(this,"_factor"),n(this,"type","function"),this._curve=A,this._factor=e}genValue(A){return this._curve.evaluate(A,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class gF{constructor(A){n(this,"type","value"),n(this,"system"),this.system=A}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class InA extends gF{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class onA extends gF{constructor(){super(...arguments),n(this,"_lastPosition",new S),n(this,"_lastDistance",0)}update(){const A=Fe(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(A),this._lastPosition.copy(A)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let A=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const g=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let I=this._lastDistance/this.system.deltaTime*g;Number.isFinite(I)||(I=0),A+=I}const e=this.system.emission.getBurst();e>0&&(A+=e/this.system.deltaTime);const i=this.system.maxParticles-this.system.currentParticles;return Ae.clamp(A,0,i/this.system.deltaTime)}}class snA extends gF{genValue(){return this.system.isPlaying,0}}class tr{constructor(A){n(this,"system"),n(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",A&&(this.system=A)}get context(){return this.system.context}initialize(A){}update(A,e){}frameUpdate(A){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class CnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleTextureSheet")}update(A,e){const i=this.system.textureSheetAnimation;if(i.enabled){const g=A.age/A.life,I=i.evaluate(g);I!==void 0&&(A.uvTile=I)}}}const t1=Symbol("particleRotation");class anA extends tr{constructor(){super(...arguments),n(this,"type","NeedleRotation")}initialize(A){A[t1]=Math.random()}update(A,e){if(A.rotation===void 0)return;const i=A.age/A.life;if(typeof A.rotation=="number"&&(this.system.rotationOverLifetime.enabled?A.rotation+=this.system.rotationOverLifetime.evaluate(i,A[t1])*e:this.system.renderer.renderMode===Ma.Billboard&&(A.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const g=A.velocity.length();A.rotation+=this.system.rotationBySpeed.evaluate(i,g)*e}}}const i1=Symbol("sizeLerpFactor"),nnA=new S;class rnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleSize"),n(this,"_minSize",0),n(this,"_maxSize",1)}initialize(A){A[i1]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(A,e){const i=A.age/A.life;let g=1;this.system.sizeOverLifetime.enabled&&(g*=this.system.sizeOverLifetime.evaluate(i,void 0,A[i1]).x);let I=1;if(this.system.renderer.renderMode!==Ma.Mesh&&(I=this.system.worldScale.x/this.system.cameraScale),A.size=A.startSize*g*I,this.system.localspace){const o=C1(this.system,nnA);A.size*=o.x}}}const Sh=Symbol("particleLife"),IF=Symbol("trailLifetime"),g1=Symbol("trailStartLength"),oF=Symbol("trailWidthRandom");class BnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleTrail")}initialize(A){A instanceof ip&&(A[Sh]=A.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(A[IF]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),A.life+=A[IF]),A[g1]=A.length,A[oF]=Math.random())}update(A){var e;if((e=this.system.trails)!=null&&e.enabled&&A instanceof ip){const i=A,g=A.age/A[Sh],I=A.previous.values(),o=A.previous.length;for(let s=0;s<o;s++){const C=I.next().value,a=1-s/(o-1);let r=A.size;r<=0&&!this.system.trails.sizeAffectsWidth&&(r=20*this.system.trails.widthOverTrail.evaluate(.5,i[oF])),C.size=this.system.trails.getWidth(r,g,a,i[oF]),C.color.copy(A.color),this.system.trails.getColor(C.color,g,a)}if(A.age>A[Sh]){A.velocity.set(0,0,0);const s=(A.age-A[Sh])/A[IF];i.length=Ae.lerp(A[g1],0,s)}}}}const P0=Symbol("startVelocity"),I1=Symbol("gravityModifier"),sF=Symbol("gravitySpeed"),j0=Symbol("velocity lerp factor"),CF=new S;class QnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleVelocity"),n(this,"_gravityDirection",new S)}initialize(A){var e,i;const g=this.system.main.simulationSpeed;A.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),A.velocity.copy(this.system.shape.getDirection(A,A.position)).multiplyScalar(A.startSpeed),(e=this.system.inheritVelocity)!=null&&e.enabled&&this.system.inheritVelocity.applyInitial(A.velocity),A[P0]?A[P0].copy(A.velocity):A[P0]=A.velocity.clone();const I=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());A[I1]=I*g,A[sF]=I*g*.5,A[j0]=Math.random(),(i=this.system.velocityOverLifetime)==null||i.init(A),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Ld.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(A,e){var i;const g=A[P0],I=A[I1];if(I!==0){const Q=I*A[sF];CF.copy(this._gravityDirection).multiplyScalar(Q),A[sF]+=e*.05,g.add(CF)}A.velocity.copy(g);const o=A.age/A.life;(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyCurrent(A.velocity,o,A[j0]);const s=this.system.noise;s.enabled&&s.apply(0,A.position,A.velocity,e,A.age,A.life);const C=this.system.sizeBySpeed;C!=null&&C.enabled&&(A.size=C.evaluate(A.velocity,o,A[j0],A.size));const a=this.system.colorBySpeed;a!=null&&a.enabled&&a.evaluate(A.velocity,A[j0],A.color);const r=this.system.velocityOverLifetime;r.enabled&&r.apply(A,0,A.position,A.velocity,e,A.age,A.life);const B=this.system.limitVelocityOverLifetime;B.enabled&&B.apply(A.position,g,A.velocity,A.size,o,e,1),this.system.worldspace&&A.velocity.multiply(this.system.worldScale)}}const o1=Symbol("colorLerpFactor"),s1=new St(1,1,1,1),zB=new St(1,1,1,1);class EnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleColor")}initialize(A){}_init(A){const e=this.system.renderer.particleMaterial;zB.copy(this.system.main.startColor.evaluate(Math.random())),e!=null&&e.color&&(s1.copy(e.color),zB.multiply(s1)),zB.convertLinearToSRGB(),A.startColor.set(zB.r,zB.g,zB.b,zB.alpha),A.color.copy(A.startColor),A[o1]=Math.random()}update(A,e){if(A.age===0&&this._init(A),this.system.colorOverLifetime.enabled){const i=A.age/A.life,g=this.system.colorOverLifetime.color.evaluate(i,A[o1]);A.color.set(g.r,g.g,g.b,g.alpha).multiply(A.startColor)}else A.color.copy(A.startColor)}}class hnA{constructor(A){n(this,"system"),n(this,"emission"),n(this,"autoDestroy"),n(this,"startLength"),n(this,"emissionBursts"),n(this,"onlyUsedByOther"),n(this,"behaviors",[]),n(this,"rendererEmitterSettings",{startLength:new BI(220),followLocalOrigin:!1}),n(this,"flatWhiteTexture"),n(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=A,this.emission=new onA(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new O0(this.system.main.startLifetime)}get startSpeed(){return new O0(this.system.main.startSpeed)}get startRotation(){return new O0(this.system.main.startRotation)}get startSize(){return new O0(this.system.main.startSize)}get startColor(){return new x0(new zA(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new snA(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return ie.Trail;switch(this.system.renderer.renderMode){case Ma.Billboard:return ie.BillBoard;case Ma.Stretch:return ie.StretchedBillBoard;case Ma.HorizontalBillboard:return ie.HorizontalBillBoard;case Ma.VerticalBillboard:return ie.VerticalBillBoard;case Ma.Mesh:return ie.Mesh}return ie.BillBoard}get speedFactor(){var A;let e=this.system.main.simulationSpeed;return((A=this.system.renderer)==null?void 0:A.renderMode)===Ma.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const A=this.material;if(A&&A.map){const e=A.map;if(this.clonedTexture.original!==e||!this.clonedTexture.clone){const i=e.clone();i.premultiplyAlpha=!1,i.colorSpace=lt,this.clonedTexture.original=e,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=VH(new St(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new InA(this.system)}get uTileCount(){var A;return this.anim.enabled?(A=this.anim)==null?void 0:A.numTilesX:void 0}get vTileCount(){var A;return this.anim.enabled?(A=this.anim)==null?void 0:A.numTilesY:void 0}get renderOrder(){return 1}get blending(){var A;return((A=this.system.renderer.particleMaterial)==null?void 0:A.blending)??ja}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Ld.World}}class cnA{constructor(){n(this,"burstIndex",0),n(this,"burstWaveIndex",0),n(this,"time",0),n(this,"waitEmiting",0)}}const W0=class extends FA{constructor(){super(...arguments),n(this,"_state"),n(this,"colorOverLifetime"),n(this,"main"),n(this,"emission"),n(this,"sizeOverLifetime"),n(this,"shape"),n(this,"noise"),n(this,"trails"),n(this,"velocityOverLifetime"),n(this,"limitVelocityOverLifetime"),n(this,"inheritVelocity"),n(this,"colorBySpeed"),n(this,"textureSheetAnimation"),n(this,"rotationOverLifetime"),n(this,"rotationBySpeed"),n(this,"sizeBySpeed"),n(this,"_cameraScale",1),n(this,"__worldQuaternion",new RA),n(this,"_worldQuaternionInverted",new RA),n(this,"_worldScale",new S),n(this,"_worldPositionFrame",-1),n(this,"_worldPos",new S),n(this,"_renderer"),n(this,"_batchSystem"),n(this,"_particleSystem"),n(this,"_interface"),n(this,"_container"),n(this,"_time",0),n(this,"_isPlaying",!0),n(this,"_isUsedAsSubsystem",!1),n(this,"_didPreWarm",!1),n(this,"_bursts"),n(this,"_subEmitterSystems"),n(this,"_lastBatchesCount",-1),n(this,"lastMaterialVersion",-1)}play(t=!1){var A;t&&CA.foreachComponent(this.gameObject,e=>{e instanceof W0&&e!==this&&e.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(A=this.emission)==null||A.reset()}pause(t=!0){t&&CA.foreachComponent(this.gameObject,A=>{A instanceof W0&&A!==this&&A.pause(!1)},!0),this._isPlaying=!1}stop(t=!0,A=!1){t&&CA.foreachComponent(this.gameObject,e=>{e instanceof W0&&e!==this&&e.stop(!1,A)},!0),this._isPlaying=!1,this._time=0,A&&this.reset()}reset(){var t;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(t=this.emission)==null||t.reset())}emit(t){if(this._particleSystem){this.onUpdate(),t=Math.min(t,this.maxParticles-this.currentParticles),this._state||(this._state=new cnA),this._state.waitEmiting=t,this._state.time=0;const A=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=A}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(t){this.main.playOnAwake=t}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var t;return((t=this._particleSystem)==null?void 0:t.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Ld.World}get localspace(){return this.main.simulationSpace===Ld.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Fe(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(t){return this._particleSystem?(t instanceof tr&&(t.system=this),re()&&console.log("add behaviour",t),this._particleSystem.addBehavior(t),!0):!1}removeBehaviour(t){if(!this._particleSystem)return!1;const A=this._particleSystem.behaviors,e=A.indexOf(t);return e!==-1&&A.splice(e,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(t){for(let A=0;A<t.length;A++){const e=t[A];if(!(e instanceof Yd)){const i=new Yd;wE(i,e),t[A]=i}}this._bursts=t}set subEmitterSystems(t){for(let A=0;A<t.length;A++){const e=t[A];if(!(e instanceof np)){const i=new np;wE(i,e),t[A]=i}}ap&&t.length>0&&console.log("SubEmitters: ",t,this),this._subEmitterSystems=t}onAfterDeserialize(t){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const A of this._subEmitterSystems)A._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(gs),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new uA,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new kaA,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new hnA(this),this._particleSystem=new caA(this._interface),this._particleSystem.addBehavior(new rnA(this)),this._particleSystem.addBehavior(new EnA(this)),this._particleSystem.addBehavior(new CnA(this)),this._particleSystem.addBehavior(new anA(this)),this._particleSystem.addBehavior(new QnA(this)),this._particleSystem.addBehavior(new BnA(this)),this._batchSystem.addSystem(this._particleSystem);const t=this._particleSystem.emitter;this.context.scene.add(t),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),ap&&(console.log(this),this.gameObject.add(new bo(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var t,A,e,i;(t=this._container)==null||t.removeFromParent(),(A=this._batchSystem)==null||A.removeFromParent(),(e=this._particleSystem)==null||e.emitter.removeFromParent(),(i=this._particleSystem)==null||i.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var t;this.main&&(this._didPreWarm===!1&&((t=this.main)==null?void 0:t.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var t;if(!((t=this.emission)!=null&&t.enabled)||this.emission.rateOverTime.getMax()<=0)return;const A=1/60,e=this.main.duration,i=this.main.startLifetime.getMax(),g=1e3,I=Math.min(Math.max(e,i)/Math.max(.01,this.main.simulationSpeed),g),o=Math.ceil(I/A),s=Date.now();ap&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${I} sec). Duration: ${e}, Lifetime: ${i}`);for(let C=0;C<o&&!(this.currentParticles>=this.maxParticles);C++){const a=Date.now()-s;if(a>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${a}`);break}this.onUpdate(),this.onSimulate(A)}}onSimulate(t){if(this._batchSystem){let A=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,A=!0),A&&this.updateLayers(),this._batchSystem.update(t)}this._time+=t,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let t=0;t<this._batchSystem.batches.length;t++){const A=this._batchSystem.batches[t];A.layers.disableAll();const e=this.layer;A.layers.mask=1<<e}}onUpdate(){var t,A;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const i=this.context.mainCamera;if(i){const o=Tt(i);this._cameraScale=o.x}const g=!this.worldspace,I=this.gameObject;if(Gt(I,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Tt(this.gameObject,this._worldScale),g&&this._container&&(t=this.gameObject)!=null&&t.parent){const o=C1(this,CF);this._container.matrix.makeScale(o.x,o.y,o.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(A=this.inheritVelocity)==null||A.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var t;if(this._subEmitterSystems&&this._particleSystem)for(const A of this._subEmitterSystems){A.particleSystem&&(A.particleSystem.__internalAwake?A.particleSystem.__internalAwake():re()&&console.warn("SubParticleSystem serialization issue(?)",A.particleSystem,A));const e=(t=A.particleSystem)==null?void 0:t._particleSystem;if(e){A.particleSystem._isUsedAsSubsystem=!0;const i=new Z0(this,this._particleSystem,A.particleSystem,e);i.emitterType=A.type,i.emitterProbability=A.emitProbability,this._particleSystem.addBehavior(i)}else ap&&console.warn("Could not add SubParticleSystem",A,this)}}};let Pi=W0;hi([w(_d)],Pi.prototype,"colorOverLifetime",2),hi([w(_g)],Pi.prototype,"main",2),hi([w(pC)],Pi.prototype,"emission",2),hi([w(Vn)],Pi.prototype,"sizeOverLifetime",2),hi([w(Qi)],Pi.prototype,"shape",2),hi([w(mt)],Pi.prototype,"noise",2),hi([w(ii)],Pi.prototype,"trails",2),hi([w(Ei)],Pi.prototype,"velocityOverLifetime",2),hi([w(Ti)],Pi.prototype,"limitVelocityOverLifetime",2),hi([w(zn)],Pi.prototype,"inheritVelocity",2),hi([w(xB)],Pi.prototype,"colorBySpeed",2),hi([w(Hg)],Pi.prototype,"textureSheetAnimation",2),hi([w(ts)],Pi.prototype,"rotationOverLifetime",2),hi([w(wo)],Pi.prototype,"rotationBySpeed",2),hi([w(KI)],Pi.prototype,"sizeBySpeed",2);class np{constructor(){n(this,"particleSystem"),n(this,"emitProbability",1),n(this,"properties"),n(this,"type")}_deserialize(A,e){const i=this.particleSystem;if(i instanceof Pi)return;let g="";i&&typeof i.guid=="string"&&(g=i.guid,this.particleSystem=CA.findByGuid(g,e)),ap&&!(this.particleSystem instanceof Pi)&&console.warn("Could not find particle system for sub emitter",g,e,this)}}function C1(t,A){if(A.set(1,1,1),t.gameObject.parent&&t.localspace)switch(t.main.scalingMode){case aN.Local:A=Tt(t.gameObject.parent,A),A.x=1/A.x,A.y=1/A.y,A.z=1/A.z;break;default:if(!t.unsupported_scaling_mode){t.unsupported_scaling_mode=!0;const e="ParticleSystem scale mode "+aN[t.main.scalingMode]+" is not supported";re()&&Ci(e),console.warn(e,t.name,t)}A=Tt(t.gameObject,A);break}return A}new S(1,1,1),new S(0,0,1);class Z0{constructor(A,e,i,g){n(this,"type","NeedleParticleSubEmitter"),n(this,"emitterType"),n(this,"emitterProbability"),n(this,"q_",new RA),n(this,"v_",new S),n(this,"v2_",new S),n(this,"_emitterMatrix",new MA),n(this,"_circularBuffer"),this.system=A,this.particleSystem=e,this.subSystem=i,this.subParticleSystem=g,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const I=1e3;this._circularBuffer=new qo(()=>new MA,I)}clone(){throw new Error("Method not implemented.")}initialize(A){A.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===iF.Birth&&this.run(A)}update(A,e){this.run(A)}frameUpdate(A){}toJSON(){}reset(){}run(A){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!A.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const e=this.system.deltaTime;if(this.emitterType===iF.Death){let g=A.life;if(A[Sh]!==void 0&&(g=A[Sh]),!(A.age+e*1.2>=g))return;const I=this.subSystem.main.maxParticles-this.subSystem.currentParticles;A.emissionState.waitEmiting=I}const i=new MA;i.set(1,0,0,A.position.x,0,1,0,A.position.y,0,0,1,A.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(e,A.emissionState,i)}}var lnA=Object.defineProperty,dnA=Object.getOwnPropertyDescriptor,pnA=(t,A,e,i)=>{for(var g=i>1?void 0:i?dnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lnA(A,e,g),g};class rp extends aI{constructor(){super(...arguments),n(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const A=new JY;return this.granularity.onValueChanged=e=>{A.granularity=e},A}}pnA([w(Ne)],rp.prototype,"granularity",2),As("PixelationEffect",rp);class Wh extends FA{constructor(){super(...arguments),n(this,"_didAssignPlayerColor",!1),n(this,"tryAssignColor",()=>{const A=CA.getComponentInParent(this.gameObject,es);if(A&&A.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(A.owner),!0;const e=CA.getComponentInParent(this.gameObject,xg);return e!=null&&e.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(e.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(At.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(At.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield YH(.2),!this.tryAssignColor()););}assignUserColor(A){const e=Wh.hashCode(A),i=Wh.colorFromHashCode(e);if(this.gameObject.type==="Mesh"){const g=this.gameObject;this.assignColor(i,A,g)}else if(this.gameObject.children)for(const g of this.gameObject.children){const I=g;I.material&&I.material.color&&this.assignColor(i,A,I)}}assignColor(A,e,i){let g=i.material;g&&(g._playerMaterial!==e&&(g=g.clone(),g._playerMaterial=e,i.material=g),g.color=A)}static hashCode(A){var e=0,i,g;if(A.length===0)return e;for(i=0;i<A.length;i++)g=A.charCodeAt(i),e=(e<<5)-e+g,e|=0;return e}static colorFromHashCode(A){const e=(A&16711680)>>16,i=(A&65280)>>8,g=A&255;return new GA(e/255,i/255,g/255)}}async function aF(t){const{NeedleEngineHTMLElement:A}=await Promise.resolve().then(()=>RBA);A.observedAttributes.includes(t)||A.observedAttributes.push(t)}var unA=Object.defineProperty,DnA=Object.getOwnPropertyDescriptor,Bp=(t,A,e,i)=>{for(var g=i>1?void 0:i?DnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&unA(A,e,g),g};const Is=tA("debugskybox");aF("skybox-image"),aF("environment-image");function a1(t,A,e,i,g){const I=new SC;I.allowDrop=!1,I.allowNetworking=!1,I.background=e,I.environment=i,CA.addComponent(t.scene,I);const o=s=>{typeof s=="string"&&(Is&&console.log(g,"CHANGED TO",s),I.setSkybox(s))};return lq(t.domElement,g,o),I.addEventListener("destroy",()=>{Is&&console.log("Destroyed attribute remote skybox",g),dq(t.domElement,g,o)}),I.setSkybox(A)}et.addContextCreatedCallback(t=>{var A;const e=t.context,i=e.domElement.getAttribute("skybox-image"),g=e.domElement.getAttribute("environment-image"),I=new Array;if(i){Is&&console.log("Creating remote skybox to load "+i),((A=e.mainCameraComponent)==null?void 0:A.clearFlags)!==wB.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=a1(e,i,!0,!1,"skybox-image");I.push(o)}if(g){Is&&console.log("Creating remote environment to load "+g);const o=a1(e,g,!1,!0,"environment-image");I.push(o)}return I.length>0?Yc(I):Promise.resolve()});function n1(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function r1(t){const A=n1().find(e=>e.src===t);return A?(Is&&console.log("Skybox: Found previously loaded texture for "+t),A.texture):null}async function wnA(t){const A=await t;YM(A,!0),qt(A)}function ynA(t,A){const e=n1();for(;e.length>5;){const i=e.shift();i&&wnA(i.texture)}A.then(i=>YM(i,!1)),e.push({src:t,texture:A})}class SC extends FA{constructor(){super(...arguments),n(this,"url"),n(this,"allowDrop",!0),n(this,"background",!0),n(this,"environment",!0),n(this,"allowNetworking",!0),n(this,"_loader"),n(this,"_prevUrl"),n(this,"_prevLoadedEnvironment"),n(this,"_prevEnvironment",null),n(this,"_prevBackground",null),n(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),n(this,"onDragOverEvent",A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)(e==="text/uri-list"||e==="Files")&&A.preventDefault()}),n(this,"onDrop",A=>{var e,i,g,I;if(this.allowDrop&&A.dataTransfer){for(const o of A.dataTransfer.types)if(Is&&console.log(o),o==="text/uri-list"){const s=A.dataTransfer.getData(o);Is&&console.log(o,s);let C=(i=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(s))==null?void 0:e.groups)==null?void 0:i.name;if(C||(C=(I=(g=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(s))==null?void 0:g.groups)==null?void 0:I.name),Is&&console.log(C),C){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+C+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${a}`),A.preventDefault(),this.setSkybox(a);break}else if(this.isValidTextureType(s)){console.log("[Remote Skybox] Setting skybox from url: "+s),A.preventDefault(),this.setSkybox(s);break}else{console.warn(`[RemoteSkybox] Unknown url ${s}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const a=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:A,url:s,apply:r=>{A.preventDefault(),this.setSkybox(r)}}});this.dispatchEvent(a)}}else if(o=="Files"){const s=A.dataTransfer.files.item(0);if(Is&&console.log(o,s),!s)continue;if(!this.isValidTextureType(s.name)){console.warn(`[RemoteSkybox]: File "${s.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(r1(s.name)===null){const C=new Blob([s]),a=URL.createObjectURL(C);A.preventDefault(),this.setSkybox(a,s.name)}else A.preventDefault(),this.setSkybox(s.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,xt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(A,e){var i;if(!this.activeAndEnabled||!A)return!1;if(e??(e=A),this.isValidTextureType(e)||console.warn("Potentially invalid skybox url",e,"on",this.name),Is&&console.log("Remote skybox url?: "+A),this._prevUrl===A&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(i=this._prevLoadedEnvironment)==null||i.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=A;const g=await this.loadTexture(A,e);if(!g||!this.enabled)return!1;this.url=A;const I=A.lastIndexOf("/");return g.name=A.substring(I>=0?I+1:0),this._loader instanceof zs&&(g.colorSpace=Ee),this._prevLoadedEnvironment=g,this.applySkybox(),!0}async loadTexture(A,e){var i,g,I,o,s;if(!A)return Promise.resolve(null);e??(e=A);const C=r1(e);if(C){const Q=await C;if(((g=(i=Q.source)==null?void 0:i.data)==null?void 0:g.length)>0||(s=(o=(I=Q.source)==null?void 0:I.data)==null?void 0:o.data)!=null&&s.length)return Q}const a=e.endsWith(".exr"),r=e.endsWith(".hdr");a?this._loader instanceof Cy||(this._loader=new Cy):r?this._loader instanceof PU||(this._loader=new PU):this._loader instanceof zs||(this._loader=new zs),Is&&console.log("Loading skybox: "+A);const B=this._loader.loadAsync(A);return ynA(e,B),await B}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=lQ,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Is&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!xt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(A){return A.startsWith("http://")||A.startsWith("https://")}isValidTextureType(A){for(const e of this.validTextureTypes)if(A.endsWith(e))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Bp([fR(SC.prototype.urlChangedSyncField),w(URL)],SC.prototype,"url",2),Bp([w()],SC.prototype,"allowDrop",2),Bp([w()],SC.prototype,"background",2),Bp([w()],SC.prototype,"environment",2),Bp([w()],SC.prototype,"allowNetworking",2);var SnA=Object.defineProperty,fnA=Object.getOwnPropertyDescriptor,fo=(t,A,e,i)=>{for(var g=i>1?void 0:i?fnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SnA(A,e,g),g};const mo=tA("debugsceneswitcher"),V0="scene";aF(V0);const ir=Promise.resolve(!1);class QI extends FA{constructor(){super(...arguments),n(this,"autoLoadFirstScene",!0),n(this,"scenes"),n(this,"loadingScene"),n(this,"queryParameterName","scene"),n(this,"useSceneName",!0),n(this,"clamp",!0),n(this,"useHistory",!0),n(this,"useKeyboard",!0),n(this,"useSwipe",!0),n(this,"useSceneLighting",!0),n(this,"preloadNext",1),n(this,"preloadPrevious",1),n(this,"preloadConcurrent",2),n(this,"_currentIndex",-1),n(this,"_currentScene"),n(this,"_engineElementOverserver"),n(this,"_preloadScheduler"),n(this,"onPopState",async A=>{if(!this.useHistory)return;const e=this.useHistory;try{this.useHistory=!1;let i=!1;if(this.queryParameterName&&(i=await this.tryLoadFromQueryParam()),!i){const g=A?.state;if(g&&g.startsWith(this.guid)){const I=g.substr(this.guid.length+2);mo&&console.log("PopState",I),await this.trySelectSceneFromValue(I)}}}finally{this.useHistory=e}}),n(this,"normalizedSwipeThresholdX",.1),n(this,"_didSwipe",!1),n(this,"onInputPointerMove",A=>{if(this.useSwipe&&!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const i=e.x/this.context.domWidth;i>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):i<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),n(this,"onInputPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),n(this,"onInputKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const i=parseInt(e)-1;if(i>=0){this.trySelectSceneFromValue(i);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),n(this,"__lastSwitchScene"),n(this,"__lastSwitchScenePromise"),n(this,"_currentlyLoadingScene"),n(this,"_lastLoadingScene"),n(this,"_loadingScenePromise"),n(this,"_isCurrentlyLoading",!1),n(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),mo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(ei.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(ei.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(ei.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===V0){const i=this.context.domElement.getAttribute(V0);i!==null&&this.trySelectSceneFromValue(i)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new mnA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(V0);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(ei.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(ei.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(ei.PointerUp,this.onInputPointerUp),(A=this._preloadScheduler)==null||A.stop()}addScene(A){if(typeof A=="string"){let e=this.context.addressables.findAssetReference(A);return e||(e=new tt(A),this.context.addressables.registerAssetReference(e)),this.scenes.push(e),e}return this.scenes.push(A),A}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,i,g;if(mo&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const o=(e=this.scenes)==null?void 0:e.find(s=>s.uri===A);if(!o){const s=tt.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(s)}if(o)A=(i=this.scenes)==null?void 0:i.indexOf(o);else return ir}if(!((g=this.scenes)!=null&&g.length))return ir;if(A<0){if(this.clamp)return ir;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return ir;A=0}const I=this.scenes[A];return this.switchScene(I)}async switchScene(A){if(!(A instanceof tt)){const e=typeof A;return e==="string"?this.select(A):e==="number"?this.select(A):(console.warn("SceneSwitcher: Can't switch to scene",A,"of type",e),!1)}return A.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===A&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=A,this.__lastSwitchScenePromise=this.__internalSwitchScene(A),await this.__lastSwitchScenePromise)}async __internalSwitchScene(A){var e,i;if(this._currentScene){mo&&console.log("UNLOAD",A.uri);const I=this.tryGetSceneEventListener(this._currentScene.asset);if(I!=null&&I.sceneClosing){const o=I.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const g=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;try{this._currentlyLoadingScene=A,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const I=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:g}});this.dispatchEvent(I),await this.onStartLoading(),await A.loadAssetAsync((s,C)=>{this._currentLoadingProgress=C,this.dispatchEvent(C)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:g}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return mo&&console.warn("Adding loaded scene prevented:",A,o),!1;if(!A.asset)return mo&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===g){if(mo&&console.log("ADD",A.uri),this._currentScene=A,CA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&g>=0){let a=g.toString();if(this.useSceneName&&(a=B1(A.uri)),(i=this.queryParameterName)!=null&&i.length)LD(this.queryParameterName,a,this.useHistory);else{const r=history.state,B=this.guid+"::"+g;r!==B&&history.pushState(B,"unused",location.href)}}const s=this.tryGetSceneEventListener(A.asset);if(s!=null&&s.sceneOpened){const a=s.sceneOpened(this);a instanceof Promise&&await a}const C=new CustomEvent("scene-opened",{detail:{scene:A,switcher:this,index:g}});return this.dispatchEvent(C),!0}}catch(I){console.error(I)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof tt)return e.preload()}return ir}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return ir;const e=tA(this.queryParameterName);return typeof e=="boolean"?ir:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);{const i=A.toLowerCase();for(let g=0;g<this.scenes.length;g++){const I=this.scenes[g];if(I&&B1(I.uri).toLowerCase().includes(i))return this.select(g)}}}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return Ao()&&console.warn('Can not find scene: "'+A+'"',this),ir}async onStartLoading(){var A,e;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(A=this.loadingScene)==null?void 0:A.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(e=this.loadingScene)!=null&&e.asset)){mo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const i=this.loadingScene.asset;CA.add(i,this.gameObject);const g=this.tryGetSceneEventListener(i);if(g!=null&&g.sceneOpened){const I=g.sceneOpened(this);I instanceof Promise&&await I}}if(this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneOpened){const g=i.sceneOpened(this);g instanceof Promise&&await g}}}async onEndLoading(){var A;if(this._isCurrentlyLoading=!1,(A=this.loadingScene)!=null&&A.asset){mo&&console.log("Remove loading scene",this.loadingScene.uri);const e=this.loadingScene.asset,i=this.tryGetSceneEventListener(e);if(typeof i?.sceneClosing=="function"){const g=i.sceneClosing();g instanceof Promise&&await g}CA.remove(e)}if(!this._isCurrentlyLoading){const e=this.tryGetSceneEventListener(this.gameObject);if(e&&e.sceneClosing){const i=e.sceneClosing();i instanceof Promise&&await i}}}tryGetSceneEventListener(A,e=0){const i=CA.foreachComponent(A,g=>g.sceneClosing?g:void 0);if(e===0&&!i&&A.children.length)for(const g of A.children){const I=this.tryGetSceneEventListener(g,e+1);if(I)return I}return i||null}}fo([w()],QI.prototype,"autoLoadFirstScene",2),fo([w(tt)],QI.prototype,"scenes",2),fo([w(tt)],QI.prototype,"loadingScene",2),fo([w()],QI.prototype,"queryParameterName",2),fo([w()],QI.prototype,"useSceneName",2),fo([w()],QI.prototype,"clamp",2),fo([w()],QI.prototype,"useHistory",2),fo([w()],QI.prototype,"useKeyboard",2),fo([w()],QI.prototype,"useSwipe",2),fo([w()],QI.prototype,"useSceneLighting",2),fo([w()],QI.prototype,"preloadNext",2),fo([w()],QI.prototype,"preloadPrevious",2),fo([w()],QI.prototype,"preloadConcurrent",2);function B1(t){const A=t.split("/").pop(),e=A?.split(".").shift();return e!=null&&e.length?e:t}class mnA{constructor(A,e=1,i=1,g=2){n(this,"maxLoadAhead"),n(this,"maxLoadBehind"),n(this,"maxConcurrent"),n(this,"_isRunning",!1),n(this,"_switcher"),n(this,"_loadTasks",[]),n(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=i,this.maxConcurrent=g}begin(){if(this._isRunning)return;mo&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,i;const g=this._switcher.scenes,I=setInterval(()=>{if(this.allLoaded()&&(mo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(I);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,i=0,e=0);const o=i%2===0;o&&(e+=1),i+=1;const s=o?this.maxLoadAhead:this.maxLoadBehind;if(e>s)return;const C=o?A+e:A-e;if(C<0||C<0||C>=g.length)return;const a=g[C];new knA(C,a,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1}return!0}}class knA{constructor(A,e,i){n(this,"index"),n(this,"asset"),n(this,"tasks"),this.index=A,this.asset=e,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(mo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),mo&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function GnA(){return new Promise((t,A)=>{const e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),t())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function MnA(t){await GnA(),t()}var UnA=Object.defineProperty,RnA=Object.getOwnPropertyDescriptor,ko=(t,A,e,i)=>{for(var g=i>1?void 0:i?RnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UnA(A,e,g),g};const lg=tA("debugvideo");var Q1=(t=>(t[t.None=0]="None",t[t.AdjustHeight=1]="AdjustHeight",t[t.AdjustWidth=2]="AdjustWidth",t))(Q1||{}),E1=(t=>(t[t.VideoClip=0]="VideoClip",t[t.Url=1]="Url",t))(E1||{}),h1=(t=>(t[t.CameraFarPlane=0]="CameraFarPlane",t[t.CameraNearPlane=1]="CameraNearPlane",t[t.RenderTexture=2]="RenderTexture",t[t.MaterialOverride=3]="MaterialOverride",t))(h1||{});class og extends FA{constructor(){super(),n(this,"playOnAwake",!0),n(this,"aspectMode",0),n(this,"clip",null),n(this,"source",1),n(this,"url",null),n(this,"renderMode"),n(this,"targetMaterialProperty"),n(this,"targetMaterialRenderer"),n(this,"targetTexture"),n(this,"time",0),n(this,"_playbackSpeed",1),n(this,"_isLooping",!1),n(this,"_muted",!1),n(this,"_audioOutputMode",2),n(this,"playInBackground",!0),n(this,"_crossOrigin","anonymous"),n(this,"_videoElement",null),n(this,"_videoTexture",null),n(this,"_videoMaterial",null),n(this,"_isPlaying",!1),n(this,"wasPlaying",!1),n(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),n(this,"_receivedInput",!1),n(this,"_overlay",null),n(this,"_targetObjects"),n(this,"_updateAspectRoutineId",-1),n(this,"_hls"),n(this,"onHlsAvailable",()=>{var A;lg&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U8||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(A=this._videoElement)==null||A.play(),lg&&console.log("HLS: loaded",this.clip))}),MnA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],tA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}get currentVideo(){return this.clip}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&re()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){lg&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(A){this.url!==A&&(this.url=A,this.source=1,lg&&console.log("set url",A),this._videoElement?A.endsWith(".m3u8")?this.ensureM3U8CanBePlayed():(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var A,e;lg&&console.log("VideoPlayer.onEnable",E1[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){var A;window.removeEventListener("visibilitychange",this.visibilityChanged),(A=this._overlay)==null||A.stop(),this.pause()}onDestroy(){var A;this._videoElement&&((A=this.videoElement)==null||A.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;if(this._videoElement||this.create(!1),!this._videoElement){lg&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U8){this.ensureM3U8CanBePlayed();return}lg&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(i=>{var g;console.log(i),lg&&console.error("Error playing video",i,"CODE="+i.code,(g=this.videoElement)==null?void 0:g.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),lg&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),lg&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),lg&&console.log("PAUSE",this,this.currentTime)}create(A){let e;switch(this.source){case 0:e=this.clip;break;case 1:e=this.url,!(e!=null&&e.length)&&typeof this.clip=="string"&&(e=this.clip);break}return e?(this._videoElement||(lg&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof e=="string"?(lg&&console.log("Set Video src",e),this._videoElement.src=e):(lg&&console.log("Set Video srcObject",e),this._videoElement.srcObject=e),this._videoTexture||(this._videoTexture=new tb(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=Ee,A&&this.handleBeginPlaying(A),lg&&console.log("Video: handle playing done...",e,A),!0):(lg&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new NnA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),lg&&console.log("created video element",A),A}handleBeginPlaying(A){var e,i;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let g=this.gameObject;switch(this.renderMode){case 3:g=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,g||(g=(i=CA.getComponent(this.gameObject,Ji))==null?void 0:i.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!g){console.error("Missing target for video material renderer",this.name,h1[this.renderMode],this);return}const I=g.material;if(I){this._targetObjects.push(g),I!==this._videoMaterial&&(this._videoMaterial=I.clone(),g.material=this._videoMaterial);const o="map",s=this._videoMaterial;if(!this.targetMaterialProperty)s[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:s[o]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&(this.shouldUseM3U8&&this.ensureM3U8CanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,i=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&i===this.clip&&this._isPlaying;){if(!i||typeof i=="string")return;let g;for(const I of i.getVideoTracks()){const o=I.getSettings();if(o&&o.width&&o.height){g=o.width/o.height;break}else g=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(g===void 0){for(let I=0;I<10;I++)yield;if(!this.isPlaying)break;continue}if(e===g){yield;continue}for(const I of this._targetObjects){let o=1;if(I.parent){const s=Tt(I.parent);o=s.x/s.y}switch(this.aspectMode){case 1:I.scale.y=1/g*I.scale.x*o;break;case 2:I.scale.x=g*I.scale.y*o;break}}for(let I=0;I<3;I++)yield}}get shouldUseM3U8(){return this.url!=null&&this.url.endsWith(".m3u8")&&this.source===1}ensureM3U8CanBePlayed(){if(!this.shouldUseM3U8)return;let A=document.head.querySelector("script[data-hls_library]");A?globalThis.Hls?this.onHlsAvailable():A.addEventListener("load",this.onHlsAvailable):(lg&&console.log("HLS: load script"),A=document.createElement("script"),A.dataset.hls_library="hls.js",A.src="https://cdn.jsdelivr.net/npm/hls.js@1",A.addEventListener("load",this.onHlsAvailable),document.head.append(A))}}ko([w()],og.prototype,"playOnAwake",2),ko([w()],og.prototype,"aspectMode",2),ko([w(URL)],og.prototype,"clip",2),ko([w()],og.prototype,"source",2),ko([w(URL)],og.prototype,"url",2),ko([w()],og.prototype,"renderMode",2),ko([w()],og.prototype,"targetMaterialProperty",2),ko([w(Ji)],og.prototype,"targetMaterialRenderer",2),ko([w(le)],og.prototype,"targetTexture",2),ko([w()],og.prototype,"time",2),ko([w()],og.prototype,"playbackSpeed",1),ko([w()],og.prototype,"isLooping",1),ko([w()],og.prototype,"audioOutputMode",1);class NnA{constructor(A){n(this,"context"),n(this,"_videos",[]),n(this,"_screenspaceModeQuad"),n(this,"_isInScreenspaceMode",!1),n(this,"_input"),this.context=A,this._input=new FnA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=ql.createPrimitive(QB.Quad,{material:new KnA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const i=this._screenspaceModeQuad;this.context.scene.add(i),this.updateScreenspaceMaterialUniforms();const g=i.material;g?.reset(),(A=this._input)==null||A.enable(g)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class FnA{constructor(A){n(this,"_onResizeScreenFn"),n(this,"_onKeyUpFn"),n(this,"_onMouseWheelFn"),n(this,"context"),n(this,"overlay"),n(this,"_material"),n(this,"_isPinching",!1),n(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=g=>{g.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=g=>{this.overlay.enabled&&(A.zoom+=g.deltaY*5e-4,g.preventDefault())},{passive:!1});const e=new eA;window.addEventListener("mousemove",g=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const I=new eA(g.movementX,g.movementY);I.x/=this.context.domElement.clientWidth,I.y/=this.context.domElement.clientHeight,e.set(I.x,I.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",g=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(g.movementX,g.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let i=0;window.addEventListener("touchstart",g=>{if(g.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",g=>{if(!this._isPinching||!this._material)return;const I=g.touches[0],o=g.touches[1],s=I.clientX-o.clientX,C=I.clientY-o.clientY,a=Math.sqrt(s*s+C*C);if(this._lastPinch!==0){const r=a-this._lastPinch;this._material.zoom-=r*.004}this._lastPinch=a}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class KnA extends Me{constructor(A){super(),n(this,"_offset",new eA),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new zA(0,0,1,1)}},this.vertexShader=`
|
|
6954
|
+
}`);new S(0,0,1);var faA=function(t){Dh(e,t);var A=wh(e);function e(i){var g;return ye(this,e),g=A.call(this,i),z(it(g),"positionBuffer",void 0),z(it(g),"previousBuffer",void 0),z(it(g),"nextBuffer",void 0),z(it(g),"uvBuffer",void 0),z(it(g),"sideBuffer",void 0),z(it(g),"widthBuffer",void 0),z(it(g),"colorBuffer",void 0),z(it(g),"indexBuffer",void 0),z(it(g),"vector_",new S),z(it(g),"vector2_",new S),z(it(g),"vector3_",new S),z(it(g),"quaternion_",new RA),g.maxParticles=1e4,g.setupBuffers(),g.rebuildMaterial(),g}return Se(e,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new he,this.indexBuffer=new ee(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(zg),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(zg),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(zg),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ee(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(zg),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ee(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(zg),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ee(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(zg),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ee(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(zg),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ee(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(zg),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(i){for(;i>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var i={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new eA(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new eA(1,1)}},g={};if(g.USE_UV="",g.USE_COLOR_ALPHA="",this.settings.material.map&&(g.USE_MAP="",g.MAP_UV=XN(this.settings.material.map.channel),i.map=new SA(this.settings.material.map),i.mapTransform=new SA(new Je().copy(this.settings.material.map.matrix))),this.settings.renderMode===ie.Trail)this.material=new Me({uniforms:i,defines:g,vertexShader:SaA,fragmentShader:yaA,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||cr});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var i=this,g=0,I=0,o=0;this.systems.forEach(function(s){for(var C=0;C<s.particleNum;C++)o+=s.particles[C].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(s){var C=i.quaternion_,a=i.vector2_,r=i.vector3_;s.emitter.matrixWorld.decompose(a,C,r);for(var B=s.particles,Q=s.particleNum,E=i.settings.uTileCount,h=i.settings.vTileCount,d=1/E,l=1/h,c=0;c<Q;c++){var p=B[c],u=p.uvTile%h,D=Math.floor(p.uvTile/h),k=p.previous.values(),U=k.next(),M=U.value,G=M;U.done||(U=k.next());var K=void 0;U.value!==void 0?K=U.value:K=G;for(var f=0;f<p.previous.length;f++,g+=2){if(i.positionBuffer.setXYZ(g,G.position.x,G.position.y,G.position.z),i.positionBuffer.setXYZ(g+1,G.position.x,G.position.y,G.position.z),s.worldSpace?(i.positionBuffer.setXYZ(g,G.position.x,G.position.y,G.position.z),i.positionBuffer.setXYZ(g+1,G.position.x,G.position.y,G.position.z)):(p.parentMatrix?i.vector_.copy(G.position).applyMatrix4(p.parentMatrix):i.vector_.copy(G.position).applyMatrix4(s.emitter.matrixWorld),i.positionBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.positionBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),s.worldSpace?(i.previousBuffer.setXYZ(g,M.position.x,M.position.y,M.position.z),i.previousBuffer.setXYZ(g+1,M.position.x,M.position.y,M.position.z)):(p.parentMatrix?i.vector_.copy(M.position).applyMatrix4(p.parentMatrix):i.vector_.copy(M.position).applyMatrix4(s.emitter.matrixWorld),i.previousBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.previousBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),s.worldSpace?(i.nextBuffer.setXYZ(g,K.position.x,K.position.y,K.position.z),i.nextBuffer.setXYZ(g+1,K.position.x,K.position.y,K.position.z)):(p.parentMatrix?i.vector_.copy(K.position).applyMatrix4(p.parentMatrix):i.vector_.copy(K.position).applyMatrix4(s.emitter.matrixWorld),i.nextBuffer.setXYZ(g,i.vector_.x,i.vector_.y,i.vector_.z),i.nextBuffer.setXYZ(g+1,i.vector_.x,i.vector_.y,i.vector_.z)),i.sideBuffer.setX(g,-1),i.sideBuffer.setX(g+1,1),s.worldSpace)i.widthBuffer.setX(g,G.size),i.widthBuffer.setX(g+1,G.size);else if(p.parentMatrix)i.widthBuffer.setX(g,G.size),i.widthBuffer.setX(g+1,G.size);else{var N=(Math.abs(r.x)+Math.abs(r.y)+Math.abs(r.z))/3;i.widthBuffer.setX(g,G.size*N),i.widthBuffer.setX(g+1,G.size*N)}i.uvBuffer.setXY(g,(f/p.previous.length+u)*d,(h-D-1)*l),i.uvBuffer.setXY(g+1,(f/p.previous.length+u)*d,(h-D)*l),i.colorBuffer.setXYZW(g,G.color.x,G.color.y,G.color.z,G.color.w),i.colorBuffer.setXYZW(g+1,G.color.x,G.color.y,G.color.z,G.color.w),f+1<p.previous.length&&(i.indexBuffer.setX(I*3,g),i.indexBuffer.setX(I*3+1,g+1),i.indexBuffer.setX(I*3+2,g+2),I++,i.indexBuffer.setX(I*3,g+2),i.indexBuffer.setX(I*3+1,g+1),i.indexBuffer.setX(I*3+2,g+3),I++),M=G,G=K,U.done||(U=k.next(),U.value!==void 0&&(K=U.value))}}}),this.positionBuffer.updateRange.count=g*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=g*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=g*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=g,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=g,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=g*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=g*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=I*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,I*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),e}(zO),maA=function(t){Dh(e,t);var A=wh(e);function e(){var i;return ye(this,e),i=A.call(this),z(it(i),"batches",[]),z(it(i),"systemToBatchIndex",new Map),z(it(i),"type","BatchedRenderer"),i}return Se(e,[{key:"addSystem",value:function(i){i._renderer=this;for(var g=i.getRendererSettings(),I=0;I<this.batches.length;I++)if(e.equals(this.batches[I].settings,g)){this.batches[I].addSystem(i),this.systemToBatchIndex.set(i,I);return}var o;switch(g.renderMode){case ie.Trail:o=new faA(g);break;case ie.Mesh:case ie.BillBoard:case ie.VerticalBillBoard:case ie.HorizontalBillBoard:case ie.StretchedBillBoard:o=new waA(g);break}o.addSystem(i),this.batches.push(o),this.systemToBatchIndex.set(i,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(i){var g=this.systemToBatchIndex.get(i);g!=null&&(this.batches[g].removeSystem(i),this.systemToBatchIndex.delete(i))}},{key:"updateSystem",value:function(i){this.deleteSystem(i),this.addSystem(i)}},{key:"update",value:function(i){this.systemToBatchIndex.forEach(function(I,o){o.update(i)});for(var g=0;g<this.batches.length;g++)this.batches[g].update()}}],[{key:"equals",value:function(i,g){return i.material.side===g.material.side&&i.material.blending===g.material.blending&&i.material.transparent===g.material.transparent&&i.material.type===g.material.type&&i.material.alphaTest===g.material.alphaTest&&i.material.map===g.material.map&&i.renderMode===g.renderMode&&i.uTileCount===g.uTileCount&&i.vTileCount===g.vTileCount&&i.instancingGeometry===g.instancingGeometry&&i.renderOrder===g.renderOrder&&i.layers.mask===g.layers.mask}}]),e}(uA),kaA=maA,$O=function(){function t(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new S;ye(this,t),z(this,"locations",[]),this.scaleX=A,this.scaleY=e,this.position=i}return Se(t,[{key:"transform",value:function(A,e){A.x=this.locations[e%this.locations.length].x*this.scaleX+this.position.x,A.y=this.locations[e%this.locations.length].y*this.scaleY+this.position.y,A.z=this.position.z}},{key:"clone",value:function(){var A=new t(this.scaleX,this.scaleY,this.position.clone());return A.locations=this.locations.map(function(e){return e.clone()}),A}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(A){return{x:A.x,y:A.y}})}}},{key:"fromImage",value:function(A,e){var i=document.createElement("canvas");i.width=A.width,i.height=A.height;var g=i.getContext("2d");if(g){g.drawImage(A,0,0);var I=g.getImageData(0,0,i.width,i.height,{colorSpace:"srgb"});i.remove(),this.locations.length=0;for(var o=0;o<I.height;o++)for(var s=0;s<I.width;s++)I.data[(o*I.width+s)*4+3]>e&&this.locations.push(new eA(s,I.height-o))}}}],[{key:"fromJSON",value:function(A){var e=new t(A.scaleX,A.scaleY,new S(A.position[0],A.position[1],A.position[2]));return e.locations=A.locations.map(function(i){return new eA(i.x,i.y)}),e}}]),t}();function GaA(t){switch(t.type){case"TextureSequencer":return $O.fromJSON(t);default:return new $O}}var MaA=function(){function t(A){ye(this,t),z(this,"type","ApplySequences"),z(this,"sequencers",[]),z(this,"time",0),z(this,"index",0),z(this,"pCount",0),z(this,"delay",void 0),z(this,"tempV",new S),this.delay=A}return Se(t,[{key:"initialize",value:function(A){A.id=this.pCount,A.dst=new S,A.begin=new S,A.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(A,e){var i=this.sequencers[this.index],g=A.id*this.delay;this.time>=i[0].a+g&&this.time<=i[0].b+g?(A.inMotion||(A.inMotion=!0,A.begin.copy(A.position),i[1].transform(A.dst,A.id)),A.position.lerpVectors(A.begin,A.dst,t.BEZIER.genValue((this.time-i[0].a-g)/(i[0].b-i[0].a)))):this.time>i[0].b+g&&(A.inMotion=!1)}},{key:"frameUpdate",value:function(A){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=A}},{key:"appendSequencer",value:function(A,e){this.sequencers.push([A,e])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(A){var e=yh(A,2),i=e[0],g=e[1];return{range:i.toJSON(),sequencer:g.toJSON()}})}}},{key:"clone",value:function(){var A=new t(this.delay);return A.sequencers=this.sequencers.map(function(e){return[e[0].clone(),e[1].clone()]}),A}}],[{key:"fromJSON",value:function(A){var e=new t(A.delay);return A.sequencers.forEach(function(i){e.sequencers.push([Lt(i.range),GaA(i.sequencer)])}),e}}]),t}();z(MaA,"BEZIER",new TN(0,0,1,1));var EA=function(t){return t[t.Number=0]="Number",t[t.Vec2=1]="Vec2",t[t.Vec3=2]="Vec3",t[t.Vec4=3]="Vec4",t[t.Boolean=4]="Boolean",t[t.AnyType=5]="AnyType",t}({}),A1=Se(function t(A,e,i,g){ye(this,t),z(this,"input",void 0),z(this,"inputIndex",void 0),z(this,"output",void 0),z(this,"outputIndex",void 0),this.input=A,this.inputIndex=e,this.input.outputs[e].push(this),this.output=i,this.outputIndex=g,this.output.inputs[g]=this}),UaA=function(){function t(){ye(this,t),z(this,"visited",new Set),z(this,"graph_",void 0),z(this,"context_",void 0),t.Instance=this}return Se(t,[{key:"traverse",value:function(A){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(A.id);for(var e=[],i=0;i<A.inputs.length;i++)if(A.inputs[i]instanceof A1){var g=A.inputs[i].input;this.visited.has(g.id)||this.traverse(g),e.push(g.outputValues[A.inputs[i].inputIndex])}else e.push(A.inputs[i].getValue(this.context_));A.func(this.context_,e,A.outputValues),this.graph_.nodesInOrder.push(A)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var A=this.graph_.nodesInOrder,e=0;e<A.length;e++){for(var i=[],g=A[e],I=0;I<g.inputs.length;I++)if(g.inputs[I]instanceof A1)i.push(g.inputs[I].input.outputValues[g.inputs[I].inputIndex]);else if(g.inputs[I]!==void 0)i.push(g.inputs[I].getValue(this.context_));else throw new Error("miss input for node ".concat(g.id));g.func(this.context_,i,g.outputValues)}}},{key:"run",value:function(A,e){if(this.graph_=A,this.context_=e,A.compiled)this.executeCompiledGraph();else{A.nodesInOrder.length=0,this.visited.clear();for(var i=0;i<A.outputNodes.length;i++){var g=A.outputNodes[i];this.traverse(g)}A.compiled=!0}}}]),t}();z(UaA,"Instance",void 0);var nt=function(){function t(A){ye(this,t),z(this,"name",void 0),z(this,"nodeTypeSignatures",[]),this.name=A}return Se(t,[{key:"addSignature",value:function(A,e,i){this.nodeTypeSignatures.push({inputTypes:A,outputTypes:e,func:i})}}]),t}(),L0=new nt("add");L0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]+e[1]}),L0.addSignature([EA.Vec2,EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].addVectors(e[0],e[1])}),L0.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].addVectors(e[0],e[1])}),L0.addSignature([EA.Vec4,EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].addVectors(e[0],e[1])});var Y0=new nt("sub");Y0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]-e[1]}),Y0.addSignature([EA.Vec2,EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].subVectors(e[0],e[1])}),Y0.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].subVectors(e[0],e[1])}),Y0.addSignature([EA.Vec4,EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].subVectors(e[0],e[1])});var _0=new nt("mul");_0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]*e[1]}),_0.addSignature([EA.Vec2,EA.Number],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])}),_0.addSignature([EA.Vec3,EA.Number],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])}),_0.addSignature([EA.Vec4,EA.Number],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).multiplyScalar(e[1])});var H0=new nt("div");H0.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]/e[1]}),H0.addSignature([EA.Vec2,EA.Number],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])}),H0.addSignature([EA.Vec3,EA.Number],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])}),H0.addSignature([EA.Vec4,EA.Number],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).divideScalar(e[1])});var RaA=new nt("sin");RaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.sin(e[0])});var NaA=new nt("cos");NaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.cos(e[0])});var FaA=new nt("tan");FaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.tan(e[0])});var KaA=new nt("abs");KaA.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.abs(e[0])});var JaA=new nt("min");JaA.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.min(e[0],e[1])});var vaA=new nt("max");vaA.addSignature([EA.Number,EA.Number],[EA.Number],function(t,A,e,i){i[0]=Math.max(e[0],e[1])});var $N=new nt("dot");$N.addSignature([EA.Vec2,EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])}),$N.addSignature([EA.Vec3,EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])}),$N.addSignature([EA.Vec4,EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].dot(e[1])});var baA=new nt("cross");baA.addSignature([EA.Vec3,EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].crossVectors(e[0],e[1])});var AF=new nt("length");AF.addSignature([EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].length()}),AF.addSignature([EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].length()}),AF.addSignature([EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].length()});var eF=new nt("lengthSq");eF.addSignature([EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()}),eF.addSignature([EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()}),eF.addSignature([EA.Vec4],[EA.Number],function(t,A,e,i){i[0]=e[0].lengthSq()});var tF=new nt("normalize");tF.addSignature([EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0].copy(e[0]).normalize()}),tF.addSignature([EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0].copy(e[0]).normalize()}),tF.addSignature([EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0].copy(e[0]).normalize()});var e1=new nt("distance");e1.addSignature([EA.Vec2,EA.Vec2],[EA.Number],function(t,A,e,i){i[0]=e[0].distanceTo(e[1])}),e1.addSignature([EA.Vec3,EA.Vec3],[EA.Number],function(t,A,e,i){i[0]=e[0].distanceTo(e[1])});var qaA=new nt("and");qaA.addSignature([EA.Boolean,EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]&&e[1]});var xaA=new nt("or");xaA.addSignature([EA.Boolean,EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]||e[1]});var LaA=new nt("not");LaA.addSignature([EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=!e[0]});var T0=new nt("equal");T0.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]===e[1]}),T0.addSignature([EA.Vec2,EA.Vec2],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])}),T0.addSignature([EA.Vec3,EA.Vec3],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])}),T0.addSignature([EA.Vec4,EA.Vec4],[EA.Boolean],function(t,A,e,i){i[0]=e[0].equals(e[1])});var YaA=new nt("lessThan");YaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]<e[1]});var _aA=new nt("greaterThan");_aA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]>e[1]});var HaA=new nt("lessThanOrEqual");HaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]<=e[1]});var TaA=new nt("greaterThanOrEqual");TaA.addSignature([EA.Number,EA.Number],[EA.Boolean],function(t,A,e,i){i[0]=e[0]>=e[1]});var OaA=new nt("if");OaA.addSignature([EA.Boolean,EA.AnyType,EA.AnyType],[EA.AnyType],function(t,A,e,i){i[0]=e[0]?e[1]:e[2]});var PaA=new nt("number");PaA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=A.value});var jaA=new nt("vec2");jaA.addSignature([],[EA.Vec2],function(t,A,e,i){i[0]=A.value});var WaA=new nt("vec3");WaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=A.value});var ZaA=new nt("vec4");ZaA.addSignature([],[EA.Vec4],function(t,A,e,i){i[0]=A.value});var VaA=new nt("bool");VaA.addSignature([],[EA.Boolean],function(t,A,e,i){i[0]=A.value});var zaA=new nt("particlePosition");zaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=t.particle[A.property]});var XaA=new nt("particleVelocity");XaA.addSignature([],[EA.Vec3],function(t,A,e,i){i[0]=t.particle[A.property]});var $aA=new nt("particleRotation");$aA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=t.particle[A.property]});var AnA=new nt("particleAge");AnA.addSignature([],[EA.Number],function(t,A,e,i){i[0]=t.particle[A.property]});var Cp=new nt("output");Cp.addSignature([EA.Number],[EA.Number],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec2],[EA.Vec2],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec3],[EA.Vec3],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Vec4],[EA.Vec4],function(t,A,e,i){i[0]=e[0]}),Cp.addSignature([EA.Boolean],[EA.Boolean],function(t,A,e,i){i[0]=e[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var enA=Object.defineProperty,tnA=Object.getOwnPropertyDescriptor,hi=(t,A,e,i)=>{for(var g=i>1?void 0:i?tnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&enA(A,e,g),g};const ap=tA("debugparticles"),inA=tA("noprogressive"),gnA=tA("debugprogressive");var iF=(t=>(t[t.Birth=0]="Birth",t[t.Collision=1]="Collision",t[t.Death=2]="Death",t[t.Trigger=3]="Trigger",t[t.Manual=4]="Manual",t))(iF||{});class gs extends FA{constructor(){super(...arguments),n(this,"renderMode"),n(this,"particleMaterial"),n(this,"trailMaterial"),n(this,"particleMesh"),n(this,"maxParticleSize"),n(this,"minParticleSize"),n(this,"velocityScale"),n(this,"cameraVelocityScale"),n(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&re()){const A=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(A)}}get transparent(){var A;return((A=this.particleMaterial)==null?void 0:A.transparent)??!1}getMaterial(A=!1){let e=A===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return e&&A&&e.side===Dg&&(e=e.clone(),e.side=pi,A?this.trailMaterial=e:this.particleMaterial=e),e&&!inA&&e._didRequestTextureLOD===void 0&&(e._didRequestTextureLOD=0,gnA&&console.log("Load material LOD",e.name),Jt.assignTextureLOD(this.context,this.sourceId,e)),e}getMesh(A){let e=null;if(!e&&(this.particleMesh instanceof hA&&(e=this.particleMesh.geometry),e===null)){e=new Zi(1,1);const i=e.attributes.uv;for(let g=0;g<i.count;g++)i.setX(g,1-i.getX(g))}return new hA(e,this.getMaterial())}}hi([w()],gs.prototype,"renderMode",2),hi([w(Re)],gs.prototype,"particleMaterial",2),hi([w(Re)],gs.prototype,"trailMaterial",2),hi([w()],gs.prototype,"maxParticleSize",2),hi([w()],gs.prototype,"minParticleSize",2),hi([w()],gs.prototype,"velocityScale",2),hi([w()],gs.prototype,"cameraVelocityScale",2),hi([w()],gs.prototype,"lengthScale",2);class O0{constructor(A,e=1){n(this,"_curve"),n(this,"_factor"),n(this,"type","function"),this._curve=A,this._factor=e}genValue(A){return this._curve.evaluate(A,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class gF{constructor(A){n(this,"type","value"),n(this,"system"),this.system=A}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class InA extends gF{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class onA extends gF{constructor(){super(...arguments),n(this,"_lastPosition",new S),n(this,"_lastDistance",0)}update(){const A=Fe(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(A),this._lastPosition.copy(A)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let A=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const g=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let I=this._lastDistance/this.system.deltaTime*g;Number.isFinite(I)||(I=0),A+=I}const e=this.system.emission.getBurst();e>0&&(A+=e/this.system.deltaTime);const i=this.system.maxParticles-this.system.currentParticles;return Ae.clamp(A,0,i/this.system.deltaTime)}}class snA extends gF{genValue(){return this.system.isPlaying,0}}class tr{constructor(A){n(this,"system"),n(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",A&&(this.system=A)}get context(){return this.system.context}initialize(A){}update(A,e){}frameUpdate(A){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class CnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleTextureSheet")}update(A,e){const i=this.system.textureSheetAnimation;if(i.enabled){const g=A.age/A.life,I=i.evaluate(g);I!==void 0&&(A.uvTile=I)}}}const t1=Symbol("particleRotation");class anA extends tr{constructor(){super(...arguments),n(this,"type","NeedleRotation")}initialize(A){A[t1]=Math.random()}update(A,e){if(A.rotation===void 0)return;const i=A.age/A.life;if(typeof A.rotation=="number"&&(this.system.rotationOverLifetime.enabled?A.rotation+=this.system.rotationOverLifetime.evaluate(i,A[t1])*e:this.system.renderer.renderMode===Ma.Billboard&&(A.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const g=A.velocity.length();A.rotation+=this.system.rotationBySpeed.evaluate(i,g)*e}}}const i1=Symbol("sizeLerpFactor"),nnA=new S;class rnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleSize"),n(this,"_minSize",0),n(this,"_maxSize",1)}initialize(A){A[i1]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(A,e){const i=A.age/A.life;let g=1;this.system.sizeOverLifetime.enabled&&(g*=this.system.sizeOverLifetime.evaluate(i,void 0,A[i1]).x);let I=1;if(this.system.renderer.renderMode!==Ma.Mesh&&(I=this.system.worldScale.x/this.system.cameraScale),A.size=A.startSize*g*I,this.system.localspace){const o=C1(this.system,nnA);A.size*=o.x}}}const Sh=Symbol("particleLife"),IF=Symbol("trailLifetime"),g1=Symbol("trailStartLength"),oF=Symbol("trailWidthRandom");class BnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleTrail")}initialize(A){A instanceof ip&&(A[Sh]=A.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(A[IF]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),A.life+=A[IF]),A[g1]=A.length,A[oF]=Math.random())}update(A){var e;if((e=this.system.trails)!=null&&e.enabled&&A instanceof ip){const i=A,g=A.age/A[Sh],I=A.previous.values(),o=A.previous.length;for(let s=0;s<o;s++){const C=I.next().value,a=1-s/(o-1);let r=A.size;r<=0&&!this.system.trails.sizeAffectsWidth&&(r=20*this.system.trails.widthOverTrail.evaluate(.5,i[oF])),C.size=this.system.trails.getWidth(r,g,a,i[oF]),C.color.copy(A.color),this.system.trails.getColor(C.color,g,a)}if(A.age>A[Sh]){A.velocity.set(0,0,0);const s=(A.age-A[Sh])/A[IF];i.length=Ae.lerp(A[g1],0,s)}}}}const P0=Symbol("startVelocity"),I1=Symbol("gravityModifier"),sF=Symbol("gravitySpeed"),j0=Symbol("velocity lerp factor"),CF=new S;class QnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleVelocity"),n(this,"_gravityDirection",new S)}initialize(A){var e,i;const g=this.system.main.simulationSpeed;A.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),A.velocity.copy(this.system.shape.getDirection(A,A.position)).multiplyScalar(A.startSpeed),(e=this.system.inheritVelocity)!=null&&e.enabled&&this.system.inheritVelocity.applyInitial(A.velocity),A[P0]?A[P0].copy(A.velocity):A[P0]=A.velocity.clone();const I=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());A[I1]=I*g,A[sF]=I*g*.5,A[j0]=Math.random(),(i=this.system.velocityOverLifetime)==null||i.init(A),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Ld.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(A,e){var i;const g=A[P0],I=A[I1];if(I!==0){const Q=I*A[sF];CF.copy(this._gravityDirection).multiplyScalar(Q),A[sF]+=e*.05,g.add(CF)}A.velocity.copy(g);const o=A.age/A.life;(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyCurrent(A.velocity,o,A[j0]);const s=this.system.noise;s.enabled&&s.apply(0,A.position,A.velocity,e,A.age,A.life);const C=this.system.sizeBySpeed;C!=null&&C.enabled&&(A.size=C.evaluate(A.velocity,o,A[j0],A.size));const a=this.system.colorBySpeed;a!=null&&a.enabled&&a.evaluate(A.velocity,A[j0],A.color);const r=this.system.velocityOverLifetime;r.enabled&&r.apply(A,0,A.position,A.velocity,e,A.age,A.life);const B=this.system.limitVelocityOverLifetime;B.enabled&&B.apply(A.position,g,A.velocity,A.size,o,e,1),this.system.worldspace&&A.velocity.multiply(this.system.worldScale)}}const o1=Symbol("colorLerpFactor"),s1=new St(1,1,1,1),zB=new St(1,1,1,1);class EnA extends tr{constructor(){super(...arguments),n(this,"type","NeedleColor")}initialize(A){}_init(A){const e=this.system.renderer.particleMaterial;zB.copy(this.system.main.startColor.evaluate(Math.random())),e!=null&&e.color&&(s1.copy(e.color),zB.multiply(s1)),zB.convertLinearToSRGB(),A.startColor.set(zB.r,zB.g,zB.b,zB.alpha),A.color.copy(A.startColor),A[o1]=Math.random()}update(A,e){if(A.age===0&&this._init(A),this.system.colorOverLifetime.enabled){const i=A.age/A.life,g=this.system.colorOverLifetime.color.evaluate(i,A[o1]);A.color.set(g.r,g.g,g.b,g.alpha).multiply(A.startColor)}else A.color.copy(A.startColor)}}class hnA{constructor(A){n(this,"system"),n(this,"emission"),n(this,"autoDestroy"),n(this,"startLength"),n(this,"emissionBursts"),n(this,"onlyUsedByOther"),n(this,"behaviors",[]),n(this,"rendererEmitterSettings",{startLength:new BI(220),followLocalOrigin:!1}),n(this,"flatWhiteTexture"),n(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=A,this.emission=new onA(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new O0(this.system.main.startLifetime)}get startSpeed(){return new O0(this.system.main.startSpeed)}get startRotation(){return new O0(this.system.main.startRotation)}get startSize(){return new O0(this.system.main.startSize)}get startColor(){return new x0(new zA(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new snA(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return ie.Trail;switch(this.system.renderer.renderMode){case Ma.Billboard:return ie.BillBoard;case Ma.Stretch:return ie.StretchedBillBoard;case Ma.HorizontalBillboard:return ie.HorizontalBillBoard;case Ma.VerticalBillboard:return ie.VerticalBillBoard;case Ma.Mesh:return ie.Mesh}return ie.BillBoard}get speedFactor(){var A;let e=this.system.main.simulationSpeed;return((A=this.system.renderer)==null?void 0:A.renderMode)===Ma.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const A=this.material;if(A&&A.map){const e=A.map;if(this.clonedTexture.original!==e||!this.clonedTexture.clone){const i=e.clone();i.premultiplyAlpha=!1,i.colorSpace=lt,this.clonedTexture.original=e,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=VH(new St(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new InA(this.system)}get uTileCount(){var A;return this.anim.enabled?(A=this.anim)==null?void 0:A.numTilesX:void 0}get vTileCount(){var A;return this.anim.enabled?(A=this.anim)==null?void 0:A.numTilesY:void 0}get renderOrder(){return 1}get blending(){var A;return((A=this.system.renderer.particleMaterial)==null?void 0:A.blending)??ja}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Ld.World}}class cnA{constructor(){n(this,"burstIndex",0),n(this,"burstWaveIndex",0),n(this,"time",0),n(this,"waitEmiting",0)}}const W0=class extends FA{constructor(){super(...arguments),n(this,"_state"),n(this,"colorOverLifetime"),n(this,"main"),n(this,"emission"),n(this,"sizeOverLifetime"),n(this,"shape"),n(this,"noise"),n(this,"trails"),n(this,"velocityOverLifetime"),n(this,"limitVelocityOverLifetime"),n(this,"inheritVelocity"),n(this,"colorBySpeed"),n(this,"textureSheetAnimation"),n(this,"rotationOverLifetime"),n(this,"rotationBySpeed"),n(this,"sizeBySpeed"),n(this,"_cameraScale",1),n(this,"__worldQuaternion",new RA),n(this,"_worldQuaternionInverted",new RA),n(this,"_worldScale",new S),n(this,"_worldPositionFrame",-1),n(this,"_worldPos",new S),n(this,"_renderer"),n(this,"_batchSystem"),n(this,"_particleSystem"),n(this,"_interface"),n(this,"_container"),n(this,"_time",0),n(this,"_isPlaying",!0),n(this,"_isUsedAsSubsystem",!1),n(this,"_didPreWarm",!1),n(this,"_bursts"),n(this,"_subEmitterSystems"),n(this,"_lastBatchesCount",-1),n(this,"lastMaterialVersion",-1)}play(t=!1){var A;t&&CA.foreachComponent(this.gameObject,e=>{e instanceof W0&&e!==this&&e.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(A=this.emission)==null||A.reset()}pause(t=!0){t&&CA.foreachComponent(this.gameObject,A=>{A instanceof W0&&A!==this&&A.pause(!1)},!0),this._isPlaying=!1}stop(t=!0,A=!1){t&&CA.foreachComponent(this.gameObject,e=>{e instanceof W0&&e!==this&&e.stop(!1,A)},!0),this._isPlaying=!1,this._time=0,A&&this.reset()}reset(){var t;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(t=this.emission)==null||t.reset())}emit(t){if(this._particleSystem){this.onUpdate(),t=Math.min(t,this.maxParticles-this.currentParticles),this._state||(this._state=new cnA),this._state.waitEmiting=t,this._state.time=0;const A=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=A}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(t){this.main.playOnAwake=t}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var t;return((t=this._particleSystem)==null?void 0:t.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Ld.World}get localspace(){return this.main.simulationSpace===Ld.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Fe(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(t){return this._particleSystem?(t instanceof tr&&(t.system=this),re()&&console.log("add behaviour",t),this._particleSystem.addBehavior(t),!0):!1}removeBehaviour(t){if(!this._particleSystem)return!1;const A=this._particleSystem.behaviors,e=A.indexOf(t);return e!==-1&&A.splice(e,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(t){for(let A=0;A<t.length;A++){const e=t[A];if(!(e instanceof Yd)){const i=new Yd;wE(i,e),t[A]=i}}this._bursts=t}set subEmitterSystems(t){for(let A=0;A<t.length;A++){const e=t[A];if(!(e instanceof np)){const i=new np;wE(i,e),t[A]=i}}ap&&t.length>0&&console.log("SubEmitters: ",t,this),this._subEmitterSystems=t}onAfterDeserialize(t){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const A of this._subEmitterSystems)A._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(gs),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new uA,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new kaA,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new hnA(this),this._particleSystem=new caA(this._interface),this._particleSystem.addBehavior(new rnA(this)),this._particleSystem.addBehavior(new EnA(this)),this._particleSystem.addBehavior(new CnA(this)),this._particleSystem.addBehavior(new anA(this)),this._particleSystem.addBehavior(new QnA(this)),this._particleSystem.addBehavior(new BnA(this)),this._batchSystem.addSystem(this._particleSystem);const t=this._particleSystem.emitter;this.context.scene.add(t),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),ap&&(console.log(this),this.gameObject.add(new bo(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var t,A,e,i;(t=this._container)==null||t.removeFromParent(),(A=this._batchSystem)==null||A.removeFromParent(),(e=this._particleSystem)==null||e.emitter.removeFromParent(),(i=this._particleSystem)==null||i.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var t;this.main&&(this._didPreWarm===!1&&((t=this.main)==null?void 0:t.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var t;if(!((t=this.emission)!=null&&t.enabled)||this.emission.rateOverTime.getMax()<=0)return;const A=1/60,e=this.main.duration,i=this.main.startLifetime.getMax(),g=1e3,I=Math.min(Math.max(e,i)/Math.max(.01,this.main.simulationSpeed),g),o=Math.ceil(I/A),s=Date.now();ap&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${I} sec). Duration: ${e}, Lifetime: ${i}`);for(let C=0;C<o&&!(this.currentParticles>=this.maxParticles);C++){const a=Date.now()-s;if(a>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${a}`);break}this.onUpdate(),this.onSimulate(A)}}onSimulate(t){if(this._batchSystem){let A=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,A=!0),A&&this.updateLayers(),this._batchSystem.update(t)}this._time+=t,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let t=0;t<this._batchSystem.batches.length;t++){const A=this._batchSystem.batches[t];A.layers.disableAll();const e=this.layer;A.layers.mask=1<<e}}onUpdate(){var t,A;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const i=this.context.mainCamera;if(i){const o=Tt(i);this._cameraScale=o.x}const g=!this.worldspace,I=this.gameObject;if(Gt(I,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Tt(this.gameObject,this._worldScale),g&&this._container&&(t=this.gameObject)!=null&&t.parent){const o=C1(this,CF);this._container.matrix.makeScale(o.x,o.y,o.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(A=this.inheritVelocity)==null||A.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var t;if(this._subEmitterSystems&&this._particleSystem)for(const A of this._subEmitterSystems){A.particleSystem&&(A.particleSystem.__internalAwake?A.particleSystem.__internalAwake():re()&&console.warn("SubParticleSystem serialization issue(?)",A.particleSystem,A));const e=(t=A.particleSystem)==null?void 0:t._particleSystem;if(e){A.particleSystem._isUsedAsSubsystem=!0;const i=new Z0(this,this._particleSystem,A.particleSystem,e);i.emitterType=A.type,i.emitterProbability=A.emitProbability,this._particleSystem.addBehavior(i)}else ap&&console.warn("Could not add SubParticleSystem",A,this)}}};let Pi=W0;hi([w(_d)],Pi.prototype,"colorOverLifetime",2),hi([w(_g)],Pi.prototype,"main",2),hi([w(pC)],Pi.prototype,"emission",2),hi([w(Vn)],Pi.prototype,"sizeOverLifetime",2),hi([w(Qi)],Pi.prototype,"shape",2),hi([w(mt)],Pi.prototype,"noise",2),hi([w(ii)],Pi.prototype,"trails",2),hi([w(Ei)],Pi.prototype,"velocityOverLifetime",2),hi([w(Ti)],Pi.prototype,"limitVelocityOverLifetime",2),hi([w(zn)],Pi.prototype,"inheritVelocity",2),hi([w(xB)],Pi.prototype,"colorBySpeed",2),hi([w(Hg)],Pi.prototype,"textureSheetAnimation",2),hi([w(ts)],Pi.prototype,"rotationOverLifetime",2),hi([w(wo)],Pi.prototype,"rotationBySpeed",2),hi([w(KI)],Pi.prototype,"sizeBySpeed",2);class np{constructor(){n(this,"particleSystem"),n(this,"emitProbability",1),n(this,"properties"),n(this,"type")}_deserialize(A,e){const i=this.particleSystem;if(i instanceof Pi)return;let g="";i&&typeof i.guid=="string"&&(g=i.guid,this.particleSystem=CA.findByGuid(g,e)),ap&&!(this.particleSystem instanceof Pi)&&console.warn("Could not find particle system for sub emitter",g,e,this)}}function C1(t,A){if(A.set(1,1,1),t.gameObject.parent&&t.localspace)switch(t.main.scalingMode){case aN.Local:A=Tt(t.gameObject.parent,A),A.x=1/A.x,A.y=1/A.y,A.z=1/A.z;break;default:if(!t.unsupported_scaling_mode){t.unsupported_scaling_mode=!0;const e="ParticleSystem scale mode "+aN[t.main.scalingMode]+" is not supported";re()&&Ci(e),console.warn(e,t.name,t)}A=Tt(t.gameObject,A);break}return A}new S(1,1,1),new S(0,0,1);class Z0{constructor(A,e,i,g){n(this,"type","NeedleParticleSubEmitter"),n(this,"emitterType"),n(this,"emitterProbability"),n(this,"q_",new RA),n(this,"v_",new S),n(this,"v2_",new S),n(this,"_emitterMatrix",new MA),n(this,"_circularBuffer"),this.system=A,this.particleSystem=e,this.subSystem=i,this.subParticleSystem=g,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const I=1e3;this._circularBuffer=new qo(()=>new MA,I)}clone(){throw new Error("Method not implemented.")}initialize(A){A.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===iF.Birth&&this.run(A)}update(A,e){this.run(A)}frameUpdate(A){}toJSON(){}reset(){}run(A){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!A.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const e=this.system.deltaTime;if(this.emitterType===iF.Death){let g=A.life;if(A[Sh]!==void 0&&(g=A[Sh]),!(A.age+e*1.2>=g))return;const I=this.subSystem.main.maxParticles-this.subSystem.currentParticles;A.emissionState.waitEmiting=I}const i=new MA;i.set(1,0,0,A.position.x,0,1,0,A.position.y,0,0,1,A.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(e,A.emissionState,i)}}var lnA=Object.defineProperty,dnA=Object.getOwnPropertyDescriptor,pnA=(t,A,e,i)=>{for(var g=i>1?void 0:i?dnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lnA(A,e,g),g};class rp extends aI{constructor(){super(...arguments),n(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const A=new JY;return this.granularity.onValueChanged=e=>{A.granularity=e},A}}pnA([w(Ne)],rp.prototype,"granularity",2),As("PixelationEffect",rp);class Wh extends FA{constructor(){super(...arguments),n(this,"_didAssignPlayerColor",!1),n(this,"tryAssignColor",()=>{const A=CA.getComponentInParent(this.gameObject,es);if(A&&A.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(A.owner),!0;const e=CA.getComponentInParent(this.gameObject,xg);return e!=null&&e.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(e.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(At.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(At.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield YH(.2),!this.tryAssignColor()););}assignUserColor(A){const e=Wh.hashCode(A),i=Wh.colorFromHashCode(e);if(this.gameObject.type==="Mesh"){const g=this.gameObject;this.assignColor(i,A,g)}else if(this.gameObject.children)for(const g of this.gameObject.children){const I=g;I.material&&I.material.color&&this.assignColor(i,A,I)}}assignColor(A,e,i){let g=i.material;g&&(g._playerMaterial!==e&&(g=g.clone(),g._playerMaterial=e,i.material=g),g.color=A)}static hashCode(A){var e=0,i,g;if(A.length===0)return e;for(i=0;i<A.length;i++)g=A.charCodeAt(i),e=(e<<5)-e+g,e|=0;return e}static colorFromHashCode(A){const e=(A&16711680)>>16,i=(A&65280)>>8,g=A&255;return new GA(e/255,i/255,g/255)}}async function aF(t){const{NeedleEngineHTMLElement:A}=await Promise.resolve().then(()=>RBA);A.observedAttributes.includes(t)||A.observedAttributes.push(t)}var unA=Object.defineProperty,DnA=Object.getOwnPropertyDescriptor,Bp=(t,A,e,i)=>{for(var g=i>1?void 0:i?DnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&unA(A,e,g),g};const Is=tA("debugskybox");aF("skybox-image"),aF("environment-image");function a1(t,A,e,i,g){const I=new SC;I.allowDrop=!1,I.allowNetworking=!1,I.background=e,I.environment=i,CA.addComponent(t.scene,I);const o=s=>{typeof s=="string"&&(Is&&console.log(g,"CHANGED TO",s),I.setSkybox(s))};return lq(t.domElement,g,o),I.addEventListener("destroy",()=>{Is&&console.log("Destroyed attribute remote skybox",g),dq(t.domElement,g,o)}),I.setSkybox(A)}et.addContextCreatedCallback(t=>{var A;const e=t.context,i=e.domElement.getAttribute("skybox-image"),g=e.domElement.getAttribute("environment-image"),I=new Array;if(i){Is&&console.log("Creating remote skybox to load "+i),((A=e.mainCameraComponent)==null?void 0:A.clearFlags)!==wB.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=a1(e,i,!0,!1,"skybox-image");I.push(o)}if(g){Is&&console.log("Creating remote environment to load "+g);const o=a1(e,g,!1,!0,"environment-image");I.push(o)}return I.length>0?Yc(I):Promise.resolve()});function n1(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function r1(t){const A=n1().find(e=>e.src===t);return A?(Is&&console.log("Skybox: Found previously loaded texture for "+t),A.texture):null}async function wnA(t){const A=await t;YM(A,!0),qt(A)}function ynA(t,A){const e=n1();for(;e.length>5;){const i=e.shift();i&&wnA(i.texture)}A.then(i=>YM(i,!1)),e.push({src:t,texture:A})}class SC extends FA{constructor(){super(...arguments),n(this,"url"),n(this,"allowDrop",!0),n(this,"background",!0),n(this,"environment",!0),n(this,"allowNetworking",!0),n(this,"_loader"),n(this,"_prevUrl"),n(this,"_prevLoadedEnvironment"),n(this,"_prevEnvironment",null),n(this,"_prevBackground",null),n(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),n(this,"onDragOverEvent",A=>{if(this.allowDrop&&A.dataTransfer)for(const e of A.dataTransfer.types)(e==="text/uri-list"||e==="Files")&&A.preventDefault()}),n(this,"onDrop",A=>{var e,i,g,I;if(this.allowDrop&&A.dataTransfer){for(const o of A.dataTransfer.types)if(Is&&console.log(o),o==="text/uri-list"){const s=A.dataTransfer.getData(o);Is&&console.log(o,s);let C=(i=(e=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(s))==null?void 0:e.groups)==null?void 0:i.name;if(C||(C=(I=(g=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(s))==null?void 0:g.groups)==null?void 0:I.name),Is&&console.log(C),C){const a="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+C+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${a}`),A.preventDefault(),this.setSkybox(a);break}else if(this.isValidTextureType(s)){console.log("[Remote Skybox] Setting skybox from url: "+s),A.preventDefault(),this.setSkybox(s);break}else{console.warn(`[RemoteSkybox] Unknown url ${s}. If you want to load a skybox from a url, make sure it is a valid image url. Url must end with${this.validTextureTypes.join(", ")}.`);const a=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:A,url:s,apply:r=>{A.preventDefault(),this.setSkybox(r)}}});this.dispatchEvent(a)}}else if(o=="Files"){const s=A.dataTransfer.files.item(0);if(Is&&console.log(o,s),!s)continue;if(!this.isValidTextureType(s.name)){console.warn(`[RemoteSkybox]: File "${s.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(r1(s.name)===null){const C=new Blob([s]),a=URL.createObjectURL(C);A.preventDefault(),this.setSkybox(a,s.name)}else A.preventDefault(),this.setSkybox(s.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var A;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,xt.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(A=this.context.mainCameraComponent)==null||A.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(A,e){var i;if(!this.activeAndEnabled||!A)return!1;if(e??(e=A),this.isValidTextureType(e)||console.warn("Potentially invalid skybox url",e,"on",this.name),Is&&console.log("Remote skybox url?: "+A),this._prevUrl===A&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(i=this._prevLoadedEnvironment)==null||i.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=A;const g=await this.loadTexture(A,e);if(!g||!this.enabled)return!1;this.url=A;const I=A.lastIndexOf("/");return g.name=A.substring(I>=0?I+1:0),this._loader instanceof zs&&(g.colorSpace=Ee),this._prevLoadedEnvironment=g,this.applySkybox(),!0}async loadTexture(A,e){var i,g,I,o,s;if(!A)return Promise.resolve(null);e??(e=A);const C=r1(e);if(C){const Q=await C;if(((g=(i=Q.source)==null?void 0:i.data)==null?void 0:g.length)>0||(s=(o=(I=Q.source)==null?void 0:I.data)==null?void 0:o.data)!=null&&s.length)return Q}const a=e.endsWith(".exr"),r=e.endsWith(".hdr");a?this._loader instanceof Cy||(this._loader=new Cy):r?this._loader instanceof PU||(this._loader=new PU):this._loader instanceof zs||(this._loader=new zs),Is&&console.log("Loading skybox: "+A);const B=this._loader.loadAsync(A);return ynA(e,B),await B}applySkybox(){var A;const e=this._prevLoadedEnvironment;e&&(e.mapping=lQ,e.needsUpdate=!0,this.context.scene.background!==e&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==e&&(this._prevEnvironment=this.context.scene.environment),Is&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=e),this.background&&!xt.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=e),((A=this.context.mainCameraComponent)==null?void 0:A.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(A){return A.startsWith("http://")||A.startsWith("https://")}isValidTextureType(A){for(const e of this.validTextureTypes)if(A.endsWith(e))return!0;return!1}registerDropEvents(){this.unregisterDropEvents(),this.context.domElement.addEventListener("dragover",this.onDragOverEvent),this.context.domElement.addEventListener("drop",this.onDrop)}unregisterDropEvents(){this.context.domElement.removeEventListener("dragover",this.onDragOverEvent),this.context.domElement.removeEventListener("drop",this.onDrop)}}Bp([fR(SC.prototype.urlChangedSyncField),w(URL)],SC.prototype,"url",2),Bp([w()],SC.prototype,"allowDrop",2),Bp([w()],SC.prototype,"background",2),Bp([w()],SC.prototype,"environment",2),Bp([w()],SC.prototype,"allowNetworking",2);var SnA=Object.defineProperty,fnA=Object.getOwnPropertyDescriptor,fo=(t,A,e,i)=>{for(var g=i>1?void 0:i?fnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SnA(A,e,g),g};const mo=tA("debugsceneswitcher"),V0="scene";aF(V0);const ir=Promise.resolve(!1);class QI extends FA{constructor(){super(...arguments),n(this,"autoLoadFirstScene",!0),n(this,"scenes"),n(this,"loadingScene"),n(this,"queryParameterName","scene"),n(this,"useSceneName",!0),n(this,"clamp",!0),n(this,"useHistory",!0),n(this,"useKeyboard",!0),n(this,"useSwipe",!0),n(this,"useSceneLighting",!0),n(this,"preloadNext",1),n(this,"preloadPrevious",1),n(this,"preloadConcurrent",2),n(this,"_currentIndex",-1),n(this,"_currentScene"),n(this,"_engineElementOverserver"),n(this,"_preloadScheduler"),n(this,"onPopState",async A=>{if(!this.useHistory)return;const e=this.useHistory;try{this.useHistory=!1;let i=!1;if(this.queryParameterName&&(i=await this.tryLoadFromQueryParam()),!i){const g=A?.state;if(g&&g.startsWith(this.guid)){const I=g.substr(this.guid.length+2);mo&&console.log("PopState",I),await this.trySelectSceneFromValue(I)}}}finally{this.useHistory=e}}),n(this,"normalizedSwipeThresholdX",.1),n(this,"_didSwipe",!1),n(this,"onInputPointerMove",A=>{if(this.useSwipe&&!this._didSwipe&&A.button===0&&A.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const e=this.context.input.getPointerPositionDelta(A.button);if(e){const i=e.x/this.context.domWidth;i>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):i<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),n(this,"onInputPointerUp",A=>{A.button===0&&(this._didSwipe=!1)}),n(this,"onInputKeyDown",A=>{if(!this.useKeyboard||!this.scenes)return;const e=A.key.toLowerCase();if(!e)return;const i=parseInt(e)-1;if(i>=0){this.trySelectSceneFromValue(i);return}switch(e){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),n(this,"__lastSwitchScene"),n(this,"__lastSwitchScenePromise"),n(this,"_currentlyLoadingScene"),n(this,"_lastLoadingScene"),n(this,"_loadingScenePromise"),n(this,"_isCurrentlyLoading",!1),n(this,"_currentLoadingProgress")}get currentIndex(){return this._currentIndex}get currentLoadingProgress(){return this._currentLoadingProgress}get currentlyLoadingScene(){return this._currentlyLoadingScene}get currentlyLoadedScene(){return this._currentScene}awake(){this.scenes===void 0&&(this.scenes=[]),mo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(ei.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(ei.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(ei.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(A=>{for(const e of A)if(e.type==="attributes"&&e.attributeName===V0){const i=this.context.domElement.getAttribute(V0);i!==null&&this.trySelectSceneFromValue(i)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new mnA(this)),this._preloadScheduler.maxLoadAhead=this.preloadNext,this._preloadScheduler.maxLoadBehind=this.preloadPrevious,this._preloadScheduler.maxConcurrent=this.preloadConcurrent,this._preloadScheduler.begin(),this.autoLoadFirstScene&&this._currentIndex===-1&&!await this.tryLoadFromQueryParam()){const A=this.context.domElement.getAttribute(V0);try{(A===null||!await this.trySelectSceneFromValue(A))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var A;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(ei.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(ei.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(ei.PointerUp,this.onInputPointerUp),(A=this._preloadScheduler)==null||A.stop()}addScene(A){if(typeof A=="string"){let e=this.context.addressables.findAssetReference(A);return e||(e=new tt(A),this.context.addressables.registerAssetReference(e)),this.scenes.push(e),e}return this.scenes.push(A),A}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(A){var e,i,g;if(mo&&console.log("select",A),typeof A=="object"&&console.warn('Switching to "'+A+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof A=="string"){const o=(e=this.scenes)==null?void 0:e.find(s=>s.uri===A);if(!o){const s=tt.getOrCreate(this.sourceId??"",A,this.context);return this.switchScene(s)}if(o)A=(i=this.scenes)==null?void 0:i.indexOf(o);else return ir}if(!((g=this.scenes)!=null&&g.length))return ir;if(A<0){if(this.clamp)return ir;A=this.scenes.length-1}else if(A>=this.scenes.length){if(this.clamp)return ir;A=0}const I=this.scenes[A];return this.switchScene(I)}async switchScene(A){if(!(A instanceof tt)){const e=typeof A;return e==="string"?this.select(A):e==="number"?this.select(A):(console.warn("SceneSwitcher: Can't switch to scene",A,"of type",e),!1)}return A.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===A&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=A,this.__lastSwitchScenePromise=this.__internalSwitchScene(A),await this.__lastSwitchScenePromise)}async __internalSwitchScene(A){var e,i;if(this._currentScene){mo&&console.log("UNLOAD",A.uri);const I=this.tryGetSceneEventListener(this._currentScene.asset);if(I!=null&&I.sceneClosing){const o=I.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const g=this._currentIndex=((e=this.scenes)==null?void 0:e.indexOf(A))??-1;try{this._currentlyLoadingScene=A,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const I=new CustomEvent("loadscene-start",{detail:{scene:A,switcher:this,index:g}});this.dispatchEvent(I),await this.onStartLoading(),await A.loadAssetAsync((s,C)=>{this._currentLoadingProgress=C,this.dispatchEvent(C)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:A,switcher:this,index:g}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return mo&&console.warn("Adding loaded scene prevented:",A,o),!1;if(!A.asset)return mo&&console.warn("Failed loading scene:",A),!1;if(this._currentIndex===g){if(mo&&console.log("ADD",A.uri),this._currentScene=A,CA.add(A.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(A),this.useHistory&&g>=0){let a=g.toString();if(this.useSceneName&&(a=B1(A.uri)),(i=this.queryParameterName)!=null&&i.length)LD(this.queryParameterName,a,this.useHistory);else{const r=history.state,B=this.guid+"::"+g;r!==B&&history.pushState(B,"unused",location.href)}}const s=this.tryGetSceneEventListener(A.asset);if(s!=null&&s.sceneOpened){const a=s.sceneOpened(this);a instanceof Promise&&await a}const C=new CustomEvent("scene-opened",{detail:{scene:A,switcher:this,index:g}});return this.dispatchEvent(C),!0}}catch(I){console.error(I)}return!1}preload(A){if(A>=0&&A<this.scenes.length){const e=this.scenes[A];if(e instanceof tt)return e.preload()}return ir}tryLoadFromQueryParam(){var A;if(!((A=this.queryParameterName)!=null&&A.length))return ir;const e=tA(this.queryParameterName);return typeof e=="boolean"?ir:this.trySelectSceneFromValue(e)}trySelectSceneFromValue(A){if(typeof A=="string"){const e=parseInt(A);if(e>=0&&e<this.scenes.length)return this.select(e);{const i=A.toLowerCase();for(let g=0;g<this.scenes.length;g++){const I=this.scenes[g];if(I&&B1(I.uri).toLowerCase().includes(i))return this.select(g)}}}else if(typeof A=="number"&&A>=0&&A<this.scenes.length)return this.select(A);return Ao()&&console.warn('Can not find scene: "'+A+'"',this),ir}async onStartLoading(){var A,e;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(A=this.loadingScene)==null?void 0:A.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(e=this.loadingScene)!=null&&e.asset)){mo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const i=this.loadingScene.asset;CA.add(i,this.gameObject);const g=this.tryGetSceneEventListener(i);if(g!=null&&g.sceneOpened){const I=g.sceneOpened(this);I instanceof Promise&&await I}}if(this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneOpened){const g=i.sceneOpened(this);g instanceof Promise&&await g}}}async onEndLoading(){var A;if(this._isCurrentlyLoading=!1,(A=this.loadingScene)!=null&&A.asset){mo&&console.log("Remove loading scene",this.loadingScene.uri);const e=this.loadingScene.asset,i=this.tryGetSceneEventListener(e);if(typeof i?.sceneClosing=="function"){const g=i.sceneClosing();g instanceof Promise&&await g}CA.remove(e)}if(!this._isCurrentlyLoading){const e=this.tryGetSceneEventListener(this.gameObject);if(e&&e.sceneClosing){const i=e.sceneClosing();i instanceof Promise&&await i}}}tryGetSceneEventListener(A,e=0){const i=CA.foreachComponent(A,g=>g.sceneClosing?g:void 0);if(e===0&&!i&&A.children.length)for(const g of A.children){const I=this.tryGetSceneEventListener(g,e+1);if(I)return I}return i||null}}fo([w()],QI.prototype,"autoLoadFirstScene",2),fo([w(tt)],QI.prototype,"scenes",2),fo([w(tt)],QI.prototype,"loadingScene",2),fo([w()],QI.prototype,"queryParameterName",2),fo([w()],QI.prototype,"useSceneName",2),fo([w()],QI.prototype,"clamp",2),fo([w()],QI.prototype,"useHistory",2),fo([w()],QI.prototype,"useKeyboard",2),fo([w()],QI.prototype,"useSwipe",2),fo([w()],QI.prototype,"useSceneLighting",2),fo([w()],QI.prototype,"preloadNext",2),fo([w()],QI.prototype,"preloadPrevious",2),fo([w()],QI.prototype,"preloadConcurrent",2);function B1(t){const A=t.split("/").pop(),e=A?.split(".").shift();return e!=null&&e.length?e:t}class mnA{constructor(A,e=1,i=1,g=2){n(this,"maxLoadAhead"),n(this,"maxLoadBehind"),n(this,"maxConcurrent"),n(this,"_isRunning",!1),n(this,"_switcher"),n(this,"_loadTasks",[]),n(this,"_maxConcurrentLoads",1),this._switcher=A,this.maxLoadAhead=e,this.maxLoadBehind=i,this.maxConcurrent=g}begin(){if(this._isRunning)return;mo&&console.log("Preload begin"),this._isRunning=!0;let A=-1,e,i;const g=this._switcher.scenes,I=setInterval(()=>{if(this.allLoaded()&&(mo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(I);return}if(this.canLoadNewScene()===!1)return;A!==this._switcher.currentIndex&&(A=this._switcher.currentIndex,i=0,e=0);const o=i%2===0;o&&(e+=1),i+=1;const s=o?this.maxLoadAhead:this.maxLoadBehind;if(e>s)return;const C=o?A+e:A-e;if(C<0||C<0||C>=g.length)return;const a=g[C];new knA(C,a,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const A of this._switcher.scenes)if(A?.isLoaded()===!1)return!1}return!0}}class knA{constructor(A,e,i){n(this,"index"),n(this,"asset"),n(this,"tasks"),this.index=A,this.asset=e,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(mo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),mo&&console.log("Preload finished: "+this.asset.uri,this.index));const A=this.tasks.indexOf(this);A>=0&&this.tasks.splice(A,1)}}function GnA(){return new Promise((t,A)=>{const e=()=>{e!=null&&(document.removeEventListener("pointerdown",e),document.removeEventListener("click",e),document.removeEventListener("dragstart",e),document.removeEventListener("touchstart",e),t())};document.addEventListener("pointerdown",e),document.addEventListener("click",e),document.addEventListener("dragstart",e),document.addEventListener("touchstart",e)})}async function MnA(t){await GnA(),t()}var UnA=Object.defineProperty,RnA=Object.getOwnPropertyDescriptor,ko=(t,A,e,i)=>{for(var g=i>1?void 0:i?RnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UnA(A,e,g),g};const lg=tA("debugvideo");var Q1=(t=>(t[t.None=0]="None",t[t.AdjustHeight=1]="AdjustHeight",t[t.AdjustWidth=2]="AdjustWidth",t))(Q1||{}),E1=(t=>(t[t.VideoClip=0]="VideoClip",t[t.Url=1]="Url",t))(E1||{}),h1=(t=>(t[t.CameraFarPlane=0]="CameraFarPlane",t[t.CameraNearPlane=1]="CameraNearPlane",t[t.RenderTexture=2]="RenderTexture",t[t.MaterialOverride=3]="MaterialOverride",t))(h1||{});class og extends FA{constructor(){super(),n(this,"playOnAwake",!0),n(this,"aspectMode",0),n(this,"clip",null),n(this,"source",1),n(this,"_url",null),n(this,"renderMode"),n(this,"targetMaterialProperty"),n(this,"targetMaterialRenderer"),n(this,"targetTexture"),n(this,"time",0),n(this,"_playbackSpeed",1),n(this,"_isLooping",!1),n(this,"_muted",!1),n(this,"_audioOutputMode",2),n(this,"playInBackground",!0),n(this,"_crossOrigin","anonymous"),n(this,"_videoElement",null),n(this,"_videoTexture",null),n(this,"_videoMaterial",null),n(this,"_isPlaying",!1),n(this,"wasPlaying",!1),n(this,"visibilityChanged",A=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),n(this,"_receivedInput",!1),n(this,"_overlay",null),n(this,"_targetObjects"),n(this,"_updateAspectRoutineId",-1),n(this,"_hls"),n(this,"onHlsAvailable",()=>{var A;lg&&console.log("HLS: available",this.clip),!(!this.shouldUseM3U||!this.url)&&(this._hls||(this._hls=new Hls),this.videoElement.autoplay=!0,this._hls.loadSource(this.url),this._hls.attachMedia(this.videoElement),(A=this._videoElement)==null||A.play(),lg&&console.log("HLS: loaded",this.clip))}),MnA(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],tA("videoscreenspace")&&window.addEventListener("keydown",A=>{A.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(A){const e=this._url!==A;this.__didAwake?e&&this.setClipURL(A??""):this._url=A}get playbackSpeed(){var A;return((A=this._videoElement)==null?void 0:A.playbackRate)??this._playbackSpeed}set playbackSpeed(A){this._playbackSpeed=A,this._videoElement&&(this._videoElement.playbackRate=A)}get isLooping(){var A;return((A=this._videoElement)==null?void 0:A.loop)??this._isLooping}set isLooping(A){this._isLooping=A,this._videoElement&&(this._videoElement.loop=A)}get currentTime(){var A;return((A=this._videoElement)==null?void 0:A.currentTime)??this.time}set currentTime(A){this._videoElement?this._videoElement.currentTime=A:this.time=A}get isPlaying(){const A=this._videoElement;return!!(A&&(A.currentTime>0&&!A.paused&&!A.ended&&A.readyState>A.HAVE_CURRENT_DATA||A.srcObject&&A.srcObject.active))}get crossOrigin(){var A;return((A=this._videoElement)==null?void 0:A.crossOrigin)??this._crossOrigin}set crossOrigin(A){this._crossOrigin=A,this._videoElement&&(A!==null?this._videoElement.setAttribute("crossorigin",A):this._videoElement.removeAttribute("crossorigin"))}get videoMaterial(){return!this._videoMaterial&&!this.create(!1)?null:this._videoMaterial}get videoTexture(){return!this._videoTexture&&!this.create(!1)?null:this._videoTexture}get videoElement(){return!this._videoElement&&!this.create(!1)?null:this._videoElement}get muted(){var A;return((A=this._videoElement)==null?void 0:A.muted)??this._muted}set muted(A){this._muted=A,this._videoElement&&(this._videoElement.muted=A)}get currentVideo(){return this.clip}set audioOutputMode(A){A!==this._audioOutputMode&&(A===1&&re()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=A,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){lg&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(A){this.clip=A,this.source=0,this._videoElement?(this._videoElement.srcObject=A,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(A){this._url!==A&&(this._url=A,this.source=1,lg&&console.log("set url",A),this._videoElement?A.endsWith(".m3u8")||A.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=A,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var A,e;lg&&console.log("VideoPlayer.onEnable",E1[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(A=this._overlay)==null||A.start():(e=this._overlay)==null||e.stop()}onDisable(){var A;window.removeEventListener("visibilitychange",this.visibilityChanged),(A=this._overlay)==null||A.stop(),this.pause()}onDestroy(){var A;this._videoElement&&((A=this.videoElement)==null||A.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var A,e;if(this._videoElement||this.create(!1),!this._videoElement){lg&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((A=this._videoElement)!=null&&A.ended)&&!((e=this._videoElement)!=null&&e.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}lg&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(i=>{var g;console.log(i),lg&&console.error("Error playing video",i,"CODE="+i.code,(g=this.videoElement)==null?void 0:g.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),lg&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),lg&&console.log("STOP",this))}pause(){var A,e;this.time=((A=this._videoElement)==null?void 0:A.currentTime)??0,this._isPlaying=!1,(e=this._videoElement)==null||e.pause(),lg&&console.log("PAUSE",this,this.currentTime)}create(A){let e;switch(this.source){case 0:e=this.clip;break;case 1:e=this.url,!(e!=null&&e.length)&&typeof this.clip=="string"&&(e=this.clip);break}return e?(this._videoElement||(lg&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof e=="string"?(lg&&console.log("Set Video src",e),this._videoElement.src=e):(lg&&console.log("Set Video srcObject",e),this._videoElement.srcObject=e),this._videoTexture||(this._videoTexture=new tb(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=Ee,A&&this.handleBeginPlaying(A),lg&&console.log("Video: handle playing done...",e,A),!0):(lg&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var A;return((A=this._overlay)==null?void 0:A.enabled)??!1}set screenspace(A){var e;if(A){if(!this._videoTexture)return;this._overlay||(this._overlay=new NnA(this.context)),this._overlay.add(this._videoTexture)}else(e=this._overlay)==null||e.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=A)}createVideoElement(){const A=document.createElement("video");return this._crossOrigin&&A.setAttribute("crossorigin",this._crossOrigin),lg&&console.log("created video element",A),A}handleBeginPlaying(A){var e,i;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let g=this.gameObject;switch(this.renderMode){case 3:g=(e=this.targetMaterialRenderer)==null?void 0:e.gameObject,g||(g=(i=CA.getComponent(this.gameObject,Ji))==null?void 0:i.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!g){console.error("Missing target for video material renderer",this.name,h1[this.renderMode],this);return}const I=g.material;if(I){this._targetObjects.push(g),I!==this._videoMaterial&&(this._videoMaterial=I.clone(),g.material=this._videoMaterial);const o="map",s=this._videoMaterial;if(!this.targetMaterialProperty)s[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:s[o]=this._videoTexture;break}}else{console.warn("Can not play video, no material found, this might be a multimaterial case which is not supported yet");return}this.updateVideoElementSettings(),this.updateVideoElementStyles(),A&&(this.shouldUseM3U&&this.ensureM3UCanBePlayed(),this.play())}updateVideoElementSettings(){if(!this._videoElement)return;this._videoElement.loop=this._isLooping,this._videoElement.currentTime=this.currentTime,this._videoElement.playbackRate=this._playbackSpeed,this._videoElement.playsInline=!0;let A=!this._receivedInput||this.audioOutputMode===0;!A&&this._muted&&(A=!0),this._videoElement.muted=A,this.playOnAwake&&(this._videoElement.autoplay=!0)}updateVideoElementStyles(){this._videoElement&&(this._videoElement.style.userSelect="none",this._videoElement.style.visibility="hidden",this._videoElement.style.display="none",this.updateAspect())}*updateAspectImpl(){const A=++this._updateAspectRoutineId,e=void 0,i=this.clip;for(;A===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&i===this.clip&&this._isPlaying;){if(!i||typeof i=="string")return;let g;for(const I of i.getVideoTracks()){const o=I.getSettings();if(o&&o.width&&o.height){g=o.width/o.height;break}else g=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(g===void 0){for(let I=0;I<10;I++)yield;if(!this.isPlaying)break;continue}if(e===g){yield;continue}for(const I of this._targetObjects){let o=1;if(I.parent){const s=Tt(I.parent);o=s.x/s.y}switch(this.aspectMode){case 1:I.scale.y=1/g*I.scale.x*o;break;case 2:I.scale.x=g*I.scale.y*o;break}}for(let I=0;I<3;I++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let A=document.head.querySelector("script[data-hls_library]");A?globalThis.Hls?this.onHlsAvailable():A.addEventListener("load",this.onHlsAvailable):(lg&&console.log("HLS: load script"),A=document.createElement("script"),A.dataset.hls_library="hls.js",A.src="https://cdn.jsdelivr.net/npm/hls.js@1",A.addEventListener("load",this.onHlsAvailable),document.head.append(A))}}ko([w()],og.prototype,"playOnAwake",2),ko([w()],og.prototype,"aspectMode",2),ko([w(URL)],og.prototype,"clip",2),ko([w()],og.prototype,"source",2),ko([w(URL)],og.prototype,"url",1),ko([w()],og.prototype,"renderMode",2),ko([w()],og.prototype,"targetMaterialProperty",2),ko([w(Ji)],og.prototype,"targetMaterialRenderer",2),ko([w(le)],og.prototype,"targetTexture",2),ko([w()],og.prototype,"time",2),ko([w()],og.prototype,"playbackSpeed",1),ko([w()],og.prototype,"isLooping",1),ko([w()],og.prototype,"audioOutputMode",1);class NnA{constructor(A){n(this,"context"),n(this,"_videos",[]),n(this,"_screenspaceModeQuad"),n(this,"_isInScreenspaceMode",!1),n(this,"_input"),this.context=A,this._input=new FnA(this)}get enabled(){return this._isInScreenspaceMode}set enabled(A){A?this.start():this.stop()}add(A){this._videos.indexOf(A)===-1&&this._videos.push(A)}remove(A){if(!A)return;const e=this._videos.indexOf(A);e>=0&&this._videos.splice(e,1)}start(){var A;if(this._isInScreenspaceMode||this._videos.length<0)return;const e=this._videos[this._videos.length-1];if(!e)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=ql.createPrimitive(QB.Quad,{material:new KnA(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const i=this._screenspaceModeQuad;this.context.scene.add(i),this.updateScreenspaceMaterialUniforms();const g=i.material;g?.reset(),(A=this._input)==null||A.enable(g)}stop(){var A;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((A=this._input)==null||A.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var A;const e=(A=this._screenspaceModeQuad)==null?void 0:A.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class FnA{constructor(A){n(this,"_onResizeScreenFn"),n(this,"_onKeyUpFn"),n(this,"_onMouseWheelFn"),n(this,"context"),n(this,"overlay"),n(this,"_material"),n(this,"_isPinching",!1),n(this,"_lastPinch",0),this.overlay=A,this.context=A.context}enable(A){this._material=A,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=g=>{g.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=g=>{this.overlay.enabled&&(A.zoom+=g.deltaY*5e-4,g.preventDefault())},{passive:!1});const e=new eA;window.addEventListener("mousemove",g=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const I=new eA(g.movementX,g.movementY);I.x/=this.context.domElement.clientWidth,I.y/=this.context.domElement.clientHeight,e.set(I.x,I.y),e.multiplyScalar(A.zoom/-this.context.time.deltaTime*.01),A.offset=A.offset.add(e)}}),window.addEventListener("pointermove",g=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(e.set(g.movementX,g.movementY),e.multiplyScalar(A.zoom*-this.context.time.deltaTime*.05),A.offset=A.offset.add(e))});let i=0;window.addEventListener("touchstart",g=>{if(g.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",g=>{if(!this._isPinching||!this._material)return;const I=g.touches[0],o=g.touches[1],s=I.clientX-o.clientX,C=I.clientY-o.clientY,a=Math.sqrt(s*s+C*C);if(this._lastPinch!==0){const r=a-this._lastPinch;this._material.zoom-=r*.004}this._lastPinch=a}),window.addEventListener("touchend",()=>{this._isPinching=!1})}disable(){this._onResizeScreenFn&&(window.removeEventListener("resize",this._onResizeScreenFn),this._onResizeScreenFn=void 0),this._onKeyUpFn&&(window.removeEventListener("keyup",this._onKeyUpFn),this._onKeyUpFn=void 0),this._onMouseWheelFn&&(window.removeEventListener("wheel",this._onMouseWheelFn),this._onMouseWheelFn=void 0)}}class KnA extends Me{constructor(A){super(),n(this,"_offset",new eA),this.uniforms={map:{value:A},screenAspect:{value:1},offsetScale:{value:new zA(0,0,1,1)}},this.vertexShader=`
|
|
6955
6955
|
uniform sampler2D map;
|
|
6956
6956
|
uniform float screenAspect;
|
|
6957
6957
|
uniform vec4 offsetScale;
|
|
@@ -7015,7 +7015,7 @@ void main() {
|
|
|
7015
7015
|
// be blended onto the scene.
|
|
7016
7016
|
gl_FragColor = vec4(direct, max);
|
|
7017
7017
|
return;
|
|
7018
|
-
`)}}applyShadowMaterial(){if(this.targetMesh)if(this.targetMesh.material.type!=="ShadowMaterial"){const A=new wD;A.color=this.shadowColor,A.opacity=this.shadowColor.alpha,this.applyMaterialOptions(A),this.targetMesh.material=A}else{const A=this.targetMesh.material;A.color=this.shadowColor,A.opacity=this.shadowColor.alpha,this.applyMaterialOptions(A)}}applyOccluderMaterial(){if(this.targetMesh){let A=this.targetMesh.material;if(!A){const e=new st;this.targetMesh.material=e,A=e}A.depthWrite=!0,A.stencilWrite=!0,A.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(A){A&&(A.depthWrite=!1,A.stencilWrite=!1)}}c1([w()],Ep.prototype,"mode",2),c1([w(St)],Ep.prototype,"shadowColor",2);var HnA=Object.defineProperty,TnA=Object.getOwnPropertyDescriptor,X0=(t,A,e,i)=>{for(var g=i>1?void 0:i?TnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HnA(A,e,g),g},rF;const l1=(rF=class extends FA{constructor(){super(...arguments),n(this,"target",null),n(this,"followFactor",.1),n(this,"rotateFactor",.1),n(this,"positionAxes",qE.All),n(this,"flipForward",!1),n(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(t){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const A=Fe(this.target),e=this._firstUpdate||t?1:Ae.clamp01(this.context.time.deltaTime*this.followFactor),i=this.worldPosition;this.positionAxes&qE.X&&(i.x=Ae.lerp(i.x,A.x,e)),this.positionAxes&qE.Y&&(i.y=Ae.lerp(i.y,A.y,e)),this.positionAxes&qE.Z&&(i.z=Ae.lerp(i.z,A.z,e)),this.worldPosition=i}if(this.rotateFactor>0){const A=Gt(this.target);this.flipForward&&A.premultiply(l1._invertForward);const e=this._firstUpdate||t?1:Ae.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(A,e)}this._firstUpdate=!1}}},n(rF,"_invertForward",new RA().setFromAxisAngle(new S(0,1,0),Math.PI)),rF);let gr=l1;X0([w(uA)],gr.prototype,"target",2),X0([w()],gr.prototype,"followFactor",2),X0([w()],gr.prototype,"rotateFactor",2),X0([w()],gr.prototype,"positionAxes",2);class OnA extends hA{constructor(A){const e=new PnA(A),i=new Zi(e.image.width*.001,e.image.height*.001),g=new st({map:e,toneMapped:!1,transparent:!0});super(i,g);function I(o){g.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",I),this.addEventListener("mousemove",I),this.addEventListener("mouseup",I),this.addEventListener("click",I),this.dispose=function(){i.dispose(),g.dispose(),g.map.dispose(),BF.delete(A),this.removeEventListener("mousedown",I),this.removeEventListener("mousemove",I),this.removeEventListener("mouseup",I),this.removeEventListener("click",I)}}}class PnA extends Ik{constructor(A){super(d1(A)),this.dom=A,this.anisotropy=16,this.colorSpace=Ee,this.minFilter=me,this.magFilter=me;const e=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),i={attributes:!0,childList:!0,subtree:!0,characterData:!0};e.observe(A,i),this.observer=e}dispatchDOMEvent(A){A.data&&jnA(this.dom,A.type,A.data.x,A.data.y)}update(){this.image=d1(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const BF=new WeakMap;function d1(t){const A=document.createRange(),e=new GA;function i(Q){const E=[];let h=!1;function d(){if(h&&(h=!1,Q.restore()),E.length===0)return;let l=-1/0,c=-1/0,p=1/0,u=1/0;for(let D=0;D<E.length;D++){const k=E[D];l=Math.max(l,k.x),c=Math.max(c,k.y),p=Math.min(p,k.x+k.width),u=Math.min(u,k.y+k.height)}Q.save(),Q.beginPath(),Q.rect(l,c,p-l,u-c),Q.clip(),h=!0}return{add:function(l){E.push(l),d()},remove:function(){E.pop(),d()}}}function g(Q,E,h,d){d!==""&&(Q.textTransform==="uppercase"&&(d=d.toUpperCase()),r.font=Q.fontWeight+" "+Q.fontSize+" "+Q.fontFamily,r.textBaseline="top",r.fillStyle=Q.color,r.fillText(d,E,h+parseFloat(Q.fontSize)*.1))}function I(Q,E,h,d,l){h<2*l&&(l=h/2),d<2*l&&(l=d/2),r.beginPath(),r.moveTo(Q+l,E),r.arcTo(Q+h,E,Q+h,E+d,l),r.arcTo(Q+h,E+d,Q,E+d,l),r.arcTo(Q,E+d,Q,E,l),r.arcTo(Q,E,Q+h,E,l),r.closePath()}function o(Q,E,h,d,l,c){const p=Q[E+"Width"],u=Q[E+"Style"],D=Q[E+"Color"];p!=="0px"&&u!=="none"&&D!=="transparent"&&D!=="rgba(0, 0, 0, 0)"&&(r.strokeStyle=D,r.lineWidth=parseFloat(p),r.beginPath(),r.moveTo(h,d),r.lineTo(h+l,d+c),r.stroke())}function s(Q,E){let h=0,d=0,l=0,c=0;if(Q.nodeType===Node.TEXT_NODE){A.selectNode(Q);const u=A.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,g(E,h,d,Q.nodeValue.trim())}else{if(Q.nodeType===Node.COMMENT_NODE)return;if(Q instanceof HTMLCanvasElement){if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,r.save();const D=window.devicePixelRatio;r.scale(1/D,1/D),r.drawImage(Q,h,d),r.restore()}else if(Q instanceof HTMLImageElement){if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,r.drawImage(Q,h,d,l,c)}else{if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,E=window.getComputedStyle(Q),I(h,d,l,c,parseFloat(E.borderRadius));const D=E.backgroundColor;D!=="transparent"&&D!=="rgba(0, 0, 0, 0)"&&(r.fillStyle=D,r.fill());const k=["borderTop","borderLeft","borderBottom","borderRight"];let U=!0,M=null;for(const G of k){if(M!==null&&(U=E[G+"Width"]===E[M+"Width"]&&E[G+"Color"]===E[M+"Color"]&&E[G+"Style"]===E[M+"Style"]),U===!1)break;M=G}if(U===!0){const G=parseFloat(E.borderTopWidth);E.borderTopWidth!=="0px"&&E.borderTopStyle!=="none"&&E.borderTopColor!=="transparent"&&E.borderTopColor!=="rgba(0, 0, 0, 0)"&&(r.strokeStyle=E.borderTopColor,r.lineWidth=G,r.stroke())}else o(E,"borderTop",h,d,l,0),o(E,"borderLeft",h,d,0,c),o(E,"borderBottom",h,d+c,l,0),o(E,"borderRight",h+l,d,0,c);if(Q instanceof HTMLInputElement){let G=E.accentColor;(G===void 0||G==="auto")&&(G=E.color),e.set(G);const K=Math.sqrt(.299*e.r**2+.587*e.g**2+.114*e.b**2)<.5?"white":"#111111";if(Q.type==="radio"&&(I(h,d,l,c,c),r.fillStyle="white",r.strokeStyle=G,r.lineWidth=1,r.fill(),r.stroke(),Q.checked&&(I(h+2,d+2,l-4,c-4,c),r.fillStyle=G,r.strokeStyle=K,r.lineWidth=2,r.fill(),r.stroke())),Q.type==="checkbox"&&(I(h,d,l,c,2),r.fillStyle=Q.checked?G:"white",r.strokeStyle=Q.checked?K:G,r.lineWidth=1,r.stroke(),r.fill(),Q.checked)){const f=r.textAlign;r.textAlign="center";const N={color:K,fontFamily:E.fontFamily,fontSize:c+"px",fontWeight:"bold"};g(N,h+l/2,d,"\u2714"),r.textAlign=f}if(Q.type==="range"){const[f,N,_]=["min","max","value"].map(v=>parseFloat(Q[v])),T=(_-f)/(N-f)*(l-c);I(h,d+c/4,l,c/2,c/4),r.fillStyle=K,r.strokeStyle=G,r.lineWidth=1,r.fill(),r.stroke(),I(h,d+c/4,T+c/2,c/2,c/4),r.fillStyle=G,r.fill(),I(h+T,d,c,c,c/2),r.fillStyle=G,r.fill()}(Q.type==="color"||Q.type==="text"||Q.type==="number")&&(B.add({x:h,y:d,width:l,height:c}),g(E,h+parseInt(E.paddingLeft),d+parseInt(E.paddingTop),Q.value),B.remove())}}}const p=E.overflow==="auto"||E.overflow==="hidden";p&&B.add({x:h,y:d,width:l,height:c});for(let u=0;u<Q.childNodes.length;u++)s(Q.childNodes[u],E);p&&B.remove()}const C=t.getBoundingClientRect();let a=BF.get(t);a===void 0&&(a=document.createElement("canvas"),a.width=C.width,a.height=C.height,BF.set(t,a));const r=a.getContext("2d"),B=new i(r);return r.clearRect(0,0,a.width,a.height),s(t),a}function jnA(t,A,e,i){const g={clientX:e*t.offsetWidth+t.offsetLeft,clientY:i*t.offsetHeight+t.offsetTop,view:t.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(A,g));const I=t.getBoundingClientRect();e=e*I.width+I.left,i=i*I.height+I.top;function o(s){if(s.nodeType!==Node.TEXT_NODE&&s.nodeType!==Node.COMMENT_NODE){const C=s.getBoundingClientRect();if(e>C.left&&e<C.right&&i>C.top&&i<C.bottom&&(s.dispatchEvent(new MouseEvent(A,g)),s instanceof HTMLInputElement&&s.type==="range"&&(A==="mousedown"||A==="click"))){const[a,r]=["min","max"].map(E=>parseFloat(s[E])),B=C.width,Q=(e-C.x)/B;s.value=a+(r-a)*Q,s.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let a=0;a<s.childNodes.length;a++)o(s.childNodes[a])}}o(t)}const $0=new eA,fh={type:"",data:$0},p1=new Hr;class WnA extends pI{listenToPointerEvents(A,e){const i=this,g=new Hr,I=A.domElement;function o(s){s.stopPropagation();const C=A.domElement.getBoundingClientRect();$0.x=(s.clientX-C.left)/C.width*2-1,$0.y=-(s.clientY-C.top)/C.height*2+1,g.setFromCamera($0,e);const a=g.intersectObjects(i.children,!1);if(a.length>0){const r=a[0],B=r.object,Q=r.uv;fh.type=s.type,fh.data.set(Q.x,1-Q.y),B.dispatchEvent(fh)}}I.addEventListener("pointerdown",o),I.addEventListener("pointerup",o),I.addEventListener("pointermove",o),I.addEventListener("mousedown",o),I.addEventListener("mouseup",o),I.addEventListener("mousemove",o),I.addEventListener("click",o)}listenToXRControllerEvents(A){const e=this,i={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function g(I){const o=I.target;p1.setFromXRController(o);const s=p1.intersectObjects(e.children,!1);if(s.length>0){const C=s[0],a=C.object,r=C.uv;fh.type=i[I.type],fh.data.set(r.x,1-r.y),a.dispatchEvent(fh)}}A.addEventListener("move",g),A.addEventListener("select",g),A.addEventListener("selectstart",g),A.addEventListener("selectend",g)}}var ZnA=Object.defineProperty,VnA=Object.getOwnPropertyDescriptor,u1=(t,A,e,i)=>{for(var g=i>1?void 0:i?VnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZnA(A,e,g),g};class hp extends FA{constructor(){super(...arguments),n(this,"id",null),n(this,"keepAspect",!1),n(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const A=document.getElementById(this.id);if(!A){console.warn('Could not find element with id "'+this.id+'"');return}A.style.display="block",A.style.visibility="hidden";const e=new WnA;e.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(e);const i=new OnA(A);e.add(i),i.visible=!1;const g=i.material;g.transparent=!0,setTimeout(()=>{i.visible=!0;const I=Zc(this.gameObject).clone();Vc(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const o=new pt;o.setFromObject(e),this.setWorldRotation(I.x,I.y,I.z);const s=o.max.x-o.min.x,C=o.max.y-o.min.y;if(this.keepAspect){const r=s/C;s>C?i.scale.set(1/s,1/C/r,1):i.scale.set(1/s*r,1/C,1)}else i.scale.set(1/s,1/C,1);const a=this.gameObject.scale;i.scale.multiply(a)},1)}onDisable(){var A;(A=this._object)==null||A.removeFromParent()}}u1([w()],hp.prototype,"id",2),u1([w()],hp.prototype,"keepAspect",2);var znA=Object.defineProperty,XnA=Object.getOwnPropertyDescriptor,cp=(t,A,e,i)=>{for(var g=i>1?void 0:i?XnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&znA(A,e,g),g};const lp=tA("debugspatialtrigger"),D1=new $g,w1=new $g;function $nA(t,A){return D1.mask=t,w1.mask=A,D1.test(w1)}class fC extends FA{constructor(){super(...arguments),n(this,"triggerMask",0),n(this,"onEnter"),n(this,"onStay"),n(this,"onExit"),n(this,"currentIntersected",[]),n(this,"lastIntersected",[])}start(){lp&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const A of dp.triggers)$nA(A.triggerMask,this.triggerMask)&&A.test(this.gameObject)&&this.currentIntersected.push(A);for(let A=this.lastIntersected.length-1;A>=0;A--){const e=this.lastIntersected[A];this.currentIntersected.indexOf(e)<0&&(this.onExitTrigger(e),this.lastIntersected.splice(A,1))}for(const A of this.currentIntersected)this.lastIntersected.indexOf(A)<0&&this.onEnterTrigger(A),this.onStayTrigger(A);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(A){var e;lp&&console.log("ENTER TRIGGER",this.name,A.name,this,A),A.raiseOnEnterEvent(this),(e=this.onEnter)==null||e.invoke(this,A)}onExitTrigger(A){var e;lp&&console.log("EXIT TRIGGER",this.name,A.name,this,A),A.raiseOnExitEvent(this),(e=this.onExit)==null||e.invoke(this,A)}onStayTrigger(A){var e;A.raiseOnStayEvent(this),(e=this.onStay)==null||e.invoke(this,A)}}cp([w()],fC.prototype,"triggerMask",2),cp([w(tg)],fC.prototype,"onEnter",2),cp([w(tg)],fC.prototype,"onStay",2),cp([w(tg)],fC.prototype,"onExit",2);var QF;const AS=(QF=class extends FA{constructor(){super(...arguments),n(this,"triggerMask"),n(this,"boxHelper")}start(){lp&&console.log(this.name,this.triggerMask,this)}onEnable(){var t;AS.triggers.push(this),this.boxHelper||(this.boxHelper=CA.addNewComponent(this.gameObject,lC),(t=this.boxHelper)==null||t.showHelper(null,lp))}onDisable(){AS.triggers.splice(AS.triggers.indexOf(this),1)}test(t){return this.boxHelper?this.boxHelper.isInBox(t)??!1:!1}raiseOnEnterEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onEnterTrigger(this)},!1)}raiseOnStayEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onStayTrigger(this)},!1)}raiseOnExitEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onExitTrigger(this)},!1)}},n(QF,"triggers",[]),QF);let dp=AS;cp([w()],dp.prototype,"triggerMask",2);var ArA=Object.defineProperty,erA=Object.getOwnPropertyDescriptor,trA=(t,A,e,i)=>{for(var g=i>1?void 0:i?erA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ArA(A,e,g),g};const Go=tA("debugspectator");class eS extends FA{constructor(){super(...arguments),n(this,"cam",null),n(this,"useKeys",!0),n(this,"_mode",0),n(this,"orbit",null),n(this,"_handler"),n(this,"eventSub_WebXRRequestStartEvent",null),n(this,"eventSub_WebXRStartEvent",null),n(this,"eventSub_WebXREndEvent",null),n(this,"_debug"),n(this,"_networking")}get mode(){return this._mode}set mode(A){this._mode=A}get isSpectating(){var A;return((A=this._handler)==null?void 0:A.currentTarget)!==void 0}isSpectatingUser(A){var e;return((e=this.target)==null?void 0:e.userId)===A}isFollowedBy(A){var e;return(e=this.followers)==null?void 0:e.includes(A)}get followers(){return this._networking.followers}stopSpectating(){if(this.context.isInXR){this.followSelf();return}this.target=void 0}get localId(){return this.context.connection.connectionId??"local"}set target(A){var e;if(this._handler){const i=(e=this._handler.currentTarget)==null?void 0:e.userId,g=this.context.players.getPlayerView(this.localId);A===void 0||this.context.isInXR===!1&&g?.currentObject===A.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),CA.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(A,i)):this._handler.currentTarget!==A&&(this._handler.set(A),CA.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(A,i))}}get target(){var A;return(A=this._handler)==null?void 0:A.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var A,e;return this.isSpectating&&((A=this.target)==null?void 0:A.currentObject)===((e=this.context.players.getPlayerView(this.localId))==null?void 0:e.currentObject)}awake(){if(this._debug=new IrA(this.context,this),this._networking=new CrA(this.context,this),this._networking.awake(),CA.setActive(this.gameObject,!1),this.cam=CA.getComponent(this.gameObject,xt),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new irA(this.context,this.cam,this)),this.orbit=CA.getComponent(this.context.mainCamera,ft)}onDestroy(){var A,e;this.stopSpectating(),(A=this._handler)==null||A.destroy(),(e=this._networking)==null||e.destroy()}isSupportedPlatform(){const A=window.navigator.userAgent,e=/Windows|MacOS/.test(A),i=/Windows NT/.test(A)&&/Edg/.test(A)&&!/Win64/.test(A);return e&&!i}onBeforeXR(A){this.isSupportedPlatform()&&CA.setActive(this.gameObject,!0)}onEnterXR(A){this.isSupportedPlatform()&&(Go&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(A){var e,i;this.context.removeCamera(this.cam),CA.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(e=this._handler)==null||e.set(void 0),(i=this._handler)==null||i.disable(),this.isSpectatingSelf&&this.stopSpectating()}followSelf(){this.target=this.context.players.getPlayerView(this.context.connection.connectionId),this.target||(this.context.players.setPlayerView(this.localId,this.context.mainCamera,Un.Headset),this.target=this.context.players.getPlayerView(this.localId)),Go&&console.log("Follow self",this.target)}onAfterRender(){var A,e,i;if(!this.cam)return;const g=this.context.renderer,I=g.xr.enabled;if(!g.xr.isPresenting&&!((A=this._handler)!=null&&A.currentTarget))return;(e=this._handler)==null||e.update(this._mode);const o=g.getRenderTarget();let s=null;const C=g.state;if(!o){if(!g.state.bindFramebuffer||!C.bindXRFramebuffer)return;s=g._framebuffer,C.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const a=this.context.mainCameraComponent;if(a){const Q=a.backgroundColor;Q&&g.setClearColor(Q,Q.alpha),this.cam.backgroundColor=Q,this.cam.clearFlags=a.clearFlags,this.cam.nearClipPlane=a.nearClipPlane,this.cam.farClipPlane=a.farClipPlane}else g.setClearColor(new GA(1,1,1));g.setRenderTarget(null),g.xr.enabled=!1;const r=(i=this.cam)==null?void 0:i.cam;this.context.updateAspect(r);const B=g.xr.isPresenting;g.xr.isPresenting=!1,g.setSize(this.context.domWidth,this.context.domHeight),g.render(this.context.scene,r),g.xr.isPresenting=B,g.xr.enabled=I,o?g.setRenderTarget(o):C.bindXRFramebuffer&&C.bindXRFramebuffer(s),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const A=this._mode===0;for(const e of xg.instances)if(e.avatar&&"isLocalAvatar"in e.avatar&&"flags"in e.avatar){let i=EC.All;this.isSpectatingSelf&&(i=A&&e.avatar.isLocalAvatar?EC.FirstPerson:EC.ThirdPerson);const g=e.avatar.flags;if(!g)continue;for(const I of g)I.UpdateVisible(i)}}resetAvatarFlags(){var A;for(const e of xg.instances)if(e.avatar&&"flags"in e.avatar){const i=e.avatar.flags;if(!i)continue;for(const g of i)"isLocalAvatar"in e.avatar&&(A=e.avatar)!=null&&A.isLocalAvatar?g.UpdateVisible(EC.FirstPerson):g.UpdateVisible(EC.ThirdPerson)}}}trA([w()],eS.prototype,"useKeys",2);class irA{constructor(A,e,i){n(this,"context"),n(this,"cam"),n(this,"spectator"),n(this,"follow"),n(this,"target"),n(this,"view"),n(this,"currentObject"),this.context=A,this.cam=e,this.spectator=i}get currentTarget(){return this.view}set(A){const e=A?.currentObject;if(!e){this.spectator.stopSpectating();return}e!==this.currentObject&&(this.currentObject=e,this.view=A,this.follow||(this.follow=CA.addNewComponent(this.cam.gameObject,gr)),this.target||(this.target=new uA),e.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,Go&&console.log("FOLLOW",e),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){Go&&console.log("STOP FOLLOW",this.currentObject),this.view=void 0,this.currentObject=void 0,this.context.removeCamera(this.cam),this.follow&&(this.follow.enabled=!1)}destroy(){var A;(A=this.target)==null||A.removeFromParent(),this.follow&&CA.destroy(this.follow)}update(A){var e,i,g,I,o,s;if(((e=this.currentTarget)==null?void 0:e.isConnected)===!1||((i=this.currentTarget)==null?void 0:i.removed)===!0){Go&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((g=this.currentTarget)==null?void 0:g.currentObject)!==this.currentObject&&(Go&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const C=this.context.mainCamera;C&&(this.cam.cam.near!==C.near||this.cam.cam.far!==C.far)&&(this.cam.cam.near=C.near,this.cam.cam.far=C.far,this.cam.cam.updateProjectionMatrix());const a=(I=this.follow)==null?void 0:I.target;if(!(!a||!this.follow)){switch(A){case 0:((o=this.view)==null?void 0:o.viewDevice)!==Un.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),a.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,a.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((s=this.view)==null?void 0:s.viewDevice)!==Un.Browser?a.quaternion.copy(grA):a.quaternion.identity()}}}const grA=new RA().setFromAxisAngle(new S(0,1,0),Math.PI);class IrA{constructor(A,e){n(this,"context"),n(this,"spectator"),this.context=A,this.spectator=e,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",g=>{!this.spectator.useKeys||g.key==="Escape"&&this.spectator.stopSpectating()});let i=0;this.context.input.addEventListener(ei.PointerDown,g=>{i=this.context.time.time}),this.context.input.addEventListener(ei.PointerUp,g=>{const I=this.context.time.time-i;I>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&I<.3&&this.trySelectObject()})}trySelectObject(){const A=new Zo;A.setMask(16777215);const e=this.context.physics.raycast(A);if(Go&&console.log(...e),e!=null&&e.length)for(const i of e){if(i.distance<.2)continue;const g=i.object,I=CA.getComponentInParent(g,xg),o=I?.connectionId;if(o){const s=this.context.players.getPlayerView(o);this.spectator.target=s,Go&&console.log("spectate",o,I);break}}}}class orA{constructor(A,e,i){n(this,"guid"),n(this,"dontSave",!0),n(this,"targetUserId"),n(this,"stoppedFollowing"),this.guid=A,this.targetUserId=e,this.stoppedFollowing=i}}class srA{constructor(A,e){n(this,"guid"),n(this,"userId"),this.guid=A.guid,this.userId=e}}class CrA{constructor(A,e){n(this,"followers",[]),n(this,"context"),n(this,"spectator"),n(this,"_followerEventMethod"),n(this,"_requestFollowMethod"),n(this,"_joinedRoomMethod"),n(this,"_lastRequestFollowUser"),n(this,"_enforceFollowInterval"),this.context=A,this.spectator=e,this._followerEventMethod=this.onFollowerEvent.bind(this),this._requestFollowMethod=this.onRequestFollowEvent.bind(this),this._joinedRoomMethod=this.onUserJoinedRoom.bind(this)}awake(){this.context.connection.beginListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.beginListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.beginListen(At.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",A=>{this.spectator.useKeys&&(A.key==="f"?this.onRequestFollowMe():A.key==="Escape"&&this.onRequestFollowMe(!0))})}destroy(){this.context.connection.stopListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.stopListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.stopListen(At.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(A,e){if(Go&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",A,e),this.context.connection.connectionId){const i=A?.userId===void 0,g=i?e:A?.userId,I=new orA(this.context.connection.connectionId,g,i);this.context.connection.send("spectator-follower-changed",I)}}onRequestFollowMe(A=!1){if(Go&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const e=A?void 0:this.context.connection.connectionId,i=new srA(this.spectator,e);this.context.connection.send("spectator-request-follow",i)}}onUserJoinedRoom(){tA("followme")&&this.onRequestFollowMe()}onFollowerEvent(A){const e=A.targetUserId,i=A.guid;if(Go&&console.log(A),e===this.context.connection.connectionId)if(A.stoppedFollowing){const g=this.followers.indexOf(i);g!==-1&&(this.followers.splice(g,1),this.removeDisconnectedFollowers(),console.log(i,"unfollows you",this.followers.length))}else this.followers.includes(i)||(this.followers.push(i),this.removeDisconnectedFollowers(),console.log(i,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let A=this.followers.length-1;A>=0;A--){const e=this.followers[A];this.context.connection.userIsInRoom(e)===!1&&this.followers.splice(A,1)}}onRequestFollowEvent(A){if(this._lastRequestFollowUser=A,A.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(A.userId===void 0)this.spectator.stopSpectating();else{const e=this.context.players.getPlayerView(A.userId);if(e)this.spectator.target=e;else return Go&&console.warn("Could not find view",A.userId),this.enforceFollow(),!1}return!0}enforceFollow(){this._enforceFollowInterval||(this._enforceFollowInterval=setInterval(()=>{this._lastRequestFollowUser===void 0||this._lastRequestFollowUser.userId&&this.spectator.isFollowedBy(this._lastRequestFollowUser.userId)?(clearInterval(this._enforceFollowInterval),this._enforceFollowInterval=void 0):(Go&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var arA=Object.defineProperty,nrA=Object.getOwnPropertyDescriptor,vI=(t,A,e,i)=>{for(var g=i>1?void 0:i?nrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&arA(A,e,g),g};const tS=tA("debugspriterenderer"),rrA=tA("wireframe"),EF=class{static getOrCreateGeometry(t){if(t.__cached_geometry)return t.__cached_geometry;if(t.guid&&EF.cache[t.guid])return tS&&console.log("Take cached geometry for sprite",t.guid),EF.cache[t.guid];const A=new he;t.__cached_geometry=A;const e=new Float32Array(t.triangles.length*3),i=new Float32Array(t.triangles.length*2);for(let g=0;g<t.triangles.length;g+=1){const I=t.triangles[g];e[g*3]=-t.vertices[I].x,e[g*3+1]=t.vertices[I].y,e[g*3+2]=0;const o=t.uv[I];i[g*2]=o.x,i[g*2+1]=1-o.y}return A.setAttribute("position",new ee(e,3)),A.setAttribute("uv",new ee(i,2)),t.guid&&(this.cache[t.guid]=A),tS&&console.log("Built sprite geometry",t,A),A}};let pp=EF;n(pp,"cache",{});class Fa{constructor(){n(this,"guid"),n(this,"texture"),n(this,"triangles"),n(this,"uv"),n(this,"vertices"),n(this,"__cached_geometry"),n(this,"_mesh"),n(this,"_material")}get mesh(){return this._mesh||(this._mesh=new hA(pp.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=Ee,this.texture.minFilter==qe&&this.texture.magFilter==qe&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new st({map:this.texture,color:16777215,side:Qt,transparent:!0})),this._material}getGeometry(){return pp.getOrCreateGeometry(this)}}vI([w()],Fa.prototype,"guid",2),vI([w(le)],Fa.prototype,"texture",2),vI([dE()],Fa.prototype,"triangles",2),vI([dE()],Fa.prototype,"uv",2),vI([dE()],Fa.prototype,"vertices",2);const hF=Symbol("spriteOwner");class up{constructor(){n(this,"sprites")}}vI([w(Fa)],up.prototype,"sprites",2);class mh{constructor(){n(this,"spriteSheet"),n(this,"index",0)}update(A,e,i){if(!this.spriteSheet)return;const g=this.index;if(g<0||g>=this.spriteSheet.sprites.length)return;const I=this.spriteSheet.sprites[g],o=I?.texture;if(o&&(o.colorSpace=Ee,o.minFilter==qe&&o.magFilter==qe&&(o.anisotropy=1),o.needsUpdate=!0,!I.__hasLoadedProgressive)){I.__hasLoadedProgressive=!0;const s=o;Jt.assignTextureLOD(A,e,o,0).then(C=>{C instanceof le&&(I.texture=C,i?.map===s&&(i.map=C,i.needsUpdate=!0))})}}}vI([w(up)],mh.prototype,"spriteSheet",2),vI([w()],mh.prototype,"index",2);class mC extends FA{constructor(){super(...arguments),n(this,"drawMode",0),n(this,"size",{x:1,y:1}),n(this,"color"),n(this,"sharedMaterial"),n(this,"transparent",!0),n(this,"cutoutThreshold",0),n(this,"castShadows",!1),n(this,"_spriteSheet"),n(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(A){if(A!==this._spriteSheet)if(typeof A=="number"){const e=Math.floor(A);this.spriteIndex=e;return}else this._spriteSheet=A,this.updateSprite()}set spriteIndex(A){this._spriteSheet&&(this._spriteSheet.index=A,this.updateSprite())}get spriteIndex(){var A;return((A=this._spriteSheet)==null?void 0:A.index)??0}get spriteFrames(){var A,e;return((e=(A=this._spriteSheet)==null?void 0:A.spriteSheet)==null?void 0:e.sprites.length)??0}awake(){this._currentSprite=void 0,tS&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var A,e,i;if(!this.__didAwake||!((e=(A=this.sprite)==null?void 0:A.spriteSheet)!=null&&e.sprites))return;const g=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!g){tS&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=pp.getOrCreateGeometry(g),this._currentSprite.material.map=g.texture;else{const I=new st({color:16777215,side:Qt});if(!I)return;if(rrA&&(I.wireframe=!0),this.color&&(I.color||(I.color=new GA),I.color.copy(this.color),I.opacity=this.color.alpha),I.transparent=!0,g.texture&&!I.wireframe){let o=g.texture;o[hF]!==void 0&&o[hF]!==this&&this.spriteFrames>1&&(o=g.texture=o.clone()),o[hF]=this,I.map=o}this.sharedMaterial=I,this._currentSprite=new hA(pp.getOrCreateGeometry(g),I),Jt.assignTextureLOD(this.context,this.sourceId,I,0)}this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,(i=this._spriteSheet)==null||i.update(this.context,this.sourceId,this.sharedMaterial)}}vI([w()],mC.prototype,"drawMode",2),vI([w(St)],mC.prototype,"color",2),vI([w(Re)],mC.prototype,"sharedMaterial",2),vI([w()],mC.prototype,"transparent",2),vI([w()],mC.prototype,"cutoutThreshold",2),vI([w()],mC.prototype,"castShadows",2),vI([w(mh)],mC.prototype,"sprite",1);class JC{constructor(){n(this,"bb",null),n(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedCameraModel(A,e){return(e||new JC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedCameraModel(A,e){return A.setPosition(A.position()+DU),(e||new JC).__init(A.readInt32(A.position())+A.position(),A)}userId(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}guid(A){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,A):null}dontSave(){const A=this.bb.__offset(this.bb_pos,8);return A?!!this.bb.readInt8(this.bb_pos+A):!1}pos(A){const e=this.bb.__offset(this.bb_pos,10);return e?(A||new DB).__init(this.bb_pos+e,this.bb):null}rot(A){const e=this.bb.__offset(this.bb_pos,12);return e?(A||new DB).__init(this.bb_pos+e,this.bb):null}static startSyncedCameraModel(A){A.startObject(5)}static addUserId(A,e){A.addFieldOffset(0,e,0)}static addGuid(A,e){A.addFieldOffset(1,e,0)}static addDontSave(A,e){A.addFieldInt8(2,+e,0)}static addPos(A,e){A.addFieldStruct(3,e,0)}static addRot(A,e){A.addFieldStruct(4,e,0)}static endSyncedCameraModel(A){return A.endObject()}static finishSyncedCameraModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedCameraModelBuffer(A,e){A.finish(e,void 0,!0)}}var BrA=Object.defineProperty,QrA=Object.getOwnPropertyDescriptor,ErA=(t,A,e,i)=>{for(var g=i>1?void 0:i?QrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BrA(A,e,g),g};const iS="SCAM";SU(iS,JC.getRootAsSyncedCameraModel);const Mo=new Pp;class hrA{constructor(A,e){n(this,"userId"),n(this,"guid"),this.guid=e,this.userId=A}send(A,e){if(A){Mo.clear();const i=Mo.createString(this.guid),g=Mo.createString(this.userId);JC.startSyncedCameraModel(Mo),JC.addGuid(Mo,i),JC.addUserId(Mo,g);const I=Fe(A),o=Zc(A);JC.addPos(Mo,DB.createVec3(Mo,I.x,I.y,I.z)),JC.addRot(Mo,DB.createVec3(Mo,o.x,o.y,o.z));const s=JC.endSyncedCameraModel(Mo);Mo.finish(s,iS),e.sendBinary(Mo.asUint8Array())}}}var cF;const lF=(cF=class extends FA{constructor(){super(...arguments),n(this,"cameraPrefab",null),n(this,"_lastWorldPosition"),n(this,"_lastWorldQuaternion"),n(this,"_model",null),n(this,"_needsUpdate",!0),n(this,"_lastUpdateTime",0),n(this,"remoteCams",{}),n(this,"userToCamMap",{}),n(this,"_camTimeoutInSeconds",10),n(this,"_receiveCallback",null)}getCameraObject(t){const A=this.userToCamMap[t];return A?this.remoteCams[A].obj:null}async awake(){this._lastWorldPosition=this.worldPosition.clone(),this._lastWorldQuaternion=this.worldQuaternion.clone(),this.cameraPrefab&&("uri"in this.cameraPrefab&&(this.cameraPrefab=await this.cameraPrefab.instantiate(this.gameObject)),this.cameraPrefab&&"isObject3D"in this.cameraPrefab&&(this.cameraPrefab.visible=!1))}onEnable(){this._receiveCallback=this.context.connection.beginListenBinary(iS,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(iS,this._receiveCallback)}update(){for(const i in this.remoteCams){const g=this.remoteCams[i],I=this.context.time.realtimeSinceStartup-g.lastUpdate;if(!g||I>this._camTimeoutInSeconds){re()&&console.log("Remote cam timeout",i),g!=null&&g.obj&&CA.destroy(g.obj),delete this.remoteCams[i],g&&delete this.userToCamMap[g.userId],lF.instances.push(g),this.context.players.removePlayerView(g.userId,Un.Browser);continue}}if(this.context.isInXR)return;const t=this.context.mainCamera;if(t===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new hrA(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const A=Fe(t),e=Gt(t);(A.distanceTo(this._lastWorldPosition)>.001||e.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(A),this._lastWorldQuaternion.copy(e),!((!this._needsUpdate||this.context.time.frameCount%2!==0)&&!(this.context.time.realtimeSinceStartup-this._lastUpdateTime>this._camTimeoutInSeconds*.5))&&(this._lastUpdateTime=this.context.time.realtimeSinceStartup,this._needsUpdate=!1,this._model.send(t,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,t,Un.Browser))}onReceivedRemoteCameraInfoBin(t){const A=t.guid();if(!A)return;const e=t.userId();if(!e||!this.context.connection.userIsInRoom(e)||!this.cameraPrefab)return;let i=this.remoteCams[A];if(!i)if("isObject3D"in this.cameraPrefab){const s=new Ys;s.context=this.context;const C=CA.instantiate(this.cameraPrefab,s);i=this.remoteCams[A]={obj:C,lastUpdate:this.context.time.realtimeSinceStartup,userId:e},i.obj.visible=!0,this.gameObject.add(C),this.userToCamMap[e]=A,lF.instances.push(i);const a=CA.getOrAddComponent(C,xg);a.connectionId=e,a.avatar=C}else return;const g=i.obj;this.context.players.setPlayerView(e,g,Un.Browser),i.lastUpdate=this.context.time.realtimeSinceStartup,ns.markDirty(g);const I=t.pos();I&&Zr(g,I.x(),I.y(),I.z());const o=t.rot();o&&Vc(g,o.x(),o.y(),o.z())}},n(cF,"instances",[]),cF);let gS=lF;ErA([w([uA,tt])],gS.prototype,"cameraPrefab",2);var crA=Object.defineProperty,lrA=Object.getOwnPropertyDescriptor,kh=(t,A,e,i)=>{for(var g=i>1?void 0:i?lrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&crA(A,e,g),g};const dF="view",pF=tA("debugsyncedroom");class Ka extends FA{constructor(){super(...arguments),n(this,"roomName"),n(this,"urlParameterName","room"),n(this,"joinRandomRoom",!0),n(this,"requireRoomParameter",!1),n(this,"autoRejoin",!0),n(this,"createJoinButton",!0),n(this,"_roomPrefix"),n(this,"_lastJoinedRoom",""),n(this,"_lastPingTime",0),n(this,"_lastRoomTime",-1),n(this,"_userWantsToBeInARoom",!1),n(this,"_roomButton"),n(this,"_roomButtonIconJoin"),n(this,"_roomButtonIconLeave"),n(this,"updateRoomButtonState",()=>{var A,e;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(A=this._roomButtonIconJoin)==null||A.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(e=this._roomButtonIconLeave)==null||e.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){pF&&console.log("Room",this.roomName,this.urlParameterName,this.joinRandomRoom,this.requireRoomParameter,this.autoRejoin),this._roomPrefix===void 0&&(this._roomPrefix=this.roomName,this.roomName="")}onEnable(){const A=tA(dF);if(A&&typeof A=="string"&&A.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(A,!0);return}if((this.joinRandomRoom||tA(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const e=this.createRoomButton();this.context.menu.appendChild(e)}}onDisable(){var A;(A=this._roomButton)==null||A.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(A=0){A===void 0&&(A=0);let e=!1;if(this.urlParameterName){const i=tA(this.urlParameterName);if(i&&typeof i=="string"||i==="number"){e=!0;const g=Qq(i);this.roomName=g}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),A<1))return this.tryJoinRoom(A+1)}else this.joinRandomRoom&&(this.roomName===null||this.roomName===void 0||this.roomName.length<=0)&&(console.log("generate room name"),this.roomName=this.generateRoomName());return this.requireRoomParameter&&!e?(pF&&console.log('No required room parameter "'+this.urlParameterName+'" in url - will not connect to networking backend.'),!1):(this.context.connection.isConnected||this.context.connection.connect(),pF&&console.log("Join "+this.roomName),this._lastJoinedRoom=this.roomName,this._roomPrefix&&(this.roomName=this._roomPrefix+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0)}update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):re()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}get currentRoomName(){return tA(dF)||tA(this.urlParameterName)}setRandomRoomUrlParameter(){const A=xc(),e=this.generateRoomName();tA(this.urlParameterName)?A.set(this.urlParameterName,e):A.append(this.urlParameterName,e),Hk(e,A)}generateRoomName(){return Tk()+"_"+Math.floor(Ae.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const A=window.location.search,e=new URLSearchParams(A);return e.has(this.urlParameterName)&&e.delete(this.urlParameterName),e.set(dF,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+e.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const A=document.createElement("button");return this._roomButton=A,A.classList.add("create-room-button"),A.setAttribute("priority","90"),A.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&LD(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(tA(this.urlParameterName)||(this._lastJoinedRoom?LD(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=ro("group"),this._roomButtonIconLeave=ro("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(At.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(At.LeftRoom,this.updateRoomButtonState),A}destroyRoomButton(){this.context.connection.stopListen(At.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(At.LeftRoom,this.updateRoomButtonState)}}kh([w()],Ka.prototype,"roomName",2),kh([w()],Ka.prototype,"urlParameterName",2),kh([w()],Ka.prototype,"joinRandomRoom",2),kh([w()],Ka.prototype,"requireRoomParameter",2),kh([w()],Ka.prototype,"autoRejoin",2),kh([w()],Ka.prototype,"createJoinButton",2);class IS extends FA{}function drA(){const t=tA("testwindowcount")||0;t&&t>0&&prA(t)}function prA(t){if(tA("testwindow"))return null;const A=new URL(window.location.href);_k(A.searchParams,lIA,1),_k(A.searchParams,"testwindow",1);const e=A.toString(),i=[];window.onbeforeunload=()=>{for(const C of i)C.close()};const g=.05,I=128;let o=0,s=0;for(let C=0;C<t;C++){o*I+I*.01>=window.innerWidth&&(s+=1,o=0);const a=o*(I*(1+g))+window.screenLeft,r=s*(I*(1+g))+window.screenTop+90+60*s;o+=1;const B=window.open(e,"test window "+C,`popup=yes width=${I} height=${I} top=${r} left=${a}`);if(!B){console.warn("Failed to open window");continue}i.push(B),B.onload=()=>{B.onbeforeunload=()=>{for(let Q=0;Q<i.length;Q++){const E=i[Q];E!==B&&E.close()}i.length=0}}}return i}class uF extends FA{awake(){drA()}}class DF extends FA{constructor(){super(...arguments),n(this,"transformsPerFrame",10),n(this,"interval",0),n(this,"useFlatbuffers",!0),n(this,"builder",null),n(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Xl,A=>{});else{this.models=[];for(let A=0;A<this.transformsPerFrame;A++)this.models.push(new y1(this.context.connection.connectionId+"_simulatedTransform_"+A,this))}}update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new Pp(1024));const A=this.builder;for(let e=0;e<this.transformsPerFrame;e++){A.clear();const i=PT(this.context.connection.connectionId,this);this.context.connection.sendBinary(i)}}else if(this.models)for(let A=0;A<this.models.length;A++){const e=this.models[A];e.dontSave=!0,e.update(this,null),this.context.connection.send("TestSimulateUserData-"+A,e)}}}}class y1{constructor(A,e){n(this,"guid"),n(this,"fast",!1),n(this,"position"),n(this,"rotation"),n(this,"velocity"),n(this,"dontSave"),this.guid=A,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(e,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(A,e){const i=A.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const g=A.worldQuaternion;if(this.rotation.x=g.x,this.rotation.y=g.y,this.rotation.z=g.z,this.rotation.w=g.w,this.fast=!1,e){const I=e.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=I.x,this.velocity.y=I.y,this.velocity.z=I.z}}}n(y1,"temp",new S);var urA=Object.defineProperty,DrA=Object.getOwnPropertyDescriptor,Gh=(t,A,e,i)=>{for(var g=i>1?void 0:i?DrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&urA(A,e,g),g};class kC extends aI{constructor(){super(...arguments),n(this,"offset"),n(this,"rotation"),n(this,"focusArea"),n(this,"feather"),n(this,"kernelSize"),n(this,"resolutionScale")}get typeName(){return"TiltShiftEffect"}init(){this.offset.defaultValue=0,this.rotation.defaultValue=0,this.focusArea.defaultValue=.4,this.feather.defaultValue=.3,this.kernelSize.defaultValue=sa.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const A=new weA({kernelSize:sa.VERY_LARGE});return this.offset.onValueChanged=e=>A.offset=e,this.rotation.onValueChanged=e=>A.rotation=e,this.focusArea.onValueChanged=e=>A.focusArea=e,this.feather.onValueChanged=e=>A.feather=e,this.kernelSize.onValueChanged=e=>A.blurPass.kernelSize=e,this.resolutionScale.onValueChanged=e=>A.resolution.scale=e/window.devicePixelRatio,A}}Gh([w(Ne)],kC.prototype,"offset",2),Gh([w(Ne)],kC.prototype,"rotation",2),Gh([w(Ne)],kC.prototype,"focusArea",2),Gh([w(Ne)],kC.prototype,"feather",2),Gh([w(Ne)],kC.prototype,"kernelSize",2),Gh([w(Ne)],kC.prototype,"resolutionScale",2),As("TiltShiftEffect",kC);var wrA=Object.defineProperty,yrA=Object.getOwnPropertyDescriptor,SrA=(t,A,e,i)=>{for(var g=i>1?void 0:i?yrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&wrA(A,e,g),g};class Dp extends aI{constructor(){super(...arguments),n(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new Ne(_I)),this.mode.defaultValue=_I}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(A){this.context.renderer.toneMapping=this.getThreeToneMapping(A)}getThreeToneMapping(A){switch(A){case 0:return cQ;case 1:return su;case 2:return ou;default:return cQ}}}SrA([w(Ne)],Dp.prototype,"mode",2),As("Tonemapping",Dp);var frA=Object.defineProperty,mrA=Object.getOwnPropertyDescriptor,oS=(t,A,e,i)=>{for(var g=i>1?void 0:i?mrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&frA(A,e,g),g};class eQ extends FA{constructor(){super(...arguments),n(this,"isGizmo",!1),n(this,"translationSnap",1),n(this,"rotationSnapAngle",15),n(this,"scaleSnap",.25),n(this,"control"),n(this,"orbit"),n(this,"onControlChangedEvent",A=>{const e=this.orbit;if(e&&(e.enabled=!A.value),A.value){const i=CA.getComponentInParent(this.gameObject,vn);i&&i.requestOwnership()}}),n(this,"windowKeyDownListener",A=>{if(this.enabled&&this.control)switch(A.keyCode){case 81:this.control.setSpace(this.control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this.control.setMode("translate");break;case 69:this.control.setMode("rotate");break;case 82:this.control.setMode("scale");break;case 187:case 107:this.control.setSize(this.control.size+.1);break;case 189:case 109:this.control.setSize(Math.max(this.control.size-.1,.1));break;case 88:this.control.showX=!this.control.showX;break;case 89:this.control.showY=!this.control.showY;break;case 90:this.control.showZ=!this.control.showZ;break;case 32:this.control.enabled=!this.control.enabled;break}}),n(this,"windowKeyUpListener",A=>{if(this.enabled)switch(A.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var A;this.isGizmo&&!fl||this.context.mainCamera&&(this.control||(this.control=new V7(this.context.mainCamera,this.context.renderer.domElement),this.control.visible=!0,this.control.enabled=!0,this.control.getRaycaster().layers.set(2),this.control.size=1,this.control.traverse(e=>{const i=e;if(i.layers.set(2),i){const g=i.material;g&&(g.opacity=.3)}}),this.orbit=CA.getComponentInParent(this.context.mainCamera,ft)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(A=this.control)==null||A.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var A,e;(A=this.control)==null||A.removeFromParent(),(e=this.control)==null||e.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this.control&&(this.control.setTranslationSnap(this.translationSnap),this.control.setRotationSnap(zi.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}oS([w()],eQ.prototype,"isGizmo",2),oS([w()],eQ.prototype,"translationSnap",2),oS([w()],eQ.prototype,"rotationSnapAngle",2),oS([w()],eQ.prototype,"scaleSnap",2);var krA=Object.defineProperty,GrA=Object.getOwnPropertyDescriptor,wF=(t,A,e,i)=>{for(var g=i>1?void 0:i?GrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&krA(A,e,g),g};class tQ extends aI{constructor(){super(...arguments),n(this,"color"),n(this,"intensity"),n(this,"center")}get typeName(){return"Vignette"}init(){this.color.defaultValue={r:0,g:0,b:0,a:1},this.intensity.defaultValue=0,this.center.defaultValue={x:.5,y:.5}}onCreateEffect(){const A=new HY;return this.intensity.onValueChanged=e=>{A.offset=e,this.updateDarkness(A)},this.color.onValueChanged=e=>{this.updateDarkness(A)},A}updateDarkness(A){const e=this.intensity.value;A.darkness=e}}wF([w(Ne)],tQ.prototype,"color",2),wF([w(Ne)],tQ.prototype,"intensity",2),wF([w(Ne)],tQ.prototype,"center",2),As("Vignette",tQ);var MrA=Object.defineProperty,UrA=Object.getOwnPropertyDescriptor,RrA=(t,A,e,i)=>{for(var g=i>1?void 0:i?UrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MrA(A,e,g),g};const sS=tA("debugarcamera");class CS extends FA{constructor(){super(...arguments),n(this,"backgroundTint",new St(1,1,1,1)),n(this,"backgroundPlane"),n(this,"threeTexture"),n(this,"forceTextureInitialization",function(){const A=new st,e=new Zi,i=new eI;i.add(new hA(e,A));const g=new xe;return function(I,o){A.map=o,I.render(i,g),sS&&console.warn("Force texture initialization")}}()),n(this,"preRender",()=>{if(!this||!this.gameObject)return;const A=this.context.renderer.xr.getFrame();A&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new le,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=FrA(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(A))})}onBeforeXR(A,e){e.optionalFeatures=e.optionalFeatures||[],e.optionalFeatures.push("camera-access"),sS&&console.warn("Requesting camera-access")}onEnterXR(A){this.backgroundPlane&&(this.context.scene.add(this.backgroundPlane),this.backgroundPlane.visible=!1),this.backgroundPlane&&this.context.scene.add(this.backgroundPlane),this.context.pre_render_callbacks.push(this.preRender)}onLeaveXR(A){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const e=this.context.pre_render_callbacks.indexOf(this.preRender);e>=0&&this.context.pre_render_callbacks.splice(e,1)}get background(){return this.backgroundPlane}onBeforeRender(A){this.updateFromFrame(A)}updateFromFrame(A){if(!A)return;const e=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(e){for(const i of e.views)if("camera"in i&&i.camera){let g=this.context.renderer.xr.getBinding();if(g||(g=new XRWebGLBinding(A.session,this.context.renderer.getContext())),g){let I=null;if("getCameraImage"in g){I=g.getCameraImage(i.camera);const o=this.context.renderer.properties.get(this.threeTexture);o.__webglTexture=I,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):sS&&console.warn("No background plane to set texture on")}}}}}}RrA([w(St)],CS.prototype,"backgroundTint",2);const NrA=`
|
|
7018
|
+
`)}}applyShadowMaterial(){if(this.targetMesh)if(this.targetMesh.material.type!=="ShadowMaterial"){const A=new wD;A.color=this.shadowColor,A.opacity=this.shadowColor.alpha,this.applyMaterialOptions(A),this.targetMesh.material=A}else{const A=this.targetMesh.material;A.color=this.shadowColor,A.opacity=this.shadowColor.alpha,this.applyMaterialOptions(A)}}applyOccluderMaterial(){if(this.targetMesh){let A=this.targetMesh.material;if(!A){const e=new st;this.targetMesh.material=e,A=e}A.depthWrite=!0,A.stencilWrite=!0,A.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(A){A&&(A.depthWrite=!1,A.stencilWrite=!1)}}c1([w()],Ep.prototype,"mode",2),c1([w(St)],Ep.prototype,"shadowColor",2);var HnA=Object.defineProperty,TnA=Object.getOwnPropertyDescriptor,X0=(t,A,e,i)=>{for(var g=i>1?void 0:i?TnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HnA(A,e,g),g},rF;const l1=(rF=class extends FA{constructor(){super(...arguments),n(this,"target",null),n(this,"followFactor",.1),n(this,"rotateFactor",.1),n(this,"positionAxes",qE.All),n(this,"flipForward",!1),n(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(t){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const A=Fe(this.target),e=this._firstUpdate||t?1:Ae.clamp01(this.context.time.deltaTime*this.followFactor),i=this.worldPosition;this.positionAxes&qE.X&&(i.x=Ae.lerp(i.x,A.x,e)),this.positionAxes&qE.Y&&(i.y=Ae.lerp(i.y,A.y,e)),this.positionAxes&qE.Z&&(i.z=Ae.lerp(i.z,A.z,e)),this.worldPosition=i}if(this.rotateFactor>0){const A=Gt(this.target);this.flipForward&&A.premultiply(l1._invertForward);const e=this._firstUpdate||t?1:Ae.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(A,e)}this._firstUpdate=!1}}},n(rF,"_invertForward",new RA().setFromAxisAngle(new S(0,1,0),Math.PI)),rF);let gr=l1;X0([w(uA)],gr.prototype,"target",2),X0([w()],gr.prototype,"followFactor",2),X0([w()],gr.prototype,"rotateFactor",2),X0([w()],gr.prototype,"positionAxes",2);class OnA extends hA{constructor(A){const e=new PnA(A),i=new Zi(e.image.width*.001,e.image.height*.001),g=new st({map:e,toneMapped:!1,transparent:!0});super(i,g);function I(o){g.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",I),this.addEventListener("mousemove",I),this.addEventListener("mouseup",I),this.addEventListener("click",I),this.dispose=function(){i.dispose(),g.dispose(),g.map.dispose(),BF.delete(A),this.removeEventListener("mousedown",I),this.removeEventListener("mousemove",I),this.removeEventListener("mouseup",I),this.removeEventListener("click",I)}}}class PnA extends Ik{constructor(A){super(d1(A)),this.dom=A,this.anisotropy=16,this.colorSpace=Ee,this.minFilter=me,this.magFilter=me;const e=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),i={attributes:!0,childList:!0,subtree:!0,characterData:!0};e.observe(A,i),this.observer=e}dispatchDOMEvent(A){A.data&&jnA(this.dom,A.type,A.data.x,A.data.y)}update(){this.image=d1(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const BF=new WeakMap;function d1(t){const A=document.createRange(),e=new GA;function i(Q){const E=[];let h=!1;function d(){if(h&&(h=!1,Q.restore()),E.length===0)return;let l=-1/0,c=-1/0,p=1/0,u=1/0;for(let D=0;D<E.length;D++){const k=E[D];l=Math.max(l,k.x),c=Math.max(c,k.y),p=Math.min(p,k.x+k.width),u=Math.min(u,k.y+k.height)}Q.save(),Q.beginPath(),Q.rect(l,c,p-l,u-c),Q.clip(),h=!0}return{add:function(l){E.push(l),d()},remove:function(){E.pop(),d()}}}function g(Q,E,h,d){d!==""&&(Q.textTransform==="uppercase"&&(d=d.toUpperCase()),r.font=Q.fontWeight+" "+Q.fontSize+" "+Q.fontFamily,r.textBaseline="top",r.fillStyle=Q.color,r.fillText(d,E,h+parseFloat(Q.fontSize)*.1))}function I(Q,E,h,d,l){h<2*l&&(l=h/2),d<2*l&&(l=d/2),r.beginPath(),r.moveTo(Q+l,E),r.arcTo(Q+h,E,Q+h,E+d,l),r.arcTo(Q+h,E+d,Q,E+d,l),r.arcTo(Q,E+d,Q,E,l),r.arcTo(Q,E,Q+h,E,l),r.closePath()}function o(Q,E,h,d,l,c){const p=Q[E+"Width"],u=Q[E+"Style"],D=Q[E+"Color"];p!=="0px"&&u!=="none"&&D!=="transparent"&&D!=="rgba(0, 0, 0, 0)"&&(r.strokeStyle=D,r.lineWidth=parseFloat(p),r.beginPath(),r.moveTo(h,d),r.lineTo(h+l,d+c),r.stroke())}function s(Q,E){let h=0,d=0,l=0,c=0;if(Q.nodeType===Node.TEXT_NODE){A.selectNode(Q);const u=A.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,g(E,h,d,Q.nodeValue.trim())}else{if(Q.nodeType===Node.COMMENT_NODE)return;if(Q instanceof HTMLCanvasElement){if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,r.save();const D=window.devicePixelRatio;r.scale(1/D,1/D),r.drawImage(Q,h,d),r.restore()}else if(Q instanceof HTMLImageElement){if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,r.drawImage(Q,h,d,l,c)}else{if(Q.style.display==="none")return;const u=Q.getBoundingClientRect();h=u.left-C.left-.5,d=u.top-C.top-.5,l=u.width,c=u.height,E=window.getComputedStyle(Q),I(h,d,l,c,parseFloat(E.borderRadius));const D=E.backgroundColor;D!=="transparent"&&D!=="rgba(0, 0, 0, 0)"&&(r.fillStyle=D,r.fill());const k=["borderTop","borderLeft","borderBottom","borderRight"];let U=!0,M=null;for(const G of k){if(M!==null&&(U=E[G+"Width"]===E[M+"Width"]&&E[G+"Color"]===E[M+"Color"]&&E[G+"Style"]===E[M+"Style"]),U===!1)break;M=G}if(U===!0){const G=parseFloat(E.borderTopWidth);E.borderTopWidth!=="0px"&&E.borderTopStyle!=="none"&&E.borderTopColor!=="transparent"&&E.borderTopColor!=="rgba(0, 0, 0, 0)"&&(r.strokeStyle=E.borderTopColor,r.lineWidth=G,r.stroke())}else o(E,"borderTop",h,d,l,0),o(E,"borderLeft",h,d,0,c),o(E,"borderBottom",h,d+c,l,0),o(E,"borderRight",h+l,d,0,c);if(Q instanceof HTMLInputElement){let G=E.accentColor;(G===void 0||G==="auto")&&(G=E.color),e.set(G);const K=Math.sqrt(.299*e.r**2+.587*e.g**2+.114*e.b**2)<.5?"white":"#111111";if(Q.type==="radio"&&(I(h,d,l,c,c),r.fillStyle="white",r.strokeStyle=G,r.lineWidth=1,r.fill(),r.stroke(),Q.checked&&(I(h+2,d+2,l-4,c-4,c),r.fillStyle=G,r.strokeStyle=K,r.lineWidth=2,r.fill(),r.stroke())),Q.type==="checkbox"&&(I(h,d,l,c,2),r.fillStyle=Q.checked?G:"white",r.strokeStyle=Q.checked?K:G,r.lineWidth=1,r.stroke(),r.fill(),Q.checked)){const f=r.textAlign;r.textAlign="center";const N={color:K,fontFamily:E.fontFamily,fontSize:c+"px",fontWeight:"bold"};g(N,h+l/2,d,"\u2714"),r.textAlign=f}if(Q.type==="range"){const[f,N,_]=["min","max","value"].map(v=>parseFloat(Q[v])),T=(_-f)/(N-f)*(l-c);I(h,d+c/4,l,c/2,c/4),r.fillStyle=K,r.strokeStyle=G,r.lineWidth=1,r.fill(),r.stroke(),I(h,d+c/4,T+c/2,c/2,c/4),r.fillStyle=G,r.fill(),I(h+T,d,c,c,c/2),r.fillStyle=G,r.fill()}(Q.type==="color"||Q.type==="text"||Q.type==="number")&&(B.add({x:h,y:d,width:l,height:c}),g(E,h+parseInt(E.paddingLeft),d+parseInt(E.paddingTop),Q.value),B.remove())}}}const p=E.overflow==="auto"||E.overflow==="hidden";p&&B.add({x:h,y:d,width:l,height:c});for(let u=0;u<Q.childNodes.length;u++)s(Q.childNodes[u],E);p&&B.remove()}const C=t.getBoundingClientRect();let a=BF.get(t);a===void 0&&(a=document.createElement("canvas"),a.width=C.width,a.height=C.height,BF.set(t,a));const r=a.getContext("2d"),B=new i(r);return r.clearRect(0,0,a.width,a.height),s(t),a}function jnA(t,A,e,i){const g={clientX:e*t.offsetWidth+t.offsetLeft,clientY:i*t.offsetHeight+t.offsetTop,view:t.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(A,g));const I=t.getBoundingClientRect();e=e*I.width+I.left,i=i*I.height+I.top;function o(s){if(s.nodeType!==Node.TEXT_NODE&&s.nodeType!==Node.COMMENT_NODE){const C=s.getBoundingClientRect();if(e>C.left&&e<C.right&&i>C.top&&i<C.bottom&&(s.dispatchEvent(new MouseEvent(A,g)),s instanceof HTMLInputElement&&s.type==="range"&&(A==="mousedown"||A==="click"))){const[a,r]=["min","max"].map(E=>parseFloat(s[E])),B=C.width,Q=(e-C.x)/B;s.value=a+(r-a)*Q,s.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let a=0;a<s.childNodes.length;a++)o(s.childNodes[a])}}o(t)}const $0=new eA,fh={type:"",data:$0},p1=new Hr;class WnA extends pI{listenToPointerEvents(A,e){const i=this,g=new Hr,I=A.domElement;function o(s){s.stopPropagation();const C=A.domElement.getBoundingClientRect();$0.x=(s.clientX-C.left)/C.width*2-1,$0.y=-(s.clientY-C.top)/C.height*2+1,g.setFromCamera($0,e);const a=g.intersectObjects(i.children,!1);if(a.length>0){const r=a[0],B=r.object,Q=r.uv;fh.type=s.type,fh.data.set(Q.x,1-Q.y),B.dispatchEvent(fh)}}I.addEventListener("pointerdown",o),I.addEventListener("pointerup",o),I.addEventListener("pointermove",o),I.addEventListener("mousedown",o),I.addEventListener("mouseup",o),I.addEventListener("mousemove",o),I.addEventListener("click",o)}listenToXRControllerEvents(A){const e=this,i={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function g(I){const o=I.target;p1.setFromXRController(o);const s=p1.intersectObjects(e.children,!1);if(s.length>0){const C=s[0],a=C.object,r=C.uv;fh.type=i[I.type],fh.data.set(r.x,1-r.y),a.dispatchEvent(fh)}}A.addEventListener("move",g),A.addEventListener("select",g),A.addEventListener("selectstart",g),A.addEventListener("selectend",g)}}var ZnA=Object.defineProperty,VnA=Object.getOwnPropertyDescriptor,u1=(t,A,e,i)=>{for(var g=i>1?void 0:i?VnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZnA(A,e,g),g};class hp extends FA{constructor(){super(...arguments),n(this,"id",null),n(this,"keepAspect",!1),n(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const A=document.getElementById(this.id);if(!A){console.warn('Could not find element with id "'+this.id+'"');return}A.style.display="block",A.style.visibility="hidden";const e=new WnA;e.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(e);const i=new OnA(A);e.add(i),i.visible=!1;const g=i.material;g.transparent=!0,setTimeout(()=>{i.visible=!0;const I=Zc(this.gameObject).clone();Vc(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const o=new pt;o.setFromObject(e),this.setWorldRotation(I.x,I.y,I.z);const s=o.max.x-o.min.x,C=o.max.y-o.min.y;if(this.keepAspect){const r=s/C;s>C?i.scale.set(1/s,1/C/r,1):i.scale.set(1/s*r,1/C,1)}else i.scale.set(1/s,1/C,1);const a=this.gameObject.scale;i.scale.multiply(a)},1)}onDisable(){var A;(A=this._object)==null||A.removeFromParent()}}u1([w()],hp.prototype,"id",2),u1([w()],hp.prototype,"keepAspect",2);var znA=Object.defineProperty,XnA=Object.getOwnPropertyDescriptor,cp=(t,A,e,i)=>{for(var g=i>1?void 0:i?XnA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&znA(A,e,g),g};const lp=tA("debugspatialtrigger"),D1=new $g,w1=new $g;function $nA(t,A){return D1.mask=t,w1.mask=A,D1.test(w1)}class fC extends FA{constructor(){super(...arguments),n(this,"triggerMask",0),n(this,"onEnter"),n(this,"onStay"),n(this,"onExit"),n(this,"currentIntersected",[]),n(this,"lastIntersected",[])}start(){lp&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const A of dp.triggers)$nA(A.triggerMask,this.triggerMask)&&A.test(this.gameObject)&&this.currentIntersected.push(A);for(let A=this.lastIntersected.length-1;A>=0;A--){const e=this.lastIntersected[A];this.currentIntersected.indexOf(e)<0&&(this.onExitTrigger(e),this.lastIntersected.splice(A,1))}for(const A of this.currentIntersected)this.lastIntersected.indexOf(A)<0&&this.onEnterTrigger(A),this.onStayTrigger(A);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(A){var e;lp&&console.log("ENTER TRIGGER",this.name,A.name,this,A),A.raiseOnEnterEvent(this),(e=this.onEnter)==null||e.invoke(this,A)}onExitTrigger(A){var e;lp&&console.log("EXIT TRIGGER",this.name,A.name,this,A),A.raiseOnExitEvent(this),(e=this.onExit)==null||e.invoke(this,A)}onStayTrigger(A){var e;A.raiseOnStayEvent(this),(e=this.onStay)==null||e.invoke(this,A)}}cp([w()],fC.prototype,"triggerMask",2),cp([w(tg)],fC.prototype,"onEnter",2),cp([w(tg)],fC.prototype,"onStay",2),cp([w(tg)],fC.prototype,"onExit",2);var QF;const AS=(QF=class extends FA{constructor(){super(...arguments),n(this,"triggerMask"),n(this,"boxHelper")}start(){lp&&console.log(this.name,this.triggerMask,this)}onEnable(){var t;AS.triggers.push(this),this.boxHelper||(this.boxHelper=CA.addNewComponent(this.gameObject,lC),(t=this.boxHelper)==null||t.showHelper(null,lp))}onDisable(){AS.triggers.splice(AS.triggers.indexOf(this),1)}test(t){return this.boxHelper?this.boxHelper.isInBox(t)??!1:!1}raiseOnEnterEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onEnterTrigger(this)},!1)}raiseOnStayEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onStayTrigger(this)},!1)}raiseOnExitEvent(t){CA.foreachComponent(this.gameObject,A=>{A!==t&&A instanceof fC&&A.onExitTrigger(this)},!1)}},n(QF,"triggers",[]),QF);let dp=AS;cp([w()],dp.prototype,"triggerMask",2);var ArA=Object.defineProperty,erA=Object.getOwnPropertyDescriptor,trA=(t,A,e,i)=>{for(var g=i>1?void 0:i?erA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ArA(A,e,g),g};const Go=tA("debugspectator");class eS extends FA{constructor(){super(...arguments),n(this,"cam",null),n(this,"useKeys",!0),n(this,"_mode",0),n(this,"orbit",null),n(this,"_handler"),n(this,"eventSub_WebXRRequestStartEvent",null),n(this,"eventSub_WebXRStartEvent",null),n(this,"eventSub_WebXREndEvent",null),n(this,"_debug"),n(this,"_networking")}get mode(){return this._mode}set mode(A){this._mode=A}get isSpectating(){var A;return((A=this._handler)==null?void 0:A.currentTarget)!==void 0}isSpectatingUser(A){var e;return((e=this.target)==null?void 0:e.userId)===A}isFollowedBy(A){var e;return(e=this.followers)==null?void 0:e.includes(A)}get followers(){return this._networking.followers}stopSpectating(){if(this.context.isInXR){this.followSelf();return}this.target=void 0}get localId(){return this.context.connection.connectionId??"local"}set target(A){var e;if(this._handler){const i=(e=this._handler.currentTarget)==null?void 0:e.userId,g=this.context.players.getPlayerView(this.localId);A===void 0||this.context.isInXR===!1&&g?.currentObject===A.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),CA.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(A,i)):this._handler.currentTarget!==A&&(this._handler.set(A),CA.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(A,i))}}get target(){var A;return(A=this._handler)==null?void 0:A.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var A,e;return this.isSpectating&&((A=this.target)==null?void 0:A.currentObject)===((e=this.context.players.getPlayerView(this.localId))==null?void 0:e.currentObject)}awake(){if(this._debug=new IrA(this.context,this),this._networking=new CrA(this.context,this),this._networking.awake(),CA.setActive(this.gameObject,!1),this.cam=CA.getComponent(this.gameObject,xt),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new irA(this.context,this.cam,this)),this.orbit=CA.getComponent(this.context.mainCamera,ft)}onDestroy(){var A,e;this.stopSpectating(),(A=this._handler)==null||A.destroy(),(e=this._networking)==null||e.destroy()}isSupportedPlatform(){const A=window.navigator.userAgent,e=/Windows|MacOS/.test(A),i=/Windows NT/.test(A)&&/Edg/.test(A)&&!/Win64/.test(A);return e&&!i}onBeforeXR(A){this.isSupportedPlatform()&&CA.setActive(this.gameObject,!0)}onEnterXR(A){this.isSupportedPlatform()&&(Go&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(A){var e,i;this.context.removeCamera(this.cam),CA.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(e=this._handler)==null||e.set(void 0),(i=this._handler)==null||i.disable(),this.isSpectatingSelf&&this.stopSpectating()}followSelf(){this.target=this.context.players.getPlayerView(this.context.connection.connectionId),this.target||(this.context.players.setPlayerView(this.localId,this.context.mainCamera,Un.Headset),this.target=this.context.players.getPlayerView(this.localId)),Go&&console.log("Follow self",this.target)}onAfterRender(){var A,e,i;if(!this.cam)return;const g=this.context.renderer,I=g.xr.enabled;if(!g.xr.isPresenting&&!((A=this._handler)!=null&&A.currentTarget))return;(e=this._handler)==null||e.update(this._mode);const o=g.getRenderTarget();let s=null;const C=g.state;if(!o){if(!g.state.bindFramebuffer||!C.bindXRFramebuffer)return;s=g._framebuffer,C.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const a=this.context.mainCameraComponent;if(a){const Q=a.backgroundColor;Q&&g.setClearColor(Q,Q.alpha),this.cam.backgroundColor=Q,this.cam.clearFlags=a.clearFlags,this.cam.nearClipPlane=a.nearClipPlane,this.cam.farClipPlane=a.farClipPlane}else g.setClearColor(new GA(1,1,1));g.setRenderTarget(null),g.xr.enabled=!1;const r=(i=this.cam)==null?void 0:i.cam;this.context.updateAspect(r);const B=g.xr.isPresenting;g.xr.isPresenting=!1,g.setSize(this.context.domWidth,this.context.domHeight),g.render(this.context.scene,r),g.xr.isPresenting=B,g.xr.enabled=I,o?g.setRenderTarget(o):C.bindXRFramebuffer&&C.bindXRFramebuffer(s),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const A=this._mode===0;for(const e of xg.instances)if(e.avatar&&"isLocalAvatar"in e.avatar&&"flags"in e.avatar){let i=EC.All;this.isSpectatingSelf&&(i=A&&e.avatar.isLocalAvatar?EC.FirstPerson:EC.ThirdPerson);const g=e.avatar.flags;if(!g)continue;for(const I of g)I.UpdateVisible(i)}}resetAvatarFlags(){var A;for(const e of xg.instances)if(e.avatar&&"flags"in e.avatar){const i=e.avatar.flags;if(!i)continue;for(const g of i)"isLocalAvatar"in e.avatar&&(A=e.avatar)!=null&&A.isLocalAvatar?g.UpdateVisible(EC.FirstPerson):g.UpdateVisible(EC.ThirdPerson)}}}trA([w()],eS.prototype,"useKeys",2);class irA{constructor(A,e,i){n(this,"context"),n(this,"cam"),n(this,"spectator"),n(this,"follow"),n(this,"target"),n(this,"view"),n(this,"currentObject"),this.context=A,this.cam=e,this.spectator=i}get currentTarget(){return this.view}set(A){const e=A?.currentObject;if(!e){this.spectator.stopSpectating();return}e!==this.currentObject&&(this.currentObject=e,this.view=A,this.follow||(this.follow=CA.addNewComponent(this.cam.gameObject,gr)),this.target||(this.target=new uA),e.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,Go&&console.log("FOLLOW",e),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){Go&&console.log("STOP FOLLOW",this.currentObject),this.view=void 0,this.currentObject=void 0,this.context.removeCamera(this.cam),this.follow&&(this.follow.enabled=!1)}destroy(){var A;(A=this.target)==null||A.removeFromParent(),this.follow&&CA.destroy(this.follow)}update(A){var e,i,g,I,o,s;if(((e=this.currentTarget)==null?void 0:e.isConnected)===!1||((i=this.currentTarget)==null?void 0:i.removed)===!0){Go&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((g=this.currentTarget)==null?void 0:g.currentObject)!==this.currentObject&&(Go&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const C=this.context.mainCamera;C&&(this.cam.cam.near!==C.near||this.cam.cam.far!==C.far)&&(this.cam.cam.near=C.near,this.cam.cam.far=C.far,this.cam.cam.updateProjectionMatrix());const a=(I=this.follow)==null?void 0:I.target;if(!(!a||!this.follow)){switch(A){case 0:((o=this.view)==null?void 0:o.viewDevice)!==Un.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),a.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,a.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((s=this.view)==null?void 0:s.viewDevice)!==Un.Browser?a.quaternion.copy(grA):a.quaternion.identity()}}}const grA=new RA().setFromAxisAngle(new S(0,1,0),Math.PI);class IrA{constructor(A,e){n(this,"context"),n(this,"spectator"),this.context=A,this.spectator=e,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",g=>{!this.spectator.useKeys||g.key==="Escape"&&this.spectator.stopSpectating()});let i=0;this.context.input.addEventListener(ei.PointerDown,g=>{i=this.context.time.time}),this.context.input.addEventListener(ei.PointerUp,g=>{const I=this.context.time.time-i;I>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&I<.3&&this.trySelectObject()})}trySelectObject(){const A=new Zo;A.setMask(16777215);const e=this.context.physics.raycast(A);if(Go&&console.log(...e),e!=null&&e.length)for(const i of e){if(i.distance<.2)continue;const g=i.object,I=CA.getComponentInParent(g,xg),o=I?.connectionId;if(o){const s=this.context.players.getPlayerView(o);this.spectator.target=s,Go&&console.log("spectate",o,I);break}}}}class orA{constructor(A,e,i){n(this,"guid"),n(this,"dontSave",!0),n(this,"targetUserId"),n(this,"stoppedFollowing"),this.guid=A,this.targetUserId=e,this.stoppedFollowing=i}}class srA{constructor(A,e){n(this,"guid"),n(this,"userId"),this.guid=A.guid,this.userId=e}}class CrA{constructor(A,e){n(this,"followers",[]),n(this,"context"),n(this,"spectator"),n(this,"_followerEventMethod"),n(this,"_requestFollowMethod"),n(this,"_joinedRoomMethod"),n(this,"_lastRequestFollowUser"),n(this,"_enforceFollowInterval"),this.context=A,this.spectator=e,this._followerEventMethod=this.onFollowerEvent.bind(this),this._requestFollowMethod=this.onRequestFollowEvent.bind(this),this._joinedRoomMethod=this.onUserJoinedRoom.bind(this)}awake(){this.context.connection.beginListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.beginListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.beginListen(At.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",A=>{this.spectator.useKeys&&(A.key==="f"?this.onRequestFollowMe():A.key==="Escape"&&this.onRequestFollowMe(!0))})}destroy(){this.context.connection.stopListen("spectator-follower-changed",this._followerEventMethod),this.context.connection.stopListen("spectator-request-follow",this._requestFollowMethod),this.context.connection.stopListen(At.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(A,e){if(Go&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",A,e),this.context.connection.connectionId){const i=A?.userId===void 0,g=i?e:A?.userId,I=new orA(this.context.connection.connectionId,g,i);this.context.connection.send("spectator-follower-changed",I)}}onRequestFollowMe(A=!1){if(Go&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const e=A?void 0:this.context.connection.connectionId,i=new srA(this.spectator,e);this.context.connection.send("spectator-request-follow",i)}}onUserJoinedRoom(){tA("followme")&&this.onRequestFollowMe()}onFollowerEvent(A){const e=A.targetUserId,i=A.guid;if(Go&&console.log(A),e===this.context.connection.connectionId)if(A.stoppedFollowing){const g=this.followers.indexOf(i);g!==-1&&(this.followers.splice(g,1),this.removeDisconnectedFollowers(),console.log(i,"unfollows you",this.followers.length))}else this.followers.includes(i)||(this.followers.push(i),this.removeDisconnectedFollowers(),console.log(i,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let A=this.followers.length-1;A>=0;A--){const e=this.followers[A];this.context.connection.userIsInRoom(e)===!1&&this.followers.splice(A,1)}}onRequestFollowEvent(A){if(this._lastRequestFollowUser=A,A.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(A.userId===void 0)this.spectator.stopSpectating();else{const e=this.context.players.getPlayerView(A.userId);if(e)this.spectator.target=e;else return Go&&console.warn("Could not find view",A.userId),this.enforceFollow(),!1}return!0}enforceFollow(){this._enforceFollowInterval||(this._enforceFollowInterval=setInterval(()=>{this._lastRequestFollowUser===void 0||this._lastRequestFollowUser.userId&&this.spectator.isFollowedBy(this._lastRequestFollowUser.userId)?(clearInterval(this._enforceFollowInterval),this._enforceFollowInterval=void 0):(Go&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var arA=Object.defineProperty,nrA=Object.getOwnPropertyDescriptor,vI=(t,A,e,i)=>{for(var g=i>1?void 0:i?nrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&arA(A,e,g),g};const tS=tA("debugspriterenderer"),rrA=tA("wireframe"),EF=class{static getOrCreateGeometry(t){if(t.__cached_geometry)return t.__cached_geometry;if(t.guid&&EF.cache[t.guid])return tS&&console.log("Take cached geometry for sprite",t.guid),EF.cache[t.guid];const A=new he;t.__cached_geometry=A;const e=new Float32Array(t.triangles.length*3),i=new Float32Array(t.triangles.length*2);for(let g=0;g<t.triangles.length;g+=1){const I=t.triangles[g];e[g*3]=-t.vertices[I].x,e[g*3+1]=t.vertices[I].y,e[g*3+2]=0;const o=t.uv[I];i[g*2]=o.x,i[g*2+1]=1-o.y}return A.setAttribute("position",new ee(e,3)),A.setAttribute("uv",new ee(i,2)),t.guid&&(this.cache[t.guid]=A),tS&&console.log("Built sprite geometry",t,A),A}};let pp=EF;n(pp,"cache",{});class Fa{constructor(){n(this,"guid"),n(this,"texture"),n(this,"triangles"),n(this,"uv"),n(this,"vertices"),n(this,"__cached_geometry"),n(this,"_mesh"),n(this,"_material")}get mesh(){return this._mesh||(this._mesh=new hA(pp.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=Ee,this.texture.minFilter==qe&&this.texture.magFilter==qe&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new st({map:this.texture,color:16777215,side:Qt,transparent:!0})),this._material}getGeometry(){return pp.getOrCreateGeometry(this)}}vI([w()],Fa.prototype,"guid",2),vI([w(le)],Fa.prototype,"texture",2),vI([dE()],Fa.prototype,"triangles",2),vI([dE()],Fa.prototype,"uv",2),vI([dE()],Fa.prototype,"vertices",2);const hF=Symbol("spriteOwner");class up{constructor(){n(this,"sprites")}}vI([w(Fa)],up.prototype,"sprites",2);class mh{constructor(){n(this,"spriteSheet"),n(this,"index",0)}update(A,e,i){if(!this.spriteSheet)return;const g=this.index;if(g<0||g>=this.spriteSheet.sprites.length)return;const I=this.spriteSheet.sprites[g],o=I?.texture;if(o&&(o.colorSpace=Ee,o.minFilter==qe&&o.magFilter==qe&&(o.anisotropy=1),o.needsUpdate=!0,!I.__hasLoadedProgressive)){I.__hasLoadedProgressive=!0;const s=o;Jt.assignTextureLOD(A,e,o,0).then(C=>{C instanceof le&&(I.texture=C,i?.map===s&&(i.map=C,i.needsUpdate=!0))})}}}vI([w(up)],mh.prototype,"spriteSheet",2),vI([w()],mh.prototype,"index",2);class mC extends FA{constructor(){super(...arguments),n(this,"drawMode",0),n(this,"size",{x:1,y:1}),n(this,"color"),n(this,"sharedMaterial"),n(this,"transparent",!0),n(this,"cutoutThreshold",0),n(this,"castShadows",!1),n(this,"_spriteSheet"),n(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(A){if(A!==this._spriteSheet)if(typeof A=="number"){const e=Math.floor(A);this.spriteIndex=e;return}else this._spriteSheet=A,this.updateSprite()}set spriteIndex(A){this._spriteSheet&&(this._spriteSheet.index=A,this.updateSprite())}get spriteIndex(){var A;return((A=this._spriteSheet)==null?void 0:A.index)??0}get spriteFrames(){var A,e;return((e=(A=this._spriteSheet)==null?void 0:A.spriteSheet)==null?void 0:e.sprites.length)??0}awake(){this._currentSprite=void 0,tS&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var A,e,i;if(!this.__didAwake||!((e=(A=this.sprite)==null?void 0:A.spriteSheet)!=null&&e.sprites))return;const g=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!g){tS&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=pp.getOrCreateGeometry(g),this._currentSprite.material.map=g.texture;else{const I=new st({color:16777215,side:Qt});if(!I)return;if(rrA&&(I.wireframe=!0),this.color&&(I.color||(I.color=new GA),I.color.copy(this.color),I.opacity=this.color.alpha),I.transparent=!0,g.texture&&!I.wireframe){let o=g.texture;o[hF]!==void 0&&o[hF]!==this&&this.spriteFrames>1&&(o=g.texture=o.clone()),o[hF]=this,I.map=o}this.sharedMaterial=I,this._currentSprite=new hA(pp.getOrCreateGeometry(g),I),Jt.assignTextureLOD(this.context,this.sourceId,I,0)}this._currentSprite.parent!==this.gameObject&&(this.drawMode===2&&this._currentSprite.scale.set(this.size.x,this.size.y,1),this.gameObject&&this.gameObject.add(this._currentSprite)),this._currentSprite&&this._currentSprite.layers.set(this.layer),this.sharedMaterial&&(this.sharedMaterial.alphaTest=this.cutoutThreshold,this.sharedMaterial.transparent=this.transparent),this._currentSprite.castShadow=this.castShadows,(i=this._spriteSheet)==null||i.update(this.context,this.sourceId,this.sharedMaterial)}}vI([w()],mC.prototype,"drawMode",2),vI([w(St)],mC.prototype,"color",2),vI([w(Re)],mC.prototype,"sharedMaterial",2),vI([w()],mC.prototype,"transparent",2),vI([w()],mC.prototype,"cutoutThreshold",2),vI([w()],mC.prototype,"castShadows",2),vI([w(mh)],mC.prototype,"sprite",1);class JC{constructor(){n(this,"bb",null),n(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedCameraModel(A,e){return(e||new JC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedCameraModel(A,e){return A.setPosition(A.position()+DU),(e||new JC).__init(A.readInt32(A.position())+A.position(),A)}userId(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}guid(A){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,A):null}dontSave(){const A=this.bb.__offset(this.bb_pos,8);return A?!!this.bb.readInt8(this.bb_pos+A):!1}pos(A){const e=this.bb.__offset(this.bb_pos,10);return e?(A||new DB).__init(this.bb_pos+e,this.bb):null}rot(A){const e=this.bb.__offset(this.bb_pos,12);return e?(A||new DB).__init(this.bb_pos+e,this.bb):null}static startSyncedCameraModel(A){A.startObject(5)}static addUserId(A,e){A.addFieldOffset(0,e,0)}static addGuid(A,e){A.addFieldOffset(1,e,0)}static addDontSave(A,e){A.addFieldInt8(2,+e,0)}static addPos(A,e){A.addFieldStruct(3,e,0)}static addRot(A,e){A.addFieldStruct(4,e,0)}static endSyncedCameraModel(A){return A.endObject()}static finishSyncedCameraModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedCameraModelBuffer(A,e){A.finish(e,void 0,!0)}}var BrA=Object.defineProperty,QrA=Object.getOwnPropertyDescriptor,ErA=(t,A,e,i)=>{for(var g=i>1?void 0:i?QrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BrA(A,e,g),g};const iS="SCAM";SU(iS,JC.getRootAsSyncedCameraModel);const Mo=new Pp;class hrA{constructor(A,e){n(this,"userId"),n(this,"guid"),this.guid=e,this.userId=A}send(A,e){if(A){Mo.clear();const i=Mo.createString(this.guid),g=Mo.createString(this.userId);JC.startSyncedCameraModel(Mo),JC.addGuid(Mo,i),JC.addUserId(Mo,g);const I=Fe(A),o=Zc(A);JC.addPos(Mo,DB.createVec3(Mo,I.x,I.y,I.z)),JC.addRot(Mo,DB.createVec3(Mo,o.x,o.y,o.z));const s=JC.endSyncedCameraModel(Mo);Mo.finish(s,iS),e.sendBinary(Mo.asUint8Array())}}}var cF;const lF=(cF=class extends FA{constructor(){super(...arguments),n(this,"cameraPrefab",null),n(this,"_lastWorldPosition"),n(this,"_lastWorldQuaternion"),n(this,"_model",null),n(this,"_needsUpdate",!0),n(this,"_lastUpdateTime",0),n(this,"remoteCams",{}),n(this,"userToCamMap",{}),n(this,"_camTimeoutInSeconds",10),n(this,"_receiveCallback",null)}getCameraObject(t){const A=this.userToCamMap[t];return A?this.remoteCams[A].obj:null}async awake(){this._lastWorldPosition=this.worldPosition.clone(),this._lastWorldQuaternion=this.worldQuaternion.clone(),this.cameraPrefab&&("uri"in this.cameraPrefab&&(this.cameraPrefab=await this.cameraPrefab.instantiate(this.gameObject)),this.cameraPrefab&&"isObject3D"in this.cameraPrefab&&(this.cameraPrefab.visible=!1))}onEnable(){this._receiveCallback=this.context.connection.beginListenBinary(iS,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(iS,this._receiveCallback)}update(){for(const i in this.remoteCams){const g=this.remoteCams[i],I=this.context.time.realtimeSinceStartup-g.lastUpdate;if(!g||I>this._camTimeoutInSeconds){re()&&console.log("Remote cam timeout",i),g!=null&&g.obj&&CA.destroy(g.obj),delete this.remoteCams[i],g&&delete this.userToCamMap[g.userId],lF.instances.push(g),this.context.players.removePlayerView(g.userId,Un.Browser);continue}}if(this.context.isInXR)return;const t=this.context.mainCamera;if(t===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new hrA(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const A=Fe(t),e=Gt(t);(A.distanceTo(this._lastWorldPosition)>.001||e.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(A),this._lastWorldQuaternion.copy(e),!((!this._needsUpdate||this.context.time.frameCount%2!==0)&&!(this.context.time.realtimeSinceStartup-this._lastUpdateTime>this._camTimeoutInSeconds*.5))&&(this._lastUpdateTime=this.context.time.realtimeSinceStartup,this._needsUpdate=!1,this._model.send(t,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,t,Un.Browser))}onReceivedRemoteCameraInfoBin(t){const A=t.guid();if(!A)return;const e=t.userId();if(!e||!this.context.connection.userIsInRoom(e)||!this.cameraPrefab)return;let i=this.remoteCams[A];if(!i)if("isObject3D"in this.cameraPrefab){const s=new Ys;s.context=this.context;const C=CA.instantiate(this.cameraPrefab,s);i=this.remoteCams[A]={obj:C,lastUpdate:this.context.time.realtimeSinceStartup,userId:e},i.obj.visible=!0,this.gameObject.add(C),this.userToCamMap[e]=A,lF.instances.push(i);const a=CA.getOrAddComponent(C,xg);a.connectionId=e,a.avatar=C}else return;const g=i.obj;this.context.players.setPlayerView(e,g,Un.Browser),i.lastUpdate=this.context.time.realtimeSinceStartup,ns.markDirty(g);const I=t.pos();I&&Zr(g,I.x(),I.y(),I.z());const o=t.rot();o&&Vc(g,o.x(),o.y(),o.z())}},n(cF,"instances",[]),cF);let gS=lF;ErA([w([uA,tt])],gS.prototype,"cameraPrefab",2);var crA=Object.defineProperty,lrA=Object.getOwnPropertyDescriptor,kh=(t,A,e,i)=>{for(var g=i>1?void 0:i?lrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&crA(A,e,g),g};const dF="view",pF=tA("debugsyncedroom");class Ka extends FA{constructor(){super(...arguments),n(this,"roomName"),n(this,"urlParameterName","room"),n(this,"joinRandomRoom",!0),n(this,"requireRoomParameter",!1),n(this,"autoRejoin",!0),n(this,"createJoinButton",!0),n(this,"_roomPrefix"),n(this,"_lastJoinedRoom",""),n(this,"_lastPingTime",0),n(this,"_lastRoomTime",-1),n(this,"_userWantsToBeInARoom",!1),n(this,"_roomButton"),n(this,"_roomButtonIconJoin"),n(this,"_roomButtonIconLeave"),n(this,"updateRoomButtonState",()=>{var A,e;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(A=this._roomButtonIconJoin)==null||A.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(e=this._roomButtonIconLeave)==null||e.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){pF&&console.log("Room",this.roomName,this.urlParameterName,this.joinRandomRoom,this.requireRoomParameter,this.autoRejoin),this._roomPrefix===void 0&&(this._roomPrefix=this.roomName,this.roomName="")}onEnable(){const A=tA(dF);if(A&&typeof A=="string"&&A.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(A,!0);return}if((this.joinRandomRoom||tA(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const e=this.createRoomButton();this.context.menu.appendChild(e)}}onDisable(){var A;(A=this._roomButton)==null||A.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(A=0){A===void 0&&(A=0);let e=!1;if(this.urlParameterName){const i=tA(this.urlParameterName);if(i&&typeof i=="string"||i==="number"){e=!0;const g=Qq(i);this.roomName=g}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),A<1))return this.tryJoinRoom(A+1)}else this.joinRandomRoom&&(this.roomName===null||this.roomName===void 0||this.roomName.length<=0)&&(console.log("generate room name"),this.roomName=this.generateRoomName());return this.requireRoomParameter&&!e?(pF&&console.log('No required room parameter "'+this.urlParameterName+'" in url - will not connect to networking backend.'),!1):(this.context.connection.isConnected||this.context.connection.connect(),pF&&console.log("Join "+this.roomName),this._lastJoinedRoom=this.roomName,this._roomPrefix&&(this.roomName=this._roomPrefix+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0)}update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):re()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}get currentRoomName(){return tA(dF)||tA(this.urlParameterName)}setRandomRoomUrlParameter(){const A=xc(),e=this.generateRoomName();tA(this.urlParameterName)?A.set(this.urlParameterName,e):A.append(this.urlParameterName,e),Hk(e,A)}generateRoomName(){return Tk()+"_"+Math.floor(Ae.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const A=window.location.search,e=new URLSearchParams(A);return e.has(this.urlParameterName)&&e.delete(this.urlParameterName),e.set(dF,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+e.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const A=document.createElement("button");return this._roomButton=A,A.classList.add("create-room-button"),A.setAttribute("priority","90"),A.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&LD(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(tA(this.urlParameterName)||(this._lastJoinedRoom?LD(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=ro("group"),this._roomButtonIconLeave=ro("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(At.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(At.LeftRoom,this.updateRoomButtonState),A}destroyRoomButton(){this.context.connection.stopListen(At.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(At.LeftRoom,this.updateRoomButtonState)}}kh([w()],Ka.prototype,"roomName",2),kh([w()],Ka.prototype,"urlParameterName",2),kh([w()],Ka.prototype,"joinRandomRoom",2),kh([w()],Ka.prototype,"requireRoomParameter",2),kh([w()],Ka.prototype,"autoRejoin",2),kh([w()],Ka.prototype,"createJoinButton",2);class IS extends FA{}function drA(){const t=tA("testwindowcount")||0;t&&t>0&&prA(t)}function prA(t){if(tA("testwindow"))return null;const A=new URL(window.location.href);_k(A.searchParams,lIA,1),_k(A.searchParams,"testwindow",1);const e=A.toString(),i=[];window.onbeforeunload=()=>{for(const C of i)C.close()};const g=.05,I=128;let o=0,s=0;for(let C=0;C<t;C++){o*I+I*.01>=window.innerWidth&&(s+=1,o=0);const a=o*(I*(1+g))+window.screenLeft,r=s*(I*(1+g))+window.screenTop+90+60*s;o+=1;const B=window.open(e,"test window "+C,`popup=yes width=${I} height=${I} top=${r} left=${a}`);if(!B){console.warn("Failed to open window");continue}i.push(B),B.onload=()=>{B.onbeforeunload=()=>{for(let Q=0;Q<i.length;Q++){const E=i[Q];E!==B&&E.close()}i.length=0}}}return i}class uF extends FA{awake(){drA()}}class DF extends FA{constructor(){super(...arguments),n(this,"transformsPerFrame",10),n(this,"interval",0),n(this,"useFlatbuffers",!0),n(this,"builder",null),n(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Xl,A=>{});else{this.models=[];for(let A=0;A<this.transformsPerFrame;A++)this.models.push(new y1(this.context.connection.connectionId+"_simulatedTransform_"+A,this))}}update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new Pp(1024));const A=this.builder;for(let e=0;e<this.transformsPerFrame;e++){A.clear();const i=PT(this.context.connection.connectionId,this);this.context.connection.sendBinary(i)}}else if(this.models)for(let A=0;A<this.models.length;A++){const e=this.models[A];e.dontSave=!0,e.update(this,null),this.context.connection.send("TestSimulateUserData-"+A,e)}}}}class y1{constructor(A,e){n(this,"guid"),n(this,"fast",!1),n(this,"position"),n(this,"rotation"),n(this,"velocity"),n(this,"dontSave"),this.guid=A,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(e,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(A,e){const i=A.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const g=A.worldQuaternion;if(this.rotation.x=g.x,this.rotation.y=g.y,this.rotation.z=g.z,this.rotation.w=g.w,this.fast=!1,e){const I=e.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=I.x,this.velocity.y=I.y,this.velocity.z=I.z}}}n(y1,"temp",new S);var urA=Object.defineProperty,DrA=Object.getOwnPropertyDescriptor,Gh=(t,A,e,i)=>{for(var g=i>1?void 0:i?DrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&urA(A,e,g),g};class kC extends aI{constructor(){super(...arguments),n(this,"offset"),n(this,"rotation"),n(this,"focusArea"),n(this,"feather"),n(this,"kernelSize"),n(this,"resolutionScale")}get typeName(){return"TiltShiftEffect"}init(){this.offset.defaultValue=0,this.rotation.defaultValue=0,this.focusArea.defaultValue=.4,this.feather.defaultValue=.3,this.kernelSize.defaultValue=sa.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const A=new weA({kernelSize:sa.VERY_LARGE});return this.offset.onValueChanged=e=>A.offset=e,this.rotation.onValueChanged=e=>A.rotation=e,this.focusArea.onValueChanged=e=>A.focusArea=e,this.feather.onValueChanged=e=>A.feather=e,this.kernelSize.onValueChanged=e=>A.blurPass.kernelSize=e,this.resolutionScale.onValueChanged=e=>A.resolution.scale=e/window.devicePixelRatio,A}}Gh([w(Ne)],kC.prototype,"offset",2),Gh([w(Ne)],kC.prototype,"rotation",2),Gh([w(Ne)],kC.prototype,"focusArea",2),Gh([w(Ne)],kC.prototype,"feather",2),Gh([w(Ne)],kC.prototype,"kernelSize",2),Gh([w(Ne)],kC.prototype,"resolutionScale",2),As("TiltShiftEffect",kC);var wrA=Object.defineProperty,yrA=Object.getOwnPropertyDescriptor,SrA=(t,A,e,i)=>{for(var g=i>1?void 0:i?yrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&wrA(A,e,g),g};class Dp extends aI{constructor(){super(...arguments),n(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new Ne(_I)),this.mode.defaultValue=_I}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(A){this.context.renderer.toneMapping=this.getThreeToneMapping(A)}getThreeToneMapping(A){switch(A){case 0:return cQ;case 1:return su;case 2:return ou;default:return cQ}}}SrA([w(Ne)],Dp.prototype,"mode",2),As("Tonemapping",Dp);var frA=Object.defineProperty,mrA=Object.getOwnPropertyDescriptor,oS=(t,A,e,i)=>{for(var g=i>1?void 0:i?mrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&frA(A,e,g),g};class eQ extends FA{constructor(){super(...arguments),n(this,"isGizmo",!1),n(this,"translationSnap",1),n(this,"rotationSnapAngle",15),n(this,"scaleSnap",.25),n(this,"control"),n(this,"orbit"),n(this,"onControlChangedEvent",A=>{const e=this.orbit;if(e&&(e.enabled=!A.value),A.value){const i=CA.getComponentInParent(this.gameObject,vn);i&&i.requestOwnership()}}),n(this,"windowKeyDownListener",A=>{if(this.enabled&&this.control)switch(A.keyCode){case 81:this.control.setSpace(this.control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this.control.setMode("translate");break;case 69:this.control.setMode("rotate");break;case 82:this.control.setMode("scale");break;case 187:case 107:this.control.setSize(this.control.size+.1);break;case 189:case 109:this.control.setSize(Math.max(this.control.size-.1,.1));break;case 88:this.control.showX=!this.control.showX;break;case 89:this.control.showY=!this.control.showY;break;case 90:this.control.showZ=!this.control.showZ;break;case 32:this.control.enabled=!this.control.enabled;break}}),n(this,"windowKeyUpListener",A=>{if(this.enabled)switch(A.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var A;this.isGizmo&&!fl||this.context.mainCamera&&(this.control||(this.control=new V7(this.context.mainCamera,this.context.renderer.domElement),this.control.visible=!0,this.control.enabled=!0,this.control.getRaycaster().layers.set(2),this.control.size=1,this.control.traverse(e=>{const i=e;if(i.layers.set(2),i){const g=i.material;g&&(g.opacity=.3)}}),this.orbit=CA.getComponentInParent(this.context.mainCamera,ft)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(A=this.control)==null||A.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var A,e;(A=this.control)==null||A.removeFromParent(),(e=this.control)==null||e.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this.control&&(this.control.setTranslationSnap(this.translationSnap),this.control.setRotationSnap(zi.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}oS([w()],eQ.prototype,"isGizmo",2),oS([w()],eQ.prototype,"translationSnap",2),oS([w()],eQ.prototype,"rotationSnapAngle",2),oS([w()],eQ.prototype,"scaleSnap",2);var krA=Object.defineProperty,GrA=Object.getOwnPropertyDescriptor,wF=(t,A,e,i)=>{for(var g=i>1?void 0:i?GrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&krA(A,e,g),g};class tQ extends aI{constructor(){super(...arguments),n(this,"color"),n(this,"intensity"),n(this,"center")}get typeName(){return"Vignette"}init(){this.color.defaultValue={r:0,g:0,b:0,a:1},this.intensity.defaultValue=0,this.center.defaultValue={x:.5,y:.5}}onCreateEffect(){const A=new HY;return this.intensity.onValueChanged=e=>{A.offset=e,this.updateDarkness(A)},this.color.onValueChanged=e=>{this.updateDarkness(A)},A}updateDarkness(A){const e=this.intensity.value;A.darkness=e}}wF([w(Ne)],tQ.prototype,"color",2),wF([w(Ne)],tQ.prototype,"intensity",2),wF([w(Ne)],tQ.prototype,"center",2),As("Vignette",tQ);var MrA=Object.defineProperty,UrA=Object.getOwnPropertyDescriptor,RrA=(t,A,e,i)=>{for(var g=i>1?void 0:i?UrA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MrA(A,e,g),g};const sS=tA("debugarcamera");class CS extends FA{constructor(){super(...arguments),n(this,"backgroundTint",new St(1,1,1,1)),n(this,"backgroundPlane"),n(this,"threeTexture"),n(this,"forceTextureInitialization",function(){const A=new st,e=new Zi,i=new eI;i.add(new hA(e,A));const g=new xe;return function(I,o){A.map=o,I.render(i,g),sS&&console.warn("Force texture initialization")}}()),n(this,"preRender",()=>{if(!this||!this.gameObject)return;const A=this.context.renderer.xr.getFrame();A&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new le,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=FrA(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(A))})}onBeforeXR(A,e){e.optionalFeatures=e.optionalFeatures||[],e.optionalFeatures.push("camera-access"),sS&&console.warn("Requesting camera-access")}onEnterXR(A){this.backgroundPlane&&(this.context.scene.add(this.backgroundPlane),this.backgroundPlane.visible=!1),this.backgroundPlane&&this.context.scene.add(this.backgroundPlane),this.context.pre_render_callbacks.push(this.preRender)}onLeaveXR(A){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const e=this.context.pre_render_callbacks.indexOf(this.preRender);e>=0&&this.context.pre_render_callbacks.splice(e,1)}get background(){return this.backgroundPlane}onBeforeRender(A){this.updateFromFrame(A)}updateFromFrame(A){if(!A)return;const e=A.session.enabledFeatures;if(e&&!e.some(g=>g==="camera-access")){this.background&&(this.background.visible=!1);return}const i=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(i){for(const g of i.views)if("camera"in g&&g.camera){let I=this.context.renderer.xr.getBinding();if(I||(I=new XRWebGLBinding(A.session,this.context.renderer.getContext())),I){let o=null;if("getCameraImage"in I){o=I.getCameraImage(g.camera);const s=this.context.renderer.properties.get(this.threeTexture);s.__webglTexture=o,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):sS&&console.warn("No background plane to set texture on")}}}}}}RrA([w(St)],CS.prototype,"backgroundTint",2);const NrA=`
|
|
7019
7019
|
uniform sampler2D t2D;
|
|
7020
7020
|
|
|
7021
7021
|
varying vec2 vUv;
|