@needle-tools/engine 3.27.1-beta → 3.27.2-beta
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 +5 -0
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.light.js +3 -3
- package/dist/needle-engine.light.min.js +3 -3
- package/dist/needle-engine.light.umd.cjs +3 -3
- package/dist/needle-engine.min.js +3 -3
- package/dist/needle-engine.umd.cjs +3 -3
- package/lib/engine/engine_addressables.js +1 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_element.js +1 -1
- package/lib/engine-components/OrbitControls.js +1 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_addressables.ts +1 -1
- package/src/engine/engine_element.ts +2 -2
- package/src/engine-components/OrbitControls.ts +1 -1
|
@@ -4252,7 +4252,7 @@ outputColor=vec4(color,inputColor.a);}`,Fx=class extends ns{constructor({blendFu
|
|
|
4252
4252
|
*
|
|
4253
4253
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
4254
4254
|
* @license MIT
|
|
4255
|
-
*/var n9=function(t){return t!=null&&(Yx(t)||r9(t)||!!t._isBuffer)};function Yx(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function r9(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Yx(t.slice(0,0))}(function(){var t=a9,A=Tx.utf8,e=n9,i=Tx.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=i.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=t.bytesToWords(I),C=I.length*8,a=1732584193,r=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[C>>>5]|=128<<C%32,s[(C+64>>>9<<4)+14]=C;for(var h=g._ff,d=g._gg,l=g._hh,c=g._ii,E=0;E<s.length;E+=16){var u=a,p=r,D=B,S=Q;a=h(a,r,B,Q,s[E+0],7,-680876936),Q=h(Q,a,r,B,s[E+1],12,-389564586),B=h(B,Q,a,r,s[E+2],17,606105819),r=h(r,B,Q,a,s[E+3],22,-1044525330),a=h(a,r,B,Q,s[E+4],7,-176418897),Q=h(Q,a,r,B,s[E+5],12,1200080426),B=h(B,Q,a,r,s[E+6],17,-1473231341),r=h(r,B,Q,a,s[E+7],22,-45705983),a=h(a,r,B,Q,s[E+8],7,1770035416),Q=h(Q,a,r,B,s[E+9],12,-1958414417),B=h(B,Q,a,r,s[E+10],17,-42063),r=h(r,B,Q,a,s[E+11],22,-1990404162),a=h(a,r,B,Q,s[E+12],7,1804603682),Q=h(Q,a,r,B,s[E+13],12,-40341101),B=h(B,Q,a,r,s[E+14],17,-1502002290),r=h(r,B,Q,a,s[E+15],22,1236535329),a=d(a,r,B,Q,s[E+1],5,-165796510),Q=d(Q,a,r,B,s[E+6],9,-1069501632),B=d(B,Q,a,r,s[E+11],14,643717713),r=d(r,B,Q,a,s[E+0],20,-373897302),a=d(a,r,B,Q,s[E+5],5,-701558691),Q=d(Q,a,r,B,s[E+10],9,38016083),B=d(B,Q,a,r,s[E+15],14,-660478335),r=d(r,B,Q,a,s[E+4],20,-405537848),a=d(a,r,B,Q,s[E+9],5,568446438),Q=d(Q,a,r,B,s[E+14],9,-1019803690),B=d(B,Q,a,r,s[E+3],14,-187363961),r=d(r,B,Q,a,s[E+8],20,1163531501),a=d(a,r,B,Q,s[E+13],5,-1444681467),Q=d(Q,a,r,B,s[E+2],9,-51403784),B=d(B,Q,a,r,s[E+7],14,1735328473),r=d(r,B,Q,a,s[E+12],20,-1926607734),a=l(a,r,B,Q,s[E+5],4,-378558),Q=l(Q,a,r,B,s[E+8],11,-2022574463),B=l(B,Q,a,r,s[E+11],16,1839030562),r=l(r,B,Q,a,s[E+14],23,-35309556),a=l(a,r,B,Q,s[E+1],4,-1530992060),Q=l(Q,a,r,B,s[E+4],11,1272893353),B=l(B,Q,a,r,s[E+7],16,-155497632),r=l(r,B,Q,a,s[E+10],23,-1094730640),a=l(a,r,B,Q,s[E+13],4,681279174),Q=l(Q,a,r,B,s[E+0],11,-358537222),B=l(B,Q,a,r,s[E+3],16,-722521979),r=l(r,B,Q,a,s[E+6],23,76029189),a=l(a,r,B,Q,s[E+9],4,-640364487),Q=l(Q,a,r,B,s[E+12],11,-421815835),B=l(B,Q,a,r,s[E+15],16,530742520),r=l(r,B,Q,a,s[E+2],23,-995338651),a=c(a,r,B,Q,s[E+0],6,-198630844),Q=c(Q,a,r,B,s[E+7],10,1126891415),B=c(B,Q,a,r,s[E+14],15,-1416354905),r=c(r,B,Q,a,s[E+5],21,-57434055),a=c(a,r,B,Q,s[E+12],6,1700485571),Q=c(Q,a,r,B,s[E+3],10,-1894986606),B=c(B,Q,a,r,s[E+10],15,-1051523),r=c(r,B,Q,a,s[E+1],21,-2054922799),a=c(a,r,B,Q,s[E+8],6,1873313359),Q=c(Q,a,r,B,s[E+15],10,-30611744),B=c(B,Q,a,r,s[E+6],15,-1560198380),r=c(r,B,Q,a,s[E+13],21,1309151649),a=c(a,r,B,Q,s[E+4],6,-145523070),Q=c(Q,a,r,B,s[E+11],10,-1120210379),B=c(B,Q,a,r,s[E+2],15,718787259),r=c(r,B,Q,a,s[E+9],21,-343485551),a=a+u>>>0,r=r+p>>>0,B=B+D>>>0,Q=Q+S>>>0}return t.endian([a,r,B,Q])};g._ff=function(I,o,s,C,a,r,B){var Q=I+(o&s|~o&C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._gg=function(I,o,s,C,a,r,B){var Q=I+(o&C|s&~C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._hh=function(I,o,s,C,a,r,B){var Q=I+(o^s^C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._ii=function(I,o,s,C,a,r,B){var Q=I+(s^(o|~C))+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._blocksize=16,g._digestsize=16,Lx.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=t.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?i.bytesToString(s):t.bytesToHex(s)}})();var B9=Lx.exports;const Q9=Qc(B9);class GG{constructor(A,e,i,g){n(this,"success"),n(this,"filename"),n(this,"hash"),n(this,"size"),n(this,"url"),this.success=A,this.filename=e,this.hash=i,this.size=g}}async function Hx(t,A){const e=await t.arrayBuffer(),i=MG(e),g=t.name.split(".").pop(),I=i+"."+g,o=t.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",i),new GG(!0,I,i,t.size);console.log("begin uploading file",o,t.size);const a=new FormData;a.append("file",t);const r={};r.filesize=t.size,o&&(r.alias=o);const B=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:r})).json();if(B?.success===!1)return B.message!==void 0?console.error("Upload failed:",B.message):console.error("Upload failed"),null;console.assert(B.hash_sum===i,"hash sum did not match","received:",B.hash_sum,"expected:",i),B.success&&console.log("successfully uploaded",i,B.id);const Q=new GG(B.success,I,i,t.size);return Q.url=A,Q}function MG(t){return Q9(new Uint8Array(t))}async function RG(t,A,e,i,g=!1){try{const I=await fetch(i+"/download/file",{method:"POST",body:t});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const C=MG(s);return g||console.assert(C===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function Ox(t,A){var e;const i=await fetch(t),g=(e=i.body)==null?void 0:e.getReader(),I=i.headers.get("Content-Length"),o=I?parseInt(I):0;if(!g)return null;let s=0;const C=[];for(;;){const{done:B,value:Q}=await g.read();if(Q&&(C.push(Q),s+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:s,total:o}))),B)break}const a=new Uint8Array(s);let r=0;for(const B of C)a.set(B,r),r+=B.length;return a}let _x,Px=null;function rs(){return _x}function UG(t){if(t==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}Px!==t&&(Px=t,_x=new t)}const sn=CA("debugaddressables");class jx{constructor(A){n(this,"_context"),n(this,"_assetReferences",{}),this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e?.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const NG=Symbol("assetReference"),_c=class{constructor(t,A,e=null){n(this,"_loading"),n(this,"_asset"),n(this,"_glbRoot"),n(this,"_url"),n(this,"_progressListeners",[]),n(this,"_hash"),n(this,"_hashedUri"),n(this,"_isLoadingRawBinary",!1),n(this,"_rawBinary"),this._url=t,this._hash=A,t.includes("?v=")?this._hashedUri=t:this._hashedUri=A?t+"?v="+A:t,e!==null&&(this.asset=e),lL(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(t,A,e){if(typeof t=="string"){if(!e&&(e=qe.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else e=t.context,t=t.sourceId;const i=FC(t,A);sn&&console.log("GetOrCreate Addressable from",t,A,"FinalPath=",i);const g=e.addressables,I=g.findAssetReference(i);if(I)return I;const o=new _c(i,e.hash);return g.registerAssetReference(o),o}get asset(){return this._glbRoot??this._asset}set asset(t){this._asset=t}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(t){return t===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||KD(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(sn&&console.log("Unload",this.asset),this.asset.scene&&Hs(this.asset.scene,!0,!0),Hs(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,qe.Current&&qe.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,sn&&console.log("Preload",this._hashedUri);const t=await Ox(this._hashedUri,A=>{this.raiseProgressEvent(A)});return this._rawBinary=t?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(t){if(sn&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(t&&this._progressListeners.push(t),this._loading!==void 0)return this._loading;const A=qe.Current;this._rawBinary?(this._loading=rs().parseSync(A,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(sn&&console.log("Load async",this.uri),this._loading=rs().loadSync(A,this._hashedUri,this.uri,null,i=>{this.raiseProgressEvent(i)}));const e=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(e),this._loading=void 0,e)return e[NG]=this,this._glbRoot&&(this._glbRoot[NG]=this),this.asset&&(this.asset[NG]=this),JD(A),e.scene!==void 0&&(this.asset=e),this.asset}async instantiate(t){return this.onInstantiate(t,!1)}async instantiateSynced(t,A=!0){return this.onInstantiate(t,!0,A)}beginListenDownload(t){this._progressListeners.indexOf(t)<0&&this._progressListeners.push(t)}endListenDownload(t){const A=this._progressListeners.indexOf(t);A>=0&&this._progressListeners.splice(A,1)}raiseProgressEvent(t){for(const A of this._progressListeners)A(this,t)}async onInstantiate(t,A=!1,e){const i=qe.Current;if(this.mustLoad&&await this.loadAssetAsync(),sn&&console.log("Instantiate",this.uri,"parent:",t),this.asset){sn&&console.log("Add to scene",this.asset);let g=t instanceof Ys?t:null;g||(g=new Ys),typeof t=="object"&&(t instanceof fA?g.parent=t:Object.assign(g,t)),g.parent||(g.parent=i.scene);let I=_c.currentlyInstantiating.get(this.uri);if(I!==void 0&&I>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+I+")"),null;try{if(I===void 0&&(I=0),I+=1,_c.currentlyInstantiating.set(this.uri,I),A){g.context=i;const o=this.asset;o.guid=this.uri;const s=jk(o,g,void 0,e);if(s)return s}else{const o=xc(this.asset,g);if(o)return o}}finally{i.post_render_callbacks.push(()=>{I===void 0||I<0?I=0:I-=1,_c.currentlyInstantiating.set(this.uri,I)})}}else sn&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(t){if(t&&t.scene){const A=t.scene;return A.isGroup&&A.children.length===1&&A.children[0].name+"glb"===A.name?A.children[0]:A}return null}};let Zi=_c;n(Zi,"currentlyInstantiating",new Map);class E9 extends OC{constructor(){super([Zi])}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?Zi.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof fA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const i=A,g=e.context,I=i.guid??i.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new Zi(I,void 0,i);return g.addressables.registerAssetReference(s),s}return null}}new E9;const h9=Promise.resolve(null),OD=class{constructor(t){n(this,"url"),n(this,"_bitmap"),n(this,"_bitmapObject"),n(this,"loader",null),this.url=t}static getOrCreate(t){let A=OD.imageReferences.get(t);return A||(A=new OD(t),OD.imageReferences.set(t,A)),A}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const t=new Image;return t.src=this.url,t}createTexture(){return this.url?(this.loader||(this.loader=new NC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):h9}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((t,A)=>{const e=document.createElement("img");e.addEventListener("load",()=>{this._bitmap=createImageBitmap(e).then(i=>(this._bitmapObject=i,t(i),i))}),e.addEventListener("error",i=>{console.error("Failed to load image:"+this.url,i),t(null)}),e.src=this.url}),this._bitmap)}};let _D=OD;n(_D,"imageReferences",new Map);class Wx extends OC{constructor(){super([_D])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const i=FC(e.gltfId,A);return _D.getOrCreate(i)}}}new Wx;const ko=CA("debugenvlight");var JQ=(t=>(t[t.Skybox=0]="Skybox",t[t.Trilight=1]="Trilight",t[t.Flat=3]="Flat",t[t.Custom=4]="Custom",t))(JQ||{}),PD=(t=>(t[t.Skybox=0]="Skybox",t[t.Custom=1]="Custom",t))(PD||{});class Vx{constructor(A){n(this,"context"),n(this,"_currentLightSettingsId"),n(this,"_sceneLightSettings"),n(this,"_timevec4",new ge),n(this,"__currentReflectionId",null),n(this,"_waitPromise"),n(this,"_lighting",{}),this.context=A,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const A=this.context.time;this._timevec4.x=A.time,this._timevec4.y=Math.sin(A.time),this._timevec4.z=Math.cos(A.time),this._timevec4.w=A.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const A=this._sceneLightSettings.get(this._currentLightSettingsId);return A?A.ambientIntensity:1}get sceneLightSettings(){var A;return(A=this._sceneLightSettings)==null?void 0:A.values()}enable(A){var e;A instanceof Zi&&(A=A.uri);const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);return i?(ko&&console.log("Enable scene light settings",A,i),A!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=A,i.enabled=!0,!0):!1}disable(A){var e;if(A instanceof Zi&&(A=A.uri),A==null)return!1;const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);return i?(ko&&console.log("Disable scene light settings",A,i),i.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const A=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),A}return null}internalRegisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not register:",A);return}ko&&console.log("Register "+A?.sourceId+" lighting",A),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(e,A)}internalUnregisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not unregister:",A);return}ko&&console.log("Unregister "+A?.sourceId+" lighting",A),this._sceneLightSettings&&this._sceneLightSettings.delete(e)}internalRegisterReflection(A,e){ko&&console.log("Register reflection",A,e);const i=new zx(this.context,e,1);this._lighting[A]=i}internalGetReflection(A){return this._lighting[A]}internalEnableReflection(A){var e;this.__currentReflectionId=A;const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);switch(ko&&console.log("Enable reflection",A,i?JQ[i.ambientMode]:"Unknown ambient mode"),i?.ambientMode){case 0:case 4:const g=this.internalGetReflection(A);if(g&&g.Source){ko&&console.log("Setting environment reflection",g);const I=this.context.scene,o=g.Source;o.colorSpace=Ie,o.mapping=ho,I.environment=o;return}else ko&&console.warn("Could not find reflection for source",A);break}if(i?.environmentReflectionSource===1)switch(i?.ambientMode){case 1:if(i.ambientTrilight){const g=i.ambientTrilight,I=I9(g[0],g[1],g[2],64,64);I.colorSpace=Ie,I.mapping=ho,this.context.scene.environment=I}else console.error("Missing ambient trilight",i.sourceId);return;case 3:if(i.ambientLight){const g=Jx(i.ambientLight,64);g.colorSpace=Ie,g.mapping=ho,this.context.scene.environment=g}else console.error("Missing ambientlight",i.sourceId);return;default:return}}internalDisableReflection(A){if(A&&A!==this.__currentReflectionId){ko&&console.log("Not disabling reflection for",A,"because it is not the current light settings id",this.__currentReflectionId);return}ko&&console.log("Disable reflection",A);const e=this.context.scene;e.environment=null}async internalGetSceneLightingData(A){return ko&&console.log("GET SCENE LIGHT DATA",A),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((e,i)=>{const g=setInterval(async()=>{const I=this.internalGetReflection(A);I&&(clearInterval(g),e(I.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class zx{constructor(A,e,i=1){n(this,"_context"),n(this,"_source"),n(this,"_sphericalHarmonics",null),n(this,"_sphericalHarmonicsArray"),n(this,"_ambientScale",1),n(this,"_lightProbe"),this._context=A,this._source=e,this._ambientScale=i,e.mapping=ho,e.colorSpace=Ie}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(A=1){var e;if((e=this._sphericalHarmonicsArray)!=null&&e.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const i=this._source;let g=null;if(i){ko&&console.log("GENERATING LIGHT PROBE",i,this.Source);const I=Math.min(i.image.width,512);g=new Wp(I).fromEquirectangularTexture(this._context.renderer,i)}if(this._sphericalHarmonicsArray=[],g){const I=i9.fromCubeRenderTarget(this._context.renderer,g);this._lightProbe=I;const o=this._ambientScale*(A*A*Math.PI*.5)-1;if(this._sphericalHarmonics=I.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const s=A/(Math.PI*.5);for(let C=0;C<this._sphericalHarmonicsArray.length;C++)this._sphericalHarmonicsArray[C]*=s;if(I.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:I}}}}catch(i){console.error(i)}return null}}var jD=(t=>(t.Visible="application-visible",t.Hidden="application-hidden",t.MuteChanged="application-mutechanged",t))(jD||{});class Zx extends EventTarget{constructor(A){super(),n(this,"_mute",!1),n(this,"context"),n(this,"_isVisible",!0),this.context=A,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(A){A!==this._mute&&(this._mute=A,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(A){switch(A.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
|
|
4255
|
+
*/var n9=function(t){return t!=null&&(Yx(t)||r9(t)||!!t._isBuffer)};function Yx(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function r9(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Yx(t.slice(0,0))}(function(){var t=a9,A=Tx.utf8,e=n9,i=Tx.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=i.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=t.bytesToWords(I),C=I.length*8,a=1732584193,r=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[C>>>5]|=128<<C%32,s[(C+64>>>9<<4)+14]=C;for(var h=g._ff,d=g._gg,l=g._hh,c=g._ii,E=0;E<s.length;E+=16){var u=a,p=r,D=B,S=Q;a=h(a,r,B,Q,s[E+0],7,-680876936),Q=h(Q,a,r,B,s[E+1],12,-389564586),B=h(B,Q,a,r,s[E+2],17,606105819),r=h(r,B,Q,a,s[E+3],22,-1044525330),a=h(a,r,B,Q,s[E+4],7,-176418897),Q=h(Q,a,r,B,s[E+5],12,1200080426),B=h(B,Q,a,r,s[E+6],17,-1473231341),r=h(r,B,Q,a,s[E+7],22,-45705983),a=h(a,r,B,Q,s[E+8],7,1770035416),Q=h(Q,a,r,B,s[E+9],12,-1958414417),B=h(B,Q,a,r,s[E+10],17,-42063),r=h(r,B,Q,a,s[E+11],22,-1990404162),a=h(a,r,B,Q,s[E+12],7,1804603682),Q=h(Q,a,r,B,s[E+13],12,-40341101),B=h(B,Q,a,r,s[E+14],17,-1502002290),r=h(r,B,Q,a,s[E+15],22,1236535329),a=d(a,r,B,Q,s[E+1],5,-165796510),Q=d(Q,a,r,B,s[E+6],9,-1069501632),B=d(B,Q,a,r,s[E+11],14,643717713),r=d(r,B,Q,a,s[E+0],20,-373897302),a=d(a,r,B,Q,s[E+5],5,-701558691),Q=d(Q,a,r,B,s[E+10],9,38016083),B=d(B,Q,a,r,s[E+15],14,-660478335),r=d(r,B,Q,a,s[E+4],20,-405537848),a=d(a,r,B,Q,s[E+9],5,568446438),Q=d(Q,a,r,B,s[E+14],9,-1019803690),B=d(B,Q,a,r,s[E+3],14,-187363961),r=d(r,B,Q,a,s[E+8],20,1163531501),a=d(a,r,B,Q,s[E+13],5,-1444681467),Q=d(Q,a,r,B,s[E+2],9,-51403784),B=d(B,Q,a,r,s[E+7],14,1735328473),r=d(r,B,Q,a,s[E+12],20,-1926607734),a=l(a,r,B,Q,s[E+5],4,-378558),Q=l(Q,a,r,B,s[E+8],11,-2022574463),B=l(B,Q,a,r,s[E+11],16,1839030562),r=l(r,B,Q,a,s[E+14],23,-35309556),a=l(a,r,B,Q,s[E+1],4,-1530992060),Q=l(Q,a,r,B,s[E+4],11,1272893353),B=l(B,Q,a,r,s[E+7],16,-155497632),r=l(r,B,Q,a,s[E+10],23,-1094730640),a=l(a,r,B,Q,s[E+13],4,681279174),Q=l(Q,a,r,B,s[E+0],11,-358537222),B=l(B,Q,a,r,s[E+3],16,-722521979),r=l(r,B,Q,a,s[E+6],23,76029189),a=l(a,r,B,Q,s[E+9],4,-640364487),Q=l(Q,a,r,B,s[E+12],11,-421815835),B=l(B,Q,a,r,s[E+15],16,530742520),r=l(r,B,Q,a,s[E+2],23,-995338651),a=c(a,r,B,Q,s[E+0],6,-198630844),Q=c(Q,a,r,B,s[E+7],10,1126891415),B=c(B,Q,a,r,s[E+14],15,-1416354905),r=c(r,B,Q,a,s[E+5],21,-57434055),a=c(a,r,B,Q,s[E+12],6,1700485571),Q=c(Q,a,r,B,s[E+3],10,-1894986606),B=c(B,Q,a,r,s[E+10],15,-1051523),r=c(r,B,Q,a,s[E+1],21,-2054922799),a=c(a,r,B,Q,s[E+8],6,1873313359),Q=c(Q,a,r,B,s[E+15],10,-30611744),B=c(B,Q,a,r,s[E+6],15,-1560198380),r=c(r,B,Q,a,s[E+13],21,1309151649),a=c(a,r,B,Q,s[E+4],6,-145523070),Q=c(Q,a,r,B,s[E+11],10,-1120210379),B=c(B,Q,a,r,s[E+2],15,718787259),r=c(r,B,Q,a,s[E+9],21,-343485551),a=a+u>>>0,r=r+p>>>0,B=B+D>>>0,Q=Q+S>>>0}return t.endian([a,r,B,Q])};g._ff=function(I,o,s,C,a,r,B){var Q=I+(o&s|~o&C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._gg=function(I,o,s,C,a,r,B){var Q=I+(o&C|s&~C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._hh=function(I,o,s,C,a,r,B){var Q=I+(o^s^C)+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._ii=function(I,o,s,C,a,r,B){var Q=I+(s^(o|~C))+(a>>>0)+B;return(Q<<r|Q>>>32-r)+o},g._blocksize=16,g._digestsize=16,Lx.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=t.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?i.bytesToString(s):t.bytesToHex(s)}})();var B9=Lx.exports;const Q9=Qc(B9);class GG{constructor(A,e,i,g){n(this,"success"),n(this,"filename"),n(this,"hash"),n(this,"size"),n(this,"url"),this.success=A,this.filename=e,this.hash=i,this.size=g}}async function Hx(t,A){const e=await t.arrayBuffer(),i=MG(e),g=t.name.split(".").pop(),I=i+"."+g,o=t.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",i),new GG(!0,I,i,t.size);console.log("begin uploading file",o,t.size);const a=new FormData;a.append("file",t);const r={};r.filesize=t.size,o&&(r.alias=o);const B=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:r})).json();if(B?.success===!1)return B.message!==void 0?console.error("Upload failed:",B.message):console.error("Upload failed"),null;console.assert(B.hash_sum===i,"hash sum did not match","received:",B.hash_sum,"expected:",i),B.success&&console.log("successfully uploaded",i,B.id);const Q=new GG(B.success,I,i,t.size);return Q.url=A,Q}function MG(t){return Q9(new Uint8Array(t))}async function RG(t,A,e,i,g=!1){try{const I=await fetch(i+"/download/file",{method:"POST",body:t});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const C=MG(s);return g||console.assert(C===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function Ox(t,A){var e;const i=await fetch(t),g=(e=i.body)==null?void 0:e.getReader(),I=i.headers.get("Content-Length"),o=I?parseInt(I):0;if(!g)return null;let s=0;const C=[];for(;;){const{done:B,value:Q}=await g.read();if(Q&&(C.push(Q),s+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:s,total:o}))),B)break}const a=new Uint8Array(s);let r=0;for(const B of C)a.set(B,r),r+=B.length;return a}let _x,Px=null;function rs(){return _x}function UG(t){if(t==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}Px!==t&&(Px=t,_x=new t)}const sn=CA("debugaddressables");class jx{constructor(A){n(this,"_context"),n(this,"_assetReferences",{}),this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e?.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const NG=Symbol("assetReference"),_c=class{constructor(t,A,e=null){n(this,"_loading"),n(this,"_asset"),n(this,"_glbRoot"),n(this,"_url"),n(this,"_progressListeners",[]),n(this,"_hash"),n(this,"_hashedUri"),n(this,"_isLoadingRawBinary",!1),n(this,"_rawBinary"),this._url=t,this._hash=A,t.includes("?v=")?this._hashedUri=t:this._hashedUri=A?t+"?v="+A:t,e!==null&&(this.asset=e),lL(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(t,A,e){if(typeof t=="string"){if(!e&&(e=qe.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else e=t.context,t=t.sourceId;const i=FC(t,A);sn&&console.log("GetOrCreate Addressable from",t,A,"FinalPath=",i);const g=e.addressables,I=g.findAssetReference(i);if(I)return I;const o=new _c(i,e.hash);return g.registerAssetReference(o),o}get asset(){return this._glbRoot??this._asset}set asset(t){this._asset=t}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(t){return t===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||KD(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(sn&&console.log("Unload",this.asset),this.asset.scene&&Hs(this.asset.scene,!0,!0),Hs(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,qe.Current&&qe.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,sn&&console.log("Preload",this._hashedUri);const t=await Ox(this._hashedUri,A=>{this.raiseProgressEvent(A)});return this._rawBinary=t?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(t){if(sn&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(t&&this._progressListeners.push(t),this._loading!==void 0)return this._loading.then(i=>this.asset);const A=qe.Current;this._rawBinary?(this._loading=rs().parseSync(A,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(sn&&console.log("Load async",this.uri),this._loading=rs().loadSync(A,this._hashedUri,this.uri,null,i=>{this.raiseProgressEvent(i)}));const e=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(e),this._loading=void 0,e)return e[NG]=this,this._glbRoot&&(this._glbRoot[NG]=this),this.asset&&(this.asset[NG]=this),JD(A),e.scene!==void 0&&(this.asset=e),this.asset}async instantiate(t){return this.onInstantiate(t,!1)}async instantiateSynced(t,A=!0){return this.onInstantiate(t,!0,A)}beginListenDownload(t){this._progressListeners.indexOf(t)<0&&this._progressListeners.push(t)}endListenDownload(t){const A=this._progressListeners.indexOf(t);A>=0&&this._progressListeners.splice(A,1)}raiseProgressEvent(t){for(const A of this._progressListeners)A(this,t)}async onInstantiate(t,A=!1,e){const i=qe.Current;if(this.mustLoad&&await this.loadAssetAsync(),sn&&console.log("Instantiate",this.uri,"parent:",t),this.asset){sn&&console.log("Add to scene",this.asset);let g=t instanceof Ys?t:null;g||(g=new Ys),typeof t=="object"&&(t instanceof fA?g.parent=t:Object.assign(g,t)),g.parent||(g.parent=i.scene);let I=_c.currentlyInstantiating.get(this.uri);if(I!==void 0&&I>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+I+")"),null;try{if(I===void 0&&(I=0),I+=1,_c.currentlyInstantiating.set(this.uri,I),A){g.context=i;const o=this.asset;o.guid=this.uri;const s=jk(o,g,void 0,e);if(s)return s}else{const o=xc(this.asset,g);if(o)return o}}finally{i.post_render_callbacks.push(()=>{I===void 0||I<0?I=0:I-=1,_c.currentlyInstantiating.set(this.uri,I)})}}else sn&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(t){if(t&&t.scene){const A=t.scene;return A.isGroup&&A.children.length===1&&A.children[0].name+"glb"===A.name?A.children[0]:A}return null}};let Zi=_c;n(Zi,"currentlyInstantiating",new Map);class E9 extends OC{constructor(){super([Zi])}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?Zi.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof fA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const i=A,g=e.context,I=i.guid??i.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new Zi(I,void 0,i);return g.addressables.registerAssetReference(s),s}return null}}new E9;const h9=Promise.resolve(null),OD=class{constructor(t){n(this,"url"),n(this,"_bitmap"),n(this,"_bitmapObject"),n(this,"loader",null),this.url=t}static getOrCreate(t){let A=OD.imageReferences.get(t);return A||(A=new OD(t),OD.imageReferences.set(t,A)),A}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const t=new Image;return t.src=this.url,t}createTexture(){return this.url?(this.loader||(this.loader=new NC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):h9}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((t,A)=>{const e=document.createElement("img");e.addEventListener("load",()=>{this._bitmap=createImageBitmap(e).then(i=>(this._bitmapObject=i,t(i),i))}),e.addEventListener("error",i=>{console.error("Failed to load image:"+this.url,i),t(null)}),e.src=this.url}),this._bitmap)}};let _D=OD;n(_D,"imageReferences",new Map);class Wx extends OC{constructor(){super([_D])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const i=FC(e.gltfId,A);return _D.getOrCreate(i)}}}new Wx;const ko=CA("debugenvlight");var JQ=(t=>(t[t.Skybox=0]="Skybox",t[t.Trilight=1]="Trilight",t[t.Flat=3]="Flat",t[t.Custom=4]="Custom",t))(JQ||{}),PD=(t=>(t[t.Skybox=0]="Skybox",t[t.Custom=1]="Custom",t))(PD||{});class Vx{constructor(A){n(this,"context"),n(this,"_currentLightSettingsId"),n(this,"_sceneLightSettings"),n(this,"_timevec4",new ge),n(this,"__currentReflectionId",null),n(this,"_waitPromise"),n(this,"_lighting",{}),this.context=A,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const A=this.context.time;this._timevec4.x=A.time,this._timevec4.y=Math.sin(A.time),this._timevec4.z=Math.cos(A.time),this._timevec4.w=A.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const A=this._sceneLightSettings.get(this._currentLightSettingsId);return A?A.ambientIntensity:1}get sceneLightSettings(){var A;return(A=this._sceneLightSettings)==null?void 0:A.values()}enable(A){var e;A instanceof Zi&&(A=A.uri);const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);return i?(ko&&console.log("Enable scene light settings",A,i),A!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=A,i.enabled=!0,!0):!1}disable(A){var e;if(A instanceof Zi&&(A=A.uri),A==null)return!1;const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);return i?(ko&&console.log("Disable scene light settings",A,i),i.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const A=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),A}return null}internalRegisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not register:",A);return}ko&&console.log("Register "+A?.sourceId+" lighting",A),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(e,A)}internalUnregisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not unregister:",A);return}ko&&console.log("Unregister "+A?.sourceId+" lighting",A),this._sceneLightSettings&&this._sceneLightSettings.delete(e)}internalRegisterReflection(A,e){ko&&console.log("Register reflection",A,e);const i=new zx(this.context,e,1);this._lighting[A]=i}internalGetReflection(A){return this._lighting[A]}internalEnableReflection(A){var e;this.__currentReflectionId=A;const i=(e=this._sceneLightSettings)==null?void 0:e.get(A);switch(ko&&console.log("Enable reflection",A,i?JQ[i.ambientMode]:"Unknown ambient mode"),i?.ambientMode){case 0:case 4:const g=this.internalGetReflection(A);if(g&&g.Source){ko&&console.log("Setting environment reflection",g);const I=this.context.scene,o=g.Source;o.colorSpace=Ie,o.mapping=ho,I.environment=o;return}else ko&&console.warn("Could not find reflection for source",A);break}if(i?.environmentReflectionSource===1)switch(i?.ambientMode){case 1:if(i.ambientTrilight){const g=i.ambientTrilight,I=I9(g[0],g[1],g[2],64,64);I.colorSpace=Ie,I.mapping=ho,this.context.scene.environment=I}else console.error("Missing ambient trilight",i.sourceId);return;case 3:if(i.ambientLight){const g=Jx(i.ambientLight,64);g.colorSpace=Ie,g.mapping=ho,this.context.scene.environment=g}else console.error("Missing ambientlight",i.sourceId);return;default:return}}internalDisableReflection(A){if(A&&A!==this.__currentReflectionId){ko&&console.log("Not disabling reflection for",A,"because it is not the current light settings id",this.__currentReflectionId);return}ko&&console.log("Disable reflection",A);const e=this.context.scene;e.environment=null}async internalGetSceneLightingData(A){return ko&&console.log("GET SCENE LIGHT DATA",A),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((e,i)=>{const g=setInterval(async()=>{const I=this.internalGetReflection(A);I&&(clearInterval(g),e(I.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class zx{constructor(A,e,i=1){n(this,"_context"),n(this,"_source"),n(this,"_sphericalHarmonics",null),n(this,"_sphericalHarmonicsArray"),n(this,"_ambientScale",1),n(this,"_lightProbe"),this._context=A,this._source=e,this._ambientScale=i,e.mapping=ho,e.colorSpace=Ie}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(A=1){var e;if((e=this._sphericalHarmonicsArray)!=null&&e.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const i=this._source;let g=null;if(i){ko&&console.log("GENERATING LIGHT PROBE",i,this.Source);const I=Math.min(i.image.width,512);g=new Wp(I).fromEquirectangularTexture(this._context.renderer,i)}if(this._sphericalHarmonicsArray=[],g){const I=i9.fromCubeRenderTarget(this._context.renderer,g);this._lightProbe=I;const o=this._ambientScale*(A*A*Math.PI*.5)-1;if(this._sphericalHarmonics=I.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const s=A/(Math.PI*.5);for(let C=0;C<this._sphericalHarmonicsArray.length;C++)this._sphericalHarmonicsArray[C]*=s;if(I.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:I}}}}catch(i){console.error(i)}return null}}var jD=(t=>(t.Visible="application-visible",t.Hidden="application-hidden",t.MuteChanged="application-mutechanged",t))(jD||{});class Zx extends EventTarget{constructor(A){super(),n(this,"_mute",!1),n(this,"context"),n(this,"_isVisible",!0),this.context=A,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(A){A!==this._mute&&(this._mute=A,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(A){switch(A.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
|
|
4256
4256
|
fflate - fast JavaScript compression/decompression
|
|
4257
4257
|
<https://101arrowz.github.io/fflate>
|
|
4258
4258
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
@@ -5186,7 +5186,7 @@ Using the assigned clip instead:`,this.clip),t=this.clip);let i=!this.sound||t&&
|
|
|
5186
5186
|
#include <colorspace_fragment>
|
|
5187
5187
|
|
|
5188
5188
|
}
|
|
5189
|
-
`,o={map:{value:A},height:{value:e.height||15},radius:{value:e.radius||100}},s=new zd(1,16),C=new Ue({uniforms:o,fragmentShader:I,vertexShader:g,side:St});super(s,C)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}}var ngA=Object.defineProperty,rgA=Object.getOwnPropertyDescriptor,mg=(t,A,e,i)=>{for(var g=i>1?void 0:i?rgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ngA(A,e,g),g};const gy=CA("freecam"),fl=CA("debugcamerafit"),Iy=CA("smoothcam"),BgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vR;class ml extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class xt extends JA{constructor(){super(...arguments),n(this,"autoFit",!1),n(this,"enableRotate",!0),n(this,"autoRotate",!1),n(this,"autoRotateSpeed",1),n(this,"enableKeys",!0),n(this,"enableDamping",!0),n(this,"dampingFactor",.1),n(this,"enableZoom",!0),n(this,"minZoom",0),n(this,"maxZoom",1/0),n(this,"enablePan",!0),n(this,"lookAtConstraint",null),n(this,"lookAtConstraint01",1),n(this,"allowInterrupt",!0),n(this,"middleClickToFocus",!0),n(this,"doubleClickToFocus",!0),n(this,"useSlerp",!0),n(this,"debugLog",!1),n(this,"targetLerpDuration",1),n(this,"autoTarget",!0),n(this,"_controls",null),n(this,"_cameraObject",null),n(this,"_lookTargetLerpActive",!1),n(this,"_lookTargetStartPosition",new y),n(this,"_lookTargetEndPosition",new y),n(this,"_lookTargetLerp01",0),n(this,"_lookTargetLerpDuration",0),n(this,"_cameraLerpActive",!1),n(this,"_cameraStartPosition",new y),n(this,"_cameraEndPosition",new y),n(this,"_cameraLerp01",0),n(this,"_cameraLerpDuration",0),n(this,"_inputs",0),n(this,"_enableTime",0),n(this,"_startedListeningToKeyEvents",!1),n(this,"_eventSystem"),n(this,"_afterHandleInputFn"),n(this,"_camera",null),n(this,"_syncedTransform"),n(this,"_didStart",!1),n(this,"targetElement",null),n(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),n(this,"_shouldDisable",!1),n(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const A=iA.getComponent(this.gameObject,Tt);if(A&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const e=he(A.cam).length(),i=new y(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setLookTargetPosition(i,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const e=new zI;e.screenPoint=new eA(0,0),e.lineThreshold=.1;const i=this.context.physics.raycast(e);i.length>0&&this.setLookTargetPosition(i[0].point,!0),fl&&console.log("OrbitControls hits",...i)}this.autoFit&&this.fitCamera()}this._eventSystem=go.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(JR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(JR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=iA.getComponent(this.gameObject,Tt);this._camera=A;const e=A?.cam;if(e&&N2(e,this,!0),!this._controls){if(!e){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}e&&(this._cameraObject=e);const i=this.targetElement??this.context.domElement,g=e?.quaternion.clone();this._controls=new wiA(e,i),e?.quaternion.copy(g),vR===void 0&&(vR={...this._controls.keys})}this._controls&&(gy&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,KC()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?gy||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):gy||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=iA.getComponent(this.gameObject,mn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&N2(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.length()||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let i=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(i||(i=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),i&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new ml(this,"camera"));else{const g=$A.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,g)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new ml(this,"lookat"));else{const g=$A.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,g)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vR:BgA,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,typeof Iy=="number"||Iy===!0){this._controls.enableDamping=!0;const g=typeof Iy=="number"?Iy:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,g))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!gy&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(A){if(!A||!(A instanceof fA))return;const e=he(A),i=yk(A);this.setTargetFromRaycast(new As(e,i)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var i,g;A&&(A instanceof fA&&(A=he(A)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((g=this._cameraObject)==null?void 0:g.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof fA&&(A=he(A)),this._lookTargetEndPosition.copy(A),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){var e,i;if(!this.controls)return;const g=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const I of g)if(I.distance>0&&iA.isActiveInHierarchy(I.object)){const o=ey(I.object);if(o){const s=o.canvas;if(s!=null&&s.screenspace)break}if(this.setLookTargetPosition(I.point),this.context.mainCamera){const s=he(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(i=(e=this._cameraObject)==null?void 0:e.parent)==null||i.worldToLocal(s),this.setCameraTargetPosition(s)}break}}fitCamera(A,e=1.1,i=!0){const g=this._cameraObject,I=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0||!g||!I)return;const o=new y,s=new y,C=new Fi;C.makeEmpty();const a=[];function r(u){let p=!0;if(u.visible&&agA(u)!==!1&&!(u.type==="TransformControlsGizmo"||u.type==="TransformControlsPlane")&&(u instanceof tk&&(p=!1),u instanceof ek&&(p=!1),u instanceof K2&&(p=!1),u.material instanceof uu&&(p=!1),u instanceof uA||(p=!1),u!==g&&u.isUI!==!0)){if(p){fl&&console.log(u.name,u.type,u);const D=u.children;u.children=a;const S=u.position,G=u.scale;if(Number.isNaN(S.x)||Number.isNaN(S.y)||Number.isNaN(S.z)){console.warn(`Object "${u.name}" has NaN values in position or scale.... will ignore it`,S,G);return}C.expandByObject(u,!0),u.children=D}for(const D of u.children)r(D)}}for(const u of A)u.updateMatrixWorld(),r(u);if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",g,C,[...A]);return}if(o.length()<=1e-10){fl&&console.warn("Camera fit size is zero",C,[...A]);return}const B=g.fov,Q=2*Math.atan(Math.tan(B*Math.PI/360/2)*g.aspect)/Math.PI*360,E=o.y/(2*Math.atan(Math.PI*B/360)),h=o.x/(2*Math.atan(Math.PI*Q/360)),d=e*Math.max(E,h)+o.z/2;fl&&console.log("Fit camera to objects",E,h,"distance",d);const l=he(g),c=I.target.clone().sub(l).normalize().multiplyScalar(d);if(I.maxDistance=d*10,I.minDistance=d*.01,this.setLookTargetPosition(s,i),this.autoTarget=!1,g.near=d/100,g.far=d*100,g.updateMatrixWorld(),g.updateProjectionMatrix(),g.parent){const u=g.parent.worldToLocal(I.target.clone().sub(c));this.setCameraTargetPosition(u,i)}else console.error(`Can not fit camera ${g.name} because it has no parent`);if(fl){const u=new tk(C);this.context.scene.add(u),Sk(u,Bc(g)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",p=>{p.code==="KeyF"&&this.fitCamera(A)}))}I.update()}}mg([w()],xt.prototype,"autoFit",2),mg([w()],xt.prototype,"enableRotate",2),mg([w()],xt.prototype,"autoRotate",2),mg([w()],xt.prototype,"autoRotateSpeed",2),mg([w()],xt.prototype,"enableKeys",2),mg([w()],xt.prototype,"enableDamping",2),mg([w()],xt.prototype,"dampingFactor",2),mg([w()],xt.prototype,"enableZoom",2),mg([w()],xt.prototype,"minZoom",2),mg([w()],xt.prototype,"maxZoom",2),mg([w()],xt.prototype,"enablePan",2),mg([w(ll)],xt.prototype,"lookAtConstraint",2),mg([w()],xt.prototype,"lookAtConstraint01",2),mg([w()],xt.prototype,"allowInterrupt",2),mg([w()],xt.prototype,"middleClickToFocus",2),mg([w()],xt.prototype,"doubleClickToFocus",2),mg([w()],xt.prototype,"targetLerpDuration",2);var QgA=Object.defineProperty,EgA=Object.getOwnPropertyDescriptor,Io=(t,A,e,i)=>{for(var g=i>1?void 0:i?EgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&QgA(A,e,g),g},Xr=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(Xr||{});const $r=CA("debugcam"),J2=CA("debugscreenpointtoray");var oy;const kl=(oy=class extends JA{constructor(){super(...arguments),n(this,"_nearClipPlane",.1),n(this,"_farClipPlane",1e3),n(this,"orthographic",!1),n(this,"orthographicSize",5),n(this,"ARBackgroundAlpha",0),n(this,"_cullingMask",4294967295),n(this,"_backgroundBlurriness"),n(this,"_backgroundIntensity"),n(this,"_environmentIntensity"),n(this,"_targetTexture",null),n(this,"_backgroundColor"),n(this,"_fov"),n(this,"_cam",null),n(this,"_clearFlags",2),n(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof ze?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof ze){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){const i=this.cam,g=kl._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),J2&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=kl._direction.set(g.x,g.y,g.z),o=he(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new As(o.clone(),I.clone())}awake(){J2&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);Vs.DrawRay(i.origin,i.direction,g,10)})}onEnable(){$r&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Xr[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),cgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;if(t){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof ze&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof ze&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new GC(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){$r&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,$r){const t=`Camera "${this.name}" clear flags: ${Xr[this._clearFlags]}`;console.log(t)}switch(this._clearFlags){case 1:if(kl.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),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;kl.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}else $r&&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 hgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;if(typeof I._transparent=="boolean")return I._transparent;const o=I.environmentBlendMode;$r&&li("Environment blend mode: "+o+" on "+navigator.userAgent);let s=o==="additive"||o==="alpha-blend";return t.xrSessionMode===zc.ImmersiveAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))&&(s=!0),I._transparent=s,s}},n(oy,"_origin",new y),n(oy,"_direction",new y),oy);let Tt=kl;Io([w()],Tt.prototype,"fieldOfView",1),Io([w()],Tt.prototype,"nearClipPlane",1),Io([w()],Tt.prototype,"farClipPlane",1),Io([w()],Tt.prototype,"clearFlags",1),Io([w()],Tt.prototype,"orthographic",2),Io([w()],Tt.prototype,"orthographicSize",2),Io([w()],Tt.prototype,"ARBackgroundAlpha",2),Io([w()],Tt.prototype,"cullingMask",1),Io([w()],Tt.prototype,"backgroundBlurriness",1),Io([w()],Tt.prototype,"backgroundIntensity",1),Io([w()],Tt.prototype,"environmentIntensity",1),Io([w(wt)],Tt.prototype,"backgroundColor",1),Io([w(jQ)],Tt.prototype,"targetTexture",1);class hgA{constructor(A){n(this,"_camera"),n(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&($r&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=ho,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)),($r||Oe())&&gg(`Camera "${this._camera.name}" has no skybox texture`))}}function cgA(t){CA("freecam")&&t.context.mainCameraComponent===t&&iA.getOrAddComponent(t.gameObject,xt)}class Gn extends JA{constructor(){super(...arguments),n(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Fv),this._listener}awake(){yi.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=this.context.mainCameraComponent||iA.getComponentInParent(this.gameObject,Tt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A)})}}var lgA=Object.defineProperty,dgA=Object.getOwnPropertyDescriptor,sy=(t,A,e,i)=>{for(var g=i>1?void 0:i?dgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lgA(A,e,g),g};const pgA=CA("debugsignals");class Gl{constructor(){n(this,"guid")}}sy([w()],Gl.prototype,"guid",2);class lE{constructor(){n(this,"signal"),n(this,"reaction")}}sy([w(Gl)],lE.prototype,"signal",2),sy([w(wg)],lE.prototype,"reaction",2);var qR;const Ba=(qR=class extends JA{constructor(){super(...arguments),n(this,"events")}static invoke(t){if(Ba.receivers[t]){const A=Ba.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){pgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)Ba.receivers[t.signal.guid]||(Ba.receivers[t.signal.guid]=[]),Ba.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(Ba.receivers[t.signal.guid]){const A=Ba.receivers[t.signal.guid].indexOf(this);A>=0&&Ba.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;const A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},n(qR,"receivers",{}),qR);let dE=Ba;sy([w(lE)],dE.prototype,"events",2);var oo=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(oo||{}),AC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(AC||{}),bR=(t=>(t.Signal="SignalEmitter",t))(bR||{});const Qa=CA("debugtimeline");class Ml{constructor(){n(this,"director"),n(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class ugA{constructor(A){n(this,"clip"),n(this,"rootPositionOffset"),n(this,"rootQuaternionOffset"),n(this,"rootStartPosition"),n(this,"rootEndPosition"),n(this,"rootStartQuaternion"),n(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";Qa&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new y().fromArray(o.values,0),this.rootEndPosition=new y().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Qa&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new MA().fromArray(o.values,0),this.rootEndQuaternion=new MA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Qa)){const s=new Gi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Cy extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"trackOffset"),n(this,"target"),n(this,"mixer"),n(this,"clips",[]),n(this,"actions",[]),n(this,"_actionOffsets",[]),n(this,"_didBind",!1),n(this,"_animator",null),n(this,"_useclipOffsets",!0),n(this,"_totalOffsetPosition",new y),n(this,"_totalOffsetRotation",new MA),n(this,"_totalOffsetPosition2",new y),n(this,"_totalOffsetRotation2",new MA),n(this,"_summedPos",new y),n(this,"_tempPos",new y),n(this,"_summedRot",new MA),n(this,"_tempRot",new MA),n(this,"_clipRotQuat",new MA)}onStateChanged(){this._animator&&v2(this._animator.gameObject,this,this.director.isPlaying)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,r=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(r=!0,this.createRotationInterpolant(e,A,B));if(!a||!r){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),d=h.substring(h.lastIndexOf(".")+1),l=B.getObjectByName(d);if(l)if(a){if(!r){const c=e.tracks[0].name.substring(0,E)+".quaternion";Qa&&console.warn("Create quaternion track",d,l);const u=l.quaternion,p=new qs(c,[0,e.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);e.tracks.push(p),this.createRotationInterpolant(e,A,p)}}else{const c=h+".position";Qa&&console.warn("Create position track",d,l);const u=l.position,p=new RC(c,[0,e.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);e.tracks.push(p),this.createPositionInterpolant(e,A,p)}}}bind(){if(!this._didBind){this._didBind=!0,Qa&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new ugA(A);this._actionOffsets.push(e)}this.target&&(this._animator=iA.getComponent(this.target,kg)??null,this._animator&&v2(this._animator.gameObject,this,!0));for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new y(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new MA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new y(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new MA(e.x,e.y,e.z,e.w)))}}evaluate(A){var e,i,g,I,o,s,C;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let a=0,r=0,B=!1,Q=!1,E=0;for(let h=0;h<this.clips.length;h++){const d=this.models[h],l=this.actions[h],c=d.asset;l.weight=0;const u=A>=d.start&&A<=d.end,p=d.preExtrapolationMode,D=d.postExtrapolationMode,S=h<this.clips.length-1?this.models[h+1]:null;let G=u,k=!1;if(!G&&!B&&d.end<A&&D!==AC.None?(!S||S.start>A)&&(G=!0,B=!0):h==0&&!G&&!Q&&d.start>A&&p!==AC.None&&(!S||S.start<A)&&(G=!0,k=!0,Q=!0),G){let R=1;R*=this.evaluateWeight(A,h,this.models,G),R*=this.director.weight;let m=u;if(k)switch(p){case AC.Hold:break;case AC.Loop:A+=d.start,m=!0;break;default:A+=d.start,m=!0;break}let f=this.getClipTime(A,d),b=0;const H=c.duration;if(k&&p===AC.Hold&&(f=0),m){if(c.loop)for(b+=Math.floor(f/(H+1e-6));f>H;)f-=H}else if(!u&&B)switch(D){case AC.Hold:f=this.getClipTime(d.end,d);break;case AC.Loop:f%=H;break;case AC.PingPong:const O=Math.floor(f/H)%2!==0;f%=H,O&&(f=H-f);break}d.reversed===!0?l.time=l.getClip().duration-f:l.time=f,l.timeScale=0;const L=Math.max(0,R);if(l.weight=L,E+=L,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const O=a==0?this._totalOffsetPosition:this._totalOffsetPosition2,Z=a==0?this._totalOffsetRotation:this._totalOffsetRotation2;a<1&&(r=1-R),a+=1;const T=this._summedPos.set(0,0,0),v=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),IA=this._tempRot.identity(),AA=c.rotation;AA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(AA,R));const W=this._actionOffsets[h];if(W.hasOffsets)for(let gA=0;gA<b;gA++)W.rootPositionOffset?v.copy(W.rootPositionOffset):v.set(0,0,0),v.applyQuaternion(Y),this._clipRotQuat&&v.applyQuaternion(this._clipRotQuat),W.rootQuaternionOffset&&(IA.copy(W.rootQuaternionOffset),Y.multiply(IA)),T.add(v);this._clipRotQuat&&Z.multiply(this._clipRotQuat),Z.multiply(Y),c.position&&T.add(c.position),O.add(T)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,r),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,r)),this.__mixerError===void 0&&(Qa||Oe())&&(i=(e=this._animator)==null?void 0:e.runtimeAnimatorController)!=null&&i.mixer&&this.mixer!==((I=(g=this._animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const h=Math.max(0,1-E);(C=(s=this._animator)==null?void 0:s.runtimeAnimatorController)==null||C.update(h)}else this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new MA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=r=>{var B;const Q=a(r);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(B=E?.onTimelineRotation)==null||B.call(E,this.director,this.target,r,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new y;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let r;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,d,l;const c=Q(E);if(s.set(c[0],c[1],c[2]),e.removeStartOffset&&(r===void 0?(r=null,r=(d=(h=this._actionOffsets.find(u=>u.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:d.clone()):r!=null&&r.isVector3&&s.sub(r)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(l=u?.onTimelinePosition)==null||l.call(u,this.director,this.target,E,s);return c[0]=s.x,c[1]=s.y,c[2]=s.z,c},B}}}const DgA=CA("mutetimeline"),Rl=class extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"listener"),n(this,"audio",[]),n(this,"audioContextTimeOffset",[]),n(this,"lastTime",0),n(this,"audioSource"),n(this,"_audioLoader",null)}getAudioFilePath(t){const A=this.director.sourceId;return FC(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new Vm(this.listener);this.audio.push(A),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}evaluate(t){if(DgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=A?.1:0;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=this.audio[i],o=g.asset;if((!I||!I.buffer)&&this.isInTimeRange(g,t-1,t+1)&&this.handleAudioLoading(g,I),yi.userInteractionRegistered!==!1&&!(I===null||!I.buffer))if(I.playbackRate=this.director.context.time.timeScale*this.director.speed,I.loop=o.loop,t>=g.start&&t<=g.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(I.isPlaying&&I.stop(),this.lastTime===t)continue}else if(!I.isPlaying)I.offset=g.clipIn+(t-g.start)*g.timeScale,I.play(e);else{const C=g.clipIn+(t-g.start)*g.timeScale,a=I.context.currentTime-I._startedAt+I.offset;Math.abs(C-a)>.3&&(I.offset=C,I.stop(),I.play(e))}let s=o.volume;if(this.track.volume!==void 0&&(s*=this.track.volume),A&&(s=0),g.easeInDuration>0){const C=Math.min((t-g.start)/g.easeInDuration,1);s*=C}if(g.easeOutDuration>0){const C=Math.min((g.end-t)/g.easeOutDuration,1);s*=C}I.setVolume(s*this.director.weight)}else I.isPlaying&&I.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Rl._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new Gu);const e=this.getAudioFilePath(t.asset.clip);if(Rl._audioBuffers.get(e)){const g=Rl._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}Qa&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Rl._audioBuffers.set(e,i),i}};let Ul=Rl;n(Ul,"_audioBuffers",new Map);class Nl extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"didTrigger",[]),n(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);(a===0||a>=1e-5&&a<i)&&(C=!0)}if(C){if(!o)if(Qa&&console.log("Trigger signal",A,I.time,I),this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)dE.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class ay extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"timelines",[]),n(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=iA.getComponent(i.sourceObject,AB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}const pE=CA("debugtimeline"),LR=class extends JA{constructor(){super(...arguments),n(this,"playableAsset"),n(this,"playOnAwake"),n(this,"extrapolationMode",1),n(this,"waitForAudio",!0),n(this,"_visibilityChangeEvt"),n(this,"_clonedPlayableAsset",!1),n(this,"_speed",1),n(this,"_guidsMap"),n(this,"_isPlaying",!1),n(this,"_internalUpdateRoutine"),n(this,"_isPaused",!1),n(this,"_isStopping",!1),n(this,"_time",0),n(this,"_duration",0),n(this,"_weight",1),n(this,"_animationTracks",[]),n(this,"_audioTracks",[]),n(this,"_signalTracks",[]),n(this,"_controlTracks",[]),n(this,"_customTracks",[]),n(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),n(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(pE||gI())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;pE&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A,e;for(const i of this._audioTracks)(t=i.onEnable)==null||t.call(i);for(const i of this._customTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onEnable)==null||e.call(i);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A,e;this.stop();for(const i of this._audioTracks)(t=i.onDisable)==null||t.call(i);for(const i of this._customTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onDisable)==null||e.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yi.userInteractionRegistered&&this.waitForAudio;)await Za(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),og.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),A&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}invokeStateChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onStateChanged)==null||t.call(A,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let A=this._time;switch(this.extrapolationMode){case 0:this._speed>0?A=Math.min(A,this._duration):this._speed<0&&(A=Math.max(A,0)),this._time=A;break;case 1:A%=this._duration,this._time=A;break;case 2:if(A>this._duration){this.stop();return}break}const e=this._time;for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case oo.Activation:if(!t&&!this._isPlaying)continue;for(let g=0;g<i.outputs.length;g++){const I=i.outputs[g];if(typeof I=="object"){let o=!1;if(i.clips)for(const C of i.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&s.visible!==o&&(s.visible=o,pE&&console.warn(this.name,"set ActivationTrack-"+g,s.name,o,e))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(e);for(const i of this._audioTracks)i.evaluate(e);for(const i of this._signalTracks)i.evaluate(e);for(const i of this._controlTracks)i.evaluate(e);for(const i of this._customTracks)i.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=bu(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=iA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(pE&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),LR.createTrackFunctions[A.type])continue;A.type!==oo.Audio&&A.type!==oo.Control&&A.type!==oo.Marker&&A.type!==oo.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===oo.Control&&A.clips)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=iA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(pE&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);if(t.markers)for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let i=iA.findObjectOfType(Gn,this.context);for(const g of this.playableAsset.tracks){const I=g.type,o=LR.createTrackFunctions[I];if(o!=null){const s=o(this,g);if(typeof s.evaluate=="function"){s.director=this,s.track=g,this._customTracks.push(s);continue}}if(g.type===oo.Animation){if(!g.clips||g.clips.length<=0){pE&&console.warn("Animation track has no clips",g);continue}for(let s=g.outputs.length-1;s>=0;s--){let C=g.outputs[s];if(C instanceof fA){const r=iA.getOrAddComponent(C,kg);r&&(C=r)}const a=(t=C?.gameObject)==null?void 0:t.animations;if(a){const r=new Cy;r.trackOffset=g.trackOffset,r.director=this,r.track=g;for(let B=0;B<g.clips.length;B++){const Q=g.clips[B],E=Q.asset;if(!E){console.error("MISSING anim model?","clip#"+B,Q,g,this.playableAsset,this.name);continue}const h=E.clip;let d=h;if((typeof d=="string"||typeof d=="number")&&(d=a.find(c=>c.name===h)),!d){console.warn("Could not find animationClip for model",Q,g.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}C instanceof kg&&C.runtimeAnimatorController&&(C.__internalDidAwakeAndStart||C.initializeRuntimeAnimatorController(),C.runtimeAnimatorController.mixer||C.runtimeAnimatorController.bind(C),r.mixer=C.runtimeAnimatorController.mixer),r.mixer||(r.mixer=new Mu(C.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(Q.asset,d);const l=r.mixer.clipAction(d);r.actions.push(l),r.models.push(Q)}this._animationTracks.push(r)}}}else if(g.type===oo.Audio){if(!g.clips||g.clips.length<=0)continue;const s=new Ul;s.director=this,s.track=g,s.audioSource=g.outputs.find(C=>C instanceof yi),this._audioTracks.push(s),i||(i=(e=this.context.mainCameraComponent)==null?void 0:e.gameObject.addNewComponent(Gn)),s.listener=i.listener;for(let C=0;C<g.clips.length;C++){const a=g.clips[C];s.addModel(a)}}else if(g.type===oo.Marker){const s=new Nl;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)switch(C.type){case bR.Signal:s.models.push(C),s.didTrigger.push(!1);break}if(s!==null&&s.models.length>0){const C=iA.getComponent(this.gameObject,dE);C&&(s.receivers.push(C),this._signalTracks.push(s))}}else if(g.type===oo.Signal){const s=new Nl;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)s.models.push(C),s.didTrigger.push(!1);for(const C of g.outputs)s.receivers.push(C);this._signalTracks.push(s)}else if(g.type===oo.Control){const s=new ay;if(s.director=this,s.track=g,g.clips)for(const C of g.clips)s.models.push(C);s.resolveSourceObjects(this.context),this._controlTracks.push(s)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const A=this.animationCallbackReceivers.indexOf(t);A!==-1&&this.animationCallbackReceivers.splice(A,1)}};let AB=LR;n(AB,"createTrackFunctions",{});const ny=Symbol("objectIsAnimatedData");function v2(t,A,e){if(!t)return;if(t[ny]===void 0){if(!e)return;t[ny]=new Set}const i=t[ny];e?i.add(A):i.has(A)&&i.delete(A)}function wgA(t){if(!t)return!1;const A=t[ny];return A!==void 0&&A.size>0}Gt.registerCallback(zi.ContextCreated,t=>{const A=t.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&t.files)for(const e of t.files)iA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof Ao&&i.playAutomatically||i instanceof kg||i instanceof AB&&i.playOnAwake===!0)return!0;if(i instanceof Ao)return i.playAutomatically=!0,!0;if(i instanceof AB)return i.playOnAwake=!0,!0}},!0)!==!0&&ygA(e.file)});function ygA(t){if(!t||!t.animations)return;for(let e=0;e<t.animations.length;e++){const i=t.animations[e];if(!(!i.tracks||i.tracks.length<=0))for(const g in i.tracks){const I=i.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=t.scene.getObjectByName(o);if(!s&&(s=t.scene.getObjectByProperty("uuid",o),!s))continue;let C=A(s);C||(C=tn(t.scene,new Ao));const a=C.animations=C.animations||[];i.name_animator=C.name,a.indexOf(i)<0&&a.push(i)}}function A(e){var i;if(!e)return;const g=(i=e.userData)==null?void 0:i.components;if(g&&g.length>0)for(let I=0;I<g.length;I++){const o=g[I];if(o instanceof kg||o instanceof Ao)return e}return A(e.parent)}}var SgA=Object.defineProperty,fgA=Object.getOwnPropertyDescriptor,ry=(t,A,e,i)=>{for(var g=i>1?void 0:i?fgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SgA(A,e,g),g};const q2=CA("debuganimator");class kg extends JA{constructor(){super(...arguments),n(this,"applyRootMotion",!1),n(this,"hasRootMotion",!1),n(this,"keepAnimatorControllerStateOnDisable",!1),n(this,"_parametersAreDirty",!1),n(this,"_isDirty",!1),n(this,"speed",1),n(this,"normalizedStartOffset",0),n(this,"_animatorController",null),n(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(A){var e;this._animatorController&&this._animatorController.model===A||(A?A instanceof Vo?(A.animator&&A.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(e=A.model)==null?void 0:e.name),A.model||console.error("AnimatorController has no model"),A=new Vo(A.model)),this._animatorController=A,this._animatorController.bind(this)):(q2&&console.log("Assign animator controller",A,this),this._animatorController=new Vo(A),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){this.play(A,e,i,g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){var I;(I=this.runtimeAnimatorController)==null||I.play(A,e,i,g),this._isDirty=!0}Reset(){this.reset()}reset(){var A;(A=this._animatorController)==null||A.reset(),this._isDirty=!0}SetBool(A,e){this.setBool(A,e)}setBool(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getBool(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setBool(A,e)}GetBool(A){return this.getBool(A)}getBool(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getBool(A))??!1}SetFloat(A,e){this.setFloat(A,e)}setFloat(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setFloat(A,e)}GetFloat(A){return this.getFloat(A)}getFloat(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getFloat(A))??-1}SetInteger(A,e){this.setInteger(A,e)}setInteger(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setInteger(A,e)}GetInteger(A){return this.getInteger(A)}getInteger(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getInteger(A))??-1}SetTrigger(A){this.setTrigger(A)}setTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.setTrigger(A),this._parametersAreDirty=!0}ResetTrigger(A){this.resetTrigger(A)}resetTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.resetTrigger(A),this._parametersAreDirty=!0}GetTrigger(A){this.getTrigger(A)}getTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.getTrigger(A)}IsInTransition(){return this.isInTransition()}isInTransition(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.isInTransition())??!1}SetSpeed(A){return this.setSpeed(A)}setSpeed(A){var e;A!==this.speed&&(this.speed=A,(e=this._animatorController)==null||e.setSpeed(A))}set minMaxSpeed(A){this.speed=$A.lerp(A.x,A.y,Math.random())}set minMaxOffsetNormalized(A){this.normalizedStartOffset=$A.lerp(A.x,A.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){q2&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(A=!1){const e=A||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&e){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var A;this.keepAnimatorControllerStateOnDisable||(A=this._animatorController)==null||A.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!wgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}ry([w()],kg.prototype,"applyRootMotion",2),ry([w()],kg.prototype,"hasRootMotion",2),ry([w()],kg.prototype,"keepAnimatorControllerStateOnDisable",2),ry([w()],kg.prototype,"runtimeAnimatorController",1);const uE=CA("debugusdzanimation"),xR=CA("debugusdzanimationserialization");class By{constructor(A,e,i){n(this,"_start"),n(this,"ext"),n(this,"root"),n(this,"clip"),this.ext=A,this.root=e,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Lo{constructor(A,e,i){n(this,"clip"),n(this,"pos"),n(this,"rot"),n(this,"scale"),n(this,"root"),n(this,"target"),n(this,"duration",0),n(this,"useRootMotion",!1),this.root=A,this.target=e,this.clip=i,i?this.duration=i.duration:this.duration=1/this.frameRate;const g=iA.getComponent(A,kg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,i,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(i=this.rot)==null?void 0:i.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,i=!0){var g,I,o;if(!this.clip)return[0,this.duration];const s=(g=this.pos)==null?void 0:g.times,C=(I=this.rot)==null?void 0:I.times,a=(o=this.scale)==null?void 0:o.times,r=[];if(A&&s)for(const B of s)r.push(B);if(e&&C)for(const B of C)r.push(B);if(i&&a)for(const B of a)r.push(B);return r.includes(0)||r.push(0),r.sort((B,Q)=>B-Q),[...new Set(r)]}*getValues(A,e=!0,i=!0,g=!0){var I,o,s;const C=new y,a=new MA,r=new y(1,1,1),B=this.target,Q=e?(I=this.pos)==null?void 0:I.createInterpolant():void 0,E=i?(o=this.rot)==null?void 0:o.createInterpolant():void 0,h=g?(s=this.scale)==null?void 0:s.createInterpolant():void 0;Q||C.set(B.position.x,B.position.y,B.position.z),E||a.set(B.quaternion.x,B.quaternion.y,B.quaternion.z,B.quaternion.w),h||r.set(B.scale.x,B.scale.y,B.scale.z);for(let d=0;d<A.length;d++){const l=A[d];if(Q){const c=Q.evaluate(l);C.set(c[0],c[1],c[2])}if(E){const c=E.evaluate(l);a.set(c[0],c[1],c[2],c[3])}if(h){const c=h.evaluate(l);r.set(c[0],c[1],c[2])}if(this.useRootMotion&&B===this.root){const c=new NA;c.compose(C,a,r),c.multiply(B.matrix),c.decompose(C,a,r)}yield{time:l,translation:C,rotation:a,scale:r,index:d}}}}n(Lo,"animationDurationPadding",1);class Fl{constructor(A){n(this,"dict",new Map),n(this,"rootTargetMap",new Map),n(this,"rootAndClipToRegisteredAnimationMap",new Map),n(this,"rootToRegisteredClipCount",new Map),n(this,"serializers",[]),n(this,"injectRestPoses",!1),n(this,"injectImplicitBehaviours",!1),this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const i=this.rootTargetMap.get(A);if(!i)return 0;const g=this.dict.get(i[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+Lo.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const i=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);uE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const a of e.tracks){const r=He.parseTrackName(a.name),B=He.findNode(A,r.nodeName);if(!B){console.warn("no object found for track",a.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const h=new Lo(null,B,void 0);Q[0]=h}let E=Q[I];E||(E=new Lo(A,B,e),Q[I]=E),E.addTrack(a),o!=null&&o.includes(B)||o==null||o.push(B)}for(const a of s){const r=this.dict.get(a);if(!r)continue;if(this.injectRestPoses&&!r[0]){const Q=new Lo(null,a,void 0);r[0]=Q}let B=r[I];B||(uE&&console.log("Adding padding clip for ",a,e),B=new Lo(A,a,e),r[I]=B)}const C=new By(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(i,C),this.rootToRegisteredClipCount.set(A,I+1),C}onAfterHierarchy(A){uE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,i;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=I?.isDynamic===!0;xR&&console.log(o,(i=g.model)==null?void 0:i.parent),o&&g.registerCallback(I)}}onExportObject(A,e,i){iA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,i)},!1);const g=new mgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class mgA{constructor(A,e){n(this,"object"),n(this,"dict"),n(this,"model"),n(this,"callback"),this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),xR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const i=this.model,g=this.dict;if(i&&i.skinnedMesh){let I=function(k){const R=[];for(const[m,f]of k){let b=`${m} : [`;const H=[];for(const L of f)H.push(`(${Cg(L.x)}, ${Cg(L.y)}, ${Cg(L.z)})`);b=b.concat(H.join(", ")),b=b.concat("],"),R.push(b)}return R},o=function(k){const R=[];for(const[m,f]of k){let b=`${m} : [`;const H=[];for(const L of f)H.push(`(${Cg(L.w)}, ${Cg(L.x)}, ${Cg(L.y)}, ${Cg(L.z)})`);b=b.concat(H.join(", ")),b=b.concat("],"),R.push(b)}return R},s=function(k){let R=!0,m;for(const[b,H]of k)if(m===void 0&&(m=H.length),m!==H.length){R=!1;break}uE&&console.log("Bone count: ",k.size,"TransformData entries per bone: ",m),console.assert(R,"All bones should have the same number of TransformData entries",k);const f=[];for(const[b,H]of k){const L=new Array;let O=0;for(let Z=0;Z<H.length;Z++)L.push(O),O+=H[Z].getDuration()+Lo.animationDurationPadding;for(let Z=0;Z<H.length;Z++){const T=H[Z],v=L[Z];f.length<=Z&&f.push({pos:[],rot:[],scale:[],timeOffset:v});const Y=f[Z];Y.pos.push(...T.getSortedTimesArray(!0,!1,!1)),Y.rot.push(...T.getSortedTimesArray(!1,!0,!1)),Y.scale.push(...T.getSortedTimesArray(!1,!1,!0))}}for(const b of f)b.pos.sort((H,L)=>H-L),b.rot.sort((H,L)=>H-L),b.scale.sort((H,L)=>H-L),b.pos=[...new Set(b.pos)],b.rot=[...new Set(b.rot)],b.scale=[...new Set(b.scale)];return f},C=function(k,R,m){const f=new Map,b=new Map,H=new Map,L=R.length;for(const O of m){const Z=k.get(O);let T;Z?console.assert(Z.length===L,"We should have the same number of TransformData entries for each bone",Z,R):T=new Lo(null,O,void 0);for(let v=0;v<L;v++){const Y=Z?Z[v]:T,IA=R[v];for(const{time:AA,translation:W}of Y.getValues(IA.pos,!0,!1,!1)){const gA=(AA+IA.timeOffset)*60;f.has(gA)||f.set(gA,new Array),f.get(gA).push(W.clone())}for(const{time:AA,rotation:W}of Y.getValues(IA.rot,!1,!0,!1)){const gA=(AA+IA.timeOffset)*60;b.has(gA)||b.set(gA,new Array),b.get(gA).push(W.clone())}for(const{time:AA,scale:W}of Y.getValues(IA.scale,!1,!1,!0)){const gA=(AA+IA.timeOffset)*60;H.has(gA)||H.set(gA,new Array),H.get(gA).push(W.clone())}}}return{position:f.size==0?void 0:f,quaternion:b.size==0?void 0:b,scale:H.size==0?void 0:H}},a=function(k){const R=[];for(const m of k)R.push(`(${Cg(m.x)}, ${Cg(m.y)}, ${Cg(m.z)})`);return R.join(", ")},r=function(k){const R=[];for(const m of k)R.push(`(${Cg(m.w)}, ${Cg(m.x)}, ${Cg(m.y)}, ${Cg(m.z)})`);return R.join(", ")},B=function(k){const R=new Map;if(uE){const m=new Array;for(const[f,b]of g)m.push(f.uuid+": "+b.length+" "+b.map(H=>{var L;return(L=H.clip)==null?void 0:L.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5189
|
+
`,o={map:{value:A},height:{value:e.height||15},radius:{value:e.radius||100}},s=new zd(1,16),C=new Ue({uniforms:o,fragmentShader:I,vertexShader:g,side:St});super(s,C)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}}var ngA=Object.defineProperty,rgA=Object.getOwnPropertyDescriptor,mg=(t,A,e,i)=>{for(var g=i>1?void 0:i?rgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ngA(A,e,g),g};const gy=CA("freecam"),fl=CA("debugcamerafit"),Iy=CA("smoothcam"),BgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vR;class ml extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class xt extends JA{constructor(){super(...arguments),n(this,"autoFit",!1),n(this,"enableRotate",!0),n(this,"autoRotate",!1),n(this,"autoRotateSpeed",1),n(this,"enableKeys",!0),n(this,"enableDamping",!0),n(this,"dampingFactor",.1),n(this,"enableZoom",!0),n(this,"minZoom",0),n(this,"maxZoom",1/0),n(this,"enablePan",!0),n(this,"lookAtConstraint",null),n(this,"lookAtConstraint01",1),n(this,"allowInterrupt",!0),n(this,"middleClickToFocus",!0),n(this,"doubleClickToFocus",!0),n(this,"useSlerp",!0),n(this,"debugLog",!1),n(this,"targetLerpDuration",1),n(this,"autoTarget",!0),n(this,"_controls",null),n(this,"_cameraObject",null),n(this,"_lookTargetLerpActive",!1),n(this,"_lookTargetStartPosition",new y),n(this,"_lookTargetEndPosition",new y),n(this,"_lookTargetLerp01",0),n(this,"_lookTargetLerpDuration",0),n(this,"_cameraLerpActive",!1),n(this,"_cameraStartPosition",new y),n(this,"_cameraEndPosition",new y),n(this,"_cameraLerp01",0),n(this,"_cameraLerpDuration",0),n(this,"_inputs",0),n(this,"_enableTime",0),n(this,"_startedListeningToKeyEvents",!1),n(this,"_eventSystem"),n(this,"_afterHandleInputFn"),n(this,"_camera",null),n(this,"_syncedTransform"),n(this,"_didStart",!1),n(this,"targetElement",null),n(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),n(this,"_shouldDisable",!1),n(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const A=iA.getComponent(this.gameObject,Tt);if(A&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const e=he(A.cam).length(),i=new y(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setLookTargetPosition(i,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const e=new zI;e.screenPoint=new eA(0,0),e.lineThreshold=.1;const i=this.context.physics.raycast(e);i.length>0&&this.setLookTargetPosition(i[0].point,!0),fl&&console.log("OrbitControls hits",...i)}this.autoFit&&this.fitCamera()}this._eventSystem=go.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(JR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(JR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=iA.getComponent(this.gameObject,Tt);this._camera=A;const e=A?.cam;if(e&&N2(e,this,!0),!this._controls){if(!e){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}e&&(this._cameraObject=e);const i=this.targetElement??this.context.renderer.domElement,g=e?.quaternion.clone();this._controls=new wiA(e,i),e?.quaternion.copy(g),vR===void 0&&(vR={...this._controls.keys})}this._controls&&(gy&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,KC()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?gy||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):gy||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=iA.getComponent(this.gameObject,mn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&N2(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.length()||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let i=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(i||(i=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),i&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new ml(this,"camera"));else{const g=$A.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,g)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new ml(this,"lookat"));else{const g=$A.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,g)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vR:BgA,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,typeof Iy=="number"||Iy===!0){this._controls.enableDamping=!0;const g=typeof Iy=="number"?Iy:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,g))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!gy&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(A){if(!A||!(A instanceof fA))return;const e=he(A),i=yk(A);this.setTargetFromRaycast(new As(e,i)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var i,g;A&&(A instanceof fA&&(A=he(A)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((g=this._cameraObject)==null?void 0:g.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof fA&&(A=he(A)),this._lookTargetEndPosition.copy(A),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){var e,i;if(!this.controls)return;const g=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const I of g)if(I.distance>0&&iA.isActiveInHierarchy(I.object)){const o=ey(I.object);if(o){const s=o.canvas;if(s!=null&&s.screenspace)break}if(this.setLookTargetPosition(I.point),this.context.mainCamera){const s=he(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(i=(e=this._cameraObject)==null?void 0:e.parent)==null||i.worldToLocal(s),this.setCameraTargetPosition(s)}break}}fitCamera(A,e=1.1,i=!0){const g=this._cameraObject,I=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0||!g||!I)return;const o=new y,s=new y,C=new Fi;C.makeEmpty();const a=[];function r(u){let p=!0;if(u.visible&&agA(u)!==!1&&!(u.type==="TransformControlsGizmo"||u.type==="TransformControlsPlane")&&(u instanceof tk&&(p=!1),u instanceof ek&&(p=!1),u instanceof K2&&(p=!1),u.material instanceof uu&&(p=!1),u instanceof uA||(p=!1),u!==g&&u.isUI!==!0)){if(p){fl&&console.log(u.name,u.type,u);const D=u.children;u.children=a;const S=u.position,G=u.scale;if(Number.isNaN(S.x)||Number.isNaN(S.y)||Number.isNaN(S.z)){console.warn(`Object "${u.name}" has NaN values in position or scale.... will ignore it`,S,G);return}C.expandByObject(u,!0),u.children=D}for(const D of u.children)r(D)}}for(const u of A)u.updateMatrixWorld(),r(u);if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",g,C,[...A]);return}if(o.length()<=1e-10){fl&&console.warn("Camera fit size is zero",C,[...A]);return}const B=g.fov,Q=2*Math.atan(Math.tan(B*Math.PI/360/2)*g.aspect)/Math.PI*360,E=o.y/(2*Math.atan(Math.PI*B/360)),h=o.x/(2*Math.atan(Math.PI*Q/360)),d=e*Math.max(E,h)+o.z/2;fl&&console.log("Fit camera to objects",E,h,"distance",d);const l=he(g),c=I.target.clone().sub(l).normalize().multiplyScalar(d);if(I.maxDistance=d*10,I.minDistance=d*.01,this.setLookTargetPosition(s,i),this.autoTarget=!1,g.near=d/100,g.far=d*100,g.updateMatrixWorld(),g.updateProjectionMatrix(),g.parent){const u=g.parent.worldToLocal(I.target.clone().sub(c));this.setCameraTargetPosition(u,i)}else console.error(`Can not fit camera ${g.name} because it has no parent`);if(fl){const u=new tk(C);this.context.scene.add(u),Sk(u,Bc(g)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",p=>{p.code==="KeyF"&&this.fitCamera(A)}))}I.update()}}mg([w()],xt.prototype,"autoFit",2),mg([w()],xt.prototype,"enableRotate",2),mg([w()],xt.prototype,"autoRotate",2),mg([w()],xt.prototype,"autoRotateSpeed",2),mg([w()],xt.prototype,"enableKeys",2),mg([w()],xt.prototype,"enableDamping",2),mg([w()],xt.prototype,"dampingFactor",2),mg([w()],xt.prototype,"enableZoom",2),mg([w()],xt.prototype,"minZoom",2),mg([w()],xt.prototype,"maxZoom",2),mg([w()],xt.prototype,"enablePan",2),mg([w(ll)],xt.prototype,"lookAtConstraint",2),mg([w()],xt.prototype,"lookAtConstraint01",2),mg([w()],xt.prototype,"allowInterrupt",2),mg([w()],xt.prototype,"middleClickToFocus",2),mg([w()],xt.prototype,"doubleClickToFocus",2),mg([w()],xt.prototype,"targetLerpDuration",2);var QgA=Object.defineProperty,EgA=Object.getOwnPropertyDescriptor,Io=(t,A,e,i)=>{for(var g=i>1?void 0:i?EgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&QgA(A,e,g),g},Xr=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(Xr||{});const $r=CA("debugcam"),J2=CA("debugscreenpointtoray");var oy;const kl=(oy=class extends JA{constructor(){super(...arguments),n(this,"_nearClipPlane",.1),n(this,"_farClipPlane",1e3),n(this,"orthographic",!1),n(this,"orthographicSize",5),n(this,"ARBackgroundAlpha",0),n(this,"_cullingMask",4294967295),n(this,"_backgroundBlurriness"),n(this,"_backgroundIntensity"),n(this,"_environmentIntensity"),n(this,"_targetTexture",null),n(this,"_backgroundColor"),n(this,"_fov"),n(this,"_cam",null),n(this,"_clearFlags",2),n(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof ze?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof ze?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof ze){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){const i=this.cam,g=kl._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),J2&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=kl._direction.set(g.x,g.y,g.z),o=he(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new As(o.clone(),I.clone())}awake(){J2&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);Vs.DrawRay(i.origin,i.direction,g,10)})}onEnable(){$r&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Xr[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),cgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;if(t){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof ze&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof ze&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new ze(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new GC(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){$r&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,$r){const t=`Camera "${this.name}" clear flags: ${Xr[this._clearFlags]}`;console.log(t)}switch(this._clearFlags){case 1:if(kl.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),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;kl.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}else $r&&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 hgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;if(typeof I._transparent=="boolean")return I._transparent;const o=I.environmentBlendMode;$r&&li("Environment blend mode: "+o+" on "+navigator.userAgent);let s=o==="additive"||o==="alpha-blend";return t.xrSessionMode===zc.ImmersiveAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))&&(s=!0),I._transparent=s,s}},n(oy,"_origin",new y),n(oy,"_direction",new y),oy);let Tt=kl;Io([w()],Tt.prototype,"fieldOfView",1),Io([w()],Tt.prototype,"nearClipPlane",1),Io([w()],Tt.prototype,"farClipPlane",1),Io([w()],Tt.prototype,"clearFlags",1),Io([w()],Tt.prototype,"orthographic",2),Io([w()],Tt.prototype,"orthographicSize",2),Io([w()],Tt.prototype,"ARBackgroundAlpha",2),Io([w()],Tt.prototype,"cullingMask",1),Io([w()],Tt.prototype,"backgroundBlurriness",1),Io([w()],Tt.prototype,"backgroundIntensity",1),Io([w()],Tt.prototype,"environmentIntensity",1),Io([w(wt)],Tt.prototype,"backgroundColor",1),Io([w(jQ)],Tt.prototype,"targetTexture",1);class hgA{constructor(A){n(this,"_camera"),n(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&($r&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=ho,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)),($r||Oe())&&gg(`Camera "${this._camera.name}" has no skybox texture`))}}function cgA(t){CA("freecam")&&t.context.mainCameraComponent===t&&iA.getOrAddComponent(t.gameObject,xt)}class Gn extends JA{constructor(){super(...arguments),n(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Fv),this._listener}awake(){yi.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=this.context.mainCameraComponent||iA.getComponentInParent(this.gameObject,Tt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A)})}}var lgA=Object.defineProperty,dgA=Object.getOwnPropertyDescriptor,sy=(t,A,e,i)=>{for(var g=i>1?void 0:i?dgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lgA(A,e,g),g};const pgA=CA("debugsignals");class Gl{constructor(){n(this,"guid")}}sy([w()],Gl.prototype,"guid",2);class lE{constructor(){n(this,"signal"),n(this,"reaction")}}sy([w(Gl)],lE.prototype,"signal",2),sy([w(wg)],lE.prototype,"reaction",2);var qR;const Ba=(qR=class extends JA{constructor(){super(...arguments),n(this,"events")}static invoke(t){if(Ba.receivers[t]){const A=Ba.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){pgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)Ba.receivers[t.signal.guid]||(Ba.receivers[t.signal.guid]=[]),Ba.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(Ba.receivers[t.signal.guid]){const A=Ba.receivers[t.signal.guid].indexOf(this);A>=0&&Ba.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;const A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},n(qR,"receivers",{}),qR);let dE=Ba;sy([w(lE)],dE.prototype,"events",2);var oo=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(oo||{}),AC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(AC||{}),bR=(t=>(t.Signal="SignalEmitter",t))(bR||{});const Qa=CA("debugtimeline");class Ml{constructor(){n(this,"director"),n(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class ugA{constructor(A){n(this,"clip"),n(this,"rootPositionOffset"),n(this,"rootQuaternionOffset"),n(this,"rootStartPosition"),n(this,"rootEndPosition"),n(this,"rootStartQuaternion"),n(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";Qa&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new y().fromArray(o.values,0),this.rootEndPosition=new y().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Qa&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new MA().fromArray(o.values,0),this.rootEndQuaternion=new MA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Qa)){const s=new Gi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Cy extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"trackOffset"),n(this,"target"),n(this,"mixer"),n(this,"clips",[]),n(this,"actions",[]),n(this,"_actionOffsets",[]),n(this,"_didBind",!1),n(this,"_animator",null),n(this,"_useclipOffsets",!0),n(this,"_totalOffsetPosition",new y),n(this,"_totalOffsetRotation",new MA),n(this,"_totalOffsetPosition2",new y),n(this,"_totalOffsetRotation2",new MA),n(this,"_summedPos",new y),n(this,"_tempPos",new y),n(this,"_summedRot",new MA),n(this,"_tempRot",new MA),n(this,"_clipRotQuat",new MA)}onStateChanged(){this._animator&&v2(this._animator.gameObject,this,this.director.isPlaying)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,r=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(r=!0,this.createRotationInterpolant(e,A,B));if(!a||!r){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),d=h.substring(h.lastIndexOf(".")+1),l=B.getObjectByName(d);if(l)if(a){if(!r){const c=e.tracks[0].name.substring(0,E)+".quaternion";Qa&&console.warn("Create quaternion track",d,l);const u=l.quaternion,p=new qs(c,[0,e.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);e.tracks.push(p),this.createRotationInterpolant(e,A,p)}}else{const c=h+".position";Qa&&console.warn("Create position track",d,l);const u=l.position,p=new RC(c,[0,e.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);e.tracks.push(p),this.createPositionInterpolant(e,A,p)}}}bind(){if(!this._didBind){this._didBind=!0,Qa&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new ugA(A);this._actionOffsets.push(e)}this.target&&(this._animator=iA.getComponent(this.target,kg)??null,this._animator&&v2(this._animator.gameObject,this,!0));for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new y(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new MA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new y(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new MA(e.x,e.y,e.z,e.w)))}}evaluate(A){var e,i,g,I,o,s,C;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let a=0,r=0,B=!1,Q=!1,E=0;for(let h=0;h<this.clips.length;h++){const d=this.models[h],l=this.actions[h],c=d.asset;l.weight=0;const u=A>=d.start&&A<=d.end,p=d.preExtrapolationMode,D=d.postExtrapolationMode,S=h<this.clips.length-1?this.models[h+1]:null;let G=u,k=!1;if(!G&&!B&&d.end<A&&D!==AC.None?(!S||S.start>A)&&(G=!0,B=!0):h==0&&!G&&!Q&&d.start>A&&p!==AC.None&&(!S||S.start<A)&&(G=!0,k=!0,Q=!0),G){let R=1;R*=this.evaluateWeight(A,h,this.models,G),R*=this.director.weight;let m=u;if(k)switch(p){case AC.Hold:break;case AC.Loop:A+=d.start,m=!0;break;default:A+=d.start,m=!0;break}let f=this.getClipTime(A,d),b=0;const H=c.duration;if(k&&p===AC.Hold&&(f=0),m){if(c.loop)for(b+=Math.floor(f/(H+1e-6));f>H;)f-=H}else if(!u&&B)switch(D){case AC.Hold:f=this.getClipTime(d.end,d);break;case AC.Loop:f%=H;break;case AC.PingPong:const O=Math.floor(f/H)%2!==0;f%=H,O&&(f=H-f);break}d.reversed===!0?l.time=l.getClip().duration-f:l.time=f,l.timeScale=0;const L=Math.max(0,R);if(l.weight=L,E+=L,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const O=a==0?this._totalOffsetPosition:this._totalOffsetPosition2,Z=a==0?this._totalOffsetRotation:this._totalOffsetRotation2;a<1&&(r=1-R),a+=1;const T=this._summedPos.set(0,0,0),v=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),IA=this._tempRot.identity(),AA=c.rotation;AA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(AA,R));const W=this._actionOffsets[h];if(W.hasOffsets)for(let gA=0;gA<b;gA++)W.rootPositionOffset?v.copy(W.rootPositionOffset):v.set(0,0,0),v.applyQuaternion(Y),this._clipRotQuat&&v.applyQuaternion(this._clipRotQuat),W.rootQuaternionOffset&&(IA.copy(W.rootQuaternionOffset),Y.multiply(IA)),T.add(v);this._clipRotQuat&&Z.multiply(this._clipRotQuat),Z.multiply(Y),c.position&&T.add(c.position),O.add(T)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,r),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,r)),this.__mixerError===void 0&&(Qa||Oe())&&(i=(e=this._animator)==null?void 0:e.runtimeAnimatorController)!=null&&i.mixer&&this.mixer!==((I=(g=this._animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const h=Math.max(0,1-E);(C=(s=this._animator)==null?void 0:s.runtimeAnimatorController)==null||C.update(h)}else this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new MA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=r=>{var B;const Q=a(r);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(B=E?.onTimelineRotation)==null||B.call(E,this.director,this.target,r,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new y;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let r;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,d,l;const c=Q(E);if(s.set(c[0],c[1],c[2]),e.removeStartOffset&&(r===void 0?(r=null,r=(d=(h=this._actionOffsets.find(u=>u.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:d.clone()):r!=null&&r.isVector3&&s.sub(r)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(l=u?.onTimelinePosition)==null||l.call(u,this.director,this.target,E,s);return c[0]=s.x,c[1]=s.y,c[2]=s.z,c},B}}}const DgA=CA("mutetimeline"),Rl=class extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"listener"),n(this,"audio",[]),n(this,"audioContextTimeOffset",[]),n(this,"lastTime",0),n(this,"audioSource"),n(this,"_audioLoader",null)}getAudioFilePath(t){const A=this.director.sourceId;return FC(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new Vm(this.listener);this.audio.push(A),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}evaluate(t){if(DgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=A?.1:0;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=this.audio[i],o=g.asset;if((!I||!I.buffer)&&this.isInTimeRange(g,t-1,t+1)&&this.handleAudioLoading(g,I),yi.userInteractionRegistered!==!1&&!(I===null||!I.buffer))if(I.playbackRate=this.director.context.time.timeScale*this.director.speed,I.loop=o.loop,t>=g.start&&t<=g.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(I.isPlaying&&I.stop(),this.lastTime===t)continue}else if(!I.isPlaying)I.offset=g.clipIn+(t-g.start)*g.timeScale,I.play(e);else{const C=g.clipIn+(t-g.start)*g.timeScale,a=I.context.currentTime-I._startedAt+I.offset;Math.abs(C-a)>.3&&(I.offset=C,I.stop(),I.play(e))}let s=o.volume;if(this.track.volume!==void 0&&(s*=this.track.volume),A&&(s=0),g.easeInDuration>0){const C=Math.min((t-g.start)/g.easeInDuration,1);s*=C}if(g.easeOutDuration>0){const C=Math.min((g.end-t)/g.easeOutDuration,1);s*=C}I.setVolume(s*this.director.weight)}else I.isPlaying&&I.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Rl._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new Gu);const e=this.getAudioFilePath(t.asset.clip);if(Rl._audioBuffers.get(e)){const g=Rl._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}Qa&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Rl._audioBuffers.set(e,i),i}};let Ul=Rl;n(Ul,"_audioBuffers",new Map);class Nl extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"didTrigger",[]),n(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);(a===0||a>=1e-5&&a<i)&&(C=!0)}if(C){if(!o)if(Qa&&console.log("Trigger signal",A,I.time,I),this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)dE.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class ay extends Ml{constructor(){super(...arguments),n(this,"models",[]),n(this,"timelines",[]),n(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=iA.getComponent(i.sourceObject,AB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}const pE=CA("debugtimeline"),LR=class extends JA{constructor(){super(...arguments),n(this,"playableAsset"),n(this,"playOnAwake"),n(this,"extrapolationMode",1),n(this,"waitForAudio",!0),n(this,"_visibilityChangeEvt"),n(this,"_clonedPlayableAsset",!1),n(this,"_speed",1),n(this,"_guidsMap"),n(this,"_isPlaying",!1),n(this,"_internalUpdateRoutine"),n(this,"_isPaused",!1),n(this,"_isStopping",!1),n(this,"_time",0),n(this,"_duration",0),n(this,"_weight",1),n(this,"_animationTracks",[]),n(this,"_audioTracks",[]),n(this,"_signalTracks",[]),n(this,"_controlTracks",[]),n(this,"_customTracks",[]),n(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),n(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(pE||gI())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;pE&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A,e;for(const i of this._audioTracks)(t=i.onEnable)==null||t.call(i);for(const i of this._customTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onEnable)==null||e.call(i);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A,e;this.stop();for(const i of this._audioTracks)(t=i.onDisable)==null||t.call(i);for(const i of this._customTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onDisable)==null||e.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yi.userInteractionRegistered&&this.waitForAudio;)await Za(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),og.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),A&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}invokeStateChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onStateChanged)==null||t.call(A,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let A=this._time;switch(this.extrapolationMode){case 0:this._speed>0?A=Math.min(A,this._duration):this._speed<0&&(A=Math.max(A,0)),this._time=A;break;case 1:A%=this._duration,this._time=A;break;case 2:if(A>this._duration){this.stop();return}break}const e=this._time;for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case oo.Activation:if(!t&&!this._isPlaying)continue;for(let g=0;g<i.outputs.length;g++){const I=i.outputs[g];if(typeof I=="object"){let o=!1;if(i.clips)for(const C of i.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&s.visible!==o&&(s.visible=o,pE&&console.warn(this.name,"set ActivationTrack-"+g,s.name,o,e))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(e);for(const i of this._audioTracks)i.evaluate(e);for(const i of this._signalTracks)i.evaluate(e);for(const i of this._controlTracks)i.evaluate(e);for(const i of this._customTracks)i.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=bu(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=iA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(pE&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),LR.createTrackFunctions[A.type])continue;A.type!==oo.Audio&&A.type!==oo.Control&&A.type!==oo.Marker&&A.type!==oo.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===oo.Control&&A.clips)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=iA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(pE&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);if(t.markers)for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let i=iA.findObjectOfType(Gn,this.context);for(const g of this.playableAsset.tracks){const I=g.type,o=LR.createTrackFunctions[I];if(o!=null){const s=o(this,g);if(typeof s.evaluate=="function"){s.director=this,s.track=g,this._customTracks.push(s);continue}}if(g.type===oo.Animation){if(!g.clips||g.clips.length<=0){pE&&console.warn("Animation track has no clips",g);continue}for(let s=g.outputs.length-1;s>=0;s--){let C=g.outputs[s];if(C instanceof fA){const r=iA.getOrAddComponent(C,kg);r&&(C=r)}const a=(t=C?.gameObject)==null?void 0:t.animations;if(a){const r=new Cy;r.trackOffset=g.trackOffset,r.director=this,r.track=g;for(let B=0;B<g.clips.length;B++){const Q=g.clips[B],E=Q.asset;if(!E){console.error("MISSING anim model?","clip#"+B,Q,g,this.playableAsset,this.name);continue}const h=E.clip;let d=h;if((typeof d=="string"||typeof d=="number")&&(d=a.find(c=>c.name===h)),!d){console.warn("Could not find animationClip for model",Q,g.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}C instanceof kg&&C.runtimeAnimatorController&&(C.__internalDidAwakeAndStart||C.initializeRuntimeAnimatorController(),C.runtimeAnimatorController.mixer||C.runtimeAnimatorController.bind(C),r.mixer=C.runtimeAnimatorController.mixer),r.mixer||(r.mixer=new Mu(C.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(Q.asset,d);const l=r.mixer.clipAction(d);r.actions.push(l),r.models.push(Q)}this._animationTracks.push(r)}}}else if(g.type===oo.Audio){if(!g.clips||g.clips.length<=0)continue;const s=new Ul;s.director=this,s.track=g,s.audioSource=g.outputs.find(C=>C instanceof yi),this._audioTracks.push(s),i||(i=(e=this.context.mainCameraComponent)==null?void 0:e.gameObject.addNewComponent(Gn)),s.listener=i.listener;for(let C=0;C<g.clips.length;C++){const a=g.clips[C];s.addModel(a)}}else if(g.type===oo.Marker){const s=new Nl;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)switch(C.type){case bR.Signal:s.models.push(C),s.didTrigger.push(!1);break}if(s!==null&&s.models.length>0){const C=iA.getComponent(this.gameObject,dE);C&&(s.receivers.push(C),this._signalTracks.push(s))}}else if(g.type===oo.Signal){const s=new Nl;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)s.models.push(C),s.didTrigger.push(!1);for(const C of g.outputs)s.receivers.push(C);this._signalTracks.push(s)}else if(g.type===oo.Control){const s=new ay;if(s.director=this,s.track=g,g.clips)for(const C of g.clips)s.models.push(C);s.resolveSourceObjects(this.context),this._controlTracks.push(s)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const A=this.animationCallbackReceivers.indexOf(t);A!==-1&&this.animationCallbackReceivers.splice(A,1)}};let AB=LR;n(AB,"createTrackFunctions",{});const ny=Symbol("objectIsAnimatedData");function v2(t,A,e){if(!t)return;if(t[ny]===void 0){if(!e)return;t[ny]=new Set}const i=t[ny];e?i.add(A):i.has(A)&&i.delete(A)}function wgA(t){if(!t)return!1;const A=t[ny];return A!==void 0&&A.size>0}Gt.registerCallback(zi.ContextCreated,t=>{const A=t.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&t.files)for(const e of t.files)iA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof Ao&&i.playAutomatically||i instanceof kg||i instanceof AB&&i.playOnAwake===!0)return!0;if(i instanceof Ao)return i.playAutomatically=!0,!0;if(i instanceof AB)return i.playOnAwake=!0,!0}},!0)!==!0&&ygA(e.file)});function ygA(t){if(!t||!t.animations)return;for(let e=0;e<t.animations.length;e++){const i=t.animations[e];if(!(!i.tracks||i.tracks.length<=0))for(const g in i.tracks){const I=i.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=t.scene.getObjectByName(o);if(!s&&(s=t.scene.getObjectByProperty("uuid",o),!s))continue;let C=A(s);C||(C=tn(t.scene,new Ao));const a=C.animations=C.animations||[];i.name_animator=C.name,a.indexOf(i)<0&&a.push(i)}}function A(e){var i;if(!e)return;const g=(i=e.userData)==null?void 0:i.components;if(g&&g.length>0)for(let I=0;I<g.length;I++){const o=g[I];if(o instanceof kg||o instanceof Ao)return e}return A(e.parent)}}var SgA=Object.defineProperty,fgA=Object.getOwnPropertyDescriptor,ry=(t,A,e,i)=>{for(var g=i>1?void 0:i?fgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SgA(A,e,g),g};const q2=CA("debuganimator");class kg extends JA{constructor(){super(...arguments),n(this,"applyRootMotion",!1),n(this,"hasRootMotion",!1),n(this,"keepAnimatorControllerStateOnDisable",!1),n(this,"_parametersAreDirty",!1),n(this,"_isDirty",!1),n(this,"speed",1),n(this,"normalizedStartOffset",0),n(this,"_animatorController",null),n(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(A){var e;this._animatorController&&this._animatorController.model===A||(A?A instanceof Vo?(A.animator&&A.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(e=A.model)==null?void 0:e.name),A.model||console.error("AnimatorController has no model"),A=new Vo(A.model)),this._animatorController=A,this._animatorController.bind(this)):(q2&&console.log("Assign animator controller",A,this),this._animatorController=new Vo(A),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){this.play(A,e,i,g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){var I;(I=this.runtimeAnimatorController)==null||I.play(A,e,i,g),this._isDirty=!0}Reset(){this.reset()}reset(){var A;(A=this._animatorController)==null||A.reset(),this._isDirty=!0}SetBool(A,e){this.setBool(A,e)}setBool(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getBool(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setBool(A,e)}GetBool(A){return this.getBool(A)}getBool(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getBool(A))??!1}SetFloat(A,e){this.setFloat(A,e)}setFloat(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setFloat(A,e)}GetFloat(A){return this.getFloat(A)}getFloat(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getFloat(A))??-1}SetInteger(A,e){this.setInteger(A,e)}setInteger(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setInteger(A,e)}GetInteger(A){return this.getInteger(A)}getInteger(A){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.getInteger(A))??-1}SetTrigger(A){this.setTrigger(A)}setTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.setTrigger(A),this._parametersAreDirty=!0}ResetTrigger(A){this.resetTrigger(A)}resetTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.resetTrigger(A),this._parametersAreDirty=!0}GetTrigger(A){this.getTrigger(A)}getTrigger(A){var e;(e=this.runtimeAnimatorController)==null||e.getTrigger(A)}IsInTransition(){return this.isInTransition()}isInTransition(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.isInTransition())??!1}SetSpeed(A){return this.setSpeed(A)}setSpeed(A){var e;A!==this.speed&&(this.speed=A,(e=this._animatorController)==null||e.setSpeed(A))}set minMaxSpeed(A){this.speed=$A.lerp(A.x,A.y,Math.random())}set minMaxOffsetNormalized(A){this.normalizedStartOffset=$A.lerp(A.x,A.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){q2&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(A=!1){const e=A||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&e){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var A;this.keepAnimatorControllerStateOnDisable||(A=this._animatorController)==null||A.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!wgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}ry([w()],kg.prototype,"applyRootMotion",2),ry([w()],kg.prototype,"hasRootMotion",2),ry([w()],kg.prototype,"keepAnimatorControllerStateOnDisable",2),ry([w()],kg.prototype,"runtimeAnimatorController",1);const uE=CA("debugusdzanimation"),xR=CA("debugusdzanimationserialization");class By{constructor(A,e,i){n(this,"_start"),n(this,"ext"),n(this,"root"),n(this,"clip"),this.ext=A,this.root=e,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Lo{constructor(A,e,i){n(this,"clip"),n(this,"pos"),n(this,"rot"),n(this,"scale"),n(this,"root"),n(this,"target"),n(this,"duration",0),n(this,"useRootMotion",!1),this.root=A,this.target=e,this.clip=i,i?this.duration=i.duration:this.duration=1/this.frameRate;const g=iA.getComponent(A,kg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,i,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(i=this.rot)==null?void 0:i.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,i=!0){var g,I,o;if(!this.clip)return[0,this.duration];const s=(g=this.pos)==null?void 0:g.times,C=(I=this.rot)==null?void 0:I.times,a=(o=this.scale)==null?void 0:o.times,r=[];if(A&&s)for(const B of s)r.push(B);if(e&&C)for(const B of C)r.push(B);if(i&&a)for(const B of a)r.push(B);return r.includes(0)||r.push(0),r.sort((B,Q)=>B-Q),[...new Set(r)]}*getValues(A,e=!0,i=!0,g=!0){var I,o,s;const C=new y,a=new MA,r=new y(1,1,1),B=this.target,Q=e?(I=this.pos)==null?void 0:I.createInterpolant():void 0,E=i?(o=this.rot)==null?void 0:o.createInterpolant():void 0,h=g?(s=this.scale)==null?void 0:s.createInterpolant():void 0;Q||C.set(B.position.x,B.position.y,B.position.z),E||a.set(B.quaternion.x,B.quaternion.y,B.quaternion.z,B.quaternion.w),h||r.set(B.scale.x,B.scale.y,B.scale.z);for(let d=0;d<A.length;d++){const l=A[d];if(Q){const c=Q.evaluate(l);C.set(c[0],c[1],c[2])}if(E){const c=E.evaluate(l);a.set(c[0],c[1],c[2],c[3])}if(h){const c=h.evaluate(l);r.set(c[0],c[1],c[2])}if(this.useRootMotion&&B===this.root){const c=new NA;c.compose(C,a,r),c.multiply(B.matrix),c.decompose(C,a,r)}yield{time:l,translation:C,rotation:a,scale:r,index:d}}}}n(Lo,"animationDurationPadding",1);class Fl{constructor(A){n(this,"dict",new Map),n(this,"rootTargetMap",new Map),n(this,"rootAndClipToRegisteredAnimationMap",new Map),n(this,"rootToRegisteredClipCount",new Map),n(this,"serializers",[]),n(this,"injectRestPoses",!1),n(this,"injectImplicitBehaviours",!1),this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const i=this.rootTargetMap.get(A);if(!i)return 0;const g=this.dict.get(i[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+Lo.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const i=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(i))return this.rootAndClipToRegisteredAnimationMap.get(i);uE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const a of e.tracks){const r=He.parseTrackName(a.name),B=He.findNode(A,r.nodeName);if(!B){console.warn("no object found for track",a.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const h=new Lo(null,B,void 0);Q[0]=h}let E=Q[I];E||(E=new Lo(A,B,e),Q[I]=E),E.addTrack(a),o!=null&&o.includes(B)||o==null||o.push(B)}for(const a of s){const r=this.dict.get(a);if(!r)continue;if(this.injectRestPoses&&!r[0]){const Q=new Lo(null,a,void 0);r[0]=Q}let B=r[I];B||(uE&&console.log("Adding padding clip for ",a,e),B=new Lo(A,a,e),r[I]=B)}const C=new By(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(i,C),this.rootToRegisteredClipCount.set(A,I+1),C}onAfterHierarchy(A){uE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,i;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=I?.isDynamic===!0;xR&&console.log(o,(i=g.model)==null?void 0:i.parent),o&&g.registerCallback(I)}}onExportObject(A,e,i){iA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,i)},!1);const g=new mgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class mgA{constructor(A,e){n(this,"object"),n(this,"dict"),n(this,"model"),n(this,"callback"),this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),xR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const i=this.model,g=this.dict;if(i&&i.skinnedMesh){let I=function(k){const R=[];for(const[m,f]of k){let b=`${m} : [`;const H=[];for(const L of f)H.push(`(${Cg(L.x)}, ${Cg(L.y)}, ${Cg(L.z)})`);b=b.concat(H.join(", ")),b=b.concat("],"),R.push(b)}return R},o=function(k){const R=[];for(const[m,f]of k){let b=`${m} : [`;const H=[];for(const L of f)H.push(`(${Cg(L.w)}, ${Cg(L.x)}, ${Cg(L.y)}, ${Cg(L.z)})`);b=b.concat(H.join(", ")),b=b.concat("],"),R.push(b)}return R},s=function(k){let R=!0,m;for(const[b,H]of k)if(m===void 0&&(m=H.length),m!==H.length){R=!1;break}uE&&console.log("Bone count: ",k.size,"TransformData entries per bone: ",m),console.assert(R,"All bones should have the same number of TransformData entries",k);const f=[];for(const[b,H]of k){const L=new Array;let O=0;for(let Z=0;Z<H.length;Z++)L.push(O),O+=H[Z].getDuration()+Lo.animationDurationPadding;for(let Z=0;Z<H.length;Z++){const T=H[Z],v=L[Z];f.length<=Z&&f.push({pos:[],rot:[],scale:[],timeOffset:v});const Y=f[Z];Y.pos.push(...T.getSortedTimesArray(!0,!1,!1)),Y.rot.push(...T.getSortedTimesArray(!1,!0,!1)),Y.scale.push(...T.getSortedTimesArray(!1,!1,!0))}}for(const b of f)b.pos.sort((H,L)=>H-L),b.rot.sort((H,L)=>H-L),b.scale.sort((H,L)=>H-L),b.pos=[...new Set(b.pos)],b.rot=[...new Set(b.rot)],b.scale=[...new Set(b.scale)];return f},C=function(k,R,m){const f=new Map,b=new Map,H=new Map,L=R.length;for(const O of m){const Z=k.get(O);let T;Z?console.assert(Z.length===L,"We should have the same number of TransformData entries for each bone",Z,R):T=new Lo(null,O,void 0);for(let v=0;v<L;v++){const Y=Z?Z[v]:T,IA=R[v];for(const{time:AA,translation:W}of Y.getValues(IA.pos,!0,!1,!1)){const gA=(AA+IA.timeOffset)*60;f.has(gA)||f.set(gA,new Array),f.get(gA).push(W.clone())}for(const{time:AA,rotation:W}of Y.getValues(IA.rot,!1,!0,!1)){const gA=(AA+IA.timeOffset)*60;b.has(gA)||b.set(gA,new Array),b.get(gA).push(W.clone())}for(const{time:AA,scale:W}of Y.getValues(IA.scale,!1,!1,!0)){const gA=(AA+IA.timeOffset)*60;H.has(gA)||H.set(gA,new Array),H.get(gA).push(W.clone())}}}return{position:f.size==0?void 0:f,quaternion:b.size==0?void 0:b,scale:H.size==0?void 0:H}},a=function(k){const R=[];for(const m of k)R.push(`(${Cg(m.x)}, ${Cg(m.y)}, ${Cg(m.z)})`);return R.join(", ")},r=function(k){const R=[];for(const m of k)R.push(`(${Cg(m.w)}, ${Cg(m.x)}, ${Cg(m.y)}, ${Cg(m.z)})`);return R.join(", ")},B=function(k){const R=new Map;if(uE){const m=new Array;for(const[f,b]of g)m.push(f.uuid+": "+b.length+" "+b.map(H=>{var L;return(L=H.clip)==null?void 0:L.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5190
5190
|
`+m.join(`
|
|
5191
5191
|
`))}for(const m of k){const f=g.get(m);f&&R.set(m,f)}return R},Q=function(k){const R=B(k),m=s(R);return C(R,m,k)};const E=i.skinnedMesh.skeleton,h=new Array;for(const k in E.bones){const R=E.bones[k],m=E.boneInverses[k];h.push({bone:R,inverse:m})}for(const k of A2(E.bones))h.push({bone:k,inverse:k.matrixWorld.clone().invert()});const d=h[0].bone.parent;d||console.error("No bone parent found for skinned mesh during USDZ export",i.skinnedMesh),h.sort((k,R)=>gE(k.bone,d)>gE(R.bone,d)?1:-1);const l=[],c=[],u=[],p=[];for(const{bone:k}of h)l.push(k.matrix.clone()),c.push(k.position),u.push(k.quaternion),p.push(k.scale);const D=h.map(k=>'"'+gE(k.bone,d)+'"').join(", "),S=h.map(k=>IE(k.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${S}]`),A.appendLine(`uniform token[] joints = [${D}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${l.map(k=>IE(k)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${IE(new NA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const G=Q(h.map(k=>k.bone));if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${D}]`),A.appendLine(`quatf[] rotations = [${r(u)}]`),G&&G.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const k=o(G.quaternion);for(const R of k)A.appendLine(R);A.closeBlock()}if(A.appendLine(`half3[] scales = [${a(p)}]`),G&&G.scale){A.beginBlock("half3[] scales.timeSamples = {","");const k=I(G.scale);for(const R of k)A.appendLine(R);A.closeBlock()}if(A.appendLine(`float3[] translations = [${a(c)}]`),G&&G.position){A.beginBlock("float3[] translations.timeSamples = {","");const k=I(G.position);for(const R of k)A.appendLine(R);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var i;if(!this.model)return;this.skinnedMeshExport(A,e);const g=this.object,I=this.dict.get(g);if(!I||g.isSkinnedMesh)return;xR&&console.log("SERIALIZE",this.model.name,this.object.type,I);const o=new NA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const s=new Array;let C=0;for(let a=0;a<I.length;a++)s.push(C),C+=I[a].getDuration()+Lo.animationDurationPadding;for(let a=0;a<I.length;a++){const r=I[a];if(!r)continue;const B=s[a];{const Q=r.getSortedTimesArray();if(!Q||Q.length===0){console.error("got an animated object but no time values?",g,r);continue}if(uE){const E=((i=r.clip)==null?void 0:i.name)??"rest",h=r.getDuration();console.log("Write .timeSamples:",E,B,h,I),A.appendLine("# "+E+": start="+(B*r.frameRate).toFixed(3)+", length="+(h*r.frameRate).toFixed(3)+", frames="+r.getFrames())}for(const{time:E,translation:h,rotation:d,scale:l}of r.getValues(Q)){o.compose(h,d,l);const c=`${(B+E)*r.frameRate}: ${IE(o)},`;A.appendLine(c)}}}A.indent--,A.appendLine("}")}}var kgA=Object.defineProperty,GgA=Object.getOwnPropertyDescriptor,b2=(t,A,e,i)=>{for(var g=i>1?void 0:i?GgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kgA(A,e,g),g};class Me{constructor(A){n(this,"_active",!0),n(this,"_value"),n(this,"_valueRaw"),n(this,"_defaultValue"),n(this,"valueProcessor"),n(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged&&this.onValueChanged(A,i,this)}testIfValueChanged(A){return this._valueRaw!==A}}b2([w()],Me.prototype,"overrideState",1),b2([w()],Me.prototype,"value",1);var MgA=Object.defineProperty,RgA=Object.getOwnPropertyDescriptor,UgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?RgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MgA(A,e,g),g};const NgA=CA("debugpost");class jg extends Bn{constructor(A=void 0){if(super(),n(this,"active",!0),n(this,"_result"),n(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof Me&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){NgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof Me&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===Me){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof Me){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===Me&&(this[e]||(this[e]=new Me))}}UgA([w()],jg.prototype,"active",2);var FgA=Object.defineProperty,KgA=Object.getOwnPropertyDescriptor,JgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?KgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&FgA(A,e,g),g};const vgA=CA("debugpost"),TR={};function xo(t,A){TR[t]=A}function qgA(t){return t.__type in TR?TR[t.__type]:(vgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),jg)}class Kl{constructor(){n(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}JgA([_Q([t=>qgA(t),jg])],Kl.prototype,"components",2);var bgA=Object.defineProperty,LgA=Object.getOwnPropertyDescriptor,xgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?LgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&bgA(A,e,g),g};class Jl extends jg{constructor(){super(...arguments),n(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new zX({preset:NQ.HIGH,edgeDetectionMode:pG.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}xgA([w(Me)],Jl.prototype,"preset",2),xo("Antialiasing",Jl);class Qy{constructor(){n(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=iA.getComponents(A,yi);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,C)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i=e.split("/").pop(),g=await(await(await fetch(e)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files["audio/"+i]=I}}}const DE=CA("debugnetworkingstreams");var eC=(t=>(t.Connected="peer-user-connected",t.StreamReceived="receive-stream",t.StreamEnded="call-ended",t.Disconnected="peer-user-disconnected",t.UserJoined="user-joined",t))(eC||{});class L2{constructor(A,e){n(this,"type","call-ended"),n(this,"userId"),n(this,"direction"),this.userId=A,this.direction=e}}class x2{constructor(A,e){n(this,"type","receive-stream"),n(this,"stream"),n(this,"target"),this.stream=A,this.target=e}}class TgA{constructor(A,e){n(this,"guid"),n(this,"peerId"),n(this,"dontSave",!0),this.guid=A.id,this.peerId=e}}var T2=(t=>(t.Incoming="incoming",t.Outgoing="outgoing",t))(T2||{});class YgA extends Pi{constructor(A,e,i){super(),n(this,"userId"),n(this,"direction"),n(this,"call"),n(this,"_stream",null),n(this,"_isDisposed",!1),this.userId=A,this.call=e,this.direction=i,this._stream=null,e.on("stream",g=>{if(DE&&console.log("Receive video",g.getAudioTracks(),g.getVideoTracks()),this._stream=g,i==="incoming"){const I=new x2(g,this);this.dispatchEvent(I)}}),e.on("close",()=>{this.dispatchEvent(new L2(A,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),Ea(this._stream))}get isOpen(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connected"}get isOpening(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const vl=class extends Pi{constructor(t,A){super(),n(this,"id"),n(this,"context"),n(this,"_peer"),n(this,"_incomingCalls",[]),n(this,"_outgoingCalls",[]),n(this,"_enabled",!1),n(this,"_enabledPeer",!1),n(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),n(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),n(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=t,this.id=A,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,A){if(vl.instances.has(A))return vl.instances.get(A);const e=new vl(t,A);return vl.instances.set(A,e),e}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,A){var e;const i={metadata:{userId:this.context.connection.connectionId}},g=(e=this._peer)==null?void 0:e.call(t,A,i);if(g)return this.registerCall(g,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Lt.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Lt.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=eL(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){DE&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new TgA(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,A){const e=t.metadata;(!e||!e.userId)&&console.error("Missing call metadata",t);const i=e.userId;A==="incoming"&&DE?console.log("Receive call from",t.metadata):DE&&console.log("Make call to",t.metadata);const g=A==="incoming"?this._incomingCalls:this._outgoingCalls,I=new YgA(i,t,A);return g.push(I),t.on("error",o=>{console.error("Call error",o)}),t.on("close",()=>{DE&&console.log("Call ended",t.metadata),t.close();const o=g.indexOf(I);o!==-1&&g.splice(o,1)}),I.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),A==="incoming"&&(I.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),t.on("stream",()=>{let o=0;const s=setInterval(()=>{const C=o===0;!I.isOpen&&C&&(o+=1,clearInterval(s),I.close())},2e3)})),I}};let Ey=vl;n(Ey,"instances",new Map);class $d extends Pi{constructor(A,e){super(),n(this,"context"),n(this,"peer"),n(this,"_sendingStreams",new Map),n(this,"debug",!1),n(this,"onJoinedRoom",i=>{this.debug&&console.log(`${i.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),n(this,"onReceiveStream",i=>{this.debug&&console.log("RECEIVE STREAM",i),this.dispatchEvent({type:"receive-stream",target:this,stream:i.stream,userId:i.userId})}),n(this,"onCallEnded",i=>{this.dispatchEvent(i)}),n(this,"onUserConnected",i=>{if(this.peer.id===i.guid){this.debug&&console.log("USER CONNECTED",i.guid,i);const g=this._sendingStreams.keys().next().value;this.peer.makeCall(i.peerId,g)}}),n(this,"onUserLeft",i=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=A,this.peer=e,DE&&(this.debug=!0)}static create(A){const e=Ey.getOrCreate(A.context,A.context.connection.connectionId);return new $d(A.context,e)}startSendingStream(A){this._sendingStreams.has(A)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(A,[]),this.updateSendingCalls())}stopSendingStream(A){if(A){const e=this._sendingStreams.get(A);if(e){this.debug&&console.log("Closing calls",e);for(const i of e)i.close()}this._sendingStreams.delete(A),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(Lt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Lt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Lt.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(Lt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Lt.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Lt.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var A;let e=!1;const i=this.context.connection.connectionId;for(const g of this._sendingStreams.keys()){const I=this._sendingStreams.get(g)||[];for(const o of this.context.connection.usersInRoom()){if(o===i)continue;const s=I.find(C=>C.userId===o);if(!s||((A=s.stream)==null?void 0:A.active)===!1){this.debug&&console.log("Starting call to",o,i);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),g);C&&(e=!0,I.push(C))}}this._sendingStreams.set(g,I)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const A of this._sendingStreams.keys()){const e=this._sendingStreams.get(A);if(e)for(let i=e.length-1;i>=0;i--){const g=e[i];this.context.connection.userIsInRoom(g.userId)||(g.close(),e.splice(i,1))}}}}function Ea(t){if(t&&t instanceof MediaStream)for(const A of t.getTracks())A.stop()}var HgA=Object.defineProperty,OgA=Object.getOwnPropertyDescriptor,Y2=(t,A,e,i)=>{for(var g=i>1?void 0:i?OgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&HgA(A,e,g),g};const H2="noVoip",_gA=CA("debugvoip");class Mn extends JA{constructor(){super(...arguments),n(this,"autoConnect",!1),n(this,"runInBackground",!0),n(this,"debug",!1),n(this,"_net"),n(this,"_outputStream",null),n(this,"onJoinedRoom",async()=>{await Za(300),this.autoConnect&&!this.isSending&&this.connect()}),n(this,"_incomingStreams",new Map),n(this,"onReceiveStream",A=>{const e=A.target.userId,i=A.stream,g=this._incomingStreams.get(e);if(g)g.srcObject=i,g.setAttribute("autoplay","true");else{const I=new Audio;this._incomingStreams.set(e,I),I.setAttribute("autoplay","true"),I.srcObject=i}}),n(this,"onStreamEnded",A=>{const e=this._incomingStreams.get(A.userId);Ea(e?.srcObject),this._incomingStreams.delete(A.userId)}),n(this,"onEnabledChanged",()=>{for(const A of this._incomingStreams){const e=A[1];e.muted=!this.enabled}}),n(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const A=document.visibilityState!=="visible";this.setMuted(A);for(const e of this._incomingStreams){const i=e[1];i.muted=A}})}awake(){_gA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async A=>{A.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=$d.create(this)),this._net.addEventListener(eC.StreamReceived,this.onReceiveStream),this._net.addEventListener(eC.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Lt.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var A;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(eC.StreamReceived,this.onReceiveStream),this._net.removeEventListener(eC.StreamEnded,this.onStreamEnded),(A=this._net)==null||A.disable(),this.context.connection.stopListen(Lt.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(A){if(this.context.connection.isConnected){if(!await ak())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),Ea(this._outputStream),this._outputStream=await this.getAudioStream(A),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await ak()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):Dq("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),Ea(this._outputStream),this._outputStream=null}setMuted(A){var e;const i=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(i)for(const g of i)g.enabled=!A}get isMuted(){var A;if(this._outputStream===null)return!1;const e=(A=this._outputStream)==null?void 0:A.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(A){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,Oe()&&gg("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(A){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:A??!0,video:!1}).catch(e=>(console.warn("VOIP failed getting audio stream",e),null)):(console.error("No getDisplayMedia support"),null)}}Y2([w()],Mn.prototype,"autoConnect",2),Y2([w()],Mn.prototype,"runInBackground",2);var PgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,O2=(t,A,e,i)=>{for(var g=i>1?void 0:i?jgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PgA(A,e,g),g};const WgA=CA("debugmouth");class ql extends JA{constructor(){super(...arguments),n(this,"idle",[]),n(this,"talking",[]),n(this,"marker",null),n(this,"voip",null),n(this,"lastMouthChangeTime",0),n(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=iA.findObjectOfType(Mn,this.context),this.marker||(this.marker=iA.getComponentInParent(this.gameObject,Pg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){WgA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}O2([w(fA)],ql.prototype,"idle",2),O2([w(fA)],ql.prototype,"talking",2);class YR extends JA{constructor(){super(...arguments),n(this,"voip",null),n(this,"marker",null),n(this,"_startPosition",null)}awake(){this.voip=iA.findObjectOfType(Mn,this.context),this.marker=iA.getComponentInParent(this.gameObject,Pg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var VgA=Object.defineProperty,zgA=Object.getOwnPropertyDescriptor,hy=(t,A,e,i)=>{for(var g=i>1?void 0:i?zgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&VgA(A,e,g),g};class eB extends JA{constructor(){super(...arguments),n(this,"eyes",[]),n(this,"lastBlinkTime",0),n(this,"blinkLength",0),n(this,"eyesOpen",!0),n(this,"state",null)}awake(){this.state=iA.getComponentInParent(this.gameObject,to)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const A of this.eyes)A&&(A.visible=this.eyesOpen)}}}hy([w(fA)],eB.prototype,"eyes",2),hy([w()],eB.prototype,"lastBlinkTime",2),hy([w()],eB.prototype,"blinkLength",2),hy([w()],eB.prototype,"eyesOpen",2);var ZgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,HR=(t,A,e,i)=>{for(var g=i>1?void 0:i?XgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ZgA(A,e,g),g},OR;const _2=(OR=class extends JA{constructor(){super(...arguments),n(this,"head",null),n(this,"eyes",null),n(this,"target",null),n(this,"brain",null),n(this,"vec",new y),n(this,"currentTargetPoint",new y)}awake(){this.brain||(this.brain=iA.getComponentInParent(this.gameObject,Dl)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=iA.addNewComponent(this.gameObject,Dl)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=he(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=he(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=_2.forward;if(I.set(0,0,1),I.applyQuaternion(Mt(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},n(OR,"forward",new y(0,0,1)),OR);let wE=_2;HR([w(fA)],wE.prototype,"head",2),HR([w(fA)],wE.prototype,"eyes",2),HR([w(fA)],wE.prototype,"target",2);var $gA=Object.defineProperty,AIA=Object.getOwnPropertyDescriptor,_R=(t,A,e,i)=>{for(var g=i>1?void 0:i?AIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&$gA(A,e,g),g};class yE extends JA{constructor(){super(...arguments),n(this,"length",1),n(this,"depthTest",!0),n(this,"isGizmo",!0),n(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Jc)return;this._axes||(this._axes=new uQ(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}_R([w()],yE.prototype,"length",2),_R([w()],yE.prototype,"depthTest",2),_R([w()],yE.prototype,"isGizmo",2);class PR extends JA{constructor(){super(...arguments),n(this,"from"),n(this,"to"),n(this,"hint"),n(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const A=he(this.to).clone(),e=he(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);const I=e.clone();I.add(A),I.multiplyScalar(.5);const o=he(this.hint).clone();o.sub(I);const s=new y;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),r=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(r),B.add(I),pi(this.gameObject,B);const Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}const eIA=CA("debugusdz");class cy{constructor(){n(this,"behaviours",[]),n(this,"behaviourComponents",[]),n(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{iA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){eIA&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var tIA=Object.defineProperty,iIA=Object.getOwnPropertyDescriptor,jR=(t,A,e,i)=>{for(var g=i>1?void 0:i?iIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&tIA(A,e,g),g};class tB extends jg{constructor(){super(...arguments),n(this,"threshold"),n(this,"intensity"),n(this,"scatter"),n(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>1*Math.PI*(1-A)):(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>100*(1-A))}onCreateEffect(){let A;if(this.selectiveBloom){const e=A=new Gx(this.context.scene,this.context.mainCamera,{blendFunction:Ye.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else A=new fG;return this.intensity.onValueChanged=e=>{A.intensity=e},this.threshold.onValueChanged=e=>{A.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{A.luminancePass.enabled=!0,A.luminanceMaterial.smoothing=e},A}}jR([w(Me)],tB.prototype,"threshold",2),jR([w(Me)],tB.prototype,"intensity",2),jR([w(Me)],tB.prototype,"scatter",2),xo("Bloom",tB);var gIA=Object.defineProperty,IIA=Object.getOwnPropertyDescriptor,To=(t,A,e,i)=>{for(var g=i>1?void 0:i?IIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&gIA(A,e,g),g};class tC extends JA{constructor(){super(...arguments),n(this,"attachedRigidbody",null),n(this,"isTrigger",!1),n(this,"sharedMaterial"),n(this,"updateProperties",()=>{var A;(A=this.context.physics.engine)==null||A.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Kt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Kt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Kt))}onDisable(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}get body(){var A;return(A=this.context.physics.engine)==null?void 0:A.getBody(this)}updatePhysicsMaterial(){var A;(A=this.context.physics.engine)==null||A.updatePhysicsMaterial(this)}}To([w(Kt)],tC.prototype,"attachedRigidbody",2),To([w()],tC.prototype,"isTrigger",2),To([w()],tC.prototype,"sharedMaterial",2);class bl extends tC{constructor(){super(...arguments),n(this,"radius",.5),n(this,"center",new y(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addSphereCollider(this),sk(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),Iq(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}To([Sg(),w()],bl.prototype,"radius",2),To([w(y)],bl.prototype,"center",2);class Ll extends tC{constructor(){super(...arguments),n(this,"size",new y(1,1,1)),n(this,"center",new y(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addBoxCollider(this,this.size)}onValidate(){this.updateProperties()}}To([Sg(),w(y)],Ll.prototype,"size",2),To([w(y)],Ll.prototype,"center",2);class SE extends tC{constructor(){super(...arguments),n(this,"sharedMesh"),n(this,"convex",!1)}onEnable(){var A,e,i,g,I;if(super.onEnable(),(A=this.sharedMesh)!=null&&A.isMesh||this.gameObject instanceof uA&&(this.sharedMesh=this.gameObject),(e=this.sharedMesh)!=null&&e.isMesh)(i=this.context.physics.engine)==null||i.addMeshCollider(this,this.sharedMesh,this.convex,Ig(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((g=this.sharedMesh)==null?void 0:g.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const s in o.children){const C=o.children[s];C.isMesh&&((I=this.context.physics.engine)==null||I.addMeshCollider(this,C,this.convex,Ig(this.gameObject)))}}}}}To([w()],SE.prototype,"sharedMesh",2),To([w()],SE.prototype,"convex",2);class Rn extends tC{constructor(){super(...arguments),n(this,"center",new y(0,0,0)),n(this,"radius",.5),n(this,"height",2)}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addCapsuleCollider(this,this.height,this.radius)}}To([w(y)],Rn.prototype,"center",2),To([w()],Rn.prototype,"radius",2),To([w()],Rn.prototype,"height",2);var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,WR=(t,A,e,i)=>{for(var g=i>1?void 0:i?sIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&oIA(A,e,g),g};class iB extends JA{constructor(){super(...arguments),n(this,"objectBounds",!1),n(this,"color"),n(this,"isGizmo",!0),n(this,"_gizmoObject",null),n(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!Jc||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new Ju(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=YH(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),og.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var A;this._boxHelper;)(A=this._boxHelper)==null||A.update(),yield}}WR([w()],iB.prototype,"objectBounds",2),WR([w(SA)],iB.prototype,"color",2),WR([w()],iB.prototype,"isGizmo",2);var CIA=Object.defineProperty,aIA=Object.getOwnPropertyDescriptor,xl=(t,A,e,i)=>{for(var g=i>1?void 0:i?aIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&CIA(A,e,g),g};const VR=CA("debugui"),zR=CA("debuguilayout");class ZR{constructor(){n(this,"width"),n(this,"height")}}class XR{constructor(){n(this,"x"),n(this,"y"),n(this,"width"),n(this,"height")}}const ys=new y,Tl=new NA,ly=new MA,P2=class extends Ms{constructor(){super(...arguments),n(this,"_anchoredPosition"),n(this,"sizeDelta",new eA(100,100)),n(this,"pivot",new eA(.5,.5)),n(this,"anchorMin",new eA(0,0)),n(this,"anchorMax",new eA(1,1)),n(this,"minWidth"),n(this,"minHeight"),n(this,"lastMatrix"),n(this,"rectBlock"),n(this,"_transformNeedsUpdate",!1),n(this,"_initialPosition"),n(this,"_parentRectTransform"),n(this,"_lastUpdateFrame",-1),n(this,"_lastAnchoring"),n(this,"_createdBlocks",[]),n(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new eA),this._anchoredPosition}set anchoredPosition(t){this._anchoredPosition=t}get width(){let t=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const A=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;t=A*e,t+=this.sizeDelta.x}return this.minWidth!==void 0&&t<this.minWidth?this.minWidth:t}get height(){let t=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const A=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;t=A*e,t+=this.sizeDelta.y}return this.minHeight!==void 0&&t<this.minHeight?this.minHeight:t}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new eA),this.lastMatrix=new NA,this.rectBlock=new fA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,hE(this,"_anchoredPosition",()=>{this.markDirty()}),hE(this,"sizeDelta",()=>{this.markDirty()}),hE(this,"pivot",()=>{this.markDirty()}),hE(this,"anchorMin",()=>{this.markDirty()}),hE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var t;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(t=this.Canvas)==null||t.registerTransform(this)}onDisable(){var t;super.onDisable(),this.removeShadowComponent(),(t=this.Canvas)==null||t.unregisterTransform(this)}onParentRectTransformChanged(t){this._transformNeedsUpdate||this.onApplyTransform(zR?`${t.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(zR&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(t){var A;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=iA.getComponentInParent(this.gameObject.parent,P2):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,zR&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+t),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,ys.set(0,0,0),this.applyPivot(ys),e.matrix.setPosition(ys.x,ys.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(ly.copy(this.gameObject.quaternion),ly.x*=-1,ly.z*=-1,Tl.makeRotationFromQuaternion(ly),e.matrix.premultiply(Tl)),ys.set(0,0,0),this.applyAnchoring(ys),(A=this.Canvas)!=null&&A.screenspace?ys.z+=.1:ys.z+=.01,Tl.identity(),Tl.setPosition(ys.x,ys.y,ys.z),e.matrix.premultiply(Tl),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const g of BG(this.gameObject,Ms,i,1)){if(g===this||!g.activeAndEnabled)continue;const I=g;I.onParentRectTransformChanged&&I.onParentRectTransformChanged(this)}}applyAnchoring(t){this._lastAnchoring||(this._lastAnchoring=new eA);const A=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=A.x,this.gameObject.position.y+=A.y,this._lastAnchoring.copy(this._anchoredPosition),t.x+=this._initialPosition.x-this.gameObject.position.x,t.y+=this._initialPosition.y-this.gameObject.position.y,t.z+=this._initialPosition.z-this.gameObject.position.z;const e=this._parentRectTransform;if(e){let i=0;const g=1-this.anchorMax.y-this.anchorMin.y;i-=e.height*.5*g,t.y+=i;let I=0;const o=1-this.anchorMax.x-this.anchorMin.x;I-=e.width*.5*o,t.x+=I}}applyPivot(t){if(this.pivot&&!this.isRoot()){const A=this.pivot.x-.5;t.x-=A*this.sizeDelta.x*this.gameObject.scale.x;const e=this.pivot.y-.5;t.y-=e*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const t={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(t),t}ensureValidSize(t,A=1e-4){return t.width<=0&&(t.width=A),t.height<=0&&(t.height=1e-4),t}createNewBlock(t){t={...this.getBasicOptions(),...t},VR&&console.log(this.name,t);const A=new ER(t);return this._createdBlocks.push(A),A}createNewText(t){VR&&console.log(t),t={...this.getBasicOptions(),...t},VR&&console.log(this.name,t);const A=new cR(t);return this._createdTextBlocks.push(A),A}};let cI=P2;xl([w(eA)],cI.prototype,"anchoredPosition",1),xl([w(eA)],cI.prototype,"sizeDelta",2),xl([w(eA)],cI.prototype,"pivot",2),xl([w(eA)],cI.prototype,"anchorMin",2),xl([w(eA)],cI.prototype,"anchorMax",2);class nIA extends bH{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const i in e)for(const g in e[i])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(i);for(const i of A._components)A._simpleState__statesProperties[i.id]&&(A._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const i=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],i.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)i.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const i in A)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=A[i]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var rIA=Object.defineProperty,BIA=Object.getOwnPropertyDescriptor,j2=(t,A,e,i)=>{for(var g=i>1?void 0:i?BIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&rIA(A,e,g),g};class fE extends JA{constructor(){super(...arguments),n(this,"effectColor"),n(this,"effectDistance")}}j2([w(wt)],fE.prototype,"effectColor",2),j2([w(eA)],fE.prototype,"effectDistance",2);var QIA=Object.defineProperty,EIA=Object.getOwnPropertyDescriptor,W2=(t,A,e,i)=>{for(var g=i>1?void 0:i?EIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&QIA(A,e,g),g};const dy={backgroundColor:new SA(1,1,1),backgroundOpacity:1,borderColor:new SA(1,1,1),borderOpacity:1};var $R;const py=($R=class extends Ms{constructor(){super(...arguments),n(this,"_alphaFactor",1),n(this,"sRGBColor",new SA(1,0,1)),n(this,"raycastTarget",!0),n(this,"uiObject",null),n(this,"_color",null),n(this,"_rect",null),n(this,"_stateManager",null),n(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new wt(1,1,1,1)),this._color}set color(t){(!this._color||this._color.r!==t.r||this._color.g!==t.g||this._color.b!==t.b||this._color.alpha!==t.alpha)&&(this._color||(this._color=new wt(1,1,1,1)),this._color.copy(t),this.onColorChanged())}setAlphaFactor(t){this._alphaFactor=t,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),dy.backgroundColor=this.sRGBColor,dy.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(dy,this._alphaFactor),this.uiObject.set(dy),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=iA.getComponent(this.gameObject,cI)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var t;(t=this.uiObject)==null||t.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(t){this.makePanel(),this.uiObject&&(this.uiObject.setState(t),this==null||this.markDirty())}setupState(t){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new nIA(this.uiObject)),this.uiObject.setupState(t.state,t.attributes))}setOptions(t){this.makePanel(),this.uiObject&&this.uiObject.set(t)}awake(){super.awake(),this.makePanel(),hE(this,"_color",()=>sgA(this,this.onColorChanged))}onEnable(){var t;super.onEnable(),this.uiObject&&((t=this.rectTransform.shadowComponent)==null||t.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const t=.015,A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:t};this.onBeforeCreate(A),this.applyEffects(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(t){}onCreate(t){this.uiObject=this.rectTransform.createNewBlock(t),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(t,A=1){var e;const i=(e=this.gameObject)==null?void 0:e.getComponent(fE);i&&(i.effectDistance&&(t.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(t.borderColor=i.effectColor,t.borderOpacity=i.effectColor.alpha*A))}async setTexture(t){if(this.setOptions({backgroundOpacity:0}),t){if(py.textureCache.has(t))t=py.textureCache.get(t);else if(!t.isRenderTargetTexture){const A=t.clone();A.colorSpace=Qi,py.textureCache.set(t,A),t=A}this.setOptions({backgroundImage:t,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},n($R,"textureCache",new Map),$R);let gB=py;W2([w(wt)],gB.prototype,"color",1),W2([w()],gB.prototype,"raycastTarget",2);class Yl extends gB{constructor(){super(...arguments),n(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var hIA=Object.defineProperty,cIA=Object.getOwnPropertyDescriptor,uy=(t,A,e,i)=>{for(var g=i>1?void 0:i?cIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&hIA(A,e,g),g};let AU=class{constructor(){n(this,"texture",null),n(this,"rect")}};uy([w(Je)],AU.prototype,"texture",2);let mE=class extends Yl{constructor(){super(...arguments),n(this,"_sprite"),n(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new AU),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,A,e,i,g,I,o,s;switch((A=(t=this.sprite)==null?void 0:t.texture)==null?void 0:A.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((g=(i=(e=this.sprite)==null?void 0:e.texture)==null?void 0:i.image)==null?void 0:g.width)===32&&((s=(o=(I=this.sprite)==null?void 0:I.texture)==null?void 0:o.image)==null?void 0:s.height)===32}onBeforeCreate(t){var A,e;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((e=(A=this.sprite)==null?void 0:A.texture)==null?void 0:e.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};uy([w(AU)],mE.prototype,"sprite",1),uy([w()],mE.prototype,"pixelsPerUnitMultiplier",2);class Dy extends Yl{constructor(){super(...arguments),n(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}uy([w(Je)],Dy.prototype,"mainTexture",1);var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,so=(t,A,e,i)=>{for(var g=i>1?void 0:i?dIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lIA(A,e,g),g};const kE=CA("debugbutton");class IB{constructor(){n(this,"colorMultiplier"),n(this,"disabledColor"),n(this,"fadeDuration"),n(this,"highlightedColor"),n(this,"normalColor"),n(this,"pressedColor"),n(this,"selectedColor")}}so([w()],IB.prototype,"colorMultiplier",2),so([w(wt)],IB.prototype,"disabledColor",2),so([w()],IB.prototype,"fadeDuration",2),so([w(wt)],IB.prototype,"highlightedColor",2),so([w(wt)],IB.prototype,"normalColor",2),so([w(wt)],IB.prototype,"pressedColor",2),so([w(wt)],IB.prototype,"selectedColor",2);class ha extends JA{constructor(){super(...arguments),n(this,"onClick"),n(this,"_isHovered",!1),n(this,"colors"),n(this,"transition"),n(this,"animationTriggers"),n(this,"animator"),n(this,"_interactable",!0),n(this,"_requestedAnimatorTrigger"),n(this,"_isInit",!1),n(this,"_image")}onPointerEnter(A){var e,i;kE&&console.log("Button Enter",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var A,e;kE&&console.log("Button Exit",(A=this.animationTriggers)==null?void 0:A.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((e=this._image)==null||e.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(A){var e,i;kE&&console.log("Button Down",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(A){var e,i;kE&&console.warn("Button Up",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(A){!this.interactable||A.pointerId!==0||A.pointerId!==0&&this.context.input.getIsMouse(A.pointerId)||(kE&&(console.warn("Button Click",this.onClick),li("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),A.use()))}set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(A){this.interactable=A}awake(){super.awake(),kE&&console.log(this),this._isInit=!1,this.init()}start(){var A;(A=this._image)==null||A.setInteractable(this.interactable),this.gameObject.getComponentInParent(kn)||this.gameObject.addComponent(Ay)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(A){var e;this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&((e=this.animator)==null||e.SetTrigger(A))}init(){this._isInit||(this._isInit=!0,this._image=iA.getComponent(this.gameObject,mE),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){var e,i,g,I,o;A.setInteractable(this.interactable);const s=this.getFinalColor(A.color,(e=this.colors)==null?void 0:e.normalColor),C={state:"normal",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};A.setupState(C);const a=this.getFinalColor(A.color,(i=this.colors)==null?void 0:i.highlightedColor),r={state:"hovered",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};A.setupState(r);const B=this.getFinalColor(A.color,(g=this.colors)==null?void 0:g.pressedColor),Q={state:"pressed",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};A.setupState(Q);const E=this.getFinalColor(A.color,(I=this.colors)==null?void 0:I.selectedColor),h={state:"selected",attributes:{backgroundColor:E,backgroundOpacity:E.alpha}};A.setupState(h);const d=this.getFinalColor(A.color,(o=this.colors)==null?void 0:o.disabledColor),l={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};A.setupState(l)}getFinalColor(A,e){return e?A.clone().multiply(e).convertLinearToSRGB():A.clone().convertLinearToSRGB()}}so([w(wg)],ha.prototype,"onClick",2),so([w()],ha.prototype,"colors",2),so([w()],ha.prototype,"transition",2),so([w()],ha.prototype,"animationTriggers",2),so([w(kg)],ha.prototype,"animator",2),so([w()],ha.prototype,"interactable",1);var pIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,xi=(t,A,e,i)=>{for(var g=i>1?void 0:i?uIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&pIA(A,e,g),g};const V2=CA("debuguilayout");class Un{constructor(){n(this,"left",0),n(this,"right",0),n(this,"top",0),n(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}xi([w()],Un.prototype,"left",2),xi([w()],Un.prototype,"right",2),xi([w()],Un.prototype,"top",2),xi([w()],Un.prototype,"bottom",2);class Co extends JA{constructor(){super(...arguments),n(this,"_rectTransform",null),n(this,"_needsUpdate",!1),n(this,"childAlignment",0),n(this,"reverseArrangement",!1),n(this,"spacing",0),n(this,"padding"),n(this,"minWidth",0),n(this,"minHeight",0),n(this,"flexibleHeight",0),n(this,"flexibleWidth",0),n(this,"preferredHeight",0),n(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(A){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(V2&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){V2&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(cI);const A=this.gameObject.getComponentInParent(Gg);A&&A.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const A=this.gameObject.getComponentInParent(Gg);A&&A.unregisterLayoutGroup(this)}set m_Spacing(A){A!==this.spacing&&(this._needsUpdate=!0,this.spacing=A)}get m_Spacing(){return this.spacing}}xi([w()],Co.prototype,"childAlignment",2),xi([w()],Co.prototype,"reverseArrangement",2),xi([w()],Co.prototype,"spacing",2),xi([w(Un)],Co.prototype,"padding",2),xi([w()],Co.prototype,"minWidth",2),xi([w()],Co.prototype,"minHeight",2),xi([w()],Co.prototype,"flexibleHeight",2),xi([w()],Co.prototype,"flexibleWidth",2),xi([w()],Co.prototype,"preferredHeight",2),xi([w()],Co.prototype,"preferredWidth",2);class Nn extends Co{constructor(){super(...arguments),n(this,"childControlHeight",!0),n(this,"childControlWidth",!0),n(this,"childForceExpandHeight",!1),n(this,"childForceExpandWidth",!1),n(this,"childScaleHeight",!1),n(this,"childScaleWidth",!1)}onCalculateLayout(A){var e;const i=this.primaryAxis,g=A.width;let I=g;const o=A.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const C=i==="x",a=C?"y":"x",r=C?this.childControlWidth:this.childControlHeight,B=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,d=C?g:o,l=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let u=0,p=0;for(let R=0;R<this.gameObject.children.length;R++){const m=this.gameObject.children[R],f=iA.getComponent(m,cI);f!=null&&f.activeAndEnabled&&(p+=1,C?u+=f.width:u+=f.height)}let D=0;const S=this.spacing*(p-1);if(Q||r){let R=0;C?R=I-=S:R=s-=S,p>0&&(D=R/p)}let G=0;G+=this.padding.left,G-=this.padding.right,l!==0&&(c=d-u,c*=l,c-=S*l,C?(c-=this.padding.right*l,c+=this.padding.left*(1-l),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*l,c+=this.padding.top*(1-l),c<this.padding.top&&(c=this.padding.top)));let k=1;for(let R=0;R<this.gameObject.children.length;R++){const m=this.gameObject.children[R],f=iA.getComponent(m,cI);if(f!=null&&f.activeAndEnabled){(e=f.pivot)==null||e.set(.5,.5),f.anchorMin.set(0,1),f.anchorMax.set(0,1);const b=g*.5+G*.5;f.anchoredPosition.x!==b&&(f.anchoredPosition.x=b);const H=o*-.5;f.anchoredPosition.y!==H&&(f.anchoredPosition.y=H),E&&B&&f.sizeDelta[a]!==h&&(f.sizeDelta[a]=h),Q&&r&&f.sizeDelta[i]!==D&&(f.sizeDelta[i]=D);const L=C?f.width:f.height,O=L*.5;if(c+=O,Q){const T=D*k-D*.5;T>c&&(c=T-D*.5+L+this.padding.left,c-=O)}let Z=c;i==="y"&&(Z=-Z),f.anchoredPosition[i]!==Z&&(f.anchoredPosition[i]=Z),c+=O,c+=this.spacing,k+=1}}}}xi([w()],Nn.prototype,"childControlHeight",2),xi([w()],Nn.prototype,"childControlWidth",2),xi([w()],Nn.prototype,"childForceExpandHeight",2),xi([w()],Nn.prototype,"childForceExpandWidth",2),xi([w()],Nn.prototype,"childScaleHeight",2),xi([w()],Nn.prototype,"childScaleWidth",2);class eU extends Nn{get primaryAxis(){return"y"}}class tU extends Nn{get primaryAxis(){return"x"}}class iU extends Co{onCalculateLayout(){}}var DIA=Object.defineProperty,wIA=Object.getOwnPropertyDescriptor,iC=(t,A,e,i)=>{for(var g=i>1?void 0:i?wIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DIA(A,e,g),g},z2=(t=>(t[t.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",t[t.ScreenSpaceCamera=1]="ScreenSpaceCamera",t[t.WorldSpace=2]="WorldSpace",t[t.Undefined=-1]="Undefined",t))(z2||{});const gU=CA("debuguilayout"),Z2=class extends yl{constructor(){super(...arguments),n(this,"_renderOnTop"),n(this,"_depthWrite",!1),n(this,"_doubleSided",!0),n(this,"_castShadows",!1),n(this,"_receiveShadows",!1),n(this,"_renderMode",-1),n(this,"_rootCanvas"),n(this,"_scaleFactor",1),n(this,"worldCamera"),n(this,"planeDistance",-1),n(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),n(this,"previousParent",null),n(this,"_lastMatrixWorld",null),n(this,"_rectTransforms",[]),n(this,"_layoutGroups",new Map),n(this,"_receivers",[]),n(this,"onBeforeRenderRoutine",()=>{var t,A,e,i;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(A=this.shadowComponent)==null||A.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),go.ensureUpdateMeshUI(lR,this.context,!0);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),go.ensureUpdateMeshUI(lR,this.context))}),n(this,"onAfterRenderRoutine",()=>{var t,A;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const g=this.context.mainCamera;g?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const e=this.context.renderer.autoClear,i=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),go.ensureUpdateMeshUI(lR,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=e,this.context.renderer.autoClearColor=i,this.previousParent.add(this.gameObject)}(A=this._lastMatrixWorld)==null||A.copy(this.gameObject.matrixWorld)}}),n(this,"_updateRenderSettingsRoutine"),n(this,"_activeRenderMode",-1),n(this,"_lastWidth",-1),n(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(t){t!==this._renderOnTop&&(this._renderOnTop=t,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(t){this._depthWrite!==t&&(this._depthWrite=t,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(t){this._doubleSided!==t&&(this._doubleSided=t,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(t){this._castShadows!==t&&(this._castShadows=t,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(t){this._receiveShadows!==t&&(this._receiveShadows=t,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode!==t&&(this._renderMode=t,this.onRenderSettingsChanged())}set rootCanvas(t){this._rootCanvas instanceof Z2||(this._rootCanvas=t)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(t){this._scaleFactor=t}awake(){var t;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,gU&&console.log("Canvas.Awake()",((t=this.previousParent)==null?void 0:t.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new NA,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);t!==-1&&this.context.pre_render_callbacks.splice(t,1);const A=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);A!==-1&&this.context.post_render_callbacks.splice(A,1)}registerTransform(t){this._rectTransforms.push(t)}unregisterTransform(t){const A=this._rectTransforms.indexOf(t);A!==-1&&this._rectTransforms.splice(A,1)}registerLayoutGroup(t){const A=t.gameObject;this._layoutGroups.set(A,t)}unregisterLayoutGroup(t){const A=t.gameObject;this._layoutGroups.delete(A)}registerEventReceiver(t){this._receivers.push(t)}unregisterEventReceiver(t){const A=this._receivers.indexOf(t);A!==-1&&this._receivers.splice(A,1)}invokeBeforeRenderEvents(){var t;for(const A of this._receivers)(t=A.onBeforeCanvasRender)==null||t.call(A,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new NA);const t=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);gU&&t&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const A=!1;for(const e of this._rectTransforms){t&&e.markDirty();let i=this._layoutGroups.get(e.gameObject);e.isDirty&&!i&&(i=e.gameObject.getComponentInParent(Co)),(e.isDirty||i!=null&&i.isDirty)&&(gU&&!A&&console.log("CANVAS UPDATE ### "+e.name+" ##################################### "+this.context.time.frame),i?.updateLayout(),e.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),og.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),ty(this.shadowComponent,this);for(const t of iA.getComponentsInChildren(this.gameObject,Ms))ty(t.shadowComponent,this)}}onUpdateRenderMode(t=!1){if(!t&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let A=this.context.mainCameraComponent,e=10;switch(A&&A.nearClipPlane>0&&A.farClipPlane>0&&(e=$A.lerp(A.nearClipPlane,A.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(A=this.worldCamera),this.planeDistance>0&&(e=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!A)return;const i=e+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const g=this.gameObject.getComponent(cI);let I=!1;g.sizeDelta.x!==this.context.domWidth&&(I=!0),g.sizeDelta.y!==this.context.domHeight&&(I=!0);const o=A.fieldOfView*Math.PI/180,s=2*Math.tan(o/2)*Math.abs(i);this.gameObject.scale.x=s/this.context.domHeight,this.gameObject.scale.y=s/this.context.domHeight,this.gameObject.scale.z=.01,I&&(g.sizeDelta.x=this.context.domWidth,g.sizeDelta.y=this.context.domHeight,g?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Gg=Z2;iC([w()],Gg.prototype,"renderOnTop",1),iC([w()],Gg.prototype,"depthWrite",1),iC([w()],Gg.prototype,"doubleSided",1),iC([w()],Gg.prototype,"castShadows",1),iC([w()],Gg.prototype,"receiveShadows",1),iC([w()],Gg.prototype,"renderMode",1),iC([w(Gg)],Gg.prototype,"rootCanvas",1),iC([w()],Gg.prototype,"scaleFactor",1),iC([w(Tt)],Gg.prototype,"worldCamera",2),iC([w()],Gg.prototype,"planeDistance",2);var yIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,IU=(t,A,e,i)=>{for(var g=i>1?void 0:i?SIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&yIA(A,e,g),g};class Fn extends JA{constructor(){super(...arguments),n(this,"_alpha",1),n(this,"interactable",!0),n(this,"blocksRaycasts",!0),n(this,"_isDirty",!1),n(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),og.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const A of iA.getComponentsInChildren(this.gameObject,Ms,this._buffer)){const e=A;e.setAlphaFactor&&e.setAlphaFactor(this._alpha)}}}IU([w()],Fn.prototype,"alpha",1),IU([w()],Fn.prototype,"interactable",2),IU([w()],Fn.prototype,"blocksRaycasts",2);var fIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,si=(t,A,e,i)=>{for(var g=i>1?void 0:i?mIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&fIA(A,e,g),g};function Hl(t){t&&(t.getComponentInParent(kn)||(Oe()&&console.warn("Create Raycaster on "+t.name+" because no raycaster was found in the hierarchy"),t.addNewComponent(ws)))}class oB extends JA{constructor(){super(...arguments),n(this,"object"),n(this,"target"),n(this,"duration",1),n(this,"relativeMotion",!1),n(this,"coroutine",null),n(this,"targetPos",new y),n(this,"targetRot",new MA),n(this,"targetScale",new y)}start(){Hl(this.gameObject)}onPointerClick(A){A.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const A=he(this.object).clone(),e=he(this.target).clone(),i=Mt(this.object).clone(),g=Mt(this.target).clone(),I=Ig(this.object).clone(),o=Ig(this.target).clone(),s=A.distanceTo(e),C=i.angleTo(g),a=I.distanceTo(o);if(s<.01&&C<.01&&a<.01){pi(this.object,e),II(this.object,g),Pu(this.object,o),this.coroutine=null;return}let r=0,B=0;for(;r<1;)r+=this.context.time.deltaTime/this.duration,r>1&&(r=1),B=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,this.targetPos.lerpVectors(A,e,B),this.targetRot.slerpQuaternions(i,g,B),this.targetScale.lerpVectors(I,o,B),pi(this.object,this.targetPos),II(this.object,this.targetRot),Pu(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const A=this.object.position.clone(),e=this.object.quaternion.clone(),i=this.object.scale.clone(),g=this.target.position.clone(),I=this.target.quaternion.clone(),o=this.target.scale.clone();g.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(g),this.targetRot.copy(this.object.quaternion).multiply(I),this.targetScale.copy(this.object.scale).multiply(o);let s=0,C=0;for(;s<1;)s+=this.context.time.deltaTime/this.duration,s>1&&(s=1),C=s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,this.object.position.lerpVectors(A,this.targetPos,C),this.object.quaternion.slerpQuaternions(e,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(A){var e;if(this.target&&this.object&&this.gameObject){const i=new QI("Move to "+((e=this.target)==null?void 0:e.name),EI.tapTrigger(this.gameObject),yt.transformAction(this.object,this.target,this.duration,this.relativeMotion?SR.Relative:SR.Absolute));A.addBehavior(i)}}}si([w(fA)],oB.prototype,"object",2),si([w(fA)],oB.prototype,"target",2),si([w()],oB.prototype,"duration",2),si([w()],oB.prototype,"relativeMotion",2);var wy;const ca=(wy=class extends JA{constructor(){super(...arguments),n(this,"materialToSwitch"),n(this,"variantMaterial"),n(this,"fadeDuration",0),n(this,"_objectsWithThisMaterial",[]),n(this,"selfModel"),n(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const t=iA.findObjectsOfType(Di);for(const A of t)for(let e=0;e<A.sharedMaterials.length;e++){const i=A.sharedMaterials[e];if(i===this.materialToSwitch){if(A.gameObject instanceof uA)this._objectsWithThisMaterial.push(A.gameObject);else if(A.gameObject instanceof tI)for(const g of A.gameObject.children)g instanceof uA&&g.material===i&&this._objectsWithThisMaterial.push(g);break}}}}start(){Hl(this.gameObject)}onPointerClick(t){if(t.use(),!!this.variantMaterial)for(let A=0;A<this._objectsWithThisMaterial.length;A++){const e=this._objectsWithThisMaterial[A];e.material=this.variantMaterial}}async beforeCreateDocument(t,A){this.targetModels=[],ca._materialTriggersPerId={},ca.variantSwitchIndex=0,this.materialToSwitch&&await cs.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await cs.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(t,A,e){this._objectsWithThisMaterial.find(i=>i.uuid===A.uuid)&&this.targetModels.push(A),this.gameObject.uuid===A.uuid&&(this.selfModel=A,this.materialToSwitch&&(ca._materialTriggersPerId[this.materialToSwitch.uuid]||(ca._materialTriggersPerId[this.materialToSwitch.uuid]=[]),ca._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(t,A){if(!this.materialToSwitch)return;const e=ca._materialTriggersPerId[this.materialToSwitch.uuid];if(e){const i={};for(const g of e){const I=g.createVariants();I&&I.length>0&&(i[g.selfModel.uuid]=I)}for(const g of e){const I=[];for(const o in i)o!==g.selfModel.uuid&&I.push(...i[o]);g.createAndAttachBehaviors(t,i[g.selfModel.uuid],I)}}delete ca._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(t,A,e){const i=[],g=[],I=Math.max(0,this.fadeDuration);g.push(yt.fadeAction([...this.targetModels,...e],I,!1)),i.push(yt.fadeAction(A,I,!1)),g.push(yt.fadeAction(A,I,!0)),t.addBehavior(new QI("Select_"+this.selfModel.name,EI.tapTrigger(this.selfModel),yt.parallel(...g))),t.addBehavior(new QI("StartHidden_"+this.selfModel.name,EI.sceneStartTrigger(),yt.parallel(...i)))}createVariants(){if(!this.variantMaterial)return null;const t=[];for(const A of this.targetModels){const e=A.clone();e.name+=" variant_"+this.variantMaterial.name+"_"+ca.variantSwitchIndex++,e.name=e.name.replace(/\s/g,"_"),e.material=this.variantMaterial,e.geometry=A.geometry,e.matrix=A.matrix,(!A.parent||!A.parent.isEmpty())&&Ko.createEmptyParent(A),A.parent&&A.parent.add(e),t.push(e)}return t}},n(wy,"_materialTriggersPerId",{}),n(wy,"variantSwitchIndex",0),wy);let GE=ca;si([w(ve)],GE.prototype,"materialToSwitch",2),si([w(ve)],GE.prototype,"variantMaterial",2),si([w()],GE.prototype,"fadeDuration",2);class ME extends JA{constructor(){super(...arguments),n(this,"target"),n(this,"toggleOnClick",!1),n(this,"targetState",!0),n(this,"hideSelf",!0),n(this,"selfModel"),n(this,"otherModel"),n(this,"toggleModel"),n(this,"stateBeforeCreatingDocument",!1)}start(){Hl(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(A,e){if(this.target){if(this.otherModel=e.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let i=this.hideSelf;this.targetState,this.toggleOnClick&&(i=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&e2.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const g=[];if(i&&g.push(yt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&g.push(yt.fadeAction(this.toggleModel,0,!0)),g.push(yt.fadeAction(this.otherModel,0,this.targetState)),A.addBehavior(new QI("Toggle_"+this.selfModel.name+"_hideSelf",EI.tapTrigger(this.selfModel),yt.sequence(...g))),this.toggleOnClick&&this.toggleModel){const I=[];I.push(yt.fadeAction(this.toggleModel,0,!1)),I.push(yt.fadeAction(this.selfModel,0,!0)),I.push(yt.fadeAction(this.otherModel,0,!this.targetState)),A.addBehavior(new QI("Toggle_"+this.selfModel.name+"_toggleSelf",EI.tapTrigger(this.toggleModel),yt.sequence(...I))),A.addBehavior(new QI("HideOnStart_"+this.gameObject.name,EI.sceneStartTrigger(),yt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}si([w(fA)],ME.prototype,"target",2),si([w()],ME.prototype,"targetState",2),si([w()],ME.prototype,"hideSelf",2);class oU extends JA{start(){this.gameObject.visible=!1}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&A.addBehavior(new QI("HideOnStart_"+this.gameObject.name,EI.sceneStartTrigger(),yt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class RE extends JA{constructor(){super(...arguments),n(this,"target"),n(this,"duration",.5),n(this,"motionType",yR.bounce)}beforeCreateDocument(){}createBehaviours(A,e,i){if(this.target&&e.uuid===this.gameObject.uuid){const g=new QI("emphasize "+this.name,EI.tapTrigger(this.gameObject),yt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));A.addBehavior(g)}}afterCreateDocument(A,e){}}si([w()],RE.prototype,"target",2),si([w()],RE.prototype,"duration",2),si([w()],RE.prototype,"motionType",2);class UE extends JA{constructor(){super(...arguments),n(this,"target"),n(this,"clip",""),n(this,"toggleOnClick",!1)}start(){Hl(this.gameObject)}onPointerClick(A){if(A.use(),!!this.clip){if(!this.target){const e=this.gameObject.addNewComponent(yi);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(A,e,i){if(!(!this.target&&!this.clip)&&e.uuid===this.gameObject.uuid){const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=this.target?this.target.gameObject:this.gameObject,o=g.split("/").pop(),s=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?mR.NonSpatial:mR.Spatial,a=new QI("playAudio "+this.name,EI.tapTrigger(this.gameObject),yt.playAudioAction(I,"audio/"+o,h2.Play,s,C));A.addBehavior(a)}}async afterSerialize(A,e){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i||typeof i!="string")return;const g=i.split("/").pop(),I=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(I);e.files["audio/"+g]=o}}si([w(yi)],UE.prototype,"target",2),si([w(URL)],UE.prototype,"clip",2),si([w()],UE.prototype,"toggleOnClick",2);var yy;const Kn=(yy=class extends JA{constructor(){super(...arguments),n(this,"animator"),n(this,"stateName"),n(this,"trigger","tap"),n(this,"selfModel"),n(this,"stateAnimationModel"),n(this,"animationSequence",new Array),n(this,"animationLoopAfterSequence",new Array)}get target(){var t;return(t=this.animator)==null?void 0:t.gameObject}start(){Hl(this.gameObject)}onPointerClick(t){var A;t.use(),this.target&&this.stateName&&((A=this.animator)==null||A.play(this.stateName,0,0,.1))}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A)}afterSerialize(){if(Kn.rootsWithExclusivePlayback.size>1){const t='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';Oe()&&gg(t),console.warn(t,...Kn.rootsWithExclusivePlayback)}Kn.animationActions=[],Kn.rootsWithExclusivePlayback=new Set}afterCreateDocument(t,A){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const e=A.document,i=A.extensions.find(o=>o instanceof Fl);if(!i)return;const g=i.getClipCount(this.target)>1;g&&(Oe()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+i.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Kn.rootsWithExclusivePlayback.add(this.target));const I=(o,s)=>{let C=Kn.animationActions.find(a=>a.affectedObjects==o&&a.start==s.start&&a.duration==s.duration);return C||(C=yt.startAnimationAction(o,s.start,s.duration),Kn.animationActions.push(C)),C};e.traverse(o=>{var s,C;if(o.uuid===((s=this.target)==null?void 0:s.uuid)){const a=yt.sequence();if(this.animationSequence!==void 0)for(const B of this.animationSequence)a.addAction(I(o,B));if(this.animationLoopAfterSequence!==void 0){const B=a.actions.length==0?a:yt.sequence();for(const Q of this.animationLoopAfterSequence)B.addAction(I(o,Q));B.makeLooping(),a!==B&&a.addAction(B)}const r=new QI("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?EI.tapTrigger(this.selfModel):EI.sceneStartTrigger(),a);g&&r.makeExclusive(!0),t.addBehavior(r)}})}createAnimation(t,A,e){var i,g,I,o;if(!this.target||!this.animator)return;const s=(i=this.animator)==null?void 0:i.runtimeAnimatorController;let C=s?.findState(this.stateName),a=[],r=[];if(s&&C){const B=new Array;B.push(C);let Q=!1;for(;B.length<100;){if(!C||C===null||!C.transitions||C.transitions.length===0){(g=C.motion)!=null&&g.isLooping&&(Q=!0);break}const E=C.transitions.find(d=>d.conditions.length===0),h=E?s.getState(E.destinationState,0):null;if(h&&B.includes(h)){C=h,Q=!0;break}else if(E){if(C=h,!C)break;B.push(C)}else{Q=((I=C.motion)==null?void 0:I.isLooping)??!1;break}}if(Q&&C){const E=B.indexOf(C);a=B.slice(0,E),r=B.slice(E),console.log("found loop from "+this.stateName,"states until loop",a,"states looping",r)}else a=B,r=[],console.log("found no loop from "+this.stateName,"states",a)}if(a=a.filter(B=>{var Q,E,h;return((Q=B.motion)==null?void 0:Q.clip)&&((h=(E=B.motion)==null?void 0:E.clip.tracks)==null?void 0:h.length)>0}),r=r.filter(B=>{var Q,E,h;return((Q=B.motion)==null?void 0:Q.clip)&&((h=(E=B.motion)==null?void 0:E.clip.tracks)==null?void 0:h.length)>0}),a.length===0&&r.length===0){console.warn("No clips found for state "+this.stateName+" on "+((o=this.animator)==null?void 0:o.name)+", can't export animation data");return}if(this.stateAnimationModel=A,a.length>0){this.animationSequence=new Array;for(const B of a)this.animationSequence.push(t.registerAnimation(this.target,B.motion.clip))}if(r.length>0){this.animationLoopAfterSequence=new Array;for(const B of r)this.animationLoopAfterSequence.push(t.registerAnimation(this.target,B.motion.clip))}}},n(yy,"animationActions",[]),n(yy,"rootsWithExclusivePlayback",new Set),yy);let NE=Kn;si([w(kg)],NE.prototype,"animator",2),si([w()],NE.prototype,"stateName",2);class FE extends JA{constructor(){super(...arguments),n(this,"target")}getType(){}getDuration(){}}si([w(fA)],FE.prototype,"target",2);class Ol extends JA{constructor(){super(...arguments),n(this,"target")}}si([w(FE)],Ol.prototype,"target",2);class _l extends FE{constructor(){super(...arguments),n(this,"type",1),n(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}si([w()],_l.prototype,"type",2),si([w()],_l.prototype,"duration",2);class sU extends Ol{}var kIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,la=(t,A,e,i)=>{for(var g=i>1?void 0:i?GIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kIA(A,e,g),g};const X2=CA("debugcharactercontroller");class sB extends JA{constructor(){super(...arguments),n(this,"center",new y(0,0,0)),n(this,"radius",.5),n(this,"height",2),n(this,"_rigidbody",null),n(this,"_activeGroundCollisions"),n(this,"_contactVelocity",new y)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Kt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Kt)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const A=this.rigidbody;let e=this.gameObject.getComponent(Rn);e||(e=this.gameObject.addNewComponent(Rn)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height;const i=new y(0,0,1),g=new y(1,0,0),I=new y(0,1,0),o=this.gameObject.getWorldDirection(new y);o.y=0;const s=g.dot(o)<0?-1:1,C=i.angleTo(o)*s;this.gameObject.setRotationFromAxisAngle(I,C),A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}onCollisionEnter(A){(A.contacts.length==0||A.contacts.some(e=>e.normal.y>.2))&&(this._activeGroundCollisions.add(A),X2&&console.log(`Collision(${this._activeGroundCollisions.size}): ${A.contacts.map(e=>e.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(A){this._activeGroundCollisions.delete(A),X2&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var A;this._contactVelocity.set(0,0,0);for(const e of this._activeGroundCollisions){const i=(A=this.context.physics.engine)==null?void 0:A.getLinearVelocity(e.collider);i&&(this._contactVelocity.x+=i.x,this._contactVelocity.y+=i.y,this._contactVelocity.z+=i.z)}return this._contactVelocity}}la([w(y)],sB.prototype,"center",2),la([w()],sB.prototype,"radius",2),la([w()],sB.prototype,"height",2);class da extends JA{constructor(){super(...arguments),n(this,"controller"),n(this,"movementSpeed",2),n(this,"rotationSpeed",2),n(this,"jumpForce",1),n(this,"doubleJumpForce",2),n(this,"animator"),n(this,"lookForward",!0),n(this,"lookInput",new eA(0,0)),n(this,"moveInput",new eA(0,0)),n(this,"jumpInput",!1),n(this,"_currentSpeed",new y(0,0,0)),n(this,"_currentAngularSpeed",new y(0,0,0)),n(this,"_temp",new y(0,0,0)),n(this,"_jumpCount",0),n(this,"_currentRotation"),n(this,"_raycastOptions",new zI)}awake(){this._currentRotation=new MA}update(){const A=this.context.input;A.isKeyPressed("KeyW")?this.moveInput.y+=1:A.isKeyPressed("KeyS")&&(this.moveInput.y-=1),A.isKeyPressed("KeyD")?this.lookInput.x+=1:A.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=A.isKeyDown("Space"))}move(A){this.moveInput.add(A)}look(A){this.lookInput.add(A)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(A,e,i){var g,I,o,s,C,a,r,B,Q,E,h;if((g=this.controller)!=null&&g.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((I=this.animator)==null||I.setBool("doubleJump",!1))),this._currentSpeed.z+=A.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",A.length()>.01),(C=this.animator)==null||C.setBool("jumping",((s=this.controller)==null?void 0:s.isGrounded)===!0&&i),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=$A.toRadians(-e.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const d=this.context.mainCameraComponent.forward;d.y=0,d.normalize(),this._currentRotation.setFromUnitVectors(new y(0,0,1),d),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&i&&this.jumpForce>0){let d=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((r=this.controller)!=null&&r.isGrounded)&&this._jumpCount===1&&(d=!0,(B=this.animator)==null||B.setBool("doubleJump",!0)),d){this._jumpCount+=1;const l=this.controller.rigidbody,c=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new y(0,1,0).multiplyScalar(c))}}if(this.controller){const d=(Q=this.controller)==null?void 0:Q.rigidbody.getVelocity().y;if(d<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new As),this._raycastOptions.ray.origin.copy(he(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const c=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(c.length&&c[0].distance>2||d<-10)&&((E=this.animator)==null||E.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}la([w(sB)],da.prototype,"controller",2),la([w()],da.prototype,"movementSpeed",2),la([w()],da.prototype,"rotationSpeed",2),la([w()],da.prototype,"jumpForce",2),la([w()],da.prototype,"doubleJumpForce",2),la([w(kg)],da.prototype,"animator",2);var MIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,UIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?RIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&MIA(A,e,g),g};class Pl extends jg{constructor(){super(...arguments),n(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const A=new Sx;return A.offset=new eA(0,0),A.radialModulation=!0,A.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=e=>{A.offset.x=-e,A.offset.y=e},A}}UIA([w(Me)],Pl.prototype,"intensity",2),xo("ChromaticAberration",Pl);var NIA=Object.defineProperty,FIA=Object.getOwnPropertyDescriptor,Sy=(t,A,e,i)=>{for(var g=i>1?void 0:i?FIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&NIA(A,e,g),g};class Jn extends jg{constructor(){super(...arguments),n(this,"postExposure"),n(this,"contrast"),n(this,"hueShift"),n(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=A=>(A=Math.pow(2,A),A),this.postExposure.defaultValue=0,this.contrast.valueProcessor=A=>{let e=1;return A>0?e=200:A<0&&(e=100),A/e},this.contrast.defaultValue=0,this.hueShift.valueProcessor=A=>Math.PI*A/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=A=>A<0?A/100:A/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===$g&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Sh);const A=new yx;this.postExposure.onValueChanged=i=>{this.context.renderer.toneMapping===$g&&(this.context.renderer.toneMapping=Sh),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=i)},this.contrast.onValueChanged=i=>{A.contrast=i};const e=new mx;return this.hueShift.onValueChanged=i=>e.hue=i,this.saturation.onValueChanged=i=>e.saturation=i,[e,A]}}Sy([w(Me)],Jn.prototype,"postExposure",2),Sy([w(Me)],Jn.prototype,"contrast",2),Sy([w(Me)],Jn.prototype,"hueShift",2),Sy([w(Me)],Jn.prototype,"saturation",2),xo("ColorAdjustments",Jn);const KIA=(Math.sqrt(5)-1)/4,Mg=(5-Math.sqrt(5))/20,fy=t=>Math.floor(t)|0,my=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function JIA(t=Math.random){const A=vIA(t),e=new Float64Array(A).map(o=>my[o%32*4]),i=new Float64Array(A).map(o=>my[o%32*4+1]),g=new Float64Array(A).map(o=>my[o%32*4+2]),I=new Float64Array(A).map(o=>my[o%32*4+3]);return function(o,s,C,a){let r,B,Q,E,h;const d=(o+s+C+a)*KIA,l=fy(o+d),c=fy(s+d),u=fy(C+d),p=fy(a+d),D=(l+c+u+p)*Mg,S=l-D,G=c-D,k=u-D,R=p-D,m=o-S,f=s-G,b=C-k,H=a-R;let L=0,O=0,Z=0,T=0;m>f?L++:O++,m>b?L++:Z++,m>H?L++:T++,f>b?O++:Z++,f>H?O++:T++,b>H?Z++:T++;const v=L>=3?1:0,Y=O>=3?1:0,IA=Z>=3?1:0,AA=T>=3?1:0,W=L>=2?1:0,gA=O>=2?1:0,dA=Z>=2?1:0,mA=T>=2?1:0,vA=L>=1?1:0,TA=O>=1?1:0,WA=Z>=1?1:0,Ae=T>=1?1:0,zA=m-v+Mg,Se=f-Y+Mg,lA=b-IA+Mg,V=H-AA+Mg,xA=m-W+2*Mg,kA=f-gA+2*Mg,wA=b-dA+2*Mg,HA=H-mA+2*Mg,DA=m-vA+3*Mg,XA=f-TA+3*Mg,Ce=b-WA+3*Mg,Ee=H-Ae+3*Mg,Xe=m-1+4*Mg,Ct=f-1+4*Mg,x=b-1+4*Mg,J=H-1+4*Mg,hA=l&255,qA=c&255,bA=u&255,P=p&255;let yA=.6-m*m-f*f-b*b-H*H;if(yA<0)r=0;else{const GA=hA+A[qA+A[bA+A[P]]];yA*=yA,r=yA*yA*(e[GA]*m+i[GA]*f+g[GA]*b+I[GA]*H)}let FA=.6-zA*zA-Se*Se-lA*lA-V*V;if(FA<0)B=0;else{const GA=hA+v+A[qA+Y+A[bA+IA+A[P+AA]]];FA*=FA,B=FA*FA*(e[GA]*zA+i[GA]*Se+g[GA]*lA+I[GA]*V)}let cA=.6-xA*xA-kA*kA-wA*wA-HA*HA;if(cA<0)Q=0;else{const GA=hA+W+A[qA+gA+A[bA+dA+A[P+mA]]];cA*=cA,Q=cA*cA*(e[GA]*xA+i[GA]*kA+g[GA]*wA+I[GA]*HA)}let VA=.6-DA*DA-XA*XA-Ce*Ce-Ee*Ee;if(VA<0)E=0;else{const GA=hA+vA+A[qA+TA+A[bA+WA+A[P+Ae]]];VA*=VA,E=VA*VA*(e[GA]*DA+i[GA]*XA+g[GA]*Ce+I[GA]*Ee)}let ZA=.6-Xe*Xe-Ct*Ct-x*x-J*J;if(ZA<0)h=0;else{const GA=hA+1+A[qA+1+A[bA+1+A[P+1]]];ZA*=ZA,h=ZA*ZA*(e[GA]*Xe+i[GA]*Ct+g[GA]*x+I[GA]*J)}return 27*(r+B+Q+E+h)}}function vIA(t){const A=new Uint8Array(512);for(let e=0;e<512/2;e++)A[e]=e;for(let e=0;e<512/2-1;e++){const i=e+~~(t()*(256-e)),g=A[e];A[e]=A[i],A[i]=g}for(let e=256;e<512;e++)A[e]=A[e-256];return A}var qIA=Object.defineProperty,bIA=Object.getOwnPropertyDescriptor,sA=(t,A,e,i)=>{for(var g=i>1?void 0:i?bIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&qIA(A,e,g),g};const ky=CA("debugparticles");var pa=(t=>(t[t.Billboard=0]="Billboard",t[t.Stretch=1]="Stretch",t[t.HorizontalBillboard=2]="HorizontalBillboard",t[t.VerticalBillboard=3]="VerticalBillboard",t[t.Mesh=4]="Mesh",t))(pa||{});let vn=class{constructor(){n(this,"alphaKeys"),n(this,"colorKeys")}get duration(){return 1}evaluate(t,A){let e,i=0,g=null,I=0;for(let o=0;o<this.alphaKeys.length;o++){const s=this.alphaKeys[o];(s.time<t||!e)&&(e=s,i=o)}for(let o=0;o<this.colorKeys.length;o++){const s=this.colorKeys[o];(s.time<t||!g)&&(g=s,I=o)}if(g)if(I+1<this.colorKeys.length){const o=this.colorKeys[I+1],s=$A.remap(t,g.time,o.time,0,1);A.r=$A.lerp(g.color.r,o.color.r,s),A.g=$A.lerp(g.color.g,o.color.g,s),A.b=$A.lerp(g.color.b,o.color.b,s)}else A.r=g.color.r,A.g=g.color.g,A.b=g.color.b;if(e)if(i+1<this.alphaKeys.length){const o=this.alphaKeys[i+1],s=$A.remap(t,e.time,o.time,0,1);A.alpha=$A.lerp(e.alpha,o.alpha,s)}else A.alpha=e.alpha;return A}};sA([w()],vn.prototype,"alphaKeys",2),sA([w()],vn.prototype,"colorKeys",2);var jl=(t=>(t[t.Local=0]="Local",t[t.World=1]="World",t[t.Custom=2]="Custom",t))(jl||{}),$2=(t=>(t[t.Sphere=0]="Sphere",t[t.SphereShell=1]="SphereShell",t[t.Hemisphere=2]="Hemisphere",t[t.HemisphereShell=3]="HemisphereShell",t[t.Cone=4]="Cone",t[t.Box=5]="Box",t[t.Mesh=6]="Mesh",t[t.ConeShell=7]="ConeShell",t[t.ConeVolume=8]="ConeVolume",t[t.ConeVolumeShell=9]="ConeVolumeShell",t[t.Circle=10]="Circle",t[t.CircleEdge=11]="CircleEdge",t[t.SingleSidedEdge=12]="SingleSidedEdge",t[t.MeshRenderer=13]="MeshRenderer",t[t.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",t[t.BoxShell=15]="BoxShell",t[t.BoxEdge=16]="BoxEdge",t[t.Donut=17]="Donut",t[t.Rectangle=18]="Rectangle",t[t.Sprite=19]="Sprite",t[t.SpriteRenderer=20]="SpriteRenderer",t))($2||{});class Be{constructor(){n(this,"mode"),n(this,"constant"),n(this,"constantMin"),n(this,"constantMax"),n(this,"curve"),n(this,"curveMin"),n(this,"curveMax"),n(this,"curveMultiplier")}evaluate(A,e){const i=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=$A.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return $A.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),i%1)*this.curveMultiplier;case 3:return $A.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let i=0;i<A.keys.length;i++){const g=A.keys[i];g.value>e&&(e=g.value)}return e}}sA([w()],Be.prototype,"mode",2),sA([w()],Be.prototype,"constant",2),sA([w()],Be.prototype,"constantMin",2),sA([w()],Be.prototype,"constantMax",2),sA([w(Zr)],Be.prototype,"curve",2),sA([w(Zr)],Be.prototype,"curveMin",2),sA([w(Zr)],Be.prototype,"curveMax",2),sA([w()],Be.prototype,"curveMultiplier",2);var Gy;const Ss=(Gy=class{constructor(){n(this,"mode"),n(this,"color"),n(this,"colorMin"),n(this,"colorMax"),n(this,"gradient"),n(this,"gradientMin"),n(this,"gradientMax")}evaluate(t,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(t,Ss._temp),Ss._temp;case 2:return Ss._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(t,Ss._temp),this.gradientMax.evaluate(t,Ss._temp2),Ss._temp.lerp(Ss._temp2,e)}return Ss._temp.set(16711935),Ss._temp.alpha=1,Ss._temp}},n(Gy,"_temp",new wt(0,0,0,1)),n(Gy,"_temp2",new wt(0,0,0,1)),Gy);let FI=Ss;sA([w(wt)],FI.prototype,"color",2),sA([w(wt)],FI.prototype,"colorMin",2),sA([w(wt)],FI.prototype,"colorMax",2),sA([w(vn)],FI.prototype,"gradient",2),sA([w(vn)],FI.prototype,"gradientMin",2),sA([w(vn)],FI.prototype,"gradientMax",2);var CU=(t=>(t[t.Hierarchy=0]="Hierarchy",t[t.Local=1]="Local",t[t.Shape=2]="Shape",t))(CU||{});class Rg{constructor(){n(this,"cullingMode"),n(this,"duration"),n(this,"emitterVelocityMode"),n(this,"flipRotation"),n(this,"gravityModifier"),n(this,"gravityModifierMultiplier"),n(this,"loop"),n(this,"maxParticles"),n(this,"playOnAwake"),n(this,"prewarm"),n(this,"ringBufferLoopRange"),n(this,"ringBufferMode"),n(this,"scalingMode"),n(this,"simulationSpace"),n(this,"simulationSpeed"),n(this,"startColor"),n(this,"startDelay"),n(this,"startDelayMultiplier"),n(this,"startLifetime"),n(this,"startLifetimeMultiplier"),n(this,"startRotation"),n(this,"startRotationMultiplier"),n(this,"startRotation3D"),n(this,"startRotationX"),n(this,"startRotationXMultiplier"),n(this,"startRotationY"),n(this,"startRotationYMultiplier"),n(this,"startRotationZ"),n(this,"startRotationZMultiplier"),n(this,"startSize"),n(this,"startSize3D"),n(this,"startSizeMultiplier"),n(this,"startSizeX"),n(this,"startSizeXMultiplier"),n(this,"startSizeY"),n(this,"startSizeYMultiplier"),n(this,"startSizeZ"),n(this,"startSizeZMultiplier"),n(this,"startSpeed"),n(this,"startSpeedMultiplier"),n(this,"stopAction"),n(this,"useUnscaledTime")}}sA([w(Be)],Rg.prototype,"gravityModifier",2),sA([w(FI)],Rg.prototype,"startColor",2),sA([w(Be)],Rg.prototype,"startDelay",2),sA([w(Be)],Rg.prototype,"startLifetime",2),sA([w(Be)],Rg.prototype,"startRotation",2),sA([w(Be)],Rg.prototype,"startRotationX",2),sA([w(Be)],Rg.prototype,"startRotationY",2),sA([w(Be)],Rg.prototype,"startRotationZ",2),sA([w(Be)],Rg.prototype,"startSize",2),sA([w(Be)],Rg.prototype,"startSizeX",2),sA([w(Be)],Rg.prototype,"startSizeY",2),sA([w(Be)],Rg.prototype,"startSizeZ",2),sA([w(Be)],Rg.prototype,"startSpeed",2);class Wl{constructor(){n(this,"cycleCount"),n(this,"maxCount"),n(this,"minCount"),n(this,"probability"),n(this,"repeatInterval"),n(this,"time"),n(this,"count"),n(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(A>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=$A.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=$A.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class gC{constructor(){n(this,"enabled"),n(this,"bursts"),n(this,"rateOverTime"),n(this,"rateOverTimeMultiplier"),n(this,"rateOverDistance"),n(this,"rateOverDistanceMultiplier"),n(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const i=this.bursts[e];this.system.main.loop&&i.time>=this.system.time&&i.reset(),A+=Math.round(i.run(this.system.time))}return A}}sA([w()],gC.prototype,"enabled",2),sA([w()],gC.prototype,"bursts",2),sA([w(Be)],gC.prototype,"rateOverTime",2),sA([w()],gC.prototype,"rateOverTimeMultiplier",2),sA([w(Be)],gC.prototype,"rateOverDistance",2),sA([w()],gC.prototype,"rateOverDistanceMultiplier",2);class Vl{constructor(){n(this,"enabled"),n(this,"color")}}sA([w(FI)],Vl.prototype,"color",2);class qn{constructor(){n(this,"enabled"),n(this,"separateAxes"),n(this,"size"),n(this,"sizeMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier"),n(this,"_time",0),n(this,"_temp",new y)}evaluate(A,e,i){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,i)*this.xMultiplier,e.y=this.y.evaluate(A,i)*this.yMultiplier,e.z=this.z.evaluate(A,i)*this.zMultiplier;else{const g=this.size.evaluate(A,i)*this.sizeMultiplier;e.x=g}return e}}sA([w(Be)],qn.prototype,"size",2),sA([w(Be)],qn.prototype,"x",2),sA([w(Be)],qn.prototype,"y",2),sA([w(Be)],qn.prototype,"z",2);var My;const zl=(My=class{constructor(){n(this,"shapeType",5),n(this,"enabled",!0),n(this,"alignToDirection",!1),n(this,"angle",0),n(this,"arc",360),n(this,"arcSpread"),n(this,"arcSpeedMultiplier"),n(this,"arcMode"),n(this,"boxThickness"),n(this,"position"),n(this,"rotation"),n(this,"_rotation",new Gi),n(this,"scale"),n(this,"radius"),n(this,"radiusThickness"),n(this,"sphericalDirectionAmount"),n(this,"randomDirectionAmount"),n(this,"randomPositionAmount"),n(this,"system"),n(this,"_space"),n(this,"_worldSpaceMatrix",new NA),n(this,"_worldSpaceMatrixInverse",new NA),n(this,"_vector",new y(0,0,0)),n(this,"_temp",new y(0,0,0)),n(this,"_dir",new y),n(this,"_loopTime",0),n(this,"_loopDirection",1),ky&&console.log(this)}get type(){return $2[this.shapeType]}initialize(t){this.getPosition(),t.position.copy(this._vector)}toJSON(){return this}clone(){return new zl}update(t,A,e,i){this.system=t,this._space=e,e===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(t){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=$A.toRadians(this.rotation.x),this._rotation.y=$A.toRadians(this.rotation.y),this._rotation.z=$A.toRadians(this.rotation.z),this._rotation.order="ZYX",t.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const t=this._temp.copy(this.position),A=this._space===1;A&&t.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:ky&&Vs.DrawWireBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(t);break;case 4:this.randomConePoint(this.position,this.angle,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),ky&&Vs.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(t){var A;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const e=t.x,i=t.y,g=t.z;this._dir.set(e,i,g),(A=this.system)!=null&&A.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),ky&&(Vs.DrawSphere(t,.01,8925952,.5,!0),Vs.DrawDirection(t,this._dir,8925952,.5,!0)),this._dir}randomizePosition(t,A){if(A<=0)return;const e=zl._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,t.add(e)}randomizeDirection(t,A){if(A===0)return;const e=zl._randomQuat,i=zl._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(i,A*Math.random()*Math.PI),t.applyQuaternion(e)}spherizeDirection(t,A){if(A===0)return;const e=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),g=Math.sin(i)*Math.cos(e),I=Math.sin(i)*Math.sin(e),o=Math.cos(i),s=new y(g,I,o);t.lerp(s,A)}randomSpherePoint(t,A,e,i,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(i/360),C=Math.acos(2*o-1),a=$A.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,r=t.x+this.scale.x*(-a*Math.sin(C)*Math.cos(s)),B=t.y+this.scale.y*(a*Math.sin(C)*Math.sin(s)),Q=t.z+this.scale.z*(a*Math.cos(C));g.x=r,g.y=B,g.z=Q}randomCirclePoint(t,A,e,i,g){const I=Math.random(),o=2*Math.PI*I*(i/360),s=$A.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=t.x+this.scale.x*s*Math.cos(o),a=t.y+this.scale.y*s*Math.sin(o),r=t.z;g.x=C,g.y=a,g.z=r}randomConePoint(t,A,e,i,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let a=2*Math.PI*s*(g/360);switch(I){case 2:case 1:a+=Math.PI+.5,a+=this._loopTime*Math.PI*2,a%=$A.toRadians(g);break}const r=Math.acos(2*C-1),B=$A.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*e,Q=t.x+-B*Math.sin(r)*Math.cos(a),E=t.y+B*Math.sin(r)*Math.sin(a),h=t.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},n(My,"_randomQuat",new MA),n(My,"_tempVec",new y),My);let mi=zl;sA([w()],mi.prototype,"shapeType",2),sA([w()],mi.prototype,"enabled",2),sA([w()],mi.prototype,"alignToDirection",2),sA([w()],mi.prototype,"angle",2),sA([w()],mi.prototype,"arc",2),sA([w()],mi.prototype,"arcSpread",2),sA([w()],mi.prototype,"arcSpeedMultiplier",2),sA([w()],mi.prototype,"arcMode",2),sA([w(y)],mi.prototype,"boxThickness",2),sA([w(y)],mi.prototype,"position",2),sA([w(y)],mi.prototype,"rotation",2),sA([w(y)],mi.prototype,"scale",2),sA([w()],mi.prototype,"radius",2),sA([w()],mi.prototype,"radiusThickness",2),sA([w()],mi.prototype,"sphericalDirectionAmount",2),sA([w()],mi.prototype,"randomDirectionAmount",2),sA([w()],mi.prototype,"randomPositionAmount",2);class pt{constructor(){n(this,"damping"),n(this,"enabled"),n(this,"frequency"),n(this,"octaveCount"),n(this,"octaveMultiplier"),n(this,"octaveScale"),n(this,"positionAmount"),n(this,"quality"),n(this,"remap"),n(this,"remapEnabled"),n(this,"remapMultiplier"),n(this,"remapX"),n(this,"remapXMultiplier"),n(this,"remapY"),n(this,"remapYMultiplier"),n(this,"remapZ"),n(this,"remapZMultiplier"),n(this,"scrollSpeedMultiplier"),n(this,"separateAxes"),n(this,"strengthMultiplier"),n(this,"strengthX"),n(this,"strengthXMultiplier"),n(this,"strengthY"),n(this,"strengthYMultiplier"),n(this,"strengthZ"),n(this,"strengthZMultiplier"),n(this,"_noise"),n(this,"_time",0),n(this,"_temp",new y)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,i,g,I,o){if(!this.enabled)return;this._noise||(this._noise=JIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),a=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),r=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,a,r).normalize();const B=I/o;let Q=this.positionAmount.evaluate(B);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(B)*1.5),this._temp.multiplyScalar(Q)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}sA([w()],pt.prototype,"damping",2),sA([w()],pt.prototype,"enabled",2),sA([w()],pt.prototype,"frequency",2),sA([w()],pt.prototype,"octaveCount",2),sA([w()],pt.prototype,"octaveMultiplier",2),sA([w()],pt.prototype,"octaveScale",2),sA([w(Be)],pt.prototype,"positionAmount",2),sA([w()],pt.prototype,"quality",2),sA([w(Be)],pt.prototype,"remap",2),sA([w()],pt.prototype,"remapEnabled",2),sA([w()],pt.prototype,"remapMultiplier",2),sA([w(Be)],pt.prototype,"remapX",2),sA([w()],pt.prototype,"remapXMultiplier",2),sA([w(Be)],pt.prototype,"remapY",2),sA([w()],pt.prototype,"remapYMultiplier",2),sA([w(Be)],pt.prototype,"remapZ",2),sA([w()],pt.prototype,"remapZMultiplier",2),sA([w()],pt.prototype,"scrollSpeedMultiplier",2),sA([w()],pt.prototype,"separateAxes",2),sA([w()],pt.prototype,"strengthMultiplier",2),sA([w(Be)],pt.prototype,"strengthX",2),sA([w()],pt.prototype,"strengthXMultiplier",2),sA([w(Be)],pt.prototype,"strengthY",2),sA([w()],pt.prototype,"strengthYMultiplier",2),sA([w(Be)],pt.prototype,"strengthZ",2),sA([w()],pt.prototype,"strengthZMultiplier",2);class Vt{constructor(){n(this,"enabled"),n(this,"attachRibbonToTransform",!1),n(this,"colorOverLifetime"),n(this,"colorOverTrail"),n(this,"dieWithParticles",!0),n(this,"inheritParticleColor",!0),n(this,"lifetime"),n(this,"lifetimeMultiplier"),n(this,"minVertexDistance",.2),n(this,"mode",0),n(this,"ratio",1),n(this,"ribbonCount",1),n(this,"shadowBias",0),n(this,"sizeAffectsLifetime",!1),n(this,"sizeAffectsWidth",!1),n(this,"splitSubEmitterRibbons",!1),n(this,"textureMode",0),n(this,"widthOverTrail"),n(this,"widthOverTrailMultiplier"),n(this,"worldSpace",!1)}getWidth(A,e,i,g){const I=this.widthOverTrail.evaluate(i,g);return A*=I,A}getColor(A,e,i){const g=this.colorOverTrail.evaluate(i),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}sA([w()],Vt.prototype,"enabled",2),sA([w()],Vt.prototype,"attachRibbonToTransform",2),sA([w(FI)],Vt.prototype,"colorOverLifetime",2),sA([w(FI)],Vt.prototype,"colorOverTrail",2),sA([w()],Vt.prototype,"dieWithParticles",2),sA([w()],Vt.prototype,"inheritParticleColor",2),sA([w(Be)],Vt.prototype,"lifetime",2),sA([w()],Vt.prototype,"lifetimeMultiplier",2),sA([w()],Vt.prototype,"minVertexDistance",2),sA([w()],Vt.prototype,"mode",2),sA([w()],Vt.prototype,"ratio",2),sA([w()],Vt.prototype,"ribbonCount",2),sA([w()],Vt.prototype,"shadowBias",2),sA([w()],Vt.prototype,"sizeAffectsLifetime",2),sA([w()],Vt.prototype,"sizeAffectsWidth",2),sA([w()],Vt.prototype,"splitSubEmitterRibbons",2),sA([w()],Vt.prototype,"textureMode",2),sA([w(Be)],Vt.prototype,"widthOverTrail",2),sA([w()],Vt.prototype,"widthOverTrailMultiplier",2),sA([w()],Vt.prototype,"worldSpace",2);class $t{constructor(){n(this,"enabled"),n(this,"space",0),n(this,"orbitalX"),n(this,"orbitalY"),n(this,"orbitalZ"),n(this,"orbitalXMultiplier"),n(this,"orbitalYMultiplier"),n(this,"orbitalZMultiplier"),n(this,"orbitalOffsetX"),n(this,"orbitalOffsetY"),n(this,"orbitalOffsetZ"),n(this,"speedModifier"),n(this,"speedModifierMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier"),n(this,"_system"),n(this,"_temp",new y),n(this,"_temp2",new y),n(this,"_temp3",new y),n(this,"_hasOrbital",!1),n(this,"_index",0),n(this,"_orbitalMatrix",new NA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,i,g,I,o,s){var C;if(!this.enabled)return;const a=o/s,r=this.speedModifier.evaluate(a)*this.speedModifierMultiplier,B=this.x.evaluate(a),Q=this.y.evaluate(a),E=this.z.evaluate(a);if(this._temp.set(-B,Q,E),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((C=this._system)==null?void 0:C.worldPos)){const h=this._temp2.set(i.x,i.y,i.z),d=this.orbitalXMultiplier,l=this.orbitalYMultiplier,c=this.orbitalZMultiplier,u=r*Math.PI*2*10,p=Math.cos(u*d),D=Math.sin(u*d),S=Math.cos(u*l),G=Math.sin(u*l),k=Math.cos(u*c),R=Math.sin(u*c),m=h.x*(S*k)+h.y*(S*R)+h.z*-G,f=h.x*(D*G*k-p*R)+h.y*(D*G*R+p*k)+h.z*(D*S),b=h.x*(p*G*k+D*R)+h.y*(p*G*R-D*k)+h.z*(p*S),H=this._temp3.set(h.x-m,h.y-f,h.z-b);H.normalize(),H.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=H.x,g.y+=H.y,g.z+=H.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=r,g.y*=r,g.z*=r}}sA([w()],$t.prototype,"enabled",2),sA([w()],$t.prototype,"space",2),sA([w(Be)],$t.prototype,"orbitalX",2),sA([w(Be)],$t.prototype,"orbitalY",2),sA([w(Be)],$t.prototype,"orbitalZ",2),sA([w()],$t.prototype,"orbitalXMultiplier",2),sA([w()],$t.prototype,"orbitalYMultiplier",2),sA([w()],$t.prototype,"orbitalZMultiplier",2),sA([w()],$t.prototype,"orbitalOffsetX",2),sA([w()],$t.prototype,"orbitalOffsetY",2),sA([w()],$t.prototype,"orbitalOffsetZ",2),sA([w(Be)],$t.prototype,"speedModifier",2),sA([w()],$t.prototype,"speedModifierMultiplier",2),sA([w(Be)],$t.prototype,"x",2),sA([w()],$t.prototype,"xMultiplier",2),sA([w(Be)],$t.prototype,"y",2),sA([w()],$t.prototype,"yMultiplier",2),sA([w(Be)],$t.prototype,"z",2),sA([w()],$t.prototype,"zMultiplier",2);class Ug{constructor(){n(this,"animation"),n(this,"enabled"),n(this,"cycleCount"),n(this,"frameOverTime"),n(this,"frameOverTimeMultiplier"),n(this,"numTilesX"),n(this,"numTilesY"),n(this,"startFrame"),n(this,"startFrameMultiplier"),n(this,"rowMode"),n(this,"rowIndex"),n(this,"spriteCount"),n(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let i=this.frameOverTime.evaluate(A%1);return i*=this.frameOverTimeMultiplier,i*=e,i=i%e,i=Math.floor(i),i}}sA([w()],Ug.prototype,"animation",2),sA([w()],Ug.prototype,"enabled",2),sA([w()],Ug.prototype,"cycleCount",2),sA([w(Be)],Ug.prototype,"frameOverTime",2),sA([w()],Ug.prototype,"frameOverTimeMultiplier",2),sA([w()],Ug.prototype,"numTilesX",2),sA([w()],Ug.prototype,"numTilesY",2),sA([w(Be)],Ug.prototype,"startFrame",2),sA([w()],Ug.prototype,"startFrameMultiplier",2),sA([w()],Ug.prototype,"rowMode",2),sA([w()],Ug.prototype,"rowIndex",2),sA([w()],Ug.prototype,"spriteCount",2),sA([w()],Ug.prototype,"timeMode",2);class Yo{constructor(){n(this,"enabled"),n(this,"separateAxes"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}sA([w()],Yo.prototype,"enabled",2),sA([w()],Yo.prototype,"separateAxes",2),sA([w(Be)],Yo.prototype,"x",2),sA([w()],Yo.prototype,"xMultiplier",2),sA([w(Be)],Yo.prototype,"y",2),sA([w()],Yo.prototype,"yMultiplier",2),sA([w(Be)],Yo.prototype,"z",2),sA([w()],Yo.prototype,"zMultiplier",2);class ao{constructor(){n(this,"enabled"),n(this,"range"),n(this,"separateAxes"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const i=$A.lerp(this.range.x,this.range.y,e);return this.z.evaluate(i)*-1}return 0}}sA([w()],ao.prototype,"enabled",2),sA([w()],ao.prototype,"range",2),sA([w()],ao.prototype,"separateAxes",2),sA([w(Be)],ao.prototype,"x",2),sA([w()],ao.prototype,"xMultiplier",2),sA([w(Be)],ao.prototype,"y",2),sA([w()],ao.prototype,"yMultiplier",2),sA([w(Be)],ao.prototype,"z",2),sA([w()],ao.prototype,"zMultiplier",2);class Ti{constructor(){n(this,"enabled"),n(this,"dampen"),n(this,"drag"),n(this,"dragMultiplier"),n(this,"limit"),n(this,"limitMultiplier"),n(this,"separateAxes"),n(this,"limitX"),n(this,"limitXMultiplier"),n(this,"limitY"),n(this,"limitYMultiplier"),n(this,"limitZ"),n(this,"limitZMultiplier"),n(this,"multiplyDragByParticleSize",!1),n(this,"multiplyDragByParticleVelocity",!1),n(this,"space"),n(this,"_temp",new y),n(this,"_temp2",new y)}apply(A,e,i,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);const a=this.dampen*.5;e.x=$A.lerp(e.x,this._temp.x,a),e.y=$A.lerp(e.y,this._temp.y,a),e.z=$A.lerp(e.z,this._temp.z,a),i.x=$A.lerp(i.x,this._temp.x,a),i.y=$A.lerp(i.y,this._temp.y,a),i.z=$A.lerp(i.z,this._temp.z,a)}}}}sA([w()],Ti.prototype,"enabled",2),sA([w()],Ti.prototype,"dampen",2),sA([w(Be)],Ti.prototype,"drag",2),sA([w()],Ti.prototype,"dragMultiplier",2),sA([w(Be)],Ti.prototype,"limit",2),sA([w()],Ti.prototype,"limitMultiplier",2),sA([w()],Ti.prototype,"separateAxes",2),sA([w(Be)],Ti.prototype,"limitX",2),sA([w()],Ti.prototype,"limitXMultiplier",2),sA([w(Be)],Ti.prototype,"limitY",2),sA([w()],Ti.prototype,"limitYMultiplier",2),sA([w(Be)],Ti.prototype,"limitZ",2),sA([w()],Ti.prototype,"limitZMultiplier",2),sA([w()],Ti.prototype,"multiplyDragByParticleSize",2),sA([w()],Ti.prototype,"multiplyDragByParticleVelocity",2),sA([w()],Ti.prototype,"space",2);class bn{constructor(){n(this,"enabled"),n(this,"curve"),n(this,"curveMultiplier"),n(this,"mode"),n(this,"system"),n(this,"_lastWorldPosition"),n(this,"_velocity",new y),n(this,"_temp",new y)}update(A){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,i);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}sA([w()],bn.prototype,"enabled",2),sA([w(Be)],bn.prototype,"curve",2),sA([w()],bn.prototype,"curveMultiplier",2),sA([w()],bn.prototype,"mode",2);class lI{constructor(){n(this,"enabled"),n(this,"range"),n(this,"separateAxes"),n(this,"size"),n(this,"sizeMultiplier"),n(this,"x"),n(this,"xMultiplier"),n(this,"y"),n(this,"yMultiplier"),n(this,"z"),n(this,"zMultiplier")}evaluate(A,e,i,g){const I=A.length(),o=$A.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,i);return g*s}}sA([w()],lI.prototype,"enabled",2),sA([w(eA)],lI.prototype,"range",2),sA([w()],lI.prototype,"separateAxes",2),sA([w(Be)],lI.prototype,"size",2),sA([w()],lI.prototype,"sizeMultiplier",2),sA([w(Be)],lI.prototype,"x",2),sA([w()],lI.prototype,"xMultiplier",2),sA([w(Be)],lI.prototype,"y",2),sA([w()],lI.prototype,"yMultiplier",2),sA([w(Be)],lI.prototype,"z",2),sA([w()],lI.prototype,"zMultiplier",2);class CB{constructor(){n(this,"enabled"),n(this,"range"),n(this,"color")}evaluate(A,e,i){const g=A.length(),I=$A.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}sA([w()],CB.prototype,"enabled",2),sA([w(eA)],CB.prototype,"range",2),sA([w(FI)],CB.prototype,"color",2);const LIA={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
5192
5192
|
|
|
@@ -6663,8 +6663,8 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
|
|
|
6663
6663
|
display: block;
|
|
6664
6664
|
width: max(600px, 100%);
|
|
6665
6665
|
height: max(300px, 100%);
|
|
6666
|
-
font-family: 'Roboto', sans-serif;
|
|
6667
6666
|
}
|
|
6667
|
+
|
|
6668
6668
|
@media (max-width: 600px) {
|
|
6669
6669
|
:host {
|
|
6670
6670
|
width: 100%;
|