@needle-tools/engine 3.37.7-beta → 3.37.7-beta.1
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 +3 -0
- package/dist/needle-engine.js +9 -8
- package/dist/needle-engine.light.js +9 -8
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js +3 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/export/usdz/extensions/Animation.ts +3 -2
|
@@ -4340,7 +4340,7 @@ void main() {
|
|
|
4340
4340
|
}`),h(ba,"blipMaterial"),h(ba,"mesh");function GN(s){return ba.copyTexture(s)}function bY(s,e=!1){return ba.textureToCanvas(s,e)}function xY(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&s instanceof ImageBitmap}let I0=!1;g9((...s)=>{var e;gt()&&((e=ri.Current)!=null&&e.isInXR)&&(kp(!0),HN("error",...s))});function kp(s){if(s){if(I0)return;I0=!0,SY()}else{if(!I0)return;I0=!1,CY()}}const jg={log:void 0,warn:void 0,error:void 0};class wY{constructor(){h(this,"familyName","needle-xr");h(this,"root",null);h(this,"context",null);h(this,"defaultFontSize",.06);h(this,"targetObject",new me);h(this,"userForwardViewPoint",new w);h(this,"oneEuroFilter",new kI(90,.8));h(this,"_lastElementRemoveTime",0);h(this,"onBeforeRender",()=>{var t,i;const e=(t=this.context)==null?void 0:t.mainCamera;if(this.context&&e instanceof Gt){const n=this.getRoot();Number.isNaN(n.position.x)&&n.position.set(0,0,0),Number.isNaN(n.quaternion.x)&&n.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const r=((i=this.context.xr)==null?void 0:i.rigScale)??1,o=3.5*r,a=e.worldForward;a.y=0,a.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(e.worldPosition).sub(a),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*r&&(this.targetObject.position.copy(this.userForwardViewPoint),EA(this.targetObject,e,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,n.position,this.context.time.time);const c=this.context.time.deltaTime;if(n.quaternion.slerp(this.targetObject.quaternion,c*5),n.scale.setScalar(r),this.targetObject.removeFromParent(),this.context.scene.add(n),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const u=Date.now();for(let d=0;d<this._activeTexts.length;d++){const f=this._activeTexts[d];if(f instanceof Oi.Text&&u-f._activatedTime>2e4){f.removeFromParent(),this._textBuffer.push(f),this._activeTexts.splice(d,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=ri.Current||ri.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var e,t,i;(t=this.context)==null||t.pre_render_callbacks.splice((e=this.context)==null?void 0:e.pre_render_callbacks.indexOf(this.onBeforeRender),1),(i=this.root)==null||i.removeFromParent()}addLog(e,t){const i=this.getRoot(),n=this.getText();let r=16777215,o=0;switch(e){case"log":r=16777215,o=0;break;case"warn":r=16772761,o=4465152;break;case"error":r=16755370,o=7798784;break}t.length>1e3&&(t=t.substring(0,1e3)+"...");const a=new Date().toISOString().split("T")[1].split(".")[0];n.textContent="["+a+"] "+t,n.visible=!0,n._activatedTime=Date.now(),i.add(n),this._activeTexts.push(n),this.context&&this.context.scene.add(i),n.set({backgroundColor:r,color:o}),Oi.update()}ensureFont(){let e=Oi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Oi.FontLibrary.addFontFamily(this.familyName);const t=e.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");t==null||t.addEventListener("ready",()=>{Oi.update()})}}getText(){const e=this.getRoot();if(this._textBuffer.length>0){const i=this._textBuffer.pop();return i.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(i),100),i}if(e.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const t=new Oi.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(t),500),setTimeout(()=>this.disableDepthTestRecursive(t),1500),t}disableDepthTestRecursive(e,t=0){for(let n=0;n<e.children.length;n++){const r=e.children[n];r instanceof me&&this.disableDepthTestRecursive(r,t+1)}e.renderOrder=10*t,e.layers.set(2);const i=e.material;i&&(i.depthWrite=!1,i.depthTest=!1,i.transparent=!0),t===0&&Oi.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 Oi.Block(t),this.root}}let br=null;function SY(){br||(br=new wY),br.onEnable();for(const s in jg){jg[s]=console[s];let e=!1;console[s]=function(){var t;if((t=jg[s])==null||t.apply(console,arguments),!e)try{e=!0,HN(s,...arguments)}finally{e=!1}}}}function CY(){br==null||br.onDisable();for(const s in jg)console[s]=jg[s]}const Vm=new Map;function HN(s,...e){try{switch(Vm.clear(),s){case"log":br==null||br.addLog("log",t());break;case"warn":br==null||br.addLog("warn",t());break;case"error":br==null||br.addLog("error",t());break}}catch(r){console.error("Error in spatial console",r)}finally{Vm.clear()}function t(){let r="";for(let o=0;o<e.length;o++){const a=e[o];r+=i(a),o<e.length-1&&(r+=", ")}return r}function i(r,o=0){if(typeof r=="string")return'"'+r+'"';if(typeof r=="number"){if(r%1!==0){const l=r.toFixed(5),c=l.indexOf(".");let u=l.length-1;for(;u>c&&l[u]==="0";)u--;return l.substring(0,u+1)}return r.toString()}else if(Array.isArray(r)){let a="[";for(let l=0;l<r.length;l++){const c=r[l];a+=i(c,o+1),l<r.length-1&&(a+=", ")}return a+="]",a}else{if(r===null)return"null";if(r===void 0)return"undefined";if(typeof r=="function")return r.name+"()"}if(r instanceof te)return`(${i(r.x)}, ${i(r.y)})`;if(r instanceof w)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)})`;if(r instanceof Ze)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)}, ${i(r.w)})`;if(r instanceof Ce)return`(${i(r.x)}, ${i(r.y)}, ${i(r.z)}, ${i(r.w)})`;if(r instanceof Ot||r instanceof _t)return r.name;if(r instanceof Ut)return`[${r.elements.join(", ")}]`;if(r instanceof we)return`[${r.elements.join(", ")}]`;if(r instanceof sr)return r.mask.toString();if(typeof r=="object"){if(Vm.has(r))return"*";let a=`{
|
|
4341
4341
|
`;a+=n(o);const l=Object.keys(r);let c="";for(let u=0;u<l.length;u++){const d=l[u],f=r[d];if(Vm.has(f)){c+="";continue}Vm.set(f,!0),c+=d+":"+i(f,o+1),u<l.length-1&&(c+=", "),c.length>=60&&(c+=`
|
|
4342
4342
|
`,c+=n(o),a+=c,c="")}return a+=c,a+=`
|
|
4343
|
-
}`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const EY=ne("nodevlogs");function tn(s,e=mo.Log){hl(e,s)}function dn(s){tn(s,mo.Warn)}function QI(s){tn(s,mo.Error)}let G1;function gt(){return EY?!1:G1!==void 0?G1:xo()}function MY(s){G1=s}const QN=ne("debugdefines");$p('if(!globalThis[""3.37.7-beta""]) globalThis[""3.37.7-beta""] = "0.0.0";');$p('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');$p('if(!globalThis[""Mon Apr 29 2024
|
|
4343
|
+
}`,a}return r}function n(r){let o="";for(let a=0;a<r;a++)o+=" ";return o}}const EY=ne("nodevlogs");function tn(s,e=mo.Log){hl(e,s)}function dn(s){tn(s,mo.Warn)}function QI(s){tn(s,mo.Error)}let G1;function gt(){return EY?!1:G1!==void 0?G1:xo()}function MY(s){G1=s}const QN=ne("debugdefines");$p('if(!globalThis[""3.37.7-beta.1""]) globalThis[""3.37.7-beta.1""] = "0.0.0";');$p('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');$p('if(!globalThis[""Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)""] = "unknown";');$p('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.7-beta.1";');$p('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');$p('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)";');const dl="3.37.7-beta.1",aw="undefined",VI="Mon Apr 29 2024 17:15:53 GMT+0200 (Central European Summer Time)";QN&&console.log(`Engine version: ${dl} (generator: ${aw})
|
|
4344
4344
|
Project built at ${VI}`);const Ac="needle_isActiveInHierarchy",Uu="builtin_components",qg="needle_editor_guid";function $p(s){try{(0,eval)(s)}catch(e){QN&&console.error(e)}}const TY='<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>',IY=btoa(TY),RY="data:image/svg+xml;base64,"+IY,PY=RY,BY=`<?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(BY);const DY='<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>',OY=btoa(DY),LY="data:image/svg+xml;charset=utf-8;base64,"+OY,kY=LY,qo=ne("debuglicense");let td="basic";qo&&console.log("License Type: "+td);function Ia(){switch(td){case"pro":case"enterprise":return!0}return!1}function WI(){switch(td){case"indie":return!0}return!1}function Fp(){return Ia()||WI()}const VN=[];function FY(s){if(Ia()||WI())return s(!0);VN.push(s)}function UY(s){for(const e of VN)try{e(s)}catch{}}ri.registerCallback(bn.ContextRegistered,s=>{GY(s.context),QY(),zY(s.context)});let Mh,H1=!1,bg="";async function NY(){if(Mh)return Mh;if(td==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+dl+"&generator="+encodeURIComponent(aw),e=await fetch(s,{method:"GET"}).catch(t=>{qo&&console.error("License check failed",t)});(e==null?void 0:e.status)===200?(H1=!1,qo&&console.log("License check succeeded"),td="pro",UY(!0)):(e==null?void 0:e.status)===403?(H1=!0,bg=await e.text()):qo&&console.log("License check failed with status "+(e==null?void 0:e.status))}catch(s){qo&&console.error("License check failed",s)}else qo&&console.log('Runtime license check is skipped because license is already applied as "'+td+'"')}Mh=NY();async function zY(s){function e(){const n=document.createElement("div");n.className="needle-forbidden",n.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5505,7 +5505,7 @@ Could not find method ${u.method} on object ${f.name}. Please rename ${u.method}
|
|
|
5505
5505
|
in script: `,f),dn("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
|
|
5506
5506
|
Could not find method ${u.method} on object ${f.name}`,f,typeof f[u.method])};if(typeof f[u.method]!="function"){let y=!1,b=f;for(;b;){const M=Object.getOwnPropertyDescriptor(b,u.method);if(M&&(M.writable===!0||M.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(gt()||Ds)&&v()}}let m=u.argument;m!==void 0?m=d(m):u.arguments!==void 0&&(m=u.arguments.map(d));const A=p?this.createEventMethod(f,u.method,m):void 0,g=new Hp(A,u.enabled);if(g.method||(g[Oie]=(o=t.object)==null?void 0:o.name),!f||!g.method){const v=t.object?"Current object: "+t.object.name+", "+t.object.guid:null;f?console.warn('EventList method not found: "'+u.method+'" on',f):console.warn("EventList is missing target - will be ignored",u.target,v,e)}else a.push(g)}const l=new es(a);Ds&&console.log(l);const c=t.target;return c!==void 0&&t.path!==void 0&&l.setEventTarget(t.path,c),l}}createEventMethod(e,t,i){return(...n)=>{const r=e[t];typeof r=="function"?i!==void 0?Array.isArray(i)?r==null||r.call(e,...i):r==null||r.call(e,i):r==null||r.call(e,...n):e[t]=i}}}const kie=new Lie;class aG extends El{constructor(){super([Ph,Yt])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof _t&&t.type===Ph){const i=e,n=new Ph(i.image.width,i.image.height,{colorSpace:yi});return n.texture=i,i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof gl&&(i.isCompressedTexture=!1,i.format=RGBAFormat),n}}}new aG;class lG extends El{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return Tc(t.gltfId,e)}}new lG;var Fie=Object.defineProperty,Uie=Object.getOwnPropertyDescriptor,Nie=(s,e,t,i)=>{for(var n=i>1?void 0:i?Uie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Fie(e,t,n),n};class VA extends Me{awake(){Vr.createIfNoneExists(this.context)}onEnable(){var e;(e=Vr.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Vr.get(this.context))==null||e.unregister(this)}}class So extends VA{constructor(){super(...arguments);h(this,"targets",null);h(this,"raycastHits",[]);h(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(t=null){if(!this.targets)return null;t??(t=new na),t.targets=this.targets,t.results=this.raycastHits;const i=t.testObject;this.ignoreSkinnedMeshes&&(t.testObject=r=>r instanceof yo?"continue in children":i?i(r):!0);const n=this.context.physics.raycast(t);return t.testObject=i,n}}Nie([x()],So.prototype,"ignoreSkinnedMeshes",2);class Tw extends So{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class Yv extends VA{performRaycast(e){if(!St.active||!(e!=null&&e.ray))return null;const t=e.ray.origin,i=.01;return this.context.physics.sphereOverlap(t,i)}}class Iw{static getObject(e){const t=e[Xo];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 i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=wd(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(n==null?void 0:n.isGraphic)===!0&&(t.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=wd(e,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function RR(s){const e=s[Xo];return e||(s.parent?RR(s.parent):null)}function zie(s){return s.isUI===!0||typeof s[Xo]=="object"}function Zb(s,e){if(!s)return;const t=s.material;if((t==null?void 0:t.isMaterial)===!0){const i=s.parent;i&&i.isText,t.side=e.doubleSided??!0?di:Os,t.shadowSide=e.doubleSided?di:Os,s.castShadow=e.castShadows?e.castShadows:!1,s.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of s.children)Zb(i,e)}function Vf(s,e,t){s[e]===void 0&&console.warn("Field",e,"is undefined on",s);const i=Proxy.revocable(s[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),n=i.revoke,r=s[e];return i.revoke=()=>{s[e]=r,n()},s[e]=i.proxy,i}const qO=Symbol("Scheduled action");function Gie(s,e,t=ji.OnBeforeRender){let i=s[qO];i||(i=s[qO]={});const n=e.name;i[t]||(i[t]={});const r=i[t];if(r[n])return;function*a(){e==null||e.call(s),r[n]=null}const l=s.startCoroutine(a(),t);r[n]=l}const ql=ne("debugeventsystem");var kM=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(kM||{});const $a=class extends Me{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",t=>{var r;let i=null;if(zie(t)&&(i=(r=t[Xo])==null?void 0:r.gameObject),this._testObjectsCache.has(t)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let o=LM(t,this._currentPointerEventName);if(!o&&i&&(o=LM(i,this._currentPointerEventName)),o){this._testObjectsCache.set(t,!0);for(const a of t.children)this.shouldRaycastObject_AddToYesCache(a);return!0}return this._testObjectsCache.set(t,!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",[]);$a.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,$a.systems.length<=0&&$a.systems.push(...oe.findObjectsOfType($a,t)));for(const n of $a.systems)if(n.context===t)return;const i=new me;oe.addNewComponent(i,$a),t.scene.add(i)}static get systems(){const t=Lt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,n=!1){vh.update(t,i,n)}static markUIDirty(t){vh.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){$a.systems.splice($a.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!oe.findObjectOfType(VA,this.context)){const i=oe.addNewComponent(this.context.scene,So);this.raycaster.push(i),(gt()||ql)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var n,r;const i=(n=this.raycaster)==null?void 0:n.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(en.PointerDown,this._handleInputFn),this.context.input.addEventListener(en.PointerUp,this._handleInputFn),this.context.input.addEventListener(en.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(en.PointerDown,this._handleInputFn),this.context.input.removeEventListener(en.PointerUp,this._handleInputFn),this.context.input.removeEventListener(en.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0||t.propagationStopped)return;const i=new lm(this.context.input,t);this._currentPointerEventName=t.type,i.inputSource=this.context.input,i.isClick=t.isClick,i.isDoubleClick=t.isDoubleClick,i.isDown=t.type==en.PointerDown,i.isUp=t.type==en.PointerUp,i.isPressed=this.context.input.getPointerPressed(t.pointerId),ql&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new na;t.hasRay?n.ray=t.ray:n.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const r=this.performRaycast(n);if(r)for(const a of r)a.event=t,t.intersections.push(a);ql&&i.isClick&&tn("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const o={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(r,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const i of t.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new na),t.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(t);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(t,i){i?(t.intersection=i,t.point=i.point,t.normal=i.normal,t.face=i.face,t.distance=i.distance,t.instanceId=i.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,i){var r;if(t!=null&&t.length){t=this.sortCandidates(t);for(const o of t){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,o),this.handleEventOnObject(o.object,i))return!0}}this.assignHitInformation(i,t==null?void 0:t[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((r=this.pressedByID.get(i.pointerId))==null||r.handlers.forEach(o=>this.invokeOnPointerUp(i,o)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const n=t[i],r=n.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClick&&ql&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return ql&&console.error("Event without pointer can't be handled",i),!1;i.object=t;const n=t.parent,r=i.isClick??!1;let o=null;if(n&&n.isUI){const d=(i.isPressed||i.isClick)??!1;if(n[Xo]){const f=n[Xo].gameObject;if(f){if(!Iw.isInteractable(f,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,d),t=f}}}r&&ql&&console.log(this.context.time.frame,t);const a=this.hoveredByID.get(i.pointerId),l=a==null?void 0:a.obj;l!==t&&l&&this.propagatePointerExit(l,a.data,t);const u=this.hoveredByID.get(i.pointerId);if(u?(u.obj=t,u.data=i):this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const d=this.pressedByID.get(i.pointerId);d?(d.obj=t,d.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(t,i,l??null),!0}propagate(t,i){for(;t;)oe.foreachComponent(t,n=>{i(n)},!1),t=t.parent}handleMainInteraction(t,i,n){const r=this.pressedByID.get(i.pointerId),o=n!==t;let a=!0;switch(i.event.pointerType){case"mouse":case"touch":const l=this.context.input.getPointerPositionLastFrame(i.pointerId),c=this.context.input.getPointerPosition(i.pointerId);a=l&&!et.approximately(l,c);break}this.propagate(t,l=>{var u;const c=l;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&o&&this.handlePointerEnter(c,i),i.isDown&&c.onPointerDown&&(c.onPointerDown(i),r==null||r.handlers.add(c),this.handlePointerCapture(i,c)),c.onPointerMove&&(a&&c.onPointerMove(i),this.handlePointerCapture(i,c)),i.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(i,c),r==null||r.handlers.delete(c)),c.onPointerExit&&((u=i.event)==null?void 0:u.pointerType)===vw.Touch&&(this.handlePointerExit(c,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&c.onPointerClick&&c.onPointerClick(i)))}),i.isUp&&(r==null||r.handlers.forEach(l=>{this.invokeOnPointerUp(i,l)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(t,i,n){this.propagate(t,r=>{if(!r.gameObject||r.destroyed)return;const o=r;if(o.onPointerExit){if(n&&this.isChild(n,r.gameObject))return;this.handlePointerExit(o,i)}})}invokeOnPointerUp(t,i){var n;(n=i.onPointerUp)==null||n.call(i,t),this.releasePointerCapture(t,i)}handlePointerEnter(t,i){t.onPointerEnter&&this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(i),this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,i){t.onPointerExit&&this.updatePointerState(t,i.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(i),this.updatePointerState(t,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,i,n,r){let o=t[n];if(r)return o&&o.includes(i)?!1:(o=o||[],o.push(i),t[n]=o,!0);{if(!o||!o.includes(i))return!1;const a=o.indexOf(i);return a!==-1&&o.splice(a,1),!0}}handlePointerCapture(t,i){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const n=t.pointerId;if(i.onPointerMove){const r=this._capturedPointer[n]||[];r.push(i),this._capturedPointer[n]=r}else gt()&&!i.z__warned_no_pointermove&&(i.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,i))}releasePointerCapture(t,i){const n=t.pointerId;if(this._capturedPointer[n]){const r=this._capturedPointer[n].indexOf(i);r!==-1&&(this._capturedPointer[n].splice(r,1),ql&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(t){var i;if(t.event.type===en.PointerMove){const n=t.pointerId,r=this._capturedPointer[n];if(r){ql&&console.log("Captured",n,r);for(let o=0;o<r.length;o++){const a=r[o];if(a.destroyed){r.splice(o,1),o--;continue}(i=a.onPointerMove)==null||i.call(a,t)}}}}isChild(t,i){return!t||!i?!1:t===i?!0:t.parent?this.isChild(t.parent,i):!1}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const n=vh.updateState(t,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&vh.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];vh.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?oe.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let Vr=$a;h(Vr,"_eventSystemMap",new Map),h(Vr,"didSearchEventSystem",!1);class vh{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const n=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(n===r.frame)return;r.frame=n;let o=this.needsUpdate||n<1;r.nextUpdate===t.time.frameCount&&(o=!0),o&&(ql&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:n,nextUpdate:n}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}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(vh,"lastSelected",null),h(vh,"lastUpdateFrame",[]),h(vh,"needsUpdate",!1);var Hie=Object.defineProperty,Qie=Object.getOwnPropertyDescriptor,Cn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Qie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Hie(e,t,n),n};const Vie=ne("debugorbit"),q0=ne("freecam"),sg=ne("debugcamerafit"),X0=ne("smoothcam"),Wie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let ZC;class Jv extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class Ci extends Me{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 w);h(this,"_lookTargetEndPosition",new w);h(this,"_lookTargetLerp01",0);h(this,"_lookTargetLerpDuration",0);h(this,"_cameraLerpActive",!1);h(this,"_cameraStartPosition",new w);h(this,"_cameraEndPosition",new w);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(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}get targetLerpSpeed(){return 5}set targetLerpSpeed(t){this.targetLerpDuration=1/t}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Vr.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(kM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(kM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=oe.getComponent(this.gameObject,zi);this._camera=t;let i=t==null?void 0:t.cam;if(!i&&this.gameObject instanceof Gt&&(i=this.gameObject),i&&PM(i,this,!0),!this._controls&&i instanceof Gt){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new gie(i,n),i==null||i.quaternion.copy(r),ZC===void 0&&(ZC={...this._controls.keys})}this._controls&&(q0&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Mo()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?q0||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):q0||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=oe.getComponent(this.gameObject,Gh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&PM(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n;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)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.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 t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t&&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 Jv(this,"camera"));else{const r=et.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 Jv(this,"lookat"));else{const r=et.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?ZC:Wie,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 X0=="number"||X0===!0){this._controls.enableDamping=!0;const r=typeof X0=="number"?X0:.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||(!q0&&((n=this.lookAtConstraint)!=null&&n.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),Vie&&bt.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const t=oe.getComponent(this.gameObject,zi);if(t&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const n=Nt(t.cam).length(),r=new w(0,0,-n).applyMatrix4(t.cam.matrixWorld);this.setLookTargetPosition(r,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const i=new na;i.screenPoint=new te(0,0),i.lineThreshold=.1;const n=this.context.physics.raycast(i);n.length>0&&this.setLookTargetPosition(n[0].point,!0),sg&&console.log("OrbitControls hits",...n)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(t){if(!t||!(t instanceof me))return;const i=Nt(t),n=NI(t);this.setTargetFromRaycast(new qr(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(t,i=!1){var n,r;t&&(t instanceof me&&(t=Nt(t)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(t),i===!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 i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(t=null,i=!1){this._controls&&t&&(t instanceof me&&(t=Nt(t)),this._lookTargetEndPosition.copy(t),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(t=0,i=1){var r;if(!this._controls)return!1;const n=(r=this.lookAtConstraint)==null?void 0:r.sources;if(n&&n.length>0){const o=n[t];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(t,i){return this.lerpLookTarget(t,i)}lerpLookTarget(t,i){this._controls&&(i>=1?this._controls.target.copy(t):this._controls.target.lerp(t,i))}setTargetFromRaycast(t){if(!this.controls)return;const i=t?this.context.physics.raycastFromRay(t):this.context.physics.raycast();for(const n of i)if(n.distance>0&&oe.isActiveInHierarchy(n.object)){const r=RR(n.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(t,i=void 0,n=!0){if(this.context.isInXR)return;i==null&&(i=1.1);const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0){console.warn("No objects to fit camera to...");return}if(!r||!o){console.warn("No camera or controls found to fit camera to objects...");return}const a=new w,l=new w,c=new Ai;c.makeEmpty();const u=[];function d(E){let T=!0;if(E.visible&&tG(E)!==!1&&!(E.type==="TransformControlsGizmo"||E.type==="TransformControlsPlane")&&(E instanceof R1&&(T=!1),E instanceof ew&&(T=!1),E instanceof $4&&(T=!1),E.material instanceof Wx&&(T=!1),E instanceof de||(T=!1),E!==r&&E.isUI!==!0)){if(T){sg&&console.log(E.name,E.type,E);const C=E.children;E.children=u;const P=E.position,S=E.scale;if(Number.isNaN(P.x)||Number.isNaN(P.y)||Number.isNaN(P.z)){console.warn(`Object "${E.name}" has NaN values in position or scale.... will ignore it`,P,S);return}c.expandByObject(E,!0),E.children=C}for(const C of E.children)d(C)}}let f=!1;for(const E of t)E&&(f=!0,E.updateMatrixWorld(),d(E));if(!f){console.warn("No objects to fit camera to...");return}if(r.updateMatrixWorld(),r.updateProjectionMatrix(),c.getCenter(l),c.applyMatrix4(r.matrixWorldInverse),c.getSize(a),c.setFromCenterAndSize(l,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",r,c,[...t]);return}if(a.length()<=1e-10){sg&&console.warn("Camera fit size is zero",c,[...t]);return}const p=r.fov,m=2*Math.atan(Math.tan(p*Math.PI/360/2)*r.aspect)/Math.PI*360,A=a.y/(2*Math.atan(Math.PI*p/360)),g=a.x/(2*Math.atan(Math.PI*m/360)),v=i*Math.max(A,g)+a.z/2;sg&&console.log("Fit camera to objects",A,g,"distance",v),o.maxDistance=v*10,o.minDistance=v*.01;const _=.05,y=l.clone();y.y-=a.y*_,this.setLookTargetPosition(y,n),this.autoTarget=!1,r.near=v/1e3,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix();const b=Nt(r),M=l.clone();if(M.sub(b),M.y=0,M.normalize(),M.multiplyScalar(v),M.y+=-_*4*a.y,r.parent){const E=r.parent.worldToLocal(l.clone().sub(M));this.setCameraTargetPosition(E,n)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(sg){const E=new R1(c);this.context.scene.add(E),HI(E,MA(r)),setTimeout(()=>{this.context.scene.remove(E)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",T=>{T.code==="KeyF"&&this.fitCamera(t,i,n)}))}o.update()}}Cn([x()],Ci.prototype,"autoTarget",2);Cn([x()],Ci.prototype,"autoFit",2);Cn([x()],Ci.prototype,"enableRotate",2);Cn([x()],Ci.prototype,"autoRotate",2);Cn([x()],Ci.prototype,"autoRotateSpeed",2);Cn([x()],Ci.prototype,"minAzimuthAngle",2);Cn([x()],Ci.prototype,"maxAzimuthAngle",2);Cn([x()],Ci.prototype,"minPolarAngle",2);Cn([x()],Ci.prototype,"maxPolarAngle",2);Cn([x()],Ci.prototype,"enableKeys",2);Cn([x()],Ci.prototype,"enableDamping",2);Cn([x()],Ci.prototype,"dampingFactor",2);Cn([x()],Ci.prototype,"enableZoom",2);Cn([x()],Ci.prototype,"minZoom",2);Cn([x()],Ci.prototype,"maxZoom",2);Cn([x()],Ci.prototype,"enablePan",2);Cn([x(Ld)],Ci.prototype,"lookAtConstraint",2);Cn([x()],Ci.prototype,"lookAtConstraint01",2);Cn([x()],Ci.prototype,"allowInterrupt",2);Cn([x()],Ci.prototype,"middleClickToFocus",2);Cn([x()],Ci.prototype,"doubleClickToFocus",2);Cn([x()],Ci.prototype,"targetLerpDuration",2);var jie=Object.defineProperty,qie=Object.getOwnPropertyDescriptor,Xr=(s,e,t,i)=>{for(var n=i>1?void 0:i?qie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&jie(e,t,n),n},Sd=(s=>(s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(Sd||{});const $l=ne("debugcam"),XO=ne("debugscreenpointtoray");var x_;const Bg=(x_=class extends Me{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 we)}get isCamera(){return!0}get aspect(){return this._cam instanceof Gt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(e){this._cam instanceof Gt&&this._cam.aspect!==e&&(this._cam.aspect=e,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Gt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof Gt){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(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(e){this.cullingMask=(1<<e|0)>>>0}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const n=this.cam,r=Bg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),XO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(n);const o=Bg._direction.set(r.x,r.y,r.z),a=Nt(n);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new qr(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new md,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new md),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(e,t){return t&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),e===this._projScreenMatrix?e:e.copy(this._projScreenMatrix)}awake(){XO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);bt.DrawRay(n.origin,n.direction,r,10)})}onEnable(){$l&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Sd[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Yie(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 e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof Gt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof Gt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new Gt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Ec(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){$l&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,$l){const e=`Camera "${this.name}" clear flags: ${Sd[this._clearFlags]}`;console.debug(e)}switch(this._clearFlags){case 1:if(Bg.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:$l&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:$l&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Bg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else $l&&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 Xie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,l;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;if(typeof t._transparent=="boolean")return t._transparent;const i=t.environmentBlendMode;$l&&tn("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return e.isInAR&&i==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((l=navigator.userAgent)!=null&&l.includes("Mobile WebXRViewer/v2")))&&(n=!0),t._transparent=n,n}},h(x_,"_origin",new w),h(x_,"_direction",new w),x_);let zi=Bg;Xr([x()],zi.prototype,"aspect",1);Xr([x()],zi.prototype,"fieldOfView",1);Xr([x()],zi.prototype,"nearClipPlane",1);Xr([x()],zi.prototype,"farClipPlane",1);Xr([x()],zi.prototype,"clearFlags",1);Xr([x()],zi.prototype,"orthographic",2);Xr([x()],zi.prototype,"orthographicSize",2);Xr([x()],zi.prototype,"ARBackgroundAlpha",2);Xr([x()],zi.prototype,"cullingMask",1);Xr([x()],zi.prototype,"backgroundBlurriness",1);Xr([x()],zi.prototype,"backgroundIntensity",1);Xr([x()],zi.prototype,"environmentIntensity",1);Xr([x(wi)],zi.prototype,"backgroundColor",1);Xr([x(Ph)],zi.prototype,"targetTexture",1);class Xie{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&&($l&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Ko,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),($l||gt())&&dn(`Camera "${this._camera.name}" has no skybox texture`))}}function Yie(s){ne("freecam")&&s.context.mainCameraComponent===s&&oe.getOrAddComponent(s.gameObject,Ci)}class Bh extends Me{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new MU),this._listener}awake(){fn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||oe.getComponentInParent(this.gameObject,zi);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Jie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,Rw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Kie(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Jie(e,t,n),n};const Zie=ne("debugsignals");class WA{constructor(){h(this,"guid")}}Rw([x()],WA.prototype,"guid",2);class cm{constructor(){h(this,"signal");h(this,"reaction")}}Rw([x(WA)],cm.prototype,"signal",2);Rw([x(es)],cm.prototype,"reaction",2);var UE;const Xl=(UE=class extends Me{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(Xl.receivers[e]){const t=Xl.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Zie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Xl.receivers[e.signal.guid]||(Xl.receivers[e.signal.guid]=[]),Xl.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Xl.receivers[e.signal.guid]){const t=Xl.receivers[e.signal.guid].indexOf(this);t>=0&&Xl.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(n){console.error(n)}}},h(UE,"receivers",{}),UE);let hm=Xl;Rw([x(cm)],hm.prototype,"events",2);var ro=(s=>(s.Activation="ActivationTrack",s.Animation="AnimationTrack",s.Audio="AudioTrack",s.Control="ControlTrack",s.Marker="MarkerTrack",s.Signal="SignalTrack",s))(ro||{}),Za=(s=>(s[s.None=0]="None",s[s.Hold=1]="Hold",s[s.Loop=2]="Loop",s[s.PingPong=3]="PingPong",s[s.Continue=4]="Continue",s))(Za||{}),PR=(s=>(s.Signal="SignalEmitter",s))(PR||{});const fl=ne("debugtimeline");class jA{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 i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,n=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(n||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const l=Math.min((e-r.start)/r.easeInDuration,1);o*=l}if(r.easeOutDuration>0&&!a){const l=Math.min((r.end-e)/r.easeOutDuration,1);o*=l}return o}return 0}}class $ie{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 i=e.getRoot(),n=i.name+".position",r=i.name+".quaternion";fl&&console.log(t.name,t.tracks,n);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(n))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),fl&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Ce().fromArray(o.values,0),this.rootEndQuaternion=new Ce().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),fl)){const a=new Wi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Pw extends jA{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 w);h(this,"_totalOffsetRotation",new Ce);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new Ce);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new Ce);h(this,"_tempRot",new Ce);h(this,"_clipRotQuat",new Ce)}onDisable(){var t;(t=this.mixer)==null||t.stopAllAction()}onStateChanged(){this._animator&&YO(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.length)<=0){console.warn("No tracks in AnimationClip",i);return}const n=i.tracks[0].name.split("."),r=n[n.length-2],o=r+".position",a=r+".quaternion";let l=!1,c=!1;for(const f of i.tracks)f.name.endsWith(o)?(l=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(c=!0,this.createRotationInterpolant(i,t,f));if(!l||!c){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],m=p.name.lastIndexOf("."),A=p.name.substring(0,m),g=A.substring(A.lastIndexOf(".")+1),v=f.getObjectByName(g);if(v)if(l){if(!c){const _=i.tracks[0].name.substring(0,m)+".quaternion";fl&&console.warn("Create quaternion track",g,v);const y=v.quaternion,b=new wl(_,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(b),this.createRotationInterpolant(i,t,b)}}else{const _=A+".position";fl&&console.warn("Create position track",g,v);const y=v.position,b=new wc(_,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(b),this.createPositionInterpolant(i,t,b)}}}bind(){if(!this._didBind){this._didBind=!0,fl&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new $ie(t);this._actionOffsets.push(i)}this.target&&(this._animator=oe.getComponent(this.target,ks)??null,this._animator&&YO(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,n=i.position,r=i.rotation;n&&n.x!==void 0&&(n.isVector3||(i.position=new w(n.x,n.y,n.z)),r.isQuaternion||(i.rotation=new Ce(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Ce(i.x,i.y,i.z,i.w)))}}evaluate(t){var l,c,u,d,f,p,m;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 i=0,n=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const g=this.models[A],v=this.actions[A],_=g.asset;v.weight=0;const y=t>=g.start&&t<=g.end,b=g.preExtrapolationMode,M=g.postExtrapolationMode,E=A<this.clips.length-1?this.models[A+1]:null;let T=y,C=!1;if(!T&&!r&&g.end<t&&M!==Za.None?(!E||E.start>t)&&(T=!0,r=!0):A==0&&!T&&!o&&g.start>t&&b!==Za.None&&(!E||E.start<t)&&(T=!0,C=!0,o=!0),T){let P=1;P*=this.evaluateWeight(t,A,this.models,T),P*=this.director.weight;let S=y;if(C)switch(b){case Za.Hold:break;case Za.Loop:t+=g.start,S=!0;break;default:t+=g.start,S=!0;break}let I=this.getClipTime(t,g),H=0;const U=_.duration;if(C&&b===Za.Hold&&(I=0),S){if(_.loop)for(H+=Math.floor(I/(U+1e-6));I>U;)I-=U}else if(!y&&r)switch(M){case Za.Hold:I=this.getClipTime(g.end,g);break;case Za.Loop:I%=U;break;case Za.PingPong:const L=Math.floor(I/U)%2!==0;I%=U,L&&(I=U-I);break}g.reversed===!0?v.time=v.getClip().duration-I:v.time=I,v.timeScale=0;const D=Math.max(0,P);if(v.weight=D,a+=D,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const V=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,L=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(n=1-P),i+=1;const k=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),K=this._tempRot.identity(),re=_.rotation;re&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(re,P));const ce=this._actionOffsets[A];if(ce.hasOffsets)for(let Re=0;Re<H;Re++)ce.rootPositionOffset?G.copy(ce.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(Y),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ce.rootQuaternionOffset&&(K.copy(ce.rootQuaternionOffset),Y.multiply(K)),k.add(G);this._clipRotQuat&&L.multiply(this._clipRotQuat),L.multiply(Y),_.position&&k.add(_.position),V.add(k)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,n),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,n)),this.__mixerError===void 0&&(fl||gt())&&((c=(l=this._animator)==null?void 0:l.runtimeAnimatorController)!=null&&c.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.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)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(m=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||m.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,n){var l;const r=n.createInterpolant.bind(n),o=new Ce;this.ensureTrackOffsets();const a=(l=this.trackOffset)==null?void 0:l.rotation;n.createInterpolant=()=>{const c=r(),u=c.evaluate.bind(c);return c.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)(p=m==null?void 0:m.onTimelineRotation)==null||p.call(m,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},c}}createPositionInterpolant(t,i,n){var u,d;const r=n.createInterpolant.bind(n),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,l=(d=this.trackOffset)==null?void 0:d.position;let c;n.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=m=>{var g,v,_;const A=p(m);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(c===void 0?(c=null,c=(v=(g=this._actionOffsets.find(y=>y.clip===t))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):c!=null&&c.isVector3&&o.sub(c)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),l&&(o.x-=l.x,o.y+=l.y,o.z+=l.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(_=y==null?void 0:y.onTimelinePosition)==null||_.call(y,this.director,this.target,m,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const ene=ne("mutetimeline"),dp=class extends jA{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(t){const i=this.director.sourceId;return Tc(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const n=this.models[i];this.audio[i].setVolume(t?n.asset.volume:0)}}addModel(t){const i=new tI(this.listener);this.audio.push(i);const n=t;n._didTriggerPlay=!1,this.models.push(n)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop();for(const t of this.models)t._didTriggerPlay=!1}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}for(const t of this.models)t._didTriggerPlay=!1}onPauseChanged(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(t){if(ene||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,n=this._playableDirectorResumed;this._playableDirectorResumed=!1;const r=i?.1:0;for(let o=0;o<this.models.length;o++){const a=this.models[o],l=this.audio[o],c=a.asset;if((!l||!l.buffer)&&this.isInTimeRange(a,t-1,t+1)&&this.handleAudioLoading(a,l),fn.userInteractionRegistered!==!1&&!(l===null||!l.buffer))if(l.playbackRate=this.director.context.time.timeScale*this.director.speed,l.loop=c.loop,t>=a.start&&t<=a.end&&t<this.director.duration){if(!l.isPlaying||!this.director.isPlaying)(n||!a._didTriggerPlay&&this.lastTime<t)&&(a.duration*a.timeScale>.3?l.offset=a.clipIn+(t-a.start)*a.timeScale:l.offset=0,fl&&console.log("Timeline Audio ("+this.track.name+") play with offset "+l.offset+" - "+a.asset.clip),l.play(r),a._didTriggerPlay=!0);else{const d=a.clipIn+(t-a.start)*a.timeScale,f=l.context.currentTime-l._startedAt+l.offset;Math.abs(d-f)>.3&&(l.offset=d,l.stop(),l.play(r))}let u=c.volume;if(this.track.volume!==void 0&&(u*=this.track.volume),i&&(u=0),a.easeInDuration>0){const d=Math.min((t-a.start)/a.easeInDuration,1);u*=d}if(a.easeOutDuration>0){const d=Math.min((a.end-t)/a.easeOutDuration,1);u*=d}l.setVolume(u*this.director.weight)}else a._didTriggerPlay=!1,this.director.isPlaying&&l.isPlaying&&l.stop()}this.lastTime=t}loadAudio(t,i=0,n=0){let r=null;const o=t-n,a=t+i;for(const l of this.models)if(this.isInTimeRange(l,o,a)){const c=this.audio[this.models.indexOf(l)],u=this.handleAudioLoading(l,c);u!==null&&(r===null&&(r=[]),r.push(u))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,n){return i<=t.start&&n>=t.end||i>=t.start&&i<=t.end||n>=t.start&&n<=t.end}static dispose(){dp._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new Sb);const n=this.getAudioFilePath(t.asset.clip);if(dp._audioBuffers.get(n)){const o=dp._audioBuffers.get(n);return o.then(a=>{a&&i.setBuffer(a)}),o}fl&&console.warn("LOAD audio track",n,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(n,l=>{i.setBuffer(l),o(l)},void 0,l=>{console.error("Error loading audio",l),o(null)})});return dp._audioBuffers.set(n,r),r}};let od=dp;h(od,"_audioBuffers",new Map);class Kv extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(this,"receivers",[])}evaluate(t){var n;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-t;let c=!1;if(o.retroActive)c=l<=1e-6;else{const u=Math.abs(l);(u===0||u>=1e-5&&u<i)&&(c=!0)}if(c){if(!a)if(fl&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((n=this.receivers)==null?void 0:n.length)<=0)hm.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class Bw extends jA{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=oe.getComponent(r.sourceObject,bc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let n=0;n<this.models.length;n++){const r=this.models[n],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[n];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;(a==null?void 0:a.sourceObject)!==l&&(l.visible=!1)}}}}}const Df=ne("debugtimeline"),dx=class extends Me{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(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Df||xo())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,n;Df&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((n=this.playableAsset)==null?void 0:n.tracks),this)}onEnable(){var t,i,n;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(n=r.onEnable)==null||n.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,n;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(n=r.onDisable)==null||n.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const n of i)(t=n.onDestroy)==null||t.call(n)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,t&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const i=[];for(const n of this._audioTracks){const r=n.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!fn.userInteractionRegistered&&this.waitForAudio;)await Pa(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),ji.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const n of this._audioTracks)n.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}const n=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case ro.Activation:if(!t&&!this._isPlaying)continue;for(let o=0;o<r.outputs.length;o++){const a=r.outputs[o];if(typeof a=="object"){let l=!1;if(r.clips)for(const u of r.clips)u.start<=n&&n<=u.end&&(l=!0);const c=a;c.visible!==void 0&&c.visible!==l&&(c.visible=l,Df&&console.warn(this.name,"set ActivationTrack-"+o,c.name,l,n))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(n);for(const r of this._audioTracks)r.evaluate(n);for(const r of this._signalTracks)r.evaluate(n);for(const r of this._controlTracks)r.evaluate(n);for(const r of this._customTracks)r.evaluate(n)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=xA(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let n=i.outputs.length-1;n>=0;n--){let r=i.outputs[n];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=oe.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(n,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Df&&console.log("Resolved binding",r,"to",o),i.outputs[n]=o)}else if(r===null){if(i.outputs.splice(n,1),dx.createTrackFunctions[i.type])continue;i.type!==ro.Audio&&i.type!==ro.Control&&i.type!==ro.Marker&&i.type!==ro.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===ro.Control&&i.clips)for(let n=0;n<i.clips.length;n++){const r=i.clips[n];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=oe.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Df&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,n,r;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let t=oe.findObjectOfType(Bh,this.context);for(const o of this.playableAsset.tracks){const a=o.type,l=dx.createTrackFunctions[a];if(l!=null){const c=l(this,o);if(typeof c.evaluate=="function"){c.director=this,c.track=o,this._customTracks.push(c);continue}}if(o.type===ro.Animation){if(!o.clips||o.clips.length<=0){Df&&console.warn("Animation track has no clips",o);continue}for(let c=o.outputs.length-1;c>=0;c--){let u=o.outputs[c];if(u instanceof me){const f=oe.getOrAddComponent(u,ks);f&&(u=f)}const d=(i=u==null?void 0:u.gameObject)==null?void 0:i.animations;if(d){const f=new Pw;f.trackOffset=o.trackOffset,f.director=this,f.track=o;for(let p=0;p<o.clips.length;p++){const m=o.clips[p],A=m.asset;if(!A){console.error(`Timeline ${this.name}: clip #${p} on track "${o.name}" has no animation data`);continue}const g=A.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=d.find(y=>y.name===g)),!v){console.warn("Could not find animationClip for model",m,o.name,this.name,(n=this.playableAsset)==null?void 0:n.name);continue}u instanceof ks&&u.runtimeAnimatorController&&(u.__internalDidAwakeAndStart||u.initializeRuntimeAnimatorController(),u.runtimeAnimatorController.mixer||u.runtimeAnimatorController.bind(u),f.mixer=u.runtimeAnimatorController.mixer),f.mixer||(f.mixer=new $x(u.gameObject)),f.clips.push(v),f.mixer.uncacheAction(v),f.createHooks(m.asset,v);const _=f.mixer.clipAction(v);f.actions.push(_),f.models.push(m)}this._animationTracks.push(f)}}}else if(o.type===ro.Audio){if(!o.clips||o.clips.length<=0)continue;const c=new od;c.director=this,c.track=o,c.audioSource=o.outputs.find(u=>u instanceof fn),this._audioTracks.push(c),t||(t=(r=this.context.mainCameraComponent)==null?void 0:r.gameObject.addNewComponent(Bh)),c.listener=t.listener;for(let u=0;u<o.clips.length;u++){const d=o.clips[u];c.addModel(d)}}else if(o.type===ro.Marker){const c=new Kv;if(c.director=this,c.track=o,o.markers)for(const u of o.markers)switch(u.type){case PR.Signal:c.models.push(u),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const u=oe.getComponent(this.gameObject,hm);u&&(c.receivers.push(u),this._signalTracks.push(c))}}else if(o.type===ro.Signal){const c=new Kv;if(c.director=this,c.track=o,o.markers)for(const u of o.markers)c.models.push(u),c.didTrigger.push(!1);for(const u of o.outputs)c.receivers.push(u);this._signalTracks.push(c)}else if(o.type===ro.Control){const c=new Bw;if(c.director=this,c.track=o,o.clips)for(const u of o.clips)c.models.push(u);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let bc=dx;h(bc,"createTrackFunctions",{});const eb=Symbol("objectIsAnimatedData");function YO(s,e,t){if(!s)return;if(s[eb]===void 0){if(!t)return;s[eb]=new Set}const i=s[eb];t?i.add(e):i.has(e)&&i.delete(e)}function tne(s){if(!s)return!1;const e=s[eb];return e!==void 0&&e.size>0}ri.registerCallback(bn.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&s.files)for(const t of s.files)oe.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof Dr&&n.playAutomatically||n instanceof ks||n instanceof bc&&n.playOnAwake===!0)return!0;if(n instanceof Dr)return n.playAutomatically=!0,!0;if(n instanceof bc)return n.playOnAwake=!0,!0}},!0)!==!0&&ine(t.file)});function ine(s){if(!s||!s.animations)return;for(let t=0;t<s.animations.length;t++){const i=s.animations[t];if(!(!i.tracks||i.tracks.length<=0))for(const n in i.tracks){const r=i.tracks[n],o=r.__objectName??r.name.substring(0,r.name.indexOf("."));let a=s.scene.getObjectByName(o);if(!a&&(a=s.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=Rh(s.scene,new Dr));const c=l.animations=l.animations||[];i.name_animator=l.name,c.indexOf(i)<0&&c.push(i)}}function e(t){var n;if(!t)return;const i=(n=t.userData)==null?void 0:n.components;if(i&&i.length>0)for(let r=0;r<i.length;r++){const o=i[r];if(o instanceof ks||o instanceof Dr)return t}return e(t.parent)}}class nne{constructor(){h(this,"_context")}get context(){return this._context??Lt.Current}get isStateMachineBehaviour(){return!0}}class Dg{constructor(e,t,i,n){h(this,"name");h(this,"nameHash");h(this,"normalizedTime");h(this,"length");h(this,"speed");h(this,"action");h(this,"hasTransitions");var r;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=i,this.speed=n,this.action=e.motion.action||null,this.hasTransitions=((r=e.transitions)==null?void 0:r.length)>0||!1}}function cG(s,e){return{name:"",isLooping:!1,guid:(e==null?void 0:e.generateUUID())??Zn.generateUUID(),index:-1,clip:new Pr(s,1,[])}}var fh=(s=>(s[s.If=1]="If",s[s.IfNot=2]="IfNot",s[s.Greater=3]="Greater",s[s.Less=4]="Less",s[s.Equals=6]="Equals",s[s.NotEqual=7]="NotEqual",s))(fh||{}),BR=(s=>(s[s.Float=1]="Float",s[s.Int=3]="Int",s[s.Bool=4]="Bool",s[s.Trigger=9]="Trigger",s))(BR||{});const vr=ne("debuganimatorcontroller"),Y0=ne("debugrootmotion");class bo{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,vr&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(t.autoTransition!==!1){const u=t.transitionDuration??0,d=u/a.duration;let f=o;(t.autoTransition===void 0||t.autoTransition===!0)&&(f=(o+1)%e.length),l.push({exitTime:1-d,offset:0,duration:u,hasExitTime:!0,destinationState:f,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:(t==null?void 0:t.looping)??!1},transitions:l,behaviours:[]};i.push(c)}const n={name:"AnimatorController",guid:new fs(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new bo(n)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[t].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){vr&&console.log("transition to ",a),this.transitionTo(a,n,i);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var n,r;const i=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[i]===e).forEach(o=>o.value=t)}getBool(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??!1}setFloat(e,t){var r,o;const i=typeof e=="string"?"name":"hash",n=(o=(r=this.model)==null?void 0:r.parameters)==null?void 0:o.filter(a=>a[i]===e);return n.forEach(a=>a.value=t),(n==null?void 0:n.length)>0}getFloat(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??0}setInteger(e,t){var n,r;const i=typeof e=="string"?"name":"hash";return(r=(n=this.model)==null?void 0:n.parameters)==null?void 0:r.filter(o=>o[i]===e).forEach(o=>o.value=t)}getInteger(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===e))==null?void 0:r.value)??0}setTrigger(e){var i,n;vr&&console.log("SET TRIGGER",e);const t=typeof e=="string"?"name":"hash";return(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.filter(r=>r[t]===e).forEach(r=>r.value=!0)}resetTrigger(e){var i,n;const t=typeof e=="string"?"name":"hash";return(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.filter(r=>r[t]===e).forEach(r=>r.value=!1)}getTrigger(e){var i,n,r;const t=typeof e=="string"?"name":"hash";return((r=(n=(i=this.model)==null?void 0:i.parameters)==null?void 0:n.find(o=>o[t]===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 i of t.stateMachine.states)if(i.name===e||i.hash==e)return i}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,i=t<=0?0:Math.abs(e.time/t);return new Dg(this._activeState,i,t,this._speed)}get currentAction(){if(!this._activeState)return null;const e=this._activeState.motion.action;return e||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 $x(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;vr&&console.warn("AnimatorController clone()",this.model);const e=xA(this.model,(i,n,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||zN(r)||r.tracks!==void 0||r instanceof bo));return console.assert(e!==this.model),new bo(e)}update(e){var i,n;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const t=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onBeforeUpdate(e)),this._mixer.update(t),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 i=this._activeStates[t],n=i.motion;if(!n.action)this._activeStates.splice(t,1),t--;else{const r=n.action;r.weight=e,r.getEffectiveWeight()<=0&&!r.isRunning()&&(vr&&console.debug("REMOVE",i.name,r.getEffectiveWeight(),r.isRunning(),r.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(vr&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const i=t.states[t.defaultState];this.transitionTo(i,0,this.normalizedStartOffset)}}evaluateTransitions(){var r;let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const t=this._activeState,i=t.motion.action;for(const o of t.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(i){const l=t.motion.clip.duration,c=l<=0?1:Math.abs(i.time/l);let u=!1;if(o.hasExitTime?i.timeScale>0?u=c>=o.exitTime:i.timeScale<0&&(u=1-c>=o.exitTime):u=!0,u){for(const d of o.conditions){const f=this.model.parameters.find(p=>p.name===d.parameter);(f==null?void 0:f.type)===BR.Trigger&&f.value&&(f.value=!1)}i.clampWhenFinished=!0,vr&&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(i){let o=t.speed??1;t.speedParameter&&(o*=this.getFloat(t.speedParameter)),o!==void 0&&(i.timeScale=o*this._speed)}let n=!1;if(t.motion.isLooping&&i&&(i.time>=i.getClip().duration?(n=!0,i.reset(),i.time=0,i.play()):i.time<=0&&i.timeScale<0&&(n=!0,i.reset(),i.time=i.getClip().duration,i.play())),!n&&t&&!e&&i&&this.animator&&t.behaviours){const o=i==null?void 0:i.getClip().duration,a=i.time/o,l=new Dg(this._activeState,a,o,this._speed);for(const c of t.behaviours)c.instance&&((r=c.instance.onStateUpdate)==null||r.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&&(vr&&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,i){var c,u,d,f,p,m,A,g;if(!this.animator)return;const n=0;if(e=this.getState(e,n),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof Pr))return;const r=this._activeState===e;if(r){const v=e.motion;if(!v.action_loopback&&v.clip){const _=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(v.clip,this.animator.gameObject),_&&_.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),v.action_loopback=this.createAction(v.clip)}}if((c=this._activeState)!=null&&c.behaviours&&this._activeState.motion.action){const v=(u=this._activeState)==null?void 0:u.motion.clip.duration,_=this._activeState.motion.action.time/v,y=new Dg(this._activeState,_,v,this._speed);for(const b of this._activeState.behaviours)(f=(d=b.instance)==null?void 0:d.onStateExit)==null||f.call(b.instance,this.animator,y,n)}const o=(p=this._activeState)==null?void 0:p.motion.action;o&&o.fadeOut(t),r&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=o);const a=this._activeState;this._activeState=e;const l=(m=e.motion)==null?void 0:m.action;if(l){if(i=Math.max(0,Math.min(1,i)),e.cycleOffsetParameter){let _=this.getFloat(e.cycleOffsetParameter);typeof _=="number"?(_<0&&(_+=1),i+=_,i%=1):vr&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(i+=e.cycleOffset,i%=1);l.isRunning()&&l.stop(),l.reset(),l.enabled=!0;const v=e.motion.clip.duration;if(l.time=r?0:i*v,l.timeScale<0&&(l.time=v-l.time),l.clampWhenFinished=!0,l.setLoop(bv,0),t>0?l.fadeIn(t):l.weight=1,l.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(l),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const _=new Dg(e,i,v,this._speed);for(const y of this._activeState.behaviours)(g=(A=y.instance)==null?void 0:A.onStateEnter)==null||g.call(y.instance,this.animator,_,n)}}else vr&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));vr&&console.log("TRANSITION FROM "+(a==null?void 0:a.name)+" TO "+e.name,t,o,l,l==null?void 0:l.getEffectiveTimeScale(),l==null?void 0:l.getEffectiveWeight(),l==null?void 0:l.isRunning(),l==null?void 0:l.isScheduled(),l==null?void 0:l.paused)}createAction(e){var i,n;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(i=this.animator)==null?void 0:i.gameObject),(n=this.animator)!=null&&n.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new sne(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(i=>i.name===e.parameter);if(!t)return!1;switch(e.mode){case fh.If:return t.value===!0;case fh.IfNot:return t.value===!1;case fh.Greater:return t.value>e.threshold;case fh.Less:return t.value<e.threshold;case fh.Equals:return t.value===e.threshold;case fh.NotEqual:return t.value!==e.threshold}return!1}createActions(e){var t,i,n,r;vr&&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=cG(c.name)),this.animator&&c.motion.clips){const u=(t=c.motion.clips)==null?void 0:t.find(d=>{var f,p;return d.node.name===((p=(f=this.animator)==null?void 0:f.gameObject)==null?void 0:p.name)});u?c.motion.clip=u.clip:(vr||gt())&&console.warn('Could not find clip for animator "'+((n=(i=this.animator)==null?void 0:i.gameObject)==null?void 0:n.name)+'"',c.motion.clips.map(d=>d.node.name))}if(!c.motion.clip){const u=new Pr(void 0,void 0,[]);c.motion.clip=u}if((r=c.motion)!=null&&r.clip){const u=c.motion.clip;if(u instanceof Pr){const d=this.createAction(u);c.motion.action=d}else(vr||gt())&&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=J.get(u.typeName),f=new d;f.isStateMachineBehaviour&&(f._context=this.context??void 0,Np(f,u.properties),u.instance=f),vr&&console.log("Created animator controller behaviour",c.name,u.typeName,u.properties,f)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let i=0;i<t.states.length;i++){const n=t.states[i];n!=null&&n.motion&&(n.motion.action&&(yield n.motion.action),n.motion.action_loopback&&(yield n.motion.action_loopback))}}}}class JO{constructor(e,t){h(this,"track");h(this,"createdInterpolant");h(this,"originalEvaluate");h(this,"customEvaluate");this.track=e;const i=e,n=i.createInterpolant.bind(e);i.createInterpolant=()=>(i.createInterpolant=n,this.createdInterpolant=n(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=r=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(r);return t(r,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 Xn=class{constructor(e,t,i,n,r){h(this,"_action");h(this,"root");h(this,"clip");h(this,"positionWrapper",null);h(this,"rotationWrapper",null);h(this,"context");h(this,"positionChange",new w);h(this,"rotationChange",new Ce);h(this,"_prevTime",0);if(this.context=e,this.root=t,this.clip=i,Xn.firstKeyframeRotation[this.cacheId]||(Xn.firstKeyframeRotation[this.cacheId]=new Ce),r){const o=r.values;Xn.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}Xn.spaceRotation[this.cacheId]||(Xn.spaceRotation[this.cacheId]=new Ce),Xn.effectiveSpaceRotation[this.cacheId]||(Xn.effectiveSpaceRotation[this.cacheId]=new Ce),Xn.clipOffsetRotation[this.cacheId]=new Ce,r&&Xn.clipOffsetRotation[this.cacheId].set(r.values[0],r.values[1],r.values[2],r.values[3]).invert(),this.handlePosition(i,n),this.handleRotation(i,r)}set action(e){this._action=e}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(e){if(e.getClip()!==this.clip)return;Xn.lastObjRotation[this.cacheId]||(Xn.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const t=Xn.lastObjRotation[this.cacheId];if(Xn.spaceRotation[this.cacheId].copy(t),Y0){const i=new Wi().setFromQuaternion(t);console.log("START",this.clip.name,et.toDegrees(i.y),this.root.position.z)}}getClipRotationOffset(){return Xn.clipOffsetRotation[this.cacheId]}handlePosition(e,t){if(t){const i=this.root;Y0&&i.add(new ea),Xn.lastObjPosition[this.cacheId]||(Xn.lastObjPosition[this.cacheId]=this.root.position.clone());const n=new w,r=new w;this.positionWrapper=new JO(t,(o,a)=>{const l=this.action.getEffectiveWeight();return Y0&&i.position.length()>8&&i.position.set(0,i.position.y,0),o>this._prevTime&&(n.set(a[0],a[1],a[2]),n.sub(r),n.multiplyScalar(l),n.applyQuaternion(this.getClipRotationOffset()),n.applyQuaternion(i.quaternion),this.positionChange.copy(n)),r.fromArray(a),this._prevTime=o,a[0]=0,a[1]=0,a[2]=0,a})}}handleRotation(e,t){if(t){if(Y0){const o=t.values,a=new Wi().setFromQuaternion(new Ce(o[0],o[1],o[2],o[3]));console.log(e.name,t.name,"FIRST ROTATION IN TRACK",et.toDegrees(a.y));const l=t.values.length-4,c=new Ce().set(o[l],o[l+1],o[l+2],o[l+3]),u=new Wi().setFromQuaternion(c);console.log(e.name,t.name,"LAST ROTATION IN TRACK",et.toDegrees(u.y))}let i=0;const n=new Ce,r=new Ce;this.rotationWrapper=new JO(t,(o,a)=>(o>i&&(r.set(a[0],a[1],a[2],a[3]),n.invert(),r.multiply(n),this.rotationChange.copy(r)),n.fromArray(a),i=o,a[0]=0,a[1]=0,a[2]=0,a[3]=1,a))}}onBeforeUpdate(e){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(e){return!this.action||(e*=this.action.getEffectiveWeight(),e<=0)?!1:(this.positionChange.multiplyScalar(e),this.rotationChange.slerp(Xn.identityQuaternion,1-e),!0)}};let Xa=Xn;h(Xa,"lastObjPosition",{}),h(Xa,"lastObjRotation",{}),h(Xa,"firstKeyframeRotation",{}),h(Xa,"spaceRotation",{}),h(Xa,"effectiveSpaceRotation",{}),h(Xa,"clipOffsetRotation",{}),h(Xa,"identityQuaternion",new Ce);class sne{constructor(e){h(this,"controller");h(this,"handler",[]);h(this,"root");h(this,"basePosition",new w);h(this,"baseQuaternion",new Ce);h(this,"baseRotation",new Wi);h(this,"summedPosition",new w);h(this,"summedRotation",new Ce);this.controller=e}createClip(e,t,i){this.root=t,t&&"name"in t&&t.name;const n=this.findRootTrack(i,".position"),r=this.findRootTrack(i,".quaternion"),o=new Xa(this.controller.context,t,i,n,r);this.handler.push(o);const a=e.clipAction(i);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 i=e.tracks;if(!i)return null;for(const n of i)if(n.name.endsWith(t))return n;return null}}class rne extends El{onSerialize(e,t){}onDeserialize(e,t){if(t.type===bo&&(e==null?void 0:e.__type)==="AnimatorController")return new bo(e)}}new rne(bo);var one=Object.defineProperty,ane=Object.getOwnPropertyDescriptor,Dw=(s,e,t,i)=>{for(var n=i>1?void 0:i?ane(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&one(e,t,n),n};const Fo=ne("debuganimator");class ks extends Me{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(t){var i;this._animatorController&&this._animatorController.model===t||(t?t instanceof bo?(t.animator&&t.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(i=t.model)==null?void 0:i.name),t.model||console.error("AnimatorController has no model"),t=new bo(t.model)),this._animatorController=t,this._animatorController.bind(this)):(Fo&&console.log("Assign animator controller",t,this),this._animatorController=new bo(t),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var t;return(t=this.runtimeAnimatorController)==null?void 0:t.getCurrentStateInfo()}get currentAction(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(t,i=-1,n=Number.NEGATIVE_INFINITY,r=0){this.play(t,i,n,r)}play(t,i=-1,n=Number.NEGATIVE_INFINITY,r=0){var o;(o=this.runtimeAnimatorController)==null||o.play(t,i,n,r),this._isDirty=!0}Reset(){this.reset()}reset(){var t;(t=this._animatorController)==null||t.reset(),this._isDirty=!0}SetBool(t,i){this.setBool(t,i)}setBool(t,i){var n,r;Fo&&console.log("setBool",t,i),((n=this.runtimeAnimatorController)==null?void 0:n.getBool(t))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(t,i)}GetBool(t){return this.getBool(t)}getBool(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getBool(t))??!1;return Fo&&console.log("getBool",t,i),i}toggleBool(t){this.setBool(t,!this.getBool(t))}SetFloat(t,i){this.setFloat(t,i)}setFloat(t,i){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(t))!==i&&(this._parametersAreDirty=!0),Fo&&console.log("setFloat",t,i),(r=this.runtimeAnimatorController)==null||r.setFloat(t,i)}GetFloat(t){return this.getFloat(t)}getFloat(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getFloat(t))??-1;return Fo&&console.log("getFloat",t,i),i}SetInteger(t,i){this.setInteger(t,i)}setInteger(t,i){var n,r;((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(t))!==i&&(this._parametersAreDirty=!0),Fo&&console.log("setInteger",t,i),(r=this.runtimeAnimatorController)==null||r.setInteger(t,i)}GetInteger(t){return this.getInteger(t)}getInteger(t){var n;const i=((n=this.runtimeAnimatorController)==null?void 0:n.getInteger(t))??-1;return Fo&&console.log("getInteger",t,i),i}SetTrigger(t){this.setTrigger(t)}setTrigger(t){var i;this._parametersAreDirty=!0,Fo&&console.log("setTrigger",t),(i=this.runtimeAnimatorController)==null||i.setTrigger(t)}ResetTrigger(t){this.resetTrigger(t)}resetTrigger(t){var i;this._parametersAreDirty=!0,Fo&&console.log("resetTrigger",t),(i=this.runtimeAnimatorController)==null||i.resetTrigger(t)}GetTrigger(t){this.getTrigger(t)}getTrigger(t){var n;const i=(n=this.runtimeAnimatorController)==null?void 0:n.getTrigger(t);return Fo&&console.log("getTrigger",t,i),i}IsInTransition(){return this.isInTransition()}isInTransition(){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.isInTransition())??!1}SetSpeed(t){return this.setSpeed(t)}setSpeed(t){var i;t!==this._speed&&(Fo&&console.log("setSpeed",t),this._speed=t,((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(t))}set minMaxSpeed(t){var i;this._speed=et.lerp(t.x,t.y,Math.random()),((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(t){var i;this._normalizedStartOffset=et.lerp(t.x,t.y,Math.random()),((i=this.runtimeAnimatorController)==null?void 0:i.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Fo&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(t=!1){const i=t||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&i){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 t;this.keepAnimatorControllerStateOnDisable||(t=this._animatorController)==null||t.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!tne(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Dw([x()],ks.prototype,"applyRootMotion",2);Dw([x()],ks.prototype,"hasRootMotion",2);Dw([x()],ks.prototype,"keepAnimatorControllerStateOnDisable",2);Dw([x()],ks.prototype,"runtimeAnimatorController",1);const il=ne("debugusdzanimation"),FM=ne("debugusdzanimationserialization");class Ow{constructor(e,t,i){h(this,"_start");h(this,"ext");h(this,"root");h(this,"clip");this.ext=e,this.root=t,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){var e;return((e=this.clip)==null?void 0:e.duration)??Nn.restPoseClipDuration}}const jP=class{constructor(e,t,i){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=e,this.target=t,this.clip=i,i?this.duration=i.duration:this.duration=jP.restPoseClipDuration;const n=oe.getComponent(e,ks);n&&(this.useRootMotion=n.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,i,n,r,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((n=(i=this.rot)==null?void 0:i.times)==null?void 0:n.length)??0,((o=(r=this.scale)==null?void 0:r.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,i=!0){var l,c,u;if(!this.clip)return[0,this.duration];const n=(l=this.pos)==null?void 0:l.times,r=(c=this.rot)==null?void 0:c.times,o=(u=this.scale)==null?void 0:u.times,a=[];if(e&&n)for(const d of n)a.push(d);if(t&&r)for(const d of r)a.push(d);if(i&&o)for(const d of o)a.push(d);return a.includes(0)||a.push(0),a.sort((d,f)=>d-f),[...new Set(a)]}*getValues(e,t=!0,i=!0,n=!0){var f,p,m;const r=new w,o=new Ce,a=new w(1,1,1),l=this.target,c=t?(f=this.pos)==null?void 0:f.createInterpolant():void 0,u=i?(p=this.rot)==null?void 0:p.createInterpolant():void 0,d=n?(m=this.scale)==null?void 0:m.createInterpolant():void 0;c||r.set(l.position.x,l.position.y,l.position.z),u||o.set(l.quaternion.x,l.quaternion.y,l.quaternion.z,l.quaternion.w),d||a.set(l.scale.x,l.scale.y,l.scale.z);for(let A=0;A<e.length;A++){const g=e[A];if(c){const v=c.evaluate(g);r.set(v[0],v[1],v[2])}if(u){const v=u.evaluate(g);o.set(v[0],v[1],v[2],v[3])}if(d){const v=d.evaluate(g);a.set(v[0],v[1],v[2])}if(this.useRootMotion&&l===this.root){const v=new we;v.compose(r,o,a),v.multiply(l.matrix),v.decompose(r,o,a)}yield{time:g,translation:r,rotation:o,scale:a,index:A}}}};let Nn=jP;h(Nn,"animationDurationPadding",1/60),h(Nn,"restPoseClipDuration",1/60);class qA{constructor(e){h(this,"dict",new Map);h(this,"rootTargetMap",new Map);h(this,"rootAndClipToRegisteredAnimationMap",new Map);h(this,"rootToRegisteredClip",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:(Nn.restPoseClipDuration+Nn.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[t,i]of this.rootAndClipToRegisteredAnimationMap){const n=i.start+i.duration;n>e&&(e=n)}return e*60}getClipCount(e){var i;let t=((i=this.rootToRegisteredClip.get(e))==null?void 0:i.length)??0;return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){if(!t)return 0;const i=this.rootTargetMap.get(e);if(!i)return 0;const n=this.dict.get(i[0]);if(!n)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let r=0;for(let o=0;o<n.length&&n[o].clip!==t;o++)r+=n[o].getDuration()+Nn.animationDurationPadding;return r}registerAnimation(e,t){var c;if(!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const i=e.uuid+((t==null?void 0:t.uuid)??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);il&&console.log("registerAnimation",e,t);const n=this.injectRestPoses?1:0,r=(((c=this.rootToRegisteredClip.get(e))==null?void 0:c.length)??0)+n,o=this.rootTargetMap.get(e),a=new Set(o);if(t&&t.tracks)for(const u of t.tracks){const d=Xt.parseTrackName(u.name),f=Xt.findNode(e,d.nodeName);if(!f){console.warn("no object found for track",u.name,"using "+e.name+" instead");continue}this.dict.has(f)||this.dict.set(f,[]);const p=this.dict.get(f);if(!p){console.warn("no transform data found for target ",f,"at slot "+r+", this is likely a bug");continue}a.delete(f),this.injectRestPoses&&!p[0]&&(p[0]=new Nn(null,f,null));let m=p[r];m||(m=new Nn(e,f,t),p[r]=m),m.addTrack(u),o!=null&&o.includes(f)||o==null||o.push(f)}il&&console.log("Unregistered nodes for this clip",a,"clip",t,"at slot",r,"for root",e,"targets",o);for(const u of a){const d=this.dict.get(u);if(!d)continue;if(this.injectRestPoses&&!d[0]){console.warn("Adding rest pose for ",u,t,"at slot",r,"This is likely a bug, should have been added earlier.");const p=new Nn(null,u,null);d[0]=p}let f=d[r];f||(il&&console.log("Adding padding clip for ",u,t,"at slot",r),f=new Nn(e,u,t),d[r]=f)}const l=new Ow(this,e,t);if(this.rootAndClipToRegisteredAnimationMap.set(i,l),il&&console.log({root:e,clip:t,info:l}),t){const u=this.rootToRegisteredClip.get(e);u?u.push(t):this.rootToRegisteredClip.set(e,[t])}return l}onAfterHierarchy(e){il&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,i;il&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const n of this.rootTargetMap.keys()){const r=this.rootTargetMap.get(n);if(!r)continue;let o;const a=[];for(const l of r){const c=this.dict.get(l);if(!c){console.error("No data found for target on USDZ export – please report a bug!",l);continue}o===void 0&&(o=c==null?void 0:c.length),o!==(c==null?void 0:c.length)&&console.error("Different array lengths for targets – please report a bug!",c);for(let u=0;u<c.length;u++){let d=c[u];if(!d){const f=u-(this.injectRestPoses?1:0);c[u]=new Nn(null,l,this.rootToRegisteredClip.get(n)[f]),d=c[u]}if(!a[u])a[u]=d.getDuration();else if(a[u]!==d.getDuration()){console.error("Different durations for targets – please report a bug!",c);continue}}}}for(const n of this.serializers){const r=(t=n.model)==null?void 0:t.parent,o=(r==null?void 0:r.isDynamic)===!0;FM&&console.log(o,(i=n.model)==null?void 0:i.parent),o&&n.registerCallback(r)}}onExportObject(e,t,i){oe.foreachComponent(e,r=>{const o=r;typeof o.createAnimation=="function"&&o.createAnimation(this,t,i)},!1);const n=new lne(e,this.dict);this.serializers.push(n),n.registerCallback(t)}}class lne{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)),FM&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){var r;const i=this.model,n=this.dict;if(i&&i.skinnedMesh){let o=function(C){const P=[];for(const[S,I]of C){let H=`${S} : [`;const U=[];for(const D of I)U.push(`(${hs(D.x)}, ${hs(D.y)}, ${hs(D.z)})`);H=H.concat(U.join(", ")),H=H.concat("],"),P.push(H)}return P},a=function(C){const P=[];for(const[S,I]of C){let H=`${S} : [`;const U=[];for(const D of I)U.push(`(${hs(D.w)}, ${hs(D.x)}, ${hs(D.y)}, ${hs(D.z)})`);H=H.concat(U.join(", ")),H=H.concat("],"),P.push(H)}return P},l=function(C){let P,S=!0;const I=new Map;for(const[U,D]of C){P===void 0&&(P=D.length),P!==D.length&&(S=!1);let V=0;for(const L of D)V++,L||(I.has(U)||I.set(U,[]),I.get(U).push(V))}il&&console.log("Bone count: ",C.size,"TransformData entries per bone: ",P,"Undefined bone entries: ",I),console.assert(S,"All bones should have the same number of TransformData entries",C),console.assert(I.size===0,"All TransformData entries should be set",I);const H=[];for(const[U,D]of C){const V=new Array;let L=0;for(let k=0;k<D.length;k++)V.push(L),L+=D[k].getDuration()+Nn.animationDurationPadding;for(let k=0;k<D.length;k++){const G=D[k],Y=V[k];H.length<=k&&H.push({pos:[],rot:[],scale:[],timeOffset:Y});const K=H[k];K.pos.push(...G.getSortedTimesArray(!0,!1,!1)),K.rot.push(...G.getSortedTimesArray(!1,!0,!1)),K.scale.push(...G.getSortedTimesArray(!1,!1,!0))}}for(const U of H)U.pos.sort((D,V)=>D-V),U.rot.sort((D,V)=>D-V),U.scale.sort((D,V)=>D-V),U.pos=[...new Set(U.pos)],U.rot=[...new Set(U.rot)],U.scale=[...new Set(U.scale)];return H},c=function(C,P,S){const I=new Map,H=new Map,U=new Map,D=P.length;for(const V of S){const L=C.get(V);let k;L?console.assert(L.length===D,"We should have the same number of TransformData entries for each bone",L,P):k=new Nn(null,V,null);for(let G=0;G<D;G++){const Y=L?L[G]:k,K=P[G];for(const{time:re,translation:ce}of Y.getValues(K.pos,!0,!1,!1)){const ie=(re+K.timeOffset)*60;I.has(ie)||I.set(ie,new Array),I.get(ie).push(ce.clone())}for(const{time:re,rotation:ce}of Y.getValues(K.rot,!1,!0,!1)){const ie=(re+K.timeOffset)*60;H.has(ie)||H.set(ie,new Array),H.get(ie).push(ce.clone())}for(const{time:re,scale:ce}of Y.getValues(K.scale,!1,!1,!0)){const ie=(re+K.timeOffset)*60;U.has(ie)||U.set(ie,new Array),U.get(ie).push(ce.clone())}}}return{position:I.size==0?void 0:I,quaternion:H.size==0?void 0:H,scale:U.size==0?void 0:U}},u=function(C){const P=[];for(const S of C)P.push(`(${hs(S.x)}, ${hs(S.y)}, ${hs(S.z)})`);return P.join(", ")},d=function(C){const P=[];for(const S of C)P.push(`(${hs(S.w)}, ${hs(S.x)}, ${hs(S.y)}, ${hs(S.z)})`);return P.join(", ")},f=function(C){const P=new Map;if(il){const S=new Array;for(const[I,H]of n)S.push(I.uuid+": "+H.length+" "+H.map(U=>{var D;return(D=U.clip)==null?void 0:D.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+S.join(`
|
|
5508
|
-
`))}for(const S of C){const I=n.get(S);I&&P.set(S,I)}return P},p=function(C){const P=f(C),S=l(P);return c(P,S,C)};const m=i.skinnedMesh.skeleton,A=new Array;for(const C in m.bones){const P=m.bones[C],S=m.boneInverses[C];A.push({bone:P,inverse:S})}for(const C of v3(m.bones))A.push({bone:C,inverse:C.matrixWorld.clone().invert()});const g=A[0].bone.parent;g||console.error("No bone parent found for skinned mesh during USDZ export",i.skinnedMesh),A.sort((C,P)=>Ap(C.bone,g)>Ap(P.bone,g)?1:-1);const v=[],_=[],y=[],b=[];for(const{bone:C}of A)v.push(C.matrix.clone()),_.push(C.position),y.push(C.quaternion),b.push(C.scale);const M=A.map(C=>'"'+Ap(C.bone,g)+'"').join(", "),E=A.map(C=>np(C.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${E}]`),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${v.map(C=>np(C)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${np(new we)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=p(A.map(C=>C.bone));if(il){let C=1e7,P=0;for(const S of((r=T.position)==null?void 0:r.keys())??[])C=Math.min(C,S),P=Math.max(P,S);console.log("Time samples",C,P,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine(`quatf[] rotations = [${d(y)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const C=a(T.quaternion);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(b)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const C=o(T.scale);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(_)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const C=o(T.position);for(const P of C)e.appendLine(P);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var u;if(!this.model)return;const i=this.dict.get(this.object);if(i)for(let d=0;d<i.length;d++)i[d]===void 0&&(i[d]=new Nn(null,this.object,null));this.skinnedMeshExport(e,t);const n=this.object,r=this.dict.get(n);if(!r||n.isSkinnedMesh)return;FM&&console.log("SERIALIZE",this.model.name,this.object.type,r);const o=new we;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const a=new Array;let l=0;for(let d=0;d<r.length;d++){if(a.push(l),r[d]===void 0){console.error("Got an undefined transform data, this is likely a bug.",n,r);continue}l+=r[d].getDuration()+Nn.animationDurationPadding}const c=Intl.NumberFormat("en",{maximumFractionDigits:2,minimumFractionDigits:0});for(let d=0;d<r.length;d++){const f=r[d];if(!f)continue;const p=a[d];{const m=f.getSortedTimesArray();if(!m||m.length===0){console.error("got an animated object but no time values?",n,f);continue}{const A=((u=f.clip)==null?void 0:u.name)??"rest",g=f.getDuration();il&&console.log("Write .timeSamples:",A,p,g,r),e.appendLine("# "+A+": start="+c.format(p*f.frameRate)+", length="+c.format(g*f.frameRate)+", frames="+f.getFrames())}for(const{time:A,translation:g,rotation:v,scale:_}of f.getValues(m)){o.compose(g,v,_);const b=`${c.format((p+A)*f.frameRate)}: ${np(o)},`;e.appendLine(b)}}}e.indent--,e.appendLine("}")}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,hG=(s,e,t,i)=>{for(var n=i>1?void 0:i?hne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cne(e,t,n),n};const KO=ne("debugpost");class kt{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 i=this._value;if(KO){let n=!0;if(typeof i=="number"&&typeof e=="number"){const r=i==null?void 0:i.toFixed(4),o=e==null?void 0:e.toFixed(4);r!=o?n=!0:n=!1}n&&console.log("VolumeParameter: value changed from",i,"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,i,this):KO&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}hG([x()],kt.prototype,"overrideState",1);hG([x()],kt.prototype,"value",1);var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,fne=(s,e,t,i)=>{for(var n=i>1?void 0:i?dne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&une(e,t,n),n};const pne=ne("debugpost");class lr extends Me{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const n=t[i],r=this[i];r instanceof kt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){pne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof kt&&n.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===kt){const a=t[r];if(a!==void 0){const l=this[r];l.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof kt){const n=t.value;return this[i].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===kt&&(this[i]||(this[i]=new kt))}}fne([x()],lr.prototype,"active",2);var mne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,vne=(s,e,t,i)=>{for(var n=i>1?void 0:i?gne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&mne(e,t,n),n};const Ane=ne("debugpost"),UM={};function la(s,e){UM[s]=e}function yne(s){return s.__type in UM?UM[s.__type]:(Ane&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),lr)}class XA{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}vne([tm([s=>yne(s),lr])],XA.prototype,"components",2);var _ne=Object.defineProperty,bne=Object.getOwnPropertyDescriptor,xne=(s,e,t,i)=>{for(var n=i>1?void 0:i?bne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&_ne(e,t,n),n};class YA extends lr{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new $3({preset:Qf.HIGH,edgeDetectionMode:sR.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}xne([x(kt)],YA.prototype,"preset",2);la("Antialiasing",YA);const wne=ne("debugusdz");class Hh{constructor(){h(this,"files",new Array)}static getName(e){var r;const t=e.split(".").pop();let n=(r=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:r.replace(".","_");return n||(n="Audio_"+Math.random().toString(36).substring(2,15)),Ba(n)+"."+t}get extensionName(){return"Audio"}onExportObject(e,t,i){const n=oe.getComponents(e,fn);if(n.length)for(const r of n){if(!r.clip||typeof r.clip!="string"||!r.playOnAwake)continue;const o=r.clip.split("/").pop()||"Audio",a=Hh.getName(r.clip),l=Ba(a);this.files.some(c=>c.path===r.clip)||this.files.push({path:r.clip,name:a}),i.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 = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${r.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i="audio/"+t.name;if(e.files[i]){wne&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(t.path)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files[i]=a}}}const Yu=ne("debugautosync"),$C=Symbol("syncerId");class Sne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Cne(e);return t[$C]=e.guid,this._syncers[t[$C]]=t,t}removeSyncer(e){delete this._syncers[e[$C]]}}const DR=new Sne;class Cne{constructor(e){h(this,"comp");h(this,"hasChanges",!1);h(this,"changedProperties",{});h(this,"data",{});h(this,"_isReceiving",!1);h(this,"_isInit",!1);h(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected||!e.isInRoom){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 i=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=i}e.send(this.networkingKey,this.data,Wo.Queued)});h(this,"onHandleReceiving",e=>{if(Yu&&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)){Yu&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const i in e){if(i==="guid")continue;const n=e[i];this.comp[i]=n,Yu&&console.log("SET",i,n)}}catch(i){console.error(i)}finally{this._isReceiving=!1}}});this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(Yu&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}}function Ene(s,e){let t=e!==s;return!t&&s&&e&&(Array.isArray(s)&&Array.isArray(e)||typeof s=="object"&&typeof e=="object")&&(t=!0),t}const ov=Symbol("AutoSyncHandler");function Mne(s){if(s[ov])return s[ov];const e=DR.getOrCreateSyncer(s);return e==null||e.init(s),s[ov]=e,e}function Tne(s){const e=s[ov];e&&(DR.removeSyncer(e),e.destroy(),delete s[ov])}const OR=function(s){return function(e,t){var u;let i="";typeof t=="string"?i=t:i=t.name;let n=null,r;typeof s=="string"?r=e[s]:typeof s=="function"&&(r=s);const o=e,a=o.__internalAwake;if(typeof a!="function"){(Yu||gt())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((u=e==null?void 0:e.constructor)==null?void 0:u.name)+'" is not supported',e);return}Yu&&console.log(i);const l=Symbol(i);o.__internalAwake=function(){if(this[l]!==void 0)return;this[l]=this[i],n=DR.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,i);if((d==null?void 0:d.set)===void 0){let f=!1;Object.defineProperty(this,i,{set:function(p){var A;const m=this[l];if(this[l]=p,f){gt()&&console.warn("Recursive call detected",i);return}f=!0;try{const g=Ene(p,m);Yu&&console.log("SyncField assignment",i,"changed?",g,p),g&&(r==null?void 0:r.call(this,p,m))!==!1&&((A=Mne(this))==null||A.notifyChanged(i,p))}finally{f=!1}},get:function(){return this[l]},configurable:!0,enumerable:!0})}n==null||n.init(this),a.call(this)};const c=o.__internalDestroy;o.__internalDestroy=function(){Tne(this),c.call(this)}}};var Ine=Object.defineProperty,Rne=Object.getOwnPropertyDescriptor,Lw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ine(e,t,n),n};const lo=ne("debugplayersync");class um extends Me{constructor(){super(...arguments);h(this,"autoSync",!0);h(this,"asset");h(this,"onPlayerSpawned");h(this,"_localInstance");h(this,"onJoinedRoom",()=>{lo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new es)}onEnable(){this.context.connection.beginListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom)}async getInstance(){var i,n,r,o,a,l;if(this._localInstance)return this._localInstance;if(lo&&console.log("PlayerSync.createInstance",(i=this.asset)==null?void 0:i.uri),!((n=this.asset)!=null&&n.asset)&&!((r=this.asset)!=null&&r.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const t=await this._localInstance;if(t){const c=oe.getComponent(t,Jo);c?(c.owner=this.context.connection.connectionId,(a=this.onPlayerSpawned)==null||a.invoke(t)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((l=this.asset)==null?void 0:l.uri)+"</strong>: please make sure the asset has a PlayerState component!"),oe.destroySynced(t))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var t;(t=this._localInstance)==null||t.then(i=>(lo&&console.log("PlayerSync.destroyInstance",i),oe.destroySynced(i))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",t=>{if(document.visibilityState==="visible")for(let i=Jo.all.length-1;i>=0;i--){const n=Jo.all[i];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}Lw([x()],um.prototype,"autoSync",2);Lw([x($t)],um.prototype,"asset",2);Lw([x(es)],um.prototype,"onPlayerSpawned",2);var uG=(s=>(s.OwnerChanged="ownerChanged",s))(uG||{}),gg;const Ss=(gg=class extends Me{constructor(){super(...arguments);h(this,"onOwnerChangeEvent",new es);h(this,"onFirstOwnerChangeEvent",new es);h(this,"hasOwner",!1);h(this,"owner");h(this,"dontDestroy",!1);h(this,"onUserLeftRoom",e=>{if(e.userId===this.owner){lo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Ss._all}static get local(){return Ss._local}static getFor(e){if(e instanceof me)return oe.getComponentInParent(e,Ss);if(e instanceof Me)return oe.getComponentInParent(e.gameObject,Ss)}static isLocalPlayer(e){const t=Ss.getFor(e);return(t==null?void 0:t.isLocalPlayer)??!1}static addEventListener(e,t){return this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),t}static removeEventListener(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i>=0&&this._callbacks[e].splice(i,1)}static dispatchEvent(e,t){if(this._callbacks[e])for(const i of this._callbacks[e])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(e,t){var o,a;lo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",e,"oldOwner",t);const i=Ss._local.indexOf(this);i>=0&&Ss._local.splice(i,1);const n={playerState:this,oldValue:t,newValue:e};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(n)),(a=this.onOwnerChangeEvent)==null||a.invoke(n),this.owner===this.context.connection.connectionId){Ss._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:n});this.dispatchEvent(l)}const r=new CustomEvent("owner-changed",{detail:n});this.dispatchEvent(r),Ss.dispatchEvent("ownerChanged",r)}awake(){Ss.all.push(this),lo&&console.log("Registered new PlayerState",this.guid,Ss.all.length-1,Ss.all),this.context.connection.beginListen(ii.UserLeftRoom,this.onUserLeftRoom)}async start(){lo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Pa(300),this.context.connection.userIsInRoom(this.owner)==!1&&(lo&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(lo&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?lo&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(lo&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):lo&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){lo&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),bw(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeftRoom),Ss.all.splice(Ss.all.indexOf(this),1),this.isLocalPlayer){const e=Ss._local.indexOf(this);e>=0&&Ss._local.splice(e,1)}}},h(gg,"_all",[]),h(gg,"_local",[]),h(gg,"_callbacks",{}),gg);let Jo=Ss;Lw([OR(Jo.prototype.onOwnerChange)],Jo.prototype,"owner",2);const Pne=ne("debugavatar"),_a=class extends Me{constructor(){super(...arguments);h(this,"connectionId");h(this,"avatar")}static getAvatar(t){return t>=0&&t<_a.instances.length?_a.instances[t]:null}static onAvatarMarkerCreated(t){return _a._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return _a._onAvatarMarkerDestroyed.push(t),t}awake(){_a.instances.push(this),Pne&&console.log(this);for(const t of _a._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){_a.instances.splice(_a.instances.indexOf(this),1);for(const t of _a._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Jn=_a;h(Jn,"instances",[]),h(Jn,"_onNewAvatarMarkerAdded",[]),h(Jn,"_onAvatarMarkerDestroyed",[]);var Bne=Object.defineProperty,Dne=Object.getOwnPropertyDescriptor,One=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Bne(e,t,n),n};const Wf=ne("debugxrflags"),dG=ne("disablexrflags");dG&&console.warn("XRFlags are disabled");var ol=(s=>(s[s.Never=0]="Never",s[s.Browser=1]="Browser",s[s.AR=2]="AR",s[s.VR=4]="VR",s[s.FirstPerson=8]="FirstPerson",s[s.ThirdPerson=16]="ThirdPerson",s[s.All=4294967295]="All",s))(ol||{});const qP=class{constructor(){h(this,"Mask",17)}Has(e){return(this.Mask&e)!==0}Set(e){Wf&&console.warn("Set XR flag state to",e),this.Mask=e,uo.Apply()}Enable(e){this.Mask|=e,uo.Apply()}Disable(e){this.Mask&=~e,uo.Apply()}Toggle(e){this.Mask^=e,uo.Apply()}EnableAll(){this.Mask=-1,uo.Apply()}DisableAll(){this.Mask=0,uo.Apply()}};let Ps=qP;h(Ps,"Global",new qP);var vg;const Yl=(vg=class extends Me{constructor(){super(...arguments);h(this,"visibleIn")}static Apply(){for(const e of this.registry)e.UpdateVisible(Ps.Global)}awake(){Yl.registry.push(this)}onEnable(){Yl.firstApply?this.UpdateVisible(Ps.Global):(Yl.firstApply=!0,Yl.Apply())}onDestroy(){const e=Yl.registry.indexOf(this);e>=0&&Yl.registry.splice(e,1)}get isOn(){return this.gameObject.visible}UpdateVisible(e=null){if(dG)return;let t;const i=e;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),Wf&&console.log(i),Yl.buffer.Mask=i,e=Yl.buffer),e instanceof Ps?(Wf&&console.warn(this.name,"use passed in mask",e.Mask,this.visibleIn),t=e.Has(this.visibleIn)):(Wf&&console.log(this.name,"use global mask"),Ps.Global.Has(this.visibleIn)),t!==void 0)if(t)Wf&&console.log(this.name,"is visible",this.gameObject.uuid),oe.setActive(this.gameObject,!0);else{if(Wf&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(vg,"registry",[]),h(vg,"firstApply"),h(vg,"buffer",new Ps),vg);let uo=Yl;One([x()],uo.prototype,"visibleIn",2);var Lne=Object.defineProperty,kne=Object.getOwnPropertyDescriptor,LR=(s,e,t,i)=>{for(var n=i>1?void 0:i?kne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Lne(e,t,n),n};const rg=ne("debugwebxr"),ZO=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI);class kd extends Me{constructor(){super(...arguments);h(this,"head");h(this,"leftHand");h(this,"rightHand");h(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;rg&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=Jo.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addNewComponent(Jn);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Jn);i&&i.destroy()}onUpdateXR(t){var l,c;if(!this.activeAndEnabled)return;const i=Jo.isLocalPlayer(this);if(!i)return;const n=t.xr;if(n.rig&&n.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),n.rig.gameObject.add(this.gameObject)),this._syncTransforms&&i)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0){const d=oe.getComponentsInChildren(this.head.asset,uo);for(const f of d)f.enabled=!1,f.gameObject.visible=!1}}const r=t.xr.leftController,o=(l=this.leftHand)==null?void 0:l.asset;r&&o&&(o.position.copy(r.gripPosition),o.quaternion.copy(r.gripQuaternion),o.quaternion.multiply(ZO),o.visible=r.isTracking);const a=t.xr.rightController;if(a&&((c=this.rightHand)!=null&&c.asset)){const u=this.rightHand.asset;u.position.copy(a.gripPosition),u.quaternion.copy(a.gripQuaternion),u.quaternion.multiply(ZO),u.visible=a.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const r=Jo.getFor(this);if(r&&r.isLocalPlayer==!1){const o=St.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(t=this.leftHand)==null?void 0:t.asset;a&&(a.visible=(o==null?void 0:o.isTracking(r.owner,"left"))??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=(o==null?void 0:o.isTracking(r.owner,"right"))??!1)}if((n=this.head)!=null&&n.asset){const a=oe.getComponentsInChildren(this.head.asset,uo);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};m4.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof me&&(this.head=new $t("",this.sourceId,this.head));else{const t=new me;t.name="Head";const i=LA.createPrimitive(bd.Cube);t.add(i),this.gameObject.add(t),this.head=new $t("",this.sourceId,t),rg&&console.log("Create head",t)}if(this.rightHand)this.rightHand instanceof me&&(this.rightHand=new $t("",this.sourceId,this.rightHand));else{const t=new me;t.name="Right Hand",this.gameObject.add(t),this.rightHand=new $t("",this.sourceId,t),rg&&console.log("Create right hand",t)}if(this.leftHand)this.leftHand instanceof me&&(this.leftHand=new $t("",this.sourceId,this.leftHand));else{const t=new me;t.name="Left Hand",this.gameObject.add(t),this.leftHand=new $t("",this.sourceId,t),rg&&console.log("Create left hand",t)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),Jo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=oe.getComponentsInChildren(this.gameObject,Gh))}async loadAvatarObjects(t,i,n){const r=t.loadAssetAsync(),o=i.loadAssetAsync(),a=n.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await wA(l);rg&&console.log("Avatar loaded results:",c)}}LR([x($t)],kd.prototype,"head",2);LR([x($t)],kd.prototype,"leftHand",2);LR([x($t)],kd.prototype,"rightHand",2);class _l{static Add(e,t,i=null){if(t){for(const n of this.Pois)if(n.obj===t)return;this.Pois.push({obj:t,avatar:i}),this.LastChangeTime=e.time.time}}static Remove(e,t){var i;if(t){for(const n of this.Pois)if(n.obj===t){this.Pois.splice(this.Pois.indexOf(n),1),this.LastChangeTime=(e==null?void 0:e.time.time)??((i=Lt.Current)==null?void 0:i.time.time);return}}}}h(_l,"Pois",[]),h(_l,"LastChangeTime",0);class Fne{constructor(){h(this,"guid");h(this,"position",new w)}}class Zv extends Me{constructor(){super(...arguments);h(this,"target",null);h(this,"avatar",null);h(this,"_model",null);h(this,"_targetModel",new Fne);h(this,"_currentTargetObject",null);h(this,"_lastUpdateTime",0);h(this,"_lookDuration",0);h(this,"_lastPoiChangedTime",0)}set controlledTarget(t){this.target=t;const i=J.get("MoveRandom");if(i&&this.target){const n=oe.getComponent(this.target,i);n&&n.destroy()}}awake(){if(this.avatar=oe.getComponentInParent(this.gameObject,Jn),this.avatar){const t=oe.getComponentInParent(this.gameObject,Jn);this._model=new SR(this.context.connection,this.guid),t!=null&&t.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",t=>{var i;this.target&&t&&t.guid===((i=this.avatar)==null?void 0:i.guid)&&rr(this.target,t.position)})}update(){var i;if((!this.context.connection.isConnected||(i=this._model)!=null&&i.hasOwnership)&&(_l.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=_l.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const n=Nt(this._currentTargetObject);rr(this.target,n),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(n))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const i=_l.Pois;if(i.length>0){const n=i[Math.floor(Math.random()*i.length)];if(n&&n.obj){if(n.avatar&&n.avatar===this.avatar)return;this._currentTargetObject=n.obj}}}}}const lp=ne("debugnetworkingstreams");var pl=(s=>(s.Connected="peer-user-connected",s.StreamReceived="receive-stream",s.StreamEnded="call-ended",s.Disconnected="peer-user-disconnected",s.UserJoined="user-joined",s))(pl||{});class fG{constructor(e,t){h(this,"type","call-ended");h(this,"userId");h(this,"direction");this.userId=e,this.direction=t}}class pG{constructor(e,t){h(this,"type","receive-stream");h(this,"stream");h(this,"target");this.stream=e,this.target=t}}class Une{constructor(e,t){h(this,"guid");h(this,"peerId");h(this,"dontSave",!0);this.guid=e.id,this.peerId=t}}var mG=(s=>(s.Incoming="incoming",s.Outgoing="outgoing",s))(mG||{});class Nne extends ps{constructor(t,i,n){super();h(this,"userId");h(this,"direction");h(this,"call");h(this,"_stream",null);h(this,"_isDisposed",!1);this.userId=t,this.call=i,this.direction=n,this._stream=null,i.on("stream",r=>{if(lp&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const o=new pG(r,this);this.dispatchEvent(o)}}),i.on("close",()=>{this.dispatchEvent(new fG(t,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),mc(this._stream))}get isOpen(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connected"}get isOpening(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const fp=class extends ps{constructor(t,i){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=t,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,i){if(fp.instances.has(i))return fp.instances.get(i);const n=new fp(t,i);return fp.instances.set(i,n),n}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,i){var o;const n={metadata:{userId:this.context.connection.connectionId}},r=(o=this._peer)==null?void 0:o.call(t,i,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(ii.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(ii.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=l4(t):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(t){lp&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new Une(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,i){const n=t.metadata;(!n||!n.userId)&&console.error("Missing call metadata",t);const r=n.userId;i==="incoming"&&lp?console.log("Receive call from",t.metadata):lp&&console.log("Make call to",t.metadata);const o=i==="incoming"?this._incomingCalls:this._outgoingCalls,a=new Nne(r,t,i);return o.push(a),t.on("error",l=>{console.error("Call error",l)}),t.on("close",()=>{lp&&console.log("Call ended",t.metadata),t.close();const l=o.indexOf(a);l!==-1&&o.splice(l,1)}),a.addEventListener("call-ended",l=>{this.dispatchEvent(l)}),i==="incoming"&&(a.addEventListener("receive-stream",l=>{this.dispatchEvent(l)}),t.on("stream",()=>{let l=0;const c=setInterval(()=>{const u=l===0;!a.isOpen&&u&&(l+=1,clearInterval(c),a.close())},2e3)})),a}};let xp=fp;h(xp,"instances",new Map);class JA extends ps{constructor(t,i){super();h(this,"context");h(this,"peer");h(this,"_sendingStreams",new Map);h(this,"debug",!1);h(this,"onJoinedRoom",t=>{this.debug&&console.log(`${t.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});h(this,"onReceiveStream",t=>{this.debug&&console.log("RECEIVE STREAM",t),this.dispatchEvent({type:"receive-stream",target:this,stream:t.stream,userId:t.userId})});h(this,"onCallEnded",t=>{this.dispatchEvent(t)});h(this,"onUserConnected",t=>{if(this.peer.id===t.guid){this.debug&&console.log("USER CONNECTED",t.guid,t);const i=this._sendingStreams.keys().next().value;this.peer.makeCall(t.peerId,i)}});h(this,"onUserLeft",t=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=t,this.peer=i,lp&&(this.debug=!0)}static create(t){const i=xp.getOrCreate(t.context,t.context.connection.connectionId);return new JA(t.context,i)}startSendingStream(t){this._sendingStreams.has(t)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(t,[]),this.updateSendingCalls())}stopSendingStream(t){if(t){const i=this._sendingStreams.get(t);if(i){this.debug&&console.log("Closing calls",i);for(const n of i)n.close()}this._sendingStreams.delete(t),i&&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(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.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(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var n;let t=!1;const i=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const o=this._sendingStreams.get(r)||[];for(const a of this.context.connection.usersInRoom()){if(a===i)continue;const l=o.find(c=>c.userId===a);if(!l||((n=l.stream)==null?void 0:n.active)===!1){this.debug&&console.log("Starting call to",a,i);const c=this.peer.makeCall(this.peer.getPeerIdFromUserId(a),r);c&&(t=!0,o.push(c))}}this._sendingStreams.set(r,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const t of this._sendingStreams.keys()){const i=this._sendingStreams.get(t);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),i.splice(n,1))}}}}function mc(s){if(s&&s instanceof MediaStream)for(const e of s.getTracks())e.stop()}var zne=Object.defineProperty,Gne=Object.getOwnPropertyDescriptor,gG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zne(e,t,n),n};const Hne="noVoip",Qne=ne("debugvoip");class Fd extends Me{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 Pa(300),this.autoConnect&&!this.isSending&&this.connect()});h(this,"_incomingStreams",new Map);h(this,"onReceiveStream",t=>{const i=t.target.userId,n=t.stream,r=this._incomingStreams.get(i);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(i,o),o.setAttribute("autoplay","true"),o.srcObject=n}});h(this,"onStreamEnded",t=>{const i=this._incomingStreams.get(t.userId);mc(i==null?void 0:i.srcObject),this._incomingStreams.delete(t.userId)});h(this,"onEnabledChanged",()=>{for(const t of this._incomingStreams){const i=t[1];i.muted=!this.enabled}});h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const i=!(document.visibilityState==="visible");this.setMuted(i);for(const n of this._incomingStreams){const r=n[1];r.muted=i}})}awake(){Qne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async t=>{t.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=JA.create(this)),this._net.addEventListener(pl.StreamReceived,this.onReceiveStream),this._net.addEventListener(pl.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var t;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(pl.StreamReceived,this.onReceiveStream),this._net.removeEventListener(pl.StreamEnded,this.onStreamEnded),(t=this._net)==null||t.disable(),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(t){if(this.context.connection.isConnected){if(!await D1())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),mc(this._outputStream),this._outputStream=await this.getAudioStream(t),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await D1()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):QI("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),mc(this._outputStream),this._outputStream=null}setMuted(t){var n;const i=(n=this._outputStream)==null?void 0:n.getAudioTracks();if(i)for(const r of i)r.enabled=!t}get isMuted(){var i;if(this._outputStream===null)return!1;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(t){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,gt()&&dn("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(t){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:t??!0,video:!1}).catch(n=>(console.warn("VOIP failed getting audio stream",n),null)):(console.error("No getDisplayMedia support"),null)}}gG([x()],Fd.prototype,"autoConnect",2);gG([x()],Fd.prototype,"runInBackground",2);var Vne=Object.defineProperty,Wne=Object.getOwnPropertyDescriptor,vG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Wne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Vne(e,t,n),n};const jne=ne("debugmouth");class KA extends Me{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=oe.findObjectOfType(Fd,this.context),this.marker||(this.marker=oe.getComponentInParent(this.gameObject,Jn))},3e3)}update(){var n;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((n=this.marker)==null?void 0:n.connectionId)??null;if(!t){jne&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<t.length;n++){const r=t[n];r&&(r.visible=n===i)}}}}vG([x(me)],KA.prototype,"idle",2);vG([x(me)],KA.prototype,"talking",2);class kR extends Me{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=oe.findObjectOfType(Fd,this.context),this.marker=oe.getComponentInParent(this.gameObject,Jn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=i/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,kw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&qne(e,t,n),n};class Ud extends Me{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=oe.getComponentInParent(this.gameObject,uo)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(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 i of this.eyes)i&&(i.visible=this.eyesOpen)}}}kw([x(me)],Ud.prototype,"eyes",2);kw([x()],Ud.prototype,"lastBlinkTime",2);kw([x()],Ud.prototype,"blinkLength",2);kw([x()],Ud.prototype,"eyesOpen",2);var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,FR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Jne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Yne(e,t,n),n},NE;const AG=(NE=class extends Me{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=oe.getComponentInParent(this.gameObject,Zv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=oe.addNewComponent(this.gameObject,Zv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=Nt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const n=Nt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const o=AG.forward;if(o.set(0,0,1),o.applyQuaternion(Ii(this.head)),o.dot(r)>.45)for(let l=0;l<t.length;l++)t[l].lookAt(this.currentTargetPoint)}}}},h(NE,"forward",new w(0,0,1)),NE);let dm=AG;FR([x(me)],dm.prototype,"head",2);FR([x(me)],dm.prototype,"eyes",2);FR([x(me)],dm.prototype,"target",2);const og=ne("debugavatar");class Fw{constructor(e,t,i,n){h(this,"root");h(this,"head");h(this,"leftHand");h(this,"rigthHand");var r;this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,(r=this.root)==null||r.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class UR{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 i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const r=new Ua;i=oe.instantiate(Dp(t,e.scene),r)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(og&&console.log("[Custom Avatar] valid config",t,og?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,og?n:""),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(og&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let r=null;if(n.ok){const a=await n.blob();a&&(r=await a.arrayBuffer())}if(!r&&(r=await dR(t,t,0,"no url here go away",!0),!r))return null;const o=await Ra().parseSync(e,r,null,0);return(o==null?void 0:o.scene)??null}const i=new em;return IA(i,e),new Promise((n,r)=>{const o=this.avatarRegistryUrl+"/"+t;i.load(o,async a=>{await Ra().createBuiltinComponents(e,o,a,null,void 0),n(a.scene)},a=>{og&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const r=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new w;new Ai().setFromObject(n).getSize(l);const c=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+c+" meters! Should be < 0.3m"),c>.3&&n.scale.multiplyScalar(1/c*.3)}return new Fw(t,n,r,o)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const r of t){if(!n)break;i.indexOf(r)===-1&&(n=!1)}if(n)return e;if(e.children)for(const r of e.children){const o=this.findAvatarPart(r,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Kne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,NR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Zne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Kne(e,t,n),n};class fm extends Me{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!BA)return;this._axes||(this._axes=new ea(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}NR([x()],fm.prototype,"length",2);NR([x()],fm.prototype,"depthTest",2);NR([x()],fm.prototype,"isGizmo",2);class zR extends Me{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 t=Nt(this.to).clone(),i=Nt(this.from).clone(),n=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=Nt(this.hint).clone();a.sub(o);const l=new w;l.crossVectors(a,r),l.crossVectors(r,l),l.normalize();const c=n*.5,u=Math.max(this.desiredDistance,c),d=Math.sqrt(u*u-c*c),f=l.clone();f.multiplyScalar(d),f.add(o),rr(this.gameObject,f);const p=o.clone();p.sub(l),this.gameObject.lookAt(p)}}const eE=ne("debugusdzbehaviours");class Uw{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(i=>{oe.foreachComponent(i,n=>{var o;const r=n;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),eE&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(t)}onExportObject(e,t,i){var n;for(const r of this.behaviourComponents)eE&&console.log("onExportObject: createBehaviours",r),(n=r.createBehaviours)==null||n.call(r,this,t,i)}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 i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const n of this.behaviours)n.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){eE&&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 $ne=Object.defineProperty,ese=Object.getOwnPropertyDescriptor,GR=(s,e,t,i)=>{for(var n=i>1?void 0:i?ese(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$ne(e,t,n),n},zE;const yG=(zE=class extends lr{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=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom==null&&(this.selectiveBloom=yG.useSelectiveBloom),this.selectiveBloom){const t=e=new Z3(this.context.scene,this.context.mainCamera,{blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new lR({blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}},h(zE,"useSelectiveBloom",!1),zE);let Nd=yG;GR([x(kt)],Nd.prototype,"threshold",2);GR([x(kt)],Nd.prototype,"intensity",2);GR([x(kt)],Nd.prototype,"scatter",2);la("Bloom",Nd);const jf="NEEDLE_progressive",Ks=ne("debugprogressive"),tE=Symbol("needle-progressive-texture"),wp=new Map;if(Ks){let s=function(){e+=1,tn(`Toggle LOD level: ${e}<br/>Registered objects: ${wp.size}`),console.log("Toggle LOD level",e,wp);const i=ri.Current;wp.forEach((n,r)=>{for(const o of n.keys){const a=r[o];if(a instanceof At){const l=Ti.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;r["DEBUG:LOD"]=c,Ti.assignMeshLOD(i,n.sourceId,r,c),l&&(t=Math.max(t,l.lods.length-1))}else if(r instanceof Ot){Ti.assignTextureLOD(i,n.sourceId,r,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",i=>{i.key==="p"&&s()}),ri.registerCallback(bn.ContextCreated,i=>{const n=document.createElement("button");n.innerText="Toggle Progressive",n.onclick=s,i.context.menu.appendChild(n)})}function $O(s,e,t){var n;if(!Ks)return;wp.has(s)||wp.set(s,{keys:[],sourceId:t});const i=wp.get(s);((n=i==null?void 0:i.keys)==null?void 0:n.includes(e))==!1&&i.keys.push(e)}const zr=class{constructor(e,t,i){h(this,"parser");h(this,"sourceId");h(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return jf}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static hasLODLevelAvailable(e,t){var r;if(e instanceof Ot){for(const o of Object.keys(e)){const a=e[o];if(a instanceof _t&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e instanceof Er){for(const o of e.children)if(o instanceof de&&this.hasLODLevelAvailable(o,t))return!0}let i,n;if(e instanceof de?i=e.geometry:e instanceof _t&&(i=e),i&&(r=i==null?void 0:i.userData)!=null&&r.LODS){const o=i.userData.LODS;if(n=this.lodInfos.get(o.key),t===void 0)return n!=null;if(n)return Array.isArray(n.lods)?t<n.lods.length:t===0}return!1}static assignMeshLOD(e,t,i,n){if(!i)return Promise.resolve(null);if(i instanceof de){const r=i.geometry,o=this.getAssignedLODInformation(r);if(!o)return Promise.resolve(null);jv(i)||q_(i,i.geometry);const a=this.onProgressiveLoadStart(e,t,i,null);return i["LOD:requested level"]=n,zr.getOrLoadLOD(e,t,r,n).then(l=>{if(i["LOD:requested level"]===n){if(delete i["LOD:requested level"],Array.isArray(l)){const c=o.index||0;l=l[c]}l&&r!=l&&(Ks=="verbose"&&console.log("Progressive Mesh "+i.name+" loaded",r,"→",l,`
|
|
5508
|
+
`))}for(const S of C){const I=n.get(S);I&&P.set(S,I)}return P},p=function(C){const P=f(C),S=l(P);return c(P,S,C)};const m=i.skinnedMesh.skeleton,A=new Array;for(const C in m.bones){const P=m.bones[C],S=m.boneInverses[C];A.push({bone:P,inverse:S})}for(const C of v3(m.bones))A.push({bone:C,inverse:C.matrixWorld.clone().invert()});const g=A[0].bone.parent;g||console.error("No bone parent found for skinned mesh during USDZ export",i.skinnedMesh),A.sort((C,P)=>Ap(C.bone,g)>Ap(P.bone,g)?1:-1);const v=[],_=[],y=[],b=[];for(const{bone:C}of A)v.push(C.matrix.clone()),_.push(C.position),y.push(C.quaternion),b.push(C.scale);const M=A.map(C=>'"'+Ap(C.bone,g)+'"').join(", "),E=A.map(C=>np(C.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${E}]`),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${v.map(C=>np(C)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${np(new we)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=p(A.map(C=>C.bone));if(il){let C=1e7,P=0;for(const S of((r=T.position)==null?void 0:r.keys())??[])C=Math.min(C,S),P=Math.max(P,S);console.log("Time samples",C,P,T)}if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${M}]`),e.appendLine(`quatf[] rotations = [${d(y)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const C=a(T.quaternion);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`half3[] scales = [${u(b)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const C=o(T.scale);for(const P of C)e.appendLine(P);e.closeBlock()}if(e.appendLine(`float3[] translations = [${u(_)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const C=o(T.position);for(const P of C)e.appendLine(P);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var u;if(!this.model)return;const i=this.dict.get(this.object);if(i)for(let d=0;d<i.length;d++)i[d]===void 0&&(i[d]=new Nn(null,this.object,null));this.skinnedMeshExport(e,t);const n=this.object,r=this.dict.get(n);if(!r||n.isSkinnedMesh)return;FM&&console.log("SERIALIZE",this.model.name,this.object.type,r);const o=new we;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const a=new Array;let l=0;for(let d=0;d<r.length;d++){if(a.push(l),r[d]===void 0){console.error("Got an undefined transform data, this is likely a bug.",n,r);continue}l+=r[d].getDuration()+Nn.animationDurationPadding}const c=Intl.NumberFormat("en-US",{maximumFractionDigits:3,minimumFractionDigits:0,useGrouping:!1});for(let d=0;d<r.length;d++){const f=r[d];if(!f)continue;const p=a[d];{const m=f.getSortedTimesArray();if(!m||m.length===0){console.error("got an animated object but no time values?",n,f);continue}{const A=((u=f.clip)==null?void 0:u.name)??"rest",g=f.getDuration();il&&console.log("Write .timeSamples:",A,p,g,r),e.appendLine("# "+A+": start="+c.format(p*f.frameRate)+", length="+c.format(g*f.frameRate)+", frames="+f.getFrames())}for(const{time:A,translation:g,rotation:v,scale:_}of f.getValues(m)){o.compose(g,v,_);const b=`${c.format((p+A)*f.frameRate)}: ${np(o)},`;e.appendLine(b)}}}e.indent--,e.appendLine("}")}}var cne=Object.defineProperty,hne=Object.getOwnPropertyDescriptor,hG=(s,e,t,i)=>{for(var n=i>1?void 0:i?hne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cne(e,t,n),n};const KO=ne("debugpost");class kt{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 i=this._value;if(KO){let n=!0;if(typeof i=="number"&&typeof e=="number"){const r=i==null?void 0:i.toFixed(4),o=e==null?void 0:e.toFixed(4);r!=o?n=!0:n=!1}n&&console.log("VolumeParameter: value changed from",i,"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,i,this):KO&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(e){return this._valueRaw!==e}}hG([x()],kt.prototype,"overrideState",1);hG([x()],kt.prototype,"value",1);var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,fne=(s,e,t,i)=>{for(var n=i>1?void 0:i?dne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&une(e,t,n),n};const pne=ne("debugpost");class lr extends Me{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const n=t[i],r=this[i];r instanceof kt&&(r.value=n)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){pne&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const n=this[i];n instanceof kt&&n.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const n=this.$serializedTypes;if(n){for(const r of Object.keys(n))if(n[r]===kt){const a=t[r];if(a!==void 0){const l=this[r];l.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof kt){const n=t.value;return this[i].value=n,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===kt&&(this[i]||(this[i]=new kt))}}fne([x()],lr.prototype,"active",2);var mne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,vne=(s,e,t,i)=>{for(var n=i>1?void 0:i?gne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&mne(e,t,n),n};const Ane=ne("debugpost"),UM={};function la(s,e){UM[s]=e}function yne(s){return s.__type in UM?UM[s.__type]:(Ane&&s.__type&&console.warn("Unknown postprocessing type",s.__type,s),lr)}class XA{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}vne([tm([s=>yne(s),lr])],XA.prototype,"components",2);var _ne=Object.defineProperty,bne=Object.getOwnPropertyDescriptor,xne=(s,e,t,i)=>{for(var n=i>1?void 0:i?bne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&_ne(e,t,n),n};class YA extends lr{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new $3({preset:Qf.HIGH,edgeDetectionMode:sR.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}xne([x(kt)],YA.prototype,"preset",2);la("Antialiasing",YA);const wne=ne("debugusdz");class Hh{constructor(){h(this,"files",new Array)}static getName(e){var r;const t=e.split(".").pop();let n=(r=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:r.replace(".","_");return n||(n="Audio_"+Math.random().toString(36).substring(2,15)),Ba(n)+"."+t}get extensionName(){return"Audio"}onExportObject(e,t,i){const n=oe.getComponents(e,fn);if(n.length)for(const r of n){if(!r.clip||typeof r.clip!="string"||!r.playOnAwake)continue;const o=r.clip.split("/").pop()||"Audio",a=Hh.getName(r.clip),l=Ba(a);this.files.some(c=>c.path===r.clip)||this.files.push({path:r.clip,name:a}),i.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 = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),c.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),c.appendLine(`uniform float gain = ${r.volume}`),c.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i="audio/"+t.name;if(e.files[i]){wne&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(t.path)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files[i]=a}}}const Yu=ne("debugautosync"),$C=Symbol("syncerId");class Sne{constructor(){h(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const t=new Cne(e);return t[$C]=e.guid,this._syncers[t[$C]]=t,t}removeSyncer(e){delete this._syncers[e[$C]]}}const DR=new Sne;class Cne{constructor(e){h(this,"comp");h(this,"hasChanges",!1);h(this,"changedProperties",{});h(this,"data",{});h(this,"_isReceiving",!1);h(this,"_isInit",!1);h(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected||!e.isInRoom){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 i=this.changedProperties[t];delete this.changedProperties[t],this.data[t]=i}e.send(this.networkingKey,this.data,Wo.Queued)});h(this,"onHandleReceiving",e=>{if(Yu&&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)){Yu&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const i in e){if(i==="guid")continue;const n=e[i];this.comp[i]=n,Yu&&console.log("SET",i,n)}}catch(i){console.error(i)}finally{this._isReceiving=!1}}});this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const t=this.comp.context.connection.tryGetState(this.comp.guid);t&&this.onHandleReceiving(t)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,t){this._isReceiving||(Yu&&console.log("Property changed: "+e,t),this.hasChanges=!0,this.changedProperties[e]=t)}}function Ene(s,e){let t=e!==s;return!t&&s&&e&&(Array.isArray(s)&&Array.isArray(e)||typeof s=="object"&&typeof e=="object")&&(t=!0),t}const ov=Symbol("AutoSyncHandler");function Mne(s){if(s[ov])return s[ov];const e=DR.getOrCreateSyncer(s);return e==null||e.init(s),s[ov]=e,e}function Tne(s){const e=s[ov];e&&(DR.removeSyncer(e),e.destroy(),delete s[ov])}const OR=function(s){return function(e,t){var u;let i="";typeof t=="string"?i=t:i=t.name;let n=null,r;typeof s=="string"?r=e[s]:typeof s=="function"&&(r=s);const o=e,a=o.__internalAwake;if(typeof a!="function"){(Yu||gt())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((u=e==null?void 0:e.constructor)==null?void 0:u.name)+'" is not supported',e);return}Yu&&console.log(i);const l=Symbol(i);o.__internalAwake=function(){if(this[l]!==void 0)return;this[l]=this[i],n=DR.getOrCreateSyncer(this);const d=Object.getOwnPropertyDescriptor(this,i);if((d==null?void 0:d.set)===void 0){let f=!1;Object.defineProperty(this,i,{set:function(p){var A;const m=this[l];if(this[l]=p,f){gt()&&console.warn("Recursive call detected",i);return}f=!0;try{const g=Ene(p,m);Yu&&console.log("SyncField assignment",i,"changed?",g,p),g&&(r==null?void 0:r.call(this,p,m))!==!1&&((A=Mne(this))==null||A.notifyChanged(i,p))}finally{f=!1}},get:function(){return this[l]},configurable:!0,enumerable:!0})}n==null||n.init(this),a.call(this)};const c=o.__internalDestroy;o.__internalDestroy=function(){Tne(this),c.call(this)}}};var Ine=Object.defineProperty,Rne=Object.getOwnPropertyDescriptor,Lw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Rne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ine(e,t,n),n};const lo=ne("debugplayersync");class um extends Me{constructor(){super(...arguments);h(this,"autoSync",!0);h(this,"asset");h(this,"onPlayerSpawned");h(this,"_localInstance");h(this,"onJoinedRoom",()=>{lo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new es)}onEnable(){this.context.connection.beginListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(ii.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom)}async getInstance(){var i,n,r,o,a,l;if(this._localInstance)return this._localInstance;if(lo&&console.log("PlayerSync.createInstance",(i=this.asset)==null?void 0:i.uri),!((n=this.asset)!=null&&n.asset)&&!((r=this.asset)!=null&&r.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const t=await this._localInstance;if(t){const c=oe.getComponent(t,Jo);c?(c.owner=this.context.connection.connectionId,(a=this.onPlayerSpawned)==null||a.invoke(t)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((l=this.asset)==null?void 0:l.uri)+"</strong>: please make sure the asset has a PlayerState component!"),oe.destroySynced(t))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var t;(t=this._localInstance)==null||t.then(i=>(lo&&console.log("PlayerSync.destroyInstance",i),oe.destroySynced(i))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",t=>{if(document.visibilityState==="visible")for(let i=Jo.all.length-1;i>=0;i--){const n=Jo.all[i];(!n.owner||!this.context.connection.userIsInRoom(n.owner))&&n.doDestroy()}})}}Lw([x()],um.prototype,"autoSync",2);Lw([x($t)],um.prototype,"asset",2);Lw([x(es)],um.prototype,"onPlayerSpawned",2);var uG=(s=>(s.OwnerChanged="ownerChanged",s))(uG||{}),gg;const Ss=(gg=class extends Me{constructor(){super(...arguments);h(this,"onOwnerChangeEvent",new es);h(this,"onFirstOwnerChangeEvent",new es);h(this,"hasOwner",!1);h(this,"owner");h(this,"dontDestroy",!1);h(this,"onUserLeftRoom",e=>{if(e.userId===this.owner){lo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return Ss._all}static get local(){return Ss._local}static getFor(e){if(e instanceof me)return oe.getComponentInParent(e,Ss);if(e instanceof Me)return oe.getComponentInParent(e.gameObject,Ss)}static isLocalPlayer(e){const t=Ss.getFor(e);return(t==null?void 0:t.isLocalPlayer)??!1}static addEventListener(e,t){return this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),t}static removeEventListener(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i>=0&&this._callbacks[e].splice(i,1)}static dispatchEvent(e,t){if(this._callbacks[e])for(const i of this._callbacks[e])i(t)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(e,t){var o,a;lo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",e,"oldOwner",t);const i=Ss._local.indexOf(this);i>=0&&Ss._local.splice(i,1);const n={playerState:this,oldValue:t,newValue:e};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(n)),(a=this.onOwnerChangeEvent)==null||a.invoke(n),this.owner===this.context.connection.connectionId){Ss._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:n});this.dispatchEvent(l)}const r=new CustomEvent("owner-changed",{detail:n});this.dispatchEvent(r),Ss.dispatchEvent("ownerChanged",r)}awake(){Ss.all.push(this),lo&&console.log("Registered new PlayerState",this.guid,Ss.all.length-1,Ss.all),this.context.connection.beginListen(ii.UserLeftRoom,this.onUserLeftRoom)}async start(){lo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Pa(300),this.context.connection.userIsInRoom(this.owner)==!1&&(lo&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(lo&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?lo&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(lo&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):lo&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){lo&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),bw(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeftRoom),Ss.all.splice(Ss.all.indexOf(this),1),this.isLocalPlayer){const e=Ss._local.indexOf(this);e>=0&&Ss._local.splice(e,1)}}},h(gg,"_all",[]),h(gg,"_local",[]),h(gg,"_callbacks",{}),gg);let Jo=Ss;Lw([OR(Jo.prototype.onOwnerChange)],Jo.prototype,"owner",2);const Pne=ne("debugavatar"),_a=class extends Me{constructor(){super(...arguments);h(this,"connectionId");h(this,"avatar")}static getAvatar(t){return t>=0&&t<_a.instances.length?_a.instances[t]:null}static onAvatarMarkerCreated(t){return _a._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return _a._onAvatarMarkerDestroyed.push(t),t}awake(){_a.instances.push(this),Pne&&console.log(this);for(const t of _a._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){_a.instances.splice(_a.instances.indexOf(this),1);for(const t of _a._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Jn=_a;h(Jn,"instances",[]),h(Jn,"_onNewAvatarMarkerAdded",[]),h(Jn,"_onAvatarMarkerDestroyed",[]);var Bne=Object.defineProperty,Dne=Object.getOwnPropertyDescriptor,One=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Bne(e,t,n),n};const Wf=ne("debugxrflags"),dG=ne("disablexrflags");dG&&console.warn("XRFlags are disabled");var ol=(s=>(s[s.Never=0]="Never",s[s.Browser=1]="Browser",s[s.AR=2]="AR",s[s.VR=4]="VR",s[s.FirstPerson=8]="FirstPerson",s[s.ThirdPerson=16]="ThirdPerson",s[s.All=4294967295]="All",s))(ol||{});const qP=class{constructor(){h(this,"Mask",17)}Has(e){return(this.Mask&e)!==0}Set(e){Wf&&console.warn("Set XR flag state to",e),this.Mask=e,uo.Apply()}Enable(e){this.Mask|=e,uo.Apply()}Disable(e){this.Mask&=~e,uo.Apply()}Toggle(e){this.Mask^=e,uo.Apply()}EnableAll(){this.Mask=-1,uo.Apply()}DisableAll(){this.Mask=0,uo.Apply()}};let Ps=qP;h(Ps,"Global",new qP);var vg;const Yl=(vg=class extends Me{constructor(){super(...arguments);h(this,"visibleIn")}static Apply(){for(const e of this.registry)e.UpdateVisible(Ps.Global)}awake(){Yl.registry.push(this)}onEnable(){Yl.firstApply?this.UpdateVisible(Ps.Global):(Yl.firstApply=!0,Yl.Apply())}onDestroy(){const e=Yl.registry.indexOf(this);e>=0&&Yl.registry.splice(e,1)}get isOn(){return this.gameObject.visible}UpdateVisible(e=null){if(dG)return;let t;const i=e;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),Wf&&console.log(i),Yl.buffer.Mask=i,e=Yl.buffer),e instanceof Ps?(Wf&&console.warn(this.name,"use passed in mask",e.Mask,this.visibleIn),t=e.Has(this.visibleIn)):(Wf&&console.log(this.name,"use global mask"),Ps.Global.Has(this.visibleIn)),t!==void 0)if(t)Wf&&console.log(this.name,"is visible",this.gameObject.uuid),oe.setActive(this.gameObject,!0);else{if(Wf&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},h(vg,"registry",[]),h(vg,"firstApply"),h(vg,"buffer",new Ps),vg);let uo=Yl;One([x()],uo.prototype,"visibleIn",2);var Lne=Object.defineProperty,kne=Object.getOwnPropertyDescriptor,LR=(s,e,t,i)=>{for(var n=i>1?void 0:i?kne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Lne(e,t,n),n};const rg=ne("debugwebxr"),ZO=new Ce().setFromAxisAngle(new w(0,1,0),Math.PI);class kd extends Me{constructor(){super(...arguments);h(this,"head");h(this,"leftHand");h(this,"rightHand");h(this,"_syncTransforms")}async onEnterXR(t){if(!this.activeAndEnabled)return;rg&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=Jo.getFor(this);if(i!=null&&i.owner){const n=this.gameObject.addNewComponent(Jn);n.avatar=this.gameObject,n.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(t){const i=this.gameObject.getComponent(Jn);i&&i.destroy()}onUpdateXR(t){var l,c;if(!this.activeAndEnabled)return;const i=Jo.isLocalPlayer(this);if(!i)return;const n=t.xr;if(n.rig&&n.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),n.rig.gameObject.add(this.gameObject)),this._syncTransforms&&i)for(const u of this._syncTransforms)u.fastMode=!0,u.isOwned()||u.requestOwnership();if(this.head&&this.context.mainCamera){const u=this.head.asset;if(u.position.copy(this.context.mainCamera.position),u.quaternion.copy(this.context.mainCamera.quaternion),u.quaternion.x*=-1,this.context.time.frameCount%10===0){const d=oe.getComponentsInChildren(this.head.asset,uo);for(const f of d)f.enabled=!1,f.gameObject.visible=!1}}const r=t.xr.leftController,o=(l=this.leftHand)==null?void 0:l.asset;r&&o&&(o.position.copy(r.gripPosition),o.quaternion.copy(r.gripQuaternion),o.quaternion.multiply(ZO),o.visible=r.isTracking);const a=t.xr.rightController;if(a&&((c=this.rightHand)!=null&&c.asset)){const u=this.rightHand.asset;u.position.copy(a.gripPosition),u.quaternion.copy(a.gripQuaternion),u.quaternion.multiply(ZO),u.visible=a.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var t,i,n;if(this.context.connection.isConnected){const r=Jo.getFor(this);if(r&&r.isLocalPlayer==!1){const o=St.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(t=this.leftHand)==null?void 0:t.asset;a&&(a.visible=(o==null?void 0:o.isTracking(r.owner,"left"))??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=(o==null?void 0:o.isTracking(r.owner,"right"))??!1)}if((n=this.head)!=null&&n.asset){const a=oe.getComponentsInChildren(this.head.asset,uo);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const t={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};m4.tryFindAvatarObjects(this.gameObject,this.sourceId||"",t),t.head&&(this.head=t.head),t.leftHand&&(this.leftHand=t.leftHand),t.rightHand&&(this.rightHand=t.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof me&&(this.head=new $t("",this.sourceId,this.head));else{const t=new me;t.name="Head";const i=LA.createPrimitive(bd.Cube);t.add(i),this.gameObject.add(t),this.head=new $t("",this.sourceId,t),rg&&console.log("Create head",t)}if(this.rightHand)this.rightHand instanceof me&&(this.rightHand=new $t("",this.sourceId,this.rightHand));else{const t=new me;t.name="Right Hand",this.gameObject.add(t),this.rightHand=new $t("",this.sourceId,t),rg&&console.log("Create right hand",t)}if(this.leftHand)this.leftHand instanceof me&&(this.leftHand=new $t("",this.sourceId,this.leftHand));else{const t=new me;t.name="Left Hand",this.gameObject.add(t),this.leftHand=new $t("",this.sourceId,t),rg&&console.log("Create left hand",t)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),Jo.isLocalPlayer(this.gameObject)&&(this._syncTransforms=oe.getComponentsInChildren(this.gameObject,Gh))}async loadAvatarObjects(t,i,n){const r=t.loadAssetAsync(),o=i.loadAssetAsync(),a=n.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await wA(l);rg&&console.log("Avatar loaded results:",c)}}LR([x($t)],kd.prototype,"head",2);LR([x($t)],kd.prototype,"leftHand",2);LR([x($t)],kd.prototype,"rightHand",2);class _l{static Add(e,t,i=null){if(t){for(const n of this.Pois)if(n.obj===t)return;this.Pois.push({obj:t,avatar:i}),this.LastChangeTime=e.time.time}}static Remove(e,t){var i;if(t){for(const n of this.Pois)if(n.obj===t){this.Pois.splice(this.Pois.indexOf(n),1),this.LastChangeTime=(e==null?void 0:e.time.time)??((i=Lt.Current)==null?void 0:i.time.time);return}}}}h(_l,"Pois",[]),h(_l,"LastChangeTime",0);class Fne{constructor(){h(this,"guid");h(this,"position",new w)}}class Zv extends Me{constructor(){super(...arguments);h(this,"target",null);h(this,"avatar",null);h(this,"_model",null);h(this,"_targetModel",new Fne);h(this,"_currentTargetObject",null);h(this,"_lastUpdateTime",0);h(this,"_lookDuration",0);h(this,"_lastPoiChangedTime",0)}set controlledTarget(t){this.target=t;const i=J.get("MoveRandom");if(i&&this.target){const n=oe.getComponent(this.target,i);n&&n.destroy()}}awake(){if(this.avatar=oe.getComponentInParent(this.gameObject,Jn),this.avatar){const t=oe.getComponentInParent(this.gameObject,Jn);this._model=new SR(this.context.connection,this.guid),t!=null&&t.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",t=>{var i;this.target&&t&&t.guid===((i=this.avatar)==null?void 0:i.guid)&&rr(this.target,t.position)})}update(){var i;if((!this.context.connection.isConnected||(i=this._model)!=null&&i.hasOwnership)&&(_l.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=_l.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const n=Nt(this._currentTargetObject);rr(this.target,n),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(n))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const i=_l.Pois;if(i.length>0){const n=i[Math.floor(Math.random()*i.length)];if(n&&n.obj){if(n.avatar&&n.avatar===this.avatar)return;this._currentTargetObject=n.obj}}}}}const lp=ne("debugnetworkingstreams");var pl=(s=>(s.Connected="peer-user-connected",s.StreamReceived="receive-stream",s.StreamEnded="call-ended",s.Disconnected="peer-user-disconnected",s.UserJoined="user-joined",s))(pl||{});class fG{constructor(e,t){h(this,"type","call-ended");h(this,"userId");h(this,"direction");this.userId=e,this.direction=t}}class pG{constructor(e,t){h(this,"type","receive-stream");h(this,"stream");h(this,"target");this.stream=e,this.target=t}}class Une{constructor(e,t){h(this,"guid");h(this,"peerId");h(this,"dontSave",!0);this.guid=e.id,this.peerId=t}}var mG=(s=>(s.Incoming="incoming",s.Outgoing="outgoing",s))(mG||{});class Nne extends ps{constructor(t,i,n){super();h(this,"userId");h(this,"direction");h(this,"call");h(this,"_stream",null);h(this,"_isDisposed",!1);this.userId=t,this.call=i,this.direction=n,this._stream=null,i.on("stream",r=>{if(lp&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,n==="incoming"){const o=new pG(r,this);this.dispatchEvent(o)}}),i.on("close",()=>{this.dispatchEvent(new fG(t,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),mc(this._stream))}get isOpen(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connected"}get isOpening(){var t;return((t=this.call.peerConnection)==null?void 0:t.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const fp=class extends ps{constructor(t,i){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=t,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,i){if(fp.instances.has(i))return fp.instances.get(i);const n=new fp(t,i);return fp.instances.set(i,n),n}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,i){var o;const n={metadata:{userId:this.context.connection.connectionId}},r=(o=this._peer)==null?void 0:o.call(t,i,n);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(ii.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(ii.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=l4(t):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(t){lp&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new Une(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,i){const n=t.metadata;(!n||!n.userId)&&console.error("Missing call metadata",t);const r=n.userId;i==="incoming"&&lp?console.log("Receive call from",t.metadata):lp&&console.log("Make call to",t.metadata);const o=i==="incoming"?this._incomingCalls:this._outgoingCalls,a=new Nne(r,t,i);return o.push(a),t.on("error",l=>{console.error("Call error",l)}),t.on("close",()=>{lp&&console.log("Call ended",t.metadata),t.close();const l=o.indexOf(a);l!==-1&&o.splice(l,1)}),a.addEventListener("call-ended",l=>{this.dispatchEvent(l)}),i==="incoming"&&(a.addEventListener("receive-stream",l=>{this.dispatchEvent(l)}),t.on("stream",()=>{let l=0;const c=setInterval(()=>{const u=l===0;!a.isOpen&&u&&(l+=1,clearInterval(c),a.close())},2e3)})),a}};let xp=fp;h(xp,"instances",new Map);class JA extends ps{constructor(t,i){super();h(this,"context");h(this,"peer");h(this,"_sendingStreams",new Map);h(this,"debug",!1);h(this,"onJoinedRoom",t=>{this.debug&&console.log(`${t.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});h(this,"onReceiveStream",t=>{this.debug&&console.log("RECEIVE STREAM",t),this.dispatchEvent({type:"receive-stream",target:this,stream:t.stream,userId:t.userId})});h(this,"onCallEnded",t=>{this.dispatchEvent(t)});h(this,"onUserConnected",t=>{if(this.peer.id===t.guid){this.debug&&console.log("USER CONNECTED",t.guid,t);const i=this._sendingStreams.keys().next().value;this.peer.makeCall(t.peerId,i)}});h(this,"onUserLeft",t=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=t,this.peer=i,lp&&(this.debug=!0)}static create(t){const i=xp.getOrCreate(t.context,t.context.connection.connectionId);return new JA(t.context,i)}startSendingStream(t){this._sendingStreams.has(t)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(t,[]),this.updateSendingCalls())}stopSendingStream(t){if(t){const i=this._sendingStreams.get(t);if(i){this.debug&&console.log("Closing calls",i);for(const n of i)n.close()}this._sendingStreams.delete(t),i&&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(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(ii.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(ii.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(ii.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var n;let t=!1;const i=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const o=this._sendingStreams.get(r)||[];for(const a of this.context.connection.usersInRoom()){if(a===i)continue;const l=o.find(c=>c.userId===a);if(!l||((n=l.stream)==null?void 0:n.active)===!1){this.debug&&console.log("Starting call to",a,i);const c=this.peer.makeCall(this.peer.getPeerIdFromUserId(a),r);c&&(t=!0,o.push(c))}}this._sendingStreams.set(r,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const t of this._sendingStreams.keys()){const i=this._sendingStreams.get(t);if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];this.context.connection.userIsInRoom(r.userId)||(r.close(),i.splice(n,1))}}}}function mc(s){if(s&&s instanceof MediaStream)for(const e of s.getTracks())e.stop()}var zne=Object.defineProperty,Gne=Object.getOwnPropertyDescriptor,gG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&zne(e,t,n),n};const Hne="noVoip",Qne=ne("debugvoip");class Fd extends Me{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 Pa(300),this.autoConnect&&!this.isSending&&this.connect()});h(this,"_incomingStreams",new Map);h(this,"onReceiveStream",t=>{const i=t.target.userId,n=t.stream,r=this._incomingStreams.get(i);if(r)r.srcObject=n,r.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(i,o),o.setAttribute("autoplay","true"),o.srcObject=n}});h(this,"onStreamEnded",t=>{const i=this._incomingStreams.get(t.userId);mc(i==null?void 0:i.srcObject),this._incomingStreams.delete(t.userId)});h(this,"onEnabledChanged",()=>{for(const t of this._incomingStreams){const i=t[1];i.muted=!this.enabled}});h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const i=!(document.visibilityState==="visible");this.setMuted(i);for(const n of this._incomingStreams){const r=n[1];r.muted=i}})}awake(){Qne&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async t=>{t.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=JA.create(this)),this._net.addEventListener(pl.StreamReceived,this.onReceiveStream),this._net.addEventListener(pl.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(ii.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var t;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(pl.StreamReceived,this.onReceiveStream),this._net.removeEventListener(pl.StreamEnded,this.onStreamEnded),(t=this._net)==null||t.disable(),this.context.connection.stopListen(ii.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(t){if(this.context.connection.isConnected){if(!await D1())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),mc(this._outputStream),this._outputStream=await this.getAudioStream(t),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await D1()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):QI("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),mc(this._outputStream),this._outputStream=null}setMuted(t){var n;const i=(n=this._outputStream)==null?void 0:n.getAudioTracks();if(i)for(const r of i)r.enabled=!t}get isMuted(){var i;if(this._outputStream===null)return!1;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t){for(const n of t)if(!n.enabled)return!0}return!1}getFrequency(t){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,gt()&&dn("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(t){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:t??!0,video:!1}).catch(n=>(console.warn("VOIP failed getting audio stream",n),null)):(console.error("No getDisplayMedia support"),null)}}gG([x()],Fd.prototype,"autoConnect",2);gG([x()],Fd.prototype,"runInBackground",2);var Vne=Object.defineProperty,Wne=Object.getOwnPropertyDescriptor,vG=(s,e,t,i)=>{for(var n=i>1?void 0:i?Wne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Vne(e,t,n),n};const jne=ne("debugmouth");class KA extends Me{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=oe.findObjectOfType(Fd,this.context),this.marker||(this.marker=oe.getComponentInParent(this.gameObject,Jn))},3e3)}update(){var n;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((n=this.marker)==null?void 0:n.connectionId)??null;if(!t){jne&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(n=>n.visible=!1):this.talking.map(n=>n.visible=!1);for(let n=0;n<t.length;n++){const r=t[n];r&&(r.visible=n===i)}}}}vG([x(me)],KA.prototype,"idle",2);vG([x(me)],KA.prototype,"talking",2);class kR extends Me{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=oe.findObjectOfType(Fd,this.context),this.marker=oe.getComponentInParent(this.gameObject,Jn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const n=i/100;this.gameObject.position.y=this._startPosition.y+n*.07}}var qne=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,kw=(s,e,t,i)=>{for(var n=i>1?void 0:i?Xne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&qne(e,t,n),n};class Ud extends Me{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=oe.getComponentInParent(this.gameObject,uo)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(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 i of this.eyes)i&&(i.visible=this.eyesOpen)}}}kw([x(me)],Ud.prototype,"eyes",2);kw([x()],Ud.prototype,"lastBlinkTime",2);kw([x()],Ud.prototype,"blinkLength",2);kw([x()],Ud.prototype,"eyesOpen",2);var Yne=Object.defineProperty,Jne=Object.getOwnPropertyDescriptor,FR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Jne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Yne(e,t,n),n},NE;const AG=(NE=class extends Me{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=oe.getComponentInParent(this.gameObject,Zv)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=oe.addNewComponent(this.gameObject,Zv)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=Nt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const n=Nt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(n).normalize();if(r.length()<.1)return;const o=AG.forward;if(o.set(0,0,1),o.applyQuaternion(Ii(this.head)),o.dot(r)>.45)for(let l=0;l<t.length;l++)t[l].lookAt(this.currentTargetPoint)}}}},h(NE,"forward",new w(0,0,1)),NE);let dm=AG;FR([x(me)],dm.prototype,"head",2);FR([x(me)],dm.prototype,"eyes",2);FR([x(me)],dm.prototype,"target",2);const og=ne("debugavatar");class Fw{constructor(e,t,i,n){h(this,"root");h(this,"head");h(this,"leftHand");h(this,"rigthHand");var r;this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,(r=this.root)==null||r.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class UR{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 i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const r=new Ua;i=oe.instantiate(Dp(t,e.scene),r)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(og&&console.log("[Custom Avatar] valid config",t,og?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,og?n:""),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(og&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let r=null;if(n.ok){const a=await n.blob();a&&(r=await a.arrayBuffer())}if(!r&&(r=await dR(t,t,0,"no url here go away",!0),!r))return null;const o=await Ra().parseSync(e,r,null,0);return(o==null?void 0:o.scene)??null}const i=new em;return IA(i,e),new Promise((n,r)=>{const o=this.avatarRegistryUrl+"/"+t;i.load(o,async a=>{await Ra().createBuiltinComponents(e,o,a,null,void 0),n(a.scene)},a=>{og&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const r=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new w;new Ai().setFromObject(n).getSize(l);const c=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+c+" meters! Should be < 0.3m"),c>.3&&n.scale.multiplyScalar(1/c*.3)}return new Fw(t,n,r,o)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const r of t){if(!n)break;i.indexOf(r)===-1&&(n=!1)}if(n)return e;if(e.children)for(const r of e.children){const o=this.findAvatarPart(r,t);if(o)return o}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}var Kne=Object.defineProperty,Zne=Object.getOwnPropertyDescriptor,NR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Zne(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Kne(e,t,n),n};class fm extends Me{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!BA)return;this._axes||(this._axes=new ea(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}NR([x()],fm.prototype,"length",2);NR([x()],fm.prototype,"depthTest",2);NR([x()],fm.prototype,"isGizmo",2);class zR extends Me{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 t=Nt(this.to).clone(),i=Nt(this.from).clone(),n=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=Nt(this.hint).clone();a.sub(o);const l=new w;l.crossVectors(a,r),l.crossVectors(r,l),l.normalize();const c=n*.5,u=Math.max(this.desiredDistance,c),d=Math.sqrt(u*u-c*c),f=l.clone();f.multiplyScalar(d),f.add(o),rr(this.gameObject,f);const p=o.clone();p.sub(l),this.gameObject.lookAt(p)}}const eE=ne("debugusdzbehaviours");class Uw{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(i=>{oe.foreachComponent(i,n=>{var o;const r=n;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),eE&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(t)}onExportObject(e,t,i){var n;for(const r of this.behaviourComponents)eE&&console.log("onExportObject: createBehaviours",r),(n=r.createBehaviours)==null||n.call(r,this,t,i)}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 i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const n of this.behaviours)n.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){eE&&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 $ne=Object.defineProperty,ese=Object.getOwnPropertyDescriptor,GR=(s,e,t,i)=>{for(var n=i>1?void 0:i?ese(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&$ne(e,t,n),n},zE;const yG=(zE=class extends lr{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=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom==null&&(this.selectiveBloom=yG.useSelectiveBloom),this.selectiveBloom){const t=e=new Z3(this.context.scene,this.context.mainCamera,{blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new lR({blendFunction:Vt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}},h(zE,"useSelectiveBloom",!1),zE);let Nd=yG;GR([x(kt)],Nd.prototype,"threshold",2);GR([x(kt)],Nd.prototype,"intensity",2);GR([x(kt)],Nd.prototype,"scatter",2);la("Bloom",Nd);const jf="NEEDLE_progressive",Ks=ne("debugprogressive"),tE=Symbol("needle-progressive-texture"),wp=new Map;if(Ks){let s=function(){e+=1,tn(`Toggle LOD level: ${e}<br/>Registered objects: ${wp.size}`),console.log("Toggle LOD level",e,wp);const i=ri.Current;wp.forEach((n,r)=>{for(const o of n.keys){const a=r[o];if(a instanceof At){const l=Ti.getMeshLODInformation(a),c=l?Math.min(e,l.lods.length):0;r["DEBUG:LOD"]=c,Ti.assignMeshLOD(i,n.sourceId,r,c),l&&(t=Math.max(t,l.lods.length-1))}else if(r instanceof Ot){Ti.assignTextureLOD(i,n.sourceId,r,e);break}}}),e>=t&&(e=-1)},e=-1,t=2;window.addEventListener("keyup",i=>{i.key==="p"&&s()}),ri.registerCallback(bn.ContextCreated,i=>{const n=document.createElement("button");n.innerText="Toggle Progressive",n.onclick=s,i.context.menu.appendChild(n)})}function $O(s,e,t){var n;if(!Ks)return;wp.has(s)||wp.set(s,{keys:[],sourceId:t});const i=wp.get(s);((n=i==null?void 0:i.keys)==null?void 0:n.includes(e))==!1&&i.keys.push(e)}const zr=class{constructor(e,t,i){h(this,"parser");h(this,"sourceId");h(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return jf}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static hasLODLevelAvailable(e,t){var r;if(e instanceof Ot){for(const o of Object.keys(e)){const a=e[o];if(a instanceof _t&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e instanceof Er){for(const o of e.children)if(o instanceof de&&this.hasLODLevelAvailable(o,t))return!0}let i,n;if(e instanceof de?i=e.geometry:e instanceof _t&&(i=e),i&&(r=i==null?void 0:i.userData)!=null&&r.LODS){const o=i.userData.LODS;if(n=this.lodInfos.get(o.key),t===void 0)return n!=null;if(n)return Array.isArray(n.lods)?t<n.lods.length:t===0}return!1}static assignMeshLOD(e,t,i,n){if(!i)return Promise.resolve(null);if(i instanceof de){const r=i.geometry,o=this.getAssignedLODInformation(r);if(!o)return Promise.resolve(null);jv(i)||q_(i,i.geometry);const a=this.onProgressiveLoadStart(e,t,i,null);return i["LOD:requested level"]=n,zr.getOrLoadLOD(e,t,r,n).then(l=>{if(i["LOD:requested level"]===n){if(delete i["LOD:requested level"],Array.isArray(l)){const c=o.index||0;l=l[c]}l&&r!=l&&(Ks=="verbose"&&console.log("Progressive Mesh "+i.name+" loaded",r,"→",l,`
|
|
5509
5509
|
`,i),l instanceof At&&(i.geometry=l,Ks&&$O(i,"geometry",t)))}return this.onProgressiveLoadEnd(a),l}).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading mesh LOD",i,l),null))}else Ks&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",i);return Promise.resolve(null)}static assignTextureLOD(e,t,i,n=0){if(!i)return Promise.resolve(null);if(i instanceof Ot){const r=i,o=[],a=new Array;if(r instanceof yA)for(const l of Object.keys(r.uniforms)){const c=r.uniforms[l].value;if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}else for(const l of Object.keys(r)){const c=r[l];if(c instanceof _t){const u=this.assignTextureLODForSlot(e,t,c,n,r,l);o.push(u),a.push(l)}}return wA(o).then(l=>{const c=new Array;for(let u=0;u<l.results.length;u++){const d=l.results[u],f=a[u];d instanceof _t?c.push({material:r,slot:f,texture:d,level:n}):c.push({material:r,slot:f,texture:null,level:n})}return c})}if(i instanceof _t){const r=i;return this.assignTextureLODForSlot(e,t,r,n,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,n,r,o){if((i==null?void 0:i.isTexture)!==!0)return Promise.resolve(null);const a=this.onProgressiveLoadStart(e,t,r,o);return zr.getOrLoadLOD(e,t,i,n).then(l=>Array.isArray(l)?null:(l==null?void 0:l.isTexture)===!0?(l!=i&&(r&&o&&(r[o]=l),Ks&&o&&r&&$O(r,o,t)),this.onProgressiveLoadEnd(a),l):(Ks=="verbose"&&console.warn("No LOD found for",i,n),this.onProgressiveLoadEnd(a),null)).catch(l=>(this.onProgressiveLoadEnd(a),console.error("Error loading LOD",i,l),null))}afterRoot(e){var i,n;Ks&&console.log("AFTER",this.sourceId,e),(i=this.parser.json.textures)==null||i.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a){for(const l of this.parser.associations.keys())if(l instanceof _t&&this.parser.associations.get(l).textures===o){const u=l;Ks&&console.log("> Progressive: register texture",o,u.name,u.uuid,u,a),u.source&&(u.source[tE]=a);const d=u.uuid;zr.assignLODInformation(u,d,0,0,void 0),zr.lodInfos.set(d,a),zr.lowresCache.set(d,u)}}}});const t=(r,o,a,l,c)=>{const u=o.geometry;u["needle:raycast-mesh"]=!0,u&&!jv(o)&&(Ks&&console.log("Set raycast mesh",o.name,o.uuid,u),q_(o,u),dw(u,!0).forEach(d=>{d instanceof de&&q_(d,u)})),u.userData||(u.userData={}),zr.assignLODInformation(u,r,a,l,c.density),zr.lodInfos.set(r,c)};return(n=this.parser.json.meshes)==null||n.forEach((r,o)=>{if(r!=null&&r.extensions){const a=r==null?void 0:r.extensions[jf];if(a&&a.lods){for(const l of this.parser.associations.keys())if(l instanceof de){const c=this.parser.associations.get(l);if(c.meshes===o){const u=l;Ks&&console.log("> Progressive: register mesh",o,u.name,a,u.uuid,u);const d=u.uuid,f=a.lods.length;if(u instanceof de){t(d,u,f,c.primitives,a);let p=zr.lowresCache.get(d);p?p.push(u.geometry):p=[u.geometry],zr.lowresCache.set(d,p)}}}}}}),null}static async getOrLoadLOD(e,t,i,n){var c,u,d;const r=Ks=="verbose",o=i.userData.LODS;if(!o)return null;const a=o==null?void 0:o.key;let l;if(i instanceof _t&&i.source&&i.source[tE]&&(l=i.source[tE]),l||(l=zr.lodInfos.get(a)),l){if(n>0){let m=!1;const A=Array.isArray(l.lods);if(A&&n>=l.lods.length?m=!0:A||(m=!0),m)return this.lowresCache.get(a)}const f=Array.isArray(l.lods)?l.lods[n].path:l.lods;if(!f)return Ks&&!l["missing:uri"]&&(l["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+n,l)),null;let p=Tc(t,f);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!l.guid)return console.warn("missing pointer for glb/gltf texture",l),null;const m=p+"_"+l.guid,A=this.previouslyLoaded.get(m);if(A!==void 0){r&&console.log(`LOD ${n} was already loading/loaded: ${m}`);let y=await A.catch(M=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5510
5510
|
`,M),null)),b=!1;if(y==null||(y instanceof _t&&i instanceof _t?(c=y.image)!=null&&c.data||(u=y.source)!=null&&u.data?y=this.copySettings(i,y):(b=!0,this.previouslyLoaded.delete(m)):y instanceof At&&i instanceof At&&((d=y.attributes.position)!=null&&d.array||(b=!0,this.previouslyLoaded.delete(m)))),!b)return y}const g=l,v=new Promise(async(y,b)=>{const M=new em;if(IA(M,e),l&&Array.isArray(l.lods)){const P=l.lods[n];P.hash&&(p+="?v="+P.hash)}Ks&&(await Pa(Math.random()*1e3),r&&console.warn("Start loading (delayed) "+p,g.guid));const E=await M.loadAsync(p).catch(P=>(console.error(`Error loading LOD ${n} from ${p}
|
|
5511
5511
|
`,P),null));if(!E)return null;const T=E.parser;r&&console.log("Loading finished "+p,g.guid);let C=0;if(E.parser.json.textures){let P=!1;for(const S of E.parser.json.textures){if(S!=null&&S.extensions){const I=S==null?void 0:S.extensions[jf];if(I!=null&&I.guid&&I.guid===g.guid){P=!0;break}}C++}if(P){let S=await T.getDependency("texture",C);return r&&console.log('change "'+i.name+'" → "'+S.name+'"',p,C,S,m),i instanceof _t&&(S=this.copySettings(i,S)),S&&(S.guid=g.guid),y(S)}}if(C=0,E.parser.json.meshes){let P=!1;for(const S of E.parser.json.meshes){if(S!=null&&S.extensions){const I=S==null?void 0:S.extensions[jf];if(I!=null&&I.guid&&I.guid===g.guid){P=!0;break}}C++}if(P){const S=await T.getDependency("mesh",C),I=g;if(r&&console.log(`Loaded Mesh "${S.name}"`,p,C,S,m),S instanceof de){const H=S.geometry;return zr.assignLODInformation(H,a,n,void 0,I.density),y(H)}else{const H=new Array;for(let U=0;U<S.children.length;U++){const D=S.children[U];if(D instanceof de){const V=D.geometry;zr.assignLODInformation(V,a,n,U,I.density),H.push(V)}}return y(H)}}}return y(null)});return this.previouslyLoaded.set(m,v),await v}else if(i instanceof _t){r&&console.log("Load texture from uri: "+p);const A=await new Al().loadAsync(p);return A?(A.guid=l.guid,A.flipY=!1,A.needsUpdate=!0,A.colorSpace=i.colorSpace,r&&console.log(l,A)):Ks&&console.warn("failed loading",p),A}}else Ks&&console.warn(`Can not load LOD ${n}: no LOD info found for "${a}" ${i.name}`,i.type);return null}static assignLODInformation(e,t,i,n,r){if(!e)return;e.userData||(e.userData={});const o=new tse(t,i,n,r);e.userData.LODS=o,e.userData.LOD=i}static getAssignedLODInformation(e){var t;return((t=e==null?void 0:e.userData)==null?void 0:t.LODS)||null}static copySettings(e,t){const i=this._copiedTextures.get(e);return i||(t=t.clone(),this._copiedTextures.set(e,t),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t)}static beginListenStart(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new eL),this._progressiveEventListeners.get(e).start.push(t)}static stopListenStart(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).start,n=i.indexOf(t);n>=0&&i.splice(n,1)}static beginListenEnd(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new eL),this._progressiveEventListeners.get(e).end.push(t)}static stopListenEnd(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).end,n=i.indexOf(t);n>=0&&i.splice(n,1)}static onProgressiveLoadStart(e,t,i,n){this._currentProgressiveLoadingInfo.has(e)||this._currentProgressiveLoadingInfo.set(e,[]);const r=new _G(e,t,i,n),o=this._currentProgressiveLoadingInfo.get(e),a=this._progressiveEventListeners.get(e);return a&&a.onStart(r),o.push(r),r}static onProgressiveLoadEnd(e){if(!e)return;const t=e.context;if(!this._currentProgressiveLoadingInfo.has(t))return;const i=this._currentProgressiveLoadingInfo.get(t),n=i.indexOf(e);if(n<0)return;i.splice(n,1);const r=this._progressiveEventListeners.get(t);r&&r.onEnd(e)}};let Ti=zr;h(Ti,"lodInfos",new Map),h(Ti,"previouslyLoaded",new Map),h(Ti,"lowresCache",new Map),h(Ti,"_copiedTextures",new Map),h(Ti,"_progressiveEventListeners",new Map),h(Ti,"_currentProgressiveLoadingInfo",new Map);class tse{constructor(e,t,i,n){h(this,"key");h(this,"level");h(this,"index");h(this,"density");this.key=e,this.level=t,i!=null&&(this.index=i),n!=null&&(this.density=n)}}class _G{constructor(e,t,i,n){h(this,"context");h(this,"source");h(this,"material");h(this,"slot");h(this,"mesh");this.context=e,this.source=t,i instanceof de?this.mesh=i:this.material=i,this.slot=n}}class eL{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 ise=Object.defineProperty,nse=Object.getOwnPropertyDescriptor,Yr=(s,e,t,i)=>{for(var n=i>1?void 0:i?nse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&ise(e,t,n),n};class Io extends Me{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 t;(t=this.context.physics.engine)==null||t.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Pi))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}get body(){var t;return(t=this.context.physics.engine)==null?void 0:t.getBody(this)}updatePhysicsMaterial(){var t;(t=this.context.physics.engine)==null||t.updatePhysicsMaterial(this)}}Yr([x(Pi)],Io.prototype,"attachedRigidbody",2);Yr([x()],Io.prototype,"isTrigger",2);Yr([x()],Io.prototype,"sharedMaterial",2);Yr([x()],Io.prototype,"membership",2);Yr([x()],Io.prototype,"filter",2);class pm extends Io{constructor(){super(...arguments);h(this,"radius",.5);h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this),tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),cI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Yr([Hs(),x()],pm.prototype,"radius",2);Yr([x(w)],pm.prototype,"center",2);class mm extends Io{constructor(){super(...arguments);h(this,"size",new w(1,1,1));h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.size),tw(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),cI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Yr([Hs(),x(w)],mm.prototype,"size",2);Yr([x(w)],mm.prototype,"center",2);class zd extends Io{constructor(){super(...arguments);h(this,"sharedMesh");h(this,"convex",!1)}onEnable(){var i,n,r;if(super.onEnable(),!this.context.physics.engine)return;(i=this.sharedMesh)!=null&&i.isMesh||this.gameObject instanceof de&&(this.sharedMesh=this.gameObject);const t=0;if((n=this.sharedMesh)!=null&&n.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Hi(this.gameObject)),Ti.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,t).then(o=>{o&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=o,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Hi(this.gameObject)))});else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((r=this.sharedMesh)==null?void 0:r.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 a=new Array;for(const l in o.children){const c=o.children[l];c.isMesh&&(this.context.physics.engine.addMeshCollider(this,c,this.convex,Hi(this.gameObject)),a.push(Ti.assignMeshLOD(this.context,this.sourceId,c,t)))}Promise.all(a).then(l=>{var u,d;if(l.some(f=>f)==!1)return;(u=this.context.physics.engine)==null||u.removeBody(this);const c=new de;for(const f of l)f&&this.activeAndEnabled&&(c.geometry=f,(d=this.context.physics.engine)==null||d.addMeshCollider(this,c,this.convex,Hi(this.gameObject)))})}}}}Yr([x(de)],zd.prototype,"sharedMesh",2);Yr([x()],zd.prototype,"convex",2);class Cc extends Io{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.height,this.radius)}}Yr([x(w)],Cc.prototype,"center",2);Yr([x()],Cc.prototype,"radius",2);Yr([x()],Cc.prototype,"height",2);var sse=Object.defineProperty,rse=Object.getOwnPropertyDescriptor,HR=(s,e,t,i)=>{for(var n=i>1?void 0:i?rse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&sse(e,t,n),n};class Gd extends Me{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&&!BA||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new rI(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=pR(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),ji.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var t;for(;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}HR([x()],Gd.prototype,"objectBounds",2);HR([x(xe)],Gd.prototype,"color",2);HR([x()],Gd.prototype,"isGizmo",2);const ose=ne("gizmos"),ase=ne("debugboxhelper"),zo=class extends Me{constructor(){super(...arguments);h(this,"box",null);h(this,"_lastMatrixUpdateFrame",-1);h(this,"_helper",null);h(this,"_color",null)}isInBox(t,i){var r;if(!t)return;if(this.box||(this.box=new Ai),t.type==="Mesh")zo.testBox.setFromObject(t);else if(t.type==="Group"){if(zo.testBox.makeEmpty(),t.children.length>0)for(let o=0;o<t.children.length;o++)t.children[o].type==="Mesh"&&zo.testBox.expandByObject(t)}else{const o=Nt(t,zo._position),a=Hi(t,zo._size);i!==void 0&&a.multiplyScalar(i),zo.testBox.setFromCenterAndSize(o,a)}this.updateBox();const n=(r=this.box)==null?void 0:r.intersectsBox(zo.testBox);return n&&ase&&bt.DrawWireBox3(zo.testBox,16711680,5),n}intersects(t){return t?this.updateBox(!1).intersectsBox(t):!1}updateBox(t=!1){if(this.box||(this.box=new Ai),t||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const i=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const n=i,r=Nt(this.gameObject,zo._position,n),o=Hi(this.gameObject,zo._size);this.box.setFromCenterAndSize(r,o)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(t=null,i=!1){var n;if(!(!ose&&!i)){if(this._helper){t&&((n=this._color)==null||n.set(t)),this.gameObject.add(this._helper);return}this._helper=pR(t),this.gameObject.add(this._helper)}}};let Yo=zo;h(Yo,"testBox",new Ai),h(Yo,"_position",new w),h(Yo,"_size",new w(.01,.01,.01));class lse extends UN{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const n in t[i])e._simpleState__statesProperties[n]||(e._simpleState__statesProperties[n]=[]),e._simpleState__statesProperties[n].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._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 i=[];for(const n in t)this._simpleState__statesProperties[n]||(this._simpleState__statesProperties[n]=[],i.push(n)),this._simpleState__statesProperties[n].push(e);for(const n of this._components)i.indexOf(n.id)>-1&&(this._simpleState__normalStyles[n.id]=n.inline?n.inline:n._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 i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);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 cse=Object.defineProperty,hse=Object.getOwnPropertyDescriptor,bG=(s,e,t,i)=>{for(var n=i>1?void 0:i?hse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&cse(e,t,n),n};class gm extends Me{constructor(){super(...arguments);h(this,"effectColor");h(this,"effectDistance")}}bG([x(wi)],gm.prototype,"effectColor",2);bG([x(te)],gm.prototype,"effectDistance",2);var use=Object.defineProperty,dse=Object.getOwnPropertyDescriptor,ZA=(s,e,t,i)=>{for(var n=i>1?void 0:i?dse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&use(e,t,n),n};const iE=ne("debugui"),nE=ne("debuguilayout");class QR{constructor(){h(this,"width");h(this,"height")}}class VR{constructor(){h(this,"x");h(this,"y");h(this,"width");h(this,"height")}}const ga=new w,ag=new we,J0=new Ce,xG=class extends Oa{constructor(){super(...arguments);h(this,"_anchoredPosition");h(this,"sizeDelta",new te(100,100));h(this,"pivot",new te(.5,.5));h(this,"anchorMin",new te(0,0));h(this,"anchorMax",new te(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 te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){let e=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const t=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;e=t*i,e+=this.sizeDelta.x}return this.minWidth!==void 0&&e<this.minWidth?this.minWidth:e}get height(){let e=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const t=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;e=t*i,e+=this.sizeDelta.y}return this.minHeight!==void 0&&e<this.minHeight?this.minHeight:e}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new we,this.rectBlock=new me,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Vf(this,"_anchoredPosition",()=>{this.markDirty()}),Vf(this,"sizeDelta",()=>{this.markDirty()}),Vf(this,"pivot",()=>{this.markDirty()}),Vf(this,"anchorMin",()=>{this.markDirty()}),Vf(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(nE?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(nE&&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(e){var n;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=oe.getComponentInParent(this.gameObject.parent,xG):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,nE&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,ga.set(0,0,0),this.applyPivot(ga),t.matrix.setPosition(ga.x,ga.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(J0.copy(this.gameObject.quaternion),J0.x*=-1,J0.z*=-1,ag.makeRotationFromQuaternion(J0),t.matrix.premultiply(ag)),ga.set(0,0,0),this.applyAnchoring(ga),(n=this.Canvas)!=null&&n.screenspace?ga.z+=.1:ga.z+=.01,ag.identity(),ag.setPosition(ga.x,ga.y,ga.z),t.matrix.premultiply(ag),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of MR(this.gameObject,Oa,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let n=0;const r=1-this.anchorMax.y-this.anchorMin.y;n-=i.height*.5*r,e.y+=n;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},iE&&console.log(this.name,e);const t=new OI(e);return this._createdBlocks.push(t),t}createNewText(e){iE&&console.log(e),e={...this.getBasicOptions(),...e},iE&&console.log(this.name,e);const t=new LI(e);return this._createdTextBlocks.push(t),t}};let Or=xG;ZA([x(te)],Or.prototype,"anchoredPosition",1);ZA([x(te)],Or.prototype,"sizeDelta",2);ZA([x(te)],Or.prototype,"pivot",2);ZA([x(te)],Or.prototype,"anchorMin",2);ZA([x(te)],Or.prototype,"anchorMax",2);var fse=Object.defineProperty,pse=Object.getOwnPropertyDescriptor,wG=(s,e,t,i)=>{for(var n=i>1?void 0:i?pse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&fse(e,t,n),n};const K0={backgroundColor:new xe(1,1,1),backgroundOpacity:1,borderColor:new xe(1,1,1),borderOpacity:1};var GE;const tb=(GE=class extends Oa{constructor(){super(...arguments);h(this,"_alphaFactor",1);h(this,"sRGBColor",new xe(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 wi(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new wi(1,1,1,1)),this._color.copy(e),this.onColorChanged())}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),K0.backgroundColor=this.sRGBColor,K0.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(K0,this._alphaFactor),this.uiObject.set(K0),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=oe.getComponent(this.gameObject,Or)),!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 e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(e){return super.__internalNewInstanceCreated(e),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new lse(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Vf(this,"_color",()=>Gie(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.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 e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var n;const i=(n=this.gameObject)==null?void 0:n.getComponent(gm);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(tb.textureCache.has(e))e=tb.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=yi,tb.textureCache.set(e,t),e=t}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Ti.assignTextureLOD(this.context,this.sourceId,e,0).then(t=>{t instanceof _t&&this.setOptions({backgroundImage:t})})}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(GE,"textureCache",new Map),GE);let Hd=tb;wG([x(wi)],Hd.prototype,"color",1);wG([x()],Hd.prototype,"raycastTarget",2);class $A extends Hd{constructor(){super(...arguments);h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,Nw=(s,e,t,i)=>{for(var n=i>1?void 0:i?gse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&mse(e,t,n),n};let WR=class{constructor(){h(this,"texture",null);h(this,"rect")}};Nw([x(_t)],WR.prototype,"texture",2);let vm=class extends $A{constructor(){super(...arguments);h(this,"_sprite");h(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new WR),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var i,n,r,o,a,l,c;const t=this.sprite;switch((i=t==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((r=(n=t==null?void 0:t.texture)==null?void 0:n.name)!=null&&r.length)&&((a=(o=t==null?void 0:t.texture)==null?void 0:o.image)==null?void 0:a.width)===32&&((c=(l=t==null?void 0:t.texture)==null?void 0:l.image)==null?void 0:c.height)===32}onBeforeCreate(t){var i,n;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((n=(i=this.sprite)==null?void 0:i.texture)==null?void 0:n.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Nw([x(WR)],vm.prototype,"sprite",1);Nw([x()],vm.prototype,"pixelsPerUnitMultiplier",2);class zw extends $A{constructor(){super(...arguments);h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Nw([x(_t)],zw.prototype,"mainTexture",1);var vse=Object.defineProperty,Ase=Object.getOwnPropertyDescriptor,Ro=(s,e,t,i)=>{for(var n=i>1?void 0:i?Ase(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&vse(e,t,n),n};const wu=ne("debugbutton");class Yh{constructor(){h(this,"colorMultiplier");h(this,"disabledColor");h(this,"fadeDuration");h(this,"highlightedColor");h(this,"normalColor");h(this,"pressedColor");h(this,"selectedColor")}}Ro([x()],Yh.prototype,"colorMultiplier",2);Ro([x(wi)],Yh.prototype,"disabledColor",2);Ro([x()],Yh.prototype,"fadeDuration",2);Ro([x(wi)],Yh.prototype,"highlightedColor",2);Ro([x(wi)],Yh.prototype,"normalColor",2);Ro([x(wi)],Yh.prototype,"pressedColor",2);Ro([x(wi)],Yh.prototype,"selectedColor",2);class yse{constructor(){h(this,"disabledTrigger");h(this,"highlightedTrigger");h(this,"normalTrigger");h(this,"pressedTrigger");h(this,"selectedTrigger")}}class Ic extends Me{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(t){var n,r;const i=t.event.pointerType==="mouse"&&t.button===0;i&&(this._isHovered+=1),wu&&console.warn("Button Enter",i,this._isHovered,(n=this.animationTriggers)==null?void 0:n.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((r=this._image)==null||r.setState("hovered")),i&&this.context.input.setCursorPointer())}onPointerExit(){var t,i;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),wu&&console.log("Button Exit",this._isHovered,(t=this.animationTriggers)==null?void 0:t.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&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(t){var i,n;wu&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.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(t){var i,n;wu&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.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(t){if(this.interactable&&!(t.button!==0&&t.event.pointerType===vw.Mouse)&&(wu&&(console.warn("Button Click",this.onClick),tn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),t.use(),wu))){const i=this.gameObject.worldPosition;i.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),bt.DrawLabel(i,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),wu&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable),this.gameObject.getComponentInParent(VA)||this.gameObject.addComponent(Tw)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=oe.getComponent(this.gameObject,vm),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,m,A,g,v;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),n={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(n);const r=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),l={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(l);const c=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.selectedColor),u={state:"selected",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};t.setupState(u);const d=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i).convertLinearToSRGB():t.clone().convertLinearToSRGB()}}Ro([x(es)],Ic.prototype,"onClick",2);Ro([x(Yh)],Ic.prototype,"colors",2);Ro([x()],Ic.prototype,"transition",2);Ro([x(yse)],Ic.prototype,"animationTriggers",2);Ro([x(ks)],Ic.prototype,"animator",2);Ro([x()],Ic.prototype,"interactable",1);var _se=Object.defineProperty,bse=Object.getOwnPropertyDescriptor,Vn=(s,e,t,i)=>{for(var n=i>1?void 0:i?bse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&_se(e,t,n),n};const tL=ne("debuguilayout");class Jh{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}}Vn([x()],Jh.prototype,"left",2);Vn([x()],Jh.prototype,"right",2);Vn([x()],Jh.prototype,"top",2);Vn([x()],Jh.prototype,"bottom",2);class Po extends Me{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(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(tL&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){tL&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Or);const t=this.gameObject.getComponentInParent(Fs);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(Fs);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Vn([x()],Po.prototype,"childAlignment",2);Vn([x()],Po.prototype,"reverseArrangement",2);Vn([x()],Po.prototype,"spacing",2);Vn([x(Jh)],Po.prototype,"padding",2);Vn([x()],Po.prototype,"minWidth",2);Vn([x()],Po.prototype,"minHeight",2);Vn([x()],Po.prototype,"flexibleHeight",2);Vn([x()],Po.prototype,"flexibleWidth",2);Vn([x()],Po.prototype,"preferredHeight",2);Vn([x()],Po.prototype,"preferredWidth",2);class Kh extends Po{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(t){var C;const i=this.primaryAxis,n=t.width;let r=n;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const l=i==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,f=l?this.childForceExpandWidth:this.childForceExpandHeight,p=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:r,A=l?n:o,g=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let v=0;l?v+=this.padding.left:v+=this.padding.top;let _=0,y=0;for(let P=0;P<this.gameObject.children.length;P++){const S=this.gameObject.children[P],I=oe.getComponent(S,Or);I!=null&&I.activeAndEnabled&&(y+=1,l?_+=I.width:_+=I.height)}let b=0;const M=this.spacing*(y-1);if(f||u){let P=0;l?P=r-=M:P=a-=M,y>0&&(b=P/y)}let E=0;E+=this.padding.left,E-=this.padding.right,g!==0&&(v=A-_,v*=g,v-=M*g,l?(v-=this.padding.right*g,v+=this.padding.left*(1-g),v<this.padding.left&&(v=this.padding.left)):(v-=this.padding.bottom*g,v+=this.padding.top*(1-g),v<this.padding.top&&(v=this.padding.top)));let T=1;for(let P=0;P<this.gameObject.children.length;P++){const S=this.gameObject.children[P],I=oe.getComponent(S,Or);if(I!=null&&I.activeAndEnabled){(C=I.pivot)==null||C.set(.5,.5),I.anchorMin.set(0,1),I.anchorMax.set(0,1);const H=n*.5+E*.5;I.anchoredPosition.x!==H&&(I.anchoredPosition.x=H);const U=o*-.5;I.anchoredPosition.y!==U&&(I.anchoredPosition.y=U),p&&d&&I.sizeDelta[c]!==m&&(I.sizeDelta[c]=m),f&&u&&I.sizeDelta[i]!==b&&(I.sizeDelta[i]=b);const D=l?I.width:I.height,V=D*.5;if(v+=V,f){const k=b*T-b*.5;k>v&&(v=k-b*.5+D+this.padding.left,v-=V)}let L=v;i==="y"&&(L=-L),I.anchoredPosition[i]!==L&&(I.anchoredPosition[i]=L),v+=V,v+=this.spacing,T+=1}}}}Vn([x()],Kh.prototype,"childControlHeight",2);Vn([x()],Kh.prototype,"childControlWidth",2);Vn([x()],Kh.prototype,"childForceExpandHeight",2);Vn([x()],Kh.prototype,"childForceExpandWidth",2);Vn([x()],Kh.prototype,"childScaleHeight",2);Vn([x()],Kh.prototype,"childScaleWidth",2);class jR extends Kh{get primaryAxis(){return"y"}}class qR extends Kh{get primaryAxis(){return"x"}}class XR extends Po{onCalculateLayout(){}}var xse=Object.defineProperty,wse=Object.getOwnPropertyDescriptor,Il=(s,e,t,i)=>{for(var n=i>1?void 0:i?wse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&xse(e,t,n),n},SG=(s=>(s[s.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",s[s.ScreenSpaceCamera=1]="ScreenSpaceCamera",s[s.WorldSpace=2]="WorldSpace",s[s.Undefined=-1]="Undefined",s))(SG||{});const sE=ne("debuguilayout"),CG=class extends QA{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 e,t,i,n;if(this.previousParent=this.gameObject.parent,((e=this.context.xr)!=null&&e.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(n=this.shadowComponent)==null||n.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Vr.ensureUpdateMeshUI(j2,this.context))});h(this,"onAfterRenderRoutine",()=>{var e,t,i,n,r;if(((e=this.context.xr)!=null&&e.isVR||(t=this.context.xr)!=null&&t.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const l=this.context.mainCamera;l==null||l.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,a=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(),Vr.ensureUpdateMeshUI(j2,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=a,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(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof CG||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,sE&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new we,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 e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(e){this._receivers.push(e)}unregisterEventReceiver(e){const t=this._receivers.indexOf(e);t!==-1&&this._receivers.splice(t,1)}async onEnterXR(e){this.screenspace?(e.xr.isVR||e.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await UU(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(e){this.screenspace&&(e.xr.isVR||e.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var e;for(const t of this._receivers)(e=t.onBeforeCanvasRender)==null||e.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new we);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);sE&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let n=this._layoutGroups.get(i.gameObject);i.isDirty&&!n&&(n=i.gameObject.getComponentInParent(Po)),(i.isDirty||n!=null&&n.isDirty)&&(sE&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),n==null||n.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),ji.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Zb(this.shadowComponent,this);for(const e of oe.getComponentsInChildren(this.gameObject,Oa))Zb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=et.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const n=i+.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(Or);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(n);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Fs=CG;Il([x()],Fs.prototype,"renderOnTop",1);Il([x()],Fs.prototype,"depthWrite",1);Il([x()],Fs.prototype,"doubleSided",1);Il([x()],Fs.prototype,"castShadows",1);Il([x()],Fs.prototype,"receiveShadows",1);Il([x()],Fs.prototype,"renderMode",1);Il([x(Fs)],Fs.prototype,"rootCanvas",1);Il([x()],Fs.prototype,"scaleFactor",1);Il([x(zi)],Fs.prototype,"worldCamera",2);Il([x()],Fs.prototype,"planeDistance",2);var Sse=Object.defineProperty,Cse=Object.getOwnPropertyDescriptor,YR=(s,e,t,i)=>{for(var n=i>1?void 0:i?Cse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Sse(e,t,n),n};class Qh extends Me{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(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),ji.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const t of oe.getComponentsInChildren(this.gameObject,Oa,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}YR([x()],Qh.prototype,"alpha",1);YR([x()],Qh.prototype,"interactable",2);YR([x()],Qh.prototype,"blocksRaycasts",2);var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,pn=(s,e,t,i)=>{for(var n=i>1?void 0:i?Mse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ese(e,t,n),n};const iL=ne("debugusdzbehaviours");function ey(s){s&&(s.getComponentInParent(VA)||(gt()&&console.warn("Create Raycaster on "+s.name+" because no raycaster was found in the hierarchy"),s.addNewComponent(So)))}class Qd extends Me{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 w);h(this,"targetRot",new Ce);h(this,"targetScale",new w)}start(){ey(this.gameObject)}onPointerClick(t){t.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 t=Nt(this.object).clone(),i=Nt(this.target).clone(),n=Ii(this.object).clone(),r=Ii(this.target).clone(),o=Hi(this.object).clone(),a=Hi(this.target).clone(),l=t.distanceTo(i),c=n.angleTo(r),u=o.distanceTo(a);if(l<.01&&c<.01&&u<.01){rr(this.object,i),ia(this.object,r),zv(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(n,r,f),this.targetScale.lerpVectors(o,a,f),rr(this.object,this.targetPos),ia(this.object,this.targetRot),zv(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),n=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(n,this.targetScale,c),yield;this.coroutine=null}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const n=new Kn("Move to "+((i=this.target)==null?void 0:i.name),Bs.tapTrigger(this.gameObject),li.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));t.addBehavior(n)}}}pn([x(me)],Qd.prototype,"object",2);pn([x(me)],Qd.prototype,"target",2);pn([x()],Qd.prototype,"duration",2);pn([x()],Qd.prototype,"relativeMotion",2);var w_;const Ya=(w_=class extends Me{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,ey(this.gameObject)}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this.objectsWithThisMaterial.length;t++){const i=this.objectsWithThisMaterial[t];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(e=>{if(e instanceof de)if(Array.isArray(e.material)){for(const t of e.material)if(t===this.materialToSwitch){this.objectsWithThisMaterial.push(e);break}}else e.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(e)}),this._objectsWithThisMaterial)}async beforeCreateDocument(e,t){this.targetModels=[],Ya._materialTriggersPerId={},Ya.variantSwitchIndex=0,this.materialToSwitch&&await Ti.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Ti.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this.objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(Ya._materialTriggersPerId[this.materialToSwitch.uuid]||(Ya._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Ya._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=Ya._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const n={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(n[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in n)a!==r.selfModel.uuid&&o.push(...n[a]);r.createAndAttachBehaviors(e,n[r.selfModel.uuid],o)}}delete Ya._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const n=[],r=[],o=Math.max(0,this.fadeDuration);r.push(li.fadeAction([...this.targetModels,...i],o,!1)),n.push(li.fadeAction(t,o,!1)),r.push(li.fadeAction(t,o,!0)),e.addBehavior(new Kn("Select_"+this.selfModel.name,Bs.tapTrigger(this.selfModel),li.parallel(...r))),e.addBehavior(new Kn("StartHidden_"+this.selfModel.name,Bs.sceneStartTrigger(),li.parallel(...n)))}static getMaterialName(e){return Ba(e.name||"Material")+"_"+e.id}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+="_Variant_"+Ya.variantSwitchIndex+++"_"+Ya.getMaterialName(this.variantMaterial),i.displayName=i.displayName+": Variant with material "+this.variantMaterial.name,i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&Ir.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(w_,"_materialTriggersPerId",{}),h(w_,"variantSwitchIndex",0),w_);let Am=Ya;pn([x(Ot)],Am.prototype,"materialToSwitch",2);pn([x(Ot)],Am.prototype,"variantMaterial",2);pn([x()],Am.prototype,"fadeDuration",2);var zf;const ln=(zf=class extends Me{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(){ey(this.gameObject)}onPointerClick(e){e.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t,this.selfModelClone=t.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ln.wasVisible]===void 0&&(this.gameObject[ln.wasVisible]=this.gameObject.activeSelf),this.target[ln.wasVisible]===void 0&&(this.target[ln.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ln.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ln.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(e,t){if(!this.target)return;this.targetModel=t.document.findById(this.target.uuid);const i=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())&&A3.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ln.toggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggle"+ln.clonedToggleIndex++,i.add(c),this.gameObject[ln.toggleClone]=c,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const l=this.gameObject[ln.toggleClone];if(!this.gameObject[ln.reverseToggleClone]){const c=this.selfModelClone.clone();c.matrix.identity(),c.name+="_toggleReverse"+ln.clonedToggleIndex++,i.add(c),this.gameObject[ln.reverseToggleClone]=c}this.toggleModel=this.gameObject[ln.reverseToggleClone],(!this.toggleModel.geometry||!l.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),n=l,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const l=[];l.push(li.fadeAction(n,0,!1)),l.push(li.fadeAction(this.toggleModel,0,!0)),l.push(li.fadeAction(this.targetModel,0,r)),e.addBehavior(new Kn("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),Bs.tapTrigger(n),li.parallel(...l)));const c=[];c.push(li.fadeAction(this.toggleModel,0,!1)),c.push(li.fadeAction(n,0,!0)),c.push(li.fadeAction(this.targetModel,0,!r)),e.addBehavior(new Kn("Toggle_"+n.name+"_toggleTo"+(r?"Off":"On"),Bs.tapTrigger(this.toggleModel),li.parallel(...c)))}}else{const l=[];this.hideSelf&&l.push(li.fadeAction(n,0,!1)),l.push(li.fadeAction(this.targetModel,0,r)),e.addBehavior(new Kn("Toggle_"+n.name+"_toggleTo"+(r?"On":"Off"),Bs.tapTrigger(n),li.parallel(...l)))}const o=l=>{const c=Ir.createEmpty();c.name="InputTarget",c.displayName=void 0,c.type="RealityKitComponent",c.onSerialize=u=>{u.appendLine("bool allowsDirectInput = 1"),u.appendLine("bool allowsIndirectInput = 1"),u.appendLine('uniform token info:id = "RealityKit.InputTarget"')},l.add(c)};o(n),this.toggleModel&&o(this.toggleModel);const a=new Array;this.targetStateBeforeCreatingDocument||a.push(this.targetModel),this.stateBeforeCreatingDocument||a.push(i),this.toggleModel&&a.push(this.toggleModel),e.addBehavior(new Kn("HideOnStart_"+this.gameObject.name,Bs.sceneStartTrigger(),li.fadeAction(a,0,!1)))}}afterSerialize(e,t){this.gameObject[ln.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ln.wasVisible],delete this.gameObject[ln.wasVisible]),this.target&&this.target[ln.wasVisible]!==void 0&&(this.target.visible=this.target[ln.wasVisible],delete this.target[ln.wasVisible]),delete this.gameObject[ln.toggleClone],delete this.gameObject[ln.reverseToggleClone]}},h(zf,"clonedToggleIndex",0),h(zf,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),h(zf,"toggleClone",Symbol("clone for toggling")),h(zf,"reverseToggleClone",Symbol("clone for reverse toggling")),zf);let Vd=ln;pn([x(me)],Vd.prototype,"target",2);pn([x()],Vd.prototype,"toggleOnClick",2);pn([x()],Vd.prototype,"targetState",2);pn([x()],Vd.prototype,"hideSelf",2);class JR extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new Kn("HideOnStart_"+this.gameObject.name,Bs.sceneStartTrigger(),li.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class ym extends Me{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(t,i,n){if(this.target&&i.uuid===this.gameObject.uuid){const r=new Kn("emphasize "+this.name,Bs.tapTrigger(this.gameObject),li.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}pn([x()],ym.prototype,"target",2);pn([x()],ym.prototype,"duration",2);pn([x()],ym.prototype,"motionType",2);class Vh extends Me{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}start(){ey(this.gameObject)}ensureAudioSource(){if(!this.target){const t=this.gameObject.addNewComponent(fn);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1)}}onPointerClick(t){var i;t.use(),!(!((i=this.target)!=null&&i.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(t,i,n){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject,a=Hh.getName(r),l=this.target?this.target.volume:1,c=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let u=!1;if(this.gameObject.traverse(d=>{d instanceof de&&d.visible&&(u=!0)}),u=!0,u){let d=li.playAudioAction(o,"audio/"+a,"play",l,c);this.toggleOnClick&&(d.multiplePerformOperation="stop"),this.target&&this.target.loop&&(d=li.sequence(d).makeLooping());const f=new Kn("playAudio "+this.name,Bs.tapTrigger(this.gameObject),d);t.addBehavior(f)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let d=li.playAudioAction(o,"audio/"+a,"play",l,c);this.target.loop&&(d=li.sequence(d).makeLooping());const f=new Kn("playAudioOnStart"+(this.name?"_"+this.name:""),Bs.sceneStartTrigger(),d);t.addBehavior(f)}}}async afterSerialize(t,i){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 o="audio/"+Hh.getName(n);if(i.files[o])return;const c=await(await(await fetch(n)).blob()).arrayBuffer(),u=new Uint8Array(c);i.files[o]=u}}pn([x(fn)],Vh.prototype,"target",2);pn([x(URL)],Vh.prototype,"clip",2);pn([x()],Vh.prototype,"toggleOnClick",2);var S_;const ch=(S_=class extends Me{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 e,t;return((e=this.animator)==null?void 0:e.gameObject)||((t=this.animation)==null?void 0:t.gameObject)}start(){ey(this.gameObject)}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}afterSerialize(){if(ch.rootsWithExclusivePlayback.size>1){const e='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.';gt()&&dn(e),console.warn(e,...ch.rootsWithExclusivePlayback)}ch.animationActions=[],ch.rootsWithExclusivePlayback=new Set}afterCreateDocument(e,t){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=t.document,n=t.extensions.find(a=>a instanceof qA);if(!n)return;const r=n.getClipCount(this.target)>1;r&&(gt()&&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."),ch.rootsWithExclusivePlayback.add(this.target));const o=(a,l)=>{let c=ch.animationActions.find(u=>u.affectedObjects==a&&u.start==l.start&&u.duration==l.duration);return c||(c=li.startAnimationAction(a,l.start,l.duration),ch.animationActions.push(c)),c};i.traverse(a=>{var l,c;if(a.uuid===((l=this.target)==null?void 0:l.uuid)){const u=li.sequence();if(this.animationSequence&&this.animationSequence.length>0)for(const f of this.animationSequence)u.addAction(o(a,f));if(this.animationLoopAfterSequence&&this.animationLoopAfterSequence.length>0){const f=u.actions.length==0?u:li.sequence();for(const p of this.animationLoopAfterSequence)f.addAction(o(a,p));f.makeLooping(),u!==f&&u.addAction(f)}const d=new Kn("_tap_"+this.name+"_toPlayClip_"+this.stateName+"_on_"+((c=this.target)==null?void 0:c.name),this.trigger=="tap"?Bs.tapTrigger(this.selfModel):Bs.sceneStartTrigger(),u);r&&d.makeExclusive(!0),e.addBehavior(d)}})}createAnimation(e,t,i){var c,u,d,f,p,m,A;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=t,this.animation){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const g=e.registerAnimation(this.target,this.animation.clip);g&&this.animationLoopAfterSequence.push(g);return}const n=(c=this.animator)==null?void 0:c.runtimeAnimatorController;let r=n==null?void 0:n.findState(this.stateName),o=[],a=[];if(n&&r){const g=new Array;g.push(r);let v=!1;for(;g.length<100;){if(!r||r===null||!r.transitions||r.transitions.length===0){(u=r.motion)!=null&&u.isLooping&&(v=!0);break}const _=r.transitions.find(b=>b.conditions.length===0),y=_?n.getState(_.destinationState,0):null;if(y&&g.includes(y)){r=y,v=!0;break}else if(_){if(r=y,!r)break;g.push(r)}else{v=((d=r.motion)==null?void 0:d.isLooping)??!1;break}}if(v&&r){const _=g.indexOf(r);o=g.slice(0,_),a=g.slice(_),iL&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",a)}else o=g,a=[],iL&&console.log("found no loop from "+this.stateName,"states",o)}if(o.length===1&&(!((f=o[0].motion)!=null&&f.clip)||((m=(p=o[0].motion)==null?void 0:p.clip.tracks)==null?void 0:m.length)===0)){this.animationSequence=new Array;const g=e.registerAnimation(this.target,null);g&&this.animationSequence.push(g);return}if(o=o.filter(g=>{var v,_,y;return((v=g.motion)==null?void 0:v.clip)&&((y=(_=g.motion)==null?void 0:_.clip.tracks)==null?void 0:y.length)>0}),a=a.filter(g=>{var v,_,y;return((v=g.motion)==null?void 0:v.clip)&&((y=(_=g.motion)==null?void 0:_.clip.tracks)==null?void 0:y.length)>0}),o.length===0&&a.length===0){console.warn("No clips found for state "+this.stateName+" on "+((A=this.animator)==null?void 0:A.name)+", can't export animation data");return}const l=(g,v)=>{var y;if(!this.target)return;const _=e.registerAnimation(this.target,g.motion.clip??null);_?v.push(_):console.warn("Couldn't register animation for state "+g.name+" on "+((y=this.animator)==null?void 0:y.name))};if(o.length>0){this.animationSequence=new Array;for(const g of o)l(g,this.animationSequence)}if(a.length>0){this.animationLoopAfterSequence=new Array;for(const g of a)l(g,this.animationLoopAfterSequence)}}},h(S_,"animationActions",[]),h(S_,"rootsWithExclusivePlayback",new Set),S_);let Cd=ch;pn([x(ks)],Cd.prototype,"animator",2);pn([x()],Cd.prototype,"stateName",2);class _m extends Me{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}pn([x(me)],_m.prototype,"target",2);class ty extends Me{constructor(){super(...arguments);h(this,"target")}}pn([x(_m)],ty.prototype,"target",2);class iy extends _m{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}}pn([x()],iy.prototype,"type",2);pn([x()],iy.prototype,"duration",2);class KR extends ty{}var Tse=Object.defineProperty,Ise=Object.getOwnPropertyDescriptor,Rc=(s,e,t,i)=>{for(var n=i>1?void 0:i?Ise(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Tse(e,t,n),n};const nL=ne("debugcharactercontroller");class Wd extends Me{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions");h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Pi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Pi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(Cc);i||(i=this.gameObject.addNewComponent(Cc)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const n=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const l=r.dot(a)<0?-1:1,c=n.angleTo(a)*l;this.gameObject.setRotationFromAxisAngle(o,c),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){(t.contacts.length==0||t.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(t),nL&&console.log(`Collision(${this._activeGroundCollisions.size}): ${t.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(t){this._activeGroundCollisions.delete(t),nL&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var t;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const n=(t=this.context.physics.engine)==null?void 0:t.getLinearVelocity(i.collider);n&&(this._contactVelocity.x+=n.x,this._contactVelocity.y+=n.y,this._contactVelocity.z+=n.z)}return this._contactVelocity}}Rc([x(w)],Wd.prototype,"center",2);Rc([x()],Wd.prototype,"radius",2);Rc([x()],Wd.prototype,"height",2);class Pc extends Me{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 te(0,0));h(this,"moveInput",new te(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new na)}awake(){this._currentRotation=new Ce}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}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(t,i,n){var r,o,a,l,c,u,d,f,p,m,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(c=this.animator)==null||c.setBool("jumping",((l=this.controller)==null?void 0:l.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+=et.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const g=this.context.mainCameraComponent.forward;g.y=0,g.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),g),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 g=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(g=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),g){this._jumpCount+=1;const v=this.controller.rigidbody,_=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(_))}}if(this.controller){const g=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(g<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qr),this._raycastOptions.ray.origin.copy(Nt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const _=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(_.length&&_[0].distance>2||g<-10)&&((m=this.animator)==null||m.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}Rc([x(Wd)],Pc.prototype,"controller",2);Rc([x()],Pc.prototype,"movementSpeed",2);Rc([x()],Pc.prototype,"rotationSpeed",2);Rc([x()],Pc.prototype,"jumpForce",2);Rc([x()],Pc.prototype,"doubleJumpForce",2);Rc([x(ks)],Pc.prototype,"animator",2);var Rse=Object.defineProperty,Pse=Object.getOwnPropertyDescriptor,Bse=(s,e,t,i)=>{for(var n=i>1?void 0:i?Pse(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Rse(e,t,n),n};class ny extends lr{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new X3;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}Bse([x(kt)],ny.prototype,"intensity",2);la("ChromaticAberration",ny);const sy=new At;sy.setAttribute("position",new tt(new Float32Array([-1,-1,3,-1,-1,3]),2));sy.setAttribute("uv",new tt(new Float32Array([0,0,2,0,0,2]),2));sy.boundingSphere=new Sn;sy.computeBoundingSphere=function(){};const Dse=new Ec;class Su{constructor(e){this._mesh=new de(sy,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,Dse)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const Ose={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new we},viewMat:{value:new we},projViewMat:{value:new we},projectionMatrixInv:{value:new we},viewMatrixInv:{value:new we},cameraPos:{value:new w},resolution:{value:new te},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:`
|