@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
|
}`),h(ua,"blipMaterial"),h(ua,"mesh");function HO(i){return ua.copyTexture(i)}function vY(i,e=!1){return ua.textureToCanvas(i,e)}function AY(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap}let Ab=!1;dW((...i)=>{var e;ut()&&(e=ni.Current)!=null&&e.isInXR&&(kp(!0),VO("error",...i))});function kp(i){if(i){if(Ab)return;Ab=!0,bY()}else{if(!Ab)return;Ab=!1,_Y()}}const vg={log:void 0,warn:void 0,error:void 0};class yY{constructor(){h(this,"familyName","needle-xr"),h(this,"root",null),h(this,"context",null),h(this,"defaultFontSize",.06),h(this,"targetObject",new ge),h(this,"userForwardViewPoint",new S),h(this,"oneEuroFilter",new _E(90,.8)),h(this,"_lastElementRemoveTime",0),h(this,"onBeforeRender",()=>{var e,t;const n=(e=this.context)==null?void 0:e.mainCamera;if(this.context&&n instanceof Ut){const r=this.getRoot();Number.isNaN(r.position.x)&&r.position.set(0,0,0),Number.isNaN(r.quaternion.x)&&r.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const s=((t=this.context.xr)==null?void 0:t.rigScale)??1,o=3.5*s,a=n.worldForward;a.y=0,a.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(n.worldPosition).sub(a),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*s&&(this.targetObject.position.copy(this.userForwardViewPoint),pg(this.targetObject,n,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,r.position,this.context.time.time);const l=this.context.time.deltaTime;if(r.quaternion.slerp(this.targetObject.quaternion,l*5),r.scale.setScalar(s),this.targetObject.removeFromParent(),this.context.scene.add(r),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const c=Date.now();for(let u=0;u<this._activeTexts.length;u++){const d=this._activeTexts[u];if(d instanceof Mi.Text&&c-d._activatedTime>2e4){d.removeFromParent(),this._textBuffer.push(d),this._activeTexts.splice(u,1);break}}}}}),h(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025}),h(this,"_textBuffer",[]),h(this,"_activeTexts",[]),this.ensureFont()}onEnable(){this.context=ni.Current||ni.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var e,t,n;(t=this.context)==null||t.pre_render_callbacks.splice((e=this.context)==null?void 0:e.pre_render_callbacks.indexOf(this.onBeforeRender),1),(n=this.root)==null||n.removeFromParent()}addLog(e,t){const n=this.getRoot(),r=this.getText();let s=16777215,o=0;switch(e){case"log":s=16777215,o=0;break;case"warn":s=16772761,o=4465152;break;case"error":s=16755370,o=7798784;break}t.length>1e3&&(t=t.substring(0,1e3)+"...");const a=new Date().toISOString().split("T")[1].split(".")[0];r.textContent="["+a+"] "+t,r.visible=!0,r._activatedTime=Date.now(),n.add(r),this._activeTexts.push(r),this.context&&this.context.scene.add(n),r.set({backgroundColor:s,color:o}),Mi.update()}ensureFont(){let e=Mi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Mi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t?.addEventListener("ready",()=>{Mi.update()})}}getText(){const e=this.getRoot();if(this._textBuffer.length>0){const n=this._textBuffer.pop();return n.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(n),100),n}if(e.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const t=new Mi.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(t),500),setTimeout(()=>this.disableDepthTestRecursive(t),1500),t}disableDepthTestRecursive(e,t=0){for(let r=0;r<e.children.length;r++){const s=e.children[r];s instanceof ge&&this.disableDepthTestRecursive(s,t+1)}e.renderOrder=10*t,e.layers.set(2);const n=e.material;n&&(n.depthWrite=!1,n.depthTest=!1,n.transparent=!0),t===0&&Mi.update()}getRoot(){if(this.root)return this.root;const e=this.defaultFontSize,t={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:e,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Mi.Block(t),this.root}}let da=null;function bY(){da||(da=new yY),da.onEnable();for(const i in vg){vg[i]=console[i];let e=!1;console[i]=function(){var t;if((t=vg[i])==null||t.apply(console,arguments),!e)try{e=!0,VO(i,...arguments)}finally{e=!1}}}}function _Y(){da?.onDisable();for(const i in vg)console[i]=vg[i]}const Ag=new Map;function VO(i,...e){try{switch(Ag.clear(),i){case"log":da?.addLog("log",t());break;case"warn":da?.addLog("warn",t());break;case"error":da?.addLog("error",t());break}}catch(s){console.error("Error in spatial console",s)}finally{Ag.clear()}function t(){let s="";for(let o=0;o<e.length;o++){const a=e[o];s+=n(a),o<e.length-1&&(s+=", ")}return s}function n(s,o=0){if(typeof s=="string")return'"'+s+'"';if(typeof s=="number"){if(s%1!==0){const a=s.toFixed(5),l=a.indexOf(".");let c=a.length-1;for(;c>l&&a[c]==="0";)c--;return a.substring(0,c+1)}return s.toString()}else if(Array.isArray(s)){let a="[";for(let l=0;l<s.length;l++){const c=s[l];a+=n(c,o+1),l<s.length-1&&(a+=", ")}return a+="]",a}else{if(s===null)return"null";if(s===void 0)return"undefined";if(typeof s=="function")return s.name+"()"}if(s instanceof $)return`(${n(s.x)}, ${n(s.y)})`;if(s instanceof S)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)})`;if(s instanceof Ye)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)}, ${n(s.w)})`;if(s instanceof Me)return`(${n(s.x)}, ${n(s.y)}, ${n(s.z)}, ${n(s.w)})`;if(s instanceof It||s instanceof gt)return s.name;if(s instanceof Dt)return`[${s.elements.join(", ")}]`;if(s instanceof Ce)return`[${s.elements.join(", ")}]`;if(s instanceof jr)return s.mask.toString();if(typeof s=="object"){if(Ag.has(s))return"*";let a=`{
|
|
4341
4341
|
`;a+=r(o);const l=Object.keys(s);let c="";for(let u=0;u<l.length;u++){const d=l[u],p=s[d];if(Ag.has(p)){c+="";continue}Ag.set(p,!0),c+=d+":"+n(p,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=r(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
|
-
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const xY=ee("nodevlogs");function Hi(i,e=Zs.Log){Na(e,i)}function $i(i){Hi(i,Zs.Warn)}function IE(i){Hi(i,Zs.Error)}let RE;function ut(){return xY?!1:RE!==void 0?RE:Hs()}function wY(i){RE=i}const WO=ee("debugdefines");Op('if(!globalThis[""3.37.
|
|
4343
|
+
}`,a}return s}function r(s){let o="";for(let a=0;a<s;a++)o+=" ";return o}}const xY=ee("nodevlogs");function Hi(i,e=Zs.Log){Na(e,i)}function $i(i){Hi(i,Zs.Warn)}function IE(i){Hi(i,Zs.Error)}let RE;function ut(){return xY?!1:RE!==void 0?RE:Hs()}function wY(i){RE=i}const WO=ee("debugdefines");Op('if(!globalThis[""3.37.6-alpha""]) globalThis[""3.37.6-alpha""] = "0.0.0";'),Op('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Op('if(!globalThis[""Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)""]) globalThis[""Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)""] = "unknown";'),Op('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.6-alpha";'),Op('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Op('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)";');const jl="3.37.6-alpha",yb="undefined",PE="Wed Apr 24 2024 17:26:48 GMT+0200 (Central European Summer Time)";WO&&console.log(`Engine version: ${jl} (generator: ${yb})
|
|
4344
4344
|
Project built at ${PE}`);const Gl="needle_isActiveInHierarchy",Ru="builtin_components",yg="needle_editor_guid";function Op(i){try{(0,eval)(i)}catch(e){WO&&console.error(e)}}const SY='<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>',CY=btoa(SY),EY="data:image/svg+xml;base64,"+CY,MY=EY,TY=`<?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(TY);const IY='<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>',RY=btoa(IY),PY="data:image/svg+xml;charset=utf-8;base64,"+RY,BY=PY,Do=ee("debuglicense");let Pu="basic";Do&&console.log("License Type: "+Pu);function pa(){switch(Pu){case"pro":case"enterprise":return!0}return!1}function BE(){switch(Pu){case"indie":return!0}return!1}function Lp(){return pa()||BE()}const qO=[];function DY(i){if(pa()||BE())return i(!0);qO.push(i)}function kY(i){for(const e of qO)try{e(i)}catch{}}ni.registerCallback(pn.ContextRegistered,i=>{UY(i.context),NY(),LY(i.context)});let Bu,DE=!1,bb="";async function OY(){if(Bu)return Bu;if(Pu==="basic")try{const i="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+jl+"&generator="+encodeURIComponent(yb),e=await fetch(i,{method:"GET"}).catch(t=>{Do&&console.error("License check failed",t)});e?.status===200?(DE=!1,Do&&console.log("License check succeeded"),Pu="pro",kY(!0)):e?.status===403?(DE=!0,bb=await e.text()):Do&&console.log("License check failed with status "+e?.status)}catch(i){Do&&console.error("License check failed",i)}else Do&&console.log('Runtime license check is skipped because license is already applied as "'+Pu+'"')}Bu=OY();async function LY(i){function e(){const r=document.createElement("div");r.className="needle-forbidden",r.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5506,8 +5506,8 @@ Could not find method ${u.method} on object ${p.name}. Please rename ${u.method}
|
|
|
5506
5506
|
Could not find method ${u.method} on object ${p.name}`,p,typeof p[u.method])};if(typeof p[u.method]!="function"){let y=!1,b=p;for(;b;){const _=Object.getOwnPropertyDescriptor(b,u.method);if(_&&(_.writable===!0||_.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(ut()||Ar)&&g()}}let m=u.argument;m!==void 0?m=d(m):u.arguments!==void 0&&(m=u.arguments.map(d));const A=f?this.createEventMethod(p,u.method,m):void 0,v=new mf(A,u.enabled);if(v.method||(v[Bie]=(o=t.object)==null?void 0:o.name),!p||!v.method){const g=t.object?"Current object: "+t.object.name+", "+t.object.guid:null;p?console.warn('EventList method not found: "'+u.method+'" on',p):console.warn("EventList is missing target - will be ignored",u.target,g,e)}else a.push(v)}const l=new Hn(a);Ar&&console.log(l);const c=t.target;return c!==void 0&&t.path!==void 0&&l.setEventTarget(t.path,c),l}}createEventMethod(e,t,n){return(...r)=>{const s=e[t];typeof s=="function"?n!==void 0?Array.isArray(n)?s?.call(e,...n):s?.call(e,n):s?.call(e,...r):e[t]=n}}}const kie=new Die;class n4 extends Ha{constructor(){super([pf,Ht])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof gt&&t.type===pf){const n=e,r=new pf(n.image.width,n.image.height,{colorSpace:di});return r.texture=n,n.isRenderTargetTexture=!0,n.flipY=!0,n.offset.y=1,n.repeat.y=-1,n.needsUpdate=!0,n.mipmaps=[],n instanceof Oa&&(n.isCompressedTexture=!1,n.format=RGBAFormat),r}}}new n4;class r4 extends Ha{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return Fl(t.gltfId,e)}}new r4;var Oie=Object.defineProperty,Lie=Object.getOwnPropertyDescriptor,Uie=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Oie(e,t,r),r};class _v extends Ie{awake(){Go.createIfNoneExists(this.context)}onEnable(){var e;(e=Go.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Go.get(this.context))==null||e.unregister(this)}}class no extends _v{constructor(){super(...arguments),h(this,"targets",null),h(this,"raycastHits",[]),h(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new No),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=r=>r instanceof Xs?"continue in children":t?t(r):!0);const n=this.context.physics.raycast(e);return e.testObject=t,n}}Uie([x()],no.prototype,"ignoreSkinnedMeshes",2);class Q_ extends no{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class xv extends _v{performRaycast(e){if(!_t.active||!(e!=null&&e.ray))return null;const t=e.ray.origin,n=.01;return this.context.physics.sphereOverlap(t,n)}}class H_{static getObject(e){const t=e[jo];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const n=this.tryFindCanvasGroup(e);if(n?.isCanvasGroup===!0&&(t&&(t.canvasGroup=n),n.blocksRaycasts===!1||n.interactable===!1))return!1;const r=Xu(e,s=>{if(s.isGraphic===!0)return s},!1);return t&&r?.isGraphic===!0&&(t.graphic=r),!(r?.raycastTarget===!1||r?.layer===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=Xu(e,n=>{const r=n;if(r.blocksRaycasts!==void 0&&r.interactable!==void 0)return r},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function tI(i){return i[jo]||(i.parent?tI(i.parent):null)}function Fie(i){return i.isUI===!0||typeof i[jo]=="object"}function V_(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const n=i.parent;n&&n.isText,t.side=e.doubleSided??!0?li:lr,t.shadowSide=e.doubleSided?li:lr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const n of i.children)V_(n,e)}function gf(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const n=Proxy.revocable(i[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),r=n.revoke,s=i[e];return n.revoke=()=>{i[e]=s,r()},i[e]=n.proxy,n}const s4=Symbol("Scheduled action");function Nie(i,e,t=Fi.OnBeforeRender){let n=i[s4];n||(n=i[s4]={});const r=e.name;n[t]||(n[t]={});const s=n[t];if(s[r])return;function*o(){e?.call(i),s[r]=null}const a=i.startCoroutine(o(),t);s[r]=a}const tc=ee("debugeventsystem");var iI=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(iI||{});const ic=class extends Ie{constructor(){super(),h(this,"raycaster",[]),h(this,"_handleInputFn"),h(this,"pressedByID",new Map),h(this,"hoveredByID",new Map),h(this,"_sortedHits",[]),h(this,"_testObjectsCache",new Map),h(this,"_currentlyActiveRaycaster",null),h(this,"_currentPointerEventName",null),h(this,"shouldRaycastObject",i=>{var e;let t=null;if(Fie(i)&&(t=(e=i[jo])==null?void 0:e.gameObject),this._testObjectsCache.has(i)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(i)===!1?"continue in children":!0;{let n=eI(i,this._currentPointerEventName);if(!n&&t&&(n=eI(t,this._currentPointerEventName)),n){this._testObjectsCache.set(i,!0);for(const r of i.children)this.shouldRaycastObject_AddToYesCache(r);return!0}return this._testObjectsCache.set(i,!1),"continue in children"}}),h(this,"_sortingBuffer",[]),h(this,"_noDepthTestingResults",[]),h(this,"out",{}),h(this,"_capturedPointer",{}),h(this,"pointerEnterSymbol",Symbol("pointerEnter")),h(this,"pointerExitSymbol",Symbol("pointerExit")),h(this,"currentActiveMeshUIComponents",[]),ic.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,ic.systems.length<=0&&ic.systems.push(...re.findObjectsOfType(ic,i)));for(const t of ic.systems)if(t.context===i)return;const e=new ge;re.addNewComponent(e,ic),i.scene.add(e)}static get systems(){const i=Ot.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e,t=!1){Ah.update(i,e,t)}static markUIDirty(i){Ah.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){ic.systems.splice(ic.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!re.findObjectOfType(_v,this.context)){const i=re.addNewComponent(this.context.scene,no);this.raycaster.push(i),(ut()||tc)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const n=(e=this.raycaster)==null?void 0:e.indexOf(i);n!==void 0&&n!==-1&&((t=this.raycaster)==null||t.splice(n,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(qi.PointerDown,this._handleInputFn),this.context.input.addEventListener(qi.PointerUp,this._handleInputFn),this.context.input.addEventListener(qi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(qi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(qi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(qi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(i){if(i===void 0||i.propagationStopped)return;const e=new dm(this.context.input,i);this._currentPointerEventName=i.type,e.inputSource=this.context.input,e.isClick=i.isClick,e.isDoubleClick=i.isDoubleClick,e.isDown=i.type==qi.PointerDown,e.isUp=i.type==qi.PointerUp,e.isPressed=this.context.input.getPointerPressed(i.pointerId),tc&&(e.isDown?console.log("DOWN",e.pointerId):e.isUp&&console.log("UP",e.pointerId),e.isClick&&console.log("CLICK",e.pointerId));const t=new No;i.hasRay?t.ray=i.ray:t.screenPoint=this.context.input.getPointerPositionRC(i.pointerId);const n=this.performRaycast(t);if(n)for(const s of n)s.event=i,i.intersections.push(s);tc&&e.isClick&&Hi("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown);const r={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(n,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}shouldRaycastObject_AddToYesCache(i){this._testObjectsCache.set(i,!0);for(const e of i.children)this.shouldRaycastObject_AddToYesCache(e)}performRaycast(i){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,i||(i=new No),i.testObject=this.shouldRaycastObject;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;this._currentlyActiveRaycaster=e;const t=e.performRaycast(i);this._currentlyActiveRaycaster=null,t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}assignHitInformation(i,e){e?(i.intersection=e,i.point=e.point,i.normal=e.normal,i.face=e.face,i.distance=e.distance,i.instanceId=e.instanceId):(i.intersection=void 0,i.point=void 0,i.normal=void 0,i.face=void 0,i.distance=void 0,i.instanceId=void 0)}handleIntersections(i,e){var t;if(i!=null&&i.length){i=this.sortCandidates(i);for(const r of i){if(e.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(e,r),this.handleEventOnObject(r.object,e))return!0}}this.assignHitInformation(e,i?.[0]),this.invokePointerCapture(e);const n=this.hoveredByID.get(e.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(e.pointerId),e.isUp&&((t=this.pressedByID.get(e.pointerId))==null||t.handlers.forEach(r=>this.invokeOnPointerUp(e,r)),this.pressedByID.delete(e.pointerId)),!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],n=t.object;if(n.material&&n.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventOnObject(i,e){if(!this.testIsVisible(i))return e.isClick&&tc&&console.log("not allowed",i),!1;if(e.pointerId===void 0)return tc&&console.error("Event without pointer can't be handled",e),!1;e.object=i;const t=i.parent,n=e.isClick??!1;let r=null;if(t&&t.isUI){const l=(e.isPressed||e.isClick)??!1;if(t[jo]){const c=t[jo].gameObject;if(c){if(!H_.isInteractable(c,this.out))return!1;r=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,l),i=c}}}n&&tc&&console.log(this.context.time.frame,i);const s=this.hoveredByID.get(e.pointerId),o=s?.obj;o!==i&&o&&this.propagatePointerExit(o,s.data,i);const a=this.hoveredByID.get(e.pointerId);if(a?(a.obj=i,a.data=e):this.hoveredByID.set(e.pointerId,{obj:i,data:e}),e.isDown){const l=this.pressedByID.get(e.pointerId);l?(l.obj=i,l.data=e):this.pressedByID.set(e.pointerId,{obj:i,data:e,handlers:new Set})}return(r===null||r.interactable)&&this.handleMainInteraction(i,e,o??null),!0}propagate(i,e){for(;i;)re.foreachComponent(i,t=>{e(t)},!1),i=i.parent}handleMainInteraction(i,e,t){const n=this.pressedByID.get(e.pointerId),r=t!==i;let s=!0;switch(e.event.pointerType){case"mouse":case"touch":const o=this.context.input.getPointerPositionLastFrame(e.pointerId),a=this.context.input.getPointerPosition(e.pointerId);s=o&&!Ze.approximately(o,a);break}this.propagate(i,o=>{var a;const l=o;l.interactable!==!1&&(!l.activeAndEnabled||!l.enabled||(l.onPointerEnter&&r&&this.handlePointerEnter(l,e),e.isDown&&l.onPointerDown&&(l.onPointerDown(e),n?.handlers.add(l),this.handlePointerCapture(e,l)),l.onPointerMove&&(s&&l.onPointerMove(e),this.handlePointerCapture(e,l)),e.isUp&&(l.onPointerUp&&(this.invokeOnPointerUp(e,l),n?.handlers.delete(l)),l.onPointerExit&&((a=e.event)==null?void 0:a.pointerType)===n_.Touch&&(this.handlePointerExit(l,e),this.hoveredByID.delete(e.pointerId))),e.isClick&&l.onPointerClick&&l.onPointerClick(e)))}),e.isUp&&(n?.handlers.forEach(o=>{this.invokeOnPointerUp(e,o)}),this.pressedByID.delete(e.pointerId))}propagatePointerExit(i,e,t){this.propagate(i,n=>{if(!n.gameObject||n.destroyed)return;const r=n;if(r.onPointerExit){if(t&&this.isChild(t,n.gameObject))return;this.handlePointerExit(r,e)}})}invokeOnPointerUp(i,e){var t;(t=e.onPointerUp)==null||t.call(e,i),this.releasePointerCapture(i,e)}handlePointerEnter(i,e){i.onPointerEnter&&this.updatePointerState(i,e.pointerId,this.pointerEnterSymbol,!0)&&i.onPointerEnter(e),this.updatePointerState(i,e.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(i,e){i.onPointerExit&&this.updatePointerState(i,e.pointerId,this.pointerExitSymbol,!0)&&i.onPointerExit(e),this.updatePointerState(i,e.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(i,e,t,n){let r=i[t];if(n)return r&&r.includes(e)?!1:(r=r||[],r.push(e),i[t]=r,!0);{if(!r||!r.includes(e))return!1;const s=r.indexOf(e);return s!==-1&&r.splice(s,1),!0}}handlePointerCapture(i,e){if(i.z__pointer_ctured){i.z__pointer_ctured=!1;const t=i.pointerId;if(e.onPointerMove){const n=this._capturedPointer[t]||[];n.push(e),this._capturedPointer[t]=n}else ut()&&!e.z__warned_no_pointermove&&(e.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 i.z__pointer_cture_rleased&&(i.z__pointer_cture_rleased=!1,this.releasePointerCapture(i,e))}releasePointerCapture(i,e){const t=i.pointerId;if(this._capturedPointer[t]){const n=this._capturedPointer[t].indexOf(e);n!==-1&&(this._capturedPointer[t].splice(n,1),tc&&console.log("released pointer capture",t,e,this._capturedPointer))}}invokePointerCapture(i){var e;if(i.event.type===qi.PointerMove){const t=i.pointerId,n=this._capturedPointer[t];if(n){tc&&console.log("Captured",t,n);for(let r=0;r<n.length;r++){const s=n[r];if(s.destroyed){n.splice(r,1),r--;continue}(e=s.onPointerMove)==null||e.call(s,i)}}}}isChild(i,e){return!i||!e?!1:i===e?!0:i.parent?this.isChild(i.parent,e):!1}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=Ah.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ah.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];Ah.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?re.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Go=ic;h(Go,"_eventSystemMap",new Map),h(Go,"didSearchEventSystem",!1);class Ah{static markDirty(){this.needsUpdate=!0}static update(e,t,n=!1){if(n){e.update();return}const r=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(r===s.frame)return;s.frame=r;let o=this.needsUpdate||r<1;s.nextUpdate===t.time.frameCount&&(o=!0),o&&(tc&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:r,nextUpdate:r}],e.update()}static updateState(e,t){let n=null;if(e&&(n=this.findBlockInParent(e),n&&n!==this.lastSelected)){if(n.interactable===!1)return null;this.needsUpdate=!0}return n}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(Ah,"lastSelected",null),h(Ah,"lastUpdateFrame",[]),h(Ah,"needsUpdate",!1);var zie=Object.defineProperty,jie=Object.getOwnPropertyDescriptor,fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?jie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zie(e,t,r),r};const Gie=ee("debugorbit"),W_=ee("freecam"),wv=ee("debugcamerafit"),q_=ee("smoothcam"),Qie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let nI;class Sv extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class bi extends Ie{constructor(){super(...arguments),h(this,"autoTarget",!0),h(this,"autoFit",!1),h(this,"enableRotate",!0),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"minAzimuthAngle",1/0),h(this,"maxAzimuthAngle",1/0),h(this,"minPolarAngle",0),h(this,"maxPolarAngle",Math.PI),h(this,"enableKeys",!0),h(this,"enableDamping",!0),h(this,"dampingFactor",.1),h(this,"enableZoom",!0),h(this,"minZoom",0),h(this,"maxZoom",1/0),h(this,"enablePan",!0),h(this,"lookAtConstraint",null),h(this,"lookAtConstraint01",1),h(this,"allowInterrupt",!0),h(this,"middleClickToFocus",!0),h(this,"doubleClickToFocus",!0),h(this,"useSlerp",!0),h(this,"debugLog",!1),h(this,"targetLerpDuration",1),h(this,"_controls",null),h(this,"_cameraObject",null),h(this,"_lookTargetLerpActive",!1),h(this,"_lookTargetStartPosition",new S),h(this,"_lookTargetEndPosition",new S),h(this,"_lookTargetLerp01",0),h(this,"_lookTargetLerpDuration",0),h(this,"_cameraLerpActive",!1),h(this,"_cameraStartPosition",new S),h(this,"_cameraEndPosition",new S),h(this,"_cameraLerp01",0),h(this,"_cameraLerpDuration",0),h(this,"_inputs",0),h(this,"_enableTime",0),h(this,"_startedListeningToKeyEvents",!1),h(this,"_eventSystem"),h(this,"_afterHandleInputFn"),h(this,"_camera",null),h(this,"_syncedTransform"),h(this,"_didStart",!1),h(this,"_didSetTarget",!1),h(this,"targetElement",null),h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),h(this,"_shouldDisable",!1),h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Go.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(iI.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(iI.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=re.getComponent(this.gameObject,Bi);this._camera=e;let t=e?.cam;if(!t&&this.gameObject instanceof Ut&&(t=this.gameObject),t&&XT(t,this,!0),!this._controls&&t instanceof Ut){this._cameraObject=t;const n=this.targetElement??this.context.renderer.domElement,r=t?.quaternion.clone();this._controls=new fie(t,n),t?.quaternion.copy(r),nI===void 0&&(nI={...this._controls.keys})}this._controls&&(W_&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Ks()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?W_||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):W_||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=re.getComponent(this.gameObject,vh)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&XT(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var e,t;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)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.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 n=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(n||(n=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),n&&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 Sv(this,"camera"));else{const r=Ze.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}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 Sv(this,"lookat"));else{const r=Ze.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}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?nI:Qie,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 q_=="number"||q_===!0){this._controls.enableDamping=!0;const r=typeof q_=="number"?q_:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}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||(!W_&&(t=this.lookAtConstraint)!=null&&t.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),Gie&&yt.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const e=re.getComponent(this.gameObject,Bi);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const t=Pt(e.cam).length(),n=new S(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const t=new No;t.screenPoint=new $(0,0),t.lineThreshold=.1;const n=this.context.physics.raycast(t);n.length>0&&this.setLookTargetPosition(n[0].point,!0),wv&&console.log("OrbitControls hits",...n)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(e){if(!e||!(e instanceof ge))return;const t=Pt(e),n=CE(e);this.setTargetFromRaycast(new Ds(t,n)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var n,r;e&&(e instanceof ge&&(e=Pt(e)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(n=this.controllerObject)==null||n.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof ge&&(e=Pt(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var n;if(!this._controls)return!1;const r=(n=this.lookAtConstraint)==null?void 0:n.sources;if(r&&r.length>0){const s=r[e];if(s)return s.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of t)if(n.distance>0&&re.isActiveInHierarchy(n.object)){const r=tI(n.object);if(r){const s=r.canvas;if(s!=null&&s.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(e,t=void 0,n=!0){if(this.context.isInXR)return;t==null&&(t=1.1);const r=this._cameraObject,s=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0){console.warn("No objects to fit camera to...");return}if(!r||!s){console.warn("No camera or controls found to fit camera to objects...");return}const o=new S,a=new S,l=new fi;l.makeEmpty();const c=[];function u(E){let I=!0;if(E.visible&&KN(E)!==!1&&!(E.type==="TransformControlsGizmo"||E.type==="TransformControlsPlane")&&(E instanceof CC&&(I=!1),E instanceof qy&&(I=!1),E instanceof YN&&(I=!1),E.material instanceof ky&&(I=!1),E instanceof ue||(I=!1),E!==r&&E.isUI!==!0)){if(I){wv&&console.log(E.name,E.type,E);const T=E.children;E.children=c;const M=E.position,D=E.scale;if(Number.isNaN(M.x)||Number.isNaN(M.y)||Number.isNaN(M.z)){console.warn(`Object "${E.name}" has NaN values in position or scale.... will ignore it`,M,D);return}l.expandByObject(E,!0),E.children=T}for(const T of E.children)u(T)}}let d=!1;for(const E of e)E&&(d=!0,E.updateMatrixWorld(),u(E));if(!d){console.warn("No objects to fit camera to...");return}if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(r.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",r,l,[...e]);return}if(o.length()<=1e-10){wv&&console.warn("Camera fit size is zero",l,[...e]);return}const p=r.fov,f=2*Math.atan(Math.tan(p*Math.PI/360/2)*r.aspect)/Math.PI*360,m=o.y/(2*Math.atan(Math.PI*p/360)),A=o.x/(2*Math.atan(Math.PI*f/360)),v=t*Math.max(m,A)+o.z/2;wv&&console.log("Fit camera to objects",m,A,"distance",v),s.maxDistance=v*10,s.minDistance=v*.01;const g=.05,y=a.clone();y.y-=o.y*g,this.setLookTargetPosition(y,n),this.autoTarget=!1,r.near=v/1e3,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix();const b=Pt(r),_=a.clone();if(_.sub(b),_.y=0,_.normalize(),_.multiplyScalar(v),_.y+=-g*4*o.y,r.parent){const E=r.parent.worldToLocal(a.clone().sub(_));this.setCameraTargetPosition(E,n)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(wv){const E=new CC(l);this.context.scene.add(E),TE(E,mg(r)),setTimeout(()=>{this.context.scene.remove(E)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",I=>{I.code==="KeyF"&&this.fitCamera(e,t,n)}))}s.update()}}fn([x()],bi.prototype,"autoTarget",2),fn([x()],bi.prototype,"autoFit",2),fn([x()],bi.prototype,"enableRotate",2),fn([x()],bi.prototype,"autoRotate",2),fn([x()],bi.prototype,"autoRotateSpeed",2),fn([x()],bi.prototype,"minAzimuthAngle",2),fn([x()],bi.prototype,"maxAzimuthAngle",2),fn([x()],bi.prototype,"minPolarAngle",2),fn([x()],bi.prototype,"maxPolarAngle",2),fn([x()],bi.prototype,"enableKeys",2),fn([x()],bi.prototype,"enableDamping",2),fn([x()],bi.prototype,"dampingFactor",2),fn([x()],bi.prototype,"enableZoom",2),fn([x()],bi.prototype,"minZoom",2),fn([x()],bi.prototype,"maxZoom",2),fn([x()],bi.prototype,"enablePan",2),fn([x($u)],bi.prototype,"lookAtConstraint",2),fn([x()],bi.prototype,"lookAtConstraint01",2),fn([x()],bi.prototype,"allowInterrupt",2),fn([x()],bi.prototype,"middleClickToFocus",2),fn([x()],bi.prototype,"doubleClickToFocus",2),fn([x()],bi.prototype,"targetLerpDuration",2);var Hie=Object.defineProperty,Vie=Object.getOwnPropertyDescriptor,Fs=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Hie(e,t,r),r},td=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(td||{});const nc=ee("debugcam"),o4=ee("debugscreenpointtoray");var X_;const Cv=(X_=class extends Ie{constructor(){super(...arguments),h(this,"_nearClipPlane",.1),h(this,"_farClipPlane",1e3),h(this,"orthographic",!1),h(this,"orthographicSize",5),h(this,"ARBackgroundAlpha",0),h(this,"_cullingMask",4294967295),h(this,"_backgroundBlurriness",0),h(this,"_backgroundIntensity",1),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox"),h(this,"_frustum"),h(this,"_projScreenMatrix",new Ce)}get isCamera(){return!0}get aspect(){return this._cam instanceof Ut?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(i){this._cam instanceof Ut&&this._cam.aspect!==i&&(this._cam.aspect=i,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Ut?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof Ut){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(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const n=this.cam,r=Cv._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),o4&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const s=Cv._direction.set(r.x,r.y,r.z),o=Pt(n);return s.sub(o),s.normalize(),t?(t.set(o,s),t):new Ds(o.clone(),s.clone())}getFrustum(){return this._frustum||(this._frustum=new au,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new au),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(i,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),i===this._projScreenMatrix?i:i.copy(this._projScreenMatrix)}awake(){o4&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const n=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);yt.DrawRay(n.origin,n.direction,r,10)})}onEnable(){nc&&console.log(`Camera enabled: "${this.name}". ClearFlags=${td[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),qie(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 i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof Ut&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Ut&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Ut(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new Dl(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){nc&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,nc){const i=`Camera "${this.name}" clear flags: ${td[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 1:if(Cv.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:nc&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:nc&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Cv.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}else nc&&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 Wie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,n,r;const s=(e=i.renderer.xr)==null?void 0:e.getSession();if(!s)return!1;if(typeof s._transparent=="boolean")return s._transparent;const o=s.environmentBlendMode;nc&&Hi("Environment blend mode: "+o+" on "+navigator.userAgent);let a=o==="additive"||o==="alpha-blend";return i.isInAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(n=navigator.userAgent)!=null&&n.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(a=!0),s._transparent=a,a}},h(X_,"_origin",new S),h(X_,"_direction",new S),X_);let Bi=Cv;Fs([x()],Bi.prototype,"aspect",1),Fs([x()],Bi.prototype,"fieldOfView",1),Fs([x()],Bi.prototype,"nearClipPlane",1),Fs([x()],Bi.prototype,"farClipPlane",1),Fs([x()],Bi.prototype,"clearFlags",1),Fs([x()],Bi.prototype,"orthographic",2),Fs([x()],Bi.prototype,"orthographicSize",2),Fs([x()],Bi.prototype,"ARBackgroundAlpha",2),Fs([x()],Bi.prototype,"cullingMask",1),Fs([x()],Bi.prototype,"backgroundBlurriness",1),Fs([x()],Bi.prototype,"backgroundIntensity",1),Fs([x()],Bi.prototype,"environmentIntensity",1),Fs([x(yi)],Bi.prototype,"backgroundColor",1),Fs([x(pf)],Bi.prototype,"targetTexture",1);class Wie{constructor(e){h(this,"_camera"),h(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(nc&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=So,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)),(nc||ut())&&$i(`Camera "${this._camera.name}" has no skybox texture`))}}function qie(i){ee("freecam")&&i.context.mainCameraComponent===i&&re.getOrAddComponent(i.gameObject,bi)}class yh extends Ie{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new $D),this._listener}awake(){en.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||re.getComponentInParent(this.gameObject,Bi);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var Xie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,Y_=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yie(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Xie(e,t,r),r};const Jie=ee("debugsignals");class Ev{constructor(){h(this,"guid")}}Y_([x()],Ev.prototype,"guid",2);class vf{constructor(){h(this,"signal"),h(this,"reaction")}}Y_([x(Ev)],vf.prototype,"signal",2),Y_([x(Hn)],vf.prototype,"reaction",2);var rI;const rc=(rI=class extends Ie{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(rc.receivers[i]){const e=rc.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){Jie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)rc.receivers[i.signal.guid]||(rc.receivers[i.signal.guid]=[]),rc.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(rc.receivers[i.signal.guid]){const e=rc.receivers[i.signal.guid].indexOf(this);e>=0&&rc.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(n){console.error(n)}}},h(rI,"receivers",{}),rI);let Af=rc;Y_([x(vf)],Af.prototype,"events",2);var ro=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(ro||{}),Ka=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ka||{}),sI=(i=>(i.Signal="SignalEmitter",i))(sI||{});const Za=ee("debugtimeline");class Mv{constructor(){h(this,"director"),h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let n=this.track.clips.length-1;n>=0;n--)yield this.track.clips[n];else for(const n of this.track.clips)yield n}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,n,r=!0){if(t<0||t>=n.length)return 0;const s=n[t];if(r||e>=s.start&&e<=s.end){let o=1;const a=!1;if(s.easeInDuration>0){const l=Math.min((e-s.start)/s.easeInDuration,1);o*=l}if(s.easeOutDuration>0&&!a){const l=Math.min((s.end-e)/s.easeOutDuration,1);o*=l}return o}return 0}}class Kie{constructor(e){h(this,"clip"),h(this,"rootPositionOffset"),h(this,"rootQuaternionOffset"),h(this,"rootStartPosition"),h(this,"rootEndPosition"),h(this,"rootStartQuaternion"),h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const n=e.getRoot(),r=n.name+".position",s=n.name+".quaternion";Za&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))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),Za&&console.log(this.rootPositionOffset);else if(o.name.endsWith(s)&&(this.rootStartQuaternion=new Me().fromArray(o.values,0),this.rootEndQuaternion=new Me().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Za)){const a=new Ni().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class J_ extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"trackOffset"),h(this,"target"),h(this,"mixer"),h(this,"clips",[]),h(this,"actions",[]),h(this,"_actionOffsets",[]),h(this,"_didBind",!1),h(this,"_animator",null),h(this,"_useclipOffsets",!0),h(this,"_totalOffsetPosition",new S),h(this,"_totalOffsetRotation",new Me),h(this,"_totalOffsetPosition2",new S),h(this,"_totalOffsetRotation2",new Me),h(this,"_summedPos",new S),h(this,"_tempPos",new S),h(this,"_summedRot",new Me),h(this,"_tempRot",new Me),h(this,"_clipRotQuat",new Me)}onStateChanged(){this._animator&&a4(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var n,r;if(((n=t.tracks)==null?void 0:n.length)<=0){console.warn("No tracks in AnimationClip",t);return}const s=t.tracks[0].name.split("."),o=s[s.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";Za&&console.warn("Create quaternion track",A,v);const y=v.quaternion,b=new La(g,[0,t.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);t.tracks.push(b),this.createRotationInterpolant(t,e,b)}}else{const g=m+".position";Za&&console.warn("Create position track",A,v);const y=v.position,b=new Ol(g,[0,t.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);t.tracks.push(b),this.createPositionInterpolant(t,e,b)}}}bind(){if(!this._didBind){this._didBind=!0,Za&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new Kie(e);this._actionOffsets.push(t)}this.target&&(this._animator=re.getComponent(this.target,Sr)??null,this._animator&&a4(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,n=t.position,r=t.rotation;n&&n.x!==void 0&&(n.isVector3||(t.position=new S(n.x,n.y,n.z)),r.isQuaternion||(t.rotation=new Me(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new S(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Me(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,n,r,s,o,a,l;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 c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const y=e>=A.start&&e<=A.end,b=A.preExtrapolationMode,_=A.postExtrapolationMode,E=m<this.clips.length-1?this.models[m+1]:null;let I=y,T=!1;if(!I&&!d&&A.end<e&&_!==Ka.None?(!E||E.start>e)&&(I=!0,d=!0):m==0&&!I&&!p&&A.start>e&&b!==Ka.None&&(!E||E.start<e)&&(I=!0,T=!0,p=!0),I){let M=1;M*=this.evaluateWeight(e,m,this.models,I),M*=this.director.weight;let D=y;if(T)switch(b){case Ka.Hold:break;case Ka.Loop:e+=A.start,D=!0;break;default:e+=A.start,D=!0;break}let C=this.getClipTime(e,A),P=0;const j=g.duration;if(T&&b===Ka.Hold&&(C=0),D){if(g.loop)for(P+=Math.floor(C/(j+1e-6));C>j;)C-=j}else if(!y&&d)switch(_){case Ka.Hold:C=this.getClipTime(A.end,A);break;case Ka.Loop:C%=j;break;case Ka.PingPong:const O=Math.floor(C/j)%2!==0;C%=j,O&&(C=j-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const Q=Math.max(0,M);if(v.weight=Q,f+=Q,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const O=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,W=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-M),c+=1;const L=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),z=this._summedRot.identity(),Z=this._tempRot.identity(),K=g.rotation;K&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(K,M));const se=this._actionOffsets[m];if(se.hasOffsets)for(let Ae=0;Ae<P;Ae++)se.rootPositionOffset?F.copy(se.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(z),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),se.rootQuaternionOffset&&(Z.copy(se.rootQuaternionOffset),z.multiply(Z)),L.add(F);this._clipRotQuat&&W.multiply(this._clipRotQuat),W.multiply(z),g.position&&L.add(g.position),O.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&(Za||ut())&&(n=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&n.mixer&&this.mixer!==((s=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:s.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 m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,n){var r;const s=n.createInterpolant.bind(n),o=new Me;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;n.createInterpolant=()=>{const l=s(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,n){var r,s;const o=n.createInterpolant.bind(n),a=new S;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(s=this.trackOffset)==null?void 0:s.position;let u;n.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(y=>y.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(v=y?.onTimelinePosition)==null||v.call(y,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const Zie=ee("mutetimeline"),Tv=class extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"listener"),h(this,"audio",[]),h(this,"audioContextTimeOffset",[]),h(this,"lastTime",0),h(this,"audioSource"),h(this,"_audioLoader",null),h(this,"_playableDirectorResumed",!1)}getAudioFilePath(i){const e=this.director.sourceId;return Fl(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new vC(this.listener);this.audio.push(e);const t=i;t._didTriggerPlay=!1,this.models.push(t)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop();for(const i of this.models)i._didTriggerPlay=!1}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}for(const i of this.models)i._didTriggerPlay=!1}onPauseChanged(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(i){if(Zie||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=this._playableDirectorResumed;this._playableDirectorResumed=!1;const n=e?.1:0;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=this.audio[r],a=s.asset;if((!o||!o.buffer)&&this.isInTimeRange(s,i-1,i+1)&&this.handleAudioLoading(s,o),en.userInteractionRegistered!==!1&&!(o===null||!o.buffer))if(o.playbackRate=this.director.context.time.timeScale*this.director.speed,o.loop=a.loop,i>=s.start&&i<=s.end&&i<this.director.duration){if(!o.isPlaying||!this.director.isPlaying)(t||!s._didTriggerPlay&&this.lastTime<i)&&(s.duration*s.timeScale>.3?o.offset=s.clipIn+(i-s.start)*s.timeScale:o.offset=0,Za&&console.log("Timeline Audio ("+this.track.name+") play with offset "+o.offset+" - "+s.asset.clip),o.play(n),s._didTriggerPlay=!0);else{const c=s.clipIn+(i-s.start)*s.timeScale,u=o.context.currentTime-o._startedAt+o.offset;Math.abs(c-u)>.3&&(o.offset=c,o.stop(),o.play(n))}let l=a.volume;if(this.track.volume!==void 0&&(l*=this.track.volume),e&&(l=0),s.easeInDuration>0){const c=Math.min((i-s.start)/s.easeInDuration,1);l*=c}if(s.easeOutDuration>0){const c=Math.min((s.end-i)/s.easeOutDuration,1);l*=c}o.setVolume(l*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&o.isPlaying&&o.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let n=null;const r=i-t,s=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,s)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(n===null&&(n=[]),n.push(l))}return n!==null?Promise.all(n):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Tv._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new Gy);const t=this.getAudioFilePath(i.asset.clip);if(Tv._audioBuffers.get(t)){const r=Tv._audioBuffers.get(t);return r.then(s=>{s&&e.setBuffer(s)}),r}Za&&console.warn("LOAD audio track",t,this.director.sourceId);const n=new Promise((r,s)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Tv._audioBuffers.set(t,n),n}};let Iv=Tv;h(Iv,"_audioBuffers",new Map);class Rv extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const n=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=this.didTrigger[r],a=s.time-e;let l=!1;if(s.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<n)&&(l=!0)}if(l){if(!o)if(Za&&console.log("Trigger signal",e,s.time,s),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Af.invoke(s.asset);else for(const c of this.receivers)c&&c.invoke(s.asset)}else s.emitOnce||(this.didTrigger[r]=!1)}}}class K_ extends Mv{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const n=this.models[t].asset;if(!n.sourceObject||typeof n.sourceObject!="object"){console.log("no source object, removing model",t,n),this.models.splice(t,1);continue}else{const r=re.getComponent(n.sourceObject,id);this.timelines.push(r),r&&n.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let n=0;n<this.models.length;n++){const r=this.models[n],s=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(s.controlActivation){const a=s.sourceObject;a.visible=!0}if(s.updateDirector){const a=this.timelines[n];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(s.controlActivation){const a=s.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}const yf=ee("debugtimeline"),oI=class extends Ie{constructor(){super(...arguments),h(this,"playableAsset"),h(this,"playOnAwake"),h(this,"extrapolationMode",1),h(this,"waitForAudio",!0),h(this,"_visibilityChangeEvt"),h(this,"_clonedPlayableAsset",!1),h(this,"_speed",1),h(this,"_guidsMap"),h(this,"_isPlaying",!1),h(this,"_internalUpdateRoutine"),h(this,"_isPaused",!1),h(this,"_isStopping",!1),h(this,"_time",0),h(this,"_duration",0),h(this,"_weight",1),h(this,"_animationTracks",[]),h(this,"_audioTracks",[]),h(this,"_signalTracks",[]),h(this,"_controlTracks",[]),h(this,"_customTracks",[]),h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),h(this,"animationCallbackReceivers",[])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(yf||Hs())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;yf&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const n of this._audioTracks)(i=n.onEnable)==null||i.call(n);for(const n of this._customTracks)(e=n.onEnable)==null||e.call(n);for(const n of this._animationTracks)(t=n.onEnable)==null||t.call(n);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 i,e,t;this.stop();for(const n of this._audioTracks)(i=n.onDisable)==null||i.call(n);for(const n of this._customTracks)(e=n.onDisable)==null||e.call(n);for(const n of this._animationTracks)(t=n.onDisable)==null||t.call(n);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,i&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const t of this._audioTracks){const n=t.loadAudio(this._time,1,0);n&&e.push(n)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!en.userInteractionRegistered&&this.waitForAudio;)await ca(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Fi.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&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 i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(i=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const t=this._time;for(const n of this.playableAsset.tracks)if(!n.muted)switch(n.type){case ro.Activation:if(!i&&!this._isPlaying)continue;for(let r=0;r<n.outputs.length;r++){const s=n.outputs[r];if(typeof s=="object"){let o=!1;if(n.clips)for(const l of n.clips)l.start<=t&&t<=l.end&&(o=!0);const a=s;a.visible!==void 0&&a.visible!==o&&(a.visible=o,yf&&console.warn(this.name,"set ActivationTrack-"+r,a.name,o,t))}}break}if(!this._isStopping)for(const n of this._animationTracks)n.evaluate(t);for(const n of this._audioTracks)n.evaluate(t);for(const n of this._signalTracks)n.evaluate(t);for(const n of this._controlTracks)n.evaluate(t);for(const n of this._customTracks)n.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=og(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let n=e.outputs[t];if(typeof n=="string"){this._guidsMap&&this._guidsMap[n]&&(n=this._guidsMap[n]);const r=re.findByGuid(n,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",n,e.name,e.type)):(yf&&console.log("Resolved binding",n,"to",r),e.outputs[t]=r)}else if(n===null){if(e.outputs.splice(t,1),oI.createTrackFunctions[e.type])continue;e.type!==ro.Audio&&e.type!==ro.Control&&e.type!==ro.Marker&&e.type!==ro.Signal&&console.warn("Missing binding",n,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===ro.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const n=e.clips[t];let r=n.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const s=re.findByGuid(r,i);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,n):(yf&&console.log("Resolved binding",r,"to",s),n.asset.sourceObject=s)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){if(i.clips)for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);if(i.markers)for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let n=re.findObjectOfType(yh,this.context);for(const r of this.playableAsset.tracks){const s=r.type,o=oI.createTrackFunctions[s];if(o!=null){const a=o(this,r);if(typeof a.evaluate=="function"){a.director=this,a.track=r,this._customTracks.push(a);continue}}if(r.type===ro.Animation){if(!r.clips||r.clips.length<=0){yf&&console.warn("Animation track has no clips",r);continue}for(let a=r.outputs.length-1;a>=0;a--){let l=r.outputs[a];if(l instanceof ge){const u=re.getOrAddComponent(l,Sr);u&&(l=u)}const c=(i=l?.gameObject)==null?void 0:i.animations;if(c){const u=new J_;u.trackOffset=r.trackOffset,u.director=this,u.track=r;for(let d=0;d<r.clips.length;d++){const p=r.clips[d],f=p.asset;if(!f){console.error(`Timeline ${this.name}: clip #${d} on track "${r.name}" has no animation data`);continue}const m=f.clip;let A=m;if((typeof A=="string"||typeof A=="number")&&(A=c.find(g=>g.name===m)),!A){console.warn("Could not find animationClip for model",p,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}l instanceof Sr&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),u.mixer=l.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Qy(l.gameObject)),u.clips.push(A),u.mixer.uncacheAction(A),u.createHooks(p.asset,A);const v=u.mixer.clipAction(A);u.actions.push(v),u.models.push(p)}this._animationTracks.push(u)}}}else if(r.type===ro.Audio){if(!r.clips||r.clips.length<=0)continue;const a=new Iv;a.director=this,a.track=r,a.audioSource=r.outputs.find(l=>l instanceof en),this._audioTracks.push(a),n||(n=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(yh)),a.listener=n.listener;for(let l=0;l<r.clips.length;l++){const c=r.clips[l];a.addModel(c)}}else if(r.type===ro.Marker){const a=new Rv;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)switch(l.type){case sI.Signal:a.models.push(l),a.didTrigger.push(!1);break}if(a!==null&&a.models.length>0){const l=re.getComponent(this.gameObject,Af);l&&(a.receivers.push(l),this._signalTracks.push(a))}}else if(r.type===ro.Signal){const a=new Rv;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)a.models.push(l),a.didTrigger.push(!1);for(const l of r.outputs)a.receivers.push(l);this._signalTracks.push(a)}else if(r.type===ro.Control){const a=new K_;if(a.director=this,a.track=r,r.clips)for(const l of r.clips)a.models.push(l);a.resolveSourceObjects(this.context),this._controlTracks.push(a)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let id=oI;h(id,"createTrackFunctions",{});const Z_=Symbol("objectIsAnimatedData");function a4(i,e,t){if(!i)return;if(i[Z_]===void 0){if(!t)return;i[Z_]=new Set}const n=i[Z_];t?n.add(e):n.has(e)&&n.delete(e)}function $ie(i){if(!i)return!1;const e=i[Z_];return e!==void 0&&e.size>0}ni.registerCallback(pn.ContextCreated,i=>{const e=i.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&i.files)for(const t of i.files)re.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof _s&&n.playAutomatically||n instanceof Sr||n instanceof id&&n.playOnAwake===!0)return!0;if(n instanceof _s)return n.playAutomatically=!0,!0;if(n instanceof id)return n.playOnAwake=!0,!0}},!0)!==!0&&ene(t.file)});function ene(i){if(!i||!i.animations)return;for(let t=0;t<i.animations.length;t++){const n=i.animations[t];if(!(!n.tracks||n.tracks.length<=0))for(const r in n.tracks){const s=n.tracks[r],o=s.__objectName??s.name.substring(0,s.name.indexOf("."));let a=i.scene.getObjectByName(o);if(!a&&(a=i.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=dh(i.scene,new _s));const c=l.animations=l.animations||[];n.name_animator=l.name,c.indexOf(n)<0&&c.push(n)}}function e(t){var n;if(!t)return;const r=(n=t.userData)==null?void 0:n.components;if(r&&r.length>0)for(let s=0;s<r.length;s++){const o=r[s];if(o instanceof Sr||o instanceof _s)return t}return e(t.parent)}}class tne{constructor(){h(this,"_context")}get context(){return this._context??Ot.Current}get isStateMachineBehaviour(){return!0}}class Pv{constructor(e,t,n,r){h(this,"name"),h(this,"nameHash"),h(this,"normalizedTime"),h(this,"length"),h(this,"speed"),h(this,"action"),this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=n,this.speed=r,this.action=e.motion.action||null}}function l4(i,e){return{name:"",isLooping:!1,guid:e?.generateUUID()??Nn.generateUUID(),index:-1,clip:new ps(i,1,[])}}var bh=(i=>(i[i.If=1]="If",i[i.IfNot=2]="IfNot",i[i.Greater=3]="Greater",i[i.Less=4]="Less",i[i.Equals=6]="Equals",i[i.NotEqual=7]="NotEqual",i))(bh||{}),aI=(i=>(i[i.Float=1]="Float",i[i.Int=3]="Int",i[i.Bool=4]="Bool",i[i.Trigger=9]="Trigger",i))(aI||{});const xs=ee("debuganimatorcontroller"),$_=ee("debugrootmotion");class _o{constructor(e){h(this,"_speed",1),h(this,"normalizedStartOffset",0),h(this,"animator"),h(this,"model"),h(this,"_mixer"),h(this,"_activeState"),h(this,"_activeStates",[]),h(this,"rootMotionHandler"),this.model=e,xs&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const n=[];for(let s=0;s<e.length;s++){const o=e[s],a=[];if(t.autoTransition!==!1){const c=t.transitionDuration??0,u=c/o.duration;let d=s;(t.autoTransition===void 0||t.autoTransition===!0)&&(d=(s+1)%e.length),a.push({exitTime:1-u,offset:0,duration:c,hasExitTime:!0,destinationState:d,conditions:[]})}const l={name:o.name,hash:s,motion:{name:o.name,clip:o,isLooping:t?.looping??!1},transitions:a,behaviours:[]};n.push(l)}const r={name:"AnimatorController",guid:new ar(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:n}}]};return new _o(r)}play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const s=this.model.layers[t].stateMachine;for(const o of s.states)if(o.name===e||o.hash===e){xs&&console.log("transition to ",o),this.transitionTo(o,r,n);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var n,r;const s=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=t)}getBool(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??!1}setFloat(e,t){var n,r;const s=typeof e=="string"?"name":"hash",o=(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(a=>a[s]===e);return o.forEach(a=>a.value=t),o?.length>0}getFloat(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??0}setInteger(e,t){var n,r;const s=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=t)}getInteger(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??0}setTrigger(e){var t,n;xs&&console.log("SET TRIGGER",e);const r=typeof e=="string"?"name":"hash";return(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.filter(s=>s[r]===e).forEach(s=>s.value=!0)}resetTrigger(e){var t,n;const r=typeof e=="string"?"name":"hash";return(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.filter(s=>s[r]===e).forEach(s=>s.value=!1)}getTrigger(e){var t,n,r;const s=typeof e=="string"?"name":"hash";return((r=(n=(t=this.model)==null?void 0:t.parameters)==null?void 0:n.find(o=>o[s]===e))==null?void 0:r.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const t of this.model.layers)for(const n of t.stateMachine.states)if(n.name===e||n.hash==e)return n}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,n=t<=0?0:Math.abs(e.time/t);return new Pv(this._activeState,n,t,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var e;return(e=this.animator)==null?void 0:e.context}get mixer(){return this._mixer}bind(e){e?this.animator!==e&&(this.animator=e,this._mixer=new Qy(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;xs&&console.warn("AnimatorController clone()",this.model);const e=og(this.model,(t,n,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||QO(r)||r.tracks!==void 0||r instanceof _o));return console.assert(e!==this.model),new _o(e)}update(e){var t,n;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const r=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(e)),this._mixer.update(r),this.animator.applyRootMotion&&((n=this.rootMotionHandler)==null||n.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const n=this._activeStates[t],r=n.motion;if(!r.action)this._activeStates.splice(t,1),t--;else{const s=r.action;s.weight=e,s.getEffectiveWeight()<=0&&!s.isRunning()&&(xs&&console.debug("REMOVE",n.name,s.getEffectiveWeight(),s.isRunning(),s.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(xs&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const n=t.states[t.defaultState];this.transitionTo(n,0,this.normalizedStartOffset)}}evaluateTransitions(){var e;let t=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;t=!0}const n=this._activeState,r=n.motion.action;for(const o of n.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let a=!0;for(const l of o.conditions)if(!this.evaluateCondition(l)){a=!1;break}if(a)if(r){const l=n.motion.clip.duration,c=l<=0?1:Math.abs(r.time/l);let u=!1;if(o.hasExitTime?r.timeScale>0?u=c>=o.exitTime:r.timeScale<0&&(u=1-c>=o.exitTime):u=!0,u){for(const d of o.conditions){const p=this.model.parameters.find(f=>f.name===d.parameter);p?.type===aI.Trigger&&p.value&&(p.value=!1)}r.clampWhenFinished=!0,xs&&console.log("transition to "+o.destinationState,o,c,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(r){let o=n.speed??1;n.speedParameter&&(o*=this.getFloat(n.speedParameter)),o!==void 0&&(r.timeScale=o*this._speed)}let s=!1;if(n.motion.isLooping&&r&&(r.time>=r.getClip().duration?(s=!0,r.reset(),r.time=0,r.play()):r.time<=0&&r.timeScale<0&&(s=!0,r.reset(),r.time=r.getClip().duration,r.play())),!s&&n&&!t&&r&&this.animator&&n.behaviours){const o=r?.getClip().duration,a=r.time/o,l=new Pv(this._activeState,a,o,this._speed);for(const c of n.behaviours)c.instance&&((e=c.instance.onStateUpdate)==null||e.call(c.instance,this.animator,l,0))}}getState(e,t){return typeof e=="number"&&(e==-1&&(e=this.model.layers[t].stateMachine.defaultState,e===void 0&&(xs&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+t),e=0)),e=this.model.layers[t].stateMachine.states[e]),e}transitionTo(e,t,n){var r,s,o,a,l,c,u,d;if(!this.animator)return;const p=0;if(e=this.getState(e,p),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof ps))return;const f=this._activeState===e;if(f){const g=e.motion;if(!g.action_loopback&&g.clip){const y=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(g.clip,this.animator.gameObject),y&&y.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),g.action_loopback=this.createAction(g.clip)}}if((r=this._activeState)!=null&&r.behaviours&&this._activeState.motion.action){const g=(s=this._activeState)==null?void 0:s.motion.clip.duration,y=this._activeState.motion.action.time/g,b=new Pv(this._activeState,y,g,this._speed);for(const _ of this._activeState.behaviours)(a=(o=_.instance)==null?void 0:o.onStateExit)==null||a.call(_.instance,this.animator,b,p)}const m=(l=this._activeState)==null?void 0:l.motion.action;m&&m.fadeOut(t),f&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=m);const A=this._activeState;this._activeState=e;const v=(c=e.motion)==null?void 0:c.action;if(v){if(n=Math.max(0,Math.min(1,n)),e.cycleOffsetParameter){let y=this.getFloat(e.cycleOffsetParameter);typeof y=="number"?(y<0&&(y+=1),n+=y,n%=1):xs&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(n+=e.cycleOffset,n%=1);v.isRunning()&&v.stop(),v.reset(),v.enabled=!0;const g=e.motion.clip.duration;if(v.time=f?0:n*g,v.timeScale<0&&(v.time=g-v.time),v.clampWhenFinished=!0,v.setLoop(wm,0),t>0?v.fadeIn(t):v.weight=1,v.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(v),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const y=new Pv(e,n,g,this._speed);for(const b of this._activeState.behaviours)(d=(u=b.instance)==null?void 0:u.onStateEnter)==null||d.call(b.instance,this.animator,y,p)}}else xs&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));xs&&console.log("TRANSITION FROM "+A?.name+" TO "+e.name,t,m,v,v?.getEffectiveTimeScale(),v?.getEffectiveWeight(),v?.isRunning(),v?.isScheduled(),v?.paused)}createAction(e){var t,n;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(t=this.animator)==null?void 0:t.gameObject),(n=this.animator)!=null&&n.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new ine(this));const r=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,r,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const t=this.model.parameters.find(n=>n.name===e.parameter);if(!t)return!1;switch(e.mode){case bh.If:return t.value===!0;case bh.IfNot:return t.value===!1;case bh.Greater:return t.value>e.threshold;case bh.Less:return t.value<e.threshold;case bh.Equals:return t.value===e.threshold;case bh.NotEqual:return t.value!==e.threshold}return!1}createActions(e){var t,n,r,s;xs&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const a=o.stateMachine;for(let l=0;l<a.states.length;l++){const c=a.states[l];c.transitions||(c.transitions=[]);for(const u of c.transitions)u.conditions||(u.conditions=[]);if(c.motion||(c.motion=l4(c.name)),this.animator&&c.motion.clips){const u=(t=c.motion.clips)==null?void 0:t.find(d=>{var p,f;return d.node.name===((f=(p=this.animator)==null?void 0:p.gameObject)==null?void 0:f.name)});u?c.motion.clip=u.clip:(xs||ut())&&console.warn('Could not find clip for animator "'+((r=(n=this.animator)==null?void 0:n.gameObject)==null?void 0:r.name)+'"',c.motion.clips.map(d=>d.node.name))}if(!c.motion.clip){const u=new ps(void 0,void 0,[]);c.motion.clip=u}if((s=c.motion)!=null&&s.clip){const u=c.motion.clip;if(u instanceof ps){const d=this.createAction(u);c.motion.action=d}else(xs||ut())&&console.warn("No valid animationclip assigned",c)}if(c.behaviours&&Array.isArray(c.behaviours))for(const u of c.behaviours){if(!(u!=null&&u.typeName))continue;const d=q.get(u.typeName),p=new d;p.isStateMachineBehaviour&&(p._context=this.context??void 0,Kp(p,u.properties),u.instance=p),xs&&console.log("Created animator controller behaviour",c.name,u.typeName,u.properties,p)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let n=0;n<t.states.length;n++){const r=t.states[n];r!=null&&r.motion&&(r.motion.action&&(yield r.motion.action),r.motion.action_loopback&&(yield r.motion.action_loopback))}}}}class c4{constructor(e,t){h(this,"track"),h(this,"createdInterpolant"),h(this,"originalEvaluate"),h(this,"customEvaluate"),this.track=e;const n=e,r=n.createInterpolant.bind(e);n.createInterpolant=()=>(n.createInterpolant=r,this.createdInterpolant=r(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=s=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(s);return t(s,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 nr=class{constructor(i,e,t,n,r){if(h(this,"_action"),h(this,"root"),h(this,"clip"),h(this,"positionWrapper",null),h(this,"rotationWrapper",null),h(this,"context"),h(this,"positionChange",new S),h(this,"rotationChange",new Me),h(this,"_prevTime",0),this.context=i,this.root=e,this.clip=t,nr.firstKeyframeRotation[this.cacheId]||(nr.firstKeyframeRotation[this.cacheId]=new Me),r){const s=r.values;nr.firstKeyframeRotation[this.cacheId].set(s[0],s[1],s[2],s[3])}nr.spaceRotation[this.cacheId]||(nr.spaceRotation[this.cacheId]=new Me),nr.effectiveSpaceRotation[this.cacheId]||(nr.effectiveSpaceRotation[this.cacheId]=new Me),nr.clipOffsetRotation[this.cacheId]=new Me,r&&nr.clipOffsetRotation[this.cacheId].set(r.values[0],r.values[1],r.values[2],r.values[3]).invert(),this.handlePosition(t,n),this.handleRotation(t,r)}set action(i){this._action=i}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(i){if(i.getClip()!==this.clip)return;nr.lastObjRotation[this.cacheId]||(nr.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=nr.lastObjRotation[this.cacheId];if(nr.spaceRotation[this.cacheId].copy(e),$_){const t=new Ni().setFromQuaternion(e);console.log("START",this.clip.name,Ze.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return nr.clipOffsetRotation[this.cacheId]}handlePosition(i,e){if(e){const t=this.root;$_&&t.add(new Mo),nr.lastObjPosition[this.cacheId]||(nr.lastObjPosition[this.cacheId]=this.root.position.clone());const n=new S,r=new S;this.positionWrapper=new c4(e,(s,o)=>{const a=this.action.getEffectiveWeight();return $_&&t.position.length()>8&&t.position.set(0,t.position.y,0),s>this._prevTime&&(n.set(o[0],o[1],o[2]),n.sub(r),n.multiplyScalar(a),n.applyQuaternion(this.getClipRotationOffset()),n.applyQuaternion(t.quaternion),this.positionChange.copy(n)),r.fromArray(o),this._prevTime=s,o[0]=0,o[1]=0,o[2]=0,o})}}handleRotation(i,e){if(e){if($_){const s=e.values,o=new Ni().setFromQuaternion(new Me(s[0],s[1],s[2],s[3]));console.log(i.name,e.name,"FIRST ROTATION IN TRACK",Ze.toDegrees(o.y));const a=e.values.length-4,l=new Me().set(s[a],s[a+1],s[a+2],s[a+3]),c=new Ni().setFromQuaternion(l);console.log(i.name,e.name,"LAST ROTATION IN TRACK",Ze.toDegrees(c.y))}let t=0;const n=new Me,r=new Me;this.rotationWrapper=new c4(e,(s,o)=>(s>t&&(r.set(o[0],o[1],o[2],o[3]),n.invert(),r.multiply(n),this.rotationChange.copy(r)),n.fromArray(o),t=s,o[0]=0,o[1]=0,o[2]=0,o[3]=1,o))}}onBeforeUpdate(i){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(i){return!this.action||(i*=this.action.getEffectiveWeight(),i<=0)?!1:(this.positionChange.multiplyScalar(i),this.rotationChange.slerp(nr.identityQuaternion,1-i),!0)}};let _h=nr;h(_h,"lastObjPosition",{}),h(_h,"lastObjRotation",{}),h(_h,"firstKeyframeRotation",{}),h(_h,"spaceRotation",{}),h(_h,"effectiveSpaceRotation",{}),h(_h,"clipOffsetRotation",{}),h(_h,"identityQuaternion",new Me);class ine{constructor(e){h(this,"controller"),h(this,"handler",[]),h(this,"root"),h(this,"basePosition",new S),h(this,"baseQuaternion",new Me),h(this,"baseRotation",new Ni),h(this,"summedPosition",new S),h(this,"summedRotation",new Me),this.controller=e}createClip(e,t,n){this.root=t,t&&"name"in t&&t.name;const r=this.findRootTrack(n,".position"),s=this.findRootTrack(n,".quaternion"),o=new _h(this.controller.context,t,n,r,s);this.handler.push(o);const a=e.clipAction(n);return o.action=a,a}onStart(e){for(const t of this.handler)t.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const t of this.handler)t.onBeforeUpdate(e)}onAfterUpdate(e){if(!(e<=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 t of this.handler)t.onAfterUpdate(e)&&(this.summedPosition.add(t.positionChange),this.summedRotation.multiply(t.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,t){const n=e.tracks;if(!n)return null;for(const r of n)if(r.name.endsWith(t))return r;return null}}class nne extends Ha{onSerialize(e,t){}onDeserialize(e,t){if(t.type===_o&&e?.__type==="AnimatorController")return new _o(e)}}new nne(_o);var rne=Object.defineProperty,sne=Object.getOwnPropertyDescriptor,ex=(i,e,t,n)=>{for(var r=n>1?void 0:n?sne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&rne(e,t,r),r};const Qo=ee("debuganimator");class Sr extends Ie{constructor(){super(...arguments),h(this,"applyRootMotion",!1),h(this,"hasRootMotion",!1),h(this,"keepAnimatorControllerStateOnDisable",!1),h(this,"_parametersAreDirty",!1),h(this,"_isDirty",!1),h(this,"_speed",1),h(this,"_normalizedStartOffset",0),h(this,"_animatorController",null),h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof _o?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new _o(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Qo&&console.log("Assign animator controller",e,this),this._animatorController=new _o(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var e;return(e=this.runtimeAnimatorController)==null?void 0:e.getCurrentStateInfo()}get currentAction(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){this.play(e,t,n,r)}play(e,t=-1,n=Number.NEGATIVE_INFINITY,r=0){var s;(s=this.runtimeAnimatorController)==null||s.play(e,t,n,r),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var n,r;Qo&&console.log("setBool",e,t),((n=this.runtimeAnimatorController)==null?void 0:n.getBool(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getBool(e))??!1;return Qo&&console.log("getBool",e,n),n}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(e))!==t&&(this._parametersAreDirty=!0),Qo&&console.log("setFloat",e,t),(r=this.runtimeAnimatorController)==null||r.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getFloat(e))??-1;return Qo&&console.log("getFloat",e,n),n}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(e))!==t&&(this._parametersAreDirty=!0),Qo&&console.log("setInteger",e,t),(r=this.runtimeAnimatorController)==null||r.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var t;const n=((t=this.runtimeAnimatorController)==null?void 0:t.getInteger(e))??-1;return Qo&&console.log("getInteger",e,n),n}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Qo&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Qo&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var t;const n=(t=this.runtimeAnimatorController)==null?void 0:t.getTrigger(e);return Qo&&console.log("getTrigger",e,n),n}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this._speed&&(Qo&&console.log("setSpeed",e),this._speed=e,((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){var t;this._speed=Ze.lerp(e.x,e.y,Math.random()),((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){var t;this._normalizedStartOffset=Ze.lerp(e.x,e.y,Math.random()),((t=this.runtimeAnimatorController)==null?void 0:t.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Qo&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const n=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=n,n?(console.assert(this.runtimeAnimatorController!==n),this.runtimeAnimatorController=n,console.assert(this.runtimeAnimatorController===n),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 e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}ex([x()],Sr.prototype,"applyRootMotion",2),ex([x()],Sr.prototype,"hasRootMotion",2),ex([x()],Sr.prototype,"keepAnimatorControllerStateOnDisable",2),ex([x()],Sr.prototype,"runtimeAnimatorController",1);const nd=ee("debugusdzanimation"),lI=ee("debugusdzanimationserialization");class tx{constructor(e,t,n){h(this,"_start"),h(this,"ext"),h(this,"root"),h(this,"clip"),this.ext=e,this.root=t,this.clip=n}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 h4=class{constructor(i,e,t){h(this,"clip"),h(this,"pos"),h(this,"rot"),h(this,"scale"),h(this,"root"),h(this,"target"),h(this,"duration",0),h(this,"useRootMotion",!1),this.root=i,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=h4.restPoseClipDuration;const n=re.getComponent(i,Sr);n&&(this.useRootMotion=n.applyRootMotion)}get frameRate(){return 60}addTrack(i){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}i.name.endsWith("position")&&(this.pos=i),i.name.endsWith("quaternion")&&(this.rot=i),i.name.endsWith("scale")&&(this.scale=i)}getFrames(){var i,e,t,n,r,s;return this.clip?Math.max(((e=(i=this.pos)==null?void 0:i.times)==null?void 0:e.length)??0,((n=(t=this.rot)==null?void 0:t.times)==null?void 0:n.length)??0,((s=(r=this.scale)==null?void 0:r.times)==null?void 0:s.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(i=!0,e=!0,t=!0){var n,r,s;if(!this.clip)return[0,this.duration];const o=(n=this.pos)==null?void 0:n.times,a=(r=this.rot)==null?void 0:r.times,l=(s=this.scale)==null?void 0:s.times,c=[];if(i&&o)for(const u of o)c.push(u);if(e&&a)for(const u of a)c.push(u);if(t&&l)for(const u of l)c.push(u);return c.includes(0)||c.push(0),c.sort((u,d)=>u-d),[...new Set(c)]}*getValues(i,e=!0,t=!0,n=!0){var r,s,o;const a=new S,l=new Me,c=new S(1,1,1),u=this.target,d=e?(r=this.pos)==null?void 0:r.createInterpolant():void 0,p=t?(s=this.rot)==null?void 0:s.createInterpolant():void 0,f=n?(o=this.scale)==null?void 0:o.createInterpolant():void 0;d||a.set(u.position.x,u.position.y,u.position.z),p||l.set(u.quaternion.x,u.quaternion.y,u.quaternion.z,u.quaternion.w),f||c.set(u.scale.x,u.scale.y,u.scale.z);for(let m=0;m<i.length;m++){const A=i[m];if(d){const v=d.evaluate(A);a.set(v[0],v[1],v[2])}if(p){const v=p.evaluate(A);l.set(v[0],v[1],v[2],v[3])}if(f){const v=f.evaluate(A);c.set(v[0],v[1],v[2])}if(this.useRootMotion&&u===this.root){const v=new Ce;v.compose(a,l,c),v.multiply(u.matrix),v.decompose(a,l,c)}yield{time:A,translation:a,rotation:l,scale:c,index:m}}}};let Jr=h4;h(Jr,"animationDurationPadding",1/60),h(Jr,"restPoseClipDuration",1/60);class Bv{constructor(e){h(this,"dict",new Map),h(this,"rootTargetMap",new Map),h(this,"rootAndClipToRegisteredAnimationMap",new Map),h(this,"rootToRegisteredClipCount",new Map),h(this,"serializers",[]),h(this,"injectRestPoses",!1),h(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(Jr.restPoseClipDuration+Jr.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[t,n]of this.rootAndClipToRegisteredAnimationMap){const r=n.start+n.duration;r>e&&(e=r)}return e*60}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const n=this.rootTargetMap.get(e);if(!n)return 0;const r=this.dict.get(n[0]);if(!r)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let s=0;for(let o=0;o<r.length&&r[o].clip!==t;o++)s+=r[o].getDuration()+Jr.animationDurationPadding;return s}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const n=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(n))return this.rootAndClipToRegisteredAnimationMap.get(n);nd&&console.log("registerAnimation",e,t);const r=this.injectRestPoses?1:0,s=this.rootToRegisteredClipCount.get(e)??r,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const c of t.tracks){const u=Qt.parseTrackName(c.name),d=Qt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",c.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const p=this.dict.get(d);if(!p){console.warn("no transform data found for target ",d,"at slot "+s+", this is likely a bug");continue}if(a.delete(d),this.injectRestPoses&&!p[0]){const m=new Jr(null,d,void 0);p[0]=m}let f=p[s];f||(f=new Jr(e,d,t),p[s]=f),f.addTrack(c),o!=null&&o.includes(d)||o==null||o.push(d)}for(const c of a){const u=this.dict.get(c);if(!u)continue;if(this.injectRestPoses&&!u[0]){const p=new Jr(null,c,void 0);u[0]=p}let d=u[s];d||(nd&&console.log("Adding padding clip for ",c,t,"at slot",s),d=new Jr(e,c,t),u[s]=d)}const l=new tx(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(n,l),this.rootToRegisteredClipCount.set(e,s+1),l}onAfterHierarchy(e){nd&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,n;for(const r of this.serializers){const s=(t=r.model)==null?void 0:t.parent,o=s?.isDynamic===!0;lI&&console.log(o,(n=r.model)==null?void 0:n.parent),o&&r.registerCallback(s)}}onExportObject(e,t,n){re.foreachComponent(e,s=>{const o=s;typeof o.createAnimation=="function"&&o.createAnimation(this,t,n)},!1);const r=new one(e,this.dict);this.serializers.push(r),r.registerCallback(t)}}class one{constructor(e,t){h(this,"object"),h(this,"dict"),h(this,"model"),h(this,"callback"),this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),lI&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){var n;const r=this.model,s=this.dict;if(r&&r.skinnedMesh){let o=function(M){const D=[];for(const[C,P]of M){let j=`${C} : [`;const Q=[];for(const O of P)Q.push(`(${$n(O.x)}, ${$n(O.y)}, ${$n(O.z)})`);j=j.concat(Q.join(", ")),j=j.concat("],"),D.push(j)}return D},a=function(M){const D=[];for(const[C,P]of M){let j=`${C} : [`;const Q=[];for(const O of P)Q.push(`(${$n(O.w)}, ${$n(O.x)}, ${$n(O.y)}, ${$n(O.z)})`);j=j.concat(Q.join(", ")),j=j.concat("],"),D.push(j)}return D},l=function(M){let D,C=!0;const P=new Map;for(const[Q,O]of M){D===void 0&&(D=O.length),D!==O.length&&(C=!1);let W=0;for(const L of O)W++,L||(P.has(Q)||P.set(Q,[]),P.get(Q).push(W))}nd&&console.log("Bone count: ",M.size,"TransformData entries per bone: ",D,"Undefined bone entries: ",P),console.assert(C,"All bones should have the same number of TransformData entries",M),console.assert(P.size===0,"All TransformData entries should be set",P);const j=[];for(const[Q,O]of M){const W=new Array;let L=0;for(let F=0;F<O.length;F++)W.push(L),L+=O[F].getDuration()+Jr.animationDurationPadding;for(let F=0;F<O.length;F++){const z=O[F],Z=W[F];j.length<=F&&j.push({pos:[],rot:[],scale:[],timeOffset:Z});const K=j[F];K.pos.push(...z.getSortedTimesArray(!0,!1,!1)),K.rot.push(...z.getSortedTimesArray(!1,!0,!1)),K.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const Q of j)Q.pos.sort((O,W)=>O-W),Q.rot.sort((O,W)=>O-W),Q.scale.sort((O,W)=>O-W),Q.pos=[...new Set(Q.pos)],Q.rot=[...new Set(Q.rot)],Q.scale=[...new Set(Q.scale)];return j},c=function(M,D,C){const P=new Map,j=new Map,Q=new Map,O=D.length;for(const W of C){const L=M.get(W);let F;L?console.assert(L.length===O,"We should have the same number of TransformData entries for each bone",L,D):F=new Jr(null,W,void 0);for(let z=0;z<O;z++){const Z=L?L[z]:F,K=D[z];for(const{time:se,translation:Ae}of Z.getValues(K.pos,!0,!1,!1)){const Pe=(se+K.timeOffset)*60;P.has(Pe)||P.set(Pe,new Array),P.get(Pe).push(Ae.clone())}for(const{time:se,rotation:Ae}of Z.getValues(K.rot,!1,!0,!1)){const Pe=(se+K.timeOffset)*60;j.has(Pe)||j.set(Pe,new Array),j.get(Pe).push(Ae.clone())}for(const{time:se,scale:Ae}of Z.getValues(K.scale,!1,!1,!0)){const Pe=(se+K.timeOffset)*60;Q.has(Pe)||Q.set(Pe,new Array),Q.get(Pe).push(Ae.clone())}}}return{position:P.size==0?void 0:P,quaternion:j.size==0?void 0:j,scale:Q.size==0?void 0:Q}},u=function(M){const D=[];for(const C of M)D.push(`(${$n(C.x)}, ${$n(C.y)}, ${$n(C.z)})`);return D.join(", ")},d=function(M){const D=[];for(const C of M)D.push(`(${$n(C.w)}, ${$n(C.x)}, ${$n(C.y)}, ${$n(C.z)})`);return D.join(", ")},p=function(M){const D=new Map;if(nd){const C=new Array;for(const[P,j]of s)C.push(P.uuid+": "+j.length+" "+j.map(Q=>{var O;return(O=Q.clip)==null?void 0:O.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+C.join(`
|
|
5508
5508
|
`))}for(const C of M){const P=s.get(C);P&&D.set(C,P)}return D},f=function(M){const D=p(M),C=l(D);return c(D,C,M)};const m=r.skinnedMesh.skeleton,A=new Array;for(const M in m.bones){const D=m.bones[M],C=m.boneInverses[M];A.push({bone:D,inverse:C})}for(const M of jL(m.bones))A.push({bone:M,inverse:M.matrixWorld.clone().invert()});const v=A[0].bone.parent;v||console.error("No bone parent found for skinned mesh during USDZ export",r.skinnedMesh),A.sort((M,D)=>Hp(M.bone,v)>Hp(D.bone,v)?1:-1);const g=[],y=[],b=[],_=[];for(const{bone:M}of A)g.push(M.matrix.clone()),y.push(M.position),b.push(M.quaternion),_.push(M.scale);const E=A.map(M=>'"'+Hp(M.bone,v)+'"').join(", "),I=A.map(M=>Vp(M.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${I}]`),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${g.map(M=>Vp(M)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${Vp(new Ce)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=f(A.map(M=>M.bone));if(nd){let M=1e7,D=0;for(const C of((n=T.position)==null?void 0:n.keys())??[])M=Math.min(M,C),D=Math.max(D,C);console.log("Time samples",M,D,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${E}]`),e.appendLine(`quatf[] rotations = [${d(b)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const M=a(T.quaternion);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(_)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const M=o(T.scale);for(const D of M)e.appendLine(D);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(y)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const M=o(T.position);for(const D of M)e.appendLine(D);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var n;if(!this.model)return;const r=this.dict.get(this.object);if(r)for(let u=0;u<r.length;u++)r[u]===void 0&&(r[u]=new Jr(null,this.object,void 0));this.skinnedMeshExport(e,t);const s=this.object,o=this.dict.get(s);if(!o||s.isSkinnedMesh)return;lI&&console.log("SERIALIZE",this.model.name,this.object.type,o);const a=new Ce;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const l=new Array;let c=0;for(let u=0;u<o.length;u++){if(l.push(c),o[u]===void 0){console.error("Got an undefined transform data, this is likely a bug.",s,o);continue}c+=o[u].getDuration()+Jr.animationDurationPadding}for(let u=0;u<o.length;u++){const d=o[u];if(!d)continue;const p=l[u];{const f=d.getSortedTimesArray();if(!f||f.length===0){console.error("got an animated object but no time values?",s,d);continue}if(nd){const m=((n=d.clip)==null?void 0:n.name)??"rest",A=d.getDuration();console.log("Write .timeSamples:",m,p,A,o),e.appendLine("# "+m+": start="+(p*d.frameRate).toFixed(3)+", length="+(A*d.frameRate).toFixed(3)+", frames="+d.getFrames())}for(const{time:m,translation:A,rotation:v,scale:g}of d.getValues(f)){a.compose(A,v,g);const y=`${(p+m)*d.frameRate}: ${Vp(a)},`;e.appendLine(y)}}}e.indent--,e.appendLine("}")}}var ane=Object.defineProperty,lne=Object.getOwnPropertyDescriptor,u4=(i,e,t,n)=>{for(var r=n>1?void 0:n?lne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&ane(e,t,r),r};const d4=ee("debugpost");class Rt{constructor(e){h(this,"_active",!0),h(this,"_value"),h(this,"_valueRaw"),h(this,"_defaultValue"),h(this,"valueProcessor"),h(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const n=this._value;if(d4){let r=!0;if(typeof n=="number"&&typeof e=="number"){const s=n?.toFixed(4),o=e?.toFixed(4);s!=o?r=!0:r=!1}r&&console.log("VolumeParameter: value changed from",n,"to",e)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged?this.onValueChanged(e,n,this):d4&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}u4([x()],Rt.prototype,"overrideState",1),u4([x()],Rt.prototype,"value",1);var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,une=(i,e,t,n)=>{for(var r=n>1?void 0:n?hne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&cne(e,t,r),r};const dne=ee("debugpost");class Kr extends Ie{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const n=e[t],r=this[t];r instanceof Rt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){dne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const n=this[t];n instanceof Rt&&n.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===Rt){const s=e[r];if(s!==void 0){const o=this[r];o.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Rt){const n=e.value;return this[t].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Rt&&(this[t]||(this[t]=new Rt))}}une([x()],Kr.prototype,"active",2);var pne=Object.defineProperty,fne=Object.getOwnPropertyDescriptor,mne=(i,e,t,n)=>{for(var r=n>1?void 0:n?fne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&pne(e,t,r),r};const gne=ee("debugpost"),cI={};function Ho(i,e){cI[i]=e}function vne(i){return i.__type in cI?cI[i.__type]:(gne&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Kr)}class Dv{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}mne([qp([i=>vne(i),Kr])],Dv.prototype,"components",2);var Ane=Object.defineProperty,yne=Object.getOwnPropertyDescriptor,bne=(i,e,t,n)=>{for(var r=n>1?void 0:n?yne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ane(e,t,r),r};class kv extends Kr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new XU({preset:Jp.HIGH,edgeDetectionMode:NM.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}bne([x(Rt)],kv.prototype,"preset",2),Ho("Antialiasing",kv);const _ne=ee("debugusdz");class Hh{constructor(){h(this,"files",new Array)}static getName(e){var t;const n=e.split(".").pop();let r=(t=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:t.replace(".","_");return r||(r="Audio_"+Math.random().toString(36).substring(2,15)),Vl(r)+"."+n}get extensionName(){return"Audio"}onExportObject(e,t,n){const r=re.getComponents(e,en);if(r.length)for(const s of r){if(!s.clip||typeof s.clip!="string"||!s.playOnAwake)continue;const o=s.clip.split("/").pop()||"Audio",a=Hh.getName(s.clip),l=Vl(a);this.files.some(c=>c.path===s.clip)||this.files.push({path:s.clip,name:a}),n.quickLookCompatible||t.addEventListener("serialize",(c,u)=>{c.appendLine(),c.beginBlock(`def SpatialAudio "${l}"`,"(",!1),c.appendLine(`displayName = "${o}"`),c.closeBlock(")"),c.beginBlock(),c.appendLine(`uniform asset filePath = @audio/${a}@`),c.appendLine(`uniform token auralMode = "${s.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${s.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${s.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const n="audio/"+t.name;if(e.files[n]){_ne&&console.warn("Audio file with name "+n+" already exists in the context. Skipping.");continue}const r=await(await(await fetch(t.path)).blob()).arrayBuffer(),s=new Uint8Array(r);e.files[n]=s}}}const rd=ee("debugautosync"),hI=Symbol("syncerId");class xne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new wne(e);return t[hI]=e.guid,this._syncers[t[hI]]=t,t}removeSyncer(e){delete this._syncers[e[hI]]}}const uI=new xne;class wne{constructor(e){h(this,"comp"),h(this,"hasChanges",!1),h(this,"changedProperties",{}),h(this,"data",{}),h(this,"_boundEvent"),h(this,"_handleReceivingMethod"),h(this,"_isReceiving",!1),h(this,"_isInit",!1),this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,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 t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}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(e,t){this._isReceiving||(rd&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}onHandleSending(){if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected){for(const t in this.changedProperties)delete this.changedProperties[t];return}for(const t in this.data)delete this.data[t];this.data.guid=this.comp.guid;for(const t in this.changedProperties){const n=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=n}e.send(this.networkingKey,this.data)}onHandleReceiving(e){if(rd&&console.log("RECEIVE",this.comp.name,this.comp.guid,e),!this._isInit||!this.comp)return;const t=e.guid;if(!(t&&t!==this.comp.guid)){rd&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const n in e){if(n==="guid")continue;const r=e[n];this.comp[n]=r,rd&&console.log("SET",n,r)}}catch(n){console.error(n)}finally{this._isReceiving=!1}}}}function Sne(i,e){let t=e!==i;return!t&&i&&e&&(Array.isArray(i)&&Array.isArray(e)||typeof i=="object"&&typeof e=="object")&&(t=!0),t}const Ov=Symbol("AutoSyncHandler");function Cne(i){if(i[Ov])return i[Ov];const e=uI.getOrCreateSyncer(i);return e?.init(i),i[Ov]=e,e}function Ene(i){const e=i[Ov];e&&(uI.removeSyncer(e),e.destroy(),delete i[Ov])}const dI=function(i){return function(e,t){var n;let r="";typeof t=="string"?r=t:r=t.name;let s=null,o;typeof i=="string"?o=e[i]:typeof i=="function"&&(o=i);const a=e,l=a.__internalAwake;if(typeof l!="function"){(rd||ut())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((n=e?.constructor)==null?void 0:n.name)+'" is not supported',e);return}rd&&console.log(r);const c=Symbol(r);a.__internalAwake=function(){if(this[c]!==void 0)return;this[c]=this[r],s=uI.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,r);if(d?.set===void 0){let p=!1;Object.defineProperty(this,r,{set:function(f){var m;const A=this[c];if(this[c]=f,p){ut()&&console.warn("Recursive call detected",r);return}p=!0;try{const v=Sne(f,A);rd&&console.log("SyncField assignment",r,"changed?",v,f),v&&o?.call(this,f,A)!==!1&&((m=Cne(this))==null||m.notifyChanged(r,f))}finally{p=!1}},get:function(){return this[c]},configurable:!0,enumerable:!0})}s?.init(this),l.call(this)};const u=a.__internalDestroy;a.__internalDestroy=function(){Ene(this),u.call(this)}}};var Mne=Object.defineProperty,Tne=Object.getOwnPropertyDescriptor,ix=(i,e,t,n)=>{for(var r=n>1?void 0:n?Tne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Mne(e,t,r),r};const so=ee("debugplayersync");class bf extends Ie{constructor(){super(...arguments),h(this,"autoSync",!0),h(this,"asset"),h(this,"onPlayerSpawned"),h(this,"_localInstance"),h(this,"onJoinedRoom",()=>{so&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Hn)}onEnable(){this.context.connection.beginListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Kt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom)}async getInstance(){var e,t,n,r,s,o;if(this._localInstance)return this._localInstance;if(so&&console.log("PlayerSync.createInstance",(e=this.asset)==null?void 0:e.uri),!((t=this.asset)!=null&&t.asset)&&!((n=this.asset)!=null&&n.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(r=this.asset)==null?void 0:r.instantiateSynced({parent:this.gameObject},!0);const a=await this._localInstance;if(a){const l=re.getComponent(a,Vo);l?(l.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(a)):(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!"),re.destroySynced(a))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(so&&console.log("PlayerSync.destroyInstance",t),re.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=Vo.all.length-1;t>=0;t--){const n=Vo.all[t];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}ix([x()],bf.prototype,"autoSync",2),ix([x(Zt)],bf.prototype,"asset",2),ix([x(Hn)],bf.prototype,"onPlayerSpawned",2);var p4=(i=>(i.OwnerChanged="ownerChanged",i))(p4||{}),Lv;const Cr=(Lv=class extends Ie{constructor(){super(...arguments),h(this,"onOwnerChangeEvent",new Hn),h(this,"onFirstOwnerChangeEvent",new Hn),h(this,"hasOwner",!1),h(this,"owner"),h(this,"dontDestroy",!1),h(this,"onUserLeftRoom",i=>{if(i.userId===this.owner){so&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Cr._all}static get local(){return Cr._local}static getFor(i){if(i instanceof ge)return re.getComponentInParent(i,Cr);if(i instanceof Ie)return re.getComponentInParent(i.gameObject,Cr)}static isLocalPlayer(i){const e=Cr.getFor(i);return e?.isLocalPlayer??!1}static addEventListener(i,e){return this._callbacks[i]||(this._callbacks[i]=[]),this._callbacks[i].push(e),e}static removeEventListener(i,e){if(!this._callbacks[i])return;const t=this._callbacks[i].indexOf(e);t>=0&&this._callbacks[i].splice(t,1)}static dispatchEvent(i,e){if(this._callbacks[i])for(const t of this._callbacks[i])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(i,e){var t,n;so&&console.log("PlayerSync.onOwnerChange",this,"newOwner",i,"oldOwner",e);const r=Cr._local.indexOf(this);r>=0&&Cr._local.splice(r,1);const s={playerState:this,oldValue:e,newValue:i};if(this.hasOwner||(this.hasOwner=!0,(t=this.onFirstOwnerChangeEvent)==null||t.invoke(s)),(n=this.onOwnerChangeEvent)==null||n.invoke(s),this.owner===this.context.connection.connectionId){Cr._local.push(this);const a=new CustomEvent("local-owner-changed",{detail:s});this.dispatchEvent(a)}const o=new CustomEvent("owner-changed",{detail:s});this.dispatchEvent(o),Cr.dispatchEvent("ownerChanged",o)}awake(){Cr.all.push(this),so&&console.log("Registered new PlayerState",this.guid,Cr.all.length-1,Cr.all),this.context.connection.beginListen(Kt.UserLeftRoom,this.onUserLeftRoom)}async start(){so&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await ca(300),this.context.connection.userIsInRoom(this.owner)==!1&&(so&&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||(so&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?so&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(so&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):so&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){so&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),I_(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeftRoom),Cr.all.splice(Cr.all.indexOf(this),1),this.isLocalPlayer){const i=Cr._local.indexOf(this);i>=0&&Cr._local.splice(i,1)}}},h(Lv,"_all",[]),h(Lv,"_local",[]),h(Lv,"_callbacks",{}),Lv);let Vo=Cr;ix([dI(Vo.prototype.onOwnerChange)],Vo.prototype,"owner",2);const Ine=ee("debugavatar"),$a=class extends Ie{constructor(){super(...arguments),h(this,"connectionId"),h(this,"avatar")}static getAvatar(i){return i>=0&&i<$a.instances.length?$a.instances[i]:null}static onAvatarMarkerCreated(i){return $a._onNewAvatarMarkerAdded.push(i),i}static onAvatarMarkerDestroyed(i){return $a._onAvatarMarkerDestroyed.push(i),i}awake(){$a.instances.push(this),Ine&&console.log(this);for(const i of $a._onNewAvatarMarkerAdded)i({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){$a.instances.splice($a.instances.indexOf(this),1);for(const i of $a._onAvatarMarkerDestroyed)i({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Er=$a;h(Er,"instances",[]),h(Er,"_onNewAvatarMarkerAdded",[]),h(Er,"_onAvatarMarkerDestroyed",[]);var Rne=Object.defineProperty,Pne=Object.getOwnPropertyDescriptor,Bne=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Rne(e,t,r),r};const _f=ee("debugxrflags"),f4=ee("disablexrflags");f4&&console.warn("XRFlags are disabled");var el=(i=>(i[i.Never=0]="Never",i[i.Browser=1]="Browser",i[i.AR=2]="AR",i[i.VR=4]="VR",i[i.FirstPerson=8]="FirstPerson",i[i.ThirdPerson=16]="ThirdPerson",i[i.All=4294967295]="All",i))(el||{});const m4=class{constructor(){h(this,"Mask",17)}Has(i){return(this.Mask&i)!==0}Set(i){_f&&console.warn("Set XR flag state to",i),this.Mask=i,oo.Apply()}Enable(i){this.Mask|=i,oo.Apply()}Disable(i){this.Mask&=~i,oo.Apply()}Toggle(i){this.Mask^=i,oo.Apply()}EnableAll(){this.Mask=-1,oo.Apply()}DisableAll(){this.Mask=0,oo.Apply()}};let ws=m4;h(ws,"Global",new m4);var Uv;const sc=(Uv=class extends Ie{constructor(){super(...arguments),h(this,"visibleIn")}static Apply(){for(const i of this.registry)i.UpdateVisible(ws.Global)}awake(){sc.registry.push(this)}onEnable(){sc.firstApply?this.UpdateVisible(ws.Global):(sc.firstApply=!0,sc.Apply())}onDestroy(){const i=sc.registry.indexOf(this);i>=0&&sc.registry.splice(i,1)}get isOn(){return this.gameObject.visible}UpdateVisible(i=null){if(f4)return;let e;const t=i;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),_f&&console.log(t),sc.buffer.Mask=t,i=sc.buffer),i instanceof ws?(_f&&console.warn(this.name,"use passed in mask",i.Mask,this.visibleIn),e=i.Has(this.visibleIn)):(_f&&console.log(this.name,"use global mask"),ws.Global.Has(this.visibleIn)),e!==void 0)if(e)_f&&console.log(this.name,"is visible",this.gameObject.uuid),re.setActive(this.gameObject,!0);else{if(_f&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(Uv,"registry",[]),h(Uv,"firstApply"),h(Uv,"buffer",new ws),Uv);let oo=sc;Bne([x()],oo.prototype,"visibleIn",2);var Dne=Object.defineProperty,kne=Object.getOwnPropertyDescriptor,pI=(i,e,t,n)=>{for(var r=n>1?void 0:n?kne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Dne(e,t,r),r};const Fv=ee("debugwebxr"),g4=new Me().setFromAxisAngle(new S(0,1,0),Math.PI);class sd extends Ie{constructor(){super(...arguments),h(this,"head"),h(this,"leftHand"),h(this,"rightHand"),h(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;Fv&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=Vo.getFor(this);if(t!=null&&t.owner){const n=this.gameObject.addNewComponent(Er);n.avatar=this.gameObject,n.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(Er);t&&t.destroy()}onUpdateXR(e){var t,n;if(!this.activeAndEnabled)return;const r=Vo.isLocalPlayer(this);if(!r)return;const s=e.xr;if(s.rig&&s.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),s.rig.gameObject.add(this.gameObject)),this._syncTransforms&&r)for(const c of this._syncTransforms)c.fastMode=!0,c.isOwned()||c.requestOwnership();if(this.head&&this.context.mainCamera){const c=this.head.asset;if(c.position.copy(this.context.mainCamera.position),c.quaternion.copy(this.context.mainCamera.quaternion),c.quaternion.x*=-1,this.context.time.frameCount%10===0){const u=re.getComponentsInChildren(this.head.asset,oo);for(const d of u)d.enabled=!1,d.gameObject.visible=!1}}const o=e.xr.leftController,a=(t=this.leftHand)==null?void 0:t.asset;o&&a&&(a.position.copy(o.gripPosition),a.quaternion.copy(o.gripQuaternion),a.quaternion.multiply(g4),a.visible=o.isTracking);const l=e.xr.rightController;if(l&&(n=this.rightHand)!=null&&n.asset){const c=this.rightHand.asset;c.position.copy(l.gripPosition),c.quaternion.copy(l.gripQuaternion),c.quaternion.multiply(g4),c.visible=l.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,n;if(this.context.connection.isConnected){const r=Vo.getFor(this);if(r&&r.isLocalPlayer==!1){const s=_t.getXRSync(this.context);if(s&&s.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const o=(e=this.leftHand)==null?void 0:e.asset;o&&(o.visible=s?.isTracking(r.owner,"left")??!1);const a=(t=this.rightHand)==null?void 0:t.asset;a&&(a.visible=s?.isTracking(r.owner,"right")??!1)}if((n=this.head)!=null&&n.asset){const o=re.getComponentsInChildren(this.head.asset,oo);for(const a of o)a.enabled=!1,a.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};XF.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof ge&&(this.head=new Zt("",this.sourceId,this.head));else{const e=new ge;e.name="Head";const t=rv.createPrimitive(Wu.Cube);e.add(t),this.gameObject.add(e),this.head=new Zt("",this.sourceId,e),Fv&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof ge&&(this.rightHand=new Zt("",this.sourceId,this.rightHand));else{const e=new ge;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new Zt("",this.sourceId,e),Fv&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof ge&&(this.leftHand=new Zt("",this.sourceId,this.leftHand));else{const e=new ge;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new Zt("",this.sourceId,e),Fv&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),Vo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=re.getComponentsInChildren(this.gameObject,vh))}async loadAvatarObjects(e,t,n){const r=e.loadAssetAsync(),s=t.loadAssetAsync(),o=n.loadAssetAsync(),a=new Array;r&&a.push(r),s&&a.push(s),o&&a.push(o);const l=await ag(a);Fv&&console.log("Avatar loaded results:",l)}}pI([x(Zt)],sd.prototype,"head",2),pI([x(Zt)],sd.prototype,"leftHand",2),pI([x(Zt)],sd.prototype,"rightHand",2);class tl{static Add(e,t,n=null){if(t){for(const r of this.Pois)if(r.obj===t)return;this.Pois.push({obj:t,avatar:n}),this.LastChangeTime=e.time.time}}static Remove(e,t){var n;if(t){for(const r of this.Pois)if(r.obj===t){this.Pois.splice(this.Pois.indexOf(r),1),this.LastChangeTime=e?.time.time??((n=Ot.Current)==null?void 0:n.time.time);return}}}}h(tl,"Pois",[]),h(tl,"LastChangeTime",0);class One{constructor(){h(this,"guid"),h(this,"position",new S)}}class Nv extends Ie{constructor(){super(...arguments),h(this,"target",null),h(this,"avatar",null),h(this,"_model",null),h(this,"_targetModel",new One),h(this,"_currentTargetObject",null),h(this,"_lastUpdateTime",0),h(this,"_lookDuration",0),h(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=q.get("MoveRandom");if(t&&this.target){const n=re.getComponent(this.target,t);n&&n.destroy()}}awake(){if(this.avatar=re.getComponentInParent(this.gameObject,Er),this.avatar){const e=re.getComponentInParent(this.gameObject,Er);this._model=new IT(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&Vr(this.target,e.position)})}update(){var e;if((!this.context.connection.isConnected||(e=this._model)!=null&&e.hasOwnership)&&(tl.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=tl.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const t=Pt(this._currentTargetObject);Vr(this.target,t),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(t))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const e=tl.Pois;if(e.length>0){const t=e[Math.floor(Math.random()*e.length)];if(t&&t.obj){if(t.avatar&&t.avatar===this.avatar)return;this._currentTargetObject=t.obj}}}}}const xf=ee("debugnetworkingstreams");var il=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(il||{});class v4{constructor(e,t){h(this,"type","call-ended"),h(this,"userId"),h(this,"direction"),this.userId=e,this.direction=t}}class A4{constructor(e,t){h(this,"type","receive-stream"),h(this,"stream"),h(this,"target"),this.stream=e,this.target=t}}class Lne{constructor(e,t){h(this,"guid"),h(this,"peerId"),h(this,"dontSave",!0),this.guid=e.id,this.peerId=t}}var y4=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(y4||{});class Une extends Kn{constructor(e,t,n){super(),h(this,"userId"),h(this,"direction"),h(this,"call"),h(this,"_stream",null),h(this,"_isDisposed",!1),this.userId=e,this.call=t,this.direction=n,this._stream=null,t.on("stream",r=>{if(xf&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const s=new A4(r,this);this.dispatchEvent(s)}}),t.on("close",()=>{this.dispatchEvent(new v4(e,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),oc(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const zv=class extends Kn{constructor(i,e){super(),h(this,"id"),h(this,"context"),h(this,"_peer"),h(this,"_incomingCalls",[]),h(this,"_outgoingCalls",[]),h(this,"_enabled",!1),h(this,"_enabledPeer",!1),h(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),h(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),h(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=i,this.id=e,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(i,e){if(zv.instances.has(e))return zv.instances.get(e);const t=new zv(i,e);return zv.instances.set(e,t),t}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(i){return this.id+"-"+i}getUserIdFromPeerId(i){return i.substring(this.id.length+1)}makeCall(i,e){var t;const n={metadata:{userId:this.context.connection.connectionId}},r=(t=this._peer)==null?void 0:t.call(i,e,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Kt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Kt.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const i=this.getMyPeerId();i?this._peer=LF(i):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(i){xf&&console.log("Peer connected as",i),this.context.connection.send("peer-user-connected",new Lne(this,i))}onPeerReceivingCall(i){i.answer(),this.registerCall(i,"incoming")}registerCall(i,e){const t=i.metadata;(!t||!t.userId)&&console.error("Missing call metadata",i);const n=t.userId;e==="incoming"&&xf?console.log("Receive call from",i.metadata):xf&&console.log("Make call to",i.metadata);const r=e==="incoming"?this._incomingCalls:this._outgoingCalls,s=new Une(n,i,e);return r.push(s),i.on("error",o=>{console.error("Call error",o)}),i.on("close",()=>{xf&&console.log("Call ended",i.metadata),i.close();const o=r.indexOf(s);o!==-1&&r.splice(o,1)}),s.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),e==="incoming"&&(s.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),i.on("stream",()=>{let o=0;const a=setInterval(()=>{const l=o===0;!s.isOpen&&l&&(o+=1,clearInterval(a),s.close())},2e3)})),s}};let nx=zv;h(nx,"instances",new Map);class sA extends Kn{constructor(e,t){super(),h(this,"context"),h(this,"peer"),h(this,"_sendingStreams",new Map),h(this,"debug",!1),h(this,"onJoinedRoom",n=>{this.debug&&console.log(`${n.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),h(this,"onReceiveStream",n=>{this.debug&&console.log("RECEIVE STREAM",n),this.dispatchEvent({type:"receive-stream",target:this,stream:n.stream,userId:n.userId})}),h(this,"onCallEnded",n=>{this.dispatchEvent(n)}),h(this,"onUserConnected",n=>{if(this.peer.id===n.guid){this.debug&&console.log("USER CONNECTED",n.guid,n);const r=this._sendingStreams.keys().next().value;this.peer.makeCall(n.peerId,r)}}),h(this,"onUserLeft",n=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=e,this.peer=t,xf&&(this.debug=!0)}static create(e){const t=nx.getOrCreate(e.context,e.context.connection.connectionId);return new sA(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const n of t)n.close()}this._sendingStreams.delete(e),t&&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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Kt.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(Kt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Kt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var e;let t=!1;const n=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const s=this._sendingStreams.get(r)||[];for(const o of this.context.connection.usersInRoom()){if(o===n)continue;const a=s.find(l=>l.userId===o);if(!a||((e=a.stream)==null?void 0:e.active)===!1){this.debug&&console.log("Starting call to",o,n);const l=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),r);l&&(t=!0,s.push(l))}}this._sendingStreams.set(r,s)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let n=t.length-1;n>=0;n--){const r=t[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),t.splice(n,1))}}}}function oc(i){if(i&&i instanceof MediaStream)for(const e of i.getTracks())e.stop()}var Fne=Object.defineProperty,Nne=Object.getOwnPropertyDescriptor,b4=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Fne(e,t,r),r};const zne="noVoip",jne=ee("debugvoip");class od extends Ie{constructor(){super(...arguments),h(this,"autoConnect",!1),h(this,"runInBackground",!0),h(this,"debug",!1),h(this,"_net"),h(this,"_outputStream",null),h(this,"onJoinedRoom",async()=>{await ca(300),this.autoConnect&&!this.isSending&&this.connect()}),h(this,"_incomingStreams",new Map),h(this,"onReceiveStream",e=>{const t=e.target.userId,n=e.stream,r=this._incomingStreams.get(t);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const s=new Audio;this._incomingStreams.set(t,s),s.setAttribute("autoplay","true"),s.srcObject=n}}),h(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);oc(t?.srcObject),this._incomingStreams.delete(e.userId)}),h(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}}),h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const e=document.visibilityState!=="visible";this.setMuted(e);for(const t of this._incomingStreams){const n=t[1];n.muted=e}})}awake(){jne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=sA.create(this)),this._net.addEventListener(il.StreamReceived,this.onReceiveStream),this._net.addEventListener(il.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Kt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(il.StreamReceived,this.onReceiveStream),this._net.removeEventListener(il.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(Kt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await DC())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),oc(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await DC()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):IE("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),oc(this._outputStream),this._outputStream=null}setMuted(e){var t;const n=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(n)for(const r of n)r.enabled=!e}get isMuted(){var e;if(this._outputStream===null)return!1;const t=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,ut()&&$i("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(t=>(console.warn("VOIP failed getting audio stream",t),null)):(console.error("No getDisplayMedia support"),null)}}b4([x()],od.prototype,"autoConnect",2),b4([x()],od.prototype,"runInBackground",2);var Gne=Object.defineProperty,Qne=Object.getOwnPropertyDescriptor,_4=(i,e,t,n)=>{for(var r=n>1?void 0:n?Qne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Gne(e,t,r),r};const Hne=ee("debugmouth");class jv extends Ie{constructor(){super(...arguments),h(this,"idle",[]),h(this,"talking",[]),h(this,"marker",null),h(this,"voip",null),h(this,"lastMouthChangeTime",0),h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=re.findObjectOfType(od,this.context),this.marker||(this.marker=re.getComponentInParent(this.gameObject,Er))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Hne&&(t=null);return}const n=this.voip.getFrequency(t)??0;this.updateLips(n)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<e.length;n++){const r=e[n];r&&(r.visible=n===t)}}}}_4([x(ge)],jv.prototype,"idle",2),_4([x(ge)],jv.prototype,"talking",2);class fI extends Ie{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=re.findObjectOfType(od,this.context),this.marker=re.getComponentInParent(this.gameObject,Er)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=t/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var Vne=Object.defineProperty,Wne=Object.getOwnPropertyDescriptor,rx=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Vne(e,t,r),r};class ad extends Ie{constructor(){super(...arguments),h(this,"eyes",[]),h(this,"lastBlinkTime",0),h(this,"blinkLength",0),h(this,"eyesOpen",!0),h(this,"state",null)}awake(){this.state=re.getComponentInParent(this.gameObject,oo)}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 e of this.eyes)e&&(e.visible=this.eyesOpen)}}}rx([x(ge)],ad.prototype,"eyes",2),rx([x()],ad.prototype,"lastBlinkTime",2),rx([x()],ad.prototype,"blinkLength",2),rx([x()],ad.prototype,"eyesOpen",2);var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,mI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Xne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&qne(e,t,r),r},gI;const x4=(gI=class extends Ie{constructor(){super(...arguments),h(this,"head",null),h(this,"eyes",null),h(this,"target",null),h(this,"brain",null),h(this,"vec",new S),h(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=re.getComponentInParent(this.gameObject,Nv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=re.addNewComponent(this.gameObject,Nv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=Pt(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const n=Pt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const s=x4.forward;if(s.set(0,0,1),s.applyQuaternion(xi(this.head)),s.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(gI,"forward",new S(0,0,1)),gI);let wf=x4;mI([x(ge)],wf.prototype,"head",2),mI([x(ge)],wf.prototype,"eyes",2),mI([x(ge)],wf.prototype,"target",2);const Gv=ee("debugavatar");class sx{constructor(e,t,n,r){h(this,"root"),h(this,"head"),h(this,"leftHand"),h(this,"rigthHand");var s;this.root=e,this.head=t,this.leftHand=n,this.rigthHand=r,(s=this.root)==null||s.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class vI{constructor(){h(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let n=null;if(typeof t=="string"){if(n=await this.loadAvatar(e,t),!n){const s=new Ia;n=re.instantiate(Ip(t,e.scene),s)}}else n=t;if(!n)return null;const r=this.findAvatar(n);return r.isValid?(Gv&&console.log("[Custom Avatar] valid config",t,Gv?r:""),r):(console.warn("[Custom Avatar] config isn't valid",t,Gv?r:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(Gv&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const r=await fetch("./"+t);let s=null;if(r.ok){const a=await r.blob();a&&(s=await a.arrayBuffer())}if(!s&&(s=await tT(t,t,0,"no url here go away",!0),!s))return null;const o=await ta().parseSync(e,s,null,0);return o?.scene??null}const n=new Fp;return Cg(n,e),new Promise((r,s)=>{const o=this.avatarRegistryUrl+"/"+t;n.load(o,async a=>{await ta().createBuiltinComponents(e,o,a,null,void 0),r(a.scene)},a=>{Gv&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),r(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let n=t;n.children.length==1&&(n=e.children[0]);let r=this.findAvatarPart(n,["head"]);const s=this.findAvatarPart(n,["left","hand"]),o=this.findAvatarPart(n,["right","hand"]);if(!r){r=t;const a=new S;new fi().setFromObject(r).getSize(a);const l=Math.max(a.x,a.y,a.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+l+" meters! Should be < 0.3m"),l>.3&&r.scale.multiplyScalar(1/l*.3)}return new sx(t,r,s,o)}findAvatarPart(e,t){const n=e.name.toLowerCase();let r=!0;for(const s of t){if(!r)break;n.indexOf(s)===-1&&(r=!1)}if(r)return e;if(e.children)for(const s of e.children){const o=this.findAvatarPart(s,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,AI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Yne(e,t,r),r};class Sf extends Ie{constructor(){super(...arguments),h(this,"length",1),h(this,"depthTest",!0),h(this,"isGizmo",!0),h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Vg)return;this._axes||(this._axes=new Mo(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}AI([x()],Sf.prototype,"length",2),AI([x()],Sf.prototype,"depthTest",2),AI([x()],Sf.prototype,"isGizmo",2);class yI extends Ie{constructor(){super(...arguments),h(this,"from"),h(this,"to"),h(this,"hint"),h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=Pt(this.to).clone(),t=Pt(this.from).clone(),n=e.distanceTo(t),r=e.clone();r.sub(t);const s=t.clone();s.add(e),s.multiplyScalar(.5);const o=Pt(this.hint).clone();o.sub(s);const a=new S;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=n*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(s),Vr(this.gameObject,d);const p=s.clone();p.sub(a),this.gameObject.lookAt(p)}}const Kne=ee("debugusdzbehaviours");class ox{constructor(){h(this,"behaviours",[]),h(this,"behaviourComponents",[]),h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(n=>{re.foreachComponent(n,r=>{var s;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(s=o.beforeCreateDocument)==null?void 0:s.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,n){var r;for(const s of this.behaviourComponents)(r=s.createBehaviours)==null||r.call(s,this,t,n)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var n;if((n=this.behaviours)!=null&&n.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){Kne&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e));this.behaviours.length=0}}var Zne=Object.defineProperty,$ne=Object.getOwnPropertyDescriptor,bI=(i,e,t,n)=>{for(var r=n>1?void 0:n?$ne(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Zne(e,t,r),r},_I;const w4=(_I=class extends Kr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>1*Math.PI*(1-i)):(this.threshold.valueProcessor=i=>i,this.intensity.valueProcessor=i=>i,this.scatter.valueProcessor=i=>100*(1-i))}onCreateEffect(){let i;if(this.selectiveBloom==null&&(this.selectiveBloom=w4.useSelectiveBloom),this.selectiveBloom){const e=i=new VU(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else i=new HM({blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{i.intensity=e},this.threshold.onValueChanged=e=>{i.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{i.luminancePass.enabled=!0,i.luminanceMaterial.smoothing=e},i}},h(_I,"useSelectiveBloom",!1),_I);let ld=w4;bI([x(Rt)],ld.prototype,"threshold",2),bI([x(Rt)],ld.prototype,"intensity",2),bI([x(Rt)],ld.prototype,"scatter",2),Ho("Bloom",ld);const Cf="NEEDLE_progressive",Zr=ee("debugprogressive"),xI=Symbol("needle-progressive-texture"),Ef=new Map;if(Zr){let i=function(){e+=1,Hi(`Toggle LOD level: ${e}<br/>Registered objects: ${Ef.size}`),console.log("Toggle LOD level",e,Ef);const n=ni.Current;Ef.forEach((r,s)=>{for(const o of r.keys){const a=s[o];if(a instanceof ft){const l=Ii.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=c,Ii.assignMeshLOD(n,r.sourceId,s,c),l&&(t=Math.max(t,l.lods.length-1))}else if(s instanceof It){Ii.assignTextureLOD(n,r.sourceId,s,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",n=>{n.key==="p"&&i()}),ni.registerCallback(pn.ContextCreated,n=>{const r=document.createElement("button");r.innerText="Toggle Progressive",r.onclick=i,n.context.menu.appendChild(r)})}function S4(i,e,t){var n;if(!Zr)return;Ef.has(i)||Ef.set(i,{keys:[],sourceId:t});const r=Ef.get(i);((n=r?.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const ao=class{constructor(i,e,t){h(this,"parser"),h(this,"sourceId"),h(this,"context"),this.parser=i,this.sourceId=e,this.context=t}get name(){return Cf}static getMeshLODInformation(i){const e=this.getAssignedLODInformation(i);return e!=null&&e.key?this.lodInfos.get(e.key):null}static hasLODLevelAvailable(i,e){var t;if(i instanceof It){for(const s of Object.keys(i)){const o=i[s];if(o instanceof gt&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(i instanceof hs){for(const s of i.children)if(s instanceof ue&&this.hasLODLevelAvailable(s,e))return!0}let n,r;if(i instanceof ue?n=i.geometry:i instanceof gt&&(n=i),n&&(t=n?.userData)!=null&&t.LODS){const s=n.userData.LODS;if(r=this.lodInfos.get(s.key),e===void 0)return r!=null;if(r)return Array.isArray(r.lods)?e<r.lods.length:e===0}return!1}static assignMeshLOD(i,e,t,n){if(!t)return Promise.resolve(null);if(t instanceof ue){const r=t.geometry,s=this.getAssignedLODInformation(r);if(!s)return Promise.resolve(null);av(t)||__(t,t.geometry);const o=this.onProgressiveLoadStart(i,e,t,null);return t["LOD:requested level"]=n,ao.getOrLoadLOD(i,e,r,n).then(a=>{if(t["LOD:requested level"]===n){if(delete t["LOD:requested level"],Array.isArray(a)){const l=s.index||0;a=a[l]}a&&r!=a&&(Zr=="verbose"&&console.log("Progressive Mesh "+t.name+" loaded",r,"\u2192",a,`
|
|
5509
|
-
`,t),a instanceof ft&&(t.geometry=a,Zr&&S4(t,"geometry",e)))}return this.onProgressiveLoadEnd(o),a}).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",t,a),null))}else Zr&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",t);return Promise.resolve(null)}static assignTextureLOD(i,e,t,n=0){if(!t)return Promise.resolve(null);if(t instanceof It){const r=t,s=[],o=new Array;if(r instanceof tg)for(const a of Object.keys(r.uniforms)){const l=r.uniforms[a].value;if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}else for(const a of Object.keys(r)){const l=r[a];if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}return ag(s).then(a=>{const l=new Array;for(let c=0;c<a.results.length;c++){const u=a.results[c],d=o[c];u instanceof gt?l.push({material:r,slot:d,texture:u,level:n}):l.push({material:r,slot:d,texture:null,level:n})}return l})}if(t instanceof gt){const r=t;return this.assignTextureLODForSlot(i,e,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(i,e,t,n,r,s){if(t?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(i,e,r,s);return ao.getOrLoadLOD(i,e,t,n).then(a=>Array.isArray(a)?null:a?.isTexture===!0?(a!=t&&(r&&s&&(r[s]=a),Zr&&s&&r&&S4(r,s,e)),this.onProgressiveLoadEnd(o),a):(Zr=="verbose"&&console.warn("No LOD found for",t,n),this.onProgressiveLoadEnd(o),null)).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",t,a),null))}afterRoot(i){var e,t;Zr&&console.log("AFTER",this.sourceId,i),(e=this.parser.json.textures)==null||e.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o){for(const a of this.parser.associations.keys())if(a instanceof gt&&this.parser.associations.get(a).textures===s){const l=a;Zr&&console.log("> Progressive: register texture",s,l.name,l.uuid,l,o),l.source&&(l.source[xI]=o);const c=l.uuid;ao.assignLODInformation(l,c,0,0,void 0),ao.lodInfos.set(c,o),ao.lowresCache.set(c,l)}}}});const n=(r,s,o,a,l)=>{const c=s.geometry;c["needle:raycast-mesh"]=!0,c&&!av(s)&&(Zr&&console.log("Set raycast mesh",s.name,s.uuid,c),__(s,c),Nb(c,!0).forEach(u=>{u instanceof ue&&__(u,c)})),c.userData||(c.userData={}),ao.assignLODInformation(c,r,o,a,l.density),ao.lodInfos.set(r,l)};return(t=this.parser.json.meshes)==null||t.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a instanceof ue){const l=this.parser.associations.get(a);if(l.meshes===s){const c=a;Zr&&console.log("> Progressive: register mesh",s,c.name,o,c.uuid,c);const u=c.uuid,d=o.lods.length;if(c instanceof ue){n(u,c,d,l.primitives,o);let p=ao.lowresCache.get(u);p?p.push(c.geometry):p=[c.geometry],ao.lowresCache.set(u,p)}}}}}}),null}static async getOrLoadLOD(i,e,t,n){var r,s,o;const a=Zr=="verbose",l=t.userData.LODS;if(!l)return null;const c=l?.key;let u;if(t instanceof gt&&t.source&&t.source[xI]&&(u=t.source[xI]),u||(u=ao.lodInfos.get(c)),u){if(n>0){let f=!1;const m=Array.isArray(u.lods);if(m&&n>=u.lods.length?f=!0:m||(f=!0),f)return this.lowresCache.get(c)}const d=Array.isArray(u.lods)?u.lods[n].path:u.lods;if(!d)return Zr&&!u["missing:uri"]&&(u["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,u)),null;
|
|
5510
|
-
`,b),null)),y=!1;if(g==null||(g instanceof gt&&t instanceof gt?(r=g.image)!=null&&r.data||(s=g.source)!=null&&s.data?g=this.copySettings(t,g):(y=!0,this.previouslyLoaded.delete(f)):g instanceof ft&&t instanceof ft&&((o=g.attributes.position)!=null&&o.array||(y=!0,this.previouslyLoaded.delete(f)))),!y)return g}const A=u,v=new Promise(async(g,y)=>{const b=new Fp;Cg(b,i),Zr&&(await ca(Math.random()*1e3),a&&console.warn("Start loading (delayed) "+p,A.guid));const _=await b.loadAsync(p).catch(T=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5509
|
+
`,t),a instanceof ft&&(t.geometry=a,Zr&&S4(t,"geometry",e)))}return this.onProgressiveLoadEnd(o),a}).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",t,a),null))}else Zr&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",t);return Promise.resolve(null)}static assignTextureLOD(i,e,t,n=0){if(!t)return Promise.resolve(null);if(t instanceof It){const r=t,s=[],o=new Array;if(r instanceof tg)for(const a of Object.keys(r.uniforms)){const l=r.uniforms[a].value;if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}else for(const a of Object.keys(r)){const l=r[a];if(l instanceof gt){const c=this.assignTextureLODForSlot(i,e,l,n,r,a);s.push(c),o.push(a)}}return ag(s).then(a=>{const l=new Array;for(let c=0;c<a.results.length;c++){const u=a.results[c],d=o[c];u instanceof gt?l.push({material:r,slot:d,texture:u,level:n}):l.push({material:r,slot:d,texture:null,level:n})}return l})}if(t instanceof gt){const r=t;return this.assignTextureLODForSlot(i,e,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(i,e,t,n,r,s){if(t?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(i,e,r,s);return ao.getOrLoadLOD(i,e,t,n).then(a=>Array.isArray(a)?null:a?.isTexture===!0?(a!=t&&(r&&s&&(r[s]=a),Zr&&s&&r&&S4(r,s,e)),this.onProgressiveLoadEnd(o),a):(Zr=="verbose"&&console.warn("No LOD found for",t,n),this.onProgressiveLoadEnd(o),null)).catch(a=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",t,a),null))}afterRoot(i){var e,t;Zr&&console.log("AFTER",this.sourceId,i),(e=this.parser.json.textures)==null||e.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o){for(const a of this.parser.associations.keys())if(a instanceof gt&&this.parser.associations.get(a).textures===s){const l=a;Zr&&console.log("> Progressive: register texture",s,l.name,l.uuid,l,o),l.source&&(l.source[xI]=o);const c=l.uuid;ao.assignLODInformation(l,c,0,0,void 0),ao.lodInfos.set(c,o),ao.lowresCache.set(c,l)}}}});const n=(r,s,o,a,l)=>{const c=s.geometry;c["needle:raycast-mesh"]=!0,c&&!av(s)&&(Zr&&console.log("Set raycast mesh",s.name,s.uuid,c),__(s,c),Nb(c,!0).forEach(u=>{u instanceof ue&&__(u,c)})),c.userData||(c.userData={}),ao.assignLODInformation(c,r,o,a,l.density),ao.lodInfos.set(r,l)};return(t=this.parser.json.meshes)==null||t.forEach((r,s)=>{if(r!=null&&r.extensions){const o=r?.extensions[Cf];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a instanceof ue){const l=this.parser.associations.get(a);if(l.meshes===s){const c=a;Zr&&console.log("> Progressive: register mesh",s,c.name,o,c.uuid,c);const u=c.uuid,d=o.lods.length;if(c instanceof ue){n(u,c,d,l.primitives,o);let p=ao.lowresCache.get(u);p?p.push(c.geometry):p=[c.geometry],ao.lowresCache.set(u,p)}}}}}}),null}static async getOrLoadLOD(i,e,t,n){var r,s,o;const a=Zr=="verbose",l=t.userData.LODS;if(!l)return null;const c=l?.key;let u;if(t instanceof gt&&t.source&&t.source[xI]&&(u=t.source[xI]),u||(u=ao.lodInfos.get(c)),u){if(n>0){let f=!1;const m=Array.isArray(u.lods);if(m&&n>=u.lods.length?f=!0:m||(f=!0),f)return this.lowresCache.get(c)}const d=Array.isArray(u.lods)?u.lods[n].path:u.lods;if(!d)return Zr&&!u["missing:uri"]&&(u["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,u)),null;let p=Fl(e,d);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!u.guid)return console.warn("missing pointer for glb/gltf texture",u),null;const f=p+"_"+u.guid,m=this.previouslyLoaded.get(f);if(m!==void 0){a&&console.log(`LOD ${n} was already loading/loaded: ${f}`);let g=await m.catch(b=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5510
|
+
`,b),null)),y=!1;if(g==null||(g instanceof gt&&t instanceof gt?(r=g.image)!=null&&r.data||(s=g.source)!=null&&s.data?g=this.copySettings(t,g):(y=!0,this.previouslyLoaded.delete(f)):g instanceof ft&&t instanceof ft&&((o=g.attributes.position)!=null&&o.array||(y=!0,this.previouslyLoaded.delete(f)))),!y)return g}const A=u,v=new Promise(async(g,y)=>{const b=new Fp;if(Cg(b,i),u&&Array.isArray(u.lods)){const T=u.lods[n];T.hash&&(p+="?v="+T.hash)}Zr&&(await ca(Math.random()*1e3),a&&console.warn("Start loading (delayed) "+p,A.guid));const _=await b.loadAsync(p).catch(T=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5511
5511
|
`,T),null));if(!_)return null;const E=_.parser;a&&console.log("Loading finished "+p,A.guid);let I=0;if(_.parser.json.textures){let T=!1;for(const M of _.parser.json.textures){if(M!=null&&M.extensions){const D=M?.extensions[Cf];if(D!=null&&D.guid&&D.guid===A.guid){T=!0;break}}I++}if(T){let M=await E.getDependency("texture",I);return a&&console.log('change "'+t.name+'" \u2192 "'+M.name+'"',p,I,M,f),t instanceof gt&&(M=this.copySettings(t,M)),M&&(M.guid=A.guid),g(M)}}if(I=0,_.parser.json.meshes){let T=!1;for(const M of _.parser.json.meshes){if(M!=null&&M.extensions){const D=M?.extensions[Cf];if(D!=null&&D.guid&&D.guid===A.guid){T=!0;break}}I++}if(T){const M=await E.getDependency("mesh",I),D=A;if(a&&console.log(`Loaded Mesh "${M.name}"`,p,I,M,f),M instanceof ue){const C=M.geometry;return ao.assignLODInformation(C,c,n,void 0,D.density),g(C)}else{const C=new Array;for(let P=0;P<M.children.length;P++){const j=M.children[P];if(j instanceof ue){const Q=j.geometry;ao.assignLODInformation(Q,c,n,P,D.density),C.push(Q)}}return g(C)}}}return g(null)});return this.previouslyLoaded.set(f,v),await v}else if(t instanceof gt){a&&console.log("Load texture from uri: "+p);const f=await new Ua().loadAsync(p);return f?(f.guid=u.guid,f.flipY=!1,f.needsUpdate=!0,f.colorSpace=t.colorSpace,a&&console.log(u,f)):Zr&&console.warn("failed loading",p),f}}else Zr&&console.warn(`Can not load LOD ${n}: no LOD info found for "${c}" ${t.name}`,t.type);return null}static assignLODInformation(i,e,t,n,r){if(!i)return;i.userData||(i.userData={});const s=new ere(e,t,n,r);i.userData.LODS=s,i.userData.LOD=t}static getAssignedLODInformation(i){var e;return((e=i?.userData)==null?void 0:e.LODS)||null}static copySettings(i,e){return this._copiedTextures.get(i)||(e=e.clone(),this._copiedTextures.set(i,e),e.offset=i.offset,e.repeat=i.repeat,e.colorSpace=i.colorSpace,e)}static beginListenStart(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new E4),this._progressiveEventListeners.get(i).start.push(e)}static stopListenStart(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).start,n=t.indexOf(e);n>=0&&t.splice(n,1)}static beginListenEnd(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new E4),this._progressiveEventListeners.get(i).end.push(e)}static stopListenEnd(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).end,n=t.indexOf(e);n>=0&&t.splice(n,1)}static onProgressiveLoadStart(i,e,t,n){this._currentProgressiveLoadingInfo.has(i)||this._currentProgressiveLoadingInfo.set(i,[]);const r=new C4(i,e,t,n),s=this._currentProgressiveLoadingInfo.get(i),o=this._progressiveEventListeners.get(i);return o&&o.onStart(r),s.push(r),r}static onProgressiveLoadEnd(i){if(!i)return;const e=i.context;if(!this._currentProgressiveLoadingInfo.has(e))return;const t=this._currentProgressiveLoadingInfo.get(e),n=t.indexOf(i);if(n<0)return;t.splice(n,1);const r=this._progressiveEventListeners.get(e);r&&r.onEnd(i)}};let Ii=ao;h(Ii,"lodInfos",new Map),h(Ii,"previouslyLoaded",new Map),h(Ii,"lowresCache",new Map),h(Ii,"_copiedTextures",new Map),h(Ii,"_progressiveEventListeners",new Map),h(Ii,"_currentProgressiveLoadingInfo",new Map);class ere{constructor(e,t,n,r){h(this,"key"),h(this,"level"),h(this,"index"),h(this,"density"),this.key=e,this.level=t,n!=null&&(this.index=n),r!=null&&(this.density=r)}}class C4{constructor(e,t,n,r){h(this,"context"),h(this,"source"),h(this,"material"),h(this,"slot"),h(this,"mesh"),this.context=e,this.source=t,n instanceof ue?this.mesh=n:this.material=n,this.slot=r}}class E4{constructor(){h(this,"start",[]),h(this,"end",[])}onStart(e){for(const t of this.start)t(e)}onEnd(e){for(const t of this.end)t(e)}}var tre=Object.defineProperty,ire=Object.getOwnPropertyDescriptor,Ns=(i,e,t,n)=>{for(var r=n>1?void 0:n?ire(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&tre(e,t,r),r};class lo extends Ie{constructor(){super(...arguments),h(this,"attachedRigidbody",null),h(this,"isTrigger",!1),h(this,"sharedMaterial"),h(this,"membership",[0]),h(this,"filter"),h(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Si))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Ns([x(Si)],lo.prototype,"attachedRigidbody",2),Ns([x()],lo.prototype,"isTrigger",2),Ns([x()],lo.prototype,"sharedMaterial",2),Ns([x()],lo.prototype,"membership",2),Ns([x()],lo.prototype,"filter",2);class Mf extends lo{constructor(){super(...arguments),h(this,"radius",.5),h(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),eb(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),BC(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Ns([wr(),x()],Mf.prototype,"radius",2),Ns([x(S)],Mf.prototype,"center",2);class Tf extends lo{constructor(){super(...arguments),h(this,"size",new S(1,1,1)),h(this,"center",new S(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size),eb(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),BC(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Ns([wr(),x(S)],Tf.prototype,"size",2),Ns([x(S)],Tf.prototype,"center",2);class cd extends lo{constructor(){super(...arguments),h(this,"sharedMesh"),h(this,"convex",!1)}onEnable(){var e,t,n;if(super.onEnable(),!this.context.physics.engine)return;(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ue&&(this.sharedMesh=this.gameObject);const r=0;if((t=this.sharedMesh)!=null&&t.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Ui(this.gameObject)),Ii.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,r).then(s=>{s&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=s,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Ui(this.gameObject)))});else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${((n=this.sharedMesh)==null?void 0:n.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 a in s.children){const l=s.children[a];l.isMesh&&(this.context.physics.engine.addMeshCollider(this,l,this.convex,Ui(this.gameObject)),o.push(Ii.assignMeshLOD(this.context,this.sourceId,l,r)))}Promise.all(o).then(a=>{var l,c;if(a.some(d=>d)==!1)return;(l=this.context.physics.engine)==null||l.removeBody(this);const u=new ue;for(const d of a)d&&this.activeAndEnabled&&(u.geometry=d,(c=this.context.physics.engine)==null||c.addMeshCollider(this,u,this.convex,Ui(this.gameObject)))})}}}}Ns([x(ue)],cd.prototype,"sharedMesh",2),Ns([x()],cd.prototype,"convex",2);class ac extends lo{constructor(){super(...arguments),h(this,"center",new S(0,0,0)),h(this,"radius",.5),h(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Ns([x(S)],ac.prototype,"center",2),Ns([x()],ac.prototype,"radius",2),Ns([x()],ac.prototype,"height",2);var nre=Object.defineProperty,rre=Object.getOwnPropertyDescriptor,wI=(i,e,t,n)=>{for(var r=n>1?void 0:n?rre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&nre(e,t,r),r};class hd extends Ie{constructor(){super(...arguments),h(this,"objectBounds",!1),h(this,"color"),h(this,"isGizmo",!0),h(this,"_gizmoObject",null),h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!Vg||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new SC(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=rT(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Fi.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var e;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}wI([x()],hd.prototype,"objectBounds",2),wI([x(Se)],hd.prototype,"color",2),wI([x()],hd.prototype,"isGizmo",2);const sre=ee("gizmos"),ore=ee("debugboxhelper"),_a=class extends Ie{constructor(){super(...arguments),h(this,"box",null),h(this,"_lastMatrixUpdateFrame",-1),h(this,"_helper",null),h(this,"_color",null)}isInBox(i,e){var t;if(!i)return;if(this.box||(this.box=new fi),i.type==="Mesh")_a.testBox.setFromObject(i);else if(i.type==="Group"){if(_a.testBox.makeEmpty(),i.children.length>0)for(let r=0;r<i.children.length;r++)i.children[r].type==="Mesh"&&_a.testBox.expandByObject(i)}else{const r=Pt(i,_a._position),s=Ui(i,_a._size);e!==void 0&&s.multiplyScalar(e),_a.testBox.setFromCenterAndSize(r,s)}this.updateBox();const n=(t=this.box)==null?void 0:t.intersectsBox(_a.testBox);return n&&ore&&yt.DrawWireBox3(_a.testBox,16711680,5),n}intersects(i){return i?this.updateBox(!1).intersectsBox(i):!1}updateBox(i=!1){if(this.box||(this.box=new fi),i||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const t=e,n=Pt(this.gameObject,_a._position,t),r=Ui(this.gameObject,_a._size);this.box.setFromCenterAndSize(n,r)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(i=null,e=!1){var t;if(!(!sre&&!e)){if(this._helper){i&&((t=this._color)==null||t.set(i)),this.gameObject.add(this._helper);return}this._helper=rT(i),this.gameObject.add(this._helper)}}};let nl=_a;h(nl,"testBox",new fi),h(nl,"_position",new S),h(nl,"_size",new S(.01,.01,.01));class are extends kO{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const n in t)for(const r in t[n])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(n);for(const n of e._components)e._simpleState__statesProperties[n.id]&&(e._simpleState__normalStyles[n.id]=n.inline?n.inline:n._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const n=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],n.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)n.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const n in e)this._simpleState__statesProperties[n]&&(this._simpleState__normalStyles[n]=e[n]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var lre=Object.defineProperty,cre=Object.getOwnPropertyDescriptor,M4=(i,e,t,n)=>{for(var r=n>1?void 0:n?cre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&lre(e,t,r),r};class If extends Ie{constructor(){super(...arguments),h(this,"effectColor"),h(this,"effectDistance")}}M4([x(yi)],If.prototype,"effectColor",2),M4([x($)],If.prototype,"effectDistance",2);var hre=Object.defineProperty,ure=Object.getOwnPropertyDescriptor,Qv=(i,e,t,n)=>{for(var r=n>1?void 0:n?ure(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&hre(e,t,r),r};const SI=ee("debugui"),CI=ee("debuguilayout");class EI{constructor(){h(this,"width"),h(this,"height")}}class MI{constructor(){h(this,"x"),h(this,"y"),h(this,"width"),h(this,"height")}}const xa=new S,Hv=new Ce,ax=new Me,T4=class extends Ra{constructor(){super(...arguments),h(this,"_anchoredPosition"),h(this,"sizeDelta",new $(100,100)),h(this,"pivot",new $(.5,.5)),h(this,"anchorMin",new $(0,0)),h(this,"anchorMax",new $(1,1)),h(this,"minWidth"),h(this,"minHeight"),h(this,"lastMatrix"),h(this,"rectBlock"),h(this,"_transformNeedsUpdate",!1),h(this,"_initialPosition"),h(this,"_parentRectTransform"),h(this,"_lastUpdateFrame",-1),h(this,"_lastAnchoring"),h(this,"_createdBlocks",[]),h(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 $),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){let i=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;i=e*t,i+=this.sizeDelta.x}return this.minWidth!==void 0&&i<this.minWidth?this.minWidth:i}get height(){let i=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;i=e*t,i+=this.sizeDelta.y}return this.minHeight!==void 0&&i<this.minHeight?this.minHeight:i}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new $),this.lastMatrix=new Ce,this.rectBlock=new ge,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,gf(this,"_anchoredPosition",()=>{this.markDirty()}),gf(this,"sizeDelta",()=>{this.markDirty()}),gf(this,"pivot",()=>{this.markDirty()}),gf(this,"anchorMin",()=>{this.markDirty()}),gf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(CI?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(CI&&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(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=re.getComponentInParent(this.gameObject.parent,T4):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,CI&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,xa.set(0,0,0),this.applyPivot(xa),t.matrix.setPosition(xa.x,xa.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(ax.copy(this.gameObject.quaternion),ax.x*=-1,ax.z*=-1,Hv.makeRotationFromQuaternion(ax),t.matrix.premultiply(Hv)),xa.set(0,0,0),this.applyAnchoring(xa),(e=this.Canvas)!=null&&e.screenspace?xa.z+=.1:xa.z+=.01,Hv.identity(),Hv.setPosition(xa.x,xa.y,xa.z),t.matrix.premultiply(Hv),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const n=!0;for(const r of HT(this.gameObject,Ra,n,1)){if(r===this||!r.activeAndEnabled)continue;const s=r;s.onParentRectTransformChanged&&s.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new $);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let n=0;const r=1-this.anchorMax.y-this.anchorMin.y;n-=t.height*.5*r,i.y+=n;let s=0;const o=1-this.anchorMax.x-this.anchorMin.x;s-=t.width*.5*o,i.x+=s}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},SI&&console.log(this.name,i);const e=new AE(i);return this._createdBlocks.push(e),e}createNewText(i){SI&&console.log(i),i={...this.getBasicOptions(),...i},SI&&console.log(this.name,i);const e=new bE(i);return this._createdTextBlocks.push(e),e}};let Ss=T4;Qv([x($)],Ss.prototype,"anchoredPosition",1),Qv([x($)],Ss.prototype,"sizeDelta",2),Qv([x($)],Ss.prototype,"pivot",2),Qv([x($)],Ss.prototype,"anchorMin",2),Qv([x($)],Ss.prototype,"anchorMax",2);var dre=Object.defineProperty,pre=Object.getOwnPropertyDescriptor,I4=(i,e,t,n)=>{for(var r=n>1?void 0:n?pre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&dre(e,t,r),r};const lx={backgroundColor:new Se(1,1,1),backgroundOpacity:1,borderColor:new Se(1,1,1),borderOpacity:1};var TI;const cx=(TI=class extends Ra{constructor(){super(...arguments),h(this,"_alphaFactor",1),h(this,"sRGBColor",new Se(1,0,1)),h(this,"raycastTarget",!0),h(this,"uiObject",null),h(this,"_color",null),h(this,"_rect",null),h(this,"_stateManager",null),h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new yi(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new yi(1,1,1,1)),this._color.copy(i),this.onColorChanged())}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),lx.backgroundColor=this.sRGBColor,lx.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(lx,this._alphaFactor),this.uiObject.set(lx),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=re.getComponent(this.gameObject,Ss)),!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 i;(i=this.uiObject)==null||i.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(i){return super.__internalNewInstanceCreated(i),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new are(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),gf(this,"_color",()=>Nie(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.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 i=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const n=(t=this.gameObject)==null?void 0:t.getComponent(If);n&&(n.effectDistance&&(i.borderWidth=Math.max(Math.abs(n.effectDistance.x),Math.abs(n.effectDistance.y))),n.effectColor&&(i.borderColor=n.effectColor,i.borderOpacity=n.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(cx.textureCache.has(i))i=cx.textureCache.get(i);else if(!i.isRenderTargetTexture){const e=i.clone();e.colorSpace=di,cx.textureCache.set(i,e),i=e}this.setOptions({backgroundImage:i,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Ii.assignTextureLOD(this.context,this.sourceId,i,0).then(e=>{e instanceof gt&&this.setOptions({backgroundImage:e})})}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)}},h(TI,"textureCache",new Map),TI);let ud=cx;I4([x(yi)],ud.prototype,"color",1),I4([x()],ud.prototype,"raycastTarget",2);class Vv extends ud{constructor(){super(...arguments),h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var fre=Object.defineProperty,mre=Object.getOwnPropertyDescriptor,hx=(i,e,t,n)=>{for(var r=n>1?void 0:n?mre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&fre(e,t,r),r};let II=class{constructor(){h(this,"texture",null),h(this,"rect")}};hx([x(gt)],II.prototype,"texture",2);let Rf=class extends Vv{constructor(){super(...arguments),h(this,"_sprite"),h(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new II),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,n,r,s,o;const a=this.sprite;switch((i=a?.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((t=(e=a?.texture)==null?void 0:e.name)!=null&&t.length)&&((r=(n=a?.texture)==null?void 0:n.image)==null?void 0:r.width)===32&&((o=(s=a?.texture)==null?void 0:s.image)==null?void 0:o.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};hx([x(II)],Rf.prototype,"sprite",1),hx([x()],Rf.prototype,"pixelsPerUnitMultiplier",2);class ux extends Vv{constructor(){super(...arguments),h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}hx([x(gt)],ux.prototype,"mainTexture",1);var gre=Object.defineProperty,vre=Object.getOwnPropertyDescriptor,co=(i,e,t,n)=>{for(var r=n>1?void 0:n?vre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&gre(e,t,r),r};const dd=ee("debugbutton");class xh{constructor(){h(this,"colorMultiplier"),h(this,"disabledColor"),h(this,"fadeDuration"),h(this,"highlightedColor"),h(this,"normalColor"),h(this,"pressedColor"),h(this,"selectedColor")}}co([x()],xh.prototype,"colorMultiplier",2),co([x(yi)],xh.prototype,"disabledColor",2),co([x()],xh.prototype,"fadeDuration",2),co([x(yi)],xh.prototype,"highlightedColor",2),co([x(yi)],xh.prototype,"normalColor",2),co([x(yi)],xh.prototype,"pressedColor",2),co([x(yi)],xh.prototype,"selectedColor",2);class Are{constructor(){h(this,"disabledTrigger"),h(this,"highlightedTrigger"),h(this,"normalTrigger"),h(this,"pressedTrigger"),h(this,"selectedTrigger")}}class lc extends Ie{constructor(){super(...arguments),h(this,"onClick"),h(this,"_isHovered",0),h(this,"colors"),h(this,"transition"),h(this,"animationTriggers"),h(this,"animator"),h(this,"_interactable",!0),h(this,"_requestedAnimatorTrigger"),h(this,"_isInit",!1),h(this,"_image")}onPointerEnter(e){var t,n;const r=e.event.pointerType==="mouse"&&e.button===0;r&&(this._isHovered+=1),dd&&console.warn("Button Enter",r,this._isHovered,(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState("hovered")),r&&this.context.input.setCursorPointer())}onPointerExit(){var e,t;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),dd&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.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&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var t,n;dd&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((n=this._image)==null||n.setState("pressed")))}onPointerUp(e){var t,n;dd&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.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&&((n=this._image)==null||n.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===n_.Mouse)&&(dd&&(console.warn("Button Click",this.onClick),Hi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),dd))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),yt.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),dd&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(_v)||this.gameObject.addComponent(Q_)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=re.getComponent(this.gameObject,Rf),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,n,r,s,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.highlightedColor),u={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(u);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const A=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),v={state:"disabled",attributes:{backgroundColor:A,backgroundOpacity:A.alpha}};e.setupState(v)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}co([x(Hn)],lc.prototype,"onClick",2),co([x(xh)],lc.prototype,"colors",2),co([x()],lc.prototype,"transition",2),co([x(Are)],lc.prototype,"animationTriggers",2),co([x(Sr)],lc.prototype,"animator",2),co([x()],lc.prototype,"interactable",1);var yre=Object.defineProperty,bre=Object.getOwnPropertyDescriptor,Bn=(i,e,t,n)=>{for(var r=n>1?void 0:n?bre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&yre(e,t,r),r};const R4=ee("debuguilayout");class wh{constructor(){h(this,"left",0),h(this,"right",0),h(this,"top",0),h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Bn([x()],wh.prototype,"left",2),Bn([x()],wh.prototype,"right",2),Bn([x()],wh.prototype,"top",2),Bn([x()],wh.prototype,"bottom",2);class ho extends Ie{constructor(){super(...arguments),h(this,"_rectTransform",null),h(this,"_needsUpdate",!1),h(this,"childAlignment",0),h(this,"reverseArrangement",!1),h(this,"spacing",0),h(this,"padding"),h(this,"minWidth",0),h(this,"minHeight",0),h(this,"flexibleHeight",0),h(this,"flexibleWidth",0),h(this,"preferredHeight",0),h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(R4&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){R4&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Ss);const e=this.gameObject.getComponentInParent(Mr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(Mr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}Bn([x()],ho.prototype,"childAlignment",2),Bn([x()],ho.prototype,"reverseArrangement",2),Bn([x()],ho.prototype,"spacing",2),Bn([x(wh)],ho.prototype,"padding",2),Bn([x()],ho.prototype,"minWidth",2),Bn([x()],ho.prototype,"minHeight",2),Bn([x()],ho.prototype,"flexibleHeight",2),Bn([x()],ho.prototype,"flexibleWidth",2),Bn([x()],ho.prototype,"preferredHeight",2),Bn([x()],ho.prototype,"preferredWidth",2);class Sh extends ho{constructor(){super(...arguments),h(this,"childControlHeight",!0),h(this,"childControlWidth",!0),h(this,"childForceExpandHeight",!1),h(this,"childForceExpandWidth",!1),h(this,"childScaleHeight",!1),h(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const n=this.primaryAxis,r=e.width;let s=r;const o=e.height;let a=o;s-=this.padding.horizontal,a-=this.padding.vertical,n==="x"?this.padding.horizontal:this.padding.vertical;const l=n==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:s,A=l?r:o,v=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let y=0,b=0;for(let M=0;M<this.gameObject.children.length;M++){const D=this.gameObject.children[M],C=re.getComponent(D,Ss);C!=null&&C.activeAndEnabled&&(b+=1,l?y+=C.width:y+=C.height)}let _=0;const E=this.spacing*(b-1);if(p||u){let M=0;l?M=s-=E:M=a-=E,b>0&&(_=M/b)}let I=0;I+=this.padding.left,I-=this.padding.right,v!==0&&(g=A-y,g*=v,g-=E*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let T=1;for(let M=0;M<this.gameObject.children.length;M++){const D=this.gameObject.children[M],C=re.getComponent(D,Ss);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const P=r*.5+I*.5;C.anchoredPosition.x!==P&&(C.anchoredPosition.x=P);const j=o*-.5;C.anchoredPosition.y!==j&&(C.anchoredPosition.y=j),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&u&&C.sizeDelta[n]!==_&&(C.sizeDelta[n]=_);const Q=l?C.width:C.height,O=Q*.5;if(g+=O,p){const L=_*T-_*.5;L>g&&(g=L-_*.5+Q+this.padding.left,g-=O)}let W=g;n==="y"&&(W=-W),C.anchoredPosition[n]!==W&&(C.anchoredPosition[n]=W),g+=O,g+=this.spacing,T+=1}}}}Bn([x()],Sh.prototype,"childControlHeight",2),Bn([x()],Sh.prototype,"childControlWidth",2),Bn([x()],Sh.prototype,"childForceExpandHeight",2),Bn([x()],Sh.prototype,"childForceExpandWidth",2),Bn([x()],Sh.prototype,"childScaleHeight",2),Bn([x()],Sh.prototype,"childScaleWidth",2);class RI extends Sh{get primaryAxis(){return"y"}}class PI extends Sh{get primaryAxis(){return"x"}}class BI extends ho{onCalculateLayout(){}}var _re=Object.defineProperty,xre=Object.getOwnPropertyDescriptor,rl=(i,e,t,n)=>{for(var r=n>1?void 0:n?xre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&_re(e,t,r),r},P4=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(P4||{});const DI=ee("debuguilayout"),B4=class extends bv{constructor(){super(...arguments),h(this,"_renderOnTop"),h(this,"_depthWrite",!1),h(this,"_doubleSided",!0),h(this,"_castShadows",!1),h(this,"_receiveShadows",!1),h(this,"_renderMode",-1),h(this,"_rootCanvas"),h(this,"_scaleFactor",1),h(this,"worldCamera"),h(this,"planeDistance",-1),h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),h(this,"previousParent",null),h(this,"_lastMatrixWorld",null),h(this,"_rectTransforms",[]),h(this,"_layoutGroups",new Map),h(this,"_receivers",[]),h(this,"onBeforeRenderRoutine",()=>{var i,e,t,n;if(this.previousParent=this.gameObject.parent,((i=this.context.xr)!=null&&i.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Go.ensureUpdateMeshUI(LO,this.context))}),h(this,"onAfterRenderRoutine",()=>{var i,e,t,n,r;if(((i=this.context.xr)!=null&&i.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(t=this.previousParent)==null||t.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const a=this.context.mainCamera;a?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const s=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(),(n=this.shadowComponent)==null||n.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Go.ensureUpdateMeshUI(LO,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=s,this.context.renderer.autoClearColor=o,this.previousParent.add(this.gameObject)}(r=this._lastMatrixWorld)==null||r.copy(this.gameObject.matrixWorld)}),h(this,"_updateRenderSettingsRoutine"),h(this,"_activeRenderMode",-1),h(this,"_lastWidth",-1),h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof B4||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,DI&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Ce,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 i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(i){this._receivers.push(i)}unregisterEventReceiver(i){const e=this._receivers.indexOf(i);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(i){this.screenspace?(i.xr.isVR||i.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await wk(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(i){this.screenspace&&(i.xr.isVR||i.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var i;for(const e of this._receivers)(i=e.onBeforeCanvasRender)==null||i.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Ce);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);DI&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let n=this._layoutGroups.get(t.gameObject);t.isDirty&&!n&&(n=t.gameObject.getComponentInParent(ho)),(t.isDirty||n!=null&&n.isDirty)&&(DI&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),n?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Fi.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),V_(this.shadowComponent,this);for(const i of re.getComponentsInChildren(this.gameObject,Ra))V_(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=Ze.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const n=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-n,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Ss);let s=!1;r.sizeDelta.x!==this.context.domWidth&&(s=!0),r.sizeDelta.y!==this.context.domHeight&&(s=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(n);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,s&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Mr=B4;rl([x()],Mr.prototype,"renderOnTop",1),rl([x()],Mr.prototype,"depthWrite",1),rl([x()],Mr.prototype,"doubleSided",1),rl([x()],Mr.prototype,"castShadows",1),rl([x()],Mr.prototype,"receiveShadows",1),rl([x()],Mr.prototype,"renderMode",1),rl([x(Mr)],Mr.prototype,"rootCanvas",1),rl([x()],Mr.prototype,"scaleFactor",1),rl([x(Bi)],Mr.prototype,"worldCamera",2),rl([x()],Mr.prototype,"planeDistance",2);var wre=Object.defineProperty,Sre=Object.getOwnPropertyDescriptor,kI=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&wre(e,t,r),r};class Ch extends Ie{constructor(){super(...arguments),h(this,"_alpha",1),h(this,"interactable",!0),h(this,"blocksRaycasts",!0),h(this,"_isDirty",!1),h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Fi.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of re.getComponentsInChildren(this.gameObject,Ra,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}kI([x()],Ch.prototype,"alpha",1),kI([x()],Ch.prototype,"interactable",2),kI([x()],Ch.prototype,"blocksRaycasts",2);var Cre=Object.defineProperty,Ere=Object.getOwnPropertyDescriptor,tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ere(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Cre(e,t,r),r};const D4=ee("debugusdzbehaviours");function Wv(i){i&&(i.getComponentInParent(_v)||(ut()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(no)))}class pd extends Ie{constructor(){super(...arguments),h(this,"object"),h(this,"target"),h(this,"duration",1),h(this,"relativeMotion",!1),h(this,"coroutine",null),h(this,"targetPos",new S),h(this,"targetRot",new Me),h(this,"targetScale",new S)}start(){Wv(this.gameObject)}onPointerClick(e){e.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 e=Pt(this.object).clone(),t=Pt(this.target).clone(),n=xi(this.object).clone(),r=xi(this.target).clone(),s=Ui(this.object).clone(),o=Ui(this.target).clone(),a=e.distanceTo(t),l=n.angleTo(r),c=s.distanceTo(o);if(a<.01&&l<.01&&c<.01){Vr(this.object,t),Bo(this.object,r),fg(this.object,o),this.coroutine=null;return}let u=0,d=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(n,r,d),this.targetScale.lerpVectors(s,o,d),Vr(this.object,this.targetPos),Bo(this.object,this.targetRot),fg(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),n=this.object.scale.clone(),r=this.target.position.clone(),s=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(s),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(n,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const n=new pr("Move to "+((t=this.target)==null?void 0:t.name),fr.tapTrigger(this.gameObject),ai.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));e.addBehavior(n)}}}tn([x(ge)],pd.prototype,"object",2),tn([x(ge)],pd.prototype,"target",2),tn([x()],pd.prototype,"duration",2),tn([x()],pd.prototype,"relativeMotion",2);var dx;const cc=(dx=class extends Ie{constructor(){super(...arguments),h(this,"materialToSwitch"),h(this,"variantMaterial"),h(this,"fadeDuration",0),h(this,"_objectsWithThisMaterial",null),h(this,"selfModel"),h(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,Wv(this.gameObject)}onPointerClick(i){if(i.use(),!!this.variantMaterial)for(let e=0;e<this.objectsWithThisMaterial.length;e++){const t=this.objectsWithThisMaterial[e];t.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(i=>{if(i instanceof ue)if(Array.isArray(i.material)){for(const e of i.material)if(e===this.materialToSwitch){this.objectsWithThisMaterial.push(i);break}}else i.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(i)}),this._objectsWithThisMaterial)}async beforeCreateDocument(i,e){this.targetModels=[],cc._materialTriggersPerId={},cc.variantSwitchIndex=0,this.materialToSwitch&&await Ii.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ii.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this.objectsWithThisMaterial.find(n=>n.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(cc._materialTriggersPerId[this.materialToSwitch.uuid]||(cc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),cc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=cc._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const n={};for(const r of t){const s=r.createVariants();s&&s.length>0&&(n[r.selfModel.uuid]=s)}for(const r of t){const s=[];for(const o in n)o!==r.selfModel.uuid&&s.push(...n[o]);r.createAndAttachBehaviors(i,n[r.selfModel.uuid],s)}}delete cc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const n=[],r=[],s=Math.max(0,this.fadeDuration);r.push(ai.fadeAction([...this.targetModels,...t],s,!1)),n.push(ai.fadeAction(e,s,!1)),r.push(ai.fadeAction(e,s,!0)),i.addBehavior(new pr("Select_"+this.selfModel.name,fr.tapTrigger(this.selfModel),ai.parallel(...r))),i.addBehavior(new pr("StartHidden_"+this.selfModel.name,fr.sceneStartTrigger(),ai.parallel(...n)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+cc.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&Oo.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},h(dx,"_materialTriggersPerId",{}),h(dx,"variantSwitchIndex",0),dx);let Pf=cc;tn([x(It)],Pf.prototype,"materialToSwitch",2),tn([x(It)],Pf.prototype,"variantMaterial",2),tn([x()],Pf.prototype,"fadeDuration",2);var Bf;const nn=(Bf=class extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"toggleOnClick",!1),h(this,"targetState",!0),h(this,"hideSelf",!0),h(this,"selfModel"),h(this,"selfModelClone"),h(this,"targetModel"),h(this,"toggleModel"),h(this,"stateBeforeCreatingDocument",!1),h(this,"targetStateBeforeCreatingDocument",!1)}start(){Wv(this.gameObject)}onPointerClick(i){i.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[nn.wasVisible]===void 0&&(this.gameObject[nn.wasVisible]=this.gameObject.activeSelf),this.target[nn.wasVisible]===void 0&&(this.target[nn.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[nn.wasVisible],this.targetStateBeforeCreatingDocument=this.target[nn.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(i,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let n=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&GL.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[nn.toggleClone]){const a=this.selfModelClone.clone();a.matrix.identity(),a.name+="_toggle"+nn.clonedToggleIndex++,t.add(a),this.gameObject[nn.toggleClone]=a,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[nn.toggleClone];if(!this.gameObject[nn.reverseToggleClone]){const a=this.selfModelClone.clone();a.matrix.identity(),a.name+="_toggleReverse"+nn.clonedToggleIndex++,t.add(a),this.gameObject[nn.reverseToggleClone]=a}this.toggleModel=this.gameObject[nn.reverseToggleClone],(!this.toggleModel.geometry||!o.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),n=o,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const o=[];o.push(ai.fadeAction(n,0,!1)),o.push(ai.fadeAction(this.toggleModel,0,!0)),o.push(ai.fadeAction(this.targetModel,0,r)),i.addBehavior(new pr("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),fr.tapTrigger(n),ai.parallel(...o)));const a=[];a.push(ai.fadeAction(this.toggleModel,0,!1)),a.push(ai.fadeAction(n,0,!0)),a.push(ai.fadeAction(this.targetModel,0,!r)),i.addBehavior(new pr("Toggle_"+n.name+"_toggleTo"+(r?"Off":"On"),fr.tapTrigger(this.toggleModel),ai.parallel(...a)))}}else{const o=[];this.hideSelf&&o.push(ai.fadeAction(n,0,!1)),o.push(ai.fadeAction(this.targetModel,0,r)),i.addBehavior(new pr("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),fr.tapTrigger(n),ai.parallel(...o)))}const s=new Array;this.targetStateBeforeCreatingDocument||s.push(this.targetModel),this.stateBeforeCreatingDocument||s.push(t),this.toggleModel&&s.push(this.toggleModel),i.addBehavior(new pr("HideOnStart_"+this.gameObject.name,fr.sceneStartTrigger(),ai.fadeAction(s,0,!1)))}}afterSerialize(i,e){this.gameObject[nn.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[nn.wasVisible],delete this.gameObject[nn.wasVisible]),this.target&&this.target[nn.wasVisible]!==void 0&&(this.target.visible=this.target[nn.wasVisible],delete this.target[nn.wasVisible]),delete this.gameObject[nn.toggleClone],delete this.gameObject[nn.reverseToggleClone]}},h(Bf,"clonedToggleIndex",0),h(Bf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(Bf,"toggleClone",Symbol("clone for toggling")),h(Bf,"reverseToggleClone",Symbol("clone for reverse toggling")),Bf);let fd=nn;tn([x(ge)],fd.prototype,"target",2),tn([x()],fd.prototype,"toggleOnClick",2),tn([x()],fd.prototype,"targetState",2),tn([x()],fd.prototype,"hideSelf",2);class OI extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,n){t.uuid===this.gameObject.uuid&&e.addBehavior(new pr("HideOnStart_"+this.gameObject.name,fr.sceneStartTrigger(),ai.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Df extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"duration",.5),h(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(e,t,n){if(this.target&&t.uuid===this.gameObject.uuid){const r=new pr("emphasize "+this.name,fr.tapTrigger(this.gameObject),ai.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}tn([x()],Df.prototype,"target",2),tn([x()],Df.prototype,"duration",2),tn([x()],Df.prototype,"motionType",2);class Eh extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"clip",""),h(this,"toggleOnClick",!1)}start(){Wv(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(en);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.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(e,t,n){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const s=this.target?this.target.gameObject:this.gameObject,o=Hh.getName(r),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let c=!1;if(this.gameObject.traverse(u=>{u instanceof ue&&u.visible&&(c=!0)}),c=!0,c){let u=ai.playAudioAction(s,"audio/"+o,"play",a,l);this.toggleOnClick&&(u.multiplePerformOperation="stop"),this.target&&this.target.loop&&(u=ai.sequence(u).makeLooping());const d=new pr("playAudio "+this.name,fr.tapTrigger(this.gameObject),u);e.addBehavior(d)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let u=ai.playAudioAction(s,"audio/"+o,"play",a,l);this.target.loop&&(u=ai.sequence(u).makeLooping());const d=new pr("playAudioOnStart"+(this.name?"_"+this.name:""),fr.sceneStartTrigger(),u);e.addBehavior(d)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const n=this.clip?this.clip:this.target?this.target.clip:void 0;if(!n||typeof n!="string")return;const r="audio/"+Hh.getName(n);if(t.files[r])return;const s=await(await(await fetch(n)).blob()).arrayBuffer(),o=new Uint8Array(s);t.files[r]=o}}tn([x(en)],Eh.prototype,"target",2),tn([x(URL)],Eh.prototype,"clip",2),tn([x()],Eh.prototype,"toggleOnClick",2);var px;const Mh=(px=class extends Ie{constructor(){super(...arguments),h(this,"animator"),h(this,"stateName"),h(this,"trigger","tap"),h(this,"animation"),h(this,"selfModel"),h(this,"stateAnimationModel"),h(this,"animationSequence",new Array),h(this,"animationLoopAfterSequence",new Array)}get target(){var i,e;return((i=this.animator)==null?void 0:i.gameObject)||((e=this.animation)==null?void 0:e.gameObject)}start(){Wv(this.gameObject)}onPointerClick(i){var e;i.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Mh.rootsWithExclusivePlayback.size>1){const i='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.';ut()&&$i(i),console.warn(i,...Mh.rootsWithExclusivePlayback)}Mh.animationActions=[],Mh.rootsWithExclusivePlayback=new Set}afterCreateDocument(i,e){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const t=e.document,n=e.extensions.find(o=>o instanceof Bv);if(!n)return;const r=n.getClipCount(this.target)>1;r&&(ut()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+n.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Mh.rootsWithExclusivePlayback.add(this.target));const s=(o,a)=>{let l=Mh.animationActions.find(c=>c.affectedObjects==o&&c.start==a.start&&c.duration==a.duration);return l||(l=ai.startAnimationAction(o,a.start,a.duration),Mh.animationActions.push(l)),l};t.traverse(o=>{var a,l;if(o.uuid===((a=this.target)==null?void 0:a.uuid)){const c=ai.sequence();if(this.animationSequence!==void 0)for(const d of this.animationSequence)c.addAction(s(o,d));if(this.animationLoopAfterSequence!==void 0){const d=c.actions.length==0?c:ai.sequence();for(const p of this.animationLoopAfterSequence)d.addAction(s(o,p));d.makeLooping(),c!==d&&c.addAction(d)}const u=new pr("tap "+this.name+" for "+this.stateName+" on "+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?fr.tapTrigger(this.selfModel):fr.sceneStartTrigger(),c);r&&u.makeExclusive(!0),i.addBehavior(u)}})}createAnimation(i,e,t){var n,r,s,o;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=e,this.animation&&this.animation.clip){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const p=i.registerAnimation(this.target,this.animation.clip);p&&this.animationLoopAfterSequence.push(p);return}const a=(n=this.animator)==null?void 0:n.runtimeAnimatorController;let l=a?.findState(this.stateName),c=[],u=[];if(a&&l){const p=new Array;p.push(l);let f=!1;for(;p.length<100;){if(!l||l===null||!l.transitions||l.transitions.length===0){(r=l.motion)!=null&&r.isLooping&&(f=!0);break}const m=l.transitions.find(v=>v.conditions.length===0),A=m?a.getState(m.destinationState,0):null;if(A&&p.includes(A)){l=A,f=!0;break}else if(m){if(l=A,!l)break;p.push(l)}else{f=((s=l.motion)==null?void 0:s.isLooping)??!1;break}}if(f&&l){const m=p.indexOf(l);c=p.slice(0,m),u=p.slice(m),D4&&console.log("found loop from "+this.stateName,"states until loop",c,"states looping",u)}else c=p,u=[],D4&&console.log("found no loop from "+this.stateName,"states",c)}if(c=c.filter(p=>{var f,m,A;return((f=p.motion)==null?void 0:f.clip)&&((A=(m=p.motion)==null?void 0:m.clip.tracks)==null?void 0:A.length)>0}),u=u.filter(p=>{var f,m,A;return((f=p.motion)==null?void 0:f.clip)&&((A=(m=p.motion)==null?void 0:m.clip.tracks)==null?void 0:A.length)>0}),c.length===0&&u.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 d=(p,f)=>{var m,A,v;if(!this.target)return;if(!((m=p.motion)!=null&&m.clip)){console.warn("No clip found for state "+p.name+" on "+((A=this.animator)==null?void 0:A.name)+", can't export animation data");return}const g=i.registerAnimation(this.target,p.motion.clip);g?f.push(g):console.warn("Couldn't register animation for state "+p.name+" on "+((v=this.animator)==null?void 0:v.name))};if(c.length>0){this.animationSequence=new Array;for(const p of c)d(p,this.animationSequence)}if(u.length>0){this.animationLoopAfterSequence=new Array;for(const p of u)d(p,this.animationLoopAfterSequence)}}},h(px,"animationActions",[]),h(px,"rootsWithExclusivePlayback",new Set),px);let md=Mh;tn([x(Sr)],md.prototype,"animator",2),tn([x()],md.prototype,"stateName",2);class kf extends Ie{constructor(){super(...arguments),h(this,"target")}getType(){}getDuration(){}}tn([x(ge)],kf.prototype,"target",2);class qv extends Ie{constructor(){super(...arguments),h(this,"target")}}tn([x(kf)],qv.prototype,"target",2);class Xv extends kf{constructor(){super(...arguments),h(this,"type",1),h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}tn([x()],Xv.prototype,"type",2),tn([x()],Xv.prototype,"duration",2);class LI extends qv{}var Mre=Object.defineProperty,Tre=Object.getOwnPropertyDescriptor,hc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Tre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Mre(e,t,r),r};const k4=ee("debugcharactercontroller");class gd extends Ie{constructor(){super(...arguments),h(this,"center",new S(0,0,0)),h(this,"radius",.5),h(this,"height",2),h(this,"_rigidbody",null),h(this,"_activeGroundCollisions"),h(this,"_contactVelocity",new S)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Si),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Si)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(ac);t||(t=this.gameObject.addNewComponent(ac)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const n=new S(0,0,1),r=new S(1,0,0),s=new S(0,1,0),o=this.gameObject.getWorldDirection(new S);o.y=0;const a=r.dot(o)<0?-1:1,l=n.angleTo(o)*a;this.gameObject.setRotationFromAxisAngle(s,l),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),k4&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),k4&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const n=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);n&&(this._contactVelocity.x+=n.x,this._contactVelocity.y+=n.y,this._contactVelocity.z+=n.z)}return this._contactVelocity}}hc([x(S)],gd.prototype,"center",2),hc([x()],gd.prototype,"radius",2),hc([x()],gd.prototype,"height",2);class uc extends Ie{constructor(){super(...arguments),h(this,"controller"),h(this,"movementSpeed",2),h(this,"rotationSpeed",2),h(this,"jumpForce",1),h(this,"doubleJumpForce",2),h(this,"animator"),h(this,"lookForward",!0),h(this,"lookInput",new $(0,0)),h(this,"moveInput",new $(0,0)),h(this,"jumpInput",!1),h(this,"_currentSpeed",new S(0,0,0)),h(this,"_currentAngularSpeed",new S(0,0,0)),h(this,"_temp",new S(0,0,0)),h(this,"_jumpCount",0),h(this,"_currentRotation"),h(this,"_raycastOptions",new No)}awake(){this._currentRotation=new Me}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}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(e,t,n){var r,s,o,a,l,c,u,d,p,f,m;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((s=this.animator)==null||s.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",e.length()>.01),(l=this.animator)==null||l.setBool("jumping",((a=this.controller)==null?void 0:a.isGrounded)===!0&&n),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+=Ze.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const A=this.context.mainCameraComponent.forward;A.y=0,A.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),A),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&&n&&this.jumpForce>0){let A=(c=this.controller)==null?void 0:c.isGrounded;if(this.doubleJumpForce>0&&!((u=this.controller)!=null&&u.isGrounded)&&this._jumpCount===1&&(A=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),A){this._jumpCount+=1;const v=this.controller.rigidbody,g=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new S(0,1,0).multiplyScalar(g))}}if(this.controller){const A=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(A<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Ds),this._raycastOptions.ray.origin.copy(Pt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const g=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(g.length&&g[0].distance>2||A<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(m=this.animator)==null||m.setBool("falling",!1)}}}hc([x(gd)],uc.prototype,"controller",2),hc([x()],uc.prototype,"movementSpeed",2),hc([x()],uc.prototype,"rotationSpeed",2),hc([x()],uc.prototype,"jumpForce",2),hc([x()],uc.prototype,"doubleJumpForce",2),hc([x(Sr)],uc.prototype,"animator",2);var Ire=Object.defineProperty,Rre=Object.getOwnPropertyDescriptor,Pre=(i,e,t,n)=>{for(var r=n>1?void 0:n?Rre(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ire(e,t,r),r};class Yv extends Kr{constructor(){super(...arguments),h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new jU;return e.offset=new $(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}Pre([x(Rt)],Yv.prototype,"intensity",2),Ho("ChromaticAberration",Yv);const Jv=new ft;Jv.setAttribute("position",new $e(new Float32Array([-1,-1,3,-1,-1,3]),2)),Jv.setAttribute("uv",new $e(new Float32Array([0,0,2,0,0,2]),2)),Jv.boundingSphere=new un,Jv.computeBoundingSphere=function(){};const Bre=new Dl;class vd{constructor(e){this._mesh=new ue(Jv,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,Bre)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const Dre={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new Ce},viewMat:{value:new Ce},projViewMat:{value:new Ce},projectionMatrixInv:{value:new Ce},viewMatrixInv:{value:new Ce},cameraPos:{value:new S},resolution:{value:new $},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 Xae=function(i){Kf(t,i);var e=Zf(t);function t(n){var r;return xt(this,t),r=e.call(this,n),Y($t(r),"positionBuffer",void 0),Y($t(r),"previousBuffer",void 0),Y($t(r),"nextBuffer",void 0),Y($t(r),"uvBuffer",void 0),Y($t(r),"sideBuffer",void 0),Y($t(r),"widthBuffer",void 0),Y($t(r),"colorBuffer",void 0),Y($t(r),"indexBuffer",void 0),Y($t(r),"vector_",new S),Y($t(r),"vector2_",new S),Y($t(r),"vector3_",new S),Y($t(r),"quaternion_",new Me),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return wt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new ft,this.indexBuffer=new $e(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Nr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Nr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Nr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Nr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Nr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Nr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new $e(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Nr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new $e(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Nr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new $(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new $(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=NR(this.settings.material.map.channel),n.map=new be(this.settings.material.map),n.mapTransform=new be(new Dt().copy(this.settings.material.map.matrix))),this.settings.renderMode===tt.Trail)this.material=new Tt({uniforms:n,defines:r,vertexShader:qae,fragmentShader:Wae,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Yh});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,s=0,o=0;this.systems.forEach(function(a){for(var l=0;l<a.particleNum;l++)o+=a.particles[l].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(a){var l=n.quaternion_,c=n.vector2_,u=n.vector3_;a.emitter.matrixWorld.decompose(c,l,u);for(var d=a.particles,p=a.particleNum,f=n.settings.uTileCount,m=n.settings.vTileCount,A=1/f,v=1/m,g=0;g<p;g++){var y=d[g],b=y.uvTile%m,_=Math.floor(y.uvTile/m),E=y.previous.values(),I=E.next(),T=I.value,M=T;I.done||(I=E.next());var D=void 0;I.value!==void 0?D=I.value:D=M;for(var C=0;C<y.previous.length;C++,r+=2){if(n.positionBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.positionBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z),a.worldSpace?(n.positionBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.positionBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(y.parentMatrix?n.vector_.copy(M.position).applyMatrix4(y.parentMatrix):n.vector_.copy(M.position).applyMatrix4(a.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.previousBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.previousBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z)):(y.parentMatrix?n.vector_.copy(T.position).applyMatrix4(y.parentMatrix):n.vector_.copy(T.position).applyMatrix4(a.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.nextBuffer.setXYZ(r,D.position.x,D.position.y,D.position.z),n.nextBuffer.setXYZ(r+1,D.position.x,D.position.y,D.position.z)):(y.parentMatrix?n.vector_.copy(D.position).applyMatrix4(y.parentMatrix):n.vector_.copy(D.position).applyMatrix4(a.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),a.worldSpace)n.widthBuffer.setX(r,M.size),n.widthBuffer.setX(r+1,M.size);else if(y.parentMatrix)n.widthBuffer.setX(r,M.size),n.widthBuffer.setX(r+1,M.size);else{var P=(Math.abs(u.x)+Math.abs(u.y)+Math.abs(u.z))/3;n.widthBuffer.setX(r,M.size*P),n.widthBuffer.setX(r+1,M.size*P)}n.uvBuffer.setXY(r,(C/y.previous.length+b)*A,(m-_-1)*v),n.uvBuffer.setXY(r+1,(C/y.previous.length+b)*A,(m-_)*v),n.colorBuffer.setXYZW(r,M.color.x,M.color.y,M.color.z,M.color.w),n.colorBuffer.setXYZW(r+1,M.color.x,M.color.y,M.color.z,M.color.w),C+1<y.previous.length&&(n.indexBuffer.setX(s*3,r),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+2),s++,n.indexBuffer.setX(s*3,r+2),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+3),s++),T=M,M=D,I.done||(I=E.next(),I.value!==void 0&&(D=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=s*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,s*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(oj),Yae=function(i){Kf(t,i);var e=Zf(t);function t(){var n;return xt(this,t),n=e.call(this),Y($t(n),"batches",[]),Y($t(n),"systemToBatchIndex",new Map),Y($t(n),"type","BatchedRenderer"),n}return wt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),s=0;s<this.batches.length;s++)if(t.equals(this.batches[s].settings,r)){this.batches[s].addSystem(n),this.systemToBatchIndex.set(n,s);return}var o;switch(r.renderMode){case tt.Trail:o=new Xae(r);break;case tt.Mesh:case tt.BillBoard:case tt.VerticalBillBoard:case tt.HorizontalBillBoard:case tt.StretchedBillBoard:o=new Vae(r);break}o.addSystem(n),this.batches.push(o),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(s,o){o.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ge),Jae=Yae,lj=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new S;xt(this,i),Y(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=n}return wt(i,[{key:"transform",value:function(e,t){e.x=this.locations[t%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[t%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new i(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(t){return t.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,t){var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");if(r){r.drawImage(e,0,0);var s=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var o=0;o<s.height;o++)for(var a=0;a<s.width;a++)s.data[(o*s.width+a)*4+3]>t&&this.locations.push(new $(a,s.height-o))}}}],[{key:"fromJSON",value:function(e){var t=new i(e.scaleX,e.scaleY,new S(e.position[0],e.position[1],e.position[2]));return t.locations=e.locations.map(function(n){return new $(n.x,n.y)}),t}}]),i}();function Kae(i){switch(i.type){case"TextureSequencer":return lj.fromJSON(i);default:return new lj}}var Zae=function(){function i(e){xt(this,i),Y(this,"type","ApplySequences"),Y(this,"sequencers",[]),Y(this,"time",0),Y(this,"index",0),Y(this,"pCount",0),Y(this,"delay",void 0),Y(this,"tempV",new S),this.delay=e}return wt(i,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new S,e.begin=new S,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,t){var n=this.sequencers[this.index],r=e.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),n[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,i.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,t){this.sequencers.push([e,t])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var t=$f(e,2),n=t[0],r=t[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new i(this.delay);return e.sequencers=this.sequencers.map(function(t){return[t[0].clone(),t[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var t=new i(e.delay);return e.sequencers.forEach(function(n){t.sequencers.push([Di(n.range),Kae(n.sequencer)])}),t}}]),i}();Y(Zae,"BEZIER",new PR(0,0,1,1));var he=function(i){return i[i.Number=0]="Number",i[i.Vec2=1]="Vec2",i[i.Vec3=2]="Vec3",i[i.Vec4=3]="Vec4",i[i.Boolean=4]="Boolean",i[i.AnyType=5]="AnyType",i}({}),cj=wt(function i(e,t,n,r){xt(this,i),Y(this,"input",void 0),Y(this,"inputIndex",void 0),Y(this,"output",void 0),Y(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=n,this.outputIndex=r,this.output.inputs[r]=this}),$ae=function(){function i(){xt(this,i),Y(this,"visited",new Set),Y(this,"graph_",void 0),Y(this,"context_",void 0),i.Instance=this}return wt(i,[{key:"traverse",value:function(e){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(e.id);for(var t=[],n=0;n<e.inputs.length;n++)if(e.inputs[n]instanceof cj){var r=e.inputs[n].input;this.visited.has(r.id)||this.traverse(r),t.push(r.outputValues[e.inputs[n].inputIndex])}else t.push(e.inputs[n].getValue(this.context_));e.func(this.context_,t,e.outputValues),this.graph_.nodesInOrder.push(e)}},{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 e=this.graph_.nodesInOrder,t=0;t<e.length;t++){for(var n=[],r=e[t],s=0;s<r.inputs.length;s++)if(r.inputs[s]instanceof cj)n.push(r.inputs[s].input.outputValues[r.inputs[s].inputIndex]);else if(r.inputs[s]!==void 0)n.push(r.inputs[s].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(e,t){if(this.graph_=e,this.context_=t,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<e.outputNodes.length;n++){var r=e.outputNodes[n];this.traverse(r)}e.compiled=!0}}}]),i}();Y($ae,"Instance",void 0);var oi=function(){function i(e){xt(this,i),Y(this,"name",void 0),Y(this,"nodeTypeSignatures",[]),this.name=e}return wt(i,[{key:"addSignature",value:function(e,t,n){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:t,func:n})}}]),i}(),Zx=new oi("add");Zx.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]+t[1]}),Zx.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),Zx.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),Zx.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].addVectors(t[0],t[1])});var $x=new oi("sub");$x.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]-t[1]}),$x.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),$x.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),$x.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].subVectors(t[0],t[1])});var ew=new oi("mul");ew.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]*t[1]}),ew.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),ew.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),ew.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])});var tw=new oi("div");tw.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]/t[1]}),tw.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),tw.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),tw.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])});var ele=new oi("sin");ele.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.sin(t[0])});var tle=new oi("cos");tle.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.cos(t[0])});var ile=new oi("tan");ile.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.tan(t[0])});var nle=new oi("abs");nle.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.abs(t[0])});var rle=new oi("min");rle.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.min(t[0],t[1])});var sle=new oi("max");sle.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.max(t[0],t[1])});var zR=new oi("dot");zR.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),zR.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),zR.addSignature([he.Vec4,he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])});var ole=new oi("cross");ole.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].crossVectors(t[0],t[1])});var jR=new oi("length");jR.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),jR.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),jR.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].length()});var GR=new oi("lengthSq");GR.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),GR.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),GR.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()});var QR=new oi("normalize");QR.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).normalize()}),QR.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).normalize()}),QR.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).normalize()});var hj=new oi("distance");hj.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])}),hj.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])});var ale=new oi("and");ale.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]&&t[1]});var lle=new oi("or");lle.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]||t[1]});var cle=new oi("not");cle.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=!t[0]});var iw=new oi("equal");iw.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]===t[1]}),iw.addSignature([he.Vec2,he.Vec2],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),iw.addSignature([he.Vec3,he.Vec3],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),iw.addSignature([he.Vec4,he.Vec4],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])});var hle=new oi("lessThan");hle.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<t[1]});var ule=new oi("greaterThan");ule.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>t[1]});var dle=new oi("lessThanOrEqual");dle.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<=t[1]});var ple=new oi("greaterThanOrEqual");ple.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>=t[1]});var fle=new oi("if");fle.addSignature([he.Boolean,he.AnyType,he.AnyType],[he.AnyType],function(i,e,t,n){n[0]=t[0]?t[1]:t[2]});var mle=new oi("number");mle.addSignature([],[he.Number],function(i,e,t,n){n[0]=e.value});var gle=new oi("vec2");gle.addSignature([],[he.Vec2],function(i,e,t,n){n[0]=e.value});var vle=new oi("vec3");vle.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=e.value});var Ale=new oi("vec4");Ale.addSignature([],[he.Vec4],function(i,e,t,n){n[0]=e.value});var yle=new oi("bool");yle.addSignature([],[he.Boolean],function(i,e,t,n){n[0]=e.value});var ble=new oi("particlePosition");ble.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var _le=new oi("particleVelocity");_le.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var xle=new oi("particleRotation");xle.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var wle=new oi("particleAge");wle.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var T0=new oi("output");T0.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var Sle=Object.defineProperty,Cle=Object.getOwnPropertyDescriptor,an=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Sle(e,t,r),r};const I0=ee("debugparticles"),Ele=ee("noprogressive"),Mle=ee("debugprogressive");var HR=(i=>(i[i.Birth=0]="Birth",i[i.Collision=1]="Collision",i[i.Death=2]="Death",i[i.Trigger=3]="Trigger",i[i.Manual=4]="Manual",i))(HR||{});class Xo extends Ie{constructor(){super(...arguments),h(this,"renderMode"),h(this,"particleMaterial"),h(this,"trailMaterial"),h(this,"particleMesh"),h(this,"maxParticleSize"),h(this,"minParticleSize"),h(this,"velocityScale"),h(this,"cameraVelocityScale"),h(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&ut()){const e=`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(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let t=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return t&&e&&t.side===lr&&(t=t.clone(),t.side=cn,e?this.trailMaterial=t:this.particleMaterial=t),t&&!Ele&&t._didRequestTextureLOD===void 0&&(t._didRequestTextureLOD=0,Mle&&console.log("Load material LOD",t.name),Ii.assignTextureLOD(this.context,this.sourceId,t)),t}getMesh(e){let t=null;if(!t&&(this.particleMesh instanceof ue&&(t=this.particleMesh.geometry),t===null)){t=new Un(1,1);const n=t.attributes.uv;for(let r=0;r<n.count;r++)n.setX(r,1-n.getX(r))}return new ue(t,this.getMaterial())}}an([x()],Xo.prototype,"renderMode",2),an([x(It)],Xo.prototype,"particleMaterial",2),an([x(It)],Xo.prototype,"trailMaterial",2),an([x()],Xo.prototype,"maxParticleSize",2),an([x()],Xo.prototype,"minParticleSize",2),an([x()],Xo.prototype,"velocityScale",2),an([x()],Xo.prototype,"cameraVelocityScale",2),an([x()],Xo.prototype,"lengthScale",2);class nw{constructor(e,t=1){h(this,"_curve"),h(this,"_factor"),h(this,"type","function"),this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class VR{constructor(e){h(this,"type","value"),h(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Tle extends VR{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class Ile extends VR{constructor(){super(...arguments),h(this,"_lastPosition",new S),h(this,"_lastDistance",0)}update(){const e=Pt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let s=this._lastDistance/this.system.deltaTime*r;Number.isFinite(s)||(s=0),e+=s}const t=this.system.emission.getBurst();t>0&&(e+=t/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return Ze.clamp(e,0,n/this.system.deltaTime)}}class Rle extends VR{genValue(){return this.system.isPlaying,0}}class Uh{constructor(e){h(this,"system"),h(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class Ple extends Uh{constructor(){super(...arguments),h(this,"type","NeedleTextureSheet")}update(e,t){const n=this.system.textureSheetAnimation;if(n.enabled){const r=e.age/e.life,s=n.evaluate(r);s!==void 0&&(e.uvTile=s)}}}const uj=Symbol("particleRotation");class Ble extends Uh{constructor(){super(...arguments),h(this,"type","NeedleRotation")}initialize(e){e[uj]=Math.random()}update(e,t){if(e.rotation===void 0)return;const n=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(n,e[uj])*t:this.system.renderer.renderMode===mc.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(n,r)*t}}}const dj=Symbol("sizeLerpFactor"),Dle=new S;class kle extends Uh{constructor(){super(...arguments),h(this,"type","NeedleSize"),h(this,"_minSize",0),h(this,"_maxSize",1)}initialize(e){e[dj]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,t){const n=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,e[dj]).x);let s=1;if(this.system.renderer.renderMode!==mc.Mesh&&(s=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*s,this.system.localspace){const o=vj(this.system,Dle);e.size*=o.x}}}const em=Symbol("particleLife"),WR=Symbol("trailLifetime"),pj=Symbol("trailStartLength"),qR=Symbol("trailWidthRandom");class Ole extends Uh{constructor(){super(...arguments),h(this,"type","NeedleTrail")}initialize(e){e instanceof w0&&(e[em]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[WR]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[WR]),e[pj]=e.length,e[qR]=Math.random())}update(e){var t;if((t=this.system.trails)!=null&&t.enabled&&e instanceof w0){const n=e,r=e.age/e[em],s=e.previous.values(),o=e.previous.length;for(let a=0;a<o;a++){const l=s.next().value,c=1-a/(o-1);let u=e.size;u<=0&&!this.system.trails.sizeAffectsWidth&&(u=20*this.system.trails.widthOverTrail.evaluate(.5,n[qR])),l.size=this.system.trails.getWidth(u,r,c,n[qR]),l.color.copy(e.color),this.system.trails.getColor(l.color,r,c)}if(e.age>e[em]){e.velocity.set(0,0,0);const a=(e.age-e[em])/e[WR];n.length=Ze.lerp(e[pj],0,a)}}}}const rw=Symbol("startVelocity"),fj=Symbol("gravityModifier"),XR=Symbol("gravitySpeed"),sw=Symbol("velocity lerp factor"),YR=new S;class Lle extends Uh{constructor(){super(...arguments),h(this,"type","NeedleVelocity"),h(this,"_gravityDirection",new S)}initialize(e){var t,n;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(t=this.system.inheritVelocity)!=null&&t.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[rw]?e[rw].copy(e.velocity):e[rw]=e.velocity.clone();const s=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[fj]=s*r,e[XR]=s*r*.5,e[sw]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===o0.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,t){var n;const r=e[rw],s=e[fj];if(s!==0){const p=s*e[XR];YR.copy(this._gravityDirection).multiplyScalar(p),e[XR]+=t*.05,r.add(YR)}e.velocity.copy(r);const o=e.age/e.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,o,e[sw]);const a=this.system.noise;a.enabled&&a.apply(0,e.position,e.velocity,t,e.age,e.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(e.size=l.evaluate(e.velocity,o,e[sw],e.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(e.velocity,e[sw],e.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(e,0,e.position,e.velocity,t,e.age,e.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(e.position,r,e.velocity,e.size,o,t,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const mj=Symbol("colorLerpFactor"),gj=new yi(1,1,1,1),Rd=new yi(1,1,1,1);class Ule extends Uh{constructor(){super(...arguments),h(this,"type","NeedleColor")}initialize(e){}_init(e){const t=this.system.renderer.particleMaterial;Rd.copy(this.system.main.startColor.evaluate(Math.random())),t!=null&&t.color&&(gj.copy(t.color),Rd.multiply(gj)),Rd.convertLinearToSRGB(),e.startColor.set(Rd.r,Rd.g,Rd.b,Rd.alpha),e.color.copy(e.startColor),e[mj]=Math.random()}update(e,t){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const n=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(n,e[mj]);e.color.set(r.r,r.g,r.b,r.alpha).multiply(e.startColor)}else e.color.copy(e.startColor)}}class Fle{constructor(e){h(this,"system"),h(this,"emission"),h(this,"autoDestroy"),h(this,"startLength"),h(this,"emissionBursts"),h(this,"onlyUsedByOther"),h(this,"behaviors",[]),h(this,"rendererEmitterSettings",{startLength:new es(220),followLocalOrigin:!1}),h(this,"flatWhiteTexture"),h(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new Ile(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 nw(this.system.main.startLifetime)}get startSpeed(){return new nw(this.system.main.startSpeed)}get startRotation(){return new nw(this.system.main.startRotation)}get startSize(){return new nw(this.system.main.startSize)}get startColor(){return new Kx(new Ye(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new Rle(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return tt.Trail;switch(this.system.renderer.renderMode){case mc.Billboard:return tt.BillBoard;case mc.Stretch:return tt.StretchedBillBoard;case mc.HorizontalBillboard:return tt.HorizontalBillBoard;case mc.VerticalBillboard:return tt.VerticalBillBoard;case mc.Mesh:return tt.Mesh}return tt.BillBoard}get speedFactor(){var e;let t=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===mc.Stretch&&(t*=this.system.renderer.velocityScale??1),t}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const n=t.clone();n.premultiplyAlpha=!1,n.colorSpace=di,this.clonedTexture.original=t,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=sN(new yi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Tle(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Ic}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===o0.World}}class Nle{constructor(){h(this,"burstIndex",0),h(this,"burstWaveIndex",0),h(this,"time",0),h(this,"waitEmiting",0)}}const ow=class extends Ie{constructor(){super(...arguments),h(this,"_state"),h(this,"colorOverLifetime"),h(this,"main"),h(this,"emission"),h(this,"sizeOverLifetime"),h(this,"shape"),h(this,"noise"),h(this,"trails"),h(this,"velocityOverLifetime"),h(this,"limitVelocityOverLifetime"),h(this,"inheritVelocity"),h(this,"colorBySpeed"),h(this,"textureSheetAnimation"),h(this,"rotationOverLifetime"),h(this,"rotationBySpeed"),h(this,"sizeBySpeed"),h(this,"_cameraScale",1),h(this,"__worldQuaternion",new Me),h(this,"_worldQuaternionInverted",new Me),h(this,"_worldScale",new S),h(this,"_worldPositionFrame",-1),h(this,"_worldPos",new S),h(this,"_renderer"),h(this,"_batchSystem"),h(this,"_particleSystem"),h(this,"_interface"),h(this,"_container"),h(this,"_time",0),h(this,"_isPlaying",!0),h(this,"_isUsedAsSubsystem",!1),h(this,"_didPreWarm",!1),h(this,"_bursts"),h(this,"_subEmitterSystems"),h(this,"_lastBatchesCount",-1),h(this,"lastMaterialVersion",-1)}play(i=!1){var e;i&&re.foreachComponent(this.gameObject,t=>{t instanceof ow&&t!==this&&t.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(i=!0){i&&re.foreachComponent(this.gameObject,e=>{e instanceof ow&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(i=!0,e=!1){i&&re.foreachComponent(this.gameObject,t=>{t instanceof ow&&t!==this&&t.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var i;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(i=this.emission)==null||i.reset())}emit(i){if(this._particleSystem){this.onUpdate(),i=Math.min(i,this.maxParticles-this.currentParticles),this._state||(this._state=new Nle),this._state.waitEmiting=i,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(i){this.main.playOnAwake=i}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var i;return((i=this._particleSystem)==null?void 0:i.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===o0.World}get localspace(){return this.main.simulationSpace===o0.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,Pt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(i){return this._particleSystem?(i instanceof Uh&&(i.system=this),ut()&&console.log("add behaviour",i),this._particleSystem.addBehavior(i),!0):!1}removeBehaviour(i){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,t=e.indexOf(i);return t!==-1&&e.splice(t,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(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof a0)){const n=new a0;Kp(n,t),i[e]=n}}this._bursts=i}set subEmitterSystems(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof R0)){const n=new R0;Kp(n,t),i[e]=n}}I0&&i.length>0&&console.log("SubEmitters: ",i,this),this._subEmitterSystems=i}onAfterDeserialize(i){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(Xo),!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 ge,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Jae,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Fle(this),this._particleSystem=new Nae(this._interface),this._particleSystem.addBehavior(new kle(this)),this._particleSystem.addBehavior(new Ule(this)),this._particleSystem.addBehavior(new Ple(this)),this._particleSystem.addBehavior(new Ble(this)),this._particleSystem.addBehavior(new Lle(this)),this._particleSystem.addBehavior(new Ole(this)),this._batchSystem.addSystem(this._particleSystem);const i=this._particleSystem.emitter;this.context.scene.add(i),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),I0&&(console.log(this),this.gameObject.add(new Mo(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var i,e,t,n;(i=this._container)==null||i.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(t=this._particleSystem)==null||t.emitter.removeFromParent(),(n=this._particleSystem)==null||n.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 i;this.main&&(this._didPreWarm===!1&&((i=this.main)==null?void 0:i.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var i;if(!((i=this.emission)!=null&&i.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,t=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,s=Math.min(Math.max(t,n)/Math.max(.01,this.main.simulationSpeed),r),o=Math.ceil(s/e),a=Date.now();I0&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${s} sec). Duration: ${t}, Lifetime: ${n}`);for(let l=0;l<o&&!(this.currentParticles>=this.maxParticles);l++){const c=Date.now()-a;if(c>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${c}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(i){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(i)}this._time+=i,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let i=0;i<this._batchSystem.batches.length;i++){const e=this._batchSystem.batches[i];e.layers.disableAll();const t=this.layer;e.layers.mask=1<<t}}onUpdate(){var i,e;const t=this.renderer.getMaterial(this.trails.enabled);if(t&&t.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=t.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const n=this.context.mainCamera;if(n){const o=Ui(n);this._cameraScale=o.x}const r=!this.worldspace,s=this.gameObject;if(xi(s,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ui(this.gameObject,this._worldScale),r&&this._container&&(i=this.gameObject)!=null&&i.parent){const o=vj(this,YR);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),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var i;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():ut()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const t=(i=e.particleSystem)==null?void 0:i._particleSystem;if(t){e.particleSystem._isUsedAsSubsystem=!0;const n=new aw(this,this._particleSystem,e.particleSystem,t);n.emitterType=e.type,n.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(n)}else I0&&console.warn("Could not add SubParticleSystem",e,this)}}};let On=ow;an([x(l0)],On.prototype,"colorOverLifetime",2),an([x(Ir)],On.prototype,"main",2),an([x(sl)],On.prototype,"emission",2),an([x(Ph)],On.prototype,"sizeOverLifetime",2),an([x(sn)],On.prototype,"shape",2),an([x(_i)],On.prototype,"noise",2),an([x(Yi)],On.prototype,"trails",2),an([x(on)],On.prototype,"velocityOverLifetime",2),an([x(Dn)],On.prototype,"limitVelocityOverLifetime",2),an([x(Bh)],On.prototype,"inheritVelocity",2),an([x(Ad)],On.prototype,"colorBySpeed",2),an([x(Rr)],On.prototype,"textureSheetAnimation",2),an([x(Wo)],On.prototype,"rotationOverLifetime",2),an([x(uo)],On.prototype,"rotationBySpeed",2),an([x(Cs)],On.prototype,"sizeBySpeed",2);class R0{constructor(){h(this,"particleSystem"),h(this,"emitProbability",1),h(this,"properties"),h(this,"type")}_deserialize(e,t){const n=this.particleSystem;if(n instanceof On)return;let r="";n&&typeof n.guid=="string"&&(r=n.guid,this.particleSystem=re.findByGuid(r,t)),I0&&!(this.particleSystem instanceof On)&&console.warn("Could not find particle system for sub emitter",r,t,this)}}function vj(i,e){if(e.set(1,1,1),i.gameObject.parent&&i.localspace)switch(i.main.scalingMode){case JI.Local:e=Ui(i.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!i.unsupported_scaling_mode){i.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+JI[i.main.scalingMode]+" is not supported";ut()&&$i(t),console.warn(t,i.name,i)}e=Ui(i.gameObject,e);break}return e}new S(1,1,1),new S(0,0,1);class aw{constructor(e,t,n,r){h(this,"type","NeedleParticleSubEmitter"),h(this,"emitterType"),h(this,"emitterProbability"),h(this,"q_",new Me),h(this,"v_",new S),h(this,"v2_",new S),h(this,"_emitterMatrix",new Ce),h(this,"_circularBuffer"),this.system=e,this.particleSystem=t,this.subSystem=n,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const s=1e3;this._circularBuffer=new To(()=>new Ce,s)}clone(){throw new Error("Method not implemented.")}initialize(e){e.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===HR.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===HR.Death){let r=e.life;if(e[em]!==void 0&&(r=e[em]),!(e.age+t*1.2>=r))return;const s=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=s}const n=new Ce;n.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(t,e.emissionState,n)}}var zle=Object.defineProperty,jle=Object.getOwnPropertyDescriptor,Gle=(i,e,t,n)=>{for(var r=n>1?void 0:n?jle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zle(e,t,r),r};class P0 extends Kr{constructor(){super(...arguments),h(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new HU;return this.granularity.onValueChanged=t=>{e.granularity=t},e}}Gle([x(Rt)],P0.prototype,"granularity",2),Ho("PixelationEffect",P0);class fm extends Ie{constructor(){super(...arguments),h(this,"_didAssignPlayerColor",!1),h(this,"tryAssignColor",()=>{const e=re.getComponentInParent(this.gameObject,Vo);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const t=re.getComponentInParent(this.gameObject,Er);return t!=null&&t.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(t.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Kt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Kt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield JF(.2),!this.tryAssignColor()););}assignUserColor(e){const t=fm.hashCode(e),n=fm.colorFromHashCode(t);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const s=r;s.material&&s.material.color&&this.assignColor(n,e,s)}}assignColor(e,t,n){let r=n.material;r&&(r._playerMaterial!==t&&(r=r.clone(),r._playerMaterial=t,n.material=r),r.color=e)}static hashCode(e){var t=0,n,r;if(e.length===0)return t;for(n=0;n<e.length;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t|=0;return t}static colorFromHashCode(e){const t=(e&16711680)>>16,n=(e&65280)>>8,r=e&255;return new Se(t/255,n/255,r/255)}}async function JR(i){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>eue);e.observedAttributes.includes(i)||e.observedAttributes.push(i)}var Qle=Object.defineProperty,Hle=Object.getOwnPropertyDescriptor,B0=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qle(e,t,r),r};const Yo=ee("debugskybox");JR("skybox-image"),JR("environment-image");function Aj(i,e,t,n,r){const s=new hl;s.allowDrop=!1,s.allowNetworking=!1,s.background=t,s.environment=n,re.addComponent(i.scene,s);const o=a=>{typeof a=="string"&&(Yo&&console.log(r,"CHANGED TO",a),s.setSkybox(a))};return Ek(i.domElement,r,o),s.addEventListener("destroy",()=>{Yo&&console.log("Destroyed attribute remote skybox",r),Mk(i.domElement,r,o)}),s.setSkybox(e)}ni.addContextCreatedCallback(i=>{var e;const t=i.context,n=t.domElement.getAttribute("skybox-image"),r=t.domElement.getAttribute("environment-image"),s=new Array;if(n){Yo&&console.log("Creating remote skybox to load "+n),((e=t.mainCameraComponent)==null?void 0:e.clearFlags)!==td.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=Aj(t,n,!0,!1,"skybox-image");s.push(o)}if(r){Yo&&console.log("Creating remote environment to load "+r);const o=Aj(t,r,!1,!0,"environment-image");s.push(o)}return s.length>0?ag(s):Promise.resolve()});function yj(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function bj(i){const e=yj().find(t=>t.src===i);return e?(Yo&&console.log("Skybox: Found previously loaded texture for "+i),e.texture):null}async function Vle(i){const e=await i;TM(e,!0),Pi(e)}function Wle(i,e){const t=yj();for(;t.length>5;){const n=t.shift();n&&Vle(n.texture)}e.then(n=>TM(n,!1)),t.push({src:i,texture:e})}class hl extends Ie{constructor(){super(...arguments),h(this,"url"),h(this,"allowDrop",!0),h(this,"background",!0),h(this,"environment",!0),h(this,"allowNetworking",!0),h(this,"_loader"),h(this,"_prevUrl"),h(this,"_prevLoadedEnvironment"),h(this,"_prevEnvironment",null),h(this,"_prevBackground",null),h(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),h(this,"onDragOverEvent",e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)(t==="text/uri-list"||t==="Files")&&e.preventDefault()}),h(this,"onDrop",e=>{var t,n,r,s;if(this.allowDrop&&e.dataTransfer){for(const o of e.dataTransfer.types)if(Yo&&console.log(o),o==="text/uri-list"){const a=e.dataTransfer.getData(o);Yo&&console.log(o,a);let l=(n=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:n.name;if(l||(l=(s=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:s.name),Yo&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${c}`),e.preventDefault(),this.setSkybox(c);break}else if(this.isValidTextureType(a)){console.log("[Remote Skybox] Setting skybox from url: "+a),e.preventDefault(),this.setSkybox(a);break}else{console.warn(`[RemoteSkybox] Unknown url ${a}. 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 c=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:e,url:a,apply:u=>{e.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(c)}}else if(o=="Files"){const a=e.dataTransfer.files.item(0);if(Yo&&console.log(o,a),!a)continue;if(!this.isValidTextureType(a.name)){console.warn(`[RemoteSkybox]: File "${a.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(bj(a.name)===null){const l=new Blob([a]),c=URL.createObjectURL(l);e.preventDefault(),this.setSkybox(c,a.name)}else e.preventDefault(),this.setSkybox(a.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Bi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(e,t){var n;if(!this.activeAndEnabled||!e)return!1;if(t??(t=e),this.isValidTextureType(t)||console.warn("Potentially invalid skybox url",t,"on",this.name),Yo&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(n=this._prevLoadedEnvironment)==null||n.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=e;const r=await this.loadTexture(e,t);if(!r||!this.enabled)return!1;this.url=e;const s=e.lastIndexOf("/");return r.name=e.substring(s>=0?s+1:0),this._loader instanceof Ua&&(r.colorSpace=pt),this._prevLoadedEnvironment=r,this.applySkybox(),!0}async loadTexture(e,t){var n,r,s,o,a;if(!e)return Promise.resolve(null);t??(t=e);const l=bj(t);if(l){const p=await l;if(((r=(n=p.source)==null?void 0:n.data)==null?void 0:r.length)>0||(a=(o=(s=p.source)==null?void 0:s.data)==null?void 0:o.data)!=null&&a.length)return p}const c=t.endsWith(".exr"),u=t.endsWith(".hdr");c?this._loader instanceof b_||(this._loader=new b_):u?this._loader instanceof DT||(this._loader=new DT):this._loader instanceof Ua||(this._loader=new Ua),Yo&&console.log("Loading skybox: "+e);const d=this._loader.loadAsync(e);return Wle(t,d),await d}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Wd,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Yo&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!Bi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(e){return e.startsWith("http://")||e.startsWith("https://")}isValidTextureType(e){for(const t of this.validTextureTypes)if(e.endsWith(t))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)}}B0([dI(hl.prototype.urlChangedSyncField),x(URL)],hl.prototype,"url",2),B0([x()],hl.prototype,"allowDrop",2),B0([x()],hl.prototype,"background",2),B0([x()],hl.prototype,"environment",2),B0([x()],hl.prototype,"allowNetworking",2);var qle=Object.defineProperty,Xle=Object.getOwnPropertyDescriptor,mo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Xle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&qle(e,t,r),r};const go=ee("debugsceneswitcher"),lw="scene";JR(lw);const Fh=Promise.resolve(!1);class ts extends Ie{constructor(){super(...arguments),h(this,"autoLoadFirstScene",!0),h(this,"scenes"),h(this,"loadingScene"),h(this,"queryParameterName","scene"),h(this,"useSceneName",!0),h(this,"clamp",!0),h(this,"useHistory",!0),h(this,"useKeyboard",!0),h(this,"useSwipe",!0),h(this,"useSceneLighting",!0),h(this,"preloadNext",1),h(this,"preloadPrevious",1),h(this,"preloadConcurrent",2),h(this,"_currentIndex",-1),h(this,"_currentScene"),h(this,"_engineElementOverserver"),h(this,"_preloadScheduler"),h(this,"onPopState",async e=>{if(!this.useHistory)return;const t=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=e?.state;if(r&&r.startsWith(this.guid)){const s=r.substr(this.guid.length+2);go&&console.log("PopState",s),await this.trySelectSceneFromValue(s)}}}finally{this.useHistory=t}}),h(this,"normalizedSwipeThresholdX",.1),h(this,"_didSwipe",!1),h(this,"onInputPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const n=t.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),h(this,"onInputPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),h(this,"onInputKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const n=parseInt(t)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),h(this,"__lastSwitchScene"),h(this,"__lastSwitchScenePromise"),h(this,"_currentlyLoadingScene"),h(this,"_lastLoadingScene"),h(this,"_loadingScenePromise"),h(this,"_isCurrentlyLoading",!1),h(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=[]),go&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(qi.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(qi.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(qi.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===lw){const n=this.context.domElement.getAttribute(lw);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Yle(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 e=this.context.domElement.getAttribute(lw);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(qi.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(qi.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(qi.PointerUp,this.onInputPointerUp),(e=this._preloadScheduler)==null||e.stop()}addScene(e){if(typeof e=="string"){let t=this.context.addressables.findAssetReference(e);return t||(t=new Zt(e),this.context.addressables.registerAssetReference(t)),this.scenes.push(t),t}return this.scenes.push(e),e}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,n,r;if(go&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(t=this.scenes)==null?void 0:t.find(a=>a.uri===e);if(!o){const a=Zt.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(a)}if(o)e=(n=this.scenes)==null?void 0:n.indexOf(o);else return Fh}if(!((r=this.scenes)!=null&&r.length))return Fh;if(e<0){if(this.clamp)return Fh;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Fh;e=0}const s=this.scenes[e];return this.switchScene(s)}async switchScene(e){if(!(e instanceof Zt)){const t=typeof e;return t==="string"?this.select(e):t==="number"?this.select(e):(console.warn("SceneSwitcher: Can't switch to scene",e,"of type",t),!1)}return e.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===e&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=e,this.__lastSwitchScenePromise=this.__internalSwitchScene(e),await this.__lastSwitchScenePromise)}async __internalSwitchScene(e){var t,n;if(this._currentScene){go&&console.log("UNLOAD",e.uri);const s=this.tryGetSceneEventListener(this._currentScene.asset);if(s!=null&&s.sceneClosing){const o=s.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;try{this._currentlyLoadingScene=e,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const s=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(s),await this.onStartLoading(),await e.loadAssetAsync((a,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return go&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return go&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if(go&&console.log("ADD",e.uri),this._currentScene=e,re.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0){let c=r.toString();if(this.useSceneName&&(c=_j(e.uri)),(n=this.queryParameterName)!=null&&n.length)Zy(this.queryParameterName,c,this.useHistory);else{const u=history.state,d=this.guid+"::"+r;u!==d&&history.pushState(d,"unused",location.href)}}const a=this.tryGetSceneEventListener(e.asset);if(a!=null&&a.sceneOpened){const c=a.sceneOpened(this);c instanceof Promise&&await c}const l=new CustomEvent("scene-opened",{detail:{scene:e,switcher:this,index:r}});return this.dispatchEvent(l),!0}}catch(s){console.error(s)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof Zt)return t.preload()}return Fh}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return Fh;const t=ee(this.queryParameterName);return typeof t=="boolean"?Fh:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);{const n=e.toLowerCase();for(let r=0;r<this.scenes.length;r++){const s=this.scenes[r];if(s&&_j(s.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return Hs()&&console.warn('Can not find scene: "'+e+'"',this),Fh}async onStartLoading(){var e,t;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(e=this.loadingScene)==null?void 0:e.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(t=this.loadingScene)!=null&&t.asset)){go&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const s=r.sceneOpened(this);s instanceof Promise&&await s}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var e;if(this._isCurrentlyLoading=!1,(e=this.loadingScene)!=null&&e.asset){go&&console.log("Remove loading scene",this.loadingScene.uri);const t=this.loadingScene.asset,n=this.tryGetSceneEventListener(t);if(typeof n?.sceneClosing=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(t)}if(!this._isCurrentlyLoading){const t=this.tryGetSceneEventListener(this.gameObject);if(t&&t.sceneClosing){const n=t.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(e,t=0){const n=re.foreachComponent(e,r=>r.sceneClosing?r:void 0);if(t===0&&!n&&e.children.length)for(const r of e.children){const s=this.tryGetSceneEventListener(r,t+1);if(s)return s}return n||null}}mo([x()],ts.prototype,"autoLoadFirstScene",2),mo([x(Zt)],ts.prototype,"scenes",2),mo([x(Zt)],ts.prototype,"loadingScene",2),mo([x()],ts.prototype,"queryParameterName",2),mo([x()],ts.prototype,"useSceneName",2),mo([x()],ts.prototype,"clamp",2),mo([x()],ts.prototype,"useHistory",2),mo([x()],ts.prototype,"useKeyboard",2),mo([x()],ts.prototype,"useSwipe",2),mo([x()],ts.prototype,"useSceneLighting",2),mo([x()],ts.prototype,"preloadNext",2),mo([x()],ts.prototype,"preloadPrevious",2),mo([x()],ts.prototype,"preloadConcurrent",2);function _j(i){const e=i.split("/").pop(),t=e?.split(".").shift();return t!=null&&t.length?t:i}class Yle{constructor(e,t=1,n=1,r=2){h(this,"maxLoadAhead"),h(this,"maxLoadBehind"),h(this,"maxConcurrent"),h(this,"_isRunning",!1),h(this,"_switcher"),h(this,"_loadTasks",[]),h(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=n,this.maxConcurrent=r}begin(){if(this._isRunning)return;go&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,n;const r=this._switcher.scenes,s=setInterval(()=>{if(this.allLoaded()&&(go&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(s);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,n=0,t=0);const o=n%2===0;o&&(t+=1),n+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new Jle(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1}return!0}}class Jle{constructor(e,t,n){h(this,"index"),h(this,"asset"),h(this,"tasks"),this.index=e,this.asset=t,this.tasks=n,n.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(go&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),go&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function Kle(){return new Promise((i,e)=>{const t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function Zle(i){await Kle(),i()}var $le=Object.defineProperty,ece=Object.getOwnPropertyDescriptor,vo=(i,e,t,n)=>{for(var r=n>1?void 0:n?ece(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&$le(e,t,r),r};const sr=ee("debugvideo");var xj=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(xj||{}),wj=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(wj||{}),Sj=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(Sj||{});class Xn extends Ie{constructor(){super(),h(this,"playOnAwake",!0),h(this,"aspectMode",0),h(this,"clip",null),h(this,"source",1),h(this,"url",null),h(this,"renderMode"),h(this,"targetMaterialProperty"),h(this,"targetMaterialRenderer"),h(this,"targetTexture"),h(this,"time",0),h(this,"_playbackSpeed",1),h(this,"_isLooping",!1),h(this,"_muted",!1),h(this,"_audioOutputMode",2),h(this,"playInBackground",!0),h(this,"_crossOrigin","anonymous"),h(this,"_videoElement",null),h(this,"_videoTexture",null),h(this,"_videoMaterial",null),h(this,"_isPlaying",!1),h(this,"wasPlaying",!1),h(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),h(this,"_receivedInput",!1),h(this,"_overlay",null),h(this,"_targetObjects"),h(this,"_updateAspectRoutineId",-1),h(this,"_hls"),h(this,"onHlsAvailable",()=>{var e;sr&&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),(e=this._videoElement)==null||e.play(),sr&&console.log("HLS: loaded",this.clip))}),Zle(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ee("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):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 e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}get currentVideo(){return this.clip}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&ut()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){sr&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(e){this.url!==e&&(this.url=e,this.source=1,sr&&console.log("set url",e),this._videoElement?e.endsWith(".m3u8")?this.ensureM3U8CanBePlayed():(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var e,t;sr&&console.log("VideoPlayer.onEnable",wj[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){var e;window.removeEventListener("visibilitychange",this.visibilityChanged),(e=this._overlay)==null||e.stop(),this.pause()}onDestroy(){var e;this._videoElement&&((e=this.videoElement)==null||e.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;if(this._videoElement||this.create(!1),!this._videoElement){sr&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U8){this.ensureM3U8CanBePlayed();return}sr&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),sr&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),sr&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),sr&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),sr&&console.log("PAUSE",this,this.currentTime)}create(e){let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url,!(t!=null&&t.length)&&typeof this.clip=="string"&&(t=this.clip);break}return t?(this._videoElement||(sr&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(sr&&console.log("Set Video src",t),this._videoElement.src=t):(sr&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new uD(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=pt,e&&this.handleBeginPlaying(e),sr&&console.log("Video: handle playing done...",t,e),!0):(sr&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new tce(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),sr&&console.log("created video element",e),e}handleBeginPlaying(e){var t,n;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(n=re.getComponent(this.gameObject,Sn))==null?void 0:n.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,Sj[this.renderMode],this);return}const s=r.material;if(s){this._targetObjects.push(r),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),r.material=this._videoMaterial);const o="map",a=this._videoMaterial;if(!this.targetMaterialProperty)a[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:a[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(),e&&(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 e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,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 e=++this._updateAspectRoutineId,t=void 0,n=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const s of n.getVideoTracks()){const o=s.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let s=0;s<10;s++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const s of this._targetObjects){let o=1;if(s.parent){const a=Ui(s.parent);o=a.x/a.y}switch(this.aspectMode){case 1:s.scale.y=1/r*s.scale.x*o;break;case 2:s.scale.x=r*s.scale.y*o;break}}for(let s=0;s<3;s++)yield}}get shouldUseM3U8(){return this.url!=null&&this.url.endsWith(".m3u8")&&this.source===1}ensureM3U8CanBePlayed(){if(!this.shouldUseM3U8)return;let e=document.head.querySelector("script[data-hls_library]");e?globalThis.Hls?this.onHlsAvailable():e.addEventListener("load",this.onHlsAvailable):(sr&&console.log("HLS: load script"),e=document.createElement("script"),e.dataset.hls_library="hls.js",e.src="https://cdn.jsdelivr.net/npm/hls.js@1",e.addEventListener("load",this.onHlsAvailable),document.head.append(e))}}vo([x()],Xn.prototype,"playOnAwake",2),vo([x()],Xn.prototype,"aspectMode",2),vo([x(URL)],Xn.prototype,"clip",2),vo([x()],Xn.prototype,"source",2),vo([x(URL)],Xn.prototype,"url",2),vo([x()],Xn.prototype,"renderMode",2),vo([x()],Xn.prototype,"targetMaterialProperty",2),vo([x(Sn)],Xn.prototype,"targetMaterialRenderer",2),vo([x(gt)],Xn.prototype,"targetTexture",2),vo([x()],Xn.prototype,"time",2),vo([x()],Xn.prototype,"playbackSpeed",1),vo([x()],Xn.prototype,"isLooping",1),vo([x()],Xn.prototype,"audioOutputMode",1);class tce{constructor(e){h(this,"context"),h(this,"_videos",[]),h(this,"_screenspaceModeQuad"),h(this,"_isInScreenspaceMode",!1),h(this,"_input"),this.context=e,this._input=new ice(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=rv.createPrimitive(Wu.Quad,{material:new nce(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const n=this._screenspaceModeQuad;this.context.scene.add(n),this.updateScreenspaceMaterialUniforms();const r=n.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class ice{constructor(e){h(this,"_onResizeScreenFn"),h(this,"_onKeyUpFn"),h(this,"_onMouseWheelFn"),h(this,"context"),h(this,"overlay"),h(this,"_material"),h(this,"_isPinching",!1),h(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new $;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const s=new $(r.movementX,r.movementY);s.x/=this.context.domElement.clientWidth,s.y/=this.context.domElement.clientHeight,t.set(s.x,s.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let n=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-n<.3&&this.overlay.stop(),n=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const s=r.touches[0],o=r.touches[1],a=s.clientX-o.clientX,l=s.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),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 nce extends Tt{constructor(e){super(),h(this,"_offset",new $),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new Ye(0,0,1,1)}},this.vertexShader=`
|
|
6954
|
+
}`);new S(0,0,1);var Xae=function(i){Kf(t,i);var e=Zf(t);function t(n){var r;return xt(this,t),r=e.call(this,n),Y($t(r),"positionBuffer",void 0),Y($t(r),"previousBuffer",void 0),Y($t(r),"nextBuffer",void 0),Y($t(r),"uvBuffer",void 0),Y($t(r),"sideBuffer",void 0),Y($t(r),"widthBuffer",void 0),Y($t(r),"colorBuffer",void 0),Y($t(r),"indexBuffer",void 0),Y($t(r),"vector_",new S),Y($t(r),"vector2_",new S),Y($t(r),"vector3_",new S),Y($t(r),"quaternion_",new Me),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return wt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new ft,this.indexBuffer=new $e(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Nr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Nr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Nr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Nr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Nr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Nr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new $e(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Nr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new $e(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Nr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new $(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new $(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=NR(this.settings.material.map.channel),n.map=new be(this.settings.material.map),n.mapTransform=new be(new Dt().copy(this.settings.material.map.matrix))),this.settings.renderMode===tt.Trail)this.material=new Tt({uniforms:n,defines:r,vertexShader:qae,fragmentShader:Wae,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Yh});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,s=0,o=0;this.systems.forEach(function(a){for(var l=0;l<a.particleNum;l++)o+=a.particles[l].previous.length*2}),o>this.maxParticles&&this.expandBuffers(o),this.systems.forEach(function(a){var l=n.quaternion_,c=n.vector2_,u=n.vector3_;a.emitter.matrixWorld.decompose(c,l,u);for(var d=a.particles,p=a.particleNum,f=n.settings.uTileCount,m=n.settings.vTileCount,A=1/f,v=1/m,g=0;g<p;g++){var y=d[g],b=y.uvTile%m,_=Math.floor(y.uvTile/m),E=y.previous.values(),I=E.next(),T=I.value,M=T;I.done||(I=E.next());var D=void 0;I.value!==void 0?D=I.value:D=M;for(var C=0;C<y.previous.length;C++,r+=2){if(n.positionBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.positionBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z),a.worldSpace?(n.positionBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.positionBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(y.parentMatrix?n.vector_.copy(M.position).applyMatrix4(y.parentMatrix):n.vector_.copy(M.position).applyMatrix4(a.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.previousBuffer.setXYZ(r,T.position.x,T.position.y,T.position.z),n.previousBuffer.setXYZ(r+1,T.position.x,T.position.y,T.position.z)):(y.parentMatrix?n.vector_.copy(T.position).applyMatrix4(y.parentMatrix):n.vector_.copy(T.position).applyMatrix4(a.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),a.worldSpace?(n.nextBuffer.setXYZ(r,D.position.x,D.position.y,D.position.z),n.nextBuffer.setXYZ(r+1,D.position.x,D.position.y,D.position.z)):(y.parentMatrix?n.vector_.copy(D.position).applyMatrix4(y.parentMatrix):n.vector_.copy(D.position).applyMatrix4(a.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),a.worldSpace)n.widthBuffer.setX(r,M.size),n.widthBuffer.setX(r+1,M.size);else if(y.parentMatrix)n.widthBuffer.setX(r,M.size),n.widthBuffer.setX(r+1,M.size);else{var P=(Math.abs(u.x)+Math.abs(u.y)+Math.abs(u.z))/3;n.widthBuffer.setX(r,M.size*P),n.widthBuffer.setX(r+1,M.size*P)}n.uvBuffer.setXY(r,(C/y.previous.length+b)*A,(m-_-1)*v),n.uvBuffer.setXY(r+1,(C/y.previous.length+b)*A,(m-_)*v),n.colorBuffer.setXYZW(r,M.color.x,M.color.y,M.color.z,M.color.w),n.colorBuffer.setXYZW(r+1,M.color.x,M.color.y,M.color.z,M.color.w),C+1<y.previous.length&&(n.indexBuffer.setX(s*3,r),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+2),s++,n.indexBuffer.setX(s*3,r+2),n.indexBuffer.setX(s*3+1,r+1),n.indexBuffer.setX(s*3+2,r+3),s++),T=M,M=D,I.done||(I=E.next(),I.value!==void 0&&(D=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=s*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,s*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(oj),Yae=function(i){Kf(t,i);var e=Zf(t);function t(){var n;return xt(this,t),n=e.call(this),Y($t(n),"batches",[]),Y($t(n),"systemToBatchIndex",new Map),Y($t(n),"type","BatchedRenderer"),n}return wt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),s=0;s<this.batches.length;s++)if(t.equals(this.batches[s].settings,r)){this.batches[s].addSystem(n),this.systemToBatchIndex.set(n,s);return}var o;switch(r.renderMode){case tt.Trail:o=new Xae(r);break;case tt.Mesh:case tt.BillBoard:case tt.VerticalBillBoard:case tt.HorizontalBillBoard:case tt.StretchedBillBoard:o=new Vae(r);break}o.addSystem(n),this.batches.push(o),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(o)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(s,o){o.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ge),Jae=Yae,lj=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new S;xt(this,i),Y(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=n}return wt(i,[{key:"transform",value:function(e,t){e.x=this.locations[t%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[t%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new i(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(t){return t.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,t){var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");if(r){r.drawImage(e,0,0);var s=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var o=0;o<s.height;o++)for(var a=0;a<s.width;a++)s.data[(o*s.width+a)*4+3]>t&&this.locations.push(new $(a,s.height-o))}}}],[{key:"fromJSON",value:function(e){var t=new i(e.scaleX,e.scaleY,new S(e.position[0],e.position[1],e.position[2]));return t.locations=e.locations.map(function(n){return new $(n.x,n.y)}),t}}]),i}();function Kae(i){switch(i.type){case"TextureSequencer":return lj.fromJSON(i);default:return new lj}}var Zae=function(){function i(e){xt(this,i),Y(this,"type","ApplySequences"),Y(this,"sequencers",[]),Y(this,"time",0),Y(this,"index",0),Y(this,"pCount",0),Y(this,"delay",void 0),Y(this,"tempV",new S),this.delay=e}return wt(i,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new S,e.begin=new S,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,t){var n=this.sequencers[this.index],r=e.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),n[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,i.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,t){this.sequencers.push([e,t])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var t=$f(e,2),n=t[0],r=t[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new i(this.delay);return e.sequencers=this.sequencers.map(function(t){return[t[0].clone(),t[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var t=new i(e.delay);return e.sequencers.forEach(function(n){t.sequencers.push([Di(n.range),Kae(n.sequencer)])}),t}}]),i}();Y(Zae,"BEZIER",new PR(0,0,1,1));var he=function(i){return i[i.Number=0]="Number",i[i.Vec2=1]="Vec2",i[i.Vec3=2]="Vec3",i[i.Vec4=3]="Vec4",i[i.Boolean=4]="Boolean",i[i.AnyType=5]="AnyType",i}({}),cj=wt(function i(e,t,n,r){xt(this,i),Y(this,"input",void 0),Y(this,"inputIndex",void 0),Y(this,"output",void 0),Y(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=n,this.outputIndex=r,this.output.inputs[r]=this}),$ae=function(){function i(){xt(this,i),Y(this,"visited",new Set),Y(this,"graph_",void 0),Y(this,"context_",void 0),i.Instance=this}return wt(i,[{key:"traverse",value:function(e){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(e.id);for(var t=[],n=0;n<e.inputs.length;n++)if(e.inputs[n]instanceof cj){var r=e.inputs[n].input;this.visited.has(r.id)||this.traverse(r),t.push(r.outputValues[e.inputs[n].inputIndex])}else t.push(e.inputs[n].getValue(this.context_));e.func(this.context_,t,e.outputValues),this.graph_.nodesInOrder.push(e)}},{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 e=this.graph_.nodesInOrder,t=0;t<e.length;t++){for(var n=[],r=e[t],s=0;s<r.inputs.length;s++)if(r.inputs[s]instanceof cj)n.push(r.inputs[s].input.outputValues[r.inputs[s].inputIndex]);else if(r.inputs[s]!==void 0)n.push(r.inputs[s].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(e,t){if(this.graph_=e,this.context_=t,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<e.outputNodes.length;n++){var r=e.outputNodes[n];this.traverse(r)}e.compiled=!0}}}]),i}();Y($ae,"Instance",void 0);var oi=function(){function i(e){xt(this,i),Y(this,"name",void 0),Y(this,"nodeTypeSignatures",[]),this.name=e}return wt(i,[{key:"addSignature",value:function(e,t,n){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:t,func:n})}}]),i}(),Zx=new oi("add");Zx.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]+t[1]}),Zx.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),Zx.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].addVectors(t[0],t[1])}),Zx.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].addVectors(t[0],t[1])});var $x=new oi("sub");$x.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]-t[1]}),$x.addSignature([he.Vec2,he.Vec2],[he.Vec2],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),$x.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].subVectors(t[0],t[1])}),$x.addSignature([he.Vec4,he.Vec4],[he.Vec4],function(i,e,t,n){n[0].subVectors(t[0],t[1])});var ew=new oi("mul");ew.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]*t[1]}),ew.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),ew.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])}),ew.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).multiplyScalar(t[1])});var tw=new oi("div");tw.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]/t[1]}),tw.addSignature([he.Vec2,he.Number],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),tw.addSignature([he.Vec3,he.Number],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])}),tw.addSignature([he.Vec4,he.Number],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).divideScalar(t[1])});var ele=new oi("sin");ele.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.sin(t[0])});var tle=new oi("cos");tle.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.cos(t[0])});var ile=new oi("tan");ile.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.tan(t[0])});var nle=new oi("abs");nle.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=Math.abs(t[0])});var rle=new oi("min");rle.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.min(t[0],t[1])});var sle=new oi("max");sle.addSignature([he.Number,he.Number],[he.Number],function(i,e,t,n){n[0]=Math.max(t[0],t[1])});var zR=new oi("dot");zR.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),zR.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])}),zR.addSignature([he.Vec4,he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].dot(t[1])});var ole=new oi("cross");ole.addSignature([he.Vec3,he.Vec3],[he.Vec3],function(i,e,t,n){n[0].crossVectors(t[0],t[1])});var jR=new oi("length");jR.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),jR.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].length()}),jR.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].length()});var GR=new oi("lengthSq");GR.addSignature([he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),GR.addSignature([he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()}),GR.addSignature([he.Vec4],[he.Number],function(i,e,t,n){n[0]=t[0].lengthSq()});var QR=new oi("normalize");QR.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0].copy(t[0]).normalize()}),QR.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0].copy(t[0]).normalize()}),QR.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0].copy(t[0]).normalize()});var hj=new oi("distance");hj.addSignature([he.Vec2,he.Vec2],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])}),hj.addSignature([he.Vec3,he.Vec3],[he.Number],function(i,e,t,n){n[0]=t[0].distanceTo(t[1])});var ale=new oi("and");ale.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]&&t[1]});var lle=new oi("or");lle.addSignature([he.Boolean,he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]||t[1]});var cle=new oi("not");cle.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=!t[0]});var iw=new oi("equal");iw.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]===t[1]}),iw.addSignature([he.Vec2,he.Vec2],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),iw.addSignature([he.Vec3,he.Vec3],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])}),iw.addSignature([he.Vec4,he.Vec4],[he.Boolean],function(i,e,t,n){n[0]=t[0].equals(t[1])});var hle=new oi("lessThan");hle.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<t[1]});var ule=new oi("greaterThan");ule.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>t[1]});var dle=new oi("lessThanOrEqual");dle.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]<=t[1]});var ple=new oi("greaterThanOrEqual");ple.addSignature([he.Number,he.Number],[he.Boolean],function(i,e,t,n){n[0]=t[0]>=t[1]});var fle=new oi("if");fle.addSignature([he.Boolean,he.AnyType,he.AnyType],[he.AnyType],function(i,e,t,n){n[0]=t[0]?t[1]:t[2]});var mle=new oi("number");mle.addSignature([],[he.Number],function(i,e,t,n){n[0]=e.value});var gle=new oi("vec2");gle.addSignature([],[he.Vec2],function(i,e,t,n){n[0]=e.value});var vle=new oi("vec3");vle.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=e.value});var Ale=new oi("vec4");Ale.addSignature([],[he.Vec4],function(i,e,t,n){n[0]=e.value});var yle=new oi("bool");yle.addSignature([],[he.Boolean],function(i,e,t,n){n[0]=e.value});var ble=new oi("particlePosition");ble.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var _le=new oi("particleVelocity");_le.addSignature([],[he.Vec3],function(i,e,t,n){n[0]=i.particle[e.property]});var xle=new oi("particleRotation");xle.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var wle=new oi("particleAge");wle.addSignature([],[he.Number],function(i,e,t,n){n[0]=i.particle[e.property]});var T0=new oi("output");T0.addSignature([he.Number],[he.Number],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec2],[he.Vec2],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec3],[he.Vec3],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Vec4],[he.Vec4],function(i,e,t,n){n[0]=t[0]}),T0.addSignature([he.Boolean],[he.Boolean],function(i,e,t,n){n[0]=t[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var Sle=Object.defineProperty,Cle=Object.getOwnPropertyDescriptor,an=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Sle(e,t,r),r};const I0=ee("debugparticles"),Ele=ee("noprogressive"),Mle=ee("debugprogressive");var HR=(i=>(i[i.Birth=0]="Birth",i[i.Collision=1]="Collision",i[i.Death=2]="Death",i[i.Trigger=3]="Trigger",i[i.Manual=4]="Manual",i))(HR||{});class Xo extends Ie{constructor(){super(...arguments),h(this,"renderMode"),h(this,"particleMaterial"),h(this,"trailMaterial"),h(this,"particleMesh"),h(this,"maxParticleSize"),h(this,"minParticleSize"),h(this,"velocityScale"),h(this,"cameraVelocityScale"),h(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&ut()){const e=`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(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let t=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return t&&e&&t.side===lr&&(t=t.clone(),t.side=cn,e?this.trailMaterial=t:this.particleMaterial=t),t&&!Ele&&t._didRequestTextureLOD===void 0&&(t._didRequestTextureLOD=0,Mle&&console.log("Load material LOD",t.name),Ii.assignTextureLOD(this.context,this.sourceId,t)),t}getMesh(e){let t=null;if(!t&&(this.particleMesh instanceof ue&&(t=this.particleMesh.geometry),t===null)){t=new Un(1,1);const n=t.attributes.uv;for(let r=0;r<n.count;r++)n.setX(r,1-n.getX(r))}return new ue(t,this.getMaterial())}}an([x()],Xo.prototype,"renderMode",2),an([x(It)],Xo.prototype,"particleMaterial",2),an([x(It)],Xo.prototype,"trailMaterial",2),an([x()],Xo.prototype,"maxParticleSize",2),an([x()],Xo.prototype,"minParticleSize",2),an([x()],Xo.prototype,"velocityScale",2),an([x()],Xo.prototype,"cameraVelocityScale",2),an([x()],Xo.prototype,"lengthScale",2);class nw{constructor(e,t=1){h(this,"_curve"),h(this,"_factor"),h(this,"type","function"),this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class VR{constructor(e){h(this,"type","value"),h(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Tle extends VR{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class Ile extends VR{constructor(){super(...arguments),h(this,"_lastPosition",new S),h(this,"_lastDistance",0)}update(){const e=Pt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let s=this._lastDistance/this.system.deltaTime*r;Number.isFinite(s)||(s=0),e+=s}const t=this.system.emission.getBurst();t>0&&(e+=t/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return Ze.clamp(e,0,n/this.system.deltaTime)}}class Rle extends VR{genValue(){return this.system.isPlaying,0}}class Uh{constructor(e){h(this,"system"),h(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class Ple extends Uh{constructor(){super(...arguments),h(this,"type","NeedleTextureSheet")}update(e,t){const n=this.system.textureSheetAnimation;if(n.enabled){const r=e.age/e.life,s=n.evaluate(r);s!==void 0&&(e.uvTile=s)}}}const uj=Symbol("particleRotation");class Ble extends Uh{constructor(){super(...arguments),h(this,"type","NeedleRotation")}initialize(e){e[uj]=Math.random()}update(e,t){if(e.rotation===void 0)return;const n=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(n,e[uj])*t:this.system.renderer.renderMode===mc.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(n,r)*t}}}const dj=Symbol("sizeLerpFactor"),Dle=new S;class kle extends Uh{constructor(){super(...arguments),h(this,"type","NeedleSize"),h(this,"_minSize",0),h(this,"_maxSize",1)}initialize(e){e[dj]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,t){const n=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,e[dj]).x);let s=1;if(this.system.renderer.renderMode!==mc.Mesh&&(s=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*s,this.system.localspace){const o=vj(this.system,Dle);e.size*=o.x}}}const em=Symbol("particleLife"),WR=Symbol("trailLifetime"),pj=Symbol("trailStartLength"),qR=Symbol("trailWidthRandom");class Ole extends Uh{constructor(){super(...arguments),h(this,"type","NeedleTrail")}initialize(e){e instanceof w0&&(e[em]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[WR]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[WR]),e[pj]=e.length,e[qR]=Math.random())}update(e){var t;if((t=this.system.trails)!=null&&t.enabled&&e instanceof w0){const n=e,r=e.age/e[em],s=e.previous.values(),o=e.previous.length;for(let a=0;a<o;a++){const l=s.next().value,c=1-a/(o-1);let u=e.size;u<=0&&!this.system.trails.sizeAffectsWidth&&(u=20*this.system.trails.widthOverTrail.evaluate(.5,n[qR])),l.size=this.system.trails.getWidth(u,r,c,n[qR]),l.color.copy(e.color),this.system.trails.getColor(l.color,r,c)}if(e.age>e[em]){e.velocity.set(0,0,0);const a=(e.age-e[em])/e[WR];n.length=Ze.lerp(e[pj],0,a)}}}}const rw=Symbol("startVelocity"),fj=Symbol("gravityModifier"),XR=Symbol("gravitySpeed"),sw=Symbol("velocity lerp factor"),YR=new S;class Lle extends Uh{constructor(){super(...arguments),h(this,"type","NeedleVelocity"),h(this,"_gravityDirection",new S)}initialize(e){var t,n;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(t=this.system.inheritVelocity)!=null&&t.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[rw]?e[rw].copy(e.velocity):e[rw]=e.velocity.clone();const s=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[fj]=s*r,e[XR]=s*r*.5,e[sw]=Math.random(),(n=this.system.velocityOverLifetime)==null||n.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===o0.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,t){var n;const r=e[rw],s=e[fj];if(s!==0){const p=s*e[XR];YR.copy(this._gravityDirection).multiplyScalar(p),e[XR]+=t*.05,r.add(YR)}e.velocity.copy(r);const o=e.age/e.life;(n=this.system.inheritVelocity)!=null&&n.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,o,e[sw]);const a=this.system.noise;a.enabled&&a.apply(0,e.position,e.velocity,t,e.age,e.life);const l=this.system.sizeBySpeed;l!=null&&l.enabled&&(e.size=l.evaluate(e.velocity,o,e[sw],e.size));const c=this.system.colorBySpeed;c!=null&&c.enabled&&c.evaluate(e.velocity,e[sw],e.color);const u=this.system.velocityOverLifetime;u.enabled&&u.apply(e,0,e.position,e.velocity,t,e.age,e.life);const d=this.system.limitVelocityOverLifetime;d.enabled&&d.apply(e.position,r,e.velocity,e.size,o,t,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const mj=Symbol("colorLerpFactor"),gj=new yi(1,1,1,1),Rd=new yi(1,1,1,1);class Ule extends Uh{constructor(){super(...arguments),h(this,"type","NeedleColor")}initialize(e){}_init(e){const t=this.system.renderer.particleMaterial;Rd.copy(this.system.main.startColor.evaluate(Math.random())),t!=null&&t.color&&(gj.copy(t.color),Rd.multiply(gj)),Rd.convertLinearToSRGB(),e.startColor.set(Rd.r,Rd.g,Rd.b,Rd.alpha),e.color.copy(e.startColor),e[mj]=Math.random()}update(e,t){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const n=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(n,e[mj]);e.color.set(r.r,r.g,r.b,r.alpha).multiply(e.startColor)}else e.color.copy(e.startColor)}}class Fle{constructor(e){h(this,"system"),h(this,"emission"),h(this,"autoDestroy"),h(this,"startLength"),h(this,"emissionBursts"),h(this,"onlyUsedByOther"),h(this,"behaviors",[]),h(this,"rendererEmitterSettings",{startLength:new es(220),followLocalOrigin:!1}),h(this,"flatWhiteTexture"),h(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new Ile(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 nw(this.system.main.startLifetime)}get startSpeed(){return new nw(this.system.main.startSpeed)}get startRotation(){return new nw(this.system.main.startRotation)}get startSize(){return new nw(this.system.main.startSize)}get startColor(){return new Kx(new Ye(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new Rle(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return tt.Trail;switch(this.system.renderer.renderMode){case mc.Billboard:return tt.BillBoard;case mc.Stretch:return tt.StretchedBillBoard;case mc.HorizontalBillboard:return tt.HorizontalBillBoard;case mc.VerticalBillboard:return tt.VerticalBillBoard;case mc.Mesh:return tt.Mesh}return tt.BillBoard}get speedFactor(){var e;let t=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===mc.Stretch&&(t*=this.system.renderer.velocityScale??1),t}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const n=t.clone();n.premultiplyAlpha=!1,n.colorSpace=di,this.clonedTexture.original=t,this.clonedTexture.clone=n}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=sN(new yi(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Tle(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Ic}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===o0.World}}class Nle{constructor(){h(this,"burstIndex",0),h(this,"burstWaveIndex",0),h(this,"time",0),h(this,"waitEmiting",0)}}const ow=class extends Ie{constructor(){super(...arguments),h(this,"_state"),h(this,"colorOverLifetime"),h(this,"main"),h(this,"emission"),h(this,"sizeOverLifetime"),h(this,"shape"),h(this,"noise"),h(this,"trails"),h(this,"velocityOverLifetime"),h(this,"limitVelocityOverLifetime"),h(this,"inheritVelocity"),h(this,"colorBySpeed"),h(this,"textureSheetAnimation"),h(this,"rotationOverLifetime"),h(this,"rotationBySpeed"),h(this,"sizeBySpeed"),h(this,"_cameraScale",1),h(this,"__worldQuaternion",new Me),h(this,"_worldQuaternionInverted",new Me),h(this,"_worldScale",new S),h(this,"_worldPositionFrame",-1),h(this,"_worldPos",new S),h(this,"_renderer"),h(this,"_batchSystem"),h(this,"_particleSystem"),h(this,"_interface"),h(this,"_container"),h(this,"_time",0),h(this,"_isPlaying",!0),h(this,"_isUsedAsSubsystem",!1),h(this,"_didPreWarm",!1),h(this,"_bursts"),h(this,"_subEmitterSystems"),h(this,"_lastBatchesCount",-1),h(this,"lastMaterialVersion",-1)}play(i=!1){var e;i&&re.foreachComponent(this.gameObject,t=>{t instanceof ow&&t!==this&&t.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(i=!0){i&&re.foreachComponent(this.gameObject,e=>{e instanceof ow&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(i=!0,e=!1){i&&re.foreachComponent(this.gameObject,t=>{t instanceof ow&&t!==this&&t.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var i;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(i=this.emission)==null||i.reset())}emit(i){if(this._particleSystem){this.onUpdate(),i=Math.min(i,this.maxParticles-this.currentParticles),this._state||(this._state=new Nle),this._state.waitEmiting=i,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(i){this.main.playOnAwake=i}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var i;return((i=this._particleSystem)==null?void 0:i.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===o0.World}get localspace(){return this.main.simulationSpace===o0.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,Pt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(i){return this._particleSystem?(i instanceof Uh&&(i.system=this),ut()&&console.log("add behaviour",i),this._particleSystem.addBehavior(i),!0):!1}removeBehaviour(i){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,t=e.indexOf(i);return t!==-1&&e.splice(t,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(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof a0)){const n=new a0;Kp(n,t),i[e]=n}}this._bursts=i}set subEmitterSystems(i){for(let e=0;e<i.length;e++){const t=i[e];if(!(t instanceof R0)){const n=new R0;Kp(n,t),i[e]=n}}I0&&i.length>0&&console.log("SubEmitters: ",i,this),this._subEmitterSystems=i}onAfterDeserialize(i){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(Xo),!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 ge,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new Jae,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Fle(this),this._particleSystem=new Nae(this._interface),this._particleSystem.addBehavior(new kle(this)),this._particleSystem.addBehavior(new Ule(this)),this._particleSystem.addBehavior(new Ple(this)),this._particleSystem.addBehavior(new Ble(this)),this._particleSystem.addBehavior(new Lle(this)),this._particleSystem.addBehavior(new Ole(this)),this._batchSystem.addSystem(this._particleSystem);const i=this._particleSystem.emitter;this.context.scene.add(i),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),I0&&(console.log(this),this.gameObject.add(new Mo(1)))}start(){this.addSubParticleSystems(),this.updateLayers()}onDestroy(){var i,e,t,n;(i=this._container)==null||i.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(t=this._particleSystem)==null||t.emitter.removeFromParent(),(n=this._particleSystem)==null||n.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 i;this.main&&(this._didPreWarm===!1&&((i=this.main)==null?void 0:i.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var i;if(!((i=this.emission)!=null&&i.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,t=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,s=Math.min(Math.max(t,n)/Math.max(.01,this.main.simulationSpeed),r),o=Math.ceil(s/e),a=Date.now();I0&&console.log(`Particles ${this.name} - Prewarm for ${o} frames (${s} sec). Duration: ${t}, Lifetime: ${n}`);for(let l=0;l<o&&!(this.currentParticles>=this.maxParticles);l++){const c=Date.now()-a;if(c>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${c}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(i){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(i)}this._time+=i,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let i=0;i<this._batchSystem.batches.length;i++){const e=this._batchSystem.batches[i];e.layers.disableAll();const t=this.layer;e.layers.mask=1<<t}}onUpdate(){var i,e;const t=this.renderer.getMaterial(this.trails.enabled);if(t&&t.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=t.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const n=this.context.mainCamera;if(n){const o=Ui(n);this._cameraScale=o.x}const r=!this.worldspace,s=this.gameObject;if(xi(s,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ui(this.gameObject,this._worldScale),r&&this._container&&(i=this.gameObject)!=null&&i.parent){const o=vj(this,YR);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),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var i;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():ut()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const t=(i=e.particleSystem)==null?void 0:i._particleSystem;if(t){e.particleSystem._isUsedAsSubsystem=!0;const n=new aw(this,this._particleSystem,e.particleSystem,t);n.emitterType=e.type,n.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(n)}else I0&&console.warn("Could not add SubParticleSystem",e,this)}}};let On=ow;an([x(l0)],On.prototype,"colorOverLifetime",2),an([x(Ir)],On.prototype,"main",2),an([x(sl)],On.prototype,"emission",2),an([x(Ph)],On.prototype,"sizeOverLifetime",2),an([x(sn)],On.prototype,"shape",2),an([x(_i)],On.prototype,"noise",2),an([x(Yi)],On.prototype,"trails",2),an([x(on)],On.prototype,"velocityOverLifetime",2),an([x(Dn)],On.prototype,"limitVelocityOverLifetime",2),an([x(Bh)],On.prototype,"inheritVelocity",2),an([x(Ad)],On.prototype,"colorBySpeed",2),an([x(Rr)],On.prototype,"textureSheetAnimation",2),an([x(Wo)],On.prototype,"rotationOverLifetime",2),an([x(uo)],On.prototype,"rotationBySpeed",2),an([x(Cs)],On.prototype,"sizeBySpeed",2);class R0{constructor(){h(this,"particleSystem"),h(this,"emitProbability",1),h(this,"properties"),h(this,"type")}_deserialize(e,t){const n=this.particleSystem;if(n instanceof On)return;let r="";n&&typeof n.guid=="string"&&(r=n.guid,this.particleSystem=re.findByGuid(r,t)),I0&&!(this.particleSystem instanceof On)&&console.warn("Could not find particle system for sub emitter",r,t,this)}}function vj(i,e){if(e.set(1,1,1),i.gameObject.parent&&i.localspace)switch(i.main.scalingMode){case JI.Local:e=Ui(i.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!i.unsupported_scaling_mode){i.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+JI[i.main.scalingMode]+" is not supported";ut()&&$i(t),console.warn(t,i.name,i)}e=Ui(i.gameObject,e);break}return e}new S(1,1,1),new S(0,0,1);class aw{constructor(e,t,n,r){h(this,"type","NeedleParticleSubEmitter"),h(this,"emitterType"),h(this,"emitterProbability"),h(this,"q_",new Me),h(this,"v_",new S),h(this,"v2_",new S),h(this,"_emitterMatrix",new Ce),h(this,"_circularBuffer"),this.system=e,this.particleSystem=t,this.subSystem=n,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const s=1e3;this._circularBuffer=new To(()=>new Ce,s)}clone(){throw new Error("Method not implemented.")}initialize(e){e.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===HR.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===HR.Death){let r=e.life;if(e[em]!==void 0&&(r=e[em]),!(e.age+t*1.2>=r))return;const s=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=s}const n=new Ce;n.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||n.multiplyMatrices(this._emitterMatrix,n),this.subParticleSystem.emit(t,e.emissionState,n)}}var zle=Object.defineProperty,jle=Object.getOwnPropertyDescriptor,Gle=(i,e,t,n)=>{for(var r=n>1?void 0:n?jle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&zle(e,t,r),r};class P0 extends Kr{constructor(){super(...arguments),h(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new HU;return this.granularity.onValueChanged=t=>{e.granularity=t},e}}Gle([x(Rt)],P0.prototype,"granularity",2),Ho("PixelationEffect",P0);class fm extends Ie{constructor(){super(...arguments),h(this,"_didAssignPlayerColor",!1),h(this,"tryAssignColor",()=>{const e=re.getComponentInParent(this.gameObject,Vo);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const t=re.getComponentInParent(this.gameObject,Er);return t!=null&&t.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(t.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Kt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Kt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield JF(.2),!this.tryAssignColor()););}assignUserColor(e){const t=fm.hashCode(e),n=fm.colorFromHashCode(t);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const s=r;s.material&&s.material.color&&this.assignColor(n,e,s)}}assignColor(e,t,n){let r=n.material;r&&(r._playerMaterial!==t&&(r=r.clone(),r._playerMaterial=t,n.material=r),r.color=e)}static hashCode(e){var t=0,n,r;if(e.length===0)return t;for(n=0;n<e.length;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t|=0;return t}static colorFromHashCode(e){const t=(e&16711680)>>16,n=(e&65280)>>8,r=e&255;return new Se(t/255,n/255,r/255)}}async function JR(i){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>eue);e.observedAttributes.includes(i)||e.observedAttributes.push(i)}var Qle=Object.defineProperty,Hle=Object.getOwnPropertyDescriptor,B0=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qle(e,t,r),r};const Yo=ee("debugskybox");JR("skybox-image"),JR("environment-image");function Aj(i,e,t,n,r){const s=new hl;s.allowDrop=!1,s.allowNetworking=!1,s.background=t,s.environment=n,re.addComponent(i.scene,s);const o=a=>{typeof a=="string"&&(Yo&&console.log(r,"CHANGED TO",a),s.setSkybox(a))};return Ek(i.domElement,r,o),s.addEventListener("destroy",()=>{Yo&&console.log("Destroyed attribute remote skybox",r),Mk(i.domElement,r,o)}),s.setSkybox(e)}ni.addContextCreatedCallback(i=>{var e;const t=i.context,n=t.domElement.getAttribute("skybox-image"),r=t.domElement.getAttribute("environment-image"),s=new Array;if(n){Yo&&console.log("Creating remote skybox to load "+n),((e=t.mainCameraComponent)==null?void 0:e.clearFlags)!==td.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=Aj(t,n,!0,!1,"skybox-image");s.push(o)}if(r){Yo&&console.log("Creating remote environment to load "+r);const o=Aj(t,r,!1,!0,"environment-image");s.push(o)}return s.length>0?ag(s):Promise.resolve()});function yj(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function bj(i){const e=yj().find(t=>t.src===i);return e?(Yo&&console.log("Skybox: Found previously loaded texture for "+i),e.texture):null}async function Vle(i){const e=await i;TM(e,!0),Pi(e)}function Wle(i,e){const t=yj();for(;t.length>5;){const n=t.shift();n&&Vle(n.texture)}e.then(n=>TM(n,!1)),t.push({src:i,texture:e})}class hl extends Ie{constructor(){super(...arguments),h(this,"url"),h(this,"allowDrop",!0),h(this,"background",!0),h(this,"environment",!0),h(this,"allowNetworking",!0),h(this,"_loader"),h(this,"_prevUrl"),h(this,"_prevLoadedEnvironment"),h(this,"_prevEnvironment",null),h(this,"_prevBackground",null),h(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]),h(this,"onDragOverEvent",e=>{if(this.allowDrop&&e.dataTransfer)for(const t of e.dataTransfer.types)(t==="text/uri-list"||t==="Files")&&e.preventDefault()}),h(this,"onDrop",e=>{var t,n,r,s;if(this.allowDrop&&e.dataTransfer){for(const o of e.dataTransfer.types)if(Yo&&console.log(o),o==="text/uri-list"){const a=e.dataTransfer.getData(o);Yo&&console.log(o,a);let l=(n=(t=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(a))==null?void 0:t.groups)==null?void 0:n.name;if(l||(l=(s=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(a))==null?void 0:r.groups)==null?void 0:s.name),Yo&&console.log(l),l){const c="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${c}`),e.preventDefault(),this.setSkybox(c);break}else if(this.isValidTextureType(a)){console.log("[Remote Skybox] Setting skybox from url: "+a),e.preventDefault(),this.setSkybox(a);break}else{console.warn(`[RemoteSkybox] Unknown url ${a}. 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 c=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:e,url:a,apply:u=>{e.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(c)}}else if(o=="Files"){const a=e.dataTransfer.files.item(0);if(Yo&&console.log(o,a),!a)continue;if(!this.isValidTextureType(a.name)){console.warn(`[RemoteSkybox]: File "${a.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(bj(a.name)===null){const l=new Blob([a]),c=URL.createObjectURL(l);e.preventDefault(),this.setSkybox(c,a.name)}else e.preventDefault(),this.setSkybox(a.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var e;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Bi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(e=this.context.mainCameraComponent)==null||e.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(e,t){var n;if(!this.activeAndEnabled||!e)return!1;if(t??(t=e),this.isValidTextureType(t)||console.warn("Potentially invalid skybox url",t,"on",this.name),Yo&&console.log("Remote skybox url?: "+e),this._prevUrl===e&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(n=this._prevLoadedEnvironment)==null||n.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=e;const r=await this.loadTexture(e,t);if(!r||!this.enabled)return!1;this.url=e;const s=e.lastIndexOf("/");return r.name=e.substring(s>=0?s+1:0),this._loader instanceof Ua&&(r.colorSpace=pt),this._prevLoadedEnvironment=r,this.applySkybox(),!0}async loadTexture(e,t){var n,r,s,o,a;if(!e)return Promise.resolve(null);t??(t=e);const l=bj(t);if(l){const p=await l;if(((r=(n=p.source)==null?void 0:n.data)==null?void 0:r.length)>0||(a=(o=(s=p.source)==null?void 0:s.data)==null?void 0:o.data)!=null&&a.length)return p}const c=t.endsWith(".exr"),u=t.endsWith(".hdr");c?this._loader instanceof b_||(this._loader=new b_):u?this._loader instanceof DT||(this._loader=new DT):this._loader instanceof Ua||(this._loader=new Ua),Yo&&console.log("Loading skybox: "+e);const d=this._loader.loadAsync(e);return Wle(t,d),await d}applySkybox(){var e;const t=this._prevLoadedEnvironment;t&&(t.mapping=Wd,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Yo&&console.log("Set remote skybox",this.url),this.environment&&(this.context.scene.environment=t),this.background&&!Bi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((e=this.context.mainCameraComponent)==null?void 0:e.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(e){return e.startsWith("http://")||e.startsWith("https://")}isValidTextureType(e){for(const t of this.validTextureTypes)if(e.endsWith(t))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)}}B0([dI(hl.prototype.urlChangedSyncField),x(URL)],hl.prototype,"url",2),B0([x()],hl.prototype,"allowDrop",2),B0([x()],hl.prototype,"background",2),B0([x()],hl.prototype,"environment",2),B0([x()],hl.prototype,"allowNetworking",2);var qle=Object.defineProperty,Xle=Object.getOwnPropertyDescriptor,mo=(i,e,t,n)=>{for(var r=n>1?void 0:n?Xle(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&qle(e,t,r),r};const go=ee("debugsceneswitcher"),lw="scene";JR(lw);const Fh=Promise.resolve(!1);class ts extends Ie{constructor(){super(...arguments),h(this,"autoLoadFirstScene",!0),h(this,"scenes"),h(this,"loadingScene"),h(this,"queryParameterName","scene"),h(this,"useSceneName",!0),h(this,"clamp",!0),h(this,"useHistory",!0),h(this,"useKeyboard",!0),h(this,"useSwipe",!0),h(this,"useSceneLighting",!0),h(this,"preloadNext",1),h(this,"preloadPrevious",1),h(this,"preloadConcurrent",2),h(this,"_currentIndex",-1),h(this,"_currentScene"),h(this,"_engineElementOverserver"),h(this,"_preloadScheduler"),h(this,"onPopState",async e=>{if(!this.useHistory)return;const t=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=e?.state;if(r&&r.startsWith(this.guid)){const s=r.substr(this.guid.length+2);go&&console.log("PopState",s),await this.trySelectSceneFromValue(s)}}}finally{this.useHistory=t}}),h(this,"normalizedSwipeThresholdX",.1),h(this,"_didSwipe",!1),h(this,"onInputPointerMove",e=>{if(this.useSwipe&&!this._didSwipe&&e.button===0&&e.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const t=this.context.input.getPointerPositionDelta(e.button);if(t){const n=t.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}}),h(this,"onInputPointerUp",e=>{e.button===0&&(this._didSwipe=!1)}),h(this,"onInputKeyDown",e=>{if(!this.useKeyboard||!this.scenes)return;const t=e.key.toLowerCase();if(!t)return;const n=parseInt(t)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(t){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}}),h(this,"__lastSwitchScene"),h(this,"__lastSwitchScenePromise"),h(this,"_currentlyLoadingScene"),h(this,"_lastLoadingScene"),h(this,"_loadingScenePromise"),h(this,"_isCurrentlyLoading",!1),h(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=[]),go&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(qi.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(qi.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(qi.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName===lw){const n=this.context.domElement.getAttribute(lw);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Yle(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 e=this.context.domElement.getAttribute(lw);try{(e===null||!await this.trySelectSceneFromValue(e))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var e;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(qi.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(qi.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(qi.PointerUp,this.onInputPointerUp),(e=this._preloadScheduler)==null||e.stop()}addScene(e){if(typeof e=="string"){let t=this.context.addressables.findAssetReference(e);return t||(t=new Zt(e),this.context.addressables.registerAssetReference(t)),this.scenes.push(t),t}return this.scenes.push(e),e}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(e){var t,n,r;if(go&&console.log("select",e),typeof e=="object"&&console.warn('Switching to "'+e+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof e=="string"){const o=(t=this.scenes)==null?void 0:t.find(a=>a.uri===e);if(!o){const a=Zt.getOrCreate(this.sourceId??"",e,this.context);return this.switchScene(a)}if(o)e=(n=this.scenes)==null?void 0:n.indexOf(o);else return Fh}if(!((r=this.scenes)!=null&&r.length))return Fh;if(e<0){if(this.clamp)return Fh;e=this.scenes.length-1}else if(e>=this.scenes.length){if(this.clamp)return Fh;e=0}const s=this.scenes[e];return this.switchScene(s)}async switchScene(e){if(!(e instanceof Zt)){const t=typeof e;return t==="string"?this.select(e):t==="number"?this.select(e):(console.warn("SceneSwitcher: Can't switch to scene",e,"of type",t),!1)}return e.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===e&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=e,this.__lastSwitchScenePromise=this.__internalSwitchScene(e),await this.__lastSwitchScenePromise)}async __internalSwitchScene(e){var t,n;if(this._currentScene){go&&console.log("UNLOAD",e.uri);const s=this.tryGetSceneEventListener(this._currentScene.asset);if(s!=null&&s.sceneClosing){const o=s.sceneClosing();o instanceof Promise&&await o}this._currentScene.unload()}this._currentScene=void 0;const r=this._currentIndex=((t=this.scenes)==null?void 0:t.indexOf(e))??-1;try{this._currentlyLoadingScene=e,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const s=new CustomEvent("loadscene-start",{detail:{scene:e,switcher:this,index:r}});this.dispatchEvent(s),await this.onStartLoading(),await e.loadAssetAsync((a,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const o=new CustomEvent("loadscene-finished",{detail:{scene:e,switcher:this,index:r}});if(this.dispatchEvent(o),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,o.defaultPrevented)return go&&console.warn("Adding loaded scene prevented:",e,o),!1;if(!e.asset)return go&&console.warn("Failed loading scene:",e),!1;if(this._currentIndex===r){if(go&&console.log("ADD",e.uri),this._currentScene=e,re.add(e.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(e),this.useHistory&&r>=0){let c=r.toString();if(this.useSceneName&&(c=_j(e.uri)),(n=this.queryParameterName)!=null&&n.length)Zy(this.queryParameterName,c,this.useHistory);else{const u=history.state,d=this.guid+"::"+r;u!==d&&history.pushState(d,"unused",location.href)}}const a=this.tryGetSceneEventListener(e.asset);if(a!=null&&a.sceneOpened){const c=a.sceneOpened(this);c instanceof Promise&&await c}const l=new CustomEvent("scene-opened",{detail:{scene:e,switcher:this,index:r}});return this.dispatchEvent(l),!0}}catch(s){console.error(s)}return!1}preload(e){if(e>=0&&e<this.scenes.length){const t=this.scenes[e];if(t instanceof Zt)return t.preload()}return Fh}tryLoadFromQueryParam(){var e;if(!((e=this.queryParameterName)!=null&&e.length))return Fh;const t=ee(this.queryParameterName);return typeof t=="boolean"?Fh:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(e){if(typeof e=="string"){const t=parseInt(e);if(t>=0&&t<this.scenes.length)return this.select(t);{const n=e.toLowerCase();for(let r=0;r<this.scenes.length;r++){const s=this.scenes[r];if(s&&_j(s.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof e=="number"&&e>=0&&e<this.scenes.length)return this.select(e);return Hs()&&console.warn('Can not find scene: "'+e+'"',this),Fh}async onStartLoading(){var e,t;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(e=this.loadingScene)==null?void 0:e.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&(t=this.loadingScene)!=null&&t.asset)){go&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const s=r.sceneOpened(this);s instanceof Promise&&await s}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var e;if(this._isCurrentlyLoading=!1,(e=this.loadingScene)!=null&&e.asset){go&&console.log("Remove loading scene",this.loadingScene.uri);const t=this.loadingScene.asset,n=this.tryGetSceneEventListener(t);if(typeof n?.sceneClosing=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(t)}if(!this._isCurrentlyLoading){const t=this.tryGetSceneEventListener(this.gameObject);if(t&&t.sceneClosing){const n=t.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(e,t=0){const n=re.foreachComponent(e,r=>r.sceneClosing?r:void 0);if(t===0&&!n&&e.children.length)for(const r of e.children){const s=this.tryGetSceneEventListener(r,t+1);if(s)return s}return n||null}}mo([x()],ts.prototype,"autoLoadFirstScene",2),mo([x(Zt)],ts.prototype,"scenes",2),mo([x(Zt)],ts.prototype,"loadingScene",2),mo([x()],ts.prototype,"queryParameterName",2),mo([x()],ts.prototype,"useSceneName",2),mo([x()],ts.prototype,"clamp",2),mo([x()],ts.prototype,"useHistory",2),mo([x()],ts.prototype,"useKeyboard",2),mo([x()],ts.prototype,"useSwipe",2),mo([x()],ts.prototype,"useSceneLighting",2),mo([x()],ts.prototype,"preloadNext",2),mo([x()],ts.prototype,"preloadPrevious",2),mo([x()],ts.prototype,"preloadConcurrent",2);function _j(i){const e=i.split("/").pop(),t=e?.split(".").shift();return t!=null&&t.length?t:i}class Yle{constructor(e,t=1,n=1,r=2){h(this,"maxLoadAhead"),h(this,"maxLoadBehind"),h(this,"maxConcurrent"),h(this,"_isRunning",!1),h(this,"_switcher"),h(this,"_loadTasks",[]),h(this,"_maxConcurrentLoads",1),this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=n,this.maxConcurrent=r}begin(){if(this._isRunning)return;go&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,n;const r=this._switcher.scenes,s=setInterval(()=>{if(this.allLoaded()&&(go&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(s);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,n=0,t=0);const o=n%2===0;o&&(t+=1),n+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const l=o?e+t:e-t;if(l<0||l<0||l>=r.length)return;const c=r[l];new Jle(l,c,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if(e?.isLoaded()===!1)return!1}return!0}}class Jle{constructor(e,t,n){h(this,"index"),h(this,"asset"),h(this,"tasks"),this.index=e,this.asset=t,this.tasks=n,n.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(go&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),go&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function Kle(){return new Promise((i,e)=>{const t=()=>{t!=null&&(document.removeEventListener("pointerdown",t),document.removeEventListener("click",t),document.removeEventListener("dragstart",t),document.removeEventListener("touchstart",t),i())};document.addEventListener("pointerdown",t),document.addEventListener("click",t),document.addEventListener("dragstart",t),document.addEventListener("touchstart",t)})}async function Zle(i){await Kle(),i()}var $le=Object.defineProperty,ece=Object.getOwnPropertyDescriptor,vo=(i,e,t,n)=>{for(var r=n>1?void 0:n?ece(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&$le(e,t,r),r};const sr=ee("debugvideo");var xj=(i=>(i[i.None=0]="None",i[i.AdjustHeight=1]="AdjustHeight",i[i.AdjustWidth=2]="AdjustWidth",i))(xj||{}),wj=(i=>(i[i.VideoClip=0]="VideoClip",i[i.Url=1]="Url",i))(wj||{}),Sj=(i=>(i[i.CameraFarPlane=0]="CameraFarPlane",i[i.CameraNearPlane=1]="CameraNearPlane",i[i.RenderTexture=2]="RenderTexture",i[i.MaterialOverride=3]="MaterialOverride",i))(Sj||{});class Xn extends Ie{constructor(){super(),h(this,"playOnAwake",!0),h(this,"aspectMode",0),h(this,"clip",null),h(this,"source",1),h(this,"_url",null),h(this,"renderMode"),h(this,"targetMaterialProperty"),h(this,"targetMaterialRenderer"),h(this,"targetTexture"),h(this,"time",0),h(this,"_playbackSpeed",1),h(this,"_isLooping",!1),h(this,"_muted",!1),h(this,"_audioOutputMode",2),h(this,"playInBackground",!0),h(this,"_crossOrigin","anonymous"),h(this,"_videoElement",null),h(this,"_videoTexture",null),h(this,"_videoMaterial",null),h(this,"_isPlaying",!1),h(this,"wasPlaying",!1),h(this,"visibilityChanged",e=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}}),h(this,"_receivedInput",!1),h(this,"_overlay",null),h(this,"_targetObjects"),h(this,"_updateAspectRoutineId",-1),h(this,"_hls"),h(this,"onHlsAvailable",()=>{var e;sr&&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),(e=this._videoElement)==null||e.play(),sr&&console.log("HLS: loaded",this.clip))}),Zle(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ee("videoscreenspace")&&window.addEventListener("keydown",e=>{e.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(e){const t=this._url!==e;this.__didAwake?t&&this.setClipURL(e??""):this._url=e}get playbackSpeed(){var e;return((e=this._videoElement)==null?void 0:e.playbackRate)??this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._videoElement&&(this._videoElement.playbackRate=e)}get isLooping(){var e;return((e=this._videoElement)==null?void 0:e.loop)??this._isLooping}set isLooping(e){this._isLooping=e,this._videoElement&&(this._videoElement.loop=e)}get currentTime(){var e;return((e=this._videoElement)==null?void 0:e.currentTime)??this.time}set currentTime(e){this._videoElement?this._videoElement.currentTime=e:this.time=e}get isPlaying(){const e=this._videoElement;return!!(e&&(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>e.HAVE_CURRENT_DATA||e.srcObject&&e.srcObject.active))}get crossOrigin(){var e;return((e=this._videoElement)==null?void 0:e.crossOrigin)??this._crossOrigin}set crossOrigin(e){this._crossOrigin=e,this._videoElement&&(e!==null?this._videoElement.setAttribute("crossorigin",e):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 e;return((e=this._videoElement)==null?void 0:e.muted)??this._muted}set muted(e){this._muted=e,this._videoElement&&(this._videoElement.muted=e)}get currentVideo(){return this.clip}set audioOutputMode(e){e!==this._audioOutputMode&&(e===1&&ut()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=e,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){sr&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(e){this.clip=e,this.source=0,this._videoElement?(this._videoElement.srcObject=e,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(e){this._url!==e&&(this._url=e,this.source=1,sr&&console.log("set url",e),this._videoElement?e.endsWith(".m3u8")||e.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=e,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var e,t;sr&&console.log("VideoPlayer.onEnable",wj[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(e=this._overlay)==null||e.start():(t=this._overlay)==null||t.stop()}onDisable(){var e;window.removeEventListener("visibilitychange",this.visibilityChanged),(e=this._overlay)==null||e.stop(),this.pause()}onDestroy(){var e;this._videoElement&&((e=this.videoElement)==null||e.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var e,t;if(this._videoElement||this.create(!1),!this._videoElement){sr&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((e=this._videoElement)!=null&&e.ended)&&!((t=this._videoElement)!=null&&t.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}sr&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),sr&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),sr&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),sr&&console.log("STOP",this))}pause(){var e,t;this.time=((e=this._videoElement)==null?void 0:e.currentTime)??0,this._isPlaying=!1,(t=this._videoElement)==null||t.pause(),sr&&console.log("PAUSE",this,this.currentTime)}create(e){let t;switch(this.source){case 0:t=this.clip;break;case 1:t=this.url,!(t!=null&&t.length)&&typeof this.clip=="string"&&(t=this.clip);break}return t?(this._videoElement||(sr&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof t=="string"?(sr&&console.log("Set Video src",t),this._videoElement.src=t):(sr&&console.log("Set Video srcObject",t),this._videoElement.srcObject=t),this._videoTexture||(this._videoTexture=new uD(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=pt,e&&this.handleBeginPlaying(e),sr&&console.log("Video: handle playing done...",t,e),!0):(sr&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var e;return((e=this._overlay)==null?void 0:e.enabled)??!1}set screenspace(e){var t;if(e){if(!this._videoTexture)return;this._overlay||(this._overlay=new tce(this.context)),this._overlay.add(this._videoTexture)}else(t=this._overlay)==null||t.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=e)}createVideoElement(){const e=document.createElement("video");return this._crossOrigin&&e.setAttribute("crossorigin",this._crossOrigin),sr&&console.log("created video element",e),e}handleBeginPlaying(e){var t,n;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let r=this.gameObject;switch(this.renderMode){case 3:r=(t=this.targetMaterialRenderer)==null?void 0:t.gameObject,r||(r=(n=re.getComponent(this.gameObject,Sn))==null?void 0:n.gameObject);break;case 2:console.error("VideoPlayer renderTexture not implemented yet. Please use material override instead");return}if(!r){console.error("Missing target for video material renderer",this.name,Sj[this.renderMode],this);return}const s=r.material;if(s){this._targetObjects.push(r),s!==this._videoMaterial&&(this._videoMaterial=s.clone(),r.material=this._videoMaterial);const o="map",a=this._videoMaterial;if(!this.targetMaterialProperty)a[o]=this._videoTexture;else switch(this.targetMaterialProperty){default:a[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(),e&&(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 e=!this._receivedInput||this.audioOutputMode===0;!e&&this._muted&&(e=!0),this._videoElement.muted=e,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 e=++this._updateAspectRoutineId,t=void 0,n=this.clip;for(;e===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const s of n.getVideoTracks()){const o=s.getSettings();if(o&&o.width&&o.height){r=o.width/o.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let s=0;s<10;s++)yield;if(!this.isPlaying)break;continue}if(t===r){yield;continue}for(const s of this._targetObjects){let o=1;if(s.parent){const a=Ui(s.parent);o=a.x/a.y}switch(this.aspectMode){case 1:s.scale.y=1/r*s.scale.x*o;break;case 2:s.scale.x=r*s.scale.y*o;break}}for(let s=0;s<3;s++)yield}}get shouldUseM3U(){return this.url!=null&&(this.url.endsWith(".m3u8")||this.url.endsWith(".m3u"))&&this.source===1}ensureM3UCanBePlayed(){if(!this.shouldUseM3U)return;let e=document.head.querySelector("script[data-hls_library]");e?globalThis.Hls?this.onHlsAvailable():e.addEventListener("load",this.onHlsAvailable):(sr&&console.log("HLS: load script"),e=document.createElement("script"),e.dataset.hls_library="hls.js",e.src="https://cdn.jsdelivr.net/npm/hls.js@1",e.addEventListener("load",this.onHlsAvailable),document.head.append(e))}}vo([x()],Xn.prototype,"playOnAwake",2),vo([x()],Xn.prototype,"aspectMode",2),vo([x(URL)],Xn.prototype,"clip",2),vo([x()],Xn.prototype,"source",2),vo([x(URL)],Xn.prototype,"url",1),vo([x()],Xn.prototype,"renderMode",2),vo([x()],Xn.prototype,"targetMaterialProperty",2),vo([x(Sn)],Xn.prototype,"targetMaterialRenderer",2),vo([x(gt)],Xn.prototype,"targetTexture",2),vo([x()],Xn.prototype,"time",2),vo([x()],Xn.prototype,"playbackSpeed",1),vo([x()],Xn.prototype,"isLooping",1),vo([x()],Xn.prototype,"audioOutputMode",1);class tce{constructor(e){h(this,"context"),h(this,"_videos",[]),h(this,"_screenspaceModeQuad"),h(this,"_isInScreenspaceMode",!1),h(this,"_input"),this.context=e,this._input=new ice(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var e;if(this._isInScreenspaceMode||this._videos.length<0)return;const t=this._videos[this._videos.length-1];if(!t)return;if(this._isInScreenspaceMode=!0,!this._screenspaceModeQuad){if(this._screenspaceModeQuad=rv.createPrimitive(Wu.Quad,{material:new nce(t)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const n=this._screenspaceModeQuad;this.context.scene.add(n),this.updateScreenspaceMaterialUniforms();const r=n.material;r?.reset(),(e=this._input)==null||e.enable(r)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var e;const t=(e=this._screenspaceModeQuad)==null?void 0:e.material;t&&(t.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class ice{constructor(e){h(this,"_onResizeScreenFn"),h(this,"_onKeyUpFn"),h(this,"_onMouseWheelFn"),h(this,"context"),h(this,"overlay"),h(this,"_material"),h(this,"_isPinching",!1),h(this,"_lastPinch",0),this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=r=>{r.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=r=>{this.overlay.enabled&&(e.zoom+=r.deltaY*5e-4,r.preventDefault())},{passive:!1});const t=new $;window.addEventListener("mousemove",r=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const s=new $(r.movementX,r.movementY);s.x/=this.context.domElement.clientWidth,s.y/=this.context.domElement.clientHeight,t.set(s.x,s.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",r=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(r.movementX,r.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let n=0;window.addEventListener("touchstart",r=>{if(r.touches.length<2){this.context.time.time-n<.3&&this.overlay.stop(),n=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",r=>{if(!this._isPinching||!this._material)return;const s=r.touches[0],o=r.touches[1],a=s.clientX-o.clientX,l=s.clientY-o.clientY,c=Math.sqrt(a*a+l*l);if(this._lastPinch!==0){const u=c-this._lastPinch;this._material.zoom-=u*.004}this._lastPinch=c}),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 nce extends Tt{constructor(e){super(),h(this,"_offset",new $),this.uniforms={map:{value:e},screenAspect:{value:1},offsetScale:{value:new Ye(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 e=new ky;e.color=this.shadowColor,e.opacity=this.shadowColor.alpha,this.applyMaterialOptions(e),this.targetMesh.material=e}else{const e=this.targetMesh.material;e.color=this.shadowColor,e.opacity=this.shadowColor.alpha,this.applyMaterialOptions(e)}}applyOccluderMaterial(){if(this.targetMesh){let e=this.targetMesh.material;if(!e){const t=new ii;this.targetMesh.material=t,e=t}e.depthWrite=!0,e.stencilWrite=!0,e.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(e){e&&(e.depthWrite=!1,e.stencilWrite=!1)}}Cj([x()],k0.prototype,"mode",2),Cj([x(yi)],k0.prototype,"shadowColor",2);var dce=Object.defineProperty,pce=Object.getOwnPropertyDescriptor,hw=(i,e,t,n)=>{for(var r=n>1?void 0:n?pce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&dce(e,t,r),r},ZR;const Ej=(ZR=class extends Ie{constructor(){super(...arguments),h(this,"target",null),h(this,"followFactor",.1),h(this,"rotateFactor",.1),h(this,"positionAxes",ff.All),h(this,"flipForward",!1),h(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(i){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const e=Pt(this.target),t=this._firstUpdate||i?1:Ze.clamp01(this.context.time.deltaTime*this.followFactor),n=this.worldPosition;this.positionAxes&ff.X&&(n.x=Ze.lerp(n.x,e.x,t)),this.positionAxes&ff.Y&&(n.y=Ze.lerp(n.y,e.y,t)),this.positionAxes&ff.Z&&(n.z=Ze.lerp(n.z,e.z,t)),this.worldPosition=n}if(this.rotateFactor>0){const e=xi(this.target);this.flipForward&&e.premultiply(Ej._invertForward);const t=this._firstUpdate||i?1:Ze.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(e,t)}this._firstUpdate=!1}}},h(ZR,"_invertForward",new Me().setFromAxisAngle(new S(0,1,0),Math.PI)),ZR);let Nh=Ej;hw([x(ge)],Nh.prototype,"target",2),hw([x()],Nh.prototype,"followFactor",2),hw([x()],Nh.prototype,"rotateFactor",2),hw([x()],Nh.prototype,"positionAxes",2);class fce extends ue{constructor(e){const t=new mce(e),n=new Un(t.image.width*.001,t.image.height*.001),r=new ii({map:t,toneMapped:!1,transparent:!0});super(n,r);function s(o){r.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",s),this.addEventListener("mousemove",s),this.addEventListener("mouseup",s),this.addEventListener("click",s),this.dispose=function(){n.dispose(),r.dispose(),r.map.dispose(),$R.delete(e),this.removeEventListener("mousedown",s),this.removeEventListener("mousemove",s),this.removeEventListener("mouseup",s),this.removeEventListener("click",s)}}}class mce extends WS{constructor(e){super(Mj(e)),this.dom=e,this.anisotropy=16,this.colorSpace=pt,this.minFilter=Ct,this.magFilter=Ct;const t=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),n={attributes:!0,childList:!0,subtree:!0,characterData:!0};t.observe(e,n),this.observer=t}dispatchDOMEvent(e){e.data&&gce(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=Mj(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const $R=new WeakMap;function Mj(i){const e=document.createRange(),t=new Se;function n(p){const f=[];let m=!1;function A(){if(m&&(m=!1,p.restore()),f.length===0)return;let v=-1/0,g=-1/0,y=1/0,b=1/0;for(let _=0;_<f.length;_++){const E=f[_];v=Math.max(v,E.x),g=Math.max(g,E.y),y=Math.min(y,E.x+E.width),b=Math.min(b,E.y+E.height)}p.save(),p.beginPath(),p.rect(v,g,y-v,b-g),p.clip(),m=!0}return{add:function(v){f.push(v),A()},remove:function(){f.pop(),A()}}}function r(p,f,m,A){A!==""&&(p.textTransform==="uppercase"&&(A=A.toUpperCase()),u.font=p.fontWeight+" "+p.fontSize+" "+p.fontFamily,u.textBaseline="top",u.fillStyle=p.color,u.fillText(A,f,m+parseFloat(p.fontSize)*.1))}function s(p,f,m,A,v){m<2*v&&(v=m/2),A<2*v&&(v=A/2),u.beginPath(),u.moveTo(p+v,f),u.arcTo(p+m,f,p+m,f+A,v),u.arcTo(p+m,f+A,p,f+A,v),u.arcTo(p,f+A,p,f,v),u.arcTo(p,f,p+m,f,v),u.closePath()}function o(p,f,m,A,v,g){const y=p[f+"Width"],b=p[f+"Style"],_=p[f+"Color"];y!=="0px"&&b!=="none"&&_!=="transparent"&&_!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=_,u.lineWidth=parseFloat(y),u.beginPath(),u.moveTo(m,A),u.lineTo(m+v,A+g),u.stroke())}function a(p,f){let m=0,A=0,v=0,g=0;if(p.nodeType===Node.TEXT_NODE){e.selectNode(p);const b=e.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,r(f,m,A,p.nodeValue.trim())}else{if(p.nodeType===Node.COMMENT_NODE)return;if(p instanceof HTMLCanvasElement){if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,u.save();const _=window.devicePixelRatio;u.scale(1/_,1/_),u.drawImage(p,m,A),u.restore()}else if(p instanceof HTMLImageElement){if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,u.drawImage(p,m,A,v,g)}else{if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,f=window.getComputedStyle(p),s(m,A,v,g,parseFloat(f.borderRadius));const _=f.backgroundColor;_!=="transparent"&&_!=="rgba(0, 0, 0, 0)"&&(u.fillStyle=_,u.fill());const E=["borderTop","borderLeft","borderBottom","borderRight"];let I=!0,T=null;for(const M of E){if(T!==null&&(I=f[M+"Width"]===f[T+"Width"]&&f[M+"Color"]===f[T+"Color"]&&f[M+"Style"]===f[T+"Style"]),I===!1)break;T=M}if(I===!0){const M=parseFloat(f.borderTopWidth);f.borderTopWidth!=="0px"&&f.borderTopStyle!=="none"&&f.borderTopColor!=="transparent"&&f.borderTopColor!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=f.borderTopColor,u.lineWidth=M,u.stroke())}else o(f,"borderTop",m,A,v,0),o(f,"borderLeft",m,A,0,g),o(f,"borderBottom",m,A+g,v,0),o(f,"borderRight",m+v,A,0,g);if(p instanceof HTMLInputElement){let M=f.accentColor;(M===void 0||M==="auto")&&(M=f.color),t.set(M);const D=Math.sqrt(.299*t.r**2+.587*t.g**2+.114*t.b**2)<.5?"white":"#111111";if(p.type==="radio"&&(s(m,A,v,g,g),u.fillStyle="white",u.strokeStyle=M,u.lineWidth=1,u.fill(),u.stroke(),p.checked&&(s(m+2,A+2,v-4,g-4,g),u.fillStyle=M,u.strokeStyle=D,u.lineWidth=2,u.fill(),u.stroke())),p.type==="checkbox"&&(s(m,A,v,g,2),u.fillStyle=p.checked?M:"white",u.strokeStyle=p.checked?D:M,u.lineWidth=1,u.stroke(),u.fill(),p.checked)){const C=u.textAlign;u.textAlign="center";const P={color:D,fontFamily:f.fontFamily,fontSize:g+"px",fontWeight:"bold"};r(P,m+v/2,A,"\u2714"),u.textAlign=C}if(p.type==="range"){const[C,P,j]=["min","max","value"].map(O=>parseFloat(p[O])),Q=(j-C)/(P-C)*(v-g);s(m,A+g/4,v,g/2,g/4),u.fillStyle=D,u.strokeStyle=M,u.lineWidth=1,u.fill(),u.stroke(),s(m,A+g/4,Q+g/2,g/2,g/4),u.fillStyle=M,u.fill(),s(m+Q,A,g,g,g/2),u.fillStyle=M,u.fill()}(p.type==="color"||p.type==="text"||p.type==="number")&&(d.add({x:m,y:A,width:v,height:g}),r(f,m+parseInt(f.paddingLeft),A+parseInt(f.paddingTop),p.value),d.remove())}}}const y=f.overflow==="auto"||f.overflow==="hidden";y&&d.add({x:m,y:A,width:v,height:g});for(let b=0;b<p.childNodes.length;b++)a(p.childNodes[b],f);y&&d.remove()}const l=i.getBoundingClientRect();let c=$R.get(i);c===void 0&&(c=document.createElement("canvas"),c.width=l.width,c.height=l.height,$R.set(i,c));const u=c.getContext("2d"),d=new n(u);return u.clearRect(0,0,c.width,c.height),a(i),c}function gce(i,e,t,n){const r={clientX:t*i.offsetWidth+i.offsetLeft,clientY:n*i.offsetHeight+i.offsetTop,view:i.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(e,r));const s=i.getBoundingClientRect();t=t*s.width+s.left,n=n*s.height+s.top;function o(a){if(a.nodeType!==Node.TEXT_NODE&&a.nodeType!==Node.COMMENT_NODE){const l=a.getBoundingClientRect();if(t>l.left&&t<l.right&&n>l.top&&n<l.bottom&&(a.dispatchEvent(new MouseEvent(e,r)),a instanceof HTMLInputElement&&a.type==="range"&&(e==="mousedown"||e==="click"))){const[c,u]=["min","max"].map(f=>parseFloat(a[f])),d=l.width,p=(t-l.x)/d;a.value=c+(u-c)*p,a.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let c=0;c<a.childNodes.length;c++)o(a.childNodes[c])}}o(i)}const uw=new $,tm={type:"",data:uw},Tj=new xu;class vce extends hs{listenToPointerEvents(e,t){const n=this,r=new xu,s=e.domElement;function o(a){a.stopPropagation();const l=e.domElement.getBoundingClientRect();uw.x=(a.clientX-l.left)/l.width*2-1,uw.y=-(a.clientY-l.top)/l.height*2+1,r.setFromCamera(uw,t);const c=r.intersectObjects(n.children,!1);if(c.length>0){const u=c[0],d=u.object,p=u.uv;tm.type=a.type,tm.data.set(p.x,1-p.y),d.dispatchEvent(tm)}}s.addEventListener("pointerdown",o),s.addEventListener("pointerup",o),s.addEventListener("pointermove",o),s.addEventListener("mousedown",o),s.addEventListener("mouseup",o),s.addEventListener("mousemove",o),s.addEventListener("click",o)}listenToXRControllerEvents(e){const t=this,n={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function r(s){const o=s.target;Tj.setFromXRController(o);const a=Tj.intersectObjects(t.children,!1);if(a.length>0){const l=a[0],c=l.object,u=l.uv;tm.type=n[s.type],tm.data.set(u.x,1-u.y),c.dispatchEvent(tm)}}e.addEventListener("move",r),e.addEventListener("select",r),e.addEventListener("selectstart",r),e.addEventListener("selectend",r)}}var Ace=Object.defineProperty,yce=Object.getOwnPropertyDescriptor,Ij=(i,e,t,n)=>{for(var r=n>1?void 0:n?yce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ace(e,t,r),r};class O0 extends Ie{constructor(){super(...arguments),h(this,"id",null),h(this,"keepAspect",!1),h(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const e=document.getElementById(this.id);if(!e){console.warn('Could not find element with id "'+this.id+'"');return}e.style.display="block",e.style.visibility="hidden";const t=new vce;t.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(t);const n=new fce(e);t.add(n),n.visible=!1;const r=n.material;r.transparent=!0,setTimeout(()=>{n.visible=!0;const s=mg(this.gameObject).clone();gg(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const o=new fi;o.setFromObject(t),this.setWorldRotation(s.x,s.y,s.z);const a=o.max.x-o.min.x,l=o.max.y-o.min.y;if(this.keepAspect){const u=a/l;a>l?n.scale.set(1/a,1/l/u,1):n.scale.set(1/a*u,1/l,1)}else n.scale.set(1/a,1/l,1);const c=this.gameObject.scale;n.scale.multiply(c)},1)}onDisable(){var e;(e=this._object)==null||e.removeFromParent()}}Ij([x()],O0.prototype,"id",2),Ij([x()],O0.prototype,"keepAspect",2);var bce=Object.defineProperty,_ce=Object.getOwnPropertyDescriptor,L0=(i,e,t,n)=>{for(var r=n>1?void 0:n?_ce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bce(e,t,r),r};const U0=ee("debugspatialtrigger"),Rj=new jr,Pj=new jr;function xce(i,e){return Rj.mask=i,Pj.mask=e,Rj.test(Pj)}class ul extends Ie{constructor(){super(...arguments),h(this,"triggerMask",0),h(this,"onEnter"),h(this,"onStay"),h(this,"onExit"),h(this,"currentIntersected",[]),h(this,"lastIntersected",[])}start(){U0&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const e of F0.triggers)xce(e.triggerMask,this.triggerMask)&&e.test(this.gameObject)&&this.currentIntersected.push(e);for(let e=this.lastIntersected.length-1;e>=0;e--){const t=this.lastIntersected[e];this.currentIntersected.indexOf(t)<0&&(this.onExitTrigger(t),this.lastIntersected.splice(e,1))}for(const e of this.currentIntersected)this.lastIntersected.indexOf(e)<0&&this.onEnterTrigger(e),this.onStayTrigger(e);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(e){var t;U0&&console.log("ENTER TRIGGER",this.name,e.name,this,e),e.raiseOnEnterEvent(this),(t=this.onEnter)==null||t.invoke(this,e)}onExitTrigger(e){var t;U0&&console.log("EXIT TRIGGER",this.name,e.name,this,e),e.raiseOnExitEvent(this),(t=this.onExit)==null||t.invoke(this,e)}onStayTrigger(e){var t;e.raiseOnStayEvent(this),(t=this.onStay)==null||t.invoke(this,e)}}L0([x()],ul.prototype,"triggerMask",2),L0([x(Hn)],ul.prototype,"onEnter",2),L0([x(Hn)],ul.prototype,"onStay",2),L0([x(Hn)],ul.prototype,"onExit",2);var e2;const dw=(e2=class extends Ie{constructor(){super(...arguments),h(this,"triggerMask"),h(this,"boxHelper")}start(){U0&&console.log(this.name,this.triggerMask,this)}onEnable(){var i;dw.triggers.push(this),this.boxHelper||(this.boxHelper=re.addNewComponent(this.gameObject,nl),(i=this.boxHelper)==null||i.showHelper(null,U0))}onDisable(){dw.triggers.splice(dw.triggers.indexOf(this),1)}test(i){return this.boxHelper?this.boxHelper.isInBox(i)??!1:!1}raiseOnEnterEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onEnterTrigger(this)},!1)}raiseOnStayEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onStayTrigger(this)},!1)}raiseOnExitEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onExitTrigger(this)},!1)}},h(e2,"triggers",[]),e2);let F0=dw;L0([x()],F0.prototype,"triggerMask",2);var wce=Object.defineProperty,Sce=Object.getOwnPropertyDescriptor,Cce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&wce(e,t,r),r};const Ao=ee("debugspectator");class pw extends Ie{constructor(){super(...arguments),h(this,"cam",null),h(this,"useKeys",!0),h(this,"_mode",0),h(this,"orbit",null),h(this,"_handler"),h(this,"eventSub_WebXRRequestStartEvent",null),h(this,"eventSub_WebXRStartEvent",null),h(this,"eventSub_WebXREndEvent",null),h(this,"_debug"),h(this,"_networking")}get mode(){return this._mode}set mode(e){this._mode=e}get isSpectating(){var e;return((e=this._handler)==null?void 0:e.currentTarget)!==void 0}isSpectatingUser(e){var t;return((t=this.target)==null?void 0:t.userId)===e}isFollowedBy(e){var t;return(t=this.followers)==null?void 0:t.includes(e)}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(e){var t;if(this._handler){const n=(t=this._handler.currentTarget)==null?void 0:t.userId,r=this.context.players.getPlayerView(this.localId);e===void 0||this.context.isInXR===!1&&r?.currentObject===e.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),re.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(e,n)):this._handler.currentTarget!==e&&(this._handler.set(e),re.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(e,n))}}get target(){var e;return(e=this._handler)==null?void 0:e.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var e,t;return this.isSpectating&&((e=this.target)==null?void 0:e.currentObject)===((t=this.context.players.getPlayerView(this.localId))==null?void 0:t.currentObject)}awake(){if(this._debug=new Tce(this.context,this),this._networking=new Pce(this.context,this),this._networking.awake(),re.setActive(this.gameObject,!1),this.cam=re.getComponent(this.gameObject,Bi),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new Ece(this.context,this.cam,this)),this.orbit=re.getComponent(this.context.mainCamera,bi)}onDestroy(){var e,t;this.stopSpectating(),(e=this._handler)==null||e.destroy(),(t=this._networking)==null||t.destroy()}isSupportedPlatform(){const e=window.navigator.userAgent,t=/Windows|MacOS/.test(e),n=/Windows NT/.test(e)&&/Edg/.test(e)&&!/Win64/.test(e);return t&&!n}onBeforeXR(e){this.isSupportedPlatform()&&re.setActive(this.gameObject,!0)}onEnterXR(e){this.isSupportedPlatform()&&(Ao&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(e){var t,n;this.context.removeCamera(this.cam),re.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(t=this._handler)==null||t.set(void 0),(n=this._handler)==null||n.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,uh.Headset),this.target=this.context.players.getPlayerView(this.localId)),Ao&&console.log("Follow self",this.target)}onAfterRender(){var e,t,n;if(!this.cam)return;const r=this.context.renderer,s=r.xr.enabled;if(!r.xr.isPresenting&&!((e=this._handler)!=null&&e.currentTarget))return;(t=this._handler)==null||t.update(this._mode);const o=r.getRenderTarget();let a=null;const l=r.state;if(!o){if(!r.state.bindFramebuffer||!l.bindXRFramebuffer)return;a=r._framebuffer,l.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const c=this.context.mainCameraComponent;if(c){const p=c.backgroundColor;p&&r.setClearColor(p,p.alpha),this.cam.backgroundColor=p,this.cam.clearFlags=c.clearFlags,this.cam.nearClipPlane=c.nearClipPlane,this.cam.farClipPlane=c.farClipPlane}else r.setClearColor(new Se(1,1,1));r.setRenderTarget(null),r.xr.enabled=!1;const u=(n=this.cam)==null?void 0:n.cam;this.context.updateAspect(u);const d=r.xr.isPresenting;r.xr.isPresenting=!1,r.setSize(this.context.domWidth,this.context.domHeight),r.render(this.context.scene,u),r.xr.isPresenting=d,r.xr.enabled=s,o?r.setRenderTarget(o):l.bindXRFramebuffer&&l.bindXRFramebuffer(a),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const e=this._mode===0;for(const t of Er.instances)if(t.avatar&&"isLocalAvatar"in t.avatar&&"flags"in t.avatar){let n=el.All;this.isSpectatingSelf&&(n=e&&t.avatar.isLocalAvatar?el.FirstPerson:el.ThirdPerson);const r=t.avatar.flags;if(!r)continue;for(const s of r)s.UpdateVisible(n)}}resetAvatarFlags(){var e;for(const t of Er.instances)if(t.avatar&&"flags"in t.avatar){const n=t.avatar.flags;if(!n)continue;for(const r of n)"isLocalAvatar"in t.avatar&&(e=t.avatar)!=null&&e.isLocalAvatar?r.UpdateVisible(el.FirstPerson):r.UpdateVisible(el.ThirdPerson)}}}Cce([x()],pw.prototype,"useKeys",2);class Ece{constructor(e,t,n){h(this,"context"),h(this,"cam"),h(this,"spectator"),h(this,"follow"),h(this,"target"),h(this,"view"),h(this,"currentObject"),this.context=e,this.cam=t,this.spectator=n}get currentTarget(){return this.view}set(e){const t=e?.currentObject;if(!t){this.spectator.stopSpectating();return}t!==this.currentObject&&(this.currentObject=t,this.view=e,this.follow||(this.follow=re.addNewComponent(this.cam.gameObject,Nh)),this.target||(this.target=new ge),t.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,Ao&&console.log("FOLLOW",t),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){Ao&&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 e;(e=this.target)==null||e.removeFromParent(),this.follow&&re.destroy(this.follow)}update(e){var t,n,r,s,o,a;if(((t=this.currentTarget)==null?void 0:t.isConnected)===!1||((n=this.currentTarget)==null?void 0:n.removed)===!0){Ao&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((r=this.currentTarget)==null?void 0:r.currentObject)!==this.currentObject&&(Ao&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const l=this.context.mainCamera;l&&(this.cam.cam.near!==l.near||this.cam.cam.far!==l.far)&&(this.cam.cam.near=l.near,this.cam.cam.far=l.far,this.cam.cam.updateProjectionMatrix());const c=(s=this.follow)==null?void 0:s.target;if(!(!c||!this.follow)){switch(e){case 0:((o=this.view)==null?void 0:o.viewDevice)!==uh.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),c.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,c.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((a=this.view)==null?void 0:a.viewDevice)!==uh.Browser?c.quaternion.copy(Mce):c.quaternion.identity()}}}const Mce=new Me().setFromAxisAngle(new S(0,1,0),Math.PI);class Tce{constructor(e,t){h(this,"context"),h(this,"spectator"),this.context=e,this.spectator=t,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",r=>{!this.spectator.useKeys||r.key==="Escape"&&this.spectator.stopSpectating()});let n=0;this.context.input.addEventListener(qi.PointerDown,r=>{n=this.context.time.time}),this.context.input.addEventListener(qi.PointerUp,r=>{const s=this.context.time.time-n;s>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&s<.3&&this.trySelectObject()})}trySelectObject(){const e=new No;e.setMask(16777215);const t=this.context.physics.raycast(e);if(Ao&&console.log(...t),t!=null&&t.length)for(const n of t){if(n.distance<.2)continue;const r=n.object,s=re.getComponentInParent(r,Er),o=s?.connectionId;if(o){const a=this.context.players.getPlayerView(o);this.spectator.target=a,Ao&&console.log("spectate",o,s);break}}}}class Ice{constructor(e,t,n){h(this,"guid"),h(this,"dontSave",!0),h(this,"targetUserId"),h(this,"stoppedFollowing"),this.guid=e,this.targetUserId=t,this.stoppedFollowing=n}}class Rce{constructor(e,t){h(this,"guid"),h(this,"userId"),this.guid=e.guid,this.userId=t}}class Pce{constructor(e,t){h(this,"followers",[]),h(this,"context"),h(this,"spectator"),h(this,"_followerEventMethod"),h(this,"_requestFollowMethod"),h(this,"_joinedRoomMethod"),h(this,"_lastRequestFollowUser"),h(this,"_enforceFollowInterval"),this.context=e,this.spectator=t,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(Kt.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",e=>{this.spectator.useKeys&&(e.key==="f"?this.onRequestFollowMe():e.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(Kt.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(e,t){if(Ao&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",e,t),this.context.connection.connectionId){const n=e?.userId===void 0,r=n?t:e?.userId,s=new Ice(this.context.connection.connectionId,r,n);this.context.connection.send("spectator-follower-changed",s)}}onRequestFollowMe(e=!1){if(Ao&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const t=e?void 0:this.context.connection.connectionId,n=new Rce(this.spectator,t);this.context.connection.send("spectator-request-follow",n)}}onUserJoinedRoom(){ee("followme")&&this.onRequestFollowMe()}onFollowerEvent(e){const t=e.targetUserId,n=e.guid;if(Ao&&console.log(e),t===this.context.connection.connectionId)if(e.stoppedFollowing){const r=this.followers.indexOf(n);r!==-1&&(this.followers.splice(r,1),this.removeDisconnectedFollowers(),console.log(n,"unfollows you",this.followers.length))}else this.followers.includes(n)||(this.followers.push(n),this.removeDisconnectedFollowers(),console.log(n,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let e=this.followers.length-1;e>=0;e--){const t=this.followers[e];this.context.connection.userIsInRoom(t)===!1&&this.followers.splice(e,1)}}onRequestFollowEvent(e){if(this._lastRequestFollowUser=e,e.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(e.userId===void 0)this.spectator.stopSpectating();else{const t=this.context.players.getPlayerView(e.userId);if(t)this.spectator.target=t;else return Ao&&console.warn("Could not find view",e.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):(Ao&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var Bce=Object.defineProperty,Dce=Object.getOwnPropertyDescriptor,Ms=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Bce(e,t,r),r};const fw=ee("debugspriterenderer"),kce=ee("wireframe"),t2=class{static getOrCreateGeometry(i){if(i.__cached_geometry)return i.__cached_geometry;if(i.guid&&t2.cache[i.guid])return fw&&console.log("Take cached geometry for sprite",i.guid),t2.cache[i.guid];const e=new ft;i.__cached_geometry=e;const t=new Float32Array(i.triangles.length*3),n=new Float32Array(i.triangles.length*2);for(let r=0;r<i.triangles.length;r+=1){const s=i.triangles[r];t[r*3]=-i.vertices[s].x,t[r*3+1]=i.vertices[s].y,t[r*3+2]=0;const o=i.uv[s];n[r*2]=o.x,n[r*2+1]=1-o.y}return e.setAttribute("position",new $e(t,3)),e.setAttribute("uv",new $e(n,2)),i.guid&&(this.cache[i.guid]=e),fw&&console.log("Built sprite geometry",i,e),e}};let N0=t2;h(N0,"cache",{});class yc{constructor(){h(this,"guid"),h(this,"texture"),h(this,"triangles"),h(this,"uv"),h(this,"vertices"),h(this,"__cached_geometry"),h(this,"_mesh"),h(this,"_material")}get mesh(){return this._mesh||(this._mesh=new ue(N0.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=pt,this.texture.minFilter==Lt&&this.texture.magFilter==Lt&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new ii({map:this.texture,color:16777215,side:li,transparent:!0})),this._material}getGeometry(){return N0.getOrCreateGeometry(this)}}Ms([x()],yc.prototype,"guid",2),Ms([x(gt)],yc.prototype,"texture",2),Ms([qp()],yc.prototype,"triangles",2),Ms([qp()],yc.prototype,"uv",2),Ms([qp()],yc.prototype,"vertices",2);const i2=Symbol("spriteOwner");class z0{constructor(){h(this,"sprites")}}Ms([x(yc)],z0.prototype,"sprites",2);class im{constructor(){h(this,"spriteSheet"),h(this,"index",0)}update(e,t,n){if(!this.spriteSheet)return;const r=this.index;if(r<0||r>=this.spriteSheet.sprites.length)return;const s=this.spriteSheet.sprites[r],o=s?.texture;if(o&&(o.colorSpace=pt,o.minFilter==Lt&&o.magFilter==Lt&&(o.anisotropy=1),o.needsUpdate=!0,!s.__hasLoadedProgressive)){s.__hasLoadedProgressive=!0;const a=o;Ii.assignTextureLOD(e,t,o,0).then(l=>{l instanceof gt&&(s.texture=l,n?.map===a&&(n.map=l,n.needsUpdate=!0))})}}}Ms([x(z0)],im.prototype,"spriteSheet",2),Ms([x()],im.prototype,"index",2);class dl extends Ie{constructor(){super(...arguments),h(this,"drawMode",0),h(this,"size",{x:1,y:1}),h(this,"color"),h(this,"sharedMaterial"),h(this,"transparent",!0),h(this,"cutoutThreshold",0),h(this,"castShadows",!1),h(this,"_spriteSheet"),h(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(e){if(e!==this._spriteSheet)if(typeof e=="number"){const t=Math.floor(e);this.spriteIndex=t;return}else this._spriteSheet=e,this.updateSprite()}set spriteIndex(e){this._spriteSheet&&(this._spriteSheet.index=e,this.updateSprite())}get spriteIndex(){var e;return((e=this._spriteSheet)==null?void 0:e.index)??0}get spriteFrames(){var e,t;return((t=(e=this._spriteSheet)==null?void 0:e.spriteSheet)==null?void 0:t.sprites.length)??0}awake(){this._currentSprite=void 0,fw&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var e,t,n;if(!this.__didAwake||!((t=(e=this.sprite)==null?void 0:e.spriteSheet)!=null&&t.sprites))return;const r=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!r){fw&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=N0.getOrCreateGeometry(r),this._currentSprite.material.map=r.texture;else{const s=new ii({color:16777215,side:li});if(!s)return;if(kce&&(s.wireframe=!0),this.color&&(s.color||(s.color=new Se),s.color.copy(this.color),s.opacity=this.color.alpha),s.transparent=!0,r.texture&&!s.wireframe){let o=r.texture;o[i2]!==void 0&&o[i2]!==this&&this.spriteFrames>1&&(o=r.texture=o.clone()),o[i2]=this,s.map=o}this.sharedMaterial=s,this._currentSprite=new ue(N0.getOrCreateGeometry(r),s),Ii.assignTextureLOD(this.context,this.sourceId,s,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,(n=this._spriteSheet)==null||n.update(this.context,this.sourceId,this.sharedMaterial)}}Ms([x()],dl.prototype,"drawMode",2),Ms([x(yi)],dl.prototype,"color",2),Ms([x(It)],dl.prototype,"sharedMaterial",2),Ms([x()],dl.prototype,"transparent",2),Ms([x()],dl.prototype,"cutoutThreshold",2),Ms([x()],dl.prototype,"castShadows",2),Ms([x(im)],dl.prototype,"sprite",1);class _l{constructor(){h(this,"bb",null),h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedCameraModel(e,t){return(t||new _l).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedCameraModel(e,t){return e.setPosition(e.position()+lT),(t||new _l).__init(e.readInt32(e.position())+e.position(),e)}userId(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}guid(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dontSave(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}pos(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new ed).__init(this.bb_pos+t,this.bb):null}rot(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new ed).__init(this.bb_pos+t,this.bb):null}static startSyncedCameraModel(e){e.startObject(5)}static addUserId(e,t){e.addFieldOffset(0,t,0)}static addGuid(e,t){e.addFieldOffset(1,t,0)}static addDontSave(e,t){e.addFieldInt8(2,+t,0)}static addPos(e,t){e.addFieldStruct(3,t,0)}static addRot(e,t){e.addFieldStruct(4,t,0)}static endSyncedCameraModel(e){return e.endObject()}static finishSyncedCameraModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedCameraModelBuffer(e,t){e.finish(t,void 0,!0)}}var Oce=Object.defineProperty,Lce=Object.getOwnPropertyDescriptor,Uce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Oce(e,t,r),r};const mw="SCAM";uT(mw,_l.getRootAsSyncedCameraModel);const yo=new rA;class Fce{constructor(e,t){h(this,"userId"),h(this,"guid"),this.guid=t,this.userId=e}send(e,t){if(e){yo.clear();const n=yo.createString(this.guid),r=yo.createString(this.userId);_l.startSyncedCameraModel(yo),_l.addGuid(yo,n),_l.addUserId(yo,r);const s=Pt(e),o=mg(e);_l.addPos(yo,ed.createVec3(yo,s.x,s.y,s.z)),_l.addRot(yo,ed.createVec3(yo,o.x,o.y,o.z));const a=_l.endSyncedCameraModel(yo);yo.finish(a,mw),t.sendBinary(yo.asUint8Array())}}}var n2;const r2=(n2=class extends Ie{constructor(){super(...arguments),h(this,"cameraPrefab",null),h(this,"_lastWorldPosition"),h(this,"_lastWorldQuaternion"),h(this,"_model",null),h(this,"_needsUpdate",!0),h(this,"_lastUpdateTime",0),h(this,"remoteCams",{}),h(this,"userToCamMap",{}),h(this,"_camTimeoutInSeconds",10),h(this,"_receiveCallback",null)}getCameraObject(i){const e=this.userToCamMap[i];return e?this.remoteCams[e].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(mw,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(mw,this._receiveCallback)}update(){for(const n in this.remoteCams){const r=this.remoteCams[n],s=this.context.time.realtimeSinceStartup-r.lastUpdate;if(!r||s>this._camTimeoutInSeconds){ut()&&console.log("Remote cam timeout",n),r!=null&&r.obj&&re.destroy(r.obj),delete this.remoteCams[n],r&&delete this.userToCamMap[r.userId],r2.instances.push(r),this.context.players.removePlayerView(r.userId,uh.Browser);continue}}if(this.context.isInXR)return;const i=this.context.mainCamera;if(i===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new Fce(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const e=Pt(i),t=xi(i);(e.distanceTo(this._lastWorldPosition)>.001||t.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(e),this._lastWorldQuaternion.copy(t),!((!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(i,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,i,uh.Browser))}onReceivedRemoteCameraInfoBin(i){const e=i.guid();if(!e)return;const t=i.userId();if(!t||!this.context.connection.userIsInRoom(t)||!this.cameraPrefab)return;let n=this.remoteCams[e];if(!n)if("isObject3D"in this.cameraPrefab){const a=new Ia;a.context=this.context;const l=re.instantiate(this.cameraPrefab,a);n=this.remoteCams[e]={obj:l,lastUpdate:this.context.time.realtimeSinceStartup,userId:t},n.obj.visible=!0,this.gameObject.add(l),this.userToCamMap[t]=e,r2.instances.push(n);const c=re.getOrAddComponent(l,Er);c.connectionId=t,c.avatar=l}else return;const r=n.obj;this.context.players.setPlayerView(t,r,uh.Browser),n.lastUpdate=this.context.time.realtimeSinceStartup,$o.markDirty(r);const s=i.pos();s&&Tu(r,s.x(),s.y(),s.z());const o=i.rot();o&&gg(r,o.x(),o.y(),o.z())}},h(n2,"instances",[]),n2);let gw=r2;Uce([x([ge,Zt])],gw.prototype,"cameraPrefab",2);var Nce=Object.defineProperty,zce=Object.getOwnPropertyDescriptor,nm=(i,e,t,n)=>{for(var r=n>1?void 0:n?zce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Nce(e,t,r),r};const s2="view",o2=ee("debugsyncedroom");class bc extends Ie{constructor(){super(...arguments),h(this,"roomName"),h(this,"urlParameterName","room"),h(this,"joinRandomRoom",!0),h(this,"requireRoomParameter",!1),h(this,"autoRejoin",!0),h(this,"createJoinButton",!0),h(this,"_roomPrefix"),h(this,"_lastJoinedRoom",""),h(this,"_lastPingTime",0),h(this,"_lastRoomTime",-1),h(this,"_userWantsToBeInARoom",!1),h(this,"_roomButton"),h(this,"_roomButtonIconJoin"),h(this,"_roomButtonIconLeave"),h(this,"updateRoomButtonState",()=>{var e,t;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(e=this._roomButtonIconJoin)==null||e.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(t=this._roomButtonIconLeave)==null||t.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){o2&&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 e=ee(s2);if(e&&typeof e=="string"&&e.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(e,!0);return}if((this.joinRandomRoom||ee(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const t=this.createRoomButton();this.context.menu.appendChild(t)}}onDisable(){var e;(e=this._roomButton)==null||e.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(e=0){e===void 0&&(e=0);let t=!1;if(this.urlParameterName){const n=ee(this.urlParameterName);if(n&&typeof n=="string"||n==="number"){t=!0;const r=xk(n);this.roomName=r}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),e<1))return this.tryJoinRoom(e+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&&!t?(o2&&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(),o2&&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()):ut()&&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 ee(s2)||ee(this.urlParameterName)}setRandomRoomUrlParameter(){const e=sg(),t=this.generateRoomName();ee(this.urlParameterName)?e.set(this.urlParameterName,t):e.append(this.urlParameterName,t),RC(t,e)}generateRoomName(){return PC()+"_"+Math.floor(Ze.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const e=window.location.search,t=new URLSearchParams(e);return t.has(this.urlParameterName)&&t.delete(this.urlParameterName),t.set(s2,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+t.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const e=document.createElement("button");return this._roomButton=e,e.classList.add("create-room-button"),e.setAttribute("priority","90"),e.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&Zy(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(ee(this.urlParameterName)||(this._lastJoinedRoom?Zy(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=to("group"),this._roomButtonIconLeave=to("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(Kt.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(Kt.LeftRoom,this.updateRoomButtonState),e}destroyRoomButton(){this.context.connection.stopListen(Kt.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(Kt.LeftRoom,this.updateRoomButtonState)}}nm([x()],bc.prototype,"roomName",2),nm([x()],bc.prototype,"urlParameterName",2),nm([x()],bc.prototype,"joinRandomRoom",2),nm([x()],bc.prototype,"requireRoomParameter",2),nm([x()],bc.prototype,"autoRejoin",2),nm([x()],bc.prototype,"createJoinButton",2);class vw extends Ie{}function jce(){const i=ee("testwindowcount")||0;i&&i>0&&Gce(i)}function Gce(i){if(ee("testwindow"))return null;const e=new URL(window.location.href);IC(e.searchParams,zne,1),IC(e.searchParams,"testwindow",1);const t=e.toString(),n=[];window.onbeforeunload=()=>{for(const l of n)l.close()};const r=.05,s=128;let o=0,a=0;for(let l=0;l<i;l++){o*s+s*.01>=window.innerWidth&&(a+=1,o=0);const c=o*(s*(1+r))+window.screenLeft,u=a*(s*(1+r))+window.screenTop+90+60*a;o+=1;const d=window.open(t,"test window "+l,`popup=yes width=${s} height=${s} top=${u} left=${c}`);if(!d){console.warn("Failed to open window");continue}n.push(d),d.onload=()=>{d.onbeforeunload=()=>{for(let p=0;p<n.length;p++){const f=n[p];f!==d&&f.close()}n.length=0}}}return n}class a2 extends Ie{awake(){jce()}}class l2 extends Ie{constructor(){super(...arguments),h(this,"transformsPerFrame",10),h(this,"interval",0),h(this,"useFlatbuffers",!0),h(this,"builder",null),h(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Av,e=>{});else{this.models=[];for(let e=0;e<this.transformsPerFrame;e++)this.models.push(new Bj(this.context.connection.connectionId+"_simulatedTransform_"+e,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 rA(1024));const e=this.builder;for(let t=0;t<this.transformsPerFrame;t++){e.clear();const n=t4(this.context.connection.connectionId,this);this.context.connection.sendBinary(n)}}else if(this.models)for(let e=0;e<this.models.length;e++){const t=this.models[e];t.dontSave=!0,t.update(this,null),this.context.connection.send("TestSimulateUserData-"+e,t)}}}}class Bj{constructor(e,t){h(this,"guid"),h(this,"fast",!1),h(this,"position"),h(this,"rotation"),h(this,"velocity"),h(this,"dontSave"),this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(e,t){const n=e.worldPosition;this.position.x=n.x,this.position.y=n.y,this.position.z=n.z;const r=e.worldQuaternion;if(this.rotation.x=r.x,this.rotation.y=r.y,this.rotation.z=r.z,this.rotation.w=r.w,this.fast=!1,t){const s=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=s.x,this.velocity.y=s.y,this.velocity.z=s.z}}}h(Bj,"temp",new S);var Qce=Object.defineProperty,Hce=Object.getOwnPropertyDescriptor,rm=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qce(e,t,r),r};class pl extends Kr{constructor(){super(...arguments),h(this,"offset"),h(this,"rotation"),h(this,"focusArea"),h(this,"feather"),h(this,"kernelSize"),h(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=ql.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const e=new V$({kernelSize:ql.VERY_LARGE});return this.offset.onValueChanged=t=>e.offset=t,this.rotation.onValueChanged=t=>e.rotation=t,this.focusArea.onValueChanged=t=>e.focusArea=t,this.feather.onValueChanged=t=>e.feather=t,this.kernelSize.onValueChanged=t=>e.blurPass.kernelSize=t,this.resolutionScale.onValueChanged=t=>e.resolution.scale=t/window.devicePixelRatio,e}}rm([x(Rt)],pl.prototype,"offset",2),rm([x(Rt)],pl.prototype,"rotation",2),rm([x(Rt)],pl.prototype,"focusArea",2),rm([x(Rt)],pl.prototype,"feather",2),rm([x(Rt)],pl.prototype,"kernelSize",2),rm([x(Rt)],pl.prototype,"resolutionScale",2),Ho("TiltShiftEffect",pl);var Vce=Object.defineProperty,Wce=Object.getOwnPropertyDescriptor,qce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Vce(e,t,r),r};class j0 extends Kr{constructor(){super(...arguments),h(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new Rt(Bs)),this.mode.defaultValue=Bs}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(e){this.context.renderer.toneMapping=this.getThreeToneMapping(e)}getThreeToneMapping(e){switch(e){case 0:return Vd;case 1:return yA;case 2:return AA;default:return Vd}}}qce([x(Rt)],j0.prototype,"mode",2),Ho("Tonemapping",j0);var Xce=Object.defineProperty,Yce=Object.getOwnPropertyDescriptor,Aw=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Xce(e,t,r),r};class kd extends Ie{constructor(){super(...arguments),h(this,"isGizmo",!1),h(this,"translationSnap",1),h(this,"rotationSnapAngle",15),h(this,"scaleSnap",.25),h(this,"control"),h(this,"orbit"),h(this,"onControlChangedEvent",e=>{const t=this.orbit;if(t&&(t.enabled=!e.value),e.value){const n=re.getComponentInParent(this.gameObject,vh);n&&n.requestOwnership()}}),h(this,"windowKeyDownListener",e=>{if(this.enabled&&this.control)switch(e.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}}),h(this,"windowKeyUpListener",e=>{if(this.enabled)switch(e.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var e;this.isGizmo&&!Vg||this.context.mainCamera&&(this.control||(this.control=new yK(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(t=>{const n=t;if(n.layers.set(2),n){const r=n.material;r&&(r.opacity=.3)}}),this.orbit=re.getComponentInParent(this.context.mainCamera,bi)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(e=this.control)==null||e.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var e,t;(e=this.control)==null||e.removeFromParent(),(t=this.control)==null||t.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(Nn.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}Aw([x()],kd.prototype,"isGizmo",2),Aw([x()],kd.prototype,"translationSnap",2),Aw([x()],kd.prototype,"rotationSnapAngle",2),Aw([x()],kd.prototype,"scaleSnap",2);var Jce=Object.defineProperty,Kce=Object.getOwnPropertyDescriptor,c2=(i,e,t,n)=>{for(var r=n>1?void 0:n?Kce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Jce(e,t,r),r};class Od extends Kr{constructor(){super(...arguments),h(this,"color"),h(this,"intensity"),h(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 e=new ZU;return this.intensity.onValueChanged=t=>{e.offset=t,this.updateDarkness(e)},this.color.onValueChanged=t=>{this.updateDarkness(e)},e}updateDarkness(e){const t=this.intensity.value;e.darkness=t}}c2([x(Rt)],Od.prototype,"color",2),c2([x(Rt)],Od.prototype,"intensity",2),c2([x(Rt)],Od.prototype,"center",2),Ho("Vignette",Od);var Zce=Object.defineProperty,$ce=Object.getOwnPropertyDescriptor,ehe=(i,e,t,n)=>{for(var r=n>1?void 0:n?$ce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Zce(e,t,r),r};const yw=ee("debugarcamera");class bw extends Ie{constructor(){super(...arguments),h(this,"backgroundTint",new yi(1,1,1,1)),h(this,"backgroundPlane"),h(this,"threeTexture"),h(this,"forceTextureInitialization",function(){const e=new ii,t=new Un,n=new Qr;n.add(new ue(t,e));const r=new Ut;return function(s,o){e.map=o,s.render(n,r),yw&&console.warn("Force texture initialization")}}()),h(this,"preRender",()=>{if(!this||!this.gameObject)return;const e=this.context.renderer.xr.getFrame();e&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new gt,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=ihe(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(e))})}onBeforeXR(e,t){t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("camera-access"),yw&&console.warn("Requesting camera-access")}onEnterXR(e){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(e){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const t=this.context.pre_render_callbacks.indexOf(this.preRender);t>=0&&this.context.pre_render_callbacks.splice(t,1)}get background(){return this.backgroundPlane}onBeforeRender(e){this.updateFromFrame(e)}updateFromFrame(e){if(!e)return;const t=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(t){for(const n of t.views)if("camera"in n&&n.camera){let r=this.context.renderer.xr.getBinding();if(r||(r=new XRWebGLBinding(e.session,this.context.renderer.getContext())),r){let s=null;if("getCameraImage"in r){s=r.getCameraImage(n.camera);const o=this.context.renderer.properties.get(this.threeTexture);o.__webglTexture=s,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):yw&&console.warn("No background plane to set texture on")}}}}}}ehe([x(yi)],bw.prototype,"backgroundTint",2);const the=`
|
|
7018
|
+
`)}}applyShadowMaterial(){if(this.targetMesh)if(this.targetMesh.material.type!=="ShadowMaterial"){const e=new ky;e.color=this.shadowColor,e.opacity=this.shadowColor.alpha,this.applyMaterialOptions(e),this.targetMesh.material=e}else{const e=this.targetMesh.material;e.color=this.shadowColor,e.opacity=this.shadowColor.alpha,this.applyMaterialOptions(e)}}applyOccluderMaterial(){if(this.targetMesh){let e=this.targetMesh.material;if(!e){const t=new ii;this.targetMesh.material=t,e=t}e.depthWrite=!0,e.stencilWrite=!0,e.colorWrite=!1,this.gameObject.renderOrder=-100}}applyMaterialOptions(e){e&&(e.depthWrite=!1,e.stencilWrite=!1)}}Cj([x()],k0.prototype,"mode",2),Cj([x(yi)],k0.prototype,"shadowColor",2);var dce=Object.defineProperty,pce=Object.getOwnPropertyDescriptor,hw=(i,e,t,n)=>{for(var r=n>1?void 0:n?pce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&dce(e,t,r),r},ZR;const Ej=(ZR=class extends Ie{constructor(){super(...arguments),h(this,"target",null),h(this,"followFactor",.1),h(this,"rotateFactor",.1),h(this,"positionAxes",ff.All),h(this,"flipForward",!1),h(this,"_firstUpdate",!0)}onBeforeRender(){this.updateNow(!1)}updateNow(i){if(!(!this.target||this.target===this.gameObject)){if(this.followFactor>0){const e=Pt(this.target),t=this._firstUpdate||i?1:Ze.clamp01(this.context.time.deltaTime*this.followFactor),n=this.worldPosition;this.positionAxes&ff.X&&(n.x=Ze.lerp(n.x,e.x,t)),this.positionAxes&ff.Y&&(n.y=Ze.lerp(n.y,e.y,t)),this.positionAxes&ff.Z&&(n.z=Ze.lerp(n.z,e.z,t)),this.worldPosition=n}if(this.rotateFactor>0){const e=xi(this.target);this.flipForward&&e.premultiply(Ej._invertForward);const t=this._firstUpdate||i?1:Ze.clamp01(this.context.time.deltaTime*this.rotateFactor);this.worldQuaternion=this.worldQuaternion.slerp(e,t)}this._firstUpdate=!1}}},h(ZR,"_invertForward",new Me().setFromAxisAngle(new S(0,1,0),Math.PI)),ZR);let Nh=Ej;hw([x(ge)],Nh.prototype,"target",2),hw([x()],Nh.prototype,"followFactor",2),hw([x()],Nh.prototype,"rotateFactor",2),hw([x()],Nh.prototype,"positionAxes",2);class fce extends ue{constructor(e){const t=new mce(e),n=new Un(t.image.width*.001,t.image.height*.001),r=new ii({map:t,toneMapped:!1,transparent:!0});super(n,r);function s(o){r.map.dispatchDOMEvent(o)}this.addEventListener("mousedown",s),this.addEventListener("mousemove",s),this.addEventListener("mouseup",s),this.addEventListener("click",s),this.dispose=function(){n.dispose(),r.dispose(),r.map.dispose(),$R.delete(e),this.removeEventListener("mousedown",s),this.removeEventListener("mousemove",s),this.removeEventListener("mouseup",s),this.removeEventListener("click",s)}}}class mce extends WS{constructor(e){super(Mj(e)),this.dom=e,this.anisotropy=16,this.colorSpace=pt,this.minFilter=Ct,this.magFilter=Ct;const t=new MutationObserver(()=>{this.scheduleUpdate||(this.scheduleUpdate=setTimeout(()=>this.update(),16))}),n={attributes:!0,childList:!0,subtree:!0,characterData:!0};t.observe(e,n),this.observer=t}dispatchDOMEvent(e){e.data&&gce(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=Mj(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}}const $R=new WeakMap;function Mj(i){const e=document.createRange(),t=new Se;function n(p){const f=[];let m=!1;function A(){if(m&&(m=!1,p.restore()),f.length===0)return;let v=-1/0,g=-1/0,y=1/0,b=1/0;for(let _=0;_<f.length;_++){const E=f[_];v=Math.max(v,E.x),g=Math.max(g,E.y),y=Math.min(y,E.x+E.width),b=Math.min(b,E.y+E.height)}p.save(),p.beginPath(),p.rect(v,g,y-v,b-g),p.clip(),m=!0}return{add:function(v){f.push(v),A()},remove:function(){f.pop(),A()}}}function r(p,f,m,A){A!==""&&(p.textTransform==="uppercase"&&(A=A.toUpperCase()),u.font=p.fontWeight+" "+p.fontSize+" "+p.fontFamily,u.textBaseline="top",u.fillStyle=p.color,u.fillText(A,f,m+parseFloat(p.fontSize)*.1))}function s(p,f,m,A,v){m<2*v&&(v=m/2),A<2*v&&(v=A/2),u.beginPath(),u.moveTo(p+v,f),u.arcTo(p+m,f,p+m,f+A,v),u.arcTo(p+m,f+A,p,f+A,v),u.arcTo(p,f+A,p,f,v),u.arcTo(p,f,p+m,f,v),u.closePath()}function o(p,f,m,A,v,g){const y=p[f+"Width"],b=p[f+"Style"],_=p[f+"Color"];y!=="0px"&&b!=="none"&&_!=="transparent"&&_!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=_,u.lineWidth=parseFloat(y),u.beginPath(),u.moveTo(m,A),u.lineTo(m+v,A+g),u.stroke())}function a(p,f){let m=0,A=0,v=0,g=0;if(p.nodeType===Node.TEXT_NODE){e.selectNode(p);const b=e.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,r(f,m,A,p.nodeValue.trim())}else{if(p.nodeType===Node.COMMENT_NODE)return;if(p instanceof HTMLCanvasElement){if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,u.save();const _=window.devicePixelRatio;u.scale(1/_,1/_),u.drawImage(p,m,A),u.restore()}else if(p instanceof HTMLImageElement){if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,u.drawImage(p,m,A,v,g)}else{if(p.style.display==="none")return;const b=p.getBoundingClientRect();m=b.left-l.left-.5,A=b.top-l.top-.5,v=b.width,g=b.height,f=window.getComputedStyle(p),s(m,A,v,g,parseFloat(f.borderRadius));const _=f.backgroundColor;_!=="transparent"&&_!=="rgba(0, 0, 0, 0)"&&(u.fillStyle=_,u.fill());const E=["borderTop","borderLeft","borderBottom","borderRight"];let I=!0,T=null;for(const M of E){if(T!==null&&(I=f[M+"Width"]===f[T+"Width"]&&f[M+"Color"]===f[T+"Color"]&&f[M+"Style"]===f[T+"Style"]),I===!1)break;T=M}if(I===!0){const M=parseFloat(f.borderTopWidth);f.borderTopWidth!=="0px"&&f.borderTopStyle!=="none"&&f.borderTopColor!=="transparent"&&f.borderTopColor!=="rgba(0, 0, 0, 0)"&&(u.strokeStyle=f.borderTopColor,u.lineWidth=M,u.stroke())}else o(f,"borderTop",m,A,v,0),o(f,"borderLeft",m,A,0,g),o(f,"borderBottom",m,A+g,v,0),o(f,"borderRight",m+v,A,0,g);if(p instanceof HTMLInputElement){let M=f.accentColor;(M===void 0||M==="auto")&&(M=f.color),t.set(M);const D=Math.sqrt(.299*t.r**2+.587*t.g**2+.114*t.b**2)<.5?"white":"#111111";if(p.type==="radio"&&(s(m,A,v,g,g),u.fillStyle="white",u.strokeStyle=M,u.lineWidth=1,u.fill(),u.stroke(),p.checked&&(s(m+2,A+2,v-4,g-4,g),u.fillStyle=M,u.strokeStyle=D,u.lineWidth=2,u.fill(),u.stroke())),p.type==="checkbox"&&(s(m,A,v,g,2),u.fillStyle=p.checked?M:"white",u.strokeStyle=p.checked?D:M,u.lineWidth=1,u.stroke(),u.fill(),p.checked)){const C=u.textAlign;u.textAlign="center";const P={color:D,fontFamily:f.fontFamily,fontSize:g+"px",fontWeight:"bold"};r(P,m+v/2,A,"\u2714"),u.textAlign=C}if(p.type==="range"){const[C,P,j]=["min","max","value"].map(O=>parseFloat(p[O])),Q=(j-C)/(P-C)*(v-g);s(m,A+g/4,v,g/2,g/4),u.fillStyle=D,u.strokeStyle=M,u.lineWidth=1,u.fill(),u.stroke(),s(m,A+g/4,Q+g/2,g/2,g/4),u.fillStyle=M,u.fill(),s(m+Q,A,g,g,g/2),u.fillStyle=M,u.fill()}(p.type==="color"||p.type==="text"||p.type==="number")&&(d.add({x:m,y:A,width:v,height:g}),r(f,m+parseInt(f.paddingLeft),A+parseInt(f.paddingTop),p.value),d.remove())}}}const y=f.overflow==="auto"||f.overflow==="hidden";y&&d.add({x:m,y:A,width:v,height:g});for(let b=0;b<p.childNodes.length;b++)a(p.childNodes[b],f);y&&d.remove()}const l=i.getBoundingClientRect();let c=$R.get(i);c===void 0&&(c=document.createElement("canvas"),c.width=l.width,c.height=l.height,$R.set(i,c));const u=c.getContext("2d"),d=new n(u);return u.clearRect(0,0,c.width,c.height),a(i),c}function gce(i,e,t,n){const r={clientX:t*i.offsetWidth+i.offsetLeft,clientY:n*i.offsetHeight+i.offsetTop,view:i.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(e,r));const s=i.getBoundingClientRect();t=t*s.width+s.left,n=n*s.height+s.top;function o(a){if(a.nodeType!==Node.TEXT_NODE&&a.nodeType!==Node.COMMENT_NODE){const l=a.getBoundingClientRect();if(t>l.left&&t<l.right&&n>l.top&&n<l.bottom&&(a.dispatchEvent(new MouseEvent(e,r)),a instanceof HTMLInputElement&&a.type==="range"&&(e==="mousedown"||e==="click"))){const[c,u]=["min","max"].map(f=>parseFloat(a[f])),d=l.width,p=(t-l.x)/d;a.value=c+(u-c)*p,a.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let c=0;c<a.childNodes.length;c++)o(a.childNodes[c])}}o(i)}const uw=new $,tm={type:"",data:uw},Tj=new xu;class vce extends hs{listenToPointerEvents(e,t){const n=this,r=new xu,s=e.domElement;function o(a){a.stopPropagation();const l=e.domElement.getBoundingClientRect();uw.x=(a.clientX-l.left)/l.width*2-1,uw.y=-(a.clientY-l.top)/l.height*2+1,r.setFromCamera(uw,t);const c=r.intersectObjects(n.children,!1);if(c.length>0){const u=c[0],d=u.object,p=u.uv;tm.type=a.type,tm.data.set(p.x,1-p.y),d.dispatchEvent(tm)}}s.addEventListener("pointerdown",o),s.addEventListener("pointerup",o),s.addEventListener("pointermove",o),s.addEventListener("mousedown",o),s.addEventListener("mouseup",o),s.addEventListener("mousemove",o),s.addEventListener("click",o)}listenToXRControllerEvents(e){const t=this,n={move:"mousemove",select:"click",selectstart:"mousedown",selectend:"mouseup"};function r(s){const o=s.target;Tj.setFromXRController(o);const a=Tj.intersectObjects(t.children,!1);if(a.length>0){const l=a[0],c=l.object,u=l.uv;tm.type=n[s.type],tm.data.set(u.x,1-u.y),c.dispatchEvent(tm)}}e.addEventListener("move",r),e.addEventListener("select",r),e.addEventListener("selectstart",r),e.addEventListener("selectend",r)}}var Ace=Object.defineProperty,yce=Object.getOwnPropertyDescriptor,Ij=(i,e,t,n)=>{for(var r=n>1?void 0:n?yce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Ace(e,t,r),r};class O0 extends Ie{constructor(){super(...arguments),h(this,"id",null),h(this,"keepAspect",!1),h(this,"_object",null)}onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const e=document.getElementById(this.id);if(!e){console.warn('Could not find element with id "'+this.id+'"');return}e.style.display="block",e.style.visibility="hidden";const t=new vce;t.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(t);const n=new fce(e);t.add(n),n.visible=!1;const r=n.material;r.transparent=!0,setTimeout(()=>{n.visible=!0;const s=mg(this.gameObject).clone();gg(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const o=new fi;o.setFromObject(t),this.setWorldRotation(s.x,s.y,s.z);const a=o.max.x-o.min.x,l=o.max.y-o.min.y;if(this.keepAspect){const u=a/l;a>l?n.scale.set(1/a,1/l/u,1):n.scale.set(1/a*u,1/l,1)}else n.scale.set(1/a,1/l,1);const c=this.gameObject.scale;n.scale.multiply(c)},1)}onDisable(){var e;(e=this._object)==null||e.removeFromParent()}}Ij([x()],O0.prototype,"id",2),Ij([x()],O0.prototype,"keepAspect",2);var bce=Object.defineProperty,_ce=Object.getOwnPropertyDescriptor,L0=(i,e,t,n)=>{for(var r=n>1?void 0:n?_ce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&bce(e,t,r),r};const U0=ee("debugspatialtrigger"),Rj=new jr,Pj=new jr;function xce(i,e){return Rj.mask=i,Pj.mask=e,Rj.test(Pj)}class ul extends Ie{constructor(){super(...arguments),h(this,"triggerMask",0),h(this,"onEnter"),h(this,"onStay"),h(this,"onExit"),h(this,"currentIntersected",[]),h(this,"lastIntersected",[])}start(){U0&&console.log(this.name,this.triggerMask,this)}update(){this.currentIntersected.length=0;for(const e of F0.triggers)xce(e.triggerMask,this.triggerMask)&&e.test(this.gameObject)&&this.currentIntersected.push(e);for(let e=this.lastIntersected.length-1;e>=0;e--){const t=this.lastIntersected[e];this.currentIntersected.indexOf(t)<0&&(this.onExitTrigger(t),this.lastIntersected.splice(e,1))}for(const e of this.currentIntersected)this.lastIntersected.indexOf(e)<0&&this.onEnterTrigger(e),this.onStayTrigger(e);this.lastIntersected.length=0,this.lastIntersected.push(...this.currentIntersected)}onEnterTrigger(e){var t;U0&&console.log("ENTER TRIGGER",this.name,e.name,this,e),e.raiseOnEnterEvent(this),(t=this.onEnter)==null||t.invoke(this,e)}onExitTrigger(e){var t;U0&&console.log("EXIT TRIGGER",this.name,e.name,this,e),e.raiseOnExitEvent(this),(t=this.onExit)==null||t.invoke(this,e)}onStayTrigger(e){var t;e.raiseOnStayEvent(this),(t=this.onStay)==null||t.invoke(this,e)}}L0([x()],ul.prototype,"triggerMask",2),L0([x(Hn)],ul.prototype,"onEnter",2),L0([x(Hn)],ul.prototype,"onStay",2),L0([x(Hn)],ul.prototype,"onExit",2);var e2;const dw=(e2=class extends Ie{constructor(){super(...arguments),h(this,"triggerMask"),h(this,"boxHelper")}start(){U0&&console.log(this.name,this.triggerMask,this)}onEnable(){var i;dw.triggers.push(this),this.boxHelper||(this.boxHelper=re.addNewComponent(this.gameObject,nl),(i=this.boxHelper)==null||i.showHelper(null,U0))}onDisable(){dw.triggers.splice(dw.triggers.indexOf(this),1)}test(i){return this.boxHelper?this.boxHelper.isInBox(i)??!1:!1}raiseOnEnterEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onEnterTrigger(this)},!1)}raiseOnStayEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onStayTrigger(this)},!1)}raiseOnExitEvent(i){re.foreachComponent(this.gameObject,e=>{e!==i&&e instanceof ul&&e.onExitTrigger(this)},!1)}},h(e2,"triggers",[]),e2);let F0=dw;L0([x()],F0.prototype,"triggerMask",2);var wce=Object.defineProperty,Sce=Object.getOwnPropertyDescriptor,Cce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&wce(e,t,r),r};const Ao=ee("debugspectator");class pw extends Ie{constructor(){super(...arguments),h(this,"cam",null),h(this,"useKeys",!0),h(this,"_mode",0),h(this,"orbit",null),h(this,"_handler"),h(this,"eventSub_WebXRRequestStartEvent",null),h(this,"eventSub_WebXRStartEvent",null),h(this,"eventSub_WebXREndEvent",null),h(this,"_debug"),h(this,"_networking")}get mode(){return this._mode}set mode(e){this._mode=e}get isSpectating(){var e;return((e=this._handler)==null?void 0:e.currentTarget)!==void 0}isSpectatingUser(e){var t;return((t=this.target)==null?void 0:t.userId)===e}isFollowedBy(e){var t;return(t=this.followers)==null?void 0:t.includes(e)}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(e){var t;if(this._handler){const n=(t=this._handler.currentTarget)==null?void 0:t.userId,r=this.context.players.getPlayerView(this.localId);e===void 0||this.context.isInXR===!1&&r?.currentObject===e.currentObject?this._handler.currentTarget!==void 0&&(this._handler.disable(),re.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),this._networking.onSpectatedObjectChanged(e,n)):this._handler.currentTarget!==e&&(this._handler.set(e),re.setActive(this.gameObject,!0),this.orbit&&(this.orbit.enabled=!1),this._networking.onSpectatedObjectChanged(e,n))}}get target(){var e;return(e=this._handler)==null?void 0:e.currentTarget}requestAllFollowMe(){this._networking.onRequestFollowMe()}get isSpectatingSelf(){var e,t;return this.isSpectating&&((e=this.target)==null?void 0:e.currentObject)===((t=this.context.players.getPlayerView(this.localId))==null?void 0:t.currentObject)}awake(){if(this._debug=new Tce(this.context,this),this._networking=new Pce(this.context,this),this._networking.awake(),re.setActive(this.gameObject,!1),this.cam=re.getComponent(this.gameObject,Bi),!this.cam){console.warn("SpectatorCamera: Spectator camera needs camera component on the same object.",this);return}!this._handler&&this.cam&&(this._handler=new Ece(this.context,this.cam,this)),this.orbit=re.getComponent(this.context.mainCamera,bi)}onDestroy(){var e,t;this.stopSpectating(),(e=this._handler)==null||e.destroy(),(t=this._networking)==null||t.destroy()}isSupportedPlatform(){const e=window.navigator.userAgent,t=/Windows|MacOS/.test(e),n=/Windows NT/.test(e)&&/Edg/.test(e)&&!/Win64/.test(e);return t&&!n}onBeforeXR(e){this.isSupportedPlatform()&&re.setActive(this.gameObject,!0)}onEnterXR(e){this.isSupportedPlatform()&&(Ao&&console.log(this.context.mainCamera),this.context.mainCamera&&this.followSelf())}onLeaveXR(e){var t,n;this.context.removeCamera(this.cam),re.setActive(this.gameObject,!1),this.orbit&&(this.orbit.enabled=!0),(t=this._handler)==null||t.set(void 0),(n=this._handler)==null||n.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,uh.Headset),this.target=this.context.players.getPlayerView(this.localId)),Ao&&console.log("Follow self",this.target)}onAfterRender(){var e,t,n;if(!this.cam)return;const r=this.context.renderer,s=r.xr.enabled;if(!r.xr.isPresenting&&!((e=this._handler)!=null&&e.currentTarget))return;(t=this._handler)==null||t.update(this._mode);const o=r.getRenderTarget();let a=null;const l=r.state;if(!o){if(!r.state.bindFramebuffer||!l.bindXRFramebuffer)return;a=r._framebuffer,l.bindXRFramebuffer(null)}this.setAvatarFlagsBeforeRender();const c=this.context.mainCameraComponent;if(c){const p=c.backgroundColor;p&&r.setClearColor(p,p.alpha),this.cam.backgroundColor=p,this.cam.clearFlags=c.clearFlags,this.cam.nearClipPlane=c.nearClipPlane,this.cam.farClipPlane=c.farClipPlane}else r.setClearColor(new Se(1,1,1));r.setRenderTarget(null),r.xr.enabled=!1;const u=(n=this.cam)==null?void 0:n.cam;this.context.updateAspect(u);const d=r.xr.isPresenting;r.xr.isPresenting=!1,r.setSize(this.context.domWidth,this.context.domHeight),r.render(this.context.scene,u),r.xr.isPresenting=d,r.xr.enabled=s,o?r.setRenderTarget(o):l.bindXRFramebuffer&&l.bindXRFramebuffer(a),this.resetAvatarFlags()}setAvatarFlagsBeforeRender(){const e=this._mode===0;for(const t of Er.instances)if(t.avatar&&"isLocalAvatar"in t.avatar&&"flags"in t.avatar){let n=el.All;this.isSpectatingSelf&&(n=e&&t.avatar.isLocalAvatar?el.FirstPerson:el.ThirdPerson);const r=t.avatar.flags;if(!r)continue;for(const s of r)s.UpdateVisible(n)}}resetAvatarFlags(){var e;for(const t of Er.instances)if(t.avatar&&"flags"in t.avatar){const n=t.avatar.flags;if(!n)continue;for(const r of n)"isLocalAvatar"in t.avatar&&(e=t.avatar)!=null&&e.isLocalAvatar?r.UpdateVisible(el.FirstPerson):r.UpdateVisible(el.ThirdPerson)}}}Cce([x()],pw.prototype,"useKeys",2);class Ece{constructor(e,t,n){h(this,"context"),h(this,"cam"),h(this,"spectator"),h(this,"follow"),h(this,"target"),h(this,"view"),h(this,"currentObject"),this.context=e,this.cam=t,this.spectator=n}get currentTarget(){return this.view}set(e){const t=e?.currentObject;if(!t){this.spectator.stopSpectating();return}t!==this.currentObject&&(this.currentObject=t,this.view=e,this.follow||(this.follow=re.addNewComponent(this.cam.gameObject,Nh)),this.target||(this.target=new ge),t.add(this.target),this.follow.enabled=!0,this.follow.target=this.target,Ao&&console.log("FOLLOW",t),this.context.isInXR?this.context.removeCamera(this.cam):this.context.setCurrentCamera(this.cam))}disable(){Ao&&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 e;(e=this.target)==null||e.removeFromParent(),this.follow&&re.destroy(this.follow)}update(e){var t,n,r,s,o,a;if(((t=this.currentTarget)==null?void 0:t.isConnected)===!1||((n=this.currentTarget)==null?void 0:n.removed)===!0){Ao&&console.log("Target disconnected or timeout",this.currentTarget),this.spectator.stopSpectating();return}this.currentTarget&&((r=this.currentTarget)==null?void 0:r.currentObject)!==this.currentObject&&(Ao&&console.log("Target changed",this.currentObject,"to",this.currentTarget.currentObject),this.set(this.currentTarget));const l=this.context.mainCamera;l&&(this.cam.cam.near!==l.near||this.cam.cam.far!==l.far)&&(this.cam.cam.near=l.near,this.cam.cam.far=l.far,this.cam.cam.updateProjectionMatrix());const c=(s=this.follow)==null?void 0:s.target;if(!(!c||!this.follow)){switch(e){case 0:((o=this.view)==null?void 0:o.viewDevice)!==uh.Browser?(this.follow.followFactor=5,this.follow.rotateFactor=5):(this.follow.followFactor=50,this.follow.rotateFactor=50),c.position.set(0,0,0);break;case 1:this.follow.followFactor=3,this.follow.rotateFactor=2,c.position.set(0,.5,1.5);break}this.follow.flipForward=!1,((a=this.view)==null?void 0:a.viewDevice)!==uh.Browser?c.quaternion.copy(Mce):c.quaternion.identity()}}}const Mce=new Me().setFromAxisAngle(new S(0,1,0),Math.PI);class Tce{constructor(e,t){h(this,"context"),h(this,"spectator"),this.context=e,this.spectator=t,console.log("Click other avatars or cameras to follow them. Press ESC to exit spectator mode."),this.context.domElement.addEventListener("keydown",r=>{!this.spectator.useKeys||r.key==="Escape"&&this.spectator.stopSpectating()});let n=0;this.context.input.addEventListener(qi.PointerDown,r=>{n=this.context.time.time}),this.context.input.addEventListener(qi.PointerUp,r=>{const s=this.context.time.time-n;s>1?this.spectator.stopSpectating():this.context.input.getPointerClicked(0)&&s<.3&&this.trySelectObject()})}trySelectObject(){const e=new No;e.setMask(16777215);const t=this.context.physics.raycast(e);if(Ao&&console.log(...t),t!=null&&t.length)for(const n of t){if(n.distance<.2)continue;const r=n.object,s=re.getComponentInParent(r,Er),o=s?.connectionId;if(o){const a=this.context.players.getPlayerView(o);this.spectator.target=a,Ao&&console.log("spectate",o,s);break}}}}class Ice{constructor(e,t,n){h(this,"guid"),h(this,"dontSave",!0),h(this,"targetUserId"),h(this,"stoppedFollowing"),this.guid=e,this.targetUserId=t,this.stoppedFollowing=n}}class Rce{constructor(e,t){h(this,"guid"),h(this,"userId"),this.guid=e.guid,this.userId=t}}class Pce{constructor(e,t){h(this,"followers",[]),h(this,"context"),h(this,"spectator"),h(this,"_followerEventMethod"),h(this,"_requestFollowMethod"),h(this,"_joinedRoomMethod"),h(this,"_lastRequestFollowUser"),h(this,"_enforceFollowInterval"),this.context=e,this.spectator=t,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(Kt.JoinedRoom,this._joinedRoomMethod),this.context.domElement.addEventListener("keydown",e=>{this.spectator.useKeys&&(e.key==="f"?this.onRequestFollowMe():e.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(Kt.JoinedRoom,this._joinedRoomMethod)}onSpectatedObjectChanged(e,t){if(Ao&&console.log(this.context.connection.connectionId,"onSpectatedObjectChanged",e,t),this.context.connection.connectionId){const n=e?.userId===void 0,r=n?t:e?.userId,s=new Ice(this.context.connection.connectionId,r,n);this.context.connection.send("spectator-follower-changed",s)}}onRequestFollowMe(e=!1){if(Ao&&console.log("Request follow",this.context.connection.connectionId),this.context.connection.connectionId){this.spectator.stopSpectating();const t=e?void 0:this.context.connection.connectionId,n=new Rce(this.spectator,t);this.context.connection.send("spectator-request-follow",n)}}onUserJoinedRoom(){ee("followme")&&this.onRequestFollowMe()}onFollowerEvent(e){const t=e.targetUserId,n=e.guid;if(Ao&&console.log(e),t===this.context.connection.connectionId)if(e.stoppedFollowing){const r=this.followers.indexOf(n);r!==-1&&(this.followers.splice(r,1),this.removeDisconnectedFollowers(),console.log(n,"unfollows you",this.followers.length))}else this.followers.includes(n)||(this.followers.push(n),this.removeDisconnectedFollowers(),console.log(n,"follows you",this.followers.length))}removeDisconnectedFollowers(){for(let e=this.followers.length-1;e>=0;e--){const t=this.followers[e];this.context.connection.userIsInRoom(t)===!1&&this.followers.splice(e,1)}}onRequestFollowEvent(e){if(this._lastRequestFollowUser=e,e.userId===this.context.connection.connectionId)this.spectator.stopSpectating();else if(e.userId===void 0)this.spectator.stopSpectating();else{const t=this.context.players.getPlayerView(e.userId);if(t)this.spectator.target=t;else return Ao&&console.warn("Could not find view",e.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):(Ao&&console.log("REQUEST FOLLOW AGAIN",this._lastRequestFollowUser.userId),this.onRequestFollowEvent(this._lastRequestFollowUser))},1e3))}}var Bce=Object.defineProperty,Dce=Object.getOwnPropertyDescriptor,Ms=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Bce(e,t,r),r};const fw=ee("debugspriterenderer"),kce=ee("wireframe"),t2=class{static getOrCreateGeometry(i){if(i.__cached_geometry)return i.__cached_geometry;if(i.guid&&t2.cache[i.guid])return fw&&console.log("Take cached geometry for sprite",i.guid),t2.cache[i.guid];const e=new ft;i.__cached_geometry=e;const t=new Float32Array(i.triangles.length*3),n=new Float32Array(i.triangles.length*2);for(let r=0;r<i.triangles.length;r+=1){const s=i.triangles[r];t[r*3]=-i.vertices[s].x,t[r*3+1]=i.vertices[s].y,t[r*3+2]=0;const o=i.uv[s];n[r*2]=o.x,n[r*2+1]=1-o.y}return e.setAttribute("position",new $e(t,3)),e.setAttribute("uv",new $e(n,2)),i.guid&&(this.cache[i.guid]=e),fw&&console.log("Built sprite geometry",i,e),e}};let N0=t2;h(N0,"cache",{});class yc{constructor(){h(this,"guid"),h(this,"texture"),h(this,"triangles"),h(this,"uv"),h(this,"vertices"),h(this,"__cached_geometry"),h(this,"_mesh"),h(this,"_material")}get mesh(){return this._mesh||(this._mesh=new ue(N0.getOrCreateGeometry(this),this.material)),this._mesh}get material(){return this._material||(this.texture&&(this.texture.colorSpace=pt,this.texture.minFilter==Lt&&this.texture.magFilter==Lt&&(this.texture.anisotropy=1),this.texture.needsUpdate=!0),this._material=new ii({map:this.texture,color:16777215,side:li,transparent:!0})),this._material}getGeometry(){return N0.getOrCreateGeometry(this)}}Ms([x()],yc.prototype,"guid",2),Ms([x(gt)],yc.prototype,"texture",2),Ms([qp()],yc.prototype,"triangles",2),Ms([qp()],yc.prototype,"uv",2),Ms([qp()],yc.prototype,"vertices",2);const i2=Symbol("spriteOwner");class z0{constructor(){h(this,"sprites")}}Ms([x(yc)],z0.prototype,"sprites",2);class im{constructor(){h(this,"spriteSheet"),h(this,"index",0)}update(e,t,n){if(!this.spriteSheet)return;const r=this.index;if(r<0||r>=this.spriteSheet.sprites.length)return;const s=this.spriteSheet.sprites[r],o=s?.texture;if(o&&(o.colorSpace=pt,o.minFilter==Lt&&o.magFilter==Lt&&(o.anisotropy=1),o.needsUpdate=!0,!s.__hasLoadedProgressive)){s.__hasLoadedProgressive=!0;const a=o;Ii.assignTextureLOD(e,t,o,0).then(l=>{l instanceof gt&&(s.texture=l,n?.map===a&&(n.map=l,n.needsUpdate=!0))})}}}Ms([x(z0)],im.prototype,"spriteSheet",2),Ms([x()],im.prototype,"index",2);class dl extends Ie{constructor(){super(...arguments),h(this,"drawMode",0),h(this,"size",{x:1,y:1}),h(this,"color"),h(this,"sharedMaterial"),h(this,"transparent",!0),h(this,"cutoutThreshold",0),h(this,"castShadows",!1),h(this,"_spriteSheet"),h(this,"_currentSprite")}get sprite(){return this._spriteSheet}set sprite(e){if(e!==this._spriteSheet)if(typeof e=="number"){const t=Math.floor(e);this.spriteIndex=t;return}else this._spriteSheet=e,this.updateSprite()}set spriteIndex(e){this._spriteSheet&&(this._spriteSheet.index=e,this.updateSprite())}get spriteIndex(){var e;return((e=this._spriteSheet)==null?void 0:e.index)??0}get spriteFrames(){var e,t;return((t=(e=this._spriteSheet)==null?void 0:e.spriteSheet)==null?void 0:t.sprites.length)??0}awake(){this._currentSprite=void 0,fw&&console.log("Awake",this.name,this,this.sprite)}start(){this._currentSprite?this.gameObject&&this.gameObject.add(this._currentSprite):this.updateSprite()}updateSprite(){var e,t,n;if(!this.__didAwake||!((t=(e=this.sprite)==null?void 0:e.spriteSheet)!=null&&t.sprites))return;const r=this.sprite.spriteSheet.sprites[this.spriteIndex];if(!r){fw&&console.warn("Sprite not found",this.spriteIndex,this.sprite.spriteSheet.sprites);return}if(this._currentSprite)this._currentSprite.geometry=N0.getOrCreateGeometry(r),this._currentSprite.material.map=r.texture;else{const s=new ii({color:16777215,side:li});if(!s)return;if(kce&&(s.wireframe=!0),this.color&&(s.color||(s.color=new Se),s.color.copy(this.color),s.opacity=this.color.alpha),s.transparent=!0,r.texture&&!s.wireframe){let o=r.texture;o[i2]!==void 0&&o[i2]!==this&&this.spriteFrames>1&&(o=r.texture=o.clone()),o[i2]=this,s.map=o}this.sharedMaterial=s,this._currentSprite=new ue(N0.getOrCreateGeometry(r),s),Ii.assignTextureLOD(this.context,this.sourceId,s,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,(n=this._spriteSheet)==null||n.update(this.context,this.sourceId,this.sharedMaterial)}}Ms([x()],dl.prototype,"drawMode",2),Ms([x(yi)],dl.prototype,"color",2),Ms([x(It)],dl.prototype,"sharedMaterial",2),Ms([x()],dl.prototype,"transparent",2),Ms([x()],dl.prototype,"cutoutThreshold",2),Ms([x()],dl.prototype,"castShadows",2),Ms([x(im)],dl.prototype,"sprite",1);class _l{constructor(){h(this,"bb",null),h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedCameraModel(e,t){return(t||new _l).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedCameraModel(e,t){return e.setPosition(e.position()+lT),(t||new _l).__init(e.readInt32(e.position())+e.position(),e)}userId(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}guid(e){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dontSave(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}pos(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new ed).__init(this.bb_pos+t,this.bb):null}rot(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new ed).__init(this.bb_pos+t,this.bb):null}static startSyncedCameraModel(e){e.startObject(5)}static addUserId(e,t){e.addFieldOffset(0,t,0)}static addGuid(e,t){e.addFieldOffset(1,t,0)}static addDontSave(e,t){e.addFieldInt8(2,+t,0)}static addPos(e,t){e.addFieldStruct(3,t,0)}static addRot(e,t){e.addFieldStruct(4,t,0)}static endSyncedCameraModel(e){return e.endObject()}static finishSyncedCameraModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedCameraModelBuffer(e,t){e.finish(t,void 0,!0)}}var Oce=Object.defineProperty,Lce=Object.getOwnPropertyDescriptor,Uce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Lce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Oce(e,t,r),r};const mw="SCAM";uT(mw,_l.getRootAsSyncedCameraModel);const yo=new rA;class Fce{constructor(e,t){h(this,"userId"),h(this,"guid"),this.guid=t,this.userId=e}send(e,t){if(e){yo.clear();const n=yo.createString(this.guid),r=yo.createString(this.userId);_l.startSyncedCameraModel(yo),_l.addGuid(yo,n),_l.addUserId(yo,r);const s=Pt(e),o=mg(e);_l.addPos(yo,ed.createVec3(yo,s.x,s.y,s.z)),_l.addRot(yo,ed.createVec3(yo,o.x,o.y,o.z));const a=_l.endSyncedCameraModel(yo);yo.finish(a,mw),t.sendBinary(yo.asUint8Array())}}}var n2;const r2=(n2=class extends Ie{constructor(){super(...arguments),h(this,"cameraPrefab",null),h(this,"_lastWorldPosition"),h(this,"_lastWorldQuaternion"),h(this,"_model",null),h(this,"_needsUpdate",!0),h(this,"_lastUpdateTime",0),h(this,"remoteCams",{}),h(this,"userToCamMap",{}),h(this,"_camTimeoutInSeconds",10),h(this,"_receiveCallback",null)}getCameraObject(i){const e=this.userToCamMap[i];return e?this.remoteCams[e].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(mw,this.onReceivedRemoteCameraInfoBin.bind(this))}onDisable(){this.context.connection.stopListenBinary(mw,this._receiveCallback)}update(){for(const n in this.remoteCams){const r=this.remoteCams[n],s=this.context.time.realtimeSinceStartup-r.lastUpdate;if(!r||s>this._camTimeoutInSeconds){ut()&&console.log("Remote cam timeout",n),r!=null&&r.obj&&re.destroy(r.obj),delete this.remoteCams[n],r&&delete this.userToCamMap[r.userId],r2.instances.push(r),this.context.players.removePlayerView(r.userId,uh.Browser);continue}}if(this.context.isInXR)return;const i=this.context.mainCamera;if(i===null){this.enabled=!1;return}if(!this.context.connection.isConnected||this.context.connection.connectionId===null)return;this._model===null&&(this._model=new Fce(this.context.connection.connectionId,this.context.connection.connectionId+"_camera"));const e=Pt(i),t=xi(i);(e.distanceTo(this._lastWorldPosition)>.001||t.angleTo(this._lastWorldQuaternion)>.01)&&(this._needsUpdate=!0),this._lastWorldPosition.copy(e),this._lastWorldQuaternion.copy(t),!((!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(i,this.context.connection),this.context.isInXR||this.context.players.setPlayerView(this.context.connection.connectionId,i,uh.Browser))}onReceivedRemoteCameraInfoBin(i){const e=i.guid();if(!e)return;const t=i.userId();if(!t||!this.context.connection.userIsInRoom(t)||!this.cameraPrefab)return;let n=this.remoteCams[e];if(!n)if("isObject3D"in this.cameraPrefab){const a=new Ia;a.context=this.context;const l=re.instantiate(this.cameraPrefab,a);n=this.remoteCams[e]={obj:l,lastUpdate:this.context.time.realtimeSinceStartup,userId:t},n.obj.visible=!0,this.gameObject.add(l),this.userToCamMap[t]=e,r2.instances.push(n);const c=re.getOrAddComponent(l,Er);c.connectionId=t,c.avatar=l}else return;const r=n.obj;this.context.players.setPlayerView(t,r,uh.Browser),n.lastUpdate=this.context.time.realtimeSinceStartup,$o.markDirty(r);const s=i.pos();s&&Tu(r,s.x(),s.y(),s.z());const o=i.rot();o&&gg(r,o.x(),o.y(),o.z())}},h(n2,"instances",[]),n2);let gw=r2;Uce([x([ge,Zt])],gw.prototype,"cameraPrefab",2);var Nce=Object.defineProperty,zce=Object.getOwnPropertyDescriptor,nm=(i,e,t,n)=>{for(var r=n>1?void 0:n?zce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Nce(e,t,r),r};const s2="view",o2=ee("debugsyncedroom");class bc extends Ie{constructor(){super(...arguments),h(this,"roomName"),h(this,"urlParameterName","room"),h(this,"joinRandomRoom",!0),h(this,"requireRoomParameter",!1),h(this,"autoRejoin",!0),h(this,"createJoinButton",!0),h(this,"_roomPrefix"),h(this,"_lastJoinedRoom",""),h(this,"_lastPingTime",0),h(this,"_lastRoomTime",-1),h(this,"_userWantsToBeInARoom",!1),h(this,"_roomButton"),h(this,"_roomButtonIconJoin"),h(this,"_roomButtonIconLeave"),h(this,"updateRoomButtonState",()=>{var e,t;this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",(e=this._roomButtonIconJoin)==null||e.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",(t=this._roomButtonIconLeave)==null||t.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))})}get roomPrefix(){return this._roomPrefix}get RoomPrefix(){return this._roomPrefix}awake(){o2&&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 e=ee(s2);if(e&&typeof e=="string"&&e.length>0){console.log("Join as viewer"),this.context.connection.joinRoom(e,!0);return}if((this.joinRandomRoom||ee(this.urlParameterName))&&this.tryJoinRoom(),this.createJoinButton){const t=this.createRoomButton();this.context.menu.appendChild(t)}}onDisable(){var e;(e=this._roomButton)==null||e.remove(),this.roomName&&this.roomName.length>0&&this.context.connection.leaveRoom(this.roomName)}onDestroy(){this.destroyRoomButton()}tryJoinRandomRoom(){this.setRandomRoomUrlParameter(),this.tryJoinRoom()}tryJoinRoom(e=0){e===void 0&&(e=0);let t=!1;if(this.urlParameterName){const n=ee(this.urlParameterName);if(n&&typeof n=="string"||n==="number"){t=!0;const r=xk(n);this.roomName=r}else if(this.joinRandomRoom&&(console.log("No room name found in url, generating random one"),this.setRandomRoomUrlParameter(),e<1))return this.tryJoinRoom(e+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&&!t?(o2&&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(),o2&&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()):ut()&&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 ee(s2)||ee(this.urlParameterName)}setRandomRoomUrlParameter(){const e=sg(),t=this.generateRoomName();ee(this.urlParameterName)?e.set(this.urlParameterName,t):e.append(this.urlParameterName,t),RC(t,e)}generateRoomName(){return PC()+"_"+Math.floor(Ze.random(100,999))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const e=window.location.search,t=new URLSearchParams(e);return t.has(this.urlParameterName)&&t.delete(this.urlParameterName),t.set(s2,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+t.toString()}return null}createRoomButton(){if(this._roomButton)return this._roomButton;const e=document.createElement("button");return this._roomButton=e,e.classList.add("create-room-button"),e.setAttribute("priority","90"),e.onclick=()=>{this.context.connection.isInRoom?(this.urlParameterName&&Zy(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1):(this.urlParameterName&&(ee(this.urlParameterName)||(this._lastJoinedRoom?Zy(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())),this.tryJoinRoom())},this._roomButtonIconJoin=to("group"),this._roomButtonIconLeave=to("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(Kt.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(Kt.LeftRoom,this.updateRoomButtonState),e}destroyRoomButton(){this.context.connection.stopListen(Kt.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(Kt.LeftRoom,this.updateRoomButtonState)}}nm([x()],bc.prototype,"roomName",2),nm([x()],bc.prototype,"urlParameterName",2),nm([x()],bc.prototype,"joinRandomRoom",2),nm([x()],bc.prototype,"requireRoomParameter",2),nm([x()],bc.prototype,"autoRejoin",2),nm([x()],bc.prototype,"createJoinButton",2);class vw extends Ie{}function jce(){const i=ee("testwindowcount")||0;i&&i>0&&Gce(i)}function Gce(i){if(ee("testwindow"))return null;const e=new URL(window.location.href);IC(e.searchParams,zne,1),IC(e.searchParams,"testwindow",1);const t=e.toString(),n=[];window.onbeforeunload=()=>{for(const l of n)l.close()};const r=.05,s=128;let o=0,a=0;for(let l=0;l<i;l++){o*s+s*.01>=window.innerWidth&&(a+=1,o=0);const c=o*(s*(1+r))+window.screenLeft,u=a*(s*(1+r))+window.screenTop+90+60*a;o+=1;const d=window.open(t,"test window "+l,`popup=yes width=${s} height=${s} top=${u} left=${c}`);if(!d){console.warn("Failed to open window");continue}n.push(d),d.onload=()=>{d.onbeforeunload=()=>{for(let p=0;p<n.length;p++){const f=n[p];f!==d&&f.close()}n.length=0}}}return n}class a2 extends Ie{awake(){jce()}}class l2 extends Ie{constructor(){super(...arguments),h(this,"transformsPerFrame",10),h(this,"interval",0),h(this,"useFlatbuffers",!0),h(this,"builder",null),h(this,"models",null)}awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(Av,e=>{});else{this.models=[];for(let e=0;e<this.transformsPerFrame;e++)this.models.push(new Bj(this.context.connection.connectionId+"_simulatedTransform_"+e,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 rA(1024));const e=this.builder;for(let t=0;t<this.transformsPerFrame;t++){e.clear();const n=t4(this.context.connection.connectionId,this);this.context.connection.sendBinary(n)}}else if(this.models)for(let e=0;e<this.models.length;e++){const t=this.models[e];t.dontSave=!0,t.update(this,null),this.context.connection.send("TestSimulateUserData-"+e,t)}}}}class Bj{constructor(e,t){h(this,"guid"),h(this,"fast",!1),h(this,"position"),h(this,"rotation"),h(this,"velocity"),h(this,"dontSave"),this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}update(e,t){const n=e.worldPosition;this.position.x=n.x,this.position.y=n.y,this.position.z=n.z;const r=e.worldQuaternion;if(this.rotation.x=r.x,this.rotation.y=r.y,this.rotation.z=r.z,this.rotation.w=r.w,this.fast=!1,t){const s=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=s.x,this.velocity.y=s.y,this.velocity.z=s.z}}}h(Bj,"temp",new S);var Qce=Object.defineProperty,Hce=Object.getOwnPropertyDescriptor,rm=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Qce(e,t,r),r};class pl extends Kr{constructor(){super(...arguments),h(this,"offset"),h(this,"rotation"),h(this,"focusArea"),h(this,"feather"),h(this,"kernelSize"),h(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=ql.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){console.log(this);const e=new V$({kernelSize:ql.VERY_LARGE});return this.offset.onValueChanged=t=>e.offset=t,this.rotation.onValueChanged=t=>e.rotation=t,this.focusArea.onValueChanged=t=>e.focusArea=t,this.feather.onValueChanged=t=>e.feather=t,this.kernelSize.onValueChanged=t=>e.blurPass.kernelSize=t,this.resolutionScale.onValueChanged=t=>e.resolution.scale=t/window.devicePixelRatio,e}}rm([x(Rt)],pl.prototype,"offset",2),rm([x(Rt)],pl.prototype,"rotation",2),rm([x(Rt)],pl.prototype,"focusArea",2),rm([x(Rt)],pl.prototype,"feather",2),rm([x(Rt)],pl.prototype,"kernelSize",2),rm([x(Rt)],pl.prototype,"resolutionScale",2),Ho("TiltShiftEffect",pl);var Vce=Object.defineProperty,Wce=Object.getOwnPropertyDescriptor,qce=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Vce(e,t,r),r};class j0 extends Kr{constructor(){super(...arguments),h(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new Rt(Bs)),this.mode.defaultValue=Bs}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(e){this.context.renderer.toneMapping=this.getThreeToneMapping(e)}getThreeToneMapping(e){switch(e){case 0:return Vd;case 1:return yA;case 2:return AA;default:return Vd}}}qce([x(Rt)],j0.prototype,"mode",2),Ho("Tonemapping",j0);var Xce=Object.defineProperty,Yce=Object.getOwnPropertyDescriptor,Aw=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Xce(e,t,r),r};class kd extends Ie{constructor(){super(...arguments),h(this,"isGizmo",!1),h(this,"translationSnap",1),h(this,"rotationSnapAngle",15),h(this,"scaleSnap",.25),h(this,"control"),h(this,"orbit"),h(this,"onControlChangedEvent",e=>{const t=this.orbit;if(t&&(t.enabled=!e.value),e.value){const n=re.getComponentInParent(this.gameObject,vh);n&&n.requestOwnership()}}),h(this,"windowKeyDownListener",e=>{if(this.enabled&&this.control)switch(e.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}}),h(this,"windowKeyUpListener",e=>{if(this.enabled)switch(e.keyCode){case 16:this.disableSnapping();break}})}onEnable(){var e;this.isGizmo&&!Vg||this.context.mainCamera&&(this.control||(this.control=new yK(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(t=>{const n=t;if(n.layers.set(2),n){const r=n.material;r&&(r.opacity=.3)}}),this.orbit=re.getComponentInParent(this.context.mainCamera,bi)??void 0),this.control&&(this.context.scene.add(this.control),this.control.attach(this.gameObject),(e=this.control)==null||e.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)))}onDisable(){var e,t;(e=this.control)==null||e.removeFromParent(),(t=this.control)==null||t.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(Nn.degToRad(this.rotationSnapAngle)),this.control.setScaleSnap(this.scaleSnap))}disableSnapping(){this.control&&(this.control.setTranslationSnap(null),this.control.setRotationSnap(null),this.control.setScaleSnap(null))}}Aw([x()],kd.prototype,"isGizmo",2),Aw([x()],kd.prototype,"translationSnap",2),Aw([x()],kd.prototype,"rotationSnapAngle",2),Aw([x()],kd.prototype,"scaleSnap",2);var Jce=Object.defineProperty,Kce=Object.getOwnPropertyDescriptor,c2=(i,e,t,n)=>{for(var r=n>1?void 0:n?Kce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Jce(e,t,r),r};class Od extends Kr{constructor(){super(...arguments),h(this,"color"),h(this,"intensity"),h(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 e=new ZU;return this.intensity.onValueChanged=t=>{e.offset=t,this.updateDarkness(e)},this.color.onValueChanged=t=>{this.updateDarkness(e)},e}updateDarkness(e){const t=this.intensity.value;e.darkness=t}}c2([x(Rt)],Od.prototype,"color",2),c2([x(Rt)],Od.prototype,"intensity",2),c2([x(Rt)],Od.prototype,"center",2),Ho("Vignette",Od);var Zce=Object.defineProperty,$ce=Object.getOwnPropertyDescriptor,ehe=(i,e,t,n)=>{for(var r=n>1?void 0:n?$ce(e,t):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(n?o(e,t,r):o(r))||r);return n&&r&&Zce(e,t,r),r};const yw=ee("debugarcamera");class bw extends Ie{constructor(){super(...arguments),h(this,"backgroundTint",new yi(1,1,1,1)),h(this,"backgroundPlane"),h(this,"threeTexture"),h(this,"forceTextureInitialization",function(){const e=new ii,t=new Un,n=new Qr;n.add(new ue(t,e));const r=new Ut;return function(s,o){e.map=o,s.render(n,r),yw&&console.warn("Force texture initialization")}}()),h(this,"preRender",()=>{if(!this||!this.gameObject)return;const e=this.context.renderer.xr.getFrame();e&&(!this.threeTexture&&this.context.renderer&&(this.threeTexture=new gt,this.forceTextureInitialization(this.context.renderer,this.threeTexture)),this.backgroundPlane===void 0&&(this.backgroundPlane=ihe(this.backgroundTint)),this.backgroundPlane.parent!==this.scene&&this.scene.add(this.backgroundPlane),this.updateFromFrame(e))})}onBeforeXR(e,t){t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("camera-access"),yw&&console.warn("Requesting camera-access")}onEnterXR(e){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(e){this.backgroundPlane&&this.backgroundPlane.removeFromParent();const t=this.context.pre_render_callbacks.indexOf(this.preRender);t>=0&&this.context.pre_render_callbacks.splice(t,1)}get background(){return this.backgroundPlane}onBeforeRender(e){this.updateFromFrame(e)}updateFromFrame(e){if(!e)return;const t=e.session.enabledFeatures;if(t&&!t.some(r=>r==="camera-access")){this.background&&(this.background.visible=!1);return}const n=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(n){for(const r of n.views)if("camera"in r&&r.camera){let s=this.context.renderer.xr.getBinding();if(s||(s=new XRWebGLBinding(e.session,this.context.renderer.getContext())),s){let o=null;if("getCameraImage"in s){o=s.getCameraImage(r.camera);const a=this.context.renderer.properties.get(this.threeTexture);a.__webglTexture=o,this.backgroundPlane?(this.backgroundPlane.setTexture(this.threeTexture),this.backgroundPlane.visible=!0):yw&&console.warn("No background plane to set texture on")}}}}}}ehe([x(yi)],bw.prototype,"backgroundTint",2);const the=`
|
|
7019
7019
|
uniform sampler2D t2D;
|
|
7020
7020
|
|
|
7021
7021
|
varying vec2 vUv;
|