@eva/plugin-renderer 2.0.1 → 2.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{};var _EVA_IIFE_renderer=function(e,t,n,r){"use strict";function o(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 a(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))}function i(e,t){return e===t||e!=e&&t!=t}function s(e,t){for(var n=e.length;n--;)if(i(e[n][0],t))return n;return-1}var c=Array.prototype.splice;function u(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}u.prototype.clear=function(){this.__data__=[],this.size=0},u.prototype.delete=function(e){var t=this.__data__,n=s(t,e);return!(n<0)&&(n==t.length-1?t.pop():c.call(t,n,1),--this.size,!0)},u.prototype.get=function(e){var t=this.__data__,n=s(t,e);return n<0?void 0:t[n][1]},u.prototype.has=function(e){return s(this.__data__,e)>-1},u.prototype.set=function(e,t){var n=this.__data__,r=s(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var p="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,h=p||l||Function("return this")(),f=h.Symbol,d=Object.prototype,v=d.hasOwnProperty,y=d.toString,_=f?f.toStringTag:void 0;var g=Object.prototype.toString;var m=f?f.toStringTag:void 0;function b(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":m&&m in Object(e)?function(e){var t=v.call(e,_),n=e[_];try{e[_]=void 0;var r=!0}catch(e){}var o=y.call(e);return r&&(t?e[_]=n:delete e[_]),o}(e):function(e){return g.call(e)}(e)}function j(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function O(e){if(!j(e))return!1;var t=b(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var w,E=h["__core-js_shared__"],A=(w=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"";var x=Function.prototype.toString;function S(e){if(null!=e){try{return x.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var C=/^\[object .+?Constructor\]$/,M=Function.prototype,P=Object.prototype,T=M.toString,R=P.hasOwnProperty,I=RegExp("^"+T.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function z(e){return!(!j(e)||(t=e,A&&A in t))&&(O(e)?I:C).test(S(e));var t}function B(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return z(n)?n:void 0}var L=B(h,"Map"),N=B(Object,"create");var V=Object.prototype.hasOwnProperty;var D=Object.prototype.hasOwnProperty;function k(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function W(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function G(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}k.prototype.clear=function(){this.__data__=N?N(null):{},this.size=0},k.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},k.prototype.get=function(e){var t=this.__data__;if(N){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return V.call(t,e)?t[e]:void 0},k.prototype.has=function(e){var t=this.__data__;return N?void 0!==t[e]:D.call(t,e)},k.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=N&&void 0===t?"__lodash_hash_undefined__":t,this},G.prototype.clear=function(){this.size=0,this.__data__={hash:new k,map:new(L||u),string:new k}},G.prototype.delete=function(e){var t=W(this,e).delete(e);return this.size-=t?1:0,t},G.prototype.get=function(e){return W(this,e).get(e)},G.prototype.has=function(e){return W(this,e).has(e)},G.prototype.set=function(e,t){var n=W(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function U(e){var t=this.__data__=new u(e);this.size=t.size}U.prototype.clear=function(){this.__data__=new u,this.size=0},U.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},U.prototype.get=function(e){return this.__data__.get(e)},U.prototype.has=function(e){return this.__data__.has(e)},U.prototype.set=function(e,t){var n=this.__data__;if(n instanceof u){var r=n.__data__;if(!L||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new G(r)}return n.set(e,t),this.size=n.size,this};function $(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new G;++t<n;)this.add(e[t])}function F(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}$.prototype.add=$.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},$.prototype.has=function(e){return this.__data__.has(e)};function Y(e,t,n,r,o,a){var i=1&n,s=e.length,c=t.length;if(s!=c&&!(i&&c>s))return!1;var u=a.get(e),p=a.get(t);if(u&&p)return u==t&&p==e;var l=-1,h=!0,f=2&n?new $:void 0;for(a.set(e,t),a.set(t,e);++l<s;){var d=e[l],v=t[l];if(r)var y=i?r(v,d,l,t,e,a):r(d,v,l,e,t,a);if(void 0!==y){if(y)continue;h=!1;break}if(f){if(!F(t,(function(e,t){if(i=t,!f.has(i)&&(d===e||o(d,e,n,r,a)))return f.push(t);var i}))){h=!1;break}}else if(d!==v&&!o(d,v,n,r,a)){h=!1;break}}return a.delete(e),a.delete(t),h}var K=h.Uint8Array;function X(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function q(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var H=f?f.prototype:void 0,J=H?H.valueOf:void 0;var Q=Array.isArray;var Z=Object.prototype.propertyIsEnumerable,ee=Object.getOwnPropertySymbols,te=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,a=[];++n<r;){var i=e[n];t(i,n,e)&&(a[o++]=i)}return a}(ee(e),(function(t){return Z.call(e,t)})))}:function(){return[]},ne=te;function re(e){return null!=e&&"object"==typeof e}function oe(e){return re(e)&&"[object Arguments]"==b(e)}var ae=Object.prototype,ie=ae.hasOwnProperty,se=ae.propertyIsEnumerable,ce=oe(function(){return arguments}())?oe:function(e){return re(e)&&ie.call(e,"callee")&&!se.call(e,"callee")},ue=ce;var pe="object"==typeof e&&e&&!e.nodeType&&e,le=pe&&"object"==typeof module&&module&&!module.nodeType&&module,he=le&&le.exports===pe?h.Buffer:void 0,fe=(he?he.isBuffer:void 0)||function(){return!1},de=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&de.test(e))&&e>-1&&e%1==0&&e<t}function ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var _e={};_e["[object Float32Array]"]=_e["[object Float64Array]"]=_e["[object Int8Array]"]=_e["[object Int16Array]"]=_e["[object Int32Array]"]=_e["[object Uint8Array]"]=_e["[object Uint8ClampedArray]"]=_e["[object Uint16Array]"]=_e["[object Uint32Array]"]=!0,_e["[object Arguments]"]=_e["[object Array]"]=_e["[object ArrayBuffer]"]=_e["[object Boolean]"]=_e["[object DataView]"]=_e["[object Date]"]=_e["[object Error]"]=_e["[object Function]"]=_e["[object Map]"]=_e["[object Number]"]=_e["[object Object]"]=_e["[object RegExp]"]=_e["[object Set]"]=_e["[object String]"]=_e["[object WeakMap]"]=!1;var ge,me="object"==typeof e&&e&&!e.nodeType&&e,be=me&&"object"==typeof module&&module&&!module.nodeType&&module,je=be&&be.exports===me&&p.process,Oe=function(){try{var e=be&&be.require&&be.require("util").types;return e||je&&je.binding&&je.binding("util")}catch(e){}}(),we=Oe&&Oe.isTypedArray,Ee=we?(ge=we,function(e){return ge(e)}):function(e){return re(e)&&ye(e.length)&&!!_e[b(e)]},Ae=Object.prototype.hasOwnProperty;function xe(e,t){var n=Q(e),r=!n&&ue(e),o=!n&&!r&&fe(e),a=!n&&!r&&!o&&Ee(e),i=n||r||o||a,s=i?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],c=s.length;for(var u in e)!t&&!Ae.call(e,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ve(u,c))||s.push(u);return s}var Se=Object.prototype;var Ce=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Me=Ce,Pe=Object.prototype.hasOwnProperty;function Te(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Se))return Me(e);var t,n,r=[];for(var o in Object(e))Pe.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Re(e){return null!=(t=e)&&ye(t.length)&&!O(t)?xe(e):Te(e);var t}function Ie(e){return function(e,t,n){var r=t(e);return Q(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Re,ne)}var ze=Object.prototype.hasOwnProperty;var Be=B(h,"DataView"),Le=B(h,"Promise"),Ne=B(h,"Set"),Ve=B(h,"WeakMap"),De="[object Map]",ke="[object Promise]",We="[object Set]",Ge="[object WeakMap]",Ue="[object DataView]",$e=S(Be),Fe=S(L),Ye=S(Le),Ke=S(Ne),Xe=S(Ve),qe=b;(Be&&qe(new Be(new ArrayBuffer(1)))!=Ue||L&&qe(new L)!=De||Le&&qe(Le.resolve())!=ke||Ne&&qe(new Ne)!=We||Ve&&qe(new Ve)!=Ge)&&(qe=function(e){var t=b(e),n="[object Object]"==t?e.constructor:void 0,r=n?S(n):"";if(r)switch(r){case $e:return Ue;case Fe:return De;case Ye:return ke;case Ke:return We;case Xe:return Ge}return t});var He=qe,Je="[object Arguments]",Qe="[object Array]",Ze="[object Object]",et=Object.prototype.hasOwnProperty;function tt(e,t,n,r,o,a){var s=Q(e),c=Q(t),u=s?Qe:He(e),p=c?Qe:He(t),l=(u=u==Je?Ze:u)==Ze,h=(p=p==Je?Ze:p)==Ze,f=u==p;if(f&&fe(e)){if(!fe(t))return!1;s=!0,l=!1}if(f&&!l)return a||(a=new U),s||Ee(e)?Y(e,t,n,r,o,a):function(e,t,n,r,o,a,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new K(e),new K(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return i(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var c=X;case"[object Set]":var u=1&r;if(c||(c=q),e.size!=t.size&&!u)return!1;var p=s.get(e);if(p)return p==t;r|=2,s.set(e,t);var l=Y(c(e),c(t),r,o,a,s);return s.delete(e),l;case"[object Symbol]":if(J)return J.call(e)==J.call(t)}return!1}(e,t,u,n,r,o,a);if(!(1&n)){var d=l&&et.call(e,"__wrapped__"),v=h&&et.call(t,"__wrapped__");if(d||v){var y=d?e.value():e,_=v?t.value():t;return a||(a=new U),o(y,_,n,r,a)}}return!!f&&(a||(a=new U),function(e,t,n,r,o,a){var i=1&n,s=Ie(e),c=s.length;if(c!=Ie(t).length&&!i)return!1;for(var u=c;u--;){var p=s[u];if(!(i?p in t:ze.call(t,p)))return!1}var l=a.get(e),h=a.get(t);if(l&&h)return l==t&&h==e;var f=!0;a.set(e,t),a.set(t,e);for(var d=i;++u<c;){var v=e[p=s[u]],y=t[p];if(r)var _=i?r(y,v,p,t,e,a):r(v,y,p,e,t,a);if(!(void 0===_?v===y||o(v,y,n,r,a):_)){f=!1;break}d||(d="constructor"==p)}if(f&&!d){var g=e.constructor,m=t.constructor;g==m||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof m&&m instanceof m||(f=!1)}return a.delete(e),a.delete(t),f}(e,t,n,r,o,a))}function nt(e,t,n,r,o){return e===t||(null==e||null==t||!re(e)&&!re(t)?e!=e&&t!=t:tt(e,t,n,r,nt,o))}var rt=class{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this.rendererSystem.rendererManager,t.containerManager=this.rendererSystem.containerManager,this.renderers.push(t)}componentChanged(e){for(const n of e)for(const e of this.renderers){const r=e.observerInfo[n.componentName];if(r){if([t.OBSERVER_TYPE.ADD,t.OBSERVER_TYPE.REMOVE].indexOf(n.type)>-1){try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject.name}, ${n.componentName} is error.`,n,e)}continue}if(r.findIndex((e=>{return t=e,r=n.prop,nt(t,r);var t,r}))>-1)try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject&&n.gameObject.name}, ${n.componentName} is componentChanged error.`,n,e)}}}}update(e){for(const t of e.components)for(const n of this.renderers){const r=[];if(n.observerInfo[t.name]&&-1===r.indexOf(e)){r.push(e);try{n.rendererUpdate&&n.rendererUpdate(e)}catch(n){console.info(`gameObject: ${e.name}, ${t.name} is update error`,n)}}}}};class ot{constructor(){this.containerMap={}}addContainer({name:e,container:t,gameObject:n}){this.containerMap[e]=t,t.gName=n.name||e}getContainer(e){return this.containerMap[e]}removeContainer(e){const t=this.containerMap[e];t&&t.destroy({children:!0}),delete this.containerMap[e]}updateTransform({name:e,transform:t}){const n=this.containerMap[e];if(!n||!t)return;const{anchor:r,origin:o,position:a,rotation:i,scale:s,size:c,skew:u}=t;n.rotation=i,n.scale=s,n.pivot.x=c.width*o.x,n.pivot.y=c.height*o.y,n.skew=u;let p=a.x,l=a.y;if(t.parent){const e=t.parent;p+=e.size.width*r.x,l+=e.size.height*r.y}n.position={x:p,y:l}}}var at=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((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,u,p=this._events[s],l=arguments.length;if(p.fn){switch(p.once&&this.removeListener(e,p.fn,void 0,!0),l){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,t),!0;case 3:return p.fn.call(p.context,t,r),!0;case 4:return p.fn.call(p.context,t,r,o),!0;case 5:return p.fn.call(p.context,t,r,o,a),!0;case 6:return p.fn.call(p.context,t,r,o,a,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];p.fn.apply(p.context,c)}else{var h,f=p.length;for(u=0;u<f;u++)switch(p[u].once&&this.removeListener(e,p[u].fn,void 0,!0),l){case 1:p[u].fn.call(p[u].context);break;case 2:p[u].fn.call(p[u].context,t);break;case 3:p[u].fn.call(p[u].context,t,r);break;case 4:p[u].fn.call(p[u].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];p[u].fn.apply(p[u].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,u=[],p=s.length;c<p;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[a]=1===u.length?u[0]:u: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})),it=at;let st=class extends it{constructor({system:e,containerManager:t}){super(),this.name="Transform",this.waitRemoveIds=[],this.waitChangeScenes=[],this.containerManager=t,this.init(e)}init(e){this.system=e,this.on("changeScene",(({scene:e,mode:t,application:n})=>{this.waitChangeScenes.push({scene:e,mode:t,application:n})}))}update(){for(const e of this.waitRemoveIds)this.containerManager.removeContainer(e);this.waitRemoveIds=[];for(const e of this.waitChangeScenes){const t=this.containerManager.getContainer(e.scene.id);t&&(e.application.stage.removeChildren(),e.application.stage.addChild(t))}this.waitChangeScenes=[]}componentChanged(e){e.type===t.OBSERVER_TYPE.ADD?this.addContainer(e):e.type===t.OBSERVER_TYPE.CHANGE?this.change(e):e.type===t.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(e.gameObject.id)}addContainer(e){const t=new n.Container;t.label=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t,gameObject:e.gameObject});const r=e.component;Object.defineProperty(r,"worldTransform",{get:()=>t.renderGroup||t.parentRenderGroup?t.worldTransform:void 0})}change(e){const t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));const n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{const t=this.containerManager.getContainer(e.gameObject.id);t.parent&&t.parent.removeChild(t)}}destroy(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null}};st=o([t.decorators.componentObserver({Transform:["_parent"]})],st);var ct,ut=st;e.RENDERER_TYPE=void 0,(ct=e.RENDERER_TYPE||(e.RENDERER_TYPE={}))[ct.UNKNOWN=0]="UNKNOWN",ct[ct.WEBGL=1]="WEBGL",ct[ct.CANVAS=2]="CANVAS";let pt=class extends t.System{constructor(){super(...arguments),this.multiApps=[]}init(e){return a(this,void 0,void 0,(function*(){this.params=e,this.application=yield this.createApplication(e),this.containerManager=new ot,this.rendererManager=new rt({game:this.game,rendererSystem:this}),this.game.canvas=this.application.canvas,this.transform=new ut({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(({scene:e,mode:n,params:r})=>a(this,void 0,void 0,(function*(){let o;switch(n){case t.LOAD_SCENE_MODE.SINGLE:o=this.application;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:o=yield this.createMultiApplication({params:r})}e.canvas=o.canvas,this.transform.emit("changeScene",{scene:e,mode:n,application:o})})))),this.game.on("pauseScene",(({scene:e})=>{this.onPauseScene(e)})),this.game.on("startScene",(({scene:e})=>{this.onStartScene(e)})),this.game.on("sceneDestroyed",(({scene:e})=>a(this,void 0,void 0,(function*(){const t=this.multiApps.findIndex((t=>t.canvas===e.canvas));if(t>-1){this.multiApps.splice(t,1)[0].destroy(),e.destroy()}}))))}))}registerObserver(e){const t=this.constructor.observerInfo;for(const n in e)t[n]||(t[n]=[]),t[n].push(...e[n])}createMultiApplication({params:e}){return a(this,void 0,void 0,(function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t}))}createApplication(e){return a(this,void 0,void 0,(function*(){const t=new n.Application;var o;return e.debugMode&&(globalThis.__PIXI_APP__=t),yield t.init(_extends(_extends({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((o=t.renderer).events.autoPreventDefault=!1,o.canvas.style.touchAction="auto"):(e=>{e.events.autoPreventDefault=!0,e.canvas.style.touchAction="none"})(t.renderer)),r.Ticker.shared.stop(),r.Ticker.shared.autoStart=!1,t}))}update(){const e=this.componentObserver.clear();for(const t of e)this.transform.componentChanged(t);for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(e)}lateUpdate(e){this.transform.update(),this.application.ticker.update(e.time)}onDestroy(){this.application.destroy();for(const e of this.multiApps)e&&e.destroy();this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null}resize(e,t){this.params.width=e,this.params.height=t,this.application.renderer.resize(e,t)}getApplicationByScene(e){const t=this.multiApps.findIndex((t=>t.canvas===e.canvas));if(t>-1){return this.multiApps[t]}console.warn("application not found")}onPauseScene(e){const t=this.getApplicationByScene(e);t&&t.stop()}onStartScene(e){const t=this.getApplicationByScene(e);t&&t.start()}resizeByScene(e,t,n){const r=this.getApplicationByScene(e);r&&r.renderer.resize(t,n)}};pt.systemName="Renderer",pt=o([t.decorators.componentObserver({Transform:["_parent"]})],pt);var lt=pt;let ht;function ft(e){e.addPreProcessResourceHandler((function(e){var t,n,r;let o=null===(n=null===(t=e.src)||void 0===t?void 0:t.image)||void 0===n?void 0:n.texture;if(!o)return;Array.isArray(o)||(o=[o]);const a=null!==(r=function(){if(ht)return ht;const e=document.createElement("canvas").getContext("webgl2");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{s3tc:!1,etc:!1,etc1:!1,pvrtc:!1,atc:!1,astc:!1};ht={s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc")||!!e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:!!e.getExtension("WEBGL_compressed_texture_atc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc")};try{console.log("Eva.js Supported Compressed Texture Format List: "+Object.keys(ht).filter((e=>ht[e])).join(", "))}catch(e){}return ht}())&&void 0!==r?r:{};let i=o.find((e=>a[e.type]));i&&_extends(e.src.image,i)}))}class dt extends t.System{constructor(e){super(e),this.asyncIdMap={},this.observerInfo=this.constructor.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}return e.ContainerManager=ot,e.Renderer=dt,e.RendererManager=rt,e.RendererSystem=lt,e.registerKtx2CompressedTexture=function(e){r.setKTXTranscoderPath(e),r.extensions.add(r.loadKTX2),r.extensions.add(r.resolveCompressedTextureUrl),r.extensions.add(r.detectCompressed),ft(t.resource)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||_EVA_IIFE_renderer;
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{};var _EVA_IIFE_renderer=function(e,t,n,r){"use strict";function o(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 a(e,t,n,r){return new(n||(n=Promise))(function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}c((r=r.apply(e,t||[])).next())})}function i(e,t){return e===t||e!=e&&t!=t}function s(e,t){for(var n=e.length;n--;)if(i(e[n][0],t))return n;return-1}var c=Array.prototype.splice;function u(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}u.prototype.clear=function(){this.__data__=[],this.size=0},u.prototype.delete=function(e){var t=this.__data__,n=s(t,e);return!(n<0)&&(n==t.length-1?t.pop():c.call(t,n,1),--this.size,!0)},u.prototype.get=function(e){var t=this.__data__,n=s(t,e);return n<0?void 0:t[n][1]},u.prototype.has=function(e){return s(this.__data__,e)>-1},u.prototype.set=function(e,t){var n=this.__data__,r=s(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var p="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,h=p||l||Function("return this")(),f=h.Symbol,d=Object.prototype,v=d.hasOwnProperty,y=d.toString,_=f?f.toStringTag:void 0;var g=Object.prototype.toString;var m=f?f.toStringTag:void 0;function b(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":m&&m in Object(e)?function(e){var t=v.call(e,_),n=e[_];try{e[_]=void 0;var r=!0}catch(e){}var o=y.call(e);return r&&(t?e[_]=n:delete e[_]),o}(e):function(e){return g.call(e)}(e)}function j(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function O(e){if(!j(e))return!1;var t=b(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var w,E=h["__core-js_shared__"],A=(w=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"";var x=Function.prototype.toString;function S(e){if(null!=e){try{return x.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var C=/^\[object .+?Constructor\]$/,M=Function.prototype,P=Object.prototype,T=M.toString,R=P.hasOwnProperty,I=RegExp("^"+T.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function z(e){return!(!j(e)||(t=e,A&&A in t))&&(O(e)?I:C).test(S(e));var t}function B(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return z(n)?n:void 0}var L=B(h,"Map"),N=B(Object,"create");var V=Object.prototype.hasOwnProperty;var D=Object.prototype.hasOwnProperty;function k(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function W(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function G(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}k.prototype.clear=function(){this.__data__=N?N(null):{},this.size=0},k.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},k.prototype.get=function(e){var t=this.__data__;if(N){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return V.call(t,e)?t[e]:void 0},k.prototype.has=function(e){var t=this.__data__;return N?void 0!==t[e]:D.call(t,e)},k.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=N&&void 0===t?"__lodash_hash_undefined__":t,this},G.prototype.clear=function(){this.size=0,this.__data__={hash:new k,map:new(L||u),string:new k}},G.prototype.delete=function(e){var t=W(this,e).delete(e);return this.size-=t?1:0,t},G.prototype.get=function(e){return W(this,e).get(e)},G.prototype.has=function(e){return W(this,e).has(e)},G.prototype.set=function(e,t){var n=W(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function U(e){var t=this.__data__=new u(e);this.size=t.size}U.prototype.clear=function(){this.__data__=new u,this.size=0},U.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},U.prototype.get=function(e){return this.__data__.get(e)},U.prototype.has=function(e){return this.__data__.has(e)},U.prototype.set=function(e,t){var n=this.__data__;if(n instanceof u){var r=n.__data__;if(!L||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new G(r)}return n.set(e,t),this.size=n.size,this};function $(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new G;++t<n;)this.add(e[t])}function F(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}$.prototype.add=$.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},$.prototype.has=function(e){return this.__data__.has(e)};function Y(e,t,n,r,o,a){var i=1&n,s=e.length,c=t.length;if(s!=c&&!(i&&c>s))return!1;var u=a.get(e),p=a.get(t);if(u&&p)return u==t&&p==e;var l=-1,h=!0,f=2&n?new $:void 0;for(a.set(e,t),a.set(t,e);++l<s;){var d=e[l],v=t[l];if(r)var y=i?r(v,d,l,t,e,a):r(d,v,l,e,t,a);if(void 0!==y){if(y)continue;h=!1;break}if(f){if(!F(t,function(e,t){if(i=t,!f.has(i)&&(d===e||o(d,e,n,r,a)))return f.push(t);var i})){h=!1;break}}else if(d!==v&&!o(d,v,n,r,a)){h=!1;break}}return a.delete(e),a.delete(t),h}var K=h.Uint8Array;function X(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function q(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var H=f?f.prototype:void 0,J=H?H.valueOf:void 0;var Q=Array.isArray;var Z=Object.prototype.propertyIsEnumerable,ee=Object.getOwnPropertySymbols,te=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,a=[];++n<r;){var i=e[n];t(i,n,e)&&(a[o++]=i)}return a}(ee(e),function(t){return Z.call(e,t)}))}:function(){return[]},ne=te;function re(e){return null!=e&&"object"==typeof e}function oe(e){return re(e)&&"[object Arguments]"==b(e)}var ae=Object.prototype,ie=ae.hasOwnProperty,se=ae.propertyIsEnumerable,ce=oe(function(){return arguments}())?oe:function(e){return re(e)&&ie.call(e,"callee")&&!se.call(e,"callee")},ue=ce;var pe="object"==typeof e&&e&&!e.nodeType&&e,le=pe&&"object"==typeof module&&module&&!module.nodeType&&module,he=le&&le.exports===pe?h.Buffer:void 0,fe=(he?he.isBuffer:void 0)||function(){return!1},de=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&de.test(e))&&e>-1&&e%1==0&&e<t}function ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var _e={};_e["[object Float32Array]"]=_e["[object Float64Array]"]=_e["[object Int8Array]"]=_e["[object Int16Array]"]=_e["[object Int32Array]"]=_e["[object Uint8Array]"]=_e["[object Uint8ClampedArray]"]=_e["[object Uint16Array]"]=_e["[object Uint32Array]"]=!0,_e["[object Arguments]"]=_e["[object Array]"]=_e["[object ArrayBuffer]"]=_e["[object Boolean]"]=_e["[object DataView]"]=_e["[object Date]"]=_e["[object Error]"]=_e["[object Function]"]=_e["[object Map]"]=_e["[object Number]"]=_e["[object Object]"]=_e["[object RegExp]"]=_e["[object Set]"]=_e["[object String]"]=_e["[object WeakMap]"]=!1;var ge,me="object"==typeof e&&e&&!e.nodeType&&e,be=me&&"object"==typeof module&&module&&!module.nodeType&&module,je=be&&be.exports===me&&p.process,Oe=function(){try{var e=be&&be.require&&be.require("util").types;return e||je&&je.binding&&je.binding("util")}catch(e){}}(),we=Oe&&Oe.isTypedArray,Ee=we?(ge=we,function(e){return ge(e)}):function(e){return re(e)&&ye(e.length)&&!!_e[b(e)]},Ae=Object.prototype.hasOwnProperty;function xe(e,t){var n=Q(e),r=!n&&ue(e),o=!n&&!r&&fe(e),a=!n&&!r&&!o&&Ee(e),i=n||r||o||a,s=i?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],c=s.length;for(var u in e)!t&&!Ae.call(e,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ve(u,c))||s.push(u);return s}var Se=Object.prototype;var Ce=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Me=Ce,Pe=Object.prototype.hasOwnProperty;function Te(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Se))return Me(e);var t,n,r=[];for(var o in Object(e))Pe.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Re(e){return null!=(t=e)&&ye(t.length)&&!O(t)?xe(e):Te(e);var t}function Ie(e){return function(e,t,n){var r=t(e);return Q(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Re,ne)}var ze=Object.prototype.hasOwnProperty;var Be=B(h,"DataView"),Le=B(h,"Promise"),Ne=B(h,"Set"),Ve=B(h,"WeakMap"),De="[object Map]",ke="[object Promise]",We="[object Set]",Ge="[object WeakMap]",Ue="[object DataView]",$e=S(Be),Fe=S(L),Ye=S(Le),Ke=S(Ne),Xe=S(Ve),qe=b;(Be&&qe(new Be(new ArrayBuffer(1)))!=Ue||L&&qe(new L)!=De||Le&&qe(Le.resolve())!=ke||Ne&&qe(new Ne)!=We||Ve&&qe(new Ve)!=Ge)&&(qe=function(e){var t=b(e),n="[object Object]"==t?e.constructor:void 0,r=n?S(n):"";if(r)switch(r){case $e:return Ue;case Fe:return De;case Ye:return ke;case Ke:return We;case Xe:return Ge}return t});var He=qe,Je="[object Arguments]",Qe="[object Array]",Ze="[object Object]",et=Object.prototype.hasOwnProperty;function tt(e,t,n,r,o,a){var s=Q(e),c=Q(t),u=s?Qe:He(e),p=c?Qe:He(t),l=(u=u==Je?Ze:u)==Ze,h=(p=p==Je?Ze:p)==Ze,f=u==p;if(f&&fe(e)){if(!fe(t))return!1;s=!0,l=!1}if(f&&!l)return a||(a=new U),s||Ee(e)?Y(e,t,n,r,o,a):function(e,t,n,r,o,a,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new K(e),new K(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return i(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var c=X;case"[object Set]":var u=1&r;if(c||(c=q),e.size!=t.size&&!u)return!1;var p=s.get(e);if(p)return p==t;r|=2,s.set(e,t);var l=Y(c(e),c(t),r,o,a,s);return s.delete(e),l;case"[object Symbol]":if(J)return J.call(e)==J.call(t)}return!1}(e,t,u,n,r,o,a);if(!(1&n)){var d=l&&et.call(e,"__wrapped__"),v=h&&et.call(t,"__wrapped__");if(d||v){var y=d?e.value():e,_=v?t.value():t;return a||(a=new U),o(y,_,n,r,a)}}return!!f&&(a||(a=new U),function(e,t,n,r,o,a){var i=1&n,s=Ie(e),c=s.length;if(c!=Ie(t).length&&!i)return!1;for(var u=c;u--;){var p=s[u];if(!(i?p in t:ze.call(t,p)))return!1}var l=a.get(e),h=a.get(t);if(l&&h)return l==t&&h==e;var f=!0;a.set(e,t),a.set(t,e);for(var d=i;++u<c;){var v=e[p=s[u]],y=t[p];if(r)var _=i?r(y,v,p,t,e,a):r(v,y,p,e,t,a);if(!(void 0===_?v===y||o(v,y,n,r,a):_)){f=!1;break}d||(d="constructor"==p)}if(f&&!d){var g=e.constructor,m=t.constructor;g==m||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof m&&m instanceof m||(f=!1)}return a.delete(e),a.delete(t),f}(e,t,n,r,o,a))}function nt(e,t,n,r,o){return e===t||(null==e||null==t||!re(e)&&!re(t)?e!=e&&t!=t:tt(e,t,n,r,nt,o))}var rt=class{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this.rendererSystem.rendererManager,t.containerManager=this.rendererSystem.containerManager,this.renderers.push(t)}componentChanged(e){for(const n of e)for(const e of this.renderers){const r=e.observerInfo[n.componentName];if(r){if([t.OBSERVER_TYPE.ADD,t.OBSERVER_TYPE.REMOVE].indexOf(n.type)>-1){try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject.name}, ${n.componentName} is error.`,n,e)}continue}if(r.findIndex(e=>{return t=e,r=n.prop,nt(t,r);var t,r})>-1)try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject&&n.gameObject.name}, ${n.componentName} is componentChanged error.`,n,e)}}}}update(e){for(const t of e.components)for(const n of this.renderers){const r=[];if(n.observerInfo[t.name]&&-1===r.indexOf(e)){r.push(e);try{n.rendererUpdate&&n.rendererUpdate(e)}catch(n){console.info(`gameObject: ${e.name}, ${t.name} is update error`,n)}}}}};class ot{constructor(){this.containerMap={}}addContainer({name:e,container:t,gameObject:n}){this.containerMap[e]=t,t.gName=n.name||e}getContainer(e){return this.containerMap[e]}removeContainer(e){const t=this.containerMap[e];t&&t.destroy({children:!0}),delete this.containerMap[e]}updateTransform({name:e,transform:t}){const n=this.containerMap[e];if(!n||!t)return;const{anchor:r,origin:o,position:a,rotation:i,scale:s,size:c,skew:u}=t;n.rotation=i,n.scale=s,n.pivot.x=c.width*o.x,n.pivot.y=c.height*o.y,n.skew=u;let p=a.x,l=a.y;if(t.parent){const e=t.parent;p+=e.size.width*r.x,l+=e.size.height*r.y}n.position={x:p,y:l}}}var at=function(e){var t={exports:{}};return e(t,t.exports),t.exports}(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,u,p=this._events[s],l=arguments.length;if(p.fn){switch(p.once&&this.removeListener(e,p.fn,void 0,!0),l){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,t),!0;case 3:return p.fn.call(p.context,t,r),!0;case 4:return p.fn.call(p.context,t,r,o),!0;case 5:return p.fn.call(p.context,t,r,o,a),!0;case 6:return p.fn.call(p.context,t,r,o,a,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];p.fn.apply(p.context,c)}else{var h,f=p.length;for(u=0;u<f;u++)switch(p[u].once&&this.removeListener(e,p[u].fn,void 0,!0),l){case 1:p[u].fn.call(p[u].context);break;case 2:p[u].fn.call(p[u].context,t);break;case 3:p[u].fn.call(p[u].context,t,r);break;case 4:p[u].fn.call(p[u].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];p[u].fn.apply(p[u].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,u=[],p=s.length;c<p;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[a]=1===u.length?u[0]:u: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}),it=at;let st=class extends it{constructor({system:e,containerManager:t}){super(),this.name="Transform",this.waitRemoveIds=[],this.waitChangeScenes=[],this.containerManager=t,this.init(e)}init(e){this.system=e,this.on("changeScene",({scene:e,mode:t,application:n})=>{this.waitChangeScenes.push({scene:e,mode:t,application:n})})}update(){for(const e of this.waitRemoveIds)this.containerManager.removeContainer(e);this.waitRemoveIds=[];for(const e of this.waitChangeScenes){const t=this.containerManager.getContainer(e.scene.id);t&&(e.application.stage.removeChildren(),e.application.stage.addChild(t))}this.waitChangeScenes=[]}componentChanged(e){e.type===t.OBSERVER_TYPE.ADD?this.addContainer(e):e.type===t.OBSERVER_TYPE.CHANGE?this.change(e):e.type===t.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(e.gameObject.id)}addContainer(e){const t=new n.Container;t.label=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t,gameObject:e.gameObject});const r=e.component;Object.defineProperty(r,"worldTransform",{get:()=>t.renderGroup||t.parentRenderGroup?t.worldTransform:void 0})}change(e){const t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));const n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{const t=this.containerManager.getContainer(e.gameObject.id);t.parent&&t.parent.removeChild(t)}}destroy(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null}};st=o([t.decorators.componentObserver({Transform:["_parent"]})],st);var ct,ut=st;e.RENDERER_TYPE=void 0,(ct=e.RENDERER_TYPE||(e.RENDERER_TYPE={}))[ct.UNKNOWN=0]="UNKNOWN",ct[ct.WEBGL=1]="WEBGL",ct[ct.CANVAS=2]="CANVAS";let pt=class extends t.System{constructor(){super(...arguments),this.multiApps=[]}init(e){return a(this,void 0,void 0,function*(){this.params=e,this.application=yield this.createApplication(e),this.containerManager=new ot,this.rendererManager=new rt({game:this.game,rendererSystem:this}),this.game.canvas=this.application.canvas,this.transform=new ut({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",({scene:e,mode:n,params:r})=>a(this,void 0,void 0,function*(){let o;switch(n){case t.LOAD_SCENE_MODE.SINGLE:o=this.application;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:o=yield this.createMultiApplication({params:r})}e.canvas=o.canvas,this.transform.emit("changeScene",{scene:e,mode:n,application:o})})),this.game.on("pauseScene",({scene:e})=>{this.onPauseScene(e)}),this.game.on("startScene",({scene:e})=>{this.onStartScene(e)}),this.game.on("sceneDestroyed",({scene:e})=>a(this,void 0,void 0,function*(){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){this.multiApps.splice(t,1)[0].destroy(),e.destroy()}}))})}registerObserver(e){const t=this.constructor.observerInfo;for(const n in e)t[n]||(t[n]=[]),t[n].push(...e[n])}createMultiApplication({params:e}){return a(this,void 0,void 0,function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t})}createApplication(e){return a(this,void 0,void 0,function*(){const t=new n.Application;var o;return e.debugMode&&(globalThis.__PIXI_APP__=t),yield t.init(_extends(_extends({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((o=t.renderer).events.autoPreventDefault=!1,o.canvas.style.touchAction="auto"):(e=>{e.events.autoPreventDefault=!0,e.canvas.style.touchAction="none"})(t.renderer)),r.Ticker.shared.stop(),r.Ticker.shared.autoStart=!1,t})}update(){const e=this.componentObserver.clear();for(const t of e)this.transform.componentChanged(t);for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(e)}lateUpdate(e){this.transform.update(),this.application.ticker.update(e.time)}onDestroy(){this.application.destroy();for(const e of this.multiApps)e&&e.destroy();this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null}resize(e,t){this.params.width=e,this.params.height=t,this.application.renderer.resize(e,t)}getApplicationByScene(e){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){return this.multiApps[t]}console.warn("application not found")}onPauseScene(e){const t=this.getApplicationByScene(e);t&&t.stop()}onStartScene(e){const t=this.getApplicationByScene(e);t&&t.start()}resizeByScene(e,t,n){const r=this.getApplicationByScene(e);r&&r.renderer.resize(t,n)}};pt.systemName="Renderer",pt=o([t.decorators.componentObserver({Transform:["_parent"]})],pt);var lt=pt;let ht;function ft(e){e.addPreProcessResourceHandler(function(e){var t,n,r;let o=null===(n=null===(t=e.src)||void 0===t?void 0:t.image)||void 0===n?void 0:n.texture;if(!o)return;Array.isArray(o)||(o=[o]);const a=null!==(r=function(){if(ht)return ht;const e=document.createElement("canvas").getContext("webgl2");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{s3tc:!1,etc:!1,etc1:!1,pvrtc:!1,atc:!1,astc:!1};ht={s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc")||!!e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:!!e.getExtension("WEBGL_compressed_texture_atc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc")};try{console.log("Eva.js Supported Compressed Texture Format List: "+Object.keys(ht).filter(e=>ht[e]).join(", "))}catch(e){}return ht}())&&void 0!==r?r:{};let i=o.find(e=>a[e.type]);i&&_extends(e.src.image,i)})}class dt extends t.System{constructor(e){super(e),this.asyncIdMap={},this.observerInfo=this.constructor.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}return e.ContainerManager=ot,e.Renderer=dt,e.RendererManager=rt,e.RendererSystem=lt,e.registerKtx2CompressedTexture=function(e){r.setKTXTranscoderPath(e),r.extensions.add(r.loadKTX2),r.extensions.add(r.resolveCompressedTextureUrl),r.extensions.add(r.detectCompressed),ft(t.resource)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||_EVA_IIFE_renderer;
|
|
@@ -13,19 +13,19 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
13
13
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
14
14
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
Copyright (c) Microsoft Corporation.
|
|
18
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
19
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
20
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
/******************************************************************************
|
|
17
|
+
Copyright (c) Microsoft Corporation.
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
25
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
19
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
+
purpose with or without fee is hereby granted.
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
29
29
|
***************************************************************************** */
|
|
30
30
|
|
|
31
31
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -36,13 +36,19 @@ function __decorate(decorators, target, key, desc) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
40
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
41
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
42
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
44
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
45
|
});
|
|
45
|
-
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
49
|
+
var e = new Error(message);
|
|
50
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
51
|
+
};
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* 渲染管理器类
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/renderer-adapter"),n=require("lodash-es/isEqual"),r=require("eventemitter3"),s=require("pixi.js");function a(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=a(n),i=a(r);
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
6
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
|
|
8
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
9
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
10
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
11
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
12
|
-
|
|
13
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
|
-
and limitations under the License.
|
|
15
|
-
***************************************************************************** */
|
|
16
|
-
function c(e,t,n,r){var s,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var i=e.length-1;i>=0;i--)(s=e[i])&&(o=(a<3?s(o):a>3?s(t,n,o):s(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function p(e,t,n,r){return new(n||(n=Promise))((function(s,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function i(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(o,i)}c((r=r.apply(e,t||[])).next())}))}var d=class{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this.rendererSystem.rendererManager,t.containerManager=this.rendererSystem.containerManager,this.renderers.push(t)}componentChanged(t){for(const n of t)for(const t of this.renderers){const r=t.observerInfo[n.componentName];if(r){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(n.type)>-1){try{t.componentChanged&&t.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject.name}, ${n.componentName} is error.`,n,e)}continue}if(r.findIndex((e=>o(e,n.prop)))>-1)try{t.componentChanged&&t.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject&&n.gameObject.name}, ${n.componentName} is componentChanged error.`,n,e)}}}}update(e){for(const t of e.components)for(const n of this.renderers){const r=[];if(n.observerInfo[t.name]&&-1===r.indexOf(e)){r.push(e);try{n.rendererUpdate&&n.rendererUpdate(e)}catch(n){console.info(`gameObject: ${e.name}, ${t.name} is update error`,n)}}}}};class h{constructor(){this.containerMap={}}addContainer({name:e,container:t,gameObject:n}){this.containerMap[e]=t,t.gName=n.name||e}getContainer(e){return this.containerMap[e]}removeContainer(e){const t=this.containerMap[e];t&&t.destroy({children:!0}),delete this.containerMap[e]}updateTransform({name:e,transform:t}){const n=this.containerMap[e];if(!n||!t)return;const{anchor:r,origin:s,position:a,rotation:o,scale:i,size:c,skew:p}=t;n.rotation=o,n.scale=i,n.pivot.x=c.width*s.x,n.pivot.y=c.height*s.y,n.skew=p;let d=a.x,h=a.y;if(t.parent){const e=t.parent;d+=e.size.width*r.x,h+=e.size.height*r.y}n.position={x:d,y:h}}}let m=class extends i{constructor({system:e,containerManager:t}){super(),this.name="Transform",this.waitRemoveIds=[],this.waitChangeScenes=[],this.containerManager=t,this.init(e)}init(e){this.system=e,this.on("changeScene",(({scene:e,mode:t,application:n})=>{this.waitChangeScenes.push({scene:e,mode:t,application:n})}))}update(){for(const e of this.waitRemoveIds)this.containerManager.removeContainer(e);this.waitRemoveIds=[];for(const e of this.waitChangeScenes){const t=this.containerManager.getContainer(e.scene.id);t&&(e.application.stage.removeChildren(),e.application.stage.addChild(t))}this.waitChangeScenes=[]}componentChanged(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)}addContainer(e){const n=new t.Container;n.label=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:n,gameObject:e.gameObject});const r=e.component;Object.defineProperty(r,"worldTransform",{get:()=>n.renderGroup||n.parentRenderGroup?n.worldTransform:void 0})}change(e){const t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));const n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{const t=this.containerManager.getContainer(e.gameObject.id);t.parent&&t.parent.removeChild(t)}}destroy(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null}};m=c([e.decorators.componentObserver({Transform:["_parent"]})],m);var l,u=m;exports.RENDERER_TYPE=void 0,(l=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[l.UNKNOWN=0]="UNKNOWN",l[l.WEBGL=1]="WEBGL",l[l.CANVAS=2]="CANVAS";let g=class extends e.System{constructor(){super(...arguments),this.multiApps=[]}init(t){return p(this,void 0,void 0,(function*(){this.params=t,this.application=yield this.createApplication(t),this.containerManager=new h,this.rendererManager=new d({game:this.game,rendererSystem:this}),this.game.canvas=this.application.canvas,this.transform=new u({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(({scene:t,mode:n,params:r})=>p(this,void 0,void 0,(function*(){let s;switch(n){case e.LOAD_SCENE_MODE.SINGLE:s=this.application;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:s=yield this.createMultiApplication({params:r})}t.canvas=s.canvas,this.transform.emit("changeScene",{scene:t,mode:n,application:s})})))),this.game.on("pauseScene",(({scene:e})=>{this.onPauseScene(e)})),this.game.on("startScene",(({scene:e})=>{this.onStartScene(e)})),this.game.on("sceneDestroyed",(({scene:e})=>p(this,void 0,void 0,(function*(){const t=this.multiApps.findIndex((t=>t.canvas===e.canvas));if(t>-1){this.multiApps.splice(t,1)[0].destroy(),e.destroy()}}))))}))}registerObserver(e){const t=this.constructor.observerInfo;for(const n in e)t[n]||(t[n]=[]),t[n].push(...e[n])}createMultiApplication({params:e}){return p(this,void 0,void 0,(function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t}))}createApplication(e){return p(this,void 0,void 0,(function*(){const n=new t.Application;var r;return e.debugMode&&(globalThis.__PIXI_APP__=n),yield n.init(Object.assign(Object.assign({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((r=n.renderer).events.autoPreventDefault=!1,r.canvas.style.touchAction="auto"):(e=>{e.events.autoPreventDefault=!0,e.canvas.style.touchAction="none"})(n.renderer)),s.Ticker.shared.stop(),s.Ticker.shared.autoStart=!1,n}))}update(){const e=this.componentObserver.clear();for(const t of e)this.transform.componentChanged(t);for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(e)}lateUpdate(e){this.transform.update(),this.application.ticker.update(e.time)}onDestroy(){this.application.destroy();for(const e of this.multiApps)e&&e.destroy();this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null}resize(e,t){this.params.width=e,this.params.height=t,this.application.renderer.resize(e,t)}getApplicationByScene(e){const t=this.multiApps.findIndex((t=>t.canvas===e.canvas));if(t>-1){return this.multiApps[t]}console.warn("application not found")}onPauseScene(e){const t=this.getApplicationByScene(e);t&&t.stop()}onStartScene(e){const t=this.getApplicationByScene(e);t&&t.start()}resizeByScene(e,t,n){const r=this.getApplicationByScene(e);r&&r.renderer.resize(t,n)}};g.systemName="Renderer",g=c([e.decorators.componentObserver({Transform:["_parent"]})],g);var f=g;let v;function y(e){e.addPreProcessResourceHandler((function(e){var t,n,r;let s=null===(n=null===(t=e.src)||void 0===t?void 0:t.image)||void 0===n?void 0:n.texture;if(!s)return;Array.isArray(s)||(s=[s]);const a=null!==(r=function(){if(v)return v;const e=document.createElement("canvas").getContext("webgl2");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{s3tc:!1,etc:!1,etc1:!1,pvrtc:!1,atc:!1,astc:!1};v={s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc")||!!e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:!!e.getExtension("WEBGL_compressed_texture_atc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc")};try{console.log("Eva.js Supported Compressed Texture Format List: "+Object.keys(v).filter((e=>v[e])).join(", "))}catch(e){}return v}())&&void 0!==r?r:{};let o=s.find((e=>a[e.type]));o&&Object.assign(e.src.image,o)}))}class E extends e.System{constructor(e){super(e),this.asyncIdMap={},this.observerInfo=this.constructor.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}exports.ContainerManager=h,exports.Renderer=E,exports.RendererManager=d,exports.RendererSystem=f,exports.registerKtx2CompressedTexture=function(t){s.setKTXTranscoderPath(t),s.extensions.add(s.loadKTX2),s.extensions.add(s.resolveCompressedTextureUrl),s.extensions.add(s.detectCompressed),y(e.resource)};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/renderer-adapter"),n=require("lodash-es/isEqual"),r=require("eventemitter3"),s=require("pixi.js");function a(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=a(n),i=a(r);function c(e,t,n,r){var s,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var i=e.length-1;i>=0;i--)(s=e[i])&&(o=(a<3?s(o):a>3?s(t,n,o):s(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function p(e,t,n,r){return new(n||(n=Promise))(function(s,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function i(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,i)}c((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;var d=class{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this.rendererSystem.rendererManager,t.containerManager=this.rendererSystem.containerManager,this.renderers.push(t)}componentChanged(t){for(const n of t)for(const t of this.renderers){const r=t.observerInfo[n.componentName];if(r){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(n.type)>-1){try{t.componentChanged&&t.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject.name}, ${n.componentName} is error.`,n,e)}continue}if(r.findIndex(e=>o(e,n.prop))>-1)try{t.componentChanged&&t.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject&&n.gameObject.name}, ${n.componentName} is componentChanged error.`,n,e)}}}}update(e){for(const t of e.components)for(const n of this.renderers){const r=[];if(n.observerInfo[t.name]&&-1===r.indexOf(e)){r.push(e);try{n.rendererUpdate&&n.rendererUpdate(e)}catch(n){console.info(`gameObject: ${e.name}, ${t.name} is update error`,n)}}}}};class h{constructor(){this.containerMap={}}addContainer({name:e,container:t,gameObject:n}){this.containerMap[e]=t,t.gName=n.name||e}getContainer(e){return this.containerMap[e]}removeContainer(e){const t=this.containerMap[e];t&&t.destroy({children:!0}),delete this.containerMap[e]}updateTransform({name:e,transform:t}){const n=this.containerMap[e];if(!n||!t)return;const{anchor:r,origin:s,position:a,rotation:o,scale:i,size:c,skew:p}=t;n.rotation=o,n.scale=i,n.pivot.x=c.width*s.x,n.pivot.y=c.height*s.y,n.skew=p;let d=a.x,h=a.y;if(t.parent){const e=t.parent;d+=e.size.width*r.x,h+=e.size.height*r.y}n.position={x:d,y:h}}}let m=class extends i{constructor({system:e,containerManager:t}){super(),this.name="Transform",this.waitRemoveIds=[],this.waitChangeScenes=[],this.containerManager=t,this.init(e)}init(e){this.system=e,this.on("changeScene",({scene:e,mode:t,application:n})=>{this.waitChangeScenes.push({scene:e,mode:t,application:n})})}update(){for(const e of this.waitRemoveIds)this.containerManager.removeContainer(e);this.waitRemoveIds=[];for(const e of this.waitChangeScenes){const t=this.containerManager.getContainer(e.scene.id);t&&(e.application.stage.removeChildren(),e.application.stage.addChild(t))}this.waitChangeScenes=[]}componentChanged(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)}addContainer(e){const n=new t.Container;n.label=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:n,gameObject:e.gameObject});const r=e.component;Object.defineProperty(r,"worldTransform",{get:()=>n.renderGroup||n.parentRenderGroup?n.worldTransform:void 0})}change(e){const t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));const n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{const t=this.containerManager.getContainer(e.gameObject.id);t.parent&&t.parent.removeChild(t)}}destroy(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null}};m=c([e.decorators.componentObserver({Transform:["_parent"]})],m);var l,u=m;exports.RENDERER_TYPE=void 0,(l=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[l.UNKNOWN=0]="UNKNOWN",l[l.WEBGL=1]="WEBGL",l[l.CANVAS=2]="CANVAS";let g=class extends e.System{constructor(){super(...arguments),this.multiApps=[]}init(t){return p(this,void 0,void 0,function*(){this.params=t,this.application=yield this.createApplication(t),this.containerManager=new h,this.rendererManager=new d({game:this.game,rendererSystem:this}),this.game.canvas=this.application.canvas,this.transform=new u({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",({scene:t,mode:n,params:r})=>p(this,void 0,void 0,function*(){let s;switch(n){case e.LOAD_SCENE_MODE.SINGLE:s=this.application;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:s=yield this.createMultiApplication({params:r})}t.canvas=s.canvas,this.transform.emit("changeScene",{scene:t,mode:n,application:s})})),this.game.on("pauseScene",({scene:e})=>{this.onPauseScene(e)}),this.game.on("startScene",({scene:e})=>{this.onStartScene(e)}),this.game.on("sceneDestroyed",({scene:e})=>p(this,void 0,void 0,function*(){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){this.multiApps.splice(t,1)[0].destroy(),e.destroy()}}))})}registerObserver(e){const t=this.constructor.observerInfo;for(const n in e)t[n]||(t[n]=[]),t[n].push(...e[n])}createMultiApplication({params:e}){return p(this,void 0,void 0,function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t})}createApplication(e){return p(this,void 0,void 0,function*(){const n=new t.Application;var r;return e.debugMode&&(globalThis.__PIXI_APP__=n),yield n.init(Object.assign(Object.assign({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((r=n.renderer).events.autoPreventDefault=!1,r.canvas.style.touchAction="auto"):(e=>{e.events.autoPreventDefault=!0,e.canvas.style.touchAction="none"})(n.renderer)),s.Ticker.shared.stop(),s.Ticker.shared.autoStart=!1,n})}update(){const e=this.componentObserver.clear();for(const t of e)this.transform.componentChanged(t);for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(e)}lateUpdate(e){this.transform.update(),this.application.ticker.update(e.time)}onDestroy(){this.application.destroy();for(const e of this.multiApps)e&&e.destroy();this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null}resize(e,t){this.params.width=e,this.params.height=t,this.application.renderer.resize(e,t)}getApplicationByScene(e){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){return this.multiApps[t]}console.warn("application not found")}onPauseScene(e){const t=this.getApplicationByScene(e);t&&t.stop()}onStartScene(e){const t=this.getApplicationByScene(e);t&&t.start()}resizeByScene(e,t,n){const r=this.getApplicationByScene(e);r&&r.renderer.resize(t,n)}};g.systemName="Renderer",g=c([e.decorators.componentObserver({Transform:["_parent"]})],g);var f=g;let v;function y(e){e.addPreProcessResourceHandler(function(e){var t,n,r;let s=null===(n=null===(t=e.src)||void 0===t?void 0:t.image)||void 0===n?void 0:n.texture;if(!s)return;Array.isArray(s)||(s=[s]);const a=null!==(r=function(){if(v)return v;const e=document.createElement("canvas").getContext("webgl2");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{s3tc:!1,etc:!1,etc1:!1,pvrtc:!1,atc:!1,astc:!1};v={s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc")||!!e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:!!e.getExtension("WEBGL_compressed_texture_atc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc")};try{console.log("Eva.js Supported Compressed Texture Format List: "+Object.keys(v).filter(e=>v[e]).join(", "))}catch(e){}return v}())&&void 0!==r?r:{};let o=s.find(e=>a[e.type]);o&&Object.assign(e.src.image,o)})}class E extends e.System{constructor(e){super(e),this.asyncIdMap={},this.observerInfo=this.constructor.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}exports.ContainerManager=h,exports.Renderer=E,exports.RendererManager=d,exports.RendererSystem=f,exports.registerKtx2CompressedTexture=function(t){s.setKTXTranscoderPath(t),s.extensions.add(s.loadKTX2),s.extensions.add(s.resolveCompressedTextureUrl),s.extensions.add(s.detectCompressed),y(e.resource)};
|
|
@@ -4,19 +4,19 @@ import isEqual from 'lodash-es/isEqual';
|
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
import { Ticker, setKTXTranscoderPath, extensions, loadKTX2, resolveCompressedTextureUrl, detectCompressed } from 'pixi.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
21
|
|
|
22
22
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -27,13 +27,19 @@ function __decorate(decorators, target, key, desc) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
30
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
31
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
32
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
33
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
34
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
35
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
36
|
});
|
|
36
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
40
|
+
var e = new Error(message);
|
|
41
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* 渲染管理器类
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer",
|
|
3
|
-
"version": "2.0.1",
|
|
3
|
+
"version": "2.0.2-beta.1",
|
|
4
4
|
"description": "@eva/plugin-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "2.0.1",
|
|
22
|
-
"@eva/renderer-adapter": "2.0.1",
|
|
23
|
-
"eventemitter3": "^
|
|
21
|
+
"@eva/eva.js": "2.0.2-beta.1",
|
|
22
|
+
"@eva/renderer-adapter": "2.0.2-beta.1",
|
|
23
|
+
"eventemitter3": "^5.0.4",
|
|
24
24
|
"lodash-es": "^4.17.21",
|
|
25
25
|
"pixi.js": "^8.17.0"
|
|
26
26
|
},
|