@eva/plugin-renderer 2.0.2-beta.3 → 2.1.0-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.
@@ -10,6 +10,9 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
10
10
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
11
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12
12
  }
13
+ function __metadata(metadataKey, metadataValue) {
14
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
15
+ }
13
16
  function __awaiter(thisArg, _arguments, P, generator) {
14
17
  function adopt(value) {
15
18
  return value instanceof P ? value : new P(function (resolve) {
@@ -909,6 +912,22 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
909
912
  }
910
913
  }
911
914
  var RendererManager$1 = RendererManager;
915
+ const toRenderBounds = (bounds, coordinateSpace, source) => {
916
+ const x = Number.isFinite(bounds.x) ? bounds.x : 0;
917
+ const y = Number.isFinite(bounds.y) ? bounds.y : 0;
918
+ const width = Number.isFinite(bounds.width) ? bounds.width : 0;
919
+ const height = Number.isFinite(bounds.height) ? bounds.height : 0;
920
+ return {
921
+ x,
922
+ y,
923
+ width,
924
+ height,
925
+ right: x + width,
926
+ bottom: y + height,
927
+ coordinateSpace,
928
+ source
929
+ };
930
+ };
912
931
  class ContainerManager {
913
932
  constructor() {
914
933
  this.containerMap = {};
@@ -924,6 +943,64 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
924
943
  getContainer(name) {
925
944
  return this.containerMap[name];
926
945
  }
946
+ getBounds(gameObject, options = {}) {
947
+ if (!gameObject || gameObject.destroyed) return null;
948
+ const coordinateSpace = options.coordinateSpace || 'world';
949
+ const fallbackToTransform = options.fallbackToTransform !== false;
950
+ const container = this.getContainer(gameObject.id);
951
+ if (container === null || container === void 0 ? void 0 : container.getBounds) {
952
+ try {
953
+ const bounds = container.getBounds();
954
+ if (bounds && Number.isFinite(bounds.width) && Number.isFinite(bounds.height) && (bounds.width !== 0 || bounds.height !== 0)) {
955
+ return toRenderBounds(bounds, coordinateSpace, 'pixi');
956
+ }
957
+ } catch (error) {}
958
+ }
959
+ if (!fallbackToTransform) return null;
960
+ return this.getTransformBounds(gameObject, coordinateSpace);
961
+ }
962
+ getTransformBounds(gameObject, coordinateSpace) {
963
+ var _a, _b, _c, _d, _e, _f;
964
+ const transform = gameObject.transform;
965
+ const container = this.getContainer(gameObject.id);
966
+ let x = (_a = container === null || container === void 0 ? void 0 : container.worldTransform) === null || _a === void 0 ? void 0 : _a.tx;
967
+ let y = (_b = container === null || container === void 0 ? void 0 : container.worldTransform) === null || _b === void 0 ? void 0 : _b.ty;
968
+ if (!Number.isFinite(x) || !Number.isFinite(y)) {
969
+ const position = this.resolveFallbackWorldPosition(transform);
970
+ x = position.x;
971
+ y = position.y;
972
+ }
973
+ const scaleX = Number.isFinite((_c = transform.scale) === null || _c === void 0 ? void 0 : _c.x) ? transform.scale.x : 1;
974
+ const scaleY = Number.isFinite((_d = transform.scale) === null || _d === void 0 ? void 0 : _d.y) ? transform.scale.y : 1;
975
+ const width = Math.abs((((_e = transform.size) === null || _e === void 0 ? void 0 : _e.width) || 0) * scaleX);
976
+ const height = Math.abs((((_f = transform.size) === null || _f === void 0 ? void 0 : _f.height) || 0) * scaleY);
977
+ return toRenderBounds({
978
+ x,
979
+ y,
980
+ width,
981
+ height
982
+ }, coordinateSpace, 'transform');
983
+ }
984
+ resolveFallbackWorldPosition(transform) {
985
+ var _a, _b, _c, _d;
986
+ if (!transform) return {
987
+ x: 0,
988
+ y: 0
989
+ };
990
+ const parent = transform.parent;
991
+ const parentPosition = parent ? this.resolveFallbackWorldPosition(parent) : {
992
+ x: 0,
993
+ y: 0
994
+ };
995
+ const parentSize = (parent === null || parent === void 0 ? void 0 : parent.size) || {
996
+ width: 0,
997
+ height: 0
998
+ };
999
+ return {
1000
+ x: parentPosition.x + (((_a = transform.position) === null || _a === void 0 ? void 0 : _a.x) || 0) + parentSize.width * (((_b = transform.anchor) === null || _b === void 0 ? void 0 : _b.x) || 0),
1001
+ y: parentPosition.y + (((_c = transform.position) === null || _c === void 0 ? void 0 : _c.y) || 0) + parentSize.height * (((_d = transform.anchor) === null || _d === void 0 ? void 0 : _d.y) || 0)
1002
+ };
1003
+ }
927
1004
  removeContainer(name) {
928
1005
  const container = this.containerMap[name];
929
1006
  if (container) {
@@ -1222,7 +1299,7 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1222
1299
  };
1223
1300
  Transform = __decorate([eva_js.decorators.componentObserver({
1224
1301
  Transform: ['_parent']
1225
- })], Transform);
1302
+ }), __metadata("design:paramtypes", [Object])], Transform);
1226
1303
  var Transform$1 = Transform;
1227
1304
  exports.RENDERER_TYPE = void 0;
1228
1305
  (function (RENDERER_TYPE) {
@@ -1238,26 +1315,41 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1238
1315
  renderer.events.autoPreventDefault = false;
1239
1316
  renderer.canvas.style.touchAction = 'auto';
1240
1317
  };
1318
+ function isRendererGameLike(value) {
1319
+ if (!value || typeof value !== 'object') return false;
1320
+ const candidate = value;
1321
+ return Boolean(candidate.scene || candidate.gameObjects || typeof candidate.on === 'function');
1322
+ }
1241
1323
  let Renderer$1 = class Renderer extends eva_js.System {
1242
1324
  constructor() {
1243
1325
  super(...arguments);
1244
1326
  this.multiApps = [];
1327
+ this.destroyed = false;
1245
1328
  }
1246
- init(params) {
1329
+ init(params = {}) {
1330
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1247
1331
  return __awaiter(this, void 0, void 0, function* () {
1248
- this.params = params;
1249
- this.application = yield this.createApplication(params);
1332
+ this.destroyed = false;
1333
+ const gameLike = !this.game && isRendererGameLike(params) ? params : undefined;
1334
+ if (gameLike) {
1335
+ this.game = gameLike;
1336
+ }
1337
+ const rendererParams = gameLike ? this.__systemDefaultParams || {} : params;
1338
+ this.params = rendererParams;
1339
+ this.application = yield this.createApplication(rendererParams);
1250
1340
  this.containerManager = new ContainerManager();
1251
1341
  this.rendererManager = new RendererManager$1({
1252
1342
  game: this.game,
1253
1343
  rendererSystem: this
1254
1344
  });
1255
- this.game.canvas = this.application.canvas;
1345
+ if (this.game) {
1346
+ this.game.canvas = this.application.canvas;
1347
+ }
1256
1348
  this.transform = new Transform$1({
1257
1349
  system: this,
1258
1350
  containerManager: this.containerManager
1259
1351
  });
1260
- this.game.on('sceneChanged', ({
1352
+ (_b = (_a = this.game) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, 'sceneChanged', ({
1261
1353
  scene,
1262
1354
  mode,
1263
1355
  params
@@ -1280,17 +1372,17 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1280
1372
  application
1281
1373
  });
1282
1374
  }));
1283
- this.game.on('pauseScene', ({
1375
+ (_d = (_c = this.game) === null || _c === void 0 ? void 0 : _c.on) === null || _d === void 0 ? void 0 : _d.call(_c, 'pauseScene', ({
1284
1376
  scene
1285
1377
  }) => {
1286
1378
  this.onPauseScene(scene);
1287
1379
  });
1288
- this.game.on('startScene', ({
1380
+ (_f = (_e = this.game) === null || _e === void 0 ? void 0 : _e.on) === null || _f === void 0 ? void 0 : _f.call(_e, 'startScene', ({
1289
1381
  scene
1290
1382
  }) => {
1291
1383
  this.onStartScene(scene);
1292
1384
  });
1293
- this.game.on('sceneDestroyed', ({
1385
+ (_h = (_g = this.game) === null || _g === void 0 ? void 0 : _g.on) === null || _h === void 0 ? void 0 : _h.call(_g, 'sceneDestroyed', ({
1294
1386
  scene
1295
1387
  }) => __awaiter(this, void 0, void 0, function* () {
1296
1388
  const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
@@ -1340,6 +1432,7 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1340
1432
  });
1341
1433
  }
1342
1434
  update() {
1435
+ if (this.destroyed || !this.game || !this.containerManager || !this.rendererManager) return;
1343
1436
  const changes = this.componentObserver.clear();
1344
1437
  for (const changed of changes) {
1345
1438
  this.transform.componentChanged(changed);
@@ -1353,15 +1446,27 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1353
1446
  }
1354
1447
  }
1355
1448
  lateUpdate(e) {
1449
+ if (this.destroyed || !this.transform || !this.application) return;
1356
1450
  this.transform.update();
1357
1451
  this.application.ticker.update(e.time);
1358
1452
  }
1359
1453
  onDestroy() {
1360
- this.application.destroy();
1454
+ var _a, _b, _c, _d, _e, _f, _g;
1455
+ if (this.destroyed) return;
1456
+ this.destroyed = true;
1457
+ (_c = (_b = (_a = this.application) === null || _a === void 0 ? void 0 : _a.ticker) === null || _b === void 0 ? void 0 : _b.stop) === null || _c === void 0 ? void 0 : _c.call(_b);
1458
+ (_d = this.application) === null || _d === void 0 ? void 0 : _d.destroy(false, {
1459
+ children: true,
1460
+ context: true
1461
+ });
1361
1462
  for (const app of this.multiApps) {
1362
- app && app.destroy();
1463
+ (_f = (_e = app === null || app === void 0 ? void 0 : app.ticker) === null || _e === void 0 ? void 0 : _e.stop) === null || _f === void 0 ? void 0 : _f.call(_e);
1464
+ app && app.destroy(false, {
1465
+ children: true,
1466
+ context: true
1467
+ });
1363
1468
  }
1364
- this.transform.destroy();
1469
+ (_g = this.transform) === null || _g === void 0 ? void 0 : _g.destroy();
1365
1470
  this.transform = null;
1366
1471
  this.params = null;
1367
1472
  this.rendererManager = null;
@@ -1370,10 +1475,77 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1370
1475
  this.game = null;
1371
1476
  this.multiApps = null;
1372
1477
  }
1373
- resize(width, height) {
1478
+ resize(width, height, resolution) {
1374
1479
  this.params.width = width;
1375
1480
  this.params.height = height;
1376
- this.application.renderer.resize(width, height);
1481
+ if (resolution != null) {
1482
+ this.params.resolution = this.clampResolution(resolution);
1483
+ }
1484
+ this.application.renderer.resize(width, height, this.params.resolution);
1485
+ if (resolution != null) {
1486
+ this.syncDisplayObjectResolution(this.params.resolution);
1487
+ }
1488
+ }
1489
+ resizeRenderer(options) {
1490
+ var _a, _b, _c, _d, _e, _f;
1491
+ const width = (_b = (_a = options.width) !== null && _a !== void 0 ? _a : this.params.width) !== null && _b !== void 0 ? _b : this.application.renderer.width;
1492
+ const height = (_d = (_c = options.height) !== null && _c !== void 0 ? _c : this.params.height) !== null && _d !== void 0 ? _d : this.application.renderer.height;
1493
+ const resolution = options.resolution == null ? (_f = (_e = this.params.resolution) !== null && _e !== void 0 ? _e : this.application.renderer.resolution) !== null && _f !== void 0 ? _f : 1 : this.clampResolution(options.resolution, options.maxResolution);
1494
+ this.params.width = width;
1495
+ this.params.height = height;
1496
+ this.params.resolution = resolution;
1497
+ this.application.renderer.resize(width, height, resolution);
1498
+ const displayResolutionSyncCount = this.syncDisplayObjectResolution(resolution);
1499
+ return {
1500
+ width,
1501
+ height,
1502
+ resolution,
1503
+ displayResolutionSyncCount
1504
+ };
1505
+ }
1506
+ setResolution(resolution, options = {}) {
1507
+ return this.resizeRenderer(_extends(_extends({}, options), {
1508
+ resolution
1509
+ }));
1510
+ }
1511
+ clampResolution(resolution, maxResolution = 3) {
1512
+ const normalized = Number.isFinite(resolution) && resolution > 0 ? resolution : 1;
1513
+ return Math.min(normalized, maxResolution);
1514
+ }
1515
+ syncDisplayObjectResolution(resolution) {
1516
+ var _a;
1517
+ const roots = ((_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.containerMap) ? Object.values(this.containerManager.containerMap) : [];
1518
+ const visited = typeof WeakSet !== 'undefined' ? new WeakSet() : undefined;
1519
+ let syncedCount = 0;
1520
+ const visit = displayObject => {
1521
+ if (!displayObject || typeof displayObject !== 'object') return;
1522
+ if (visited === null || visited === void 0 ? void 0 : visited.has(displayObject)) return;
1523
+ visited === null || visited === void 0 ? void 0 : visited.add(displayObject);
1524
+ if ('resolution' in displayObject) {
1525
+ const currentResolution = displayObject.resolution;
1526
+ if ((typeof currentResolution === 'number' || currentResolution === null) && Math.abs((currentResolution !== null && currentResolution !== void 0 ? currentResolution : 1) - resolution) > 0.001) {
1527
+ try {
1528
+ displayObject.resolution = resolution;
1529
+ if (typeof displayObject.resolution === 'number' && Math.abs(displayObject.resolution - resolution) <= 0.001) {
1530
+ syncedCount += 1;
1531
+ }
1532
+ } catch (_) {}
1533
+ }
1534
+ }
1535
+ if (Array.isArray(displayObject.children)) {
1536
+ for (const child of displayObject.children) {
1537
+ visit(child);
1538
+ }
1539
+ }
1540
+ };
1541
+ for (const root of roots) {
1542
+ visit(root);
1543
+ }
1544
+ return syncedCount;
1545
+ }
1546
+ getBounds(gameObject, options) {
1547
+ var _a;
1548
+ return ((_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getBounds(gameObject, options)) || null;
1377
1549
  }
1378
1550
  getApplicationByScene(scene) {
1379
1551
  const index = this.multiApps.findIndex(app => app.canvas === scene.canvas);
@@ -1396,10 +1568,10 @@ var _EVA_IIFE_renderer = function (exports, eva_js, rendererAdapter, pixi_js) {
1396
1568
  app.start();
1397
1569
  }
1398
1570
  }
1399
- resizeByScene(scene, width, height) {
1571
+ resizeByScene(scene, width, height, resolution) {
1400
1572
  const app = this.getApplicationByScene(scene);
1401
1573
  if (app) {
1402
- app.renderer.resize(width, height);
1574
+ app.renderer.resize(width, height, resolution);
1403
1575
  }
1404
1576
  }
1405
1577
  };
@@ -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,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function i(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(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(a,s)}c((r=r.apply(e,t||[])).next())})}function a(e,t){return e===t||e!=e&&t!=t}function s(e,t){for(var n=e.length;n--;)if(a(e[n][0],t))return n;return-1}var c=Array.prototype.splice;function l(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])}}l.prototype.clear=function(){this.__data__=[],this.size=0},l.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)},l.prototype.get=function(e){var t=this.__data__,n=s(t,e);return n<0?void 0:t[n][1]},l.prototype.has=function(e){return s(this.__data__,e)>-1},l.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 u="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,p=u||h||Function("return this")(),d=p.Symbol,f=Object.prototype,v=f.hasOwnProperty,y=f.toString,m=d?d.toStringTag:void 0;var g=Object.prototype.toString;var b=d?d.toStringTag:void 0;function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":b&&b in Object(e)?function(e){var t=v.call(e,m),n=e[m];try{e[m]=void 0;var r=!0}catch(e){}var o=y.call(e);return r&&(t?e[m]=n:delete e[m]),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=_(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var w,x=p["__core-js_shared__"],E=(w=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"";var A=Function.prototype.toString;function S(e){if(null!=e){try{return A.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var M=/^\[object .+?Constructor\]$/,C=Function.prototype,R=Object.prototype,T=C.toString,P=R.hasOwnProperty,z=RegExp("^"+T.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function I(e){return!(!j(e)||(t=e,E&&E in t))&&(O(e)?z:M).test(S(e));var t}function N(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return I(n)?n:void 0}var B=N(p,"Map"),k=N(Object,"create");var D=Object.prototype.hasOwnProperty;var L=Object.prototype.hasOwnProperty;function F(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 V(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 W(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])}}F.prototype.clear=function(){this.__data__=k?k(null):{},this.size=0},F.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},F.prototype.get=function(e){var t=this.__data__;if(k){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return D.call(t,e)?t[e]:void 0},F.prototype.has=function(e){var t=this.__data__;return k?void 0!==t[e]:L.call(t,e)},F.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=k&&void 0===t?"__lodash_hash_undefined__":t,this},W.prototype.clear=function(){this.size=0,this.__data__={hash:new F,map:new(B||l),string:new F}},W.prototype.delete=function(e){var t=V(this,e).delete(e);return this.size-=t?1:0,t},W.prototype.get=function(e){return V(this,e).get(e)},W.prototype.has=function(e){return V(this,e).has(e)},W.prototype.set=function(e,t){var n=V(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function G(e){var t=this.__data__=new l(e);this.size=t.size}G.prototype.clear=function(){this.__data__=new l,this.size=0},G.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},G.prototype.get=function(e){return this.__data__.get(e)},G.prototype.has=function(e){return this.__data__.has(e)},G.prototype.set=function(e,t){var n=this.__data__;if(n instanceof l){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new W(r)}return n.set(e,t),this.size=n.size,this};function U(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new W;++t<n;)this.add(e[t])}function $(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}U.prototype.add=U.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},U.prototype.has=function(e){return this.__data__.has(e)};function Y(e,t,n,r,o,i){var a=1&n,s=e.length,c=t.length;if(s!=c&&!(a&&c>s))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var h=-1,p=!0,d=2&n?new U:void 0;for(i.set(e,t),i.set(t,e);++h<s;){var f=e[h],v=t[h];if(r)var y=a?r(v,f,h,t,e,i):r(f,v,h,e,t,i);if(void 0!==y){if(y)continue;p=!1;break}if(d){if(!$(t,function(e,t){if(a=t,!d.has(a)&&(f===e||o(f,e,n,r,i)))return d.push(t);var a})){p=!1;break}}else if(f!==v&&!o(f,v,n,r,i)){p=!1;break}}return i.delete(e),i.delete(t),p}var K=p.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=d?d.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,i=[];++n<r;){var a=e[n];t(a,n,e)&&(i[o++]=a)}return i}(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]"==_(e)}var ie=Object.prototype,ae=ie.hasOwnProperty,se=ie.propertyIsEnumerable,ce=oe(function(){return arguments}())?oe:function(e){return re(e)&&ae.call(e,"callee")&&!se.call(e,"callee")},le=ce;var ue="object"==typeof e&&e&&!e.nodeType&&e,he=ue&&"object"==typeof module&&module&&!module.nodeType&&module,pe=he&&he.exports===ue?p.Buffer:void 0,de=(pe?pe.isBuffer:void 0)||function(){return!1},fe=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&fe.test(e))&&e>-1&&e%1==0&&e<t}function ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var me={};me["[object Float32Array]"]=me["[object Float64Array]"]=me["[object Int8Array]"]=me["[object Int16Array]"]=me["[object Int32Array]"]=me["[object Uint8Array]"]=me["[object Uint8ClampedArray]"]=me["[object Uint16Array]"]=me["[object Uint32Array]"]=!0,me["[object Arguments]"]=me["[object Array]"]=me["[object ArrayBuffer]"]=me["[object Boolean]"]=me["[object DataView]"]=me["[object Date]"]=me["[object Error]"]=me["[object Function]"]=me["[object Map]"]=me["[object Number]"]=me["[object Object]"]=me["[object RegExp]"]=me["[object Set]"]=me["[object String]"]=me["[object WeakMap]"]=!1;var ge,be="object"==typeof e&&e&&!e.nodeType&&e,_e=be&&"object"==typeof module&&module&&!module.nodeType&&module,je=_e&&_e.exports===be&&u.process,Oe=function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||je&&je.binding&&je.binding("util")}catch(e){}}(),we=Oe&&Oe.isTypedArray,xe=we?(ge=we,function(e){return ge(e)}):function(e){return re(e)&&ye(e.length)&&!!me[_(e)]},Ee=Object.prototype.hasOwnProperty;function Ae(e,t){var n=Q(e),r=!n&&le(e),o=!n&&!r&&de(e),i=!n&&!r&&!o&&xe(e),a=n||r||o||i,s=a?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 l in e)!t&&!Ee.call(e,l)||a&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||ve(l,c))||s.push(l);return s}var Se=Object.prototype;var Me=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Ce=Me,Re=Object.prototype.hasOwnProperty;function Te(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Se))return Ce(e);var t,n,r=[];for(var o in Object(e))Re.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Pe(e){return null!=(t=e)&&ye(t.length)&&!O(t)?Ae(e):Te(e);var t}function ze(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,Pe,ne)}var Ie=Object.prototype.hasOwnProperty;var Ne=N(p,"DataView"),Be=N(p,"Promise"),ke=N(p,"Set"),De=N(p,"WeakMap"),Le="[object Map]",Fe="[object Promise]",Ve="[object Set]",We="[object WeakMap]",Ge="[object DataView]",Ue=S(Ne),$e=S(B),Ye=S(Be),Ke=S(ke),Xe=S(De),qe=_;(Ne&&qe(new Ne(new ArrayBuffer(1)))!=Ge||B&&qe(new B)!=Le||Be&&qe(Be.resolve())!=Fe||ke&&qe(new ke)!=Ve||De&&qe(new De)!=We)&&(qe=function(e){var t=_(e),n="[object Object]"==t?e.constructor:void 0,r=n?S(n):"";if(r)switch(r){case Ue:return Ge;case $e:return Le;case Ye:return Fe;case Ke:return Ve;case Xe:return We}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,i){var s=Q(e),c=Q(t),l=s?Qe:He(e),u=c?Qe:He(t),h=(l=l==Je?Ze:l)==Ze,p=(u=u==Je?Ze:u)==Ze,d=l==u;if(d&&de(e)){if(!de(t))return!1;s=!0,h=!1}if(d&&!h)return i||(i=new G),s||xe(e)?Y(e,t,n,r,o,i):function(e,t,n,r,o,i,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||!i(new K(e),new K(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+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 l=1&r;if(c||(c=q),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var h=Y(c(e),c(t),r,o,i,s);return s.delete(e),h;case"[object Symbol]":if(J)return J.call(e)==J.call(t)}return!1}(e,t,l,n,r,o,i);if(!(1&n)){var f=h&&et.call(e,"__wrapped__"),v=p&&et.call(t,"__wrapped__");if(f||v){var y=f?e.value():e,m=v?t.value():t;return i||(i=new G),o(y,m,n,r,i)}}return!!d&&(i||(i=new G),function(e,t,n,r,o,i){var a=1&n,s=ze(e),c=s.length;if(c!=ze(t).length&&!a)return!1;for(var l=c;l--;){var u=s[l];if(!(a?u in t:Ie.call(t,u)))return!1}var h=i.get(e),p=i.get(t);if(h&&p)return h==t&&p==e;var d=!0;i.set(e,t),i.set(t,e);for(var f=a;++l<c;){var v=e[u=s[l]],y=t[u];if(r)var m=a?r(y,v,u,t,e,i):r(v,y,u,e,t,i);if(!(void 0===m?v===y||o(v,y,n,r,i):m)){d=!1;break}f||(f="constructor"==u)}if(d&&!f){var g=e.constructor,b=t.constructor;g==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(d=!1)}return i.delete(e),i.delete(t),d}(e,t,n,r,o,i))}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)}}}}};const ot=(e,t,n)=>{const r=Number.isFinite(e.x)?e.x:0,o=Number.isFinite(e.y)?e.y:0,i=Number.isFinite(e.width)?e.width:0,a=Number.isFinite(e.height)?e.height:0;return{x:r,y:o,width:i,height:a,right:r+i,bottom:o+a,coordinateSpace:t,source:n}};class it{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]}getBounds(e,t={}){if(!e||e.destroyed)return null;const n=t.coordinateSpace||"world",r=!1!==t.fallbackToTransform,o=this.getContainer(e.id);if(null==o?void 0:o.getBounds)try{const e=o.getBounds();if(e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(0!==e.width||0!==e.height))return ot(e,n,"pixi")}catch(e){}return r?this.getTransformBounds(e,n):null}getTransformBounds(e,t){var n,r,o,i,a,s;const c=e.transform,l=this.getContainer(e.id);let u=null===(n=null==l?void 0:l.worldTransform)||void 0===n?void 0:n.tx,h=null===(r=null==l?void 0:l.worldTransform)||void 0===r?void 0:r.ty;if(!Number.isFinite(u)||!Number.isFinite(h)){const e=this.resolveFallbackWorldPosition(c);u=e.x,h=e.y}const p=Number.isFinite(null===(o=c.scale)||void 0===o?void 0:o.x)?c.scale.x:1,d=Number.isFinite(null===(i=c.scale)||void 0===i?void 0:i.y)?c.scale.y:1,f=Math.abs(((null===(a=c.size)||void 0===a?void 0:a.width)||0)*p),v=Math.abs(((null===(s=c.size)||void 0===s?void 0:s.height)||0)*d);return ot({x:u,y:h,width:f,height:v},t,"transform")}resolveFallbackWorldPosition(e){var t,n,r,o;if(!e)return{x:0,y:0};const i=e.parent,a=i?this.resolveFallbackWorldPosition(i):{x:0,y:0},s=(null==i?void 0:i.size)||{width:0,height:0};return{x:a.x+((null===(t=e.position)||void 0===t?void 0:t.x)||0)+s.width*((null===(n=e.anchor)||void 0===n?void 0:n.x)||0),y:a.y+((null===(r=e.position)||void 0===r?void 0:r.y)||0)+s.height*((null===(o=e.anchor)||void 0===o?void 0:o.y)||0)}}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:i,rotation:a,scale:s,size:c,skew:l}=t;n.rotation=a,n.scale=s,n.pivot.x=c.width*o.x,n.pivot.y=c.height*o.y,n.skew=l;let u=i.x,h=i.y;if(t.parent){const e=t.parent;u+=e.size.width*r.x,h+=e.size.height*r.y}n.position={x:u,y:h}}}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 i(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,i||e,a),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 a(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,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},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,i,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,i),!0;case 6:return u.fn.call(u.context,t,r,o,i,a),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var p,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(p=1,c=new Array(h-1);p<h;p++)c[p-1]=arguments[p];u[l].fn.apply(u[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var c=0,l=[],u=s.length;c<u;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[i]=1===l.length?l[0]:l:a(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(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}),st=at;let ct=class extends st{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}};ct=o([t.decorators.componentObserver({Transform:["_parent"]}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[Object])],ct);var lt,ut=ct;e.RENDERER_TYPE=void 0,(lt=e.RENDERER_TYPE||(e.RENDERER_TYPE={}))[lt.UNKNOWN=0]="UNKNOWN",lt[lt.WEBGL=1]="WEBGL",lt[lt.CANVAS=2]="CANVAS";let ht=class extends t.System{constructor(){super(...arguments),this.multiApps=[],this.destroyed=!1}init(e={}){var n,r,o,a,s,c,l,u;return i(this,void 0,void 0,function*(){this.destroyed=!1;const h=!this.game&&function(e){if(!e||"object"!=typeof e)return!1;const t=e;return Boolean(t.scene||t.gameObjects||"function"==typeof t.on)}(e)?e:void 0;h&&(this.game=h);const p=h?this.__systemDefaultParams||{}:e;this.params=p,this.application=yield this.createApplication(p),this.containerManager=new it,this.rendererManager=new rt({game:this.game,rendererSystem:this}),this.game&&(this.game.canvas=this.application.canvas),this.transform=new ut({system:this,containerManager:this.containerManager}),null===(r=null===(n=this.game)||void 0===n?void 0:n.on)||void 0===r||r.call(n,"sceneChanged",({scene:e,mode:n,params:r})=>i(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})})),null===(a=null===(o=this.game)||void 0===o?void 0:o.on)||void 0===a||a.call(o,"pauseScene",({scene:e})=>{this.onPauseScene(e)}),null===(c=null===(s=this.game)||void 0===s?void 0:s.on)||void 0===c||c.call(s,"startScene",({scene:e})=>{this.onStartScene(e)}),null===(u=null===(l=this.game)||void 0===l?void 0:l.on)||void 0===u||u.call(l,"sceneDestroyed",({scene:e})=>i(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 i(this,void 0,void 0,function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t})}createApplication(e){return i(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(){if(this.destroyed||!this.game||!this.containerManager||!this.rendererManager)return;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.destroyed&&this.transform&&this.application&&(this.transform.update(),this.application.ticker.update(e.time))}onDestroy(){var e,t,n,r,o,i,a;if(!this.destroyed){this.destroyed=!0,null===(n=null===(t=null===(e=this.application)||void 0===e?void 0:e.ticker)||void 0===t?void 0:t.stop)||void 0===n||n.call(t),null===(r=this.application)||void 0===r||r.destroy(!1,{children:!0,context:!0});for(const e of this.multiApps)null===(i=null===(o=null==e?void 0:e.ticker)||void 0===o?void 0:o.stop)||void 0===i||i.call(o),e&&e.destroy(!1,{children:!0,context:!0});null===(a=this.transform)||void 0===a||a.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,n){this.params.width=e,this.params.height=t,null!=n&&(this.params.resolution=this.clampResolution(n)),this.application.renderer.resize(e,t,this.params.resolution),null!=n&&this.syncDisplayObjectResolution(this.params.resolution)}resizeRenderer(e){var t,n,r,o,i,a;const s=null!==(n=null!==(t=e.width)&&void 0!==t?t:this.params.width)&&void 0!==n?n:this.application.renderer.width,c=null!==(o=null!==(r=e.height)&&void 0!==r?r:this.params.height)&&void 0!==o?o:this.application.renderer.height,l=null==e.resolution?null!==(a=null!==(i=this.params.resolution)&&void 0!==i?i:this.application.renderer.resolution)&&void 0!==a?a:1:this.clampResolution(e.resolution,e.maxResolution);this.params.width=s,this.params.height=c,this.params.resolution=l,this.application.renderer.resize(s,c,l);return{width:s,height:c,resolution:l,displayResolutionSyncCount:this.syncDisplayObjectResolution(l)}}setResolution(e,t={}){return this.resizeRenderer(_extends(_extends({},t),{resolution:e}))}clampResolution(e,t=3){const n=Number.isFinite(e)&&e>0?e:1;return Math.min(n,t)}syncDisplayObjectResolution(e){var t;const n=(null===(t=this.containerManager)||void 0===t?void 0:t.containerMap)?Object.values(this.containerManager.containerMap):[],r="undefined"!=typeof WeakSet?new WeakSet:void 0;let o=0;const i=t=>{if(t&&"object"==typeof t&&!(null==r?void 0:r.has(t))){if(null==r||r.add(t),"resolution"in t){const n=t.resolution;if(("number"==typeof n||null===n)&&Math.abs((null!=n?n:1)-e)>.001)try{t.resolution=e,"number"==typeof t.resolution&&Math.abs(t.resolution-e)<=.001&&(o+=1)}catch(e){}}if(Array.isArray(t.children))for(const e of t.children)i(e)}};for(const e of n)i(e);return o}getBounds(e,t){var n;return(null===(n=this.containerManager)||void 0===n?void 0:n.getBounds(e,t))||null}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,r){const o=this.getApplicationByScene(e);o&&o.renderer.resize(t,n,r)}};ht.systemName="Renderer",ht=o([t.decorators.componentObserver({Transform:["_parent"]})],ht);var pt=ht;let dt;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 i=null!==(r=function(){if(dt)return dt;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};dt={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(dt).filter(e=>dt[e]).join(", "))}catch(e){}return dt}())&&void 0!==r?r:{};let a=o.find(e=>i[e.type]);a&&_extends(e.src.image,a)})}class vt 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=it,e.Renderer=vt,e.RendererManager=rt,e.RendererSystem=pt,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;