@eva/eva.js
Advanced tools
Comparing version 1.1.0-beta.2 to 1.1.0
@@ -1348,3 +1348,3 @@ 'use strict'; | ||
audio: resourceLoader.XhrLoadStrategy, | ||
video: resourceLoader.VideoLoadStrategy, | ||
video: resourceLoader.VideoLoadStrategy | ||
}; | ||
@@ -1355,3 +1355,2 @@ class Resource extends EventEmitter__default { | ||
this.timeout = 6000; | ||
this.preProcessResourceHandlers = []; | ||
this.resourcesMap = {}; | ||
@@ -1384,5 +1383,2 @@ this.makeInstanceFunctions = {}; | ||
} | ||
for (const handler of this.preProcessResourceHandlers) { | ||
handler(res); | ||
} | ||
this.resourcesMap[res.name] = res; | ||
@@ -1392,8 +1388,2 @@ this.resourcesMap[res.name].data = {}; | ||
} | ||
addPreProcessResourceHandler(handler) { | ||
this.preProcessResourceHandlers.push(handler); | ||
} | ||
removePreProcessResourceHandler(handler) { | ||
this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(handler), 1); | ||
} | ||
preload() { | ||
@@ -1577,3 +1567,2 @@ const names = Object.values(this.resourcesMap) | ||
exports.IDEProp = IDEProp; | ||
exports.STRATEGY = STRATEGY; | ||
exports.Scene = Scene; | ||
@@ -1580,0 +1569,0 @@ exports.System = System; |
@@ -16,2 +16,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),s=require("resource-loader");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o,n=r(e);class i extends n{constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}}exports.OBSERVER_TYPE=void 0,(o=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",o.REMOVE="REMOVE",o.CHANGE="CHANGE";const a={},c={},h={},m={};function p(e,t){a[e.gameObject.id]||(a[e.gameObject.id]={});const s=a[e.gameObject.id],r=e.name+"_"+t.join(",");if(s[r])return s[r];const o=t.length-1;let n=e;for(let e=0;e<o;e++)n=n[t[e]];return s[r]={property:n,key:t[o]},s[r]}function l({systemName:e,componentName:t,component:s,prop:r,type:o}){c[e].componentObserver.add({component:s,prop:r,type:o,componentName:t})}function u({obj:e,key:s,prop:r,component:o,componentName:n}){if(void 0!==e)if(s in e){if(Object.defineProperty(e,`_${s}`,{enumerable:!1,writable:!0,value:e[s]}),r.deep&&t.isObject(e[s]))for(const t of Object.keys(e[s]))u({obj:e[s],key:t,prop:r,component:o,componentName:n});Object.defineProperty(e,s,{enumerable:!0,set(i){e[`_${s}`]!==i&&(e[`_${s}`]=i,function({prop:e,component:s,componentName:r}){for(const o in h){const n=(h[o]||{})[r];n&&(n.findIndex((s=>t.isEqual(s,e)))>-1&&l({systemName:o,componentName:r,component:s,prop:e,type:exports.OBSERVER_TYPE.CHANGE}))}}({prop:r,component:o,componentName:n}))},get:()=>e[`_${s}`]})}else console.error(`prop ${s} not in component: ${n}, Can not observer`)}function d(e,t=e.name){for(const s in h){(h[s]||{})[t]&&c[s].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete a[e.gameObject.id]}(e)} | ||
***************************************************************************** */ | ||
function f(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}function y(e,t,s,r){return new(s||(s=Promise))((function(o,n){function i(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){e.done?o(e.value):new s((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function g(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}class E extends i{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(e={}){const t=["position","size","origin","anchor","scale","skew"];for(const s of t)Object.assign(this[s],e[s]);this.rotation=e.rotation||this.rotation}set parent(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(e){if(e.parent===this){const t=this.children.findIndex((t=>t===e));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)}removeChild(e){const t=this.children.findIndex((t=>t===e));t>-1&&(this.children.splice(t,1),e._parent=null)}clearChildren(){this.children.length=0}}E.componentName="Transform",f([g],E.prototype,"position",void 0),f([g],E.prototype,"size",void 0),f([g],E.prototype,"origin",void 0),f([g],E.prototype,"anchor",void 0),f([g],E.prototype,"scale",void 0),f([g],E.prototype,"skew",void 0),f([g],E.prototype,"rotation",void 0);let b=0;class T{constructor(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++b,this.addComponent(E,t)}get transform(){return this.getComponent(E)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(e){if(this._scene===e)return;const t=this._scene;if(this._scene=e,this.transform&&this.transform.children)for(const t of this.transform.children)t.gameObject.scene=e;e?e.addGameObject(this):t&&t.removeGameObject(this)}get scene(){return this._scene}addChild(e){if(e&&e.transform&&e!==this){if(!(e instanceof T))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);e.transform.parent=this.transform,e.scene=this.scene}}removeChild(e){return e instanceof T&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(e,t){const s=function(e){return e instanceof i?e.name:e instanceof Function?e.componentName:void 0}(e);if(this._componentCache[s])return;let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof i))throw new Error("addComponent recieve Component and Component Constructor");r=e}if(r.gameObject)throw new Error(`component has been added on gameObject ${r.gameObject.name}`);return r.gameObject=this,r.init&&r.init(r.__componentDefaultParams),function(e,t=e.name){for(const s in h)(h[s]||{})[t]&&c[s].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(r,r.name),function(e,t=e.name){if(t&&m[t]){if(!(e&&(s=e,s&&s.constructor&&"componentName"in s.constructor)))throw new Error("component param must be an instance of Component");var s;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const s of m[t]){const{property:r,key:o}=p(e,s.prop);u({obj:r,key:o,prop:s,component:e,componentName:t})}}}(r,r.name),this.components.push(r),this._componentCache[s]=r,r.awake&&r.awake(),r}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof i?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)}_removeComponent(e){const t=this.components.findIndex((({name:t})=>t===e));if(-1===t)return;const s=this.components.splice(t,1)[0];return delete this._componentCache[e],delete s.__componentDefaultParams,s.onDestroy&&s.onDestroy(),d(s,e),s.gameObject=void 0,s}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof i?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){Array.from(this.transform.children).forEach((({gameObject:e})=>{e.destroy()})),this.remove(),this.transform.clearChildren();for(const e in this._componentCache)this._removeComponent(e);this.components.length=0}}class O{constructor(){this.events=[]}add({component:e,prop:s,type:r,componentName:o}){r===exports.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((t=>t.component!==e)));const n=this.events.findIndex((o=>o.component===e&&t.isEqual(o.prop,s)&&o.type===r));n>-1&&this.events.splice(n,1),this.events.push({gameObject:e.gameObject,component:e,prop:s,type:r,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}}class R{constructor(e){this.started=!1,this.componentObserver=new O,this.__systemDefaultParams=e,this.name=this.constructor.systemName}destroy(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)}}const v=function(e=!0){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),_={originTime:0,playbackRate:1},S=Symbol("timeMark"),k=Symbol("playbackRate"),x=Symbol("timers"),N=Symbol("originTime"),j=Symbol("setTimer"),C=Symbol("parent");class I{constructor(e,t){e instanceof I&&(t=e,e={}),e=Object.assign({},_,e),t&&(this[C]=t);const s=e.nowtime||v;if(t)Object.defineProperty(this,"globalTime",{get:()=>t.currentTime});else{const e=s();Object.defineProperty(this,"globalTime",{get:()=>s()-e})}this[S]=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this[C]&&(this[S][0].globalEntropy=this[C].entropy),this[N]=e.originTime,this[k]=e.playbackRate,this[x]=new Map}get parent(){return this[C]}get lastTimeMark(){return this[S][this[S].length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:s=this.playbackRate}={}){const r={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:s,globalEntropy:this.globalEntropy};this[S].push(r)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){const t=this.currentTime,s=e,r=this[x];this.markTime({time:e}),Array.from(Object.entries(r)).forEach((([e,o])=>{if(!r.has(e))return;const{isEntropy:n,delay:i,heading:a}=o.time,{handler:c,startTime:h}=o;if(n)0===i&&(c(),this.clearTimeout(e));else{const r=h+i;(0===i||!1!==a&&(s-t)*i<=0||t<=r&&r<=s||t>=r&&r>=s)&&(c(),this.clearTimeout(e))}})),this.updateTimers()}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}get globalEntropy(){return this[C]?this[C].entropy:this.globalTime}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this[S].length=t+1}this.markTime({entropy:e}),this.updateTimers()}fork(e){return new I(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),s=this[S][t],{entropy:r,playbackRate:o,globalTime:n}=s;return n+(e-r)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),s=this[S][t],{localTime:r,entropy:o,playbackRate:n}=s;return n>0?r+(e-o):r-(e-o)}seekTimeMark(e){const t=this[S];let s=0,r=t.length-1;if(e<=t[s].entropy)return s;if(e>=t[r].entropy)return r;let o=Math.floor((s+r)/2);for(;o>s&&o<r;){if(e===t[o].entropy)return o;e<t[o].entropy?r=o:e>t[o].entropy&&(s=o),o=Math.floor((s+r)/2)}return s}get playbackRate(){return this[k]}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[k]=e,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}updateTimers(){Array.from(this[x].entries()).forEach((([e,t])=>{this[j](t.handler,t.time,e)}))}clearTimeout(e){const t=this[x].get(e);t&&null!=t.timerID&&(this[C]?this[C].clearTimeout(t.timerID):clearTimeout(t.timerID)),this[x].delete(e)}clearInterval(e){return this.clearTimeout(e)}clear(){const e=this[x];Array.from(Object.keys(e)).forEach((e=>{this.clearTimeout(e)}))}setTimeout(e,t={delay:0}){return this[j](e,t)}setInterval(e,t={delay:0}){const s=this,r=this[j]((function o(){s[j](o,t,r),e()}),t);return r}[j](e,t,s=Symbol("timerID")){t=function(e){return"number"==typeof e?e={delay:e}:"entropy"in e&&(e={delay:e.entropy,isEntropy:!0}),e}(t);const r=this[x].get(s);let o,n,i,a=null;r?(this.clearTimeout(s),o=t.isEntropy?(t.delay-(this.entropy-r.startEntropy))/Math.abs(this.playbackRate):(t.delay-(this.currentTime-r.startTime))/this.playbackRate,n=r.startTime,i=r.startEntropy):(o=t.delay/(t.isEntropy?Math.abs(this.playbackRate):this.playbackRate),n=this.currentTime,i=this.entropy);const c=this[C],h=c?c.setTimeout.bind(c):setTimeout,m=t.heading;return!c&&!1===m&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),h!==setTimeout&&(o={delay:o,heading:m}),a=h((()=>{this[x].delete(s),e()}),o)),this[x].set(s,{timerID:a,handler:e,time:t,startTime:n,startEntropy:i}),s}}const D={autoStart:!0,frameRate:60};class M{constructor(e){e=Object.assign({},D,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new I({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const e=this.timeline.currentTime,t=e-this._lastFrameTime;if(t>=this._frameDuration){const s=e-t%this._frameDuration,r=s-this._lastFrameTime;this._lastFrameTime=s;const o={deltaTime:r,time:e,currentTime:e,frameCount:++this._frameCount,fps:Math.round(1e3/r)};for(const e of this._tickers)"function"==typeof e&&e(o)}}add(e){this._tickers.add(e)}remove(e){this._tickers.delete(e)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}}class P extends T{constructor(e,t){super(e,t),this.gameObjects=[],this.scene=this}addGameObject(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)}removeGameObject(e){const t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}}var L;exports.LOAD_SCENE_MODE=void 0,(L=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",L.MULTI_CANVAS="MULTI_CANVAS";const A=e=>{if((e instanceof R||e instanceof i)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof i?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};function w(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const s in e[t]){let r;"string"==typeof e[t][s]&&(e[t][s]=[e[t][s]]),Array.isArray(e[t][s])&&(r={prop:e[t][s],deep:!1},e[t][s]=r),r=e[t][s],"string"==typeof r.prop&&(r.prop=[r.prop])}t.observerInfo=e}}}class $ extends n{constructor({resource:e,resourceTotal:t}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=t,0===t&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(exports.LOAD_EVENT.START,this)}onProgress(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}}var V,X;exports.LOAD_EVENT=void 0,(V=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",V.PROGRESS="progress",V.LOADED="loaded",V.COMPLETE="complete",V.ERROR="error",exports.RESOURCE_TYPE=void 0,(X=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",X.SPRITE="SPRITE",X.SPRITE_ANIMATION="SPRITE_ANIMATION",X.DRAGONBONE="DRAGONBONE",X.SPINE="SPINE",X.AUDIO="AUDIO",X.VIDEO="VIDEO",s.XhrLoadStrategy.setExtensionXhrType("json",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("tex",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("ske",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("mp3",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("wav",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("aac",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("ogg",s.XhrResponseType.Buffer);const G={png:s.ImageLoadStrategy,jpg:s.ImageLoadStrategy,jpeg:s.ImageLoadStrategy,webp:s.ImageLoadStrategy,json:s.XhrLoadStrategy,tex:s.XhrLoadStrategy,ske:s.XhrLoadStrategy,audio:s.XhrLoadStrategy,video:s.VideoLoadStrategy};const F=new class extends n{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.loaders=[],e&&"number"==typeof e.timeout&&(this.timeout=e.timeout)}loadConfig(e){this.addResource(e),this.preload()}loadSingle(e){return this.addResource([e]),this.getResource(e.name)}addResource(e){if(!e||e.length<1)console.warn("no resources");else for(const t of e)if(this.resourcesMap[t.name])console.warn(t.name+" was already added");else{for(const e of this.preProcessResourceHandlers)e(t);this.resourcesMap[t.name]=t,this.resourcesMap[t.name].data={}}}addPreProcessResourceHandler(e){this.preProcessResourceHandlers.push(e)}removePreProcessResourceHandler(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)}preload(){const e=Object.values(this.resourcesMap).filter((({preload:e})=>e)).map((({name:e})=>e));this.progress=new $({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return y(this,void 0,void 0,(function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})}))}instance(e){return y(this,void 0,void 0,(function*(){const t=this.resourcesMap[e];return this.makeInstanceFunctions[t.type]&&(yield this.makeInstanceFunctions[t.type](t))}))}destroy(e){return y(this,void 0,void 0,(function*(){yield this._destroy(e)}))}_destroy(e,t=!1){return y(this,void 0,void 0,(function*(){const s=this.resourcesMap[e];if(s){if(!t)try{this.destroyInstanceFunctions[s.type]&&(yield this.destroyInstanceFunctions[s.type](s))}catch(e){console.warn(`destroy resource ${s.name} error with '${e.message}'`)}delete this.promiseMap[e],s.data={},s.complete=!1,s.instance=void 0}}))}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:e=[],preload:t=!1}){const s=e.filter((e=>!this.promiseMap[e]&&this.resourcesMap[e]));if(!s.length)return;const r={},o=this.getLoader(t);s.forEach((e=>{this.promiseMap[e]=new Promise((t=>r[e]=t));const s=this.resourcesMap[e];for(const n in s.src){const i=s.src[n].type;"data"===i?(s.data[n]=s.src[n].data,this.doComplete(e,r[e],t)):o.add({url:s.src[n].url,name:`${s.name}_${n}`,strategy:G[i],metadata:{key:n,name:s.name,resolves:r}})}})),o.load()}doComplete(e,t,s=!1){return y(this,void 0,void 0,(function*(){const r=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{r.instance=yield this.instance(e),r.complete=!0,s&&this.progress.onProgress(o),t(r)}catch(e){r.complete=!1,s&&(o.errMsg=e.message,o.success=!1,this.progress.onProgress(o)),t({})}}))}checkAllLoaded(e){const t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((e=>t.data[e]))}getLoader(e=!1){let t=this.loaders.find((({loading:e})=>!e));return t||(t=new s.Loader,this.loaders.push(t)),e&&t.onStart.once((()=>{this.progress.onStart()})),t.onLoad.add(((t,s)=>{this.onLoad({preload:e,resource:s})})),t.onError.add(((t,s,r)=>{this.onError({errMsg:t,resource:r,preload:e})})),t.onComplete.once((()=>{t.onLoad.detachAll(),t.onError.detachAll(),t.reset()})),t}onLoad({preload:e=!1,resource:t}){return y(this,void 0,void 0,(function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t;this.resourcesMap[r].data[s]=n,this.doComplete(r,o[r],e)}))}onError({errMsg:e,preload:t=!1,resource:s}){return y(this,void 0,void 0,(function*(){const{metadata:{name:r,resolves:o}}=s;if(this._destroy(r,!0),o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}}))}},U={IDEProp:g,componentObserver:w};exports.Component=i,exports.Game=class extends n{constructor({systems:e,frameRate:t=60,autoStart:s=!0,needScene:r=!0}={}){if(super(),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[],this.ticker=new M({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)this.addSystem(t);r&&this.loadScene(new P("scene")),s&&this.start()}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const s=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],r=null==e?void 0:e.multiScenes.map((({gameObjects:e})=>e));let o=[];for(const e of r)o=[...o,...e];return[...s,...o]})(this)}addSystem(e,s){let r;if(e instanceof Function)r=new e(s);else{if(!(e instanceof R))return void console.warn("can only add System");r=e}if(!this.systems.find((e=>e.constructor===r.constructor))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){h[t.systemName]=t.observerInfo,c[t.systemName]=e}(r,r.constructor),function(e){const s=[];e instanceof Array?s.push(...e):s.push(e);for(const e of s)for(const s in e.observerInfo){m[s]=m[s]||[];const r=m[s];for(const o of e.observerInfo[s])-1===r.findIndex((e=>t.isEqual(e,o)))&&m[s].push(o)}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(`${r.constructor.systemName} awake error`,e)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}removeSystem(e){if(!e)return;let t=-1;"string"==typeof e?t=this.systems.findIndex((t=>t.name===e)):e instanceof Function?t=this.systems.findIndex((t=>t.constructor===e)):e instanceof R&&(t=this.systems.findIndex((t=>t===e))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}getSystem(e){return this.systems.find((t=>"string"==typeof e?t.name===e:t instanceof e))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((e=>{this.scene&&((e,t=[])=>{for(const s of t)for(const t of s.components)try{A(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} update error`,e)}for(const s of t)for(const t of s.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{A(t),t.update&&t.update(e)}catch(e){console.error(`${t.constructor.systemName} update error`,e)}for(const t of this.systems)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`${t.constructor.systemName} lateUpdate error`,e)}}))}triggerResume(){(e=>{for(const t of e)for(const e of t.components)try{e.onResume&&e.onResume()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onResume&&e.onResume()}catch(t){console.error(`${e.constructor.systemName}, onResume error`,t)}}triggerPause(){(e=>{for(const t of e)for(const e of t.components)try{e.onPause&&e.onPause()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onPause&&e.onPause()}catch(t){console.error(`${e.constructor.systemName}, onPause error`,t)}}destroySystems(){for(const e of[...this.systems])this.removeSystem(e);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:t=exports.LOAD_SCENE_MODE.SINGLE,params:s={}}){if(e){switch(t){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:t,params:s})}}},exports.GameObject=T,exports.IDEProp=g,exports.STRATEGY=G,exports.Scene=P,exports.System=R,exports.Transform=E,exports.componentObserver=w,exports.decorators=U,exports.resource=F; | ||
function y(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}function f(e,t,s,r){return new(s||(s=Promise))((function(o,n){function i(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){e.done?o(e.value):new s((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function g(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}class E extends i{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(e={}){const t=["position","size","origin","anchor","scale","skew"];for(const s of t)Object.assign(this[s],e[s]);this.rotation=e.rotation||this.rotation}set parent(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(e){if(e.parent===this){const t=this.children.findIndex((t=>t===e));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)}removeChild(e){const t=this.children.findIndex((t=>t===e));t>-1&&(this.children.splice(t,1),e._parent=null)}clearChildren(){this.children.length=0}}E.componentName="Transform",y([g],E.prototype,"position",void 0),y([g],E.prototype,"size",void 0),y([g],E.prototype,"origin",void 0),y([g],E.prototype,"anchor",void 0),y([g],E.prototype,"scale",void 0),y([g],E.prototype,"skew",void 0),y([g],E.prototype,"rotation",void 0);let b=0;class T{constructor(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++b,this.addComponent(E,t)}get transform(){return this.getComponent(E)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(e){if(this._scene===e)return;const t=this._scene;if(this._scene=e,this.transform&&this.transform.children)for(const t of this.transform.children)t.gameObject.scene=e;e?e.addGameObject(this):t&&t.removeGameObject(this)}get scene(){return this._scene}addChild(e){if(e&&e.transform&&e!==this){if(!(e instanceof T))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);e.transform.parent=this.transform,e.scene=this.scene}}removeChild(e){return e instanceof T&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(e,t){const s=function(e){return e instanceof i?e.name:e instanceof Function?e.componentName:void 0}(e);if(this._componentCache[s])return;let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof i))throw new Error("addComponent recieve Component and Component Constructor");r=e}if(r.gameObject)throw new Error(`component has been added on gameObject ${r.gameObject.name}`);return r.gameObject=this,r.init&&r.init(r.__componentDefaultParams),function(e,t=e.name){for(const s in h)(h[s]||{})[t]&&c[s].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(r,r.name),function(e,t=e.name){if(t&&m[t]){if(!(e&&(s=e,s&&s.constructor&&"componentName"in s.constructor)))throw new Error("component param must be an instance of Component");var s;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const s of m[t]){const{property:r,key:o}=p(e,s.prop);u({obj:r,key:o,prop:s,component:e,componentName:t})}}}(r,r.name),this.components.push(r),this._componentCache[s]=r,r.awake&&r.awake(),r}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof i?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)}_removeComponent(e){const t=this.components.findIndex((({name:t})=>t===e));if(-1===t)return;const s=this.components.splice(t,1)[0];return delete this._componentCache[e],delete s.__componentDefaultParams,s.onDestroy&&s.onDestroy(),d(s,e),s.gameObject=void 0,s}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof i?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){Array.from(this.transform.children).forEach((({gameObject:e})=>{e.destroy()})),this.remove(),this.transform.clearChildren();for(const e in this._componentCache)this._removeComponent(e);this.components.length=0}}class O{constructor(){this.events=[]}add({component:e,prop:s,type:r,componentName:o}){r===exports.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((t=>t.component!==e)));const n=this.events.findIndex((o=>o.component===e&&t.isEqual(o.prop,s)&&o.type===r));n>-1&&this.events.splice(n,1),this.events.push({gameObject:e.gameObject,component:e,prop:s,type:r,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}}class v{constructor(e){this.started=!1,this.componentObserver=new O,this.__systemDefaultParams=e,this.name=this.constructor.systemName}destroy(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)}}const _=function(e=!0){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),R={originTime:0,playbackRate:1},S=Symbol("timeMark"),k=Symbol("playbackRate"),x=Symbol("timers"),N=Symbol("originTime"),j=Symbol("setTimer"),C=Symbol("parent");class I{constructor(e,t){e instanceof I&&(t=e,e={}),e=Object.assign({},R,e),t&&(this[C]=t);const s=e.nowtime||_;if(t)Object.defineProperty(this,"globalTime",{get:()=>t.currentTime});else{const e=s();Object.defineProperty(this,"globalTime",{get:()=>s()-e})}this[S]=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this[C]&&(this[S][0].globalEntropy=this[C].entropy),this[N]=e.originTime,this[k]=e.playbackRate,this[x]=new Map}get parent(){return this[C]}get lastTimeMark(){return this[S][this[S].length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:s=this.playbackRate}={}){const r={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:s,globalEntropy:this.globalEntropy};this[S].push(r)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){const t=this.currentTime,s=e,r=this[x];this.markTime({time:e}),Array.from(Object.entries(r)).forEach((([e,o])=>{if(!r.has(e))return;const{isEntropy:n,delay:i,heading:a}=o.time,{handler:c,startTime:h}=o;if(n)0===i&&(c(),this.clearTimeout(e));else{const r=h+i;(0===i||!1!==a&&(s-t)*i<=0||t<=r&&r<=s||t>=r&&r>=s)&&(c(),this.clearTimeout(e))}})),this.updateTimers()}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}get globalEntropy(){return this[C]?this[C].entropy:this.globalTime}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this[S].length=t+1}this.markTime({entropy:e}),this.updateTimers()}fork(e){return new I(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),s=this[S][t],{entropy:r,playbackRate:o,globalTime:n}=s;return n+(e-r)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),s=this[S][t],{localTime:r,entropy:o,playbackRate:n}=s;return n>0?r+(e-o):r-(e-o)}seekTimeMark(e){const t=this[S];let s=0,r=t.length-1;if(e<=t[s].entropy)return s;if(e>=t[r].entropy)return r;let o=Math.floor((s+r)/2);for(;o>s&&o<r;){if(e===t[o].entropy)return o;e<t[o].entropy?r=o:e>t[o].entropy&&(s=o),o=Math.floor((s+r)/2)}return s}get playbackRate(){return this[k]}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[k]=e,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}updateTimers(){Array.from(this[x].entries()).forEach((([e,t])=>{this[j](t.handler,t.time,e)}))}clearTimeout(e){const t=this[x].get(e);t&&null!=t.timerID&&(this[C]?this[C].clearTimeout(t.timerID):clearTimeout(t.timerID)),this[x].delete(e)}clearInterval(e){return this.clearTimeout(e)}clear(){const e=this[x];Array.from(Object.keys(e)).forEach((e=>{this.clearTimeout(e)}))}setTimeout(e,t={delay:0}){return this[j](e,t)}setInterval(e,t={delay:0}){const s=this,r=this[j]((function o(){s[j](o,t,r),e()}),t);return r}[j](e,t,s=Symbol("timerID")){t=function(e){return"number"==typeof e?e={delay:e}:"entropy"in e&&(e={delay:e.entropy,isEntropy:!0}),e}(t);const r=this[x].get(s);let o,n,i,a=null;r?(this.clearTimeout(s),o=t.isEntropy?(t.delay-(this.entropy-r.startEntropy))/Math.abs(this.playbackRate):(t.delay-(this.currentTime-r.startTime))/this.playbackRate,n=r.startTime,i=r.startEntropy):(o=t.delay/(t.isEntropy?Math.abs(this.playbackRate):this.playbackRate),n=this.currentTime,i=this.entropy);const c=this[C],h=c?c.setTimeout.bind(c):setTimeout,m=t.heading;return!c&&!1===m&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),h!==setTimeout&&(o={delay:o,heading:m}),a=h((()=>{this[x].delete(s),e()}),o)),this[x].set(s,{timerID:a,handler:e,time:t,startTime:n,startEntropy:i}),s}}const D={autoStart:!0,frameRate:60};class M{constructor(e){e=Object.assign({},D,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new I({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const e=this.timeline.currentTime,t=e-this._lastFrameTime;if(t>=this._frameDuration){const s=e-t%this._frameDuration,r=s-this._lastFrameTime;this._lastFrameTime=s;const o={deltaTime:r,time:e,currentTime:e,frameCount:++this._frameCount,fps:Math.round(1e3/r)};for(const e of this._tickers)"function"==typeof e&&e(o)}}add(e){this._tickers.add(e)}remove(e){this._tickers.delete(e)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}}class L extends T{constructor(e,t){super(e,t),this.gameObjects=[],this.scene=this}addGameObject(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)}removeGameObject(e){const t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}}var A;exports.LOAD_SCENE_MODE=void 0,(A=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",A.MULTI_CANVAS="MULTI_CANVAS";const w=e=>{if((e instanceof v||e instanceof i)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof i?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};function P(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const s in e[t]){let r;"string"==typeof e[t][s]&&(e[t][s]=[e[t][s]]),Array.isArray(e[t][s])&&(r={prop:e[t][s],deep:!1},e[t][s]=r),r=e[t][s],"string"==typeof r.prop&&(r.prop=[r.prop])}t.observerInfo=e}}}class $ extends n{constructor({resource:e,resourceTotal:t}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=t,0===t&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(exports.LOAD_EVENT.START,this)}onProgress(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}}var V,X;exports.LOAD_EVENT=void 0,(V=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",V.PROGRESS="progress",V.LOADED="loaded",V.COMPLETE="complete",V.ERROR="error",exports.RESOURCE_TYPE=void 0,(X=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",X.SPRITE="SPRITE",X.SPRITE_ANIMATION="SPRITE_ANIMATION",X.DRAGONBONE="DRAGONBONE",X.SPINE="SPINE",X.AUDIO="AUDIO",X.VIDEO="VIDEO",s.XhrLoadStrategy.setExtensionXhrType("json",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("tex",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("ske",s.XhrResponseType.Json),s.XhrLoadStrategy.setExtensionXhrType("mp3",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("wav",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("aac",s.XhrResponseType.Buffer),s.XhrLoadStrategy.setExtensionXhrType("ogg",s.XhrResponseType.Buffer);const G={png:s.ImageLoadStrategy,jpg:s.ImageLoadStrategy,jpeg:s.ImageLoadStrategy,webp:s.ImageLoadStrategy,json:s.XhrLoadStrategy,tex:s.XhrLoadStrategy,ske:s.XhrLoadStrategy,audio:s.XhrLoadStrategy,video:s.VideoLoadStrategy};const F=new class extends n{constructor(e){super(),this.timeout=6e3,this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.loaders=[],e&&"number"==typeof e.timeout&&(this.timeout=e.timeout)}loadConfig(e){this.addResource(e),this.preload()}loadSingle(e){return this.addResource([e]),this.getResource(e.name)}addResource(e){if(!e||e.length<1)console.warn("no resources");else for(const t of e)this.resourcesMap[t.name]?console.warn(t.name+" was already added"):(this.resourcesMap[t.name]=t,this.resourcesMap[t.name].data={})}preload(){const e=Object.values(this.resourcesMap).filter((({preload:e})=>e)).map((({name:e})=>e));this.progress=new $({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return f(this,void 0,void 0,(function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})}))}instance(e){return f(this,void 0,void 0,(function*(){const t=this.resourcesMap[e];return this.makeInstanceFunctions[t.type]&&(yield this.makeInstanceFunctions[t.type](t))}))}destroy(e){return f(this,void 0,void 0,(function*(){yield this._destroy(e)}))}_destroy(e,t=!1){return f(this,void 0,void 0,(function*(){const s=this.resourcesMap[e];if(s){if(!t)try{this.destroyInstanceFunctions[s.type]&&(yield this.destroyInstanceFunctions[s.type](s))}catch(e){console.warn(`destroy resource ${s.name} error with '${e.message}'`)}delete this.promiseMap[e],s.data={},s.complete=!1,s.instance=void 0}}))}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:e=[],preload:t=!1}){const s=e.filter((e=>!this.promiseMap[e]&&this.resourcesMap[e]));if(!s.length)return;const r={},o=this.getLoader(t);s.forEach((e=>{this.promiseMap[e]=new Promise((t=>r[e]=t));const s=this.resourcesMap[e];for(const n in s.src){const i=s.src[n].type;"data"===i?(s.data[n]=s.src[n].data,this.doComplete(e,r[e],t)):o.add({url:s.src[n].url,name:`${s.name}_${n}`,strategy:G[i],metadata:{key:n,name:s.name,resolves:r}})}})),o.load()}doComplete(e,t,s=!1){return f(this,void 0,void 0,(function*(){const r=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{r.instance=yield this.instance(e),r.complete=!0,s&&this.progress.onProgress(o),t(r)}catch(e){r.complete=!1,s&&(o.errMsg=e.message,o.success=!1,this.progress.onProgress(o)),t({})}}))}checkAllLoaded(e){const t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((e=>t.data[e]))}getLoader(e=!1){let t=this.loaders.find((({loading:e})=>!e));return t||(t=new s.Loader,this.loaders.push(t)),e&&t.onStart.once((()=>{this.progress.onStart()})),t.onLoad.add(((t,s)=>{this.onLoad({preload:e,resource:s})})),t.onError.add(((t,s,r)=>{this.onError({errMsg:t,resource:r,preload:e})})),t.onComplete.once((()=>{t.onLoad.detachAll(),t.onError.detachAll(),t.reset()})),t}onLoad({preload:e=!1,resource:t}){return f(this,void 0,void 0,(function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t;this.resourcesMap[r].data[s]=n,this.doComplete(r,o[r],e)}))}onError({errMsg:e,preload:t=!1,resource:s}){return f(this,void 0,void 0,(function*(){const{metadata:{name:r,resolves:o}}=s;if(this._destroy(r,!0),o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}}))}},U={IDEProp:g,componentObserver:P};exports.Component=i,exports.Game=class extends n{constructor({systems:e,frameRate:t=60,autoStart:s=!0,needScene:r=!0}={}){if(super(),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[],this.ticker=new M({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)this.addSystem(t);r&&this.loadScene(new L("scene")),s&&this.start()}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const s=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],r=null==e?void 0:e.multiScenes.map((({gameObjects:e})=>e));let o=[];for(const e of r)o=[...o,...e];return[...s,...o]})(this)}addSystem(e,s){let r;if(e instanceof Function)r=new e(s);else{if(!(e instanceof v))return void console.warn("can only add System");r=e}if(!this.systems.find((e=>e.constructor===r.constructor))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){h[t.systemName]=t.observerInfo,c[t.systemName]=e}(r,r.constructor),function(e){const s=[];e instanceof Array?s.push(...e):s.push(e);for(const e of s)for(const s in e.observerInfo){m[s]=m[s]||[];const r=m[s];for(const o of e.observerInfo[s])-1===r.findIndex((e=>t.isEqual(e,o)))&&m[s].push(o)}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(`${r.constructor.systemName} awake error`,e)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}removeSystem(e){if(!e)return;let t=-1;"string"==typeof e?t=this.systems.findIndex((t=>t.name===e)):e instanceof Function?t=this.systems.findIndex((t=>t.constructor===e)):e instanceof v&&(t=this.systems.findIndex((t=>t===e))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}getSystem(e){return this.systems.find((t=>"string"==typeof e?t.name===e:t instanceof e))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((e=>{this.scene&&((e,t=[])=>{for(const s of t)for(const t of s.components)try{w(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} update error`,e)}for(const s of t)for(const t of s.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{w(t),t.update&&t.update(e)}catch(e){console.error(`${t.constructor.systemName} update error`,e)}for(const t of this.systems)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`${t.constructor.systemName} lateUpdate error`,e)}}))}triggerResume(){(e=>{for(const t of e)for(const e of t.components)try{e.onResume&&e.onResume()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onResume&&e.onResume()}catch(t){console.error(`${e.constructor.systemName}, onResume error`,t)}}triggerPause(){(e=>{for(const t of e)for(const e of t.components)try{e.onPause&&e.onPause()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onPause&&e.onPause()}catch(t){console.error(`${e.constructor.systemName}, onPause error`,t)}}destroySystems(){for(const e of[...this.systems])this.removeSystem(e);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:t=exports.LOAD_SCENE_MODE.SINGLE,params:s={}}){if(e){switch(t){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:t,params:s})}}},exports.GameObject=T,exports.IDEProp=g,exports.Scene=L,exports.System=v,exports.Transform=E,exports.componentObserver=P,exports.decorators=U,exports.resource=F; |
@@ -1,2 +0,1 @@ | ||
import { AbstractLoadStrategy } from 'resource-loader'; | ||
import EE from 'eventemitter3'; | ||
@@ -170,4 +169,2 @@ import EventEmitter from 'eventemitter3'; | ||
declare type PreProcessResourceHandler = (res: ResourceBase) => void; | ||
declare class Progress extends EE { | ||
@@ -195,3 +192,2 @@ progress: number; | ||
timeout: number; | ||
private preProcessResourceHandlers; | ||
private resourcesMap; | ||
@@ -209,4 +205,2 @@ private makeInstanceFunctions; | ||
addResource(resources: ResourceBase[]): void; | ||
addPreProcessResourceHandler(handler: PreProcessResourceHandler): void; | ||
removePreProcessResourceHandler(handler: PreProcessResourceHandler): void; | ||
preload(): void; | ||
@@ -288,9 +282,4 @@ getResource(name: string): Promise<ResourceStruct>; | ||
data?: any; | ||
texture?: TextureBase[] | TextureBase; | ||
} | ||
export declare const STRATEGY: { | ||
[type: string]: new (...args: any[]) => AbstractLoadStrategy; | ||
}; | ||
export declare class System { | ||
@@ -318,7 +307,2 @@ static systemName: string; | ||
declare interface TextureBase { | ||
type: string; | ||
url: string; | ||
} | ||
declare class Ticker { | ||
@@ -325,0 +309,0 @@ autoStart: boolean; |
import EventEmitter from 'eventemitter3'; | ||
import { isEqual, isObject } from 'lodash-es'; | ||
import { XhrLoadStrategy, XhrResponseType, ImageLoadStrategy, VideoLoadStrategy, Loader } from 'resource-loader'; | ||
import { XhrLoadStrategy, XhrResponseType, Loader, ImageLoadStrategy, VideoLoadStrategy } from 'resource-loader'; | ||
@@ -1340,3 +1340,3 @@ function getComponentName(component) { | ||
audio: XhrLoadStrategy, | ||
video: VideoLoadStrategy, | ||
video: VideoLoadStrategy | ||
}; | ||
@@ -1347,3 +1347,2 @@ class Resource extends EventEmitter { | ||
this.timeout = 6000; | ||
this.preProcessResourceHandlers = []; | ||
this.resourcesMap = {}; | ||
@@ -1376,5 +1375,2 @@ this.makeInstanceFunctions = {}; | ||
} | ||
for (const handler of this.preProcessResourceHandlers) { | ||
handler(res); | ||
} | ||
this.resourcesMap[res.name] = res; | ||
@@ -1384,8 +1380,2 @@ this.resourcesMap[res.name].data = {}; | ||
} | ||
addPreProcessResourceHandler(handler) { | ||
this.preProcessResourceHandlers.push(handler); | ||
} | ||
removePreProcessResourceHandler(handler) { | ||
this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(handler), 1); | ||
} | ||
preload() { | ||
@@ -1565,2 +1555,2 @@ const names = Object.values(this.resourcesMap) | ||
export { Component, Game, GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, STRATEGY, Scene, System, Transform, componentObserver, decorators, resource }; | ||
export { Component, Game, GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, Scene, System, Transform, componentObserver, decorators, resource }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EVA={})}(this,(function(t){"use strict";var e=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function s(t,e,n,s,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,s||t,i),c=r?r+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,s,i){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,o),!0;case 5:return h.fn.call(h.context,e,n,o,s),!0;case 6:return h.fn.call(h.context,e,n,o,s,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];h.fn.apply(h.context,c)}else{var p,f=h.length;for(u=0;u<f;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),l){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,n);break;case 4:h[u].fn.call(h[u].context,e,n,o);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];h[u].fn.apply(h[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return s(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return s(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var s=r?r+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||i(this,s);else{for(var c=0,u=[],h=a.length;c<h;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}));class r extends e{constructor(t){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=t}}var n="object"==typeof global&&global&&global.Object===Object&&global,o="object"==typeof self&&self&&self.Object===Object&&self,s=n||o||Function("return this")(),i=s.Symbol,a=Object.prototype,c=a.hasOwnProperty,u=a.toString,h=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p=i?i.toStringTag:void 0;function f(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":p&&p in Object(t)?function(t){var e=c.call(t,h),r=t[h];try{t[h]=void 0;var n=!0}catch(t){}var o=u.call(t);return n&&(e?t[h]=r:delete t[h]),o}(t):function(t){return l.call(t)}(t)}function d(t){return null!=t&&"object"==typeof t}var m=Array.isArray;function y(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function _(t){if(!y(t))return!1;var e=f(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var g,b=s["__core-js_shared__"],v=(g=/[^.]+$/.exec(b&&b.keys&&b.keys.IE_PROTO||""))?"Symbol(src)_1."+g:"";var E=Function.prototype.toString;function O(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var w=/^\[object .+?Constructor\]$/,T=Function.prototype,j=Object.prototype,x=T.toString,k=j.hasOwnProperty,A=RegExp("^"+x.call(k).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R(t){return!(!y(t)||(e=t,v&&v in e))&&(_(t)?A:w).test(O(t));var e}function S(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return R(r)?r:void 0}var C=S(s,"WeakMap"),L=/^(?:0|[1-9]\d*)$/;function P(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&L.test(t))&&t>-1&&t%1==0&&t<e}function D(t,e){return t===e||t!=t&&e!=e}function M(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var I=Object.prototype;function N(t){return d(t)&&"[object Arguments]"==f(t)}var B=Object.prototype,q=B.hasOwnProperty,U=B.propertyIsEnumerable,$=N(function(){return arguments}())?N:function(t){return d(t)&&q.call(t,"callee")&&!U.call(t,"callee")};var V="object"==typeof t&&t&&!t.nodeType&&t,F=V&&"object"==typeof module&&module&&!module.nodeType&&module,z=F&&F.exports===V?s.Buffer:void 0,G=(z?z.isBuffer:void 0)||function(){return!1},X={};X["[object Float32Array]"]=X["[object Float64Array]"]=X["[object Int8Array]"]=X["[object Int16Array]"]=X["[object Int32Array]"]=X["[object Uint8Array]"]=X["[object Uint8ClampedArray]"]=X["[object Uint16Array]"]=X["[object Uint32Array]"]=!0,X["[object Arguments]"]=X["[object Array]"]=X["[object ArrayBuffer]"]=X["[object Boolean]"]=X["[object DataView]"]=X["[object Date]"]=X["[object Error]"]=X["[object Function]"]=X["[object Map]"]=X["[object Number]"]=X["[object Object]"]=X["[object RegExp]"]=X["[object Set]"]=X["[object String]"]=X["[object WeakMap]"]=!1;var H,J="object"==typeof t&&t&&!t.nodeType&&t,Y=J&&"object"==typeof module&&module&&!module.nodeType&&module,Q=Y&&Y.exports===J&&n.process,W=function(){try{var t=Y&&Y.require&&Y.require("util").types;return t||Q&&Q.binding&&Q.binding("util")}catch(t){}}(),K=W&&W.isTypedArray,Z=K?(H=K,function(t){return H(t)}):function(t){return d(t)&&M(t.length)&&!!X[f(t)]},tt=Object.prototype.hasOwnProperty;function et(t,e){var r=m(t),n=!r&&$(t),o=!r&&!n&&G(t),s=!r&&!n&&!o&&Z(t),i=r||n||o||s,a=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!tt.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||P(u,c))||a.push(u);return a}var rt=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),nt=Object.prototype.hasOwnProperty;function ot(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||I))return rt(t);var e,r,n=[];for(var o in Object(t))nt.call(t,o)&&"constructor"!=o&&n.push(o);return n}function st(t){return null!=(e=t)&&M(e.length)&&!_(e)?et(t):ot(t);var e}var it=S(Object,"create");var at=Object.prototype.hasOwnProperty;var ct=Object.prototype.hasOwnProperty;function ut(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ht(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}ut.prototype.clear=function(){this.__data__=it?it(null):{},this.size=0},ut.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ut.prototype.get=function(t){var e=this.__data__;if(it){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return at.call(e,t)?e[t]:void 0},ut.prototype.has=function(t){var e=this.__data__;return it?void 0!==e[t]:ct.call(e,t)},ut.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=it&&void 0===e?"__lodash_hash_undefined__":e,this};var lt=Array.prototype.splice;function pt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}pt.prototype.clear=function(){this.__data__=[],this.size=0},pt.prototype.delete=function(t){var e=this.__data__,r=ht(e,t);return!(r<0)&&(r==e.length-1?e.pop():lt.call(e,r,1),--this.size,!0)},pt.prototype.get=function(t){var e=this.__data__,r=ht(e,t);return r<0?void 0:e[r][1]},pt.prototype.has=function(t){return ht(this.__data__,t)>-1},pt.prototype.set=function(t,e){var r=this.__data__,n=ht(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ft=S(s,"Map");function dt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function mt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}mt.prototype.clear=function(){this.size=0,this.__data__={hash:new ut,map:new(ft||pt),string:new ut}},mt.prototype.delete=function(t){var e=dt(this,t).delete(t);return this.size-=e?1:0,e},mt.prototype.get=function(t){return dt(this,t).get(t)},mt.prototype.has=function(t){return dt(this,t).has(t)},mt.prototype.set=function(t,e){var r=dt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function yt(t){var e=this.__data__=new pt(t);this.size=e.size}yt.prototype.clear=function(){this.__data__=new pt,this.size=0},yt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},yt.prototype.get=function(t){return this.__data__.get(t)},yt.prototype.has=function(t){return this.__data__.has(t)},yt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof pt){var n=r.__data__;if(!ft||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new mt(n)}return r.set(t,e),this.size=r.size,this};var _t=Object.prototype.propertyIsEnumerable,gt=Object.getOwnPropertySymbols,bt=gt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s}(gt(t),(function(e){return _t.call(t,e)})))}:function(){return[]};function vt(t){return function(t,e,r){var n=e(t);return m(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,st,bt)}var Et=S(s,"DataView"),Ot=S(s,"Promise"),wt=S(s,"Set"),Tt="[object Map]",jt="[object Promise]",xt="[object Set]",kt="[object WeakMap]",At="[object DataView]",Rt=O(Et),St=O(ft),Ct=O(Ot),Lt=O(wt),Pt=O(C),Dt=f;(Et&&Dt(new Et(new ArrayBuffer(1)))!=At||ft&&Dt(new ft)!=Tt||Ot&&Dt(Ot.resolve())!=jt||wt&&Dt(new wt)!=xt||C&&Dt(new C)!=kt)&&(Dt=function(t){var e=f(t),r="[object Object]"==e?t.constructor:void 0,n=r?O(r):"";if(n)switch(n){case Rt:return At;case St:return Tt;case Ct:return jt;case Lt:return xt;case Pt:return kt}return e});var Mt=Dt,It=s.Uint8Array;function Nt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new mt;++e<r;)this.add(t[e])}function Bt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Nt.prototype.add=Nt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Nt.prototype.has=function(t){return this.__data__.has(t)};function qt(t,e,r,n,o,s){var i=1&r,a=t.length,c=e.length;if(a!=c&&!(i&&c>a))return!1;var u=s.get(t),h=s.get(e);if(u&&h)return u==e&&h==t;var l=-1,p=!0,f=2&r?new Nt:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var d=t[l],m=e[l];if(n)var y=i?n(m,d,l,e,t,s):n(d,m,l,t,e,s);if(void 0!==y){if(y)continue;p=!1;break}if(f){if(!Bt(e,(function(t,e){if(i=e,!f.has(i)&&(d===t||o(d,t,r,n,s)))return f.push(e);var i}))){p=!1;break}}else if(d!==m&&!o(d,m,r,n,s)){p=!1;break}}return s.delete(t),s.delete(e),p}function Ut(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function $t(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Vt=i?i.prototype:void 0,Ft=Vt?Vt.valueOf:void 0;var zt=Object.prototype.hasOwnProperty;var Gt,Xt="[object Arguments]",Ht="[object Array]",Jt="[object Object]",Yt=Object.prototype.hasOwnProperty;function Qt(t,e,r,n,o,s){var i=m(t),a=m(e),c=i?Ht:Mt(t),u=a?Ht:Mt(e),h=(c=c==Xt?Jt:c)==Jt,l=(u=u==Xt?Jt:u)==Jt,p=c==u;if(p&&G(t)){if(!G(e))return!1;i=!0,h=!1}if(p&&!h)return s||(s=new yt),i||Z(t)?qt(t,e,r,n,o,s):function(t,e,r,n,o,s,i){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new It(t),new It(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return D(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ut;case"[object Set]":var c=1&n;if(a||(a=$t),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=2,i.set(t,e);var h=qt(a(t),a(e),n,o,s,i);return i.delete(t),h;case"[object Symbol]":if(Ft)return Ft.call(t)==Ft.call(e)}return!1}(t,e,c,r,n,o,s);if(!(1&r)){var f=h&&Yt.call(t,"__wrapped__"),d=l&&Yt.call(e,"__wrapped__");if(f||d){var y=f?t.value():t,_=d?e.value():e;return s||(s=new yt),o(y,_,r,n,s)}}return!!p&&(s||(s=new yt),function(t,e,r,n,o,s){var i=1&r,a=vt(t),c=a.length;if(c!=vt(e).length&&!i)return!1;for(var u=c;u--;){var h=a[u];if(!(i?h in e:zt.call(e,h)))return!1}var l=s.get(t),p=s.get(e);if(l&&p)return l==e&&p==t;var f=!0;s.set(t,e),s.set(e,t);for(var d=i;++u<c;){var m=t[h=a[u]],y=e[h];if(n)var _=i?n(y,m,h,e,t,s):n(m,y,h,t,e,s);if(!(void 0===_?m===y||o(m,y,r,n,s):_)){f=!1;break}d||(d="constructor"==h)}if(f&&!d){var g=t.constructor,b=e.constructor;g==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(f=!1)}return s.delete(t),s.delete(e),f}(t,e,r,n,o,s))}function Wt(t,e,r,n,o){return t===e||(null==t||null==e||!d(t)&&!d(e)?t!=t&&e!=e:Qt(t,e,r,n,Wt,o))}function Kt(t,e){return Wt(t,e)}t.OBSERVER_TYPE=void 0,(Gt=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",Gt.REMOVE="REMOVE",Gt.CHANGE="CHANGE";const Zt={},te={},ee={},re={};function ne(t,e){Zt[t.gameObject.id]||(Zt[t.gameObject.id]={});const r=Zt[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];const o=e.length-1;let s=t;for(let t=0;t<o;t++)s=s[e[t]];return r[n]={property:s,key:e[o]},r[n]}function oe({systemName:t,componentName:e,component:r,prop:n,type:o}){te[t].componentObserver.add({component:r,prop:n,type:o,componentName:e})}function se({obj:e,key:r,prop:n,component:o,componentName:s}){if(void 0!==e)if(r in e){if(Object.defineProperty(e,`_${r}`,{enumerable:!1,writable:!0,value:e[r]}),n.deep&&y(e[r]))for(const t of Object.keys(e[r]))se({obj:e[r],key:t,prop:n,component:o,componentName:s});Object.defineProperty(e,r,{enumerable:!0,set(i){e[`_${r}`]!==i&&(e[`_${r}`]=i,function({prop:e,component:r,componentName:n}){for(const o in ee){const s=(ee[o]||{})[n];s&&(s.findIndex((t=>Kt(t,e)))>-1&&oe({systemName:o,componentName:n,component:r,prop:e,type:t.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:o,componentName:s}))},get:()=>e[`_${r}`]})}else console.error(`prop ${r} not in component: ${s}, Can not observer`)}function ie(e,r=e.name){for(const n in ee){(ee[n]||{})[r]&&te[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.REMOVE,componentName:r})}!function(t){t.gameObject&&delete Zt[t.gameObject.id]}(e)}function ae(t,e,r,n){var o,s=arguments.length,i=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s<3?o(i):s>3?o(e,r,i):o(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i}function ce(t,e,r,n){return new(r||(r=Promise))((function(o,s){function i(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((n=n.apply(t,e||[])).next())}))}function ue(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}class he extends r{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(t={}){const e=["position","size","origin","anchor","scale","skew"];for(const r of e)Object.assign(this[r],t[r]);this.rotation=t.rotation||this.rotation}set parent(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(t){if(t.parent===this){const e=this.children.findIndex((e=>e===t));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)}removeChild(t){const e=this.children.findIndex((e=>e===t));e>-1&&(this.children.splice(e,1),t._parent=null)}clearChildren(){this.children.length=0}}he.componentName="Transform",ae([ue],he.prototype,"position",void 0),ae([ue],he.prototype,"size",void 0),ae([ue],he.prototype,"origin",void 0),ae([ue],he.prototype,"anchor",void 0),ae([ue],he.prototype,"scale",void 0),ae([ue],he.prototype,"skew",void 0),ae([ue],he.prototype,"rotation",void 0);let le=0;class pe{constructor(t,e){this._componentCache={},this.components=[],this._name=t,this.id=++le,this.addComponent(he,e)}get transform(){return this.getComponent(he)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(t){if(this._scene===t)return;const e=this._scene;if(this._scene=t,this.transform&&this.transform.children)for(const e of this.transform.children)e.gameObject.scene=t;t?t.addGameObject(this):e&&e.removeGameObject(this)}get scene(){return this._scene}addChild(t){if(t&&t.transform&&t!==this){if(!(t instanceof pe))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);t.transform.parent=this.transform,t.scene=this.scene}}removeChild(t){return t instanceof pe&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t}addComponent(e,n){const o=function(t){return t instanceof r?t.name:t instanceof Function?t.componentName:void 0}(e);if(this._componentCache[o])return;let s;if(e instanceof Function)s=new e(n);else{if(!(e instanceof r))throw new Error("addComponent recieve Component and Component Constructor");s=e}if(s.gameObject)throw new Error(`component has been added on gameObject ${s.gameObject.name}`);return s.gameObject=this,s.init&&s.init(s.__componentDefaultParams),function(e,r=e.name){for(const n in ee)(ee[n]||{})[r]&&te[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r})}(s,s.name),function(t,e=t.name){if(e&&re[e]){if(!(t&&(r=t,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of re[e]){const{property:n,key:o}=ne(t,r.prop);se({obj:n,key:o,prop:r,component:t,componentName:e})}}}(s,s.name),this.components.push(s),this._componentCache[o]=s,s.awake&&s.awake(),s}removeComponent(t){let e;if("string"==typeof t?e=t:t instanceof r?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)}_removeComponent(t){const e=this.components.findIndex((({name:e})=>e===t));if(-1===e)return;const r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),ie(r,t),r.gameObject=void 0,r}getComponent(t){let e;return"string"==typeof t?e=t:t instanceof r?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){Array.from(this.transform.children).forEach((({gameObject:t})=>{t.destroy()})),this.remove(),this.transform.clearChildren();for(const t in this._componentCache)this._removeComponent(t);this.components.length=0}}class fe{constructor(){this.events=[]}add({component:e,prop:r,type:n,componentName:o}){n===t.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((t=>t.component!==e)));const s=this.events.findIndex((t=>t.component===e&&Kt(t.prop,r)&&t.type===n));s>-1&&this.events.splice(s,1),this.events.push({gameObject:e.gameObject,component:e,prop:r,type:n,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const t=this.events;return this.events=[],t}}class de{constructor(t){this.started=!1,this.componentObserver=new fe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}destroy(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)}}const me=function(t=!0){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),ye={originTime:0,playbackRate:1},_e=Symbol("timeMark"),ge=Symbol("playbackRate"),be=Symbol("timers"),ve=Symbol("originTime"),Ee=Symbol("setTimer"),Oe=Symbol("parent");class we{constructor(t,e){t instanceof we&&(e=t,t={}),t=Object.assign({},ye,t),e&&(this[Oe]=e);const r=t.nowtime||me;if(e)Object.defineProperty(this,"globalTime",{get:()=>e.currentTime});else{const t=r();Object.defineProperty(this,"globalTime",{get:()=>r()-t})}this[_e]=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this[Oe]&&(this[_e][0].globalEntropy=this[Oe].entropy),this[ve]=t.originTime,this[ge]=t.playbackRate,this[be]=new Map}get parent(){return this[Oe]}get lastTimeMark(){return this[_e][this[_e].length-1]}markTime({time:t=this.currentTime,entropy:e=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:t,entropy:e,playbackRate:r,globalEntropy:this.globalEntropy};this[_e].push(n)}get currentTime(){const{localTime:t,globalTime:e}=this.lastTimeMark;return t+(this.globalTime-e)*this.playbackRate}set currentTime(t){const e=this.currentTime,r=t,n=this[be];this.markTime({time:t}),Array.from(Object.entries(n)).forEach((([t,o])=>{if(!n.has(t))return;const{isEntropy:s,delay:i,heading:a}=o.time,{handler:c,startTime:u}=o;if(s)0===i&&(c(),this.clearTimeout(t));else{const n=u+i;(0===i||!1!==a&&(r-e)*i<=0||e<=n&&n<=r||e>=n&&n>=r)&&(c(),this.clearTimeout(t))}})),this.updateTimers()}get entropy(){const{entropy:t,globalEntropy:e}=this.lastTimeMark;return t+Math.abs((this.globalEntropy-e)*this.playbackRate)}get globalEntropy(){return this[Oe]?this[Oe].entropy:this.globalTime}set entropy(t){if(this.entropy>t){const e=this.seekTimeMark(t);this[_e].length=e+1}this.markTime({entropy:t}),this.updateTimers()}fork(t){return new we(t,this)}seekGlobalTime(t){const e=this.seekTimeMark(t),r=this[_e][e],{entropy:n,playbackRate:o,globalTime:s}=r;return s+(t-n)/Math.abs(o)}seekLocalTime(t){const e=this.seekTimeMark(t),r=this[_e][e],{localTime:n,entropy:o,playbackRate:s}=r;return s>0?n+(t-o):n-(t-o)}seekTimeMark(t){const e=this[_e];let r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;let o=Math.floor((r+n)/2);for(;o>r&&o<n;){if(t===e[o].entropy)return o;t<e[o].entropy?n=o:t>e[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r}get playbackRate(){return this[ge]}set playbackRate(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this[ge]=t,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let t=this.parent;for(;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1}updateTimers(){Array.from(this[be].entries()).forEach((([t,e])=>{this[Ee](e.handler,e.time,t)}))}clearTimeout(t){const e=this[be].get(t);e&&null!=e.timerID&&(this[Oe]?this[Oe].clearTimeout(e.timerID):clearTimeout(e.timerID)),this[be].delete(t)}clearInterval(t){return this.clearTimeout(t)}clear(){const t=this[be];Array.from(Object.keys(t)).forEach((t=>{this.clearTimeout(t)}))}setTimeout(t,e={delay:0}){return this[Ee](t,e)}setInterval(t,e={delay:0}){const r=this,n=this[Ee]((function o(){r[Ee](o,e,n),t()}),e);return n}[Ee](t,e,r=Symbol("timerID")){e=function(t){return"number"==typeof t?t={delay:t}:"entropy"in t&&(t={delay:t.entropy,isEntropy:!0}),t}(e);const n=this[be].get(r);let o,s,i,a=null;n?(this.clearTimeout(r),o=e.isEntropy?(e.delay-(this.entropy-n.startEntropy))/Math.abs(this.playbackRate):(e.delay-(this.currentTime-n.startTime))/this.playbackRate,s=n.startTime,i=n.startEntropy):(o=e.delay/(e.isEntropy?Math.abs(this.playbackRate):this.playbackRate),s=this.currentTime,i=this.entropy);const c=this[Oe],u=c?c.setTimeout.bind(c):setTimeout,h=e.heading;return!c&&!1===h&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),u!==setTimeout&&(o={delay:o,heading:h}),a=u((()=>{this[be].delete(r),t()}),o)),this[be].set(r,{timerID:a,handler:t,time:e,startTime:s,startEntropy:i}),r}}const Te={autoStart:!0,frameRate:60};class je{constructor(t){t=Object.assign({},Te,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new we({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const t=this.timeline.currentTime,e=t-this._lastFrameTime;if(e>=this._frameDuration){const r=t-e%this._frameDuration,n=r-this._lastFrameTime;this._lastFrameTime=r;const o={deltaTime:n,time:t,currentTime:t,frameCount:++this._frameCount,fps:Math.round(1e3/n)};for(const t of this._tickers)"function"==typeof t&&t(o)}}add(t){this._tickers.add(t)}remove(t){this._tickers.delete(t)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}}class xe extends pe{constructor(t,e){super(t,e),this.gameObjects=[],this.scene=this}addGameObject(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)}removeGameObject(t){const e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}}var ke;t.LOAD_SCENE_MODE=void 0,(ke=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",ke.MULTI_CANVAS="MULTI_CANVAS";const Ae=t=>{if((t instanceof de||t instanceof r)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof r?console.error(`${t.constructor.componentName} start error`,e):console.error(`${t.constructor.systemName} start error`,e)}}};function Re(t={}){return function(e){if(!e.observerInfo){for(const e in t)for(const r in t[e]){let n;"string"==typeof t[e][r]&&(t[e][r]=[t[e][r]]),Array.isArray(t[e][r])&&(n={prop:t[e][r],deep:!1},t[e][r]=n),n=t[e][r],"string"==typeof n.prop&&(n.prop=[n.prop])}e.observerInfo=t}}}var Se=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),Ce=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Se(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Se(t,!0,e))},t.prototype.detach=function(t){var e=t;return e.owner!==this||(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._head?(this._head=e.next,null===e.next&&(this._tail=null)):e===this._tail&&(this._tail=e.prev,this._tail&&(this._tail.next=null)),e.owner=null),this},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addSignalBinding=function(t){var e=t;return this._head?(this._tail&&(this._tail.next=e),e.prev=this._tail,this._tail=e):(this._head=e,this._tail=e),e.owner=this,e},t}();var Le,Pe,De=function(t,e){if(t){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},n=r.parser[e.strictMode?"strict":"loose"].exec(t),o={},s=14;s--;)o[r.key[s]]=n[s]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o}},Me=function(t){this.config=t,this.onError=new Ce,this.onComplete=new Ce,this.onProgress=new Ce},Ie=function(t,e){return(Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function Ne(t,e){function r(){this.constructor=t}Ie(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Be(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var s=arguments[e],i=0,a=s.length;i<a;i++,o++)n[o]=s[i];return n}function qe(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),s=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Ue(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(Le||(Le={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(Pe||(Pe={}));var $e,Ve=function(t){function e(e,r){var n=t.call(this,e)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return Ne(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+qe(n));var s=document.createElement("source");s.src=n,s.type=o,this._element.appendChild(s)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents();var t=Le.Unknown;switch(this.elementType){case"audio":t=Le.Audio;break;case"video":t=Le.Video;break;default:Ue(this.elementType)}this.onComplete.dispatch(t,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error(this.elementType+" failed to load.")},e.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},e}(Me),Fe=function(t){function e(e){return t.call(this,e,"audio")||this}return Ne(e,t),e}(Ve),ze=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._element=e._createElement(),e._elementTimer=0,e}return Ne(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(Le.Image,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error("Image failed to load.")},e.prototype._onTimeout=function(){this._error("Image load timed out.")},e}(Me),Ge=function(t){function e(e){return t.call(this,e,"video")||this}return Ne(e,t),e}(Ve),Xe=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function He(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}($e||($e={}));var Je=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnAbort=e._onAbort.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._boundOnProgress=e._onProgress.bind(e),e._xhr=e._createRequest(),e._xhrType=$e.Default,e}return Ne(e,t),e.prototype.load=function(){var t=this.config,e=qe(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||$e.Default,Xe?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===$e.Json||t.xhrType===$e.Document?r.responseType=$e.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},e.prototype.abort=function(){Xe?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return Xe?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||$e.Default},e.prototype._clearEvents=function(){Xe?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},e.prototype._onLoad=function(){var t=this._xhr,e="",r=void 0===t.status?200:t.status;if(void 0!==t.responseType&&""!==t.responseType&&"text"!==t.responseType||(e=t.responseText),0===r&&(e.length>0||t.responseType===$e.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case $e.Buffer:this._complete(Le.Buffer,t.response);break;case $e.Blob:this._complete(Le.Blob,t.response);break;case $e.Document:this._parseDocument(e);break;case $e.Json:this._parseJson(e);break;case $e.Default:case $e.Text:this._complete(Le.Text,e);break;default:Ue(this._xhrType)}else this._error("["+t.status+"] "+t.statusText+": "+t.responseURL)},e.prototype._parseDocument=function(t){try{if(window.DOMParser){var e=(new DOMParser).parseFromString(t,"text/xml");this._complete(Le.Xml,e)}else{var r=document.createElement("div");r.innerHTML=t,this._complete(Le.Xml,r)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},e.prototype._parseJson=function(t){try{var e=JSON.parse(t);this._complete(Le.Json,e)}catch(t){this._error("Error trying to parse loaded json: "+t)}},e.prototype._onAbort=function(){var t=this._xhr;this._error(He(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(He(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(He(t)+" Request timed out.")},e.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},e.setExtensionXhrType=function(t,r){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(e._xhrTypeMap[t]=r)},e.ResponseType=$e,e._xhrTypeMap={xhtml:$e.Document,html:$e.Document,htm:$e.Document,xml:$e.Document,tmx:$e.Document,svg:$e.Document,tsx:$e.Document,gif:$e.Blob,png:$e.Blob,bmp:$e.Blob,jpg:$e.Blob,jpeg:$e.Blob,tif:$e.Blob,tiff:$e.Blob,webp:$e.Blob,tga:$e.Blob,json:$e.Json,text:$e.Text,txt:$e.Text,ttf:$e.Buffer,otf:$e.Buffer},e}(Me);function Ye(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var Qe=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new Ce,this.onUnsaturated=new Ce,this.onEmpty=new Ce,this.onDrain=new Ce,this.onError=new Ce,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,Ye(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,Be([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),We=function(){function t(e,r){if(this.children=[],this.onStart=new Ce,this.onProgress=new Ce,this.onComplete=new Ce,this.onAfterMiddleware=new Ce,this.data=null,this.type=Le.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=Pe.NotStarted,this.name=e,this.metadata=r.metadata,"string"!=typeof r.crossOrigin&&(r.crossOrigin=this._determineCrossOrigin(r.url)),r.strategy&&"function"!=typeof r.strategy)this._strategy=r.strategy,this._strategy.config=r;else{var n=r.strategy;n||(n=t._loadStrategyMap[qe(r.url)]),n||(n=t._defaultLoadStrategy),this._strategy=new n(r)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return t.setDefaultLoadStrategy=function(e){t._defaultLoadStrategy=e},t.setLoadStrategy=function(e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t._loadStrategyMap[e]=r)},Object.defineProperty(t.prototype,"strategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoading",{get:function(){return this._state===Pe.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isComplete",{get:function(){return this._state===Pe.Complete},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this._strategy.abort()},t.prototype.load=function(){this._state=Pe.Loading,this.onStart.dispatch(this),this._strategy.load()},t.prototype._error=function(t){this._state=Pe.Complete,this.error=t,this.onComplete.dispatch(this)},t.prototype._complete=function(t,e){this._state=Pe.Complete,this.type=t,this.data=e,this.onComplete.dispatch(this)},t.prototype._progress=function(t){this.onProgress.dispatch(this,t)},t.prototype._determineCrossOrigin=function(e,r){if(void 0===r&&(r=window.location),0===e.indexOf("data:")||0===e.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";t._tempAnchor||(t._tempAnchor=document.createElement("a")),t._tempAnchor.href=e;var n=De(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,s=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&s===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=Je,t._loadStrategyMap={gif:ze,png:ze,bmp:ze,jpg:ze,jpeg:ze,tif:ze,tiff:ze,webp:ze,tga:ze,svg:ze,"svg+xml":ze,mp3:Fe,ogg:Fe,wav:Fe,mp4:Ge,webm:Ge,mov:Ge},t}();var Ke,Ze,tr=/(#[\w-]+)?$/,er=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new Ce,this.onLoad=new Ce,this.onStart=new Ce,this.onComplete=new Ce,this.onProgress=new Ce,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new Qe(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",s=this._baseUrl,i={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,s=t.baseUrl||s,i=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!i.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,s),i.url=n;var a=new We(o,i);if(this.resources[o]=a,"function"==typeof i.onComplete&&a.onAfterMiddleware.once(i.onComplete),this.loading){var c=i.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var h=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=h;for(r=0;r<u.length;++r)u[r].progressChunk=h;a.progressChunk=h}return this._queue.push(a),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=De(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=De(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=tr.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),function(t,e,r,n){void 0===n&&(n=!1);var o=0,s=t.length;!function i(a){a||o===s?r&&r(a):n?setTimeout((function(){return e(t[o++],i)}),1):e(t[o++],i)}()}(this._middleware,(function(r,n){r.fn.call(e,t,n)}),(function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()}),!0)},t.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}();class rr extends e{constructor({resource:e,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=r,0===r&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(t.LOAD_EVENT.START,this)}onProgress(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(t.LOAD_EVENT.LOADED,this,e):this.resource.emit(t.LOAD_EVENT.ERROR,this,e),this.resource.emit(t.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}}t.LOAD_EVENT=void 0,(Ke=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",Ke.PROGRESS="progress",Ke.LOADED="loaded",Ke.COMPLETE="complete",Ke.ERROR="error",t.RESOURCE_TYPE=void 0,(Ze=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",Ze.SPRITE="SPRITE",Ze.SPRITE_ANIMATION="SPRITE_ANIMATION",Ze.DRAGONBONE="DRAGONBONE",Ze.SPINE="SPINE",Ze.AUDIO="AUDIO",Ze.VIDEO="VIDEO",Je.setExtensionXhrType("json",$e.Json),Je.setExtensionXhrType("tex",$e.Json),Je.setExtensionXhrType("ske",$e.Json),Je.setExtensionXhrType("mp3",$e.Buffer),Je.setExtensionXhrType("wav",$e.Buffer),Je.setExtensionXhrType("aac",$e.Buffer),Je.setExtensionXhrType("ogg",$e.Buffer);const nr={png:ze,jpg:ze,jpeg:ze,webp:ze,json:Je,tex:Je,ske:Je,audio:Je,video:Ge};const or=new class extends e{constructor(t){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.loaders=[],t&&"number"==typeof t.timeout&&(this.timeout=t.timeout)}loadConfig(t){this.addResource(t),this.preload()}loadSingle(t){return this.addResource([t]),this.getResource(t.name)}addResource(t){if(!t||t.length<1)console.warn("no resources");else for(const e of t)if(this.resourcesMap[e.name])console.warn(e.name+" was already added");else{for(const t of this.preProcessResourceHandlers)t(e);this.resourcesMap[e.name]=e,this.resourcesMap[e.name].data={}}}addPreProcessResourceHandler(t){this.preProcessResourceHandlers.push(t)}removePreProcessResourceHandler(t){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(t),1)}preload(){const t=Object.values(this.resourcesMap).filter((({preload:t})=>t)).map((({name:t})=>t));this.progress=new rr({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})}getResource(t){return ce(this,void 0,void 0,(function*(){return this.loadResource({names:[t]}),this.promiseMap[t]||Promise.resolve({})}))}instance(t){return ce(this,void 0,void 0,(function*(){const e=this.resourcesMap[t];return this.makeInstanceFunctions[e.type]&&(yield this.makeInstanceFunctions[e.type](e))}))}destroy(t){return ce(this,void 0,void 0,(function*(){yield this._destroy(t)}))}_destroy(t,e=!1){return ce(this,void 0,void 0,(function*(){const r=this.resourcesMap[t];if(r){if(!e)try{this.destroyInstanceFunctions[r.type]&&(yield this.destroyInstanceFunctions[r.type](r))}catch(t){console.warn(`destroy resource ${r.name} error with '${t.message}'`)}delete this.promiseMap[t],r.data={},r.complete=!1,r.instance=void 0}}))}registerInstance(t,e){this.makeInstanceFunctions[t]=e}registerDestroy(t,e){this.destroyInstanceFunctions[t]=e}loadResource({names:t=[],preload:e=!1}){const r=t.filter((t=>!this.promiseMap[t]&&this.resourcesMap[t]));if(!r.length)return;const n={},o=this.getLoader(e);r.forEach((t=>{this.promiseMap[t]=new Promise((e=>n[t]=e));const r=this.resourcesMap[t];for(const s in r.src){const i=r.src[s].type;"data"===i?(r.data[s]=r.src[s].data,this.doComplete(t,n[t],e)):o.add({url:r.src[s].url,name:`${r.name}_${s}`,strategy:nr[i],metadata:{key:s,name:r.name,resolves:n}})}})),o.load()}doComplete(t,e,r=!1){return ce(this,void 0,void 0,(function*(){const n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0};if(this.checkAllLoaded(t))try{n.instance=yield this.instance(t),n.complete=!0,r&&this.progress.onProgress(o),e(n)}catch(t){n.complete=!1,r&&(o.errMsg=t.message,o.success=!1,this.progress.onProgress(o)),e({})}}))}checkAllLoaded(t){const e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((t=>e.data[t]))}getLoader(t=!1){let e=this.loaders.find((({loading:t})=>!t));return e||(e=new er,this.loaders.push(e)),t&&e.onStart.once((()=>{this.progress.onStart()})),e.onLoad.add(((e,r)=>{this.onLoad({preload:t,resource:r})})),e.onError.add(((e,r,n)=>{this.onError({errMsg:e,resource:n,preload:t})})),e.onComplete.once((()=>{e.onLoad.detachAll(),e.onError.detachAll(),e.reset()})),e}onLoad({preload:t=!1,resource:e}){return ce(this,void 0,void 0,(function*(){const{metadata:{key:r,name:n,resolves:o},data:s}=e;this.resourcesMap[n].data[r]=s,this.doComplete(n,o[n],t)}))}onError({errMsg:t,preload:e=!1,resource:r}){return ce(this,void 0,void 0,(function*(){const{metadata:{name:n,resolves:o}}=r;if(this._destroy(n,!0),o[n]({}),e){const e={name:n,resource:this.resourcesMap[n],success:!1,errMsg:t};this.progress.onProgress(e)}}))}},sr={IDEProp:ue,componentObserver:Re};t.Component=r,t.Game=class extends e{constructor({systems:t,frameRate:e=60,autoStart:r=!0,needScene:n=!0}={}){if(super(),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[],this.ticker=new je({autoStart:!1,frameRate:e}),this.initTicker(),t&&t.length)for(const e of t)this.addSystem(e);n&&this.loadScene(new xe("scene")),r&&this.start()}get scene(){return this._scene}set scene(t){this._scene=t}get gameObjects(){return(t=>{var e;const r=(null===(e=null==t?void 0:t.scene)||void 0===e?void 0:e.gameObjects)||[],n=null==t?void 0:t.multiScenes.map((({gameObjects:t})=>t));let o=[];for(const t of n)o=[...o,...t];return[...r,...o]})(this)}addSystem(t,e){let r;if(t instanceof Function)r=new t(e);else{if(!(t instanceof de))return void console.warn("can only add System");r=t}if(!this.systems.find((t=>t.constructor===r.constructor))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(t,e){ee[e.systemName]=e.observerInfo,te[e.systemName]=t}(r,r.constructor),function(t){const e=[];t instanceof Array?e.push(...t):e.push(t);for(const t of e)for(const e in t.observerInfo){re[e]=re[e]||[];const r=re[e];for(const n of t.observerInfo[e])-1===r.findIndex((t=>Kt(t,n)))&&re[e].push(n)}}(r.constructor);try{r.awake&&r.awake()}catch(t){console.error(`${r.constructor.systemName} awake error`,t)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}removeSystem(t){if(!t)return;let e=-1;"string"==typeof t?e=this.systems.findIndex((e=>e.name===t)):t instanceof Function?e=this.systems.findIndex((e=>e.constructor===t)):t instanceof de&&(e=this.systems.findIndex((e=>e===t))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}getSystem(t){return this.systems.find((e=>"string"==typeof t?e.name===t:e instanceof t))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((t=>{this.scene&&((t,e=[])=>{for(const r of e)for(const e of r.components)try{Ae(e),e.update&&e.update(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} update error`,t)}for(const r of e)for(const e of r.components)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} lateUpdate error`,t)}})(t,this.gameObjects);for(const e of this.systems)try{Ae(e),e.update&&e.update(t)}catch(t){console.error(`${e.constructor.systemName} update error`,t)}for(const e of this.systems)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`${e.constructor.systemName} lateUpdate error`,t)}}))}triggerResume(){(t=>{for(const e of t)for(const t of e.components)try{t.onResume&&t.onResume()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onResume&&t.onResume()}catch(e){console.error(`${t.constructor.systemName}, onResume error`,e)}}triggerPause(){(t=>{for(const e of t)for(const t of e.components)try{t.onPause&&t.onPause()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onPause&&t.onPause()}catch(e){console.error(`${t.constructor.systemName}, onPause error`,e)}}destroySystems(){for(const t of[...this.systems])this.removeSystem(t);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:r=t.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(e){switch(r){case t.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:r,params:n})}}},t.GameObject=pe,t.IDEProp=ue,t.STRATEGY=nr,t.Scene=xe,t.System=de,t.Transform=he,t.componentObserver=Re,t.decorators=sr,t.resource=or,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EVA={})}(this,(function(t){"use strict";var e=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function s(t,e,n,s,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,s||t,i),c=r?r+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function i(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,s,i){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,o),!0;case 5:return h.fn.call(h.context,e,n,o,s),!0;case 6:return h.fn.call(h.context,e,n,o,s,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];h.fn.apply(h.context,c)}else{var p,f=h.length;for(u=0;u<f;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),l){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,n);break;case 4:h[u].fn.call(h[u].context,e,n,o);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];h[u].fn.apply(h[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return s(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return s(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var s=r?r+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||i(this,s);else{for(var c=0,u=[],h=a.length;c<h;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}));class r extends e{constructor(t){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=t}}var n="object"==typeof global&&global&&global.Object===Object&&global,o="object"==typeof self&&self&&self.Object===Object&&self,s=n||o||Function("return this")(),i=s.Symbol,a=Object.prototype,c=a.hasOwnProperty,u=a.toString,h=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p=i?i.toStringTag:void 0;function f(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":p&&p in Object(t)?function(t){var e=c.call(t,h),r=t[h];try{t[h]=void 0;var n=!0}catch(t){}var o=u.call(t);return n&&(e?t[h]=r:delete t[h]),o}(t):function(t){return l.call(t)}(t)}function d(t){return null!=t&&"object"==typeof t}var m=Array.isArray;function y(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function _(t){if(!y(t))return!1;var e=f(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var g,b=s["__core-js_shared__"],v=(g=/[^.]+$/.exec(b&&b.keys&&b.keys.IE_PROTO||""))?"Symbol(src)_1."+g:"";var E=Function.prototype.toString;function O(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var w=/^\[object .+?Constructor\]$/,T=Function.prototype,j=Object.prototype,k=T.toString,x=j.hasOwnProperty,A=RegExp("^"+k.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function S(t){return!(!y(t)||(e=t,v&&v in e))&&(_(t)?A:w).test(O(t));var e}function C(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return S(r)?r:void 0}var R=C(s,"WeakMap"),L=/^(?:0|[1-9]\d*)$/;function P(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&L.test(t))&&t>-1&&t%1==0&&t<e}function D(t,e){return t===e||t!=t&&e!=e}function M(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var I=Object.prototype;function N(t){return d(t)&&"[object Arguments]"==f(t)}var B=Object.prototype,q=B.hasOwnProperty,U=B.propertyIsEnumerable,$=N(function(){return arguments}())?N:function(t){return d(t)&&q.call(t,"callee")&&!U.call(t,"callee")};var V="object"==typeof t&&t&&!t.nodeType&&t,F=V&&"object"==typeof module&&module&&!module.nodeType&&module,z=F&&F.exports===V?s.Buffer:void 0,G=(z?z.isBuffer:void 0)||function(){return!1},X={};X["[object Float32Array]"]=X["[object Float64Array]"]=X["[object Int8Array]"]=X["[object Int16Array]"]=X["[object Int32Array]"]=X["[object Uint8Array]"]=X["[object Uint8ClampedArray]"]=X["[object Uint16Array]"]=X["[object Uint32Array]"]=!0,X["[object Arguments]"]=X["[object Array]"]=X["[object ArrayBuffer]"]=X["[object Boolean]"]=X["[object DataView]"]=X["[object Date]"]=X["[object Error]"]=X["[object Function]"]=X["[object Map]"]=X["[object Number]"]=X["[object Object]"]=X["[object RegExp]"]=X["[object Set]"]=X["[object String]"]=X["[object WeakMap]"]=!1;var J,Y="object"==typeof t&&t&&!t.nodeType&&t,H=Y&&"object"==typeof module&&module&&!module.nodeType&&module,Q=H&&H.exports===Y&&n.process,W=function(){try{var t=H&&H.require&&H.require("util").types;return t||Q&&Q.binding&&Q.binding("util")}catch(t){}}(),K=W&&W.isTypedArray,Z=K?(J=K,function(t){return J(t)}):function(t){return d(t)&&M(t.length)&&!!X[f(t)]},tt=Object.prototype.hasOwnProperty;function et(t,e){var r=m(t),n=!r&&$(t),o=!r&&!n&&G(t),s=!r&&!n&&!o&&Z(t),i=r||n||o||s,a=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!tt.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||P(u,c))||a.push(u);return a}var rt=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),nt=Object.prototype.hasOwnProperty;function ot(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||I))return rt(t);var e,r,n=[];for(var o in Object(t))nt.call(t,o)&&"constructor"!=o&&n.push(o);return n}function st(t){return null!=(e=t)&&M(e.length)&&!_(e)?et(t):ot(t);var e}var it=C(Object,"create");var at=Object.prototype.hasOwnProperty;var ct=Object.prototype.hasOwnProperty;function ut(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ht(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}ut.prototype.clear=function(){this.__data__=it?it(null):{},this.size=0},ut.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ut.prototype.get=function(t){var e=this.__data__;if(it){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return at.call(e,t)?e[t]:void 0},ut.prototype.has=function(t){var e=this.__data__;return it?void 0!==e[t]:ct.call(e,t)},ut.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=it&&void 0===e?"__lodash_hash_undefined__":e,this};var lt=Array.prototype.splice;function pt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}pt.prototype.clear=function(){this.__data__=[],this.size=0},pt.prototype.delete=function(t){var e=this.__data__,r=ht(e,t);return!(r<0)&&(r==e.length-1?e.pop():lt.call(e,r,1),--this.size,!0)},pt.prototype.get=function(t){var e=this.__data__,r=ht(e,t);return r<0?void 0:e[r][1]},pt.prototype.has=function(t){return ht(this.__data__,t)>-1},pt.prototype.set=function(t,e){var r=this.__data__,n=ht(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ft=C(s,"Map");function dt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function mt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}mt.prototype.clear=function(){this.size=0,this.__data__={hash:new ut,map:new(ft||pt),string:new ut}},mt.prototype.delete=function(t){var e=dt(this,t).delete(t);return this.size-=e?1:0,e},mt.prototype.get=function(t){return dt(this,t).get(t)},mt.prototype.has=function(t){return dt(this,t).has(t)},mt.prototype.set=function(t,e){var r=dt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function yt(t){var e=this.__data__=new pt(t);this.size=e.size}yt.prototype.clear=function(){this.__data__=new pt,this.size=0},yt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},yt.prototype.get=function(t){return this.__data__.get(t)},yt.prototype.has=function(t){return this.__data__.has(t)},yt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof pt){var n=r.__data__;if(!ft||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new mt(n)}return r.set(t,e),this.size=r.size,this};var _t=Object.prototype.propertyIsEnumerable,gt=Object.getOwnPropertySymbols,bt=gt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s}(gt(t),(function(e){return _t.call(t,e)})))}:function(){return[]};function vt(t){return function(t,e,r){var n=e(t);return m(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,st,bt)}var Et=C(s,"DataView"),Ot=C(s,"Promise"),wt=C(s,"Set"),Tt="[object Map]",jt="[object Promise]",kt="[object Set]",xt="[object WeakMap]",At="[object DataView]",St=O(Et),Ct=O(ft),Rt=O(Ot),Lt=O(wt),Pt=O(R),Dt=f;(Et&&Dt(new Et(new ArrayBuffer(1)))!=At||ft&&Dt(new ft)!=Tt||Ot&&Dt(Ot.resolve())!=jt||wt&&Dt(new wt)!=kt||R&&Dt(new R)!=xt)&&(Dt=function(t){var e=f(t),r="[object Object]"==e?t.constructor:void 0,n=r?O(r):"";if(n)switch(n){case St:return At;case Ct:return Tt;case Rt:return jt;case Lt:return kt;case Pt:return xt}return e});var Mt=Dt,It=s.Uint8Array;function Nt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new mt;++e<r;)this.add(t[e])}function Bt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Nt.prototype.add=Nt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Nt.prototype.has=function(t){return this.__data__.has(t)};function qt(t,e,r,n,o,s){var i=1&r,a=t.length,c=e.length;if(a!=c&&!(i&&c>a))return!1;var u=s.get(t),h=s.get(e);if(u&&h)return u==e&&h==t;var l=-1,p=!0,f=2&r?new Nt:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var d=t[l],m=e[l];if(n)var y=i?n(m,d,l,e,t,s):n(d,m,l,t,e,s);if(void 0!==y){if(y)continue;p=!1;break}if(f){if(!Bt(e,(function(t,e){if(i=e,!f.has(i)&&(d===t||o(d,t,r,n,s)))return f.push(e);var i}))){p=!1;break}}else if(d!==m&&!o(d,m,r,n,s)){p=!1;break}}return s.delete(t),s.delete(e),p}function Ut(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function $t(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Vt=i?i.prototype:void 0,Ft=Vt?Vt.valueOf:void 0;var zt=Object.prototype.hasOwnProperty;var Gt,Xt="[object Arguments]",Jt="[object Array]",Yt="[object Object]",Ht=Object.prototype.hasOwnProperty;function Qt(t,e,r,n,o,s){var i=m(t),a=m(e),c=i?Jt:Mt(t),u=a?Jt:Mt(e),h=(c=c==Xt?Yt:c)==Yt,l=(u=u==Xt?Yt:u)==Yt,p=c==u;if(p&&G(t)){if(!G(e))return!1;i=!0,h=!1}if(p&&!h)return s||(s=new yt),i||Z(t)?qt(t,e,r,n,o,s):function(t,e,r,n,o,s,i){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new It(t),new It(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return D(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ut;case"[object Set]":var c=1&n;if(a||(a=$t),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=2,i.set(t,e);var h=qt(a(t),a(e),n,o,s,i);return i.delete(t),h;case"[object Symbol]":if(Ft)return Ft.call(t)==Ft.call(e)}return!1}(t,e,c,r,n,o,s);if(!(1&r)){var f=h&&Ht.call(t,"__wrapped__"),d=l&&Ht.call(e,"__wrapped__");if(f||d){var y=f?t.value():t,_=d?e.value():e;return s||(s=new yt),o(y,_,r,n,s)}}return!!p&&(s||(s=new yt),function(t,e,r,n,o,s){var i=1&r,a=vt(t),c=a.length;if(c!=vt(e).length&&!i)return!1;for(var u=c;u--;){var h=a[u];if(!(i?h in e:zt.call(e,h)))return!1}var l=s.get(t),p=s.get(e);if(l&&p)return l==e&&p==t;var f=!0;s.set(t,e),s.set(e,t);for(var d=i;++u<c;){var m=t[h=a[u]],y=e[h];if(n)var _=i?n(y,m,h,e,t,s):n(m,y,h,t,e,s);if(!(void 0===_?m===y||o(m,y,r,n,s):_)){f=!1;break}d||(d="constructor"==h)}if(f&&!d){var g=t.constructor,b=e.constructor;g==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(f=!1)}return s.delete(t),s.delete(e),f}(t,e,r,n,o,s))}function Wt(t,e,r,n,o){return t===e||(null==t||null==e||!d(t)&&!d(e)?t!=t&&e!=e:Qt(t,e,r,n,Wt,o))}function Kt(t,e){return Wt(t,e)}t.OBSERVER_TYPE=void 0,(Gt=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",Gt.REMOVE="REMOVE",Gt.CHANGE="CHANGE";const Zt={},te={},ee={},re={};function ne(t,e){Zt[t.gameObject.id]||(Zt[t.gameObject.id]={});const r=Zt[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];const o=e.length-1;let s=t;for(let t=0;t<o;t++)s=s[e[t]];return r[n]={property:s,key:e[o]},r[n]}function oe({systemName:t,componentName:e,component:r,prop:n,type:o}){te[t].componentObserver.add({component:r,prop:n,type:o,componentName:e})}function se({obj:e,key:r,prop:n,component:o,componentName:s}){if(void 0!==e)if(r in e){if(Object.defineProperty(e,`_${r}`,{enumerable:!1,writable:!0,value:e[r]}),n.deep&&y(e[r]))for(const t of Object.keys(e[r]))se({obj:e[r],key:t,prop:n,component:o,componentName:s});Object.defineProperty(e,r,{enumerable:!0,set(i){e[`_${r}`]!==i&&(e[`_${r}`]=i,function({prop:e,component:r,componentName:n}){for(const o in ee){const s=(ee[o]||{})[n];s&&(s.findIndex((t=>Kt(t,e)))>-1&&oe({systemName:o,componentName:n,component:r,prop:e,type:t.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:o,componentName:s}))},get:()=>e[`_${r}`]})}else console.error(`prop ${r} not in component: ${s}, Can not observer`)}function ie(e,r=e.name){for(const n in ee){(ee[n]||{})[r]&&te[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.REMOVE,componentName:r})}!function(t){t.gameObject&&delete Zt[t.gameObject.id]}(e)}function ae(t,e,r,n){var o,s=arguments.length,i=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s<3?o(i):s>3?o(e,r,i):o(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i}function ce(t,e,r,n){return new(r||(r=Promise))((function(o,s){function i(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((n=n.apply(t,e||[])).next())}))}function ue(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}class he extends r{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(t={}){const e=["position","size","origin","anchor","scale","skew"];for(const r of e)Object.assign(this[r],t[r]);this.rotation=t.rotation||this.rotation}set parent(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(t){if(t.parent===this){const e=this.children.findIndex((e=>e===t));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)}removeChild(t){const e=this.children.findIndex((e=>e===t));e>-1&&(this.children.splice(e,1),t._parent=null)}clearChildren(){this.children.length=0}}he.componentName="Transform",ae([ue],he.prototype,"position",void 0),ae([ue],he.prototype,"size",void 0),ae([ue],he.prototype,"origin",void 0),ae([ue],he.prototype,"anchor",void 0),ae([ue],he.prototype,"scale",void 0),ae([ue],he.prototype,"skew",void 0),ae([ue],he.prototype,"rotation",void 0);let le=0;class pe{constructor(t,e){this._componentCache={},this.components=[],this._name=t,this.id=++le,this.addComponent(he,e)}get transform(){return this.getComponent(he)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(t){if(this._scene===t)return;const e=this._scene;if(this._scene=t,this.transform&&this.transform.children)for(const e of this.transform.children)e.gameObject.scene=t;t?t.addGameObject(this):e&&e.removeGameObject(this)}get scene(){return this._scene}addChild(t){if(t&&t.transform&&t!==this){if(!(t instanceof pe))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);t.transform.parent=this.transform,t.scene=this.scene}}removeChild(t){return t instanceof pe&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t}addComponent(e,n){const o=function(t){return t instanceof r?t.name:t instanceof Function?t.componentName:void 0}(e);if(this._componentCache[o])return;let s;if(e instanceof Function)s=new e(n);else{if(!(e instanceof r))throw new Error("addComponent recieve Component and Component Constructor");s=e}if(s.gameObject)throw new Error(`component has been added on gameObject ${s.gameObject.name}`);return s.gameObject=this,s.init&&s.init(s.__componentDefaultParams),function(e,r=e.name){for(const n in ee)(ee[n]||{})[r]&&te[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r})}(s,s.name),function(t,e=t.name){if(e&&re[e]){if(!(t&&(r=t,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of re[e]){const{property:n,key:o}=ne(t,r.prop);se({obj:n,key:o,prop:r,component:t,componentName:e})}}}(s,s.name),this.components.push(s),this._componentCache[o]=s,s.awake&&s.awake(),s}removeComponent(t){let e;if("string"==typeof t?e=t:t instanceof r?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)}_removeComponent(t){const e=this.components.findIndex((({name:e})=>e===t));if(-1===e)return;const r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),ie(r,t),r.gameObject=void 0,r}getComponent(t){let e;return"string"==typeof t?e=t:t instanceof r?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){Array.from(this.transform.children).forEach((({gameObject:t})=>{t.destroy()})),this.remove(),this.transform.clearChildren();for(const t in this._componentCache)this._removeComponent(t);this.components.length=0}}class fe{constructor(){this.events=[]}add({component:e,prop:r,type:n,componentName:o}){n===t.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((t=>t.component!==e)));const s=this.events.findIndex((t=>t.component===e&&Kt(t.prop,r)&&t.type===n));s>-1&&this.events.splice(s,1),this.events.push({gameObject:e.gameObject,component:e,prop:r,type:n,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const t=this.events;return this.events=[],t}}class de{constructor(t){this.started=!1,this.componentObserver=new fe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}destroy(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)}}const me=function(t=!0){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),ye={originTime:0,playbackRate:1},_e=Symbol("timeMark"),ge=Symbol("playbackRate"),be=Symbol("timers"),ve=Symbol("originTime"),Ee=Symbol("setTimer"),Oe=Symbol("parent");class we{constructor(t,e){t instanceof we&&(e=t,t={}),t=Object.assign({},ye,t),e&&(this[Oe]=e);const r=t.nowtime||me;if(e)Object.defineProperty(this,"globalTime",{get:()=>e.currentTime});else{const t=r();Object.defineProperty(this,"globalTime",{get:()=>r()-t})}this[_e]=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this[Oe]&&(this[_e][0].globalEntropy=this[Oe].entropy),this[ve]=t.originTime,this[ge]=t.playbackRate,this[be]=new Map}get parent(){return this[Oe]}get lastTimeMark(){return this[_e][this[_e].length-1]}markTime({time:t=this.currentTime,entropy:e=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:t,entropy:e,playbackRate:r,globalEntropy:this.globalEntropy};this[_e].push(n)}get currentTime(){const{localTime:t,globalTime:e}=this.lastTimeMark;return t+(this.globalTime-e)*this.playbackRate}set currentTime(t){const e=this.currentTime,r=t,n=this[be];this.markTime({time:t}),Array.from(Object.entries(n)).forEach((([t,o])=>{if(!n.has(t))return;const{isEntropy:s,delay:i,heading:a}=o.time,{handler:c,startTime:u}=o;if(s)0===i&&(c(),this.clearTimeout(t));else{const n=u+i;(0===i||!1!==a&&(r-e)*i<=0||e<=n&&n<=r||e>=n&&n>=r)&&(c(),this.clearTimeout(t))}})),this.updateTimers()}get entropy(){const{entropy:t,globalEntropy:e}=this.lastTimeMark;return t+Math.abs((this.globalEntropy-e)*this.playbackRate)}get globalEntropy(){return this[Oe]?this[Oe].entropy:this.globalTime}set entropy(t){if(this.entropy>t){const e=this.seekTimeMark(t);this[_e].length=e+1}this.markTime({entropy:t}),this.updateTimers()}fork(t){return new we(t,this)}seekGlobalTime(t){const e=this.seekTimeMark(t),r=this[_e][e],{entropy:n,playbackRate:o,globalTime:s}=r;return s+(t-n)/Math.abs(o)}seekLocalTime(t){const e=this.seekTimeMark(t),r=this[_e][e],{localTime:n,entropy:o,playbackRate:s}=r;return s>0?n+(t-o):n-(t-o)}seekTimeMark(t){const e=this[_e];let r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;let o=Math.floor((r+n)/2);for(;o>r&&o<n;){if(t===e[o].entropy)return o;t<e[o].entropy?n=o:t>e[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r}get playbackRate(){return this[ge]}set playbackRate(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this[ge]=t,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let t=this.parent;for(;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1}updateTimers(){Array.from(this[be].entries()).forEach((([t,e])=>{this[Ee](e.handler,e.time,t)}))}clearTimeout(t){const e=this[be].get(t);e&&null!=e.timerID&&(this[Oe]?this[Oe].clearTimeout(e.timerID):clearTimeout(e.timerID)),this[be].delete(t)}clearInterval(t){return this.clearTimeout(t)}clear(){const t=this[be];Array.from(Object.keys(t)).forEach((t=>{this.clearTimeout(t)}))}setTimeout(t,e={delay:0}){return this[Ee](t,e)}setInterval(t,e={delay:0}){const r=this,n=this[Ee]((function o(){r[Ee](o,e,n),t()}),e);return n}[Ee](t,e,r=Symbol("timerID")){e=function(t){return"number"==typeof t?t={delay:t}:"entropy"in t&&(t={delay:t.entropy,isEntropy:!0}),t}(e);const n=this[be].get(r);let o,s,i,a=null;n?(this.clearTimeout(r),o=e.isEntropy?(e.delay-(this.entropy-n.startEntropy))/Math.abs(this.playbackRate):(e.delay-(this.currentTime-n.startTime))/this.playbackRate,s=n.startTime,i=n.startEntropy):(o=e.delay/(e.isEntropy?Math.abs(this.playbackRate):this.playbackRate),s=this.currentTime,i=this.entropy);const c=this[Oe],u=c?c.setTimeout.bind(c):setTimeout,h=e.heading;return!c&&!1===h&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),u!==setTimeout&&(o={delay:o,heading:h}),a=u((()=>{this[be].delete(r),t()}),o)),this[be].set(r,{timerID:a,handler:t,time:e,startTime:s,startEntropy:i}),r}}const Te={autoStart:!0,frameRate:60};class je{constructor(t){t=Object.assign({},Te,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new we({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const t=this.timeline.currentTime,e=t-this._lastFrameTime;if(e>=this._frameDuration){const r=t-e%this._frameDuration,n=r-this._lastFrameTime;this._lastFrameTime=r;const o={deltaTime:n,time:t,currentTime:t,frameCount:++this._frameCount,fps:Math.round(1e3/n)};for(const t of this._tickers)"function"==typeof t&&t(o)}}add(t){this._tickers.add(t)}remove(t){this._tickers.delete(t)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}}class ke extends pe{constructor(t,e){super(t,e),this.gameObjects=[],this.scene=this}addGameObject(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)}removeGameObject(t){const e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}}var xe;t.LOAD_SCENE_MODE=void 0,(xe=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",xe.MULTI_CANVAS="MULTI_CANVAS";const Ae=t=>{if((t instanceof de||t instanceof r)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof r?console.error(`${t.constructor.componentName} start error`,e):console.error(`${t.constructor.systemName} start error`,e)}}};function Se(t={}){return function(e){if(!e.observerInfo){for(const e in t)for(const r in t[e]){let n;"string"==typeof t[e][r]&&(t[e][r]=[t[e][r]]),Array.isArray(t[e][r])&&(n={prop:t[e][r],deep:!1},t[e][r]=n),n=t[e][r],"string"==typeof n.prop&&(n.prop=[n.prop])}e.observerInfo=t}}}var Ce=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),Re=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Ce(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Ce(t,!0,e))},t.prototype.detach=function(t){var e=t;return e.owner!==this||(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._head?(this._head=e.next,null===e.next&&(this._tail=null)):e===this._tail&&(this._tail=e.prev,this._tail&&(this._tail.next=null)),e.owner=null),this},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addSignalBinding=function(t){var e=t;return this._head?(this._tail&&(this._tail.next=e),e.prev=this._tail,this._tail=e):(this._head=e,this._tail=e),e.owner=this,e},t}();var Le,Pe,De=function(t,e){if(t){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},n=r.parser[e.strictMode?"strict":"loose"].exec(t),o={},s=14;s--;)o[r.key[s]]=n[s]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o}},Me=function(t){this.config=t,this.onError=new Re,this.onComplete=new Re,this.onProgress=new Re},Ie=function(t,e){return(Ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function Ne(t,e){function r(){this.constructor=t}Ie(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Be(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var s=arguments[e],i=0,a=s.length;i<a;i++,o++)n[o]=s[i];return n}function qe(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),s=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Ue(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(Le||(Le={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(Pe||(Pe={}));var $e,Ve=function(t){function e(e,r){var n=t.call(this,e)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return Ne(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+qe(n));var s=document.createElement("source");s.src=n,s.type=o,this._element.appendChild(s)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents();var t=Le.Unknown;switch(this.elementType){case"audio":t=Le.Audio;break;case"video":t=Le.Video;break;default:Ue(this.elementType)}this.onComplete.dispatch(t,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error(this.elementType+" failed to load.")},e.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},e}(Me),Fe=function(t){function e(e){return t.call(this,e,"audio")||this}return Ne(e,t),e}(Ve),ze=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._element=e._createElement(),e._elementTimer=0,e}return Ne(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(Le.Image,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error("Image failed to load.")},e.prototype._onTimeout=function(){this._error("Image load timed out.")},e}(Me),Ge=function(t){function e(e){return t.call(this,e,"video")||this}return Ne(e,t),e}(Ve),Xe=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function Je(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}($e||($e={}));var Ye=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnAbort=e._onAbort.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._boundOnProgress=e._onProgress.bind(e),e._xhr=e._createRequest(),e._xhrType=$e.Default,e}return Ne(e,t),e.prototype.load=function(){var t=this.config,e=qe(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||$e.Default,Xe?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===$e.Json||t.xhrType===$e.Document?r.responseType=$e.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},e.prototype.abort=function(){Xe?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return Xe?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||$e.Default},e.prototype._clearEvents=function(){Xe?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},e.prototype._onLoad=function(){var t=this._xhr,e="",r=void 0===t.status?200:t.status;if(void 0!==t.responseType&&""!==t.responseType&&"text"!==t.responseType||(e=t.responseText),0===r&&(e.length>0||t.responseType===$e.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case $e.Buffer:console.warn(Le.Buffer,t.response),this._complete(Le.Buffer,t.response);break;case $e.Blob:this._complete(Le.Blob,t.response);break;case $e.Document:this._parseDocument(e);break;case $e.Json:this._parseJson(e);break;case $e.Default:case $e.Text:this._complete(Le.Text,e);break;default:Ue(this._xhrType)}else this._error("["+t.status+"] "+t.statusText+": "+t.responseURL)},e.prototype._parseDocument=function(t){try{if(window.DOMParser){var e=(new DOMParser).parseFromString(t,"text/xml");this._complete(Le.Xml,e)}else{var r=document.createElement("div");r.innerHTML=t,this._complete(Le.Xml,r)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},e.prototype._parseJson=function(t){try{var e=JSON.parse(t);this._complete(Le.Json,e)}catch(t){this._error("Error trying to parse loaded json: "+t)}},e.prototype._onAbort=function(){var t=this._xhr;this._error(Je(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(Je(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(Je(t)+" Request timed out.")},e.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},e.setExtensionXhrType=function(t,r){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(e._xhrTypeMap[t]=r)},e.ResponseType=$e,e._xhrTypeMap={xhtml:$e.Document,html:$e.Document,htm:$e.Document,xml:$e.Document,tmx:$e.Document,svg:$e.Document,tsx:$e.Document,gif:$e.Blob,png:$e.Blob,bmp:$e.Blob,jpg:$e.Blob,jpeg:$e.Blob,tif:$e.Blob,tiff:$e.Blob,webp:$e.Blob,tga:$e.Blob,json:$e.Json,text:$e.Text,txt:$e.Text,ttf:$e.Buffer,otf:$e.Buffer},e}(Me);function He(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var Qe=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new Re,this.onUnsaturated=new Re,this.onEmpty=new Re,this.onDrain=new Re,this.onError=new Re,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,He(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,Be([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),We=function(){function t(e,r){if(this.children=[],this.onStart=new Re,this.onProgress=new Re,this.onComplete=new Re,this.onAfterMiddleware=new Re,this.data=null,this.type=Le.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=Pe.NotStarted,this.name=e,this.metadata=r.metadata,"string"!=typeof r.crossOrigin&&(r.crossOrigin=this._determineCrossOrigin(r.url)),r.strategy&&"function"!=typeof r.strategy)this._strategy=r.strategy,this._strategy.config=r;else{var n=r.strategy;n||(n=t._loadStrategyMap[qe(r.url)]),n||(n=t._defaultLoadStrategy),this._strategy=new n(r)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return t.setDefaultLoadStrategy=function(e){t._defaultLoadStrategy=e},t.setLoadStrategy=function(e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t._loadStrategyMap[e]=r)},Object.defineProperty(t.prototype,"strategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoading",{get:function(){return this._state===Pe.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isComplete",{get:function(){return this._state===Pe.Complete},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this._strategy.abort()},t.prototype.load=function(){this._state=Pe.Loading,this.onStart.dispatch(this),this._strategy.load()},t.prototype._error=function(t){this._state=Pe.Complete,this.error=t,this.onComplete.dispatch(this)},t.prototype._complete=function(t,e){this._state=Pe.Complete,this.type=t,this.data=e,this.onComplete.dispatch(this)},t.prototype._progress=function(t){this.onProgress.dispatch(this,t)},t.prototype._determineCrossOrigin=function(e,r){if(void 0===r&&(r=window.location),0===e.indexOf("data:")||0===e.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";t._tempAnchor||(t._tempAnchor=document.createElement("a")),t._tempAnchor.href=e;var n=De(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,s=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&s===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=Ye,t._loadStrategyMap={gif:ze,png:ze,bmp:ze,jpg:ze,jpeg:ze,tif:ze,tiff:ze,webp:ze,tga:ze,svg:ze,"svg+xml":ze,mp3:Fe,ogg:Fe,wav:Fe,mp4:Ge,webm:Ge,mov:Ge},t}();var Ke,Ze,tr=/(#[\w-]+)?$/,er=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new Re,this.onLoad=new Re,this.onStart=new Re,this.onComplete=new Re,this.onProgress=new Re,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new Qe(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",s=this._baseUrl,i={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,s=t.baseUrl||s,i=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!i.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,s),i.url=n;var a=new We(o,i);if(this.resources[o]=a,"function"==typeof i.onComplete&&a.onAfterMiddleware.once(i.onComplete),this.loading){var c=i.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var h=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=h;for(r=0;r<u.length;++r)u[r].progressChunk=h;a.progressChunk=h}return this._queue.push(a),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=De(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=De(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=tr.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),function(t,e,r,n){void 0===n&&(n=!1);var o=0,s=t.length;!function i(a){a||o===s?r&&r(a):n?setTimeout((function(){return e(t[o++],i)}),1):e(t[o++],i)}()}(this._middleware,(function(r,n){r.fn.call(e,t,n)}),(function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()}),!0)},t.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}();class rr extends e{constructor({resource:e,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=r,0===r&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(t.LOAD_EVENT.START,this)}onProgress(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(t.LOAD_EVENT.LOADED,this,e):this.resource.emit(t.LOAD_EVENT.ERROR,this,e),this.resource.emit(t.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}}t.LOAD_EVENT=void 0,(Ke=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",Ke.PROGRESS="progress",Ke.LOADED="loaded",Ke.COMPLETE="complete",Ke.ERROR="error",t.RESOURCE_TYPE=void 0,(Ze=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",Ze.SPRITE="SPRITE",Ze.SPRITE_ANIMATION="SPRITE_ANIMATION",Ze.DRAGONBONE="DRAGONBONE",Ze.SPINE="SPINE",Ze.AUDIO="AUDIO",Ze.VIDEO="VIDEO",Ye.setExtensionXhrType("json",$e.Json),Ye.setExtensionXhrType("tex",$e.Json),Ye.setExtensionXhrType("ske",$e.Json),Ye.setExtensionXhrType("mp3",$e.Buffer),Ye.setExtensionXhrType("wav",$e.Buffer),Ye.setExtensionXhrType("aac",$e.Buffer),Ye.setExtensionXhrType("ogg",$e.Buffer);const nr={png:ze,jpg:ze,jpeg:ze,webp:ze,json:Ye,tex:Ye,ske:Ye,audio:Ye,video:Ge};const or=new class extends e{constructor(t){super(),this.timeout=6e3,this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.loaders=[],t&&"number"==typeof t.timeout&&(this.timeout=t.timeout)}loadConfig(t){this.addResource(t),this.preload()}loadSingle(t){return this.addResource([t]),this.getResource(t.name)}addResource(t){if(!t||t.length<1)console.warn("no resources");else for(const e of t)this.resourcesMap[e.name]?console.warn(e.name+" was already added"):(this.resourcesMap[e.name]=e,this.resourcesMap[e.name].data={})}preload(){const t=Object.values(this.resourcesMap).filter((({preload:t})=>t)).map((({name:t})=>t));this.progress=new rr({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})}getResource(t){return ce(this,void 0,void 0,(function*(){return this.loadResource({names:[t]}),this.promiseMap[t]||Promise.resolve({})}))}instance(t){return ce(this,void 0,void 0,(function*(){const e=this.resourcesMap[t];return this.makeInstanceFunctions[e.type]&&(yield this.makeInstanceFunctions[e.type](e))}))}destroy(t){return ce(this,void 0,void 0,(function*(){yield this._destroy(t)}))}_destroy(t,e=!1){return ce(this,void 0,void 0,(function*(){const r=this.resourcesMap[t];if(r){if(!e)try{this.destroyInstanceFunctions[r.type]&&(yield this.destroyInstanceFunctions[r.type](r))}catch(t){console.warn(`destroy resource ${r.name} error with '${t.message}'`)}delete this.promiseMap[t],r.data={},r.complete=!1,r.instance=void 0}}))}registerInstance(t,e){this.makeInstanceFunctions[t]=e}registerDestroy(t,e){this.destroyInstanceFunctions[t]=e}loadResource({names:t=[],preload:e=!1}){const r=t.filter((t=>!this.promiseMap[t]&&this.resourcesMap[t]));if(!r.length)return;const n={},o=this.getLoader(e);r.forEach((t=>{this.promiseMap[t]=new Promise((e=>n[t]=e));const r=this.resourcesMap[t];for(const s in r.src){const i=r.src[s].type;"data"===i?(r.data[s]=r.src[s].data,this.doComplete(t,n[t],e)):o.add({url:r.src[s].url,name:`${r.name}_${s}`,strategy:nr[i],metadata:{key:s,name:r.name,resolves:n}})}})),o.load()}doComplete(t,e,r=!1){return ce(this,void 0,void 0,(function*(){const n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0};if(this.checkAllLoaded(t))try{n.instance=yield this.instance(t),n.complete=!0,r&&this.progress.onProgress(o),e(n)}catch(t){n.complete=!1,r&&(o.errMsg=t.message,o.success=!1,this.progress.onProgress(o)),e({})}}))}checkAllLoaded(t){const e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((t=>e.data[t]))}getLoader(t=!1){let e=this.loaders.find((({loading:t})=>!t));return e||(e=new er,this.loaders.push(e)),t&&e.onStart.once((()=>{this.progress.onStart()})),e.onLoad.add(((e,r)=>{this.onLoad({preload:t,resource:r})})),e.onError.add(((e,r,n)=>{this.onError({errMsg:e,resource:n,preload:t})})),e.onComplete.once((()=>{e.onLoad.detachAll(),e.onError.detachAll(),e.reset()})),e}onLoad({preload:t=!1,resource:e}){return ce(this,void 0,void 0,(function*(){const{metadata:{key:r,name:n,resolves:o},data:s}=e;this.resourcesMap[n].data[r]=s,this.doComplete(n,o[n],t)}))}onError({errMsg:t,preload:e=!1,resource:r}){return ce(this,void 0,void 0,(function*(){const{metadata:{name:n,resolves:o}}=r;if(this._destroy(n,!0),o[n]({}),e){const e={name:n,resource:this.resourcesMap[n],success:!1,errMsg:t};this.progress.onProgress(e)}}))}},sr={IDEProp:ue,componentObserver:Se};t.Component=r,t.Game=class extends e{constructor({systems:t,frameRate:e=60,autoStart:r=!0,needScene:n=!0}={}){if(super(),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[],this.ticker=new je({autoStart:!1,frameRate:e}),this.initTicker(),t&&t.length)for(const e of t)this.addSystem(e);n&&this.loadScene(new ke("scene")),r&&this.start()}get scene(){return this._scene}set scene(t){this._scene=t}get gameObjects(){return(t=>{var e;const r=(null===(e=null==t?void 0:t.scene)||void 0===e?void 0:e.gameObjects)||[],n=null==t?void 0:t.multiScenes.map((({gameObjects:t})=>t));let o=[];for(const t of n)o=[...o,...t];return[...r,...o]})(this)}addSystem(t,e){let r;if(t instanceof Function)r=new t(e);else{if(!(t instanceof de))return void console.warn("can only add System");r=t}if(!this.systems.find((t=>t.constructor===r.constructor))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(t,e){ee[e.systemName]=e.observerInfo,te[e.systemName]=t}(r,r.constructor),function(t){const e=[];t instanceof Array?e.push(...t):e.push(t);for(const t of e)for(const e in t.observerInfo){re[e]=re[e]||[];const r=re[e];for(const n of t.observerInfo[e])-1===r.findIndex((t=>Kt(t,n)))&&re[e].push(n)}}(r.constructor);try{r.awake&&r.awake()}catch(t){console.error(`${r.constructor.systemName} awake error`,t)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}removeSystem(t){if(!t)return;let e=-1;"string"==typeof t?e=this.systems.findIndex((e=>e.name===t)):t instanceof Function?e=this.systems.findIndex((e=>e.constructor===t)):t instanceof de&&(e=this.systems.findIndex((e=>e===t))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}getSystem(t){return this.systems.find((e=>"string"==typeof t?e.name===t:e instanceof t))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((t=>{this.scene&&((t,e=[])=>{for(const r of e)for(const e of r.components)try{Ae(e),e.update&&e.update(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} update error`,t)}for(const r of e)for(const e of r.components)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} lateUpdate error`,t)}})(t,this.gameObjects);for(const e of this.systems)try{Ae(e),e.update&&e.update(t)}catch(t){console.error(`${e.constructor.systemName} update error`,t)}for(const e of this.systems)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`${e.constructor.systemName} lateUpdate error`,t)}}))}triggerResume(){(t=>{for(const e of t)for(const t of e.components)try{t.onResume&&t.onResume()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onResume&&t.onResume()}catch(e){console.error(`${t.constructor.systemName}, onResume error`,e)}}triggerPause(){(t=>{for(const e of t)for(const t of e.components)try{t.onPause&&t.onPause()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onPause&&t.onPause()}catch(e){console.error(`${t.constructor.systemName}, onPause error`,e)}}destroySystems(){for(const t of[...this.systems])this.removeSystem(t);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:r=t.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(e){switch(r){case t.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:r,params:n})}}},t.GameObject=pe,t.IDEProp=ue,t.Scene=ke,t.System=de,t.Transform=he,t.componentObserver=Se,t.decorators=sr,t.resource=or,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@eva/eva.js", | ||
"version": "1.1.0-beta.2", | ||
"version": "1.1.0", | ||
"description": "@eva/eva.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
356133
51
8381