@eva/plugin-renderer 2.0.1-beta.2 → 2.0.1-beta.20
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.
|
@@ -1261,14 +1261,14 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
|
|
|
1261
1261
|
scene,
|
|
1262
1262
|
mode,
|
|
1263
1263
|
params
|
|
1264
|
-
}) => {
|
|
1264
|
+
}) => __awaiter(this, void 0, void 0, function* () {
|
|
1265
1265
|
let application;
|
|
1266
1266
|
switch (mode) {
|
|
1267
1267
|
case eva_js.LOAD_SCENE_MODE.SINGLE:
|
|
1268
1268
|
application = this.application;
|
|
1269
1269
|
break;
|
|
1270
1270
|
case eva_js.LOAD_SCENE_MODE.MULTI_CANVAS:
|
|
1271
|
-
application = this.createMultiApplication({
|
|
1271
|
+
application = yield this.createMultiApplication({
|
|
1272
1272
|
params
|
|
1273
1273
|
});
|
|
1274
1274
|
break;
|
|
@@ -1279,7 +1279,27 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
|
|
|
1279
1279
|
mode,
|
|
1280
1280
|
application
|
|
1281
1281
|
});
|
|
1282
|
+
}));
|
|
1283
|
+
this.game.on('pauseScene', ({
|
|
1284
|
+
scene
|
|
1285
|
+
}) => {
|
|
1286
|
+
this.onPauseScene(scene);
|
|
1287
|
+
});
|
|
1288
|
+
this.game.on('startScene', ({
|
|
1289
|
+
scene
|
|
1290
|
+
}) => {
|
|
1291
|
+
this.onStartScene(scene);
|
|
1282
1292
|
});
|
|
1293
|
+
this.game.on('sceneDestroyed', ({
|
|
1294
|
+
scene
|
|
1295
|
+
}) => __awaiter(this, void 0, void 0, function* () {
|
|
1296
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
1297
|
+
if (index > -1) {
|
|
1298
|
+
const app = this.multiApps.splice(index, 1)[0];
|
|
1299
|
+
app.destroy();
|
|
1300
|
+
scene.destroy();
|
|
1301
|
+
}
|
|
1302
|
+
}));
|
|
1283
1303
|
});
|
|
1284
1304
|
}
|
|
1285
1305
|
registerObserver(observerInfo) {
|
|
@@ -1306,9 +1326,6 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
|
|
|
1306
1326
|
if (params.debugMode) {
|
|
1307
1327
|
globalThis.__PIXI_APP__ = app;
|
|
1308
1328
|
}
|
|
1309
|
-
const ticker = new pixi_js.Ticker();
|
|
1310
|
-
pixi_js.Ticker._system = pixi_js.Ticker._shared = ticker;
|
|
1311
|
-
ticker._protected = true;
|
|
1312
1329
|
yield app.init(_extends(_extends({
|
|
1313
1330
|
sharedTicker: true
|
|
1314
1331
|
}, params), {
|
|
@@ -1365,6 +1382,33 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
|
|
|
1365
1382
|
this.params.height = height;
|
|
1366
1383
|
this.application.renderer.resize(width, height);
|
|
1367
1384
|
}
|
|
1385
|
+
getApplicationByScene(scene) {
|
|
1386
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
1387
|
+
if (index > -1) {
|
|
1388
|
+
const application = this.multiApps[index];
|
|
1389
|
+
return application;
|
|
1390
|
+
} else {
|
|
1391
|
+
console.warn('application not found');
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
onPauseScene(scene) {
|
|
1395
|
+
const app = this.getApplicationByScene(scene);
|
|
1396
|
+
if (app) {
|
|
1397
|
+
app.stop();
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
onStartScene(scene) {
|
|
1401
|
+
const app = this.getApplicationByScene(scene);
|
|
1402
|
+
if (app) {
|
|
1403
|
+
app.start();
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
resizeByScene(scene, width, height) {
|
|
1407
|
+
const app = this.getApplicationByScene(scene);
|
|
1408
|
+
if (app) {
|
|
1409
|
+
app.renderer.resize(width, height);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1368
1412
|
};
|
|
1369
1413
|
Renderer$1.systemName = 'Renderer';
|
|
1370
1414
|
Renderer$1 = __decorate([eva_js.decorators.componentObserver({
|
|
@@ -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,f=p||l||Function("return this")(),h=f.Symbol,d=Object.prototype,v=d.hasOwnProperty,_=d.toString,y=h?h.toStringTag:void 0;var g=Object.prototype.toString;var m=h?h.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,y),n=e[y];try{e[y]=void 0;var r=!0}catch(e){}var o=_.call(e);return r&&(t?e[y]=n:delete e[y]),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=f["__core-js_shared__"],x=(w=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"";var A=Function.prototype.toString;function C(e){if(null!=e){try{return A.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var M=/^\[object .+?Constructor\]$/,S=Function.prototype,T=Object.prototype,P=S.toString,R=T.hasOwnProperty,I=RegExp("^"+P.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function z(e){return!(!j(e)||(t=e,x&&x in t))&&(O(e)?I:M).test(C(e));var t}function L(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return z(n)?n:void 0}var k=L(f,"Map"),N=L(Object,"create");var V=Object.prototype.hasOwnProperty;var B=Object.prototype.hasOwnProperty;function D(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])}}D.prototype.clear=function(){this.__data__=N?N(null):{},this.size=0},D.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},D.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},D.prototype.has=function(e){var t=this.__data__;return N?void 0!==t[e]:B.call(t,e)},D.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 D,map:new(k||u),string:new D}},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(!k||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,f=!0,h=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 _=i?r(v,d,l,t,e,a):r(d,v,l,e,t,a);if(void 0!==_){if(_)continue;f=!1;break}if(h){if(!F(t,(function(e,t){if(i=t,!h.has(i)&&(d===e||o(d,e,n,r,a)))return h.push(t);var i}))){f=!1;break}}else if(d!==v&&!o(d,v,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}var K=f.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=h?h.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,fe=le&&le.exports===pe?f.Buffer:void 0,he=(fe?fe.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 _e(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var ye={};ye["[object Float32Array]"]=ye["[object Float64Array]"]=ye["[object Int8Array]"]=ye["[object Int16Array]"]=ye["[object Int32Array]"]=ye["[object Uint8Array]"]=ye["[object Uint8ClampedArray]"]=ye["[object Uint16Array]"]=ye["[object Uint32Array]"]=!0,ye["[object Arguments]"]=ye["[object Array]"]=ye["[object ArrayBuffer]"]=ye["[object Boolean]"]=ye["[object DataView]"]=ye["[object Date]"]=ye["[object Error]"]=ye["[object Function]"]=ye["[object Map]"]=ye["[object Number]"]=ye["[object Object]"]=ye["[object RegExp]"]=ye["[object Set]"]=ye["[object String]"]=ye["[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)&&_e(e.length)&&!!ye[b(e)]},xe=Object.prototype.hasOwnProperty;function Ae(e,t){var n=Q(e),r=!n&&ue(e),o=!n&&!r&&he(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&&!xe.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 Ce=Object.prototype;var Me=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Se=Me,Te=Object.prototype.hasOwnProperty;function Pe(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Ce))return Se(e);var t,n,r=[];for(var o in Object(e))Te.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Re(e){return null!=(t=e)&&_e(t.length)&&!O(t)?Ae(e):Pe(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 Le=L(f,"DataView"),ke=L(f,"Promise"),Ne=L(f,"Set"),Ve=L(f,"WeakMap"),Be="[object Map]",De="[object Promise]",We="[object Set]",Ge="[object WeakMap]",Ue="[object DataView]",$e=C(Le),Fe=C(k),Ye=C(ke),Ke=C(Ne),Xe=C(Ve),qe=b;(Le&&qe(new Le(new ArrayBuffer(1)))!=Ue||k&&qe(new k)!=Be||ke&&qe(ke.resolve())!=De||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?C(n):"";if(r)switch(r){case $e:return Ue;case Fe:return Be;case Ye:return De;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,f=(p=p==Je?Ze:p)==Ze,h=u==p;if(h&&he(e)){if(!he(t))return!1;s=!0,l=!1}if(h&&!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=f&&et.call(t,"__wrapped__");if(d||v){var _=d?e.value():e,y=v?t.value():t;return a||(a=new U),o(_,y,n,r,a)}}return!!h&&(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),f=a.get(t);if(l&&f)return l==t&&f==e;var h=!0;a.set(e,t),a.set(t,e);for(var d=i;++u<c;){var v=e[p=s[u]],_=t[p];if(r)var y=i?r(_,v,p,t,e,a):r(v,_,p,e,t,a);if(!(void 0===y?v===_||o(v,_,n,r,a):y)){h=!1;break}d||(d="constructor"==p)}if(h&&!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||(h=!1)}return a.delete(e),a.delete(t),h}(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 f,h=p.length;for(u=0;u<h;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(f=1,c=new Array(l-1);f<l;f++)c[f-1]=arguments[f];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})=>{let o;switch(n){case t.LOAD_SCENE_MODE.SINGLE:o=this.application;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:o=this.createMultiApplication({params:r})}e.canvas=o.canvas,this.transform.emit("changeScene",{scene:e,mode:n,application:o})}))}))}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;e.debugMode&&(globalThis.__PIXI_APP__=t);const o=new r.Ticker;var a;return r.Ticker._system=r.Ticker._shared=o,o._protected=!0,yield t.init(_extends(_extends({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((a=t.renderer).events.autoPreventDefault=!1,a.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){for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(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)}};pt.systemName="Renderer",pt=o([t.decorators.componentObserver({Transform:["_parent"]})],pt);var lt=pt;let ft;function ht(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(ft)return ft;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};ft={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(ft).filter((e=>ft[e])).join(", "))}catch(e){}return ft}())&&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),ht(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,f=p||l||Function("return this")(),h=f.Symbol,d=Object.prototype,v=d.hasOwnProperty,y=d.toString,_=h?h.toStringTag:void 0;var g=Object.prototype.toString;var m=h?h.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=f["__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,T=Object.prototype,P=M.toString,R=T.hasOwnProperty,I=RegExp("^"+P.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(f,"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,f=!0,h=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;f=!1;break}if(h){if(!F(t,(function(e,t){if(i=t,!h.has(i)&&(d===e||o(d,e,n,r,a)))return h.push(t);var i}))){f=!1;break}}else if(d!==v&&!o(d,v,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}var K=f.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=h?h.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,fe=le&&le.exports===pe?f.Buffer:void 0,he=(fe?fe.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&&he(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,Te=Object.prototype.hasOwnProperty;function Pe(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))Te.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Re(e){return null!=(t=e)&&ye(t.length)&&!O(t)?xe(e):Pe(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(f,"DataView"),Le=B(f,"Promise"),Ne=B(f,"Set"),Ve=B(f,"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,f=(p=p==Je?Ze:p)==Ze,h=u==p;if(h&&he(e)){if(!he(t))return!1;s=!0,l=!1}if(h&&!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=f&&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!!h&&(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),f=a.get(t);if(l&&f)return l==t&&f==e;var h=!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):_)){h=!1;break}d||(d="constructor"==p)}if(h&&!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||(h=!1)}return a.delete(e),a.delete(t),h}(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 f,h=p.length;for(u=0;u<h;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(f=1,c=new Array(l-1);f<l;f++)c[f-1]=arguments[f];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){for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(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 ft;function ht(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(ft)return ft;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};ft={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(ft).filter((e=>ft[e])).join(", "))}catch(e){}return ft}())&&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),ht(t.resource)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||_EVA_IIFE_renderer;
|
|
@@ -265,14 +265,14 @@ let Renderer$1 = class Renderer extends eva_js.System {
|
|
|
265
265
|
system: this,
|
|
266
266
|
containerManager: this.containerManager,
|
|
267
267
|
});
|
|
268
|
-
this.game.on('sceneChanged', ({ scene, mode, params }) => {
|
|
268
|
+
this.game.on('sceneChanged', ({ scene, mode, params }) => __awaiter(this, void 0, void 0, function* () {
|
|
269
269
|
let application;
|
|
270
270
|
switch (mode) {
|
|
271
271
|
case eva_js.LOAD_SCENE_MODE.SINGLE:
|
|
272
272
|
application = this.application;
|
|
273
273
|
break;
|
|
274
274
|
case eva_js.LOAD_SCENE_MODE.MULTI_CANVAS:
|
|
275
|
-
application = this.createMultiApplication({ params });
|
|
275
|
+
application = yield this.createMultiApplication({ params });
|
|
276
276
|
break;
|
|
277
277
|
}
|
|
278
278
|
scene.canvas = application.canvas;
|
|
@@ -281,7 +281,21 @@ let Renderer$1 = class Renderer extends eva_js.System {
|
|
|
281
281
|
mode,
|
|
282
282
|
application,
|
|
283
283
|
});
|
|
284
|
+
}));
|
|
285
|
+
this.game.on('pauseScene', ({ scene }) => {
|
|
286
|
+
this.onPauseScene(scene);
|
|
284
287
|
});
|
|
288
|
+
this.game.on('startScene', ({ scene }) => {
|
|
289
|
+
this.onStartScene(scene);
|
|
290
|
+
});
|
|
291
|
+
this.game.on('sceneDestroyed', ({ scene }) => __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
293
|
+
if (index > -1) {
|
|
294
|
+
const app = this.multiApps.splice(index, 1)[0];
|
|
295
|
+
app.destroy();
|
|
296
|
+
scene.destroy();
|
|
297
|
+
}
|
|
298
|
+
}));
|
|
285
299
|
});
|
|
286
300
|
}
|
|
287
301
|
registerObserver(observerInfo) {
|
|
@@ -306,9 +320,6 @@ let Renderer$1 = class Renderer extends eva_js.System {
|
|
|
306
320
|
if (params.debugMode) {
|
|
307
321
|
globalThis.__PIXI_APP__ = app;
|
|
308
322
|
}
|
|
309
|
-
const ticker = new pixi_js.Ticker();
|
|
310
|
-
pixi_js.Ticker._system = pixi_js.Ticker._shared = ticker;
|
|
311
|
-
ticker._protected = true;
|
|
312
323
|
yield app.init(Object.assign(Object.assign({ sharedTicker: true }, params), { hello: true }));
|
|
313
324
|
if (params.enableScroll !== undefined) {
|
|
314
325
|
params.enableScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
|
|
@@ -361,6 +372,34 @@ let Renderer$1 = class Renderer extends eva_js.System {
|
|
|
361
372
|
this.params.height = height;
|
|
362
373
|
this.application.renderer.resize(width, height);
|
|
363
374
|
}
|
|
375
|
+
getApplicationByScene(scene) {
|
|
376
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
377
|
+
if (index > -1) {
|
|
378
|
+
const application = this.multiApps[index];
|
|
379
|
+
return application;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
console.warn('application not found');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
onPauseScene(scene) {
|
|
386
|
+
const app = this.getApplicationByScene(scene);
|
|
387
|
+
if (app) {
|
|
388
|
+
app.stop();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
onStartScene(scene) {
|
|
392
|
+
const app = this.getApplicationByScene(scene);
|
|
393
|
+
if (app) {
|
|
394
|
+
app.start();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
resizeByScene(scene, width, height) {
|
|
398
|
+
const app = this.getApplicationByScene(scene);
|
|
399
|
+
if (app) {
|
|
400
|
+
app.renderer.resize(width, height);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
364
403
|
};
|
|
365
404
|
Renderer$1.systemName = 'Renderer';
|
|
366
405
|
Renderer$1 = __decorate([
|
|
@@ -1,4 +1,4 @@
|
|
|
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"),
|
|
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
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function c(e,t,n,r){var a
|
|
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){for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(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)};
|
|
@@ -91,6 +91,10 @@ export declare class RendererSystem extends System<RendererSystemParams> {
|
|
|
91
91
|
lateUpdate(e: any): void;
|
|
92
92
|
onDestroy(): void;
|
|
93
93
|
resize(width: any, height: any): void;
|
|
94
|
+
private getApplicationByScene;
|
|
95
|
+
private onPauseScene;
|
|
96
|
+
private onStartScene;
|
|
97
|
+
resizeByScene(scene: any, width: number, height: number): void;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
export declare interface RendererSystemParams extends Partial<ApplicationOptions> {
|
|
@@ -256,14 +256,14 @@ let Renderer$1 = class Renderer extends System {
|
|
|
256
256
|
system: this,
|
|
257
257
|
containerManager: this.containerManager,
|
|
258
258
|
});
|
|
259
|
-
this.game.on('sceneChanged', ({ scene, mode, params }) => {
|
|
259
|
+
this.game.on('sceneChanged', ({ scene, mode, params }) => __awaiter(this, void 0, void 0, function* () {
|
|
260
260
|
let application;
|
|
261
261
|
switch (mode) {
|
|
262
262
|
case LOAD_SCENE_MODE.SINGLE:
|
|
263
263
|
application = this.application;
|
|
264
264
|
break;
|
|
265
265
|
case LOAD_SCENE_MODE.MULTI_CANVAS:
|
|
266
|
-
application = this.createMultiApplication({ params });
|
|
266
|
+
application = yield this.createMultiApplication({ params });
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
269
269
|
scene.canvas = application.canvas;
|
|
@@ -272,7 +272,21 @@ let Renderer$1 = class Renderer extends System {
|
|
|
272
272
|
mode,
|
|
273
273
|
application,
|
|
274
274
|
});
|
|
275
|
+
}));
|
|
276
|
+
this.game.on('pauseScene', ({ scene }) => {
|
|
277
|
+
this.onPauseScene(scene);
|
|
275
278
|
});
|
|
279
|
+
this.game.on('startScene', ({ scene }) => {
|
|
280
|
+
this.onStartScene(scene);
|
|
281
|
+
});
|
|
282
|
+
this.game.on('sceneDestroyed', ({ scene }) => __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
284
|
+
if (index > -1) {
|
|
285
|
+
const app = this.multiApps.splice(index, 1)[0];
|
|
286
|
+
app.destroy();
|
|
287
|
+
scene.destroy();
|
|
288
|
+
}
|
|
289
|
+
}));
|
|
276
290
|
});
|
|
277
291
|
}
|
|
278
292
|
registerObserver(observerInfo) {
|
|
@@ -297,9 +311,6 @@ let Renderer$1 = class Renderer extends System {
|
|
|
297
311
|
if (params.debugMode) {
|
|
298
312
|
globalThis.__PIXI_APP__ = app;
|
|
299
313
|
}
|
|
300
|
-
const ticker = new Ticker();
|
|
301
|
-
Ticker._system = Ticker._shared = ticker;
|
|
302
|
-
ticker._protected = true;
|
|
303
314
|
yield app.init(Object.assign(Object.assign({ sharedTicker: true }, params), { hello: true }));
|
|
304
315
|
if (params.enableScroll !== undefined) {
|
|
305
316
|
params.enableScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
|
|
@@ -352,6 +363,34 @@ let Renderer$1 = class Renderer extends System {
|
|
|
352
363
|
this.params.height = height;
|
|
353
364
|
this.application.renderer.resize(width, height);
|
|
354
365
|
}
|
|
366
|
+
getApplicationByScene(scene) {
|
|
367
|
+
const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
|
|
368
|
+
if (index > -1) {
|
|
369
|
+
const application = this.multiApps[index];
|
|
370
|
+
return application;
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
console.warn('application not found');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
onPauseScene(scene) {
|
|
377
|
+
const app = this.getApplicationByScene(scene);
|
|
378
|
+
if (app) {
|
|
379
|
+
app.stop();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
onStartScene(scene) {
|
|
383
|
+
const app = this.getApplicationByScene(scene);
|
|
384
|
+
if (app) {
|
|
385
|
+
app.start();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
resizeByScene(scene, width, height) {
|
|
389
|
+
const app = this.getApplicationByScene(scene);
|
|
390
|
+
if (app) {
|
|
391
|
+
app.renderer.resize(width, height);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
355
394
|
};
|
|
356
395
|
Renderer$1.systemName = 'Renderer';
|
|
357
396
|
Renderer$1 = __decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.20",
|
|
4
4
|
"description": "@eva/plugin-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
22
|
-
"@eva/renderer-adapter": "2.0.1-beta.
|
|
21
|
+
"@eva/eva.js": "2.0.1-beta.20",
|
|
22
|
+
"@eva/renderer-adapter": "2.0.1-beta.20",
|
|
23
23
|
"eventemitter3": "^3.1.2",
|
|
24
24
|
"lodash-es": "^4.17.21",
|
|
25
25
|
"pixi.js": "^8.8.1"
|