@eva/plugin-renderer
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/renderer-adapter"),n=require("lodash"),r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function i(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function s(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(c(arguments[t]));return e}var f=function(){function t(e){var t=e.game,n=e.rendererSystem;this.renderers=[],this.game=t,this.rendererSystem=n}return t.prototype.register=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{for(var o=s(n),a=o.next();!a.done;a=o.next()){var i=a.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},t.prototype.componentChanged=function(t){var r,o,a=function(t){var r,o;try{for(var a=(r=void 0,s(i.renderers)),c=a.next();!c.done;c=a.next()){var l=c.value,f=l.observerInfo[t.componentName];if(f){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(t.type)>-1){try{l.componentChanged&&l.componentChanged(t)}catch(e){console.error("gameObject: "+t.gameObject.name+", "+t.componentName+" is error.",t,e)}continue}if(f.findIndex((function(e){return n.isEqual(e,t.prop)}))>-1)try{l.componentChanged&&l.componentChanged(t)}catch(e){console.error("gameObject: "+(t.gameObject&&t.gameObject.name)+", "+t.componentName+" is componentChanged error.",t,e)}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}},i=this;try{for(var c=s(t),l=c.next();!l.done;l=c.next()){a(l.value)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}},t.prototype.update=function(e){var t,n,r,o;try{for(var a=s(e.components),i=a.next();!i.done;i=a.next()){var c=i.value;try{for(var l=(r=void 0,s(this.renderers)),f=l.next();!f.done;f=l.next()){var p=f.value,u=[];if(p.observerInfo[c.name]&&-1===u.indexOf(e)){u.push(e);try{p.rendererUpdate&&p.rendererUpdate(e)}catch(t){console.info("gameObject: "+e.name+", "+c.name+" is update error",t)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},t}(),p=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var t=e.name,n=e.container;this.containerMap[t]=n},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){delete this.containerMap[e]},e.prototype.updateTransform=function(e){var t=e.name,n=e.transform,r=this.containerMap[t];if(r){var o=n.anchor,a=n.origin,i=n.position,s=n.rotation,c=n.scale,l=n.size,f=n.skew;r.rotation=s,r.scale=c,r.pivot.x=l.width*a.x,r.pivot.y=l.height*a.y,r.skew=f;var p=i.x,u=i.y;if(n.parent){var h=n.parent;p+=h.size.width*o.x,u+=h.size.height*o.y}r.position={x:p,y:u}}},e}();function u(e,t){return e(t={exports:{}},t.exports),t.exports}var h=function(n){function r(e){var t=e.system,r=e.containerManager,o=n.call(this)||this;return o.name="Transform",o.waitRemoveIds=[],o.waitChangeScenes=[],o.containerManager=r,o.init(t),o}return o(r,n),r.prototype.init=function(e){var t=this;this.system=e,this.on("changeScene",(function(e){var n=e.scene,r=e.mode,o=e.application;t.waitChangeScenes.push({scene:n,mode:r,application:o})}))},r.prototype.update=function(){var e,t,n,r;try{for(var o=s(this.waitRemoveIds),a=o.next();!a.done;a=o.next()){var i=a.value;this.containerManager.removeContainer(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var c=s(this.waitChangeScenes),l=c.next();!l.done;l=c.next()){var f=l.value,p=this.containerManager.getContainer(f.scene.id);p&&(f.application.stage.removeChildren(),f.application.stage.addChild(p))}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}this.waitChangeScenes=[]},r.prototype.componentChanged=function(t){t.type===e.OBSERVER_TYPE.ADD?this.addContainer(t):t.type===e.OBSERVER_TYPE.CHANGE?this.change(t):t.type===e.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(t.gameObject.id)},r.prototype.addContainer=function(e){var n=new t.Container;n.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:n}),e.component.worldTransform=n.transform.worldTransform},r.prototype.change=function(e){var t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{var r=this.containerManager.getContainer(e.gameObject.id);r.parent&&r.parent.removeChild(r)}},r.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},r=i([e.decorators.componentObserver({Transform:["_parent"]})],r)}(u((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,f=this._events[s],p=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,a),!0;case 6:return f.fn.call(f.context,t,r,o,a,i),!0}for(l=1,c=new Array(p-1);l<p;l++)c[l-1]=arguments[l];f.fn.apply(f.context,c)}else{var u,h=f.length;for(l=0;l<h;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),p){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,r);break;case 4:f[l].fn.call(f[l].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];f[l].fn.apply(f[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,l=[],f=s.length;c<f;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[a]=1===l.length?l[0]:l:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}))),m={autoStart:!0,frameRate:60},y=function(){function e(e){var t=this;e=Object.assign({},m,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,n=Date.now();if(n-this._lastTime>=this._frameDuration){var r=n-this._lastTime,o={deltaTime:r,frameCount:++this._frameCount,time:n-this._blockTime,fps:Math.round(1e3/r)};try{for(var a=s(this._tickers),i=a.next();!i.done;i=a.next()){var c=i.value;"function"==typeof c&&c(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=n}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}();function v(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var d=u((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,f=this._events[s],p=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,a),!0;case 6:return f.fn.call(f.context,t,r,o,a,i),!0}for(l=1,c=new Array(p-1);l<p;l++)c[l-1]=arguments[l];f.fn.apply(f.context,c)}else{var u,h=f.length;for(l=0;l<h;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),p){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,r);break;case 4:f[l].fn.call(f[l].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];f[l].fn.apply(f[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,l=[],f=s.length;c<f;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[a]=1===l.length?l[0]:l:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}));var g,b=function(e){function t(t){var n=e.call(this)||this;return n.started=!1,n.name=n.constructor.componentName,n.__componentDefaultParams=t,n}return o(t,e),t}(d),_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return o(t,e),t.prototype.init=function(e){var t,n;void 0===e&&(e={});try{for(var r=s(["position","size","origin","anchor","scale","skew"]),o=r.next();!o.done;o=r.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",i([v],t.prototype,"position",void 0),i([v],t.prototype,"size",void 0),i([v],t.prototype,"origin",void 0),i([v],t.prototype,"anchor",void 0),i([v],t.prototype,"scale",void 0),i([v],t.prototype,"skew",void 0),i([v],t.prototype,"rotation",void 0),t}(b);!function(e){e.ADD="ADD",e.REMOVE="REMOVE",e.CHANGE="CHANGE"}(g||(g={}));var x={},w={},O={},C={};function j(e,t){x[e.gameObject.id]||(x[e.gameObject.id]={});var n=x[e.gameObject.id],r=e.name+"_"+t.join(",");if(n[r])return n[r];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return n[r]={property:a,key:t[o]},n[r]}function E(e){var t=e.systemName,n=e.componentName,r=e.component,o=e.prop,a=e.type;w[t].componentObserver.add({component:r,prop:o,type:a,componentName:n})}function S(e){var t,r,o=e.obj,a=e.key,i=e.prop,c=e.component,l=e.componentName;if(void 0!==o)if(a in o){if(Object.defineProperty(o,"_"+a,{enumerable:!1,writable:!0,value:o[a]}),i.deep&&n.isObject(o[a]))try{for(var f=s(Object.keys(o[a])),p=f.next();!p.done;p=f.next()){var u=p.value;S({obj:o[a],key:u,prop:i,component:c,componentName:l})}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}Object.defineProperty(o,a,{enumerable:!0,set:function(e){o["_"+a]!==e&&(o["_"+a]=e,function(e){var t=e.prop,r=e.component,o=e.componentName;for(var a in O){var i=(O[a]||{})[o];i&&i.findIndex((function(e){return n.isEqual(e,t)}))>-1&&E({systemName:a,componentName:o,component:r,prop:t,type:g.CHANGE})}}({prop:i,component:c,componentName:l}))},get:function(){return o["_"+a]}})}else console.error("prop "+a+" not in component: "+l+", Can not observer")}function N(e,t){for(var n in void 0===t&&(t=e.name),O){(O[n]||{})[t]&&w[n].componentObserver.add({component:e,type:g.REMOVE,componentName:t})}!function(e){e.gameObject&&delete x[e.gameObject.id]}(e)}var R=0;var P,A=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.gameObjects=[],r.scene=r,r}return o(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++R,this.addComponent(_,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(_.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,n;if(this._scene!==e){var r=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=s(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):r&&r.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))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}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var n=function(e){return e instanceof b?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[n]){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof b))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){for(var n in void 0===t&&(t=e.name),O)(O[n]||{})[t]&&w[n].componentObserver.add({component:e,type:g.ADD,componentName:t})}(r,r.name),function(e,t){var n,r;if(void 0===t&&(t=e.name),t&&C[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=s(C[t]),i=a.next();!i.done;i=a.next()){var c=i.value,l=j(e,c.prop);S({obj:l.property,key:l.key,prop:c,component:e,componentName:t})}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}}(r,r.name),this.components.push(r),this._componentCache[n]=r,r.awake&&r.awake(),r}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof b?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var n=this.components.splice(t,1)[0];return delete this._componentCache[e],n.onDestroy&&n.onDestroy(),N(n,e),n.gameObject=void 0,n}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof b?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}()),k=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,r=e.prop,o=e.type,a=e.componentName;o===g.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var i=this.events.findIndex((function(e){return e.component===t&&n.isEqual(e.prop,r)&&e.type===o}));i>-1&&this.events.splice(i,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:o,componentName:a})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),T=function(){function e(t){this.started=!1,this.componentObserver=new k,this.__systemDefaultParams=t,this.name=e.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}();!function(e){e.SINGLE="SINGLE",e.MULTI_CANVAS="MULTI_CANVAS"}(P||(P={}));var M,I=function(e){if((e instanceof T||e instanceof b)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof b?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}};!function(e){function t(t){var n,r,o=void 0===t?{}:t,a=o.autoStart,i=void 0===a||a,c=o.frameRate,l=void 0===c?120:c,f=o.systems,p=o.needScene,u=void 0===p||p,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new y({autoStart:!1,frameRate:l}),h.initTicker(),f&&f.length)try{for(var m=s(f),v=m.next();!v.done;v=m.next()){var d=v.value;h.addSystem(d)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return u&&h.loadScene(new A("scene")),i&&h.start(),h}o(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,n,r,o=(null===(r=null==e?void 0:e.scene)||void 0===r?void 0:r.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var c=s(a),f=c.next();!f.done;f=c.next())i=l(i,f.value)}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return l(o,i)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof T))return void console.warn("can only add System");r=e}if(!this.systems.find((function(e){return e.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){O[t.systemName]=t.observerInfo,w[t.systemName]=e}(r,r.constructor),function(e){var t,r,o,a,i=[];e instanceof Array?i.push.apply(i,l(e)):i.push(e);try{for(var c=s(i),f=c.next();!f.done;f=c.next()){var p=f.value;for(var u in p.observerInfo){C[u]=C[u]||[];var h=C[u],m=function(e){-1===h.findIndex((function(t){return n.isEqual(t,e)}))&&C[u].push(e)};try{for(var y=(o=void 0,s(p.observerInfo[u])),v=y.next();!v.done;v=y.next())m(v.value)}catch(e){o={error:e}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}}}}catch(e){t={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}}(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")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof T&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var n,r,o,a;e.scene&&function(e,t){var n,r,o,a,i,c,l,f;void 0===t&&(t=[]);try{for(var p=s(t),u=p.next();!u.done;u=p.next()){var h=u.value;try{for(var m=(o=void 0,s(h.components)),y=m.next();!y.done;y=m.next()){var v=y.value;try{I(v),v.update&&v.update(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var d=s(t),g=d.next();!g.done;g=d.next()){h=g.value;try{for(var b=(l=void 0,s(h.components)),_=b.next();!_.done;_=b.next()){v=_.value;try{v.lateUpdate&&v.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" lateUpdate error",e)}}}catch(e){l={error:e}}finally{try{_&&!_.done&&(f=b.return)&&f.call(b)}finally{if(l)throw l.error}}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(c=d.return)&&c.call(d)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=s(e.systems),c=i.next();!c.done;c=i.next()){var l=c.value;try{I(l),l.update&&l.update(t)}catch(t){console.error(l.constructor.systemName+" update error",t)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}try{for(var f=s(e.systems),p=f.next();!p.done;p=f.next()){l=p.value;try{l.lateUpdate&&l.lateUpdate(t)}catch(t){console.error(l.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=s(e),i=a.next();!i.done;i=a.next()){var c=i.value;try{for(var l=(r=void 0,s(c.components)),f=l.next();!f.done;f=l.next()){var p=f.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+c.name+", "+p.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=s(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=s(e),i=a.next();!i.done;i=a.next()){var c=i.value;try{for(var l=(r=void 0,s(c.components)),f=l.next();!f.done;f=l.next()){var p=f.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+c.name+", "+p.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=s(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var n=s(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,n=e.mode,r=void 0===n?P.SINGLE:n,o=e.params,a=void 0===o?{}:o;if(t){switch(r){case P.SINGLE:this.scene=t;break;case P.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:a})}}}(d);(M=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[M.UNKNOWN=0]="UNKNOWN",M[M.WEBGL=1]="WEBGL",M[M.CANVAS=2]="CANVAS";var D=function(n){function r(){var e=null!==n&&n.apply(this,arguments)||this;return e.multiApps=[],e}return o(r,n),r.prototype.init=function(e){var t=this;this.params=e,this.application=this.createApplication(e),this.containerManager=new p,this.rendererManager=new f({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new h({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(e){var n,r=e.scene,o=e.mode,a=e.params;switch(o){case P.SINGLE:n=t.application;break;case P.MULTI_CANVAS:n=t.createMultiApplication({params:a})}r.canvas=n.view,t.transform.emit("changeScene",{scene:r,mode:o,application:n})}))},r.prototype.registerObserver=function(e){var t,n=this.constructor.observerInfo;for(var r in e)n[r]||(n[r]=[]),(t=n[r]).push.apply(t,l(e[r]))},r.prototype.createMultiApplication=function(e){var t=e.params,n=this.createApplication(t);return this.multiApps.push(n),n},r.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===exports.RENDERER_TYPE.CANVAS&&(e.forceCanvas=!0);var n=new t.Application(a({sharedTicker:!0},e));return!1!==e.preventScroll&&(n.renderer.plugins.interaction.autoPreventDefault=!1,n.renderer.view.style.touchAction="auto"),n},r.prototype.update=function(e){var t,n,r,o,a=this.componentObserver.clear();try{for(var i=s(a),c=i.next();!c.done;c=i.next()){var l=c.value;this.transform.componentChanged(l)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}try{for(var f=s(this.game.gameObjects),p=f.next();!p.done;p=f.next()){var u=p.value;this.containerManager.updateTransform({name:u.id,transform:u.transform}),this.rendererManager.update(u)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}this.application.ticker.update(e.time)},r.prototype.lateUpdate=function(){this.transform.update()},r.prototype.onDestroy=function(){var e,t;this.application.destroy();try{for(var n=s(this.multiApps),r=n.next();!r.done;r=n.next()){var o=r.value;o&&o.destroy()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},r.systemName="Renderer",r=i([e.decorators.componentObserver({Transform:["_parent"]})],r)}(e.System),L=function(e){function t(){var t=e.call(this)||this;return t.observerInfo=t.constructor.observerInfo,t}return o(t,e),t.prototype.update=function(){var e,t,n=this.componentObserver.clear();try{for(var r=s(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.componentChanged(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t}(e.System);exports.ContainerManager=p,exports.Renderer=L,exports.RendererManager=f,exports.RendererSystem=D; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/renderer-adapter"),n=require("lodash"),r=require("pixi.js"),o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function c(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e}var p=function(){function t(e){var t=e.game,n=e.rendererSystem;this.renderers=[],this.game=t,this.rendererSystem=n}return t.prototype.register=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{for(var o=c(n),a=o.next();!a.done;a=o.next()){var i=a.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},t.prototype.componentChanged=function(t){var r,o,a=function(t){var r,o;try{for(var a=(r=void 0,c(i.renderers)),s=a.next();!s.done;s=a.next()){var l=s.value,f=l.observerInfo[t.componentName];if(f){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(t.type)>-1){try{l.componentChanged&&l.componentChanged(t)}catch(e){console.error("gameObject: "+t.gameObject.name+", "+t.componentName+" is error.",t,e)}continue}if(f.findIndex((function(e){return n.isEqual(e,t.prop)}))>-1)try{l.componentChanged&&l.componentChanged(t)}catch(e){console.error("gameObject: "+(t.gameObject&&t.gameObject.name)+", "+t.componentName+" is componentChanged error.",t,e)}}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}},i=this;try{for(var s=c(t),l=s.next();!l.done;l=s.next()){a(l.value)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}},t.prototype.update=function(e){var t,n,r,o;try{for(var a=c(e.components),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var l=(r=void 0,c(this.renderers)),f=l.next();!f.done;f=l.next()){var p=f.value,u=[];if(p.observerInfo[s.name]&&-1===u.indexOf(e)){u.push(e);try{p.rendererUpdate&&p.rendererUpdate(e)}catch(t){console.info("gameObject: "+e.name+", "+s.name+" is update error",t)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},t}(),u=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var t=e.name,n=e.container;this.containerMap[t]=n},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){delete this.containerMap[e]},e.prototype.updateTransform=function(e){var t=e.name,n=e.transform,r=this.containerMap[t];if(r){var o=n.anchor,a=n.origin,i=n.position,s=n.rotation,c=n.scale,l=n.size,f=n.skew;r.rotation=s,r.scale=c,r.pivot.x=l.width*a.x,r.pivot.y=l.height*a.y,r.skew=f;var p=i.x,u=i.y;if(n.parent){var h=n.parent;p+=h.size.width*o.x,u+=h.size.height*o.y}r.position={x:p,y:u}}},e}();function h(e,t){return e(t={exports:{}},t.exports),t.exports}var m=function(n){function r(e){var t=e.system,r=e.containerManager,o=n.call(this)||this;return o.name="Transform",o.waitRemoveIds=[],o.waitChangeScenes=[],o.containerManager=r,o.init(t),o}return a(r,n),r.prototype.init=function(e){var t=this;this.system=e,this.on("changeScene",(function(e){var n=e.scene,r=e.mode,o=e.application;t.waitChangeScenes.push({scene:n,mode:r,application:o})}))},r.prototype.update=function(){var e,t,n,r;try{for(var o=c(this.waitRemoveIds),a=o.next();!a.done;a=o.next()){var i=a.value;this.containerManager.removeContainer(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var s=c(this.waitChangeScenes),l=s.next();!l.done;l=s.next()){var f=l.value,p=this.containerManager.getContainer(f.scene.id);p&&(f.application.stage.removeChildren(),f.application.stage.addChild(p))}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.waitChangeScenes=[]},r.prototype.componentChanged=function(t){t.type===e.OBSERVER_TYPE.ADD?this.addContainer(t):t.type===e.OBSERVER_TYPE.CHANGE?this.change(t):t.type===e.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(t.gameObject.id)},r.prototype.addContainer=function(e){var n=new t.Container;n.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:n}),e.component.worldTransform=n.transform.worldTransform},r.prototype.change=function(e){var t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{var r=this.containerManager.getContainer(e.gameObject.id);r.parent&&r.parent.removeChild(r)}},r.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},r=s([e.decorators.componentObserver({Transform:["_parent"]})],r)}(h((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,f=this._events[s],p=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,a),!0;case 6:return f.fn.call(f.context,t,r,o,a,i),!0}for(l=1,c=new Array(p-1);l<p;l++)c[l-1]=arguments[l];f.fn.apply(f.context,c)}else{var u,h=f.length;for(l=0;l<h;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),p){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,r);break;case 4:f[l].fn.call(f[l].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];f[l].fn.apply(f[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,l=[],f=s.length;c<f;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[a]=1===l.length?l[0]:l:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}))),y={autoStart:!0,frameRate:60},v=function(){function e(e){var t=this;e=Object.assign({},y,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,n=Date.now();if(n-this._lastTime>=this._frameDuration){var r=n-this._lastTime,o={deltaTime:r,frameCount:++this._frameCount,time:n-this._blockTime,fps:Math.round(1e3/r)};try{for(var a=c(this._tickers),i=a.next();!i.done;i=a.next()){var s=i.value;"function"==typeof s&&s(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=n}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}();function d(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var g=h((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,f=this._events[s],p=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),p){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,a),!0;case 6:return f.fn.call(f.context,t,r,o,a,i),!0}for(l=1,c=new Array(p-1);l<p;l++)c[l-1]=arguments[l];f.fn.apply(f.context,c)}else{var u,h=f.length;for(l=0;l<h;l++)switch(f[l].once&&this.removeListener(e,f[l].fn,void 0,!0),p){case 1:f[l].fn.call(f[l].context);break;case 2:f[l].fn.call(f[l].context,t);break;case 3:f[l].fn.call(f[l].context,t,r);break;case 4:f[l].fn.call(f[l].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];f[l].fn.apply(f[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,l=[],f=s.length;c<f;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[a]=1===l.length?l[0]:l:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}));var b,_=function(e){function t(t){var n=e.call(this)||this;return n.started=!1,n.name=n.constructor.componentName,n.__componentDefaultParams=t,n}return a(t,e),t}(g),x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return a(t,e),t.prototype.init=function(e){var t,n;void 0===e&&(e={});try{for(var r=c(["position","size","origin","anchor","scale","skew"]),o=r.next();!o.done;o=r.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",s([d],t.prototype,"position",void 0),s([d],t.prototype,"size",void 0),s([d],t.prototype,"origin",void 0),s([d],t.prototype,"anchor",void 0),s([d],t.prototype,"scale",void 0),s([d],t.prototype,"skew",void 0),s([d],t.prototype,"rotation",void 0),t}(_);!function(e){e.ADD="ADD",e.REMOVE="REMOVE",e.CHANGE="CHANGE"}(b||(b={}));var w={},O={},j={},C={};function E(e,t){w[e.gameObject.id]||(w[e.gameObject.id]={});var n=w[e.gameObject.id],r=e.name+"_"+t.join(",");if(n[r])return n[r];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return n[r]={property:a,key:t[o]},n[r]}function S(e){var t=e.systemName,n=e.componentName,r=e.component,o=e.prop,a=e.type;O[t].componentObserver.add({component:r,prop:o,type:a,componentName:n})}function N(e){var t,r,o=e.obj,a=e.key,i=e.prop,s=e.component,l=e.componentName;if(void 0!==o)if(a in o){if(Object.defineProperty(o,"_"+a,{enumerable:!1,writable:!0,value:o[a]}),i.deep&&n.isObject(o[a]))try{for(var f=c(Object.keys(o[a])),p=f.next();!p.done;p=f.next()){var u=p.value;N({obj:o[a],key:u,prop:i,component:s,componentName:l})}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}Object.defineProperty(o,a,{enumerable:!0,set:function(e){o["_"+a]!==e&&(o["_"+a]=e,function(e){var t=e.prop,r=e.component,o=e.componentName;for(var a in j){var i=(j[a]||{})[o];i&&i.findIndex((function(e){return n.isEqual(e,t)}))>-1&&S({systemName:a,componentName:o,component:r,prop:t,type:b.CHANGE})}}({prop:i,component:s,componentName:l}))},get:function(){return o["_"+a]}})}else console.error("prop "+a+" not in component: "+l+", Can not observer")}function R(e,t){for(var n in void 0===t&&(t=e.name),j){(j[n]||{})[t]&&O[n].componentObserver.add({component:e,type:b.REMOVE,componentName:t})}!function(e){e.gameObject&&delete w[e.gameObject.id]}(e)}var k=0;var P,A=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.gameObjects=[],r.scene=r,r}return a(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++k,this.addComponent(x,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(x.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,n;if(this._scene!==e){var r=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=c(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):r&&r.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))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}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var n=function(e){return e instanceof _?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[n]){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof _))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){for(var n in void 0===t&&(t=e.name),j)(j[n]||{})[t]&&O[n].componentObserver.add({component:e,type:b.ADD,componentName:t})}(r,r.name),function(e,t){var n,r;if(void 0===t&&(t=e.name),t&&C[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=c(C[t]),i=a.next();!i.done;i=a.next()){var s=i.value,l=E(e,s.prop);N({obj:l.property,key:l.key,prop:s,component:e,componentName:t})}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}}(r,r.name),this.components.push(r),this._componentCache[n]=r,r.awake&&r.awake(),r}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof _?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var n=this.components.splice(t,1)[0];return delete this._componentCache[e],n.onDestroy&&n.onDestroy(),R(n,e),n.gameObject=void 0,n}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof _?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}()),T=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,r=e.prop,o=e.type,a=e.componentName;o===b.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var i=this.events.findIndex((function(e){return e.component===t&&n.isEqual(e.prop,r)&&e.type===o}));i>-1&&this.events.splice(i,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:o,componentName:a})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),M=function(){function e(t){this.started=!1,this.componentObserver=new T,this.__systemDefaultParams=t,this.name=e.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}();!function(e){e.SINGLE="SINGLE",e.MULTI_CANVAS="MULTI_CANVAS"}(P||(P={}));var I,D=function(e){if((e instanceof M||e instanceof _)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof _?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}};!function(e){function t(t){var n,r,o=void 0===t?{}:t,a=o.autoStart,i=void 0===a||a,s=o.frameRate,l=void 0===s?120:s,f=o.systems,p=o.needScene,u=void 0===p||p,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new v({autoStart:!1,frameRate:l}),h.initTicker(),f&&f.length)try{for(var m=c(f),y=m.next();!y.done;y=m.next()){var d=y.value;h.addSystem(d)}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return u&&h.loadScene(new A("scene")),i&&h.start(),h}a(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,n,r,o=(null===(r=null==e?void 0:e.scene)||void 0===r?void 0:r.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var s=c(a),l=s.next();!l.done;l=s.next())i=f(i,l.value)}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return f(o,i)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof M))return void console.warn("can only add System");r=e}if(!this.systems.find((function(e){return e.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){j[t.systemName]=t.observerInfo,O[t.systemName]=e}(r,r.constructor),function(e){var t,r,o,a,i=[];e instanceof Array?i.push.apply(i,f(e)):i.push(e);try{for(var s=c(i),l=s.next();!l.done;l=s.next()){var p=l.value;for(var u in p.observerInfo){C[u]=C[u]||[];var h=C[u],m=function(e){-1===h.findIndex((function(t){return n.isEqual(t,e)}))&&C[u].push(e)};try{for(var y=(o=void 0,c(p.observerInfo[u])),v=y.next();!v.done;v=y.next())m(v.value)}catch(e){o={error:e}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}(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")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof M&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var n,r,o,a;e.scene&&function(e,t){var n,r,o,a,i,s,l,f;void 0===t&&(t=[]);try{for(var p=c(t),u=p.next();!u.done;u=p.next()){var h=u.value;try{for(var m=(o=void 0,c(h.components)),y=m.next();!y.done;y=m.next()){var v=y.value;try{D(v),v.update&&v.update(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var d=c(t),g=d.next();!g.done;g=d.next()){h=g.value;try{for(var b=(l=void 0,c(h.components)),_=b.next();!_.done;_=b.next()){v=_.value;try{v.lateUpdate&&v.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" lateUpdate error",e)}}}catch(e){l={error:e}}finally{try{_&&!_.done&&(f=b.return)&&f.call(b)}finally{if(l)throw l.error}}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=c(e.systems),s=i.next();!s.done;s=i.next()){var l=s.value;try{D(l),l.update&&l.update(t)}catch(t){console.error(l.constructor.systemName+" update error",t)}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}try{for(var f=c(e.systems),p=f.next();!p.done;p=f.next()){l=p.value;try{l.lateUpdate&&l.lateUpdate(t)}catch(t){console.error(l.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=c(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var l=(r=void 0,c(s.components)),f=l.next();!f.done;f=l.next()){var p=f.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+s.name+", "+p.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=c(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=c(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var l=(r=void 0,c(s.components)),f=l.next();!f.done;f=l.next()){var p=f.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+s.name+", "+p.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=c(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var n=c(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,n=e.mode,r=void 0===n?P.SINGLE:n,o=e.params,a=void 0===o?{}:o;if(t){switch(r){case P.SINGLE:this.scene=t;break;case P.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:a})}}}(g);(I=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[I.UNKNOWN=0]="UNKNOWN",I[I.WEBGL=1]="WEBGL",I[I.CANVAS=2]="CANVAS";var L=function(n){function o(){var e=null!==n&&n.apply(this,arguments)||this;return e.multiApps=[],e}return a(o,n),o.prototype.init=function(e){var t=this;this.params=e,this.application=this.createApplication(e),this.containerManager=new u,this.rendererManager=new p({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new m({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(e){var n,r=e.scene,o=e.mode,a=e.params;switch(o){case P.SINGLE:n=t.application;break;case P.MULTI_CANVAS:n=t.createMultiApplication({params:a})}r.canvas=n.view,t.transform.emit("changeScene",{scene:r,mode:o,application:n})}))},o.prototype.registerObserver=function(e){var t,n=this.constructor.observerInfo;for(var r in e)n[r]||(n[r]=[]),(t=n[r]).push.apply(t,f(e[r]))},o.prototype.createMultiApplication=function(e){var t=e.params,n=this.createApplication(t);return this.multiApps.push(n),n},o.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===exports.RENDERER_TYPE.CANVAS&&(e.forceCanvas=!0),r.ticker.shared.autoStart=!1,r.ticker.shared.stop();var n=new t.Application(i({sharedTicker:!0},e));return!1!==e.preventScroll&&(n.renderer.plugins.interaction.autoPreventDefault=!1,n.renderer.view.style.touchAction="auto"),n},o.prototype.update=function(e){var t,n,r,o,a=this.componentObserver.clear();try{for(var i=c(a),s=i.next();!s.done;s=i.next()){var l=s.value;this.transform.componentChanged(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}try{for(var f=c(this.game.gameObjects),p=f.next();!p.done;p=f.next()){var u=p.value;this.containerManager.updateTransform({name:u.id,transform:u.transform}),this.rendererManager.update(u)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}this.application.ticker.update(e.time)},o.prototype.lateUpdate=function(){this.transform.update()},o.prototype.onDestroy=function(){var e,t;this.application.destroy();try{for(var n=c(this.multiApps),r=n.next();!r.done;r=n.next()){var o=r.value;o&&o.destroy()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},o.systemName="Renderer",o=s([e.decorators.componentObserver({Transform:["_parent"]})],o)}(e.System),V=function(e){function t(){var t=e.call(this)||this;return t.observerInfo=t.constructor.observerInfo,t}return a(t,e),t.prototype.update=function(){var e,t,n=this.componentObserver.clear();try{for(var r=c(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.componentChanged(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t}(e.System);exports.ContainerManager=u,exports.Renderer=V,exports.RendererManager=p,exports.RendererSystem=L; |
@@ -1,1 +0,1 @@ | ||
import{OBSERVER_TYPE as e,decorators as t,System as n}from"@eva/eva.js";import{Container as r,Application as o}from"@eva/renderer-adapter";import{isEqual as a,isObject as i}from"lodash";var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function c(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function l(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}var m=function(){function t(e){var t=e.game,n=e.rendererSystem;this.renderers=[],this.game=t,this.rendererSystem=n}return t.prototype.register=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{for(var o=p(n),a=o.next();!a.done;a=o.next()){var i=a.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},t.prototype.componentChanged=function(t){var n,r,o=function(t){var n,r;try{for(var o=(n=void 0,p(i.renderers)),s=o.next();!s.done;s=o.next()){var c=s.value,f=c.observerInfo[t.componentName];if(f){if([e.ADD,e.REMOVE].indexOf(t.type)>-1){try{c.componentChanged&&c.componentChanged(t)}catch(e){console.error("gameObject: "+t.gameObject.name+", "+t.componentName+" is error.",t,e)}continue}if(f.findIndex((function(e){return a(e,t.prop)}))>-1)try{c.componentChanged&&c.componentChanged(t)}catch(e){console.error("gameObject: "+(t.gameObject&&t.gameObject.name)+", "+t.componentName+" is componentChanged error.",t,e)}}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},i=this;try{for(var s=p(t),c=s.next();!c.done;c=s.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e){var t,n,r,o;try{for(var a=p(e.components),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,p(this.renderers)),f=c.next();!f.done;f=c.next()){var l=f.value,u=[];if(l.observerInfo[s.name]&&-1===u.indexOf(e)){u.push(e);try{l.rendererUpdate&&l.rendererUpdate(e)}catch(t){console.info("gameObject: "+e.name+", "+s.name+" is update error",t)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},t}(),y=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var t=e.name,n=e.container;this.containerMap[t]=n},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){delete this.containerMap[e]},e.prototype.updateTransform=function(e){var t=e.name,n=e.transform,r=this.containerMap[t];if(r){var o=n.anchor,a=n.origin,i=n.position,s=n.rotation,c=n.scale,f=n.size,l=n.skew;r.rotation=s,r.scale=c,r.pivot.x=f.width*a.x,r.pivot.y=f.height*a.y,r.skew=l;var p=i.x,u=i.y;if(n.parent){var h=n.parent;p+=h.size.width*o.x,u+=h.size.height*o.y}r.position={x:p,y:u}}},e}();function v(e,t){return e(t={exports:{}},t.exports),t.exports}var d=function(n){function o(e){var t=e.system,r=e.containerManager,o=n.call(this)||this;return o.name="Transform",o.waitRemoveIds=[],o.waitChangeScenes=[],o.containerManager=r,o.init(t),o}return c(o,n),o.prototype.init=function(e){var t=this;this.system=e,this.on("changeScene",(function(e){var n=e.scene,r=e.mode,o=e.application;t.waitChangeScenes.push({scene:n,mode:r,application:o})}))},o.prototype.update=function(){var e,t,n,r;try{for(var o=p(this.waitRemoveIds),a=o.next();!a.done;a=o.next()){var i=a.value;this.containerManager.removeContainer(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var s=p(this.waitChangeScenes),c=s.next();!c.done;c=s.next()){var f=c.value,l=this.containerManager.getContainer(f.scene.id);l&&(f.application.stage.removeChildren(),f.application.stage.addChild(l))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.waitChangeScenes=[]},o.prototype.componentChanged=function(t){t.type===e.ADD?this.addContainer(t):t.type===e.CHANGE?this.change(t):t.type===e.REMOVE&&this.waitRemoveIds.push(t.gameObject.id)},o.prototype.addContainer=function(e){var t=new r;t.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t}),e.component.worldTransform=t.transform.worldTransform},o.prototype.change=function(e){var t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{var r=this.containerManager.getContainer(e.gameObject.id);r.parent&&r.parent.removeChild(r)}},o.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},o=l([t.componentObserver({Transform:["_parent"]})],o)}(v((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,f,l=this._events[s],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,a),!0;case 6:return l.fn.call(l.context,t,r,o,a,i),!0}for(f=1,c=new Array(p-1);f<p;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var u,h=l.length;for(f=0;f<h;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),p){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,t);break;case 3:l[f].fn.call(l[f].context,t,r);break;case 4:l[f].fn.call(l[f].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l[f].fn.apply(l[f].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,f=[],l=s.length;c<l;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}))),g={autoStart:!0,frameRate:60},b=function(){function e(e){var t=this;e=Object.assign({},g,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,n=Date.now();if(n-this._lastTime>=this._frameDuration){var r=n-this._lastTime,o={deltaTime:r,frameCount:++this._frameCount,time:n-this._blockTime,fps:Math.round(1e3/r)};try{for(var a=p(this._tickers),i=a.next();!i.done;i=a.next()){var s=i.value;"function"==typeof s&&s(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=n}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}();function _(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var w=v((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,f,l=this._events[s],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,a),!0;case 6:return l.fn.call(l.context,t,r,o,a,i),!0}for(f=1,c=new Array(p-1);f<p;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var u,h=l.length;for(f=0;f<h;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),p){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,t);break;case 3:l[f].fn.call(l[f].context,t,r);break;case 4:l[f].fn.call(l[f].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l[f].fn.apply(l[f].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,f=[],l=s.length;c<l;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}));var x,O=function(e){function t(t){var n=e.call(this)||this;return n.started=!1,n.name=n.constructor.componentName,n.__componentDefaultParams=t,n}return c(t,e),t}(w),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return c(t,e),t.prototype.init=function(e){var t,n;void 0===e&&(e={});try{for(var r=p(["position","size","origin","anchor","scale","skew"]),o=r.next();!o.done;o=r.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",l([_],t.prototype,"position",void 0),l([_],t.prototype,"size",void 0),l([_],t.prototype,"origin",void 0),l([_],t.prototype,"anchor",void 0),l([_],t.prototype,"scale",void 0),l([_],t.prototype,"skew",void 0),l([_],t.prototype,"rotation",void 0),t}(O);!function(e){e.ADD="ADD",e.REMOVE="REMOVE",e.CHANGE="CHANGE"}(x||(x={}));var j={},S={},N={},k={};function A(e,t){j[e.gameObject.id]||(j[e.gameObject.id]={});var n=j[e.gameObject.id],r=e.name+"_"+t.join(",");if(n[r])return n[r];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return n[r]={property:a,key:t[o]},n[r]}function E(e){var t=e.systemName,n=e.componentName,r=e.component,o=e.prop,a=e.type;S[t].componentObserver.add({component:r,prop:o,type:a,componentName:n})}function P(e){var t,n,r=e.obj,o=e.key,s=e.prop,c=e.component,f=e.componentName;if(void 0!==r)if(o in r){if(Object.defineProperty(r,"_"+o,{enumerable:!1,writable:!0,value:r[o]}),s.deep&&i(r[o]))try{for(var l=p(Object.keys(r[o])),u=l.next();!u.done;u=l.next()){var h=u.value;P({obj:r[o],key:h,prop:s,component:c,componentName:f})}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}Object.defineProperty(r,o,{enumerable:!0,set:function(e){r["_"+o]!==e&&(r["_"+o]=e,function(e){var t=e.prop,n=e.component,r=e.componentName;for(var o in N){var i=(N[o]||{})[r];i&&i.findIndex((function(e){return a(e,t)}))>-1&&E({systemName:o,componentName:r,component:n,prop:t,type:x.CHANGE})}}({prop:s,component:c,componentName:f}))},get:function(){return r["_"+o]}})}else console.error("prop "+o+" not in component: "+f+", Can not observer")}function M(e,t){for(var n in void 0===t&&(t=e.name),N){(N[n]||{})[t]&&S[n].componentObserver.add({component:e,type:x.REMOVE,componentName:t})}!function(e){e.gameObject&&delete j[e.gameObject.id]}(e)}var I=0;var T,R=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.gameObjects=[],r.scene=r,r}return c(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++I,this.addComponent(C,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(C.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,n;if(this._scene!==e){var r=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=p(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):r&&r.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))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}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var n=function(e){return e instanceof O?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[n]){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof O))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){for(var n in void 0===t&&(t=e.name),N)(N[n]||{})[t]&&S[n].componentObserver.add({component:e,type:x.ADD,componentName:t})}(r,r.name),function(e,t){var n,r;if(void 0===t&&(t=e.name),t&&k[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=p(k[t]),i=a.next();!i.done;i=a.next()){var s=i.value,c=A(e,s.prop);P({obj:c.property,key:c.key,prop:s,component:e,componentName:t})}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}}(r,r.name),this.components.push(r),this._componentCache[n]=r,r.awake&&r.awake(),r}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof O?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var n=this.components.splice(t,1)[0];return delete this._componentCache[e],n.onDestroy&&n.onDestroy(),M(n,e),n.gameObject=void 0,n}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof O?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}()),D=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,n=e.prop,r=e.type,o=e.componentName;r===x.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var i=this.events.findIndex((function(e){return e.component===t&&a(e.prop,n)&&e.type===r}));i>-1&&this.events.splice(i,1),this.events.push({gameObject:t.gameObject,component:t,prop:n,type:r,componentName:o})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),L=function(){function e(t){this.started=!1,this.componentObserver=new D,this.__systemDefaultParams=t,this.name=e.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}();!function(e){e.SINGLE="SINGLE",e.MULTI_CANVAS="MULTI_CANVAS"}(T||(T={}));var G,U=function(e){if((e instanceof L||e instanceof O)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof O?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}};!function(e){function t(t){var n,r,o=void 0===t?{}:t,a=o.autoStart,i=void 0===a||a,s=o.frameRate,c=void 0===s?120:s,f=o.systems,l=o.needScene,u=void 0===l||l,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new b({autoStart:!1,frameRate:c}),h.initTicker(),f&&f.length)try{for(var m=p(f),y=m.next();!y.done;y=m.next()){var v=y.value;h.addSystem(v)}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return u&&h.loadScene(new R("scene")),i&&h.start(),h}c(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,n,r,o=(null===(r=null==e?void 0:e.scene)||void 0===r?void 0:r.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var s=p(a),c=s.next();!c.done;c=s.next())i=h(i,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return h(o,i)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof L))return void console.warn("can only add System");n=e}if(!this.systems.find((function(e){return e.constructor===n.constructor}))){n.game=this,n.init&&n.init(n.__systemDefaultParams),function(e,t){N[t.systemName]=t.observerInfo,S[t.systemName]=e}(n,n.constructor),function(e){var t,n,r,o,i=[];e instanceof Array?i.push.apply(i,h(e)):i.push(e);try{for(var s=p(i),c=s.next();!c.done;c=s.next()){var f=c.value;for(var l in f.observerInfo){k[l]=k[l]||[];var u=k[l],m=function(e){-1===u.findIndex((function(t){return a(t,e)}))&&k[l].push(e)};try{for(var y=(r=void 0,p(f.observerInfo[l])),v=y.next();!v.done;v=y.next())m(v.value)}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}(n.constructor);try{n.awake&&n.awake()}catch(e){console.error(n.constructor.systemName+" awake error",e)}return this.systems.push(n),n}console.warn(n.constructor.systemName+" System has been added")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof L&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var n,r,o,a;e.scene&&function(e,t){var n,r,o,a,i,s,c,f;void 0===t&&(t=[]);try{for(var l=p(t),u=l.next();!u.done;u=l.next()){var h=u.value;try{for(var m=(o=void 0,p(h.components)),y=m.next();!y.done;y=m.next()){var v=y.value;try{U(v),v.update&&v.update(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}try{for(var d=p(t),g=d.next();!g.done;g=d.next()){h=g.value;try{for(var b=(c=void 0,p(h.components)),_=b.next();!_.done;_=b.next()){v=_.value;try{v.lateUpdate&&v.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{_&&!_.done&&(f=b.return)&&f.call(b)}finally{if(c)throw c.error}}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=p(e.systems),s=i.next();!s.done;s=i.next()){var c=s.value;try{U(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}try{for(var f=p(e.systems),l=f.next();!l.done;l=f.next()){c=l.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=p(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,p(s.components)),f=c.next();!f.done;f=c.next()){var l=f.value;try{l.onResume&&l.onResume()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=p(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=p(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,p(s.components)),f=c.next();!f.done;f=c.next()){var l=f.value;try{l.onPause&&l.onPause()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=p(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var n=p(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,n=e.mode,r=void 0===n?T.SINGLE:n,o=e.params,a=void 0===o?{}:o;if(t){switch(r){case T.SINGLE:this.scene=t;break;case T.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:a})}}}(w);!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"}(G||(G={}));var V=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.multiApps=[],t}return c(n,e),n.prototype.init=function(e){var t=this;this.params=e,this.application=this.createApplication(e),this.containerManager=new y,this.rendererManager=new m({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new d({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(e){var n,r=e.scene,o=e.mode,a=e.params;switch(o){case T.SINGLE:n=t.application;break;case T.MULTI_CANVAS:n=t.createMultiApplication({params:a})}r.canvas=n.view,t.transform.emit("changeScene",{scene:r,mode:o,application:n})}))},n.prototype.registerObserver=function(e){var t,n=this.constructor.observerInfo;for(var r in e)n[r]||(n[r]=[]),(t=n[r]).push.apply(t,h(e[r]))},n.prototype.createMultiApplication=function(e){var t=e.params,n=this.createApplication(t);return this.multiApps.push(n),n},n.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===G.CANVAS&&(e.forceCanvas=!0);var t=new o(f({sharedTicker:!0},e));return!1!==e.preventScroll&&(t.renderer.plugins.interaction.autoPreventDefault=!1,t.renderer.view.style.touchAction="auto"),t},n.prototype.update=function(e){var t,n,r,o,a=this.componentObserver.clear();try{for(var i=p(a),s=i.next();!s.done;s=i.next()){var c=s.value;this.transform.componentChanged(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}try{for(var f=p(this.game.gameObjects),l=f.next();!l.done;l=f.next()){var u=l.value;this.containerManager.updateTransform({name:u.id,transform:u.transform}),this.rendererManager.update(u)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}this.application.ticker.update(e.time)},n.prototype.lateUpdate=function(){this.transform.update()},n.prototype.onDestroy=function(){var e,t;this.application.destroy();try{for(var n=p(this.multiApps),r=n.next();!r.done;r=n.next()){var o=r.value;o&&o.destroy()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},n.systemName="Renderer",n=l([t.componentObserver({Transform:["_parent"]})],n)}(n),W=function(e){function t(){var t=e.call(this)||this;return t.observerInfo=t.constructor.observerInfo,t}return c(t,e),t.prototype.update=function(){var e,t,n=this.componentObserver.clear();try{for(var r=p(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.componentChanged(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t}(n);export{y as ContainerManager,G as RENDERER_TYPE,W as Renderer,m as RendererManager,V as RendererSystem}; | ||
import{OBSERVER_TYPE as e,decorators as t,System as n}from"@eva/eva.js";import{Container as r,Application as o}from"@eva/renderer-adapter";import{isEqual as a,isObject as i}from"lodash";import{ticker as s}from"pixi.js";var c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function f(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l=function(){return(l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}var y=function(){function t(e){var t=e.game,n=e.rendererSystem;this.renderers=[],this.game=t,this.rendererSystem=n}return t.prototype.register=function(){for(var e,t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{for(var o=u(n),a=o.next();!a.done;a=o.next()){var i=a.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},t.prototype.componentChanged=function(t){var n,r,o=function(t){var n,r;try{for(var o=(n=void 0,u(i.renderers)),s=o.next();!s.done;s=o.next()){var c=s.value,f=c.observerInfo[t.componentName];if(f){if([e.ADD,e.REMOVE].indexOf(t.type)>-1){try{c.componentChanged&&c.componentChanged(t)}catch(e){console.error("gameObject: "+t.gameObject.name+", "+t.componentName+" is error.",t,e)}continue}if(f.findIndex((function(e){return a(e,t.prop)}))>-1)try{c.componentChanged&&c.componentChanged(t)}catch(e){console.error("gameObject: "+(t.gameObject&&t.gameObject.name)+", "+t.componentName+" is componentChanged error.",t,e)}}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},i=this;try{for(var s=u(t),c=s.next();!c.done;c=s.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e){var t,n,r,o;try{for(var a=u(e.components),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,u(this.renderers)),f=c.next();!f.done;f=c.next()){var l=f.value,p=[];if(l.observerInfo[s.name]&&-1===p.indexOf(e)){p.push(e);try{l.rendererUpdate&&l.rendererUpdate(e)}catch(t){console.info("gameObject: "+e.name+", "+s.name+" is update error",t)}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},t}(),v=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var t=e.name,n=e.container;this.containerMap[t]=n},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){delete this.containerMap[e]},e.prototype.updateTransform=function(e){var t=e.name,n=e.transform,r=this.containerMap[t];if(r){var o=n.anchor,a=n.origin,i=n.position,s=n.rotation,c=n.scale,f=n.size,l=n.skew;r.rotation=s,r.scale=c,r.pivot.x=f.width*a.x,r.pivot.y=f.height*a.y,r.skew=l;var p=i.x,u=i.y;if(n.parent){var h=n.parent;p+=h.size.width*o.x,u+=h.size.height*o.y}r.position={x:p,y:u}}},e}();function d(e,t){return e(t={exports:{}},t.exports),t.exports}var g=function(n){function o(e){var t=e.system,r=e.containerManager,o=n.call(this)||this;return o.name="Transform",o.waitRemoveIds=[],o.waitChangeScenes=[],o.containerManager=r,o.init(t),o}return f(o,n),o.prototype.init=function(e){var t=this;this.system=e,this.on("changeScene",(function(e){var n=e.scene,r=e.mode,o=e.application;t.waitChangeScenes.push({scene:n,mode:r,application:o})}))},o.prototype.update=function(){var e,t,n,r;try{for(var o=u(this.waitRemoveIds),a=o.next();!a.done;a=o.next()){var i=a.value;this.containerManager.removeContainer(i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var s=u(this.waitChangeScenes),c=s.next();!c.done;c=s.next()){var f=c.value,l=this.containerManager.getContainer(f.scene.id);l&&(f.application.stage.removeChildren(),f.application.stage.addChild(l))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}this.waitChangeScenes=[]},o.prototype.componentChanged=function(t){t.type===e.ADD?this.addContainer(t):t.type===e.CHANGE?this.change(t):t.type===e.REMOVE&&this.waitRemoveIds.push(t.gameObject.id)},o.prototype.addContainer=function(e){var t=new r;t.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t}),e.component.worldTransform=t.transform.worldTransform},o.prototype.change=function(e){var t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{var r=this.containerManager.getContainer(e.gameObject.id);r.parent&&r.parent.removeChild(r)}},o.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},o=p([t.componentObserver({Transform:["_parent"]})],o)}(d((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,f,l=this._events[s],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,a),!0;case 6:return l.fn.call(l.context,t,r,o,a,i),!0}for(f=1,c=new Array(p-1);f<p;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var u,h=l.length;for(f=0;f<h;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),p){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,t);break;case 3:l[f].fn.call(l[f].context,t,r);break;case 4:l[f].fn.call(l[f].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l[f].fn.apply(l[f].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,f=[],l=s.length;c<l;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}))),b={autoStart:!0,frameRate:60},_=function(){function e(e){var t=this;e=Object.assign({},b,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,n=Date.now();if(n-this._lastTime>=this._frameDuration){var r=n-this._lastTime,o={deltaTime:r,frameCount:++this._frameCount,time:n-this._blockTime,fps:Math.round(1e3/r)};try{for(var a=u(this._tickers),i=a.next();!i.done;i=a.next()){var s=i.value;"function"==typeof s&&s(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=n}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}();function w(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var x=d((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,a=r.length,i=new Array(a);o<a;o++)i[o]=r[o].fn;return i},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,a,i){var s=n?n+e:e;if(!this._events[s])return!1;var c,f,l=this._events[s],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,a),!0;case 6:return l.fn.call(l.context,t,r,o,a,i),!0}for(f=1,c=new Array(p-1);f<p;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var u,h=l.length;for(f=0;f<h;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),p){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,t);break;case 3:l[f].fn.call(l[f].context,t,r);break;case 4:l[f].fn.call(l[f].context,t,r,o);break;default:if(!c)for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l[f].fn.apply(l[f].context,c)}}return!0},s.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return i(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||i(this,a);else{for(var c=0,f=[],l=s.length;c<l;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&f.push(s[c]);f.length?this._events[a]=1===f.length?f[0]:f:i(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}));var O,j=function(e){function t(t){var n=e.call(this)||this;return n.started=!1,n.name=n.constructor.componentName,n.__componentDefaultParams=t,n}return f(t,e),t}(x),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return f(t,e),t.prototype.init=function(e){var t,n;void 0===e&&(e={});try{for(var r=u(["position","size","origin","anchor","scale","skew"]),o=r.next();!o.done;o=r.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",p([w],t.prototype,"position",void 0),p([w],t.prototype,"size",void 0),p([w],t.prototype,"origin",void 0),p([w],t.prototype,"anchor",void 0),p([w],t.prototype,"scale",void 0),p([w],t.prototype,"skew",void 0),p([w],t.prototype,"rotation",void 0),t}(j);!function(e){e.ADD="ADD",e.REMOVE="REMOVE",e.CHANGE="CHANGE"}(O||(O={}));var S={},N={},k={},A={};function E(e,t){S[e.gameObject.id]||(S[e.gameObject.id]={});var n=S[e.gameObject.id],r=e.name+"_"+t.join(",");if(n[r])return n[r];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return n[r]={property:a,key:t[o]},n[r]}function P(e){var t=e.systemName,n=e.componentName,r=e.component,o=e.prop,a=e.type;N[t].componentObserver.add({component:r,prop:o,type:a,componentName:n})}function M(e){var t,n,r=e.obj,o=e.key,s=e.prop,c=e.component,f=e.componentName;if(void 0!==r)if(o in r){if(Object.defineProperty(r,"_"+o,{enumerable:!1,writable:!0,value:r[o]}),s.deep&&i(r[o]))try{for(var l=u(Object.keys(r[o])),p=l.next();!p.done;p=l.next()){var h=p.value;M({obj:r[o],key:h,prop:s,component:c,componentName:f})}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}Object.defineProperty(r,o,{enumerable:!0,set:function(e){r["_"+o]!==e&&(r["_"+o]=e,function(e){var t=e.prop,n=e.component,r=e.componentName;for(var o in k){var i=(k[o]||{})[r];i&&i.findIndex((function(e){return a(e,t)}))>-1&&P({systemName:o,componentName:r,component:n,prop:t,type:O.CHANGE})}}({prop:s,component:c,componentName:f}))},get:function(){return r["_"+o]}})}else console.error("prop "+o+" not in component: "+f+", Can not observer")}function I(e,t){for(var n in void 0===t&&(t=e.name),k){(k[n]||{})[t]&&N[n].componentObserver.add({component:e,type:O.REMOVE,componentName:t})}!function(e){e.gameObject&&delete S[e.gameObject.id]}(e)}var T=0;var R,D=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.gameObjects=[],r.scene=r,r}return f(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++T,this.addComponent(C,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(C.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,n;if(this._scene!==e){var r=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=u(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):r&&r.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))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}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var n=function(e){return e instanceof j?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[n]){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof j))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){for(var n in void 0===t&&(t=e.name),k)(k[n]||{})[t]&&N[n].componentObserver.add({component:e,type:O.ADD,componentName:t})}(r,r.name),function(e,t){var n,r;if(void 0===t&&(t=e.name),t&&A[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=u(A[t]),i=a.next();!i.done;i=a.next()){var s=i.value,c=E(e,s.prop);M({obj:c.property,key:c.key,prop:s,component:e,componentName:t})}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}}(r,r.name),this.components.push(r),this._componentCache[n]=r,r.awake&&r.awake(),r}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof j?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var n=this.components.splice(t,1)[0];return delete this._componentCache[e],n.onDestroy&&n.onDestroy(),I(n,e),n.gameObject=void 0,n}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof j?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}()),L=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,n=e.prop,r=e.type,o=e.componentName;r===O.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var i=this.events.findIndex((function(e){return e.component===t&&a(e.prop,n)&&e.type===r}));i>-1&&this.events.splice(i,1),this.events.push({gameObject:t.gameObject,component:t,prop:n,type:r,componentName:o})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),G=function(){function e(t){this.started=!1,this.componentObserver=new L,this.__systemDefaultParams=t,this.name=e.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}();!function(e){e.SINGLE="SINGLE",e.MULTI_CANVAS="MULTI_CANVAS"}(R||(R={}));var U,V=function(e){if((e instanceof G||e instanceof j)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof j?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}};!function(e){function t(t){var n,r,o=void 0===t?{}:t,a=o.autoStart,i=void 0===a||a,s=o.frameRate,c=void 0===s?120:s,f=o.systems,l=o.needScene,p=void 0===l||l,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new _({autoStart:!1,frameRate:c}),h.initTicker(),f&&f.length)try{for(var m=u(f),y=m.next();!y.done;y=m.next()){var v=y.value;h.addSystem(v)}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return p&&h.loadScene(new D("scene")),i&&h.start(),h}f(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,n,r,o=(null===(r=null==e?void 0:e.scene)||void 0===r?void 0:r.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var s=u(a),c=s.next();!c.done;c=s.next())i=m(i,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return m(o,i)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof G))return void console.warn("can only add System");n=e}if(!this.systems.find((function(e){return e.constructor===n.constructor}))){n.game=this,n.init&&n.init(n.__systemDefaultParams),function(e,t){k[t.systemName]=t.observerInfo,N[t.systemName]=e}(n,n.constructor),function(e){var t,n,r,o,i=[];e instanceof Array?i.push.apply(i,m(e)):i.push(e);try{for(var s=u(i),c=s.next();!c.done;c=s.next()){var f=c.value;for(var l in f.observerInfo){A[l]=A[l]||[];var p=A[l],h=function(e){-1===p.findIndex((function(t){return a(t,e)}))&&A[l].push(e)};try{for(var y=(r=void 0,u(f.observerInfo[l])),v=y.next();!v.done;v=y.next())h(v.value)}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}(n.constructor);try{n.awake&&n.awake()}catch(e){console.error(n.constructor.systemName+" awake error",e)}return this.systems.push(n),n}console.warn(n.constructor.systemName+" System has been added")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof G&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var n,r,o,a;e.scene&&function(e,t){var n,r,o,a,i,s,c,f;void 0===t&&(t=[]);try{for(var l=u(t),p=l.next();!p.done;p=l.next()){var h=p.value;try{for(var m=(o=void 0,u(h.components)),y=m.next();!y.done;y=m.next()){var v=y.value;try{V(v),v.update&&v.update(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}try{for(var d=u(t),g=d.next();!g.done;g=d.next()){h=g.value;try{for(var b=(c=void 0,u(h.components)),_=b.next();!_.done;_=b.next()){v=_.value;try{v.lateUpdate&&v.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+v.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{_&&!_.done&&(f=b.return)&&f.call(b)}finally{if(c)throw c.error}}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=u(e.systems),s=i.next();!s.done;s=i.next()){var c=s.value;try{V(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}try{for(var f=u(e.systems),l=f.next();!l.done;l=f.next()){c=l.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=u(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,u(s.components)),f=c.next();!f.done;f=c.next()){var l=f.value;try{l.onResume&&l.onResume()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=u(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,n,r,o;try{for(var a=u(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(r=void 0,u(s.components)),f=c.next();!f.done;f=c.next()){var l=f.value;try{l.onPause&&l.onPause()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var n=u(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var n=u(this.systems),r=n.next();!r.done;r=n.next()){var o=r.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,n=e.mode,r=void 0===n?R.SINGLE:n,o=e.params,a=void 0===o?{}:o;if(t){switch(r){case R.SINGLE:this.scene=t;break;case R.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:a})}}}(x);!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"}(U||(U={}));var W=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.multiApps=[],t}return f(n,e),n.prototype.init=function(e){var t=this;this.params=e,this.application=this.createApplication(e),this.containerManager=new v,this.rendererManager=new y({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new g({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(e){var n,r=e.scene,o=e.mode,a=e.params;switch(o){case R.SINGLE:n=t.application;break;case R.MULTI_CANVAS:n=t.createMultiApplication({params:a})}r.canvas=n.view,t.transform.emit("changeScene",{scene:r,mode:o,application:n})}))},n.prototype.registerObserver=function(e){var t,n=this.constructor.observerInfo;for(var r in e)n[r]||(n[r]=[]),(t=n[r]).push.apply(t,m(e[r]))},n.prototype.createMultiApplication=function(e){var t=e.params,n=this.createApplication(t);return this.multiApps.push(n),n},n.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===U.CANVAS&&(e.forceCanvas=!0),s.shared.autoStart=!1,s.shared.stop();var t=new o(l({sharedTicker:!0},e));return!1!==e.preventScroll&&(t.renderer.plugins.interaction.autoPreventDefault=!1,t.renderer.view.style.touchAction="auto"),t},n.prototype.update=function(e){var t,n,r,o,a=this.componentObserver.clear();try{for(var i=u(a),s=i.next();!s.done;s=i.next()){var c=s.value;this.transform.componentChanged(c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}try{for(var f=u(this.game.gameObjects),l=f.next();!l.done;l=f.next()){var p=l.value;this.containerManager.updateTransform({name:p.id,transform:p.transform}),this.rendererManager.update(p)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}this.application.ticker.update(e.time)},n.prototype.lateUpdate=function(){this.transform.update()},n.prototype.onDestroy=function(){var e,t;this.application.destroy();try{for(var n=u(this.multiApps),r=n.next();!r.done;r=n.next()){var o=r.value;o&&o.destroy()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},n.systemName="Renderer",n=p([t.componentObserver({Transform:["_parent"]})],n)}(n),z=function(e){function t(){var t=e.call(this)||this;return t.observerInfo=t.constructor.observerInfo,t}return f(t,e),t.prototype.update=function(){var e,t,n=this.componentObserver.clear();try{for(var r=u(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.componentChanged(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t}(n);export{v as ContainerManager,U as RENDERER_TYPE,z as Renderer,y as RendererManager,W as RendererSystem}; |
{ | ||
"name": "@eva/plugin-renderer", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "@eva/plugin-renderer", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@eva/eva.js": "^1.0.0-alpha.6", | ||
"@eva/renderer-adapter": "^1.0.0-alpha.6", | ||
"@eva/eva.js": "^1.0.0-alpha.7", | ||
"@eva/renderer-adapter": "^1.0.0-alpha.7", | ||
"eventemitter3": "^3.1.2", | ||
@@ -27,0 +27,0 @@ "pixi.js": "^4.8.7" |
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
159926
2935