@eva/plugin-a11y 1.2.0-alpha.4 → 1.2.0-alpha.8

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.
@@ -3,15 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var eva_js = require('@eva/eva.js');
6
- var pixi_js = require('pixi.js');
6
+ var pluginRenderer = require('@eva/plugin-renderer');
7
7
  var inspectorDecorator = require('@eva/inspector-decorator');
8
- var isEqual = require('lodash-es/isEqual');
9
- var EventEmitter = require('eventemitter3');
10
-
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
12
-
13
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
14
- var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
15
8
 
16
9
  /*! *****************************************************************************
17
10
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -106,918 +99,8 @@ function __values(o) {
106
99
  return { value: o && o[i++], done: !o };
107
100
  }
108
101
  };
109
- }
110
-
111
- function __read(o, n) {
112
- var m = typeof Symbol === "function" && o[Symbol.iterator];
113
- if (!m) return o;
114
- var i = m.call(o), r, ar = [], e;
115
- try {
116
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
117
- }
118
- catch (error) { e = { error: error }; }
119
- finally {
120
- try {
121
- if (r && !r.done && (m = i["return"])) m.call(i);
122
- }
123
- finally { if (e) throw e.error; }
124
- }
125
- return ar;
126
- }
127
-
128
- function __spread() {
129
- for (var ar = [], i = 0; i < arguments.length; i++)
130
- ar = ar.concat(__read(arguments[i]));
131
- return ar;
132
- }
133
-
134
- var Application = (function (_super) {
135
- __extends(Application, _super);
136
- function Application(params) {
137
- var _this = this;
138
- params.autoStart = false;
139
- _this = _super.call(this, params) || this;
140
- return _this;
141
- }
142
- return Application;
143
- }(pixi_js.Application));
144
- var Application$1 = Application;
145
-
146
- var Container = (function (_super) {
147
- __extends(Container, _super);
148
- function Container() {
149
- return _super !== null && _super.apply(this, arguments) || this;
150
- }
151
- return Container;
152
- }(pixi_js.Container));
153
- var Container$1 = Container;
154
-
155
- var RendererManager = (function () {
156
- function RendererManager(_a) {
157
- var game = _a.game, rendererSystem = _a.rendererSystem;
158
- this.renderers = [];
159
- this.game = game;
160
- this.rendererSystem = rendererSystem;
161
- }
162
- RendererManager.prototype.register = function () {
163
- var e_1, _a;
164
- var renderers = [];
165
- for (var _i = 0; _i < arguments.length; _i++) {
166
- renderers[_i] = arguments[_i];
167
- }
168
- try {
169
- for (var renderers_1 = __values(renderers), renderers_1_1 = renderers_1.next(); !renderers_1_1.done; renderers_1_1 = renderers_1.next()) {
170
- var renderer = renderers_1_1.value;
171
- renderer.game = this.game;
172
- renderer.rendererManager = this.rendererSystem.rendererManager;
173
- renderer.containerManager = this.rendererSystem.containerManager;
174
- this.renderers.push(renderer);
175
- }
176
- }
177
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
178
- finally {
179
- try {
180
- if (renderers_1_1 && !renderers_1_1.done && (_a = renderers_1.return)) _a.call(renderers_1);
181
- }
182
- finally { if (e_1) throw e_1.error; }
183
- }
184
- };
185
- RendererManager.prototype.componentChanged = function (changes) {
186
- var e_2, _a;
187
- var _loop_1 = function (changed) {
188
- var e_3, _a;
189
- try {
190
- for (var _b = (e_3 = void 0, __values(this_1.renderers)), _c = _b.next(); !_c.done; _c = _b.next()) {
191
- var renderer = _c.value;
192
- var props = renderer.observerInfo[changed.componentName];
193
- if (props) {
194
- if ([eva_js.OBSERVER_TYPE.ADD, eva_js.OBSERVER_TYPE.REMOVE].indexOf(changed.type) > -1) {
195
- try {
196
- renderer.componentChanged && renderer.componentChanged(changed);
197
- }
198
- catch (e) {
199
- console.error("gameObject: " + changed.gameObject.name + ", " + changed.componentName + " is error.", changed, e);
200
- }
201
- continue;
202
- }
203
- var index = props.findIndex(function (prop) {
204
- return isEqual__default(prop, changed.prop);
205
- });
206
- if (index > -1) {
207
- try {
208
- renderer.componentChanged && renderer.componentChanged(changed);
209
- }
210
- catch (e) {
211
- console.error("gameObject: " + (changed.gameObject && changed.gameObject.name) + ", " + changed.componentName + " is componentChanged error.", changed, e);
212
- }
213
- }
214
- }
215
- }
216
- }
217
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
218
- finally {
219
- try {
220
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
221
- }
222
- finally { if (e_3) throw e_3.error; }
223
- }
224
- };
225
- var this_1 = this;
226
- try {
227
- for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
228
- var changed = changes_1_1.value;
229
- _loop_1(changed);
230
- }
231
- }
232
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
233
- finally {
234
- try {
235
- if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
236
- }
237
- finally { if (e_2) throw e_2.error; }
238
- }
239
- };
240
- RendererManager.prototype.update = function (gameObject) {
241
- var e_4, _a, e_5, _b;
242
- try {
243
- for (var _c = __values(gameObject.components), _d = _c.next(); !_d.done; _d = _c.next()) {
244
- var component = _d.value;
245
- try {
246
- for (var _e = (e_5 = void 0, __values(this.renderers)), _f = _e.next(); !_f.done; _f = _e.next()) {
247
- var renderer = _f.value;
248
- var cache = [];
249
- var props = renderer.observerInfo[component.name];
250
- if (props && cache.indexOf(gameObject) === -1) {
251
- cache.push(gameObject);
252
- try {
253
- renderer.rendererUpdate && renderer.rendererUpdate(gameObject);
254
- }
255
- catch (e) {
256
- console.info("gameObject: " + gameObject.name + ", " + component.name + " is update error", e);
257
- }
258
- }
259
- }
260
- }
261
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
262
- finally {
263
- try {
264
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
265
- }
266
- finally { if (e_5) throw e_5.error; }
267
- }
268
- }
269
- }
270
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
271
- finally {
272
- try {
273
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
274
- }
275
- finally { if (e_4) throw e_4.error; }
276
- }
277
- };
278
- return RendererManager;
279
- }());
280
- var RendererManager$1 = RendererManager;
281
-
282
- var ContainerManager = (function () {
283
- function ContainerManager() {
284
- this.containerMap = {};
285
- }
286
- ContainerManager.prototype.addContainer = function (_a) {
287
- var name = _a.name, container = _a.container;
288
- this.containerMap[name] = container;
289
- };
290
- ContainerManager.prototype.getContainer = function (name) {
291
- return this.containerMap[name];
292
- };
293
- ContainerManager.prototype.removeContainer = function (name) {
294
- var _a;
295
- (_a = this.containerMap[name]) === null || _a === void 0 ? void 0 : _a.destroy({ children: true });
296
- delete this.containerMap[name];
297
- };
298
- ContainerManager.prototype.updateTransform = function (_a) {
299
- var name = _a.name, transform = _a.transform;
300
- var container = this.containerMap[name];
301
- if (!container)
302
- return;
303
- var anchor = transform.anchor, origin = transform.origin, position = transform.position, rotation = transform.rotation, scale = transform.scale, size = transform.size, skew = transform.skew;
304
- container.rotation = rotation;
305
- container.scale = scale;
306
- container.pivot.x = size.width * origin.x;
307
- container.pivot.y = size.height * origin.y;
308
- container.skew = skew;
309
- var x = position.x;
310
- var y = position.y;
311
- if (transform.parent) {
312
- var parent_1 = transform.parent;
313
- x = x + parent_1.size.width * anchor.x;
314
- y = y + parent_1.size.height * anchor.y;
315
- }
316
- container.position = { x: x, y: y };
317
- };
318
- return ContainerManager;
319
- }());
320
- var ContainerManager$1 = ContainerManager;
321
-
322
- var Transform = (function (_super) {
323
- __extends(Transform, _super);
324
- function Transform(_a) {
325
- var system = _a.system, containerManager = _a.containerManager;
326
- var _this = _super.call(this) || this;
327
- _this.name = 'Transform';
328
- _this.waitRemoveIds = [];
329
- _this.waitChangeScenes = [];
330
- _this.containerManager = containerManager;
331
- _this.init(system);
332
- return _this;
333
- }
334
- Transform.prototype.init = function (system) {
335
- var _this = this;
336
- this.system = system;
337
- this.on('changeScene', function (_a) {
338
- var scene = _a.scene, mode = _a.mode, application = _a.application;
339
- _this.waitChangeScenes.push({ scene: scene, mode: mode, application: application });
340
- });
341
- };
342
- Transform.prototype.update = function () {
343
- var e_1, _a, e_2, _b;
344
- try {
345
- for (var _c = __values(this.waitRemoveIds), _d = _c.next(); !_d.done; _d = _c.next()) {
346
- var id = _d.value;
347
- this.containerManager.removeContainer(id);
348
- }
349
- }
350
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
351
- finally {
352
- try {
353
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
354
- }
355
- finally { if (e_1) throw e_1.error; }
356
- }
357
- this.waitRemoveIds = [];
358
- try {
359
- for (var _e = __values(this.waitChangeScenes), _f = _e.next(); !_f.done; _f = _e.next()) {
360
- var sceneInfo = _f.value;
361
- var container = this.containerManager.getContainer(sceneInfo.scene.id);
362
- if (container) {
363
- sceneInfo.application.stage.removeChildren();
364
- sceneInfo.application.stage.addChild(container);
365
- }
366
- }
367
- }
368
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
369
- finally {
370
- try {
371
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
372
- }
373
- finally { if (e_2) throw e_2.error; }
374
- }
375
- this.waitChangeScenes = [];
376
- };
377
- Transform.prototype.componentChanged = function (changed) {
378
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
379
- this.addContainer(changed);
380
- }
381
- else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
382
- this.change(changed);
383
- }
384
- else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
385
- this.waitRemoveIds.push(changed.gameObject.id);
386
- }
387
- };
388
- Transform.prototype.addContainer = function (changed) {
389
- var container = new Container$1();
390
- container.name = changed.gameObject.name;
391
- this.containerManager.addContainer({
392
- name: changed.gameObject.id,
393
- container: container,
394
- });
395
- var transform = changed.component;
396
- transform.worldTransform = container.transform.worldTransform;
397
- };
398
- Transform.prototype.change = function (changed) {
399
- var transform = changed.component;
400
- if (transform.parent) {
401
- var parentContainer = this.containerManager.getContainer(transform.parent.gameObject.id);
402
- parentContainer.addChild(this.containerManager.getContainer(changed.gameObject.id));
403
- var render = changed.gameObject.transform.parent &&
404
- changed.gameObject.transform.parent.gameObject.getComponent('Render');
405
- if (render) {
406
- render.sortDirty = true;
407
- }
408
- }
409
- else {
410
- var container = this.containerManager.getContainer(changed.gameObject.id);
411
- delete transform.worldTransform;
412
- container.parent && container.parent.removeChild(container);
413
- }
414
- };
415
- Transform.prototype.destroy = function () {
416
- this.removeAllListeners();
417
- this.waitRemoveIds = null;
418
- this.waitChangeScenes = null;
419
- this.system = null;
420
- this.containerManager = null;
421
- };
422
- Transform = __decorate([
423
- eva_js.decorators.componentObserver({
424
- Transform: ['_parent'],
425
- })
426
- ], Transform);
427
- return Transform;
428
- }(EventEmitter__default));
429
- var Transform$1 = Transform;
430
-
431
- var result = undefined;
432
- function getSuportCompressedTextureFormats(gl) {
433
- if (result)
434
- return result;
435
- if (!gl) {
436
- console.warn('WebGL not available for compressed textures. Silently failing.');
437
- return {
438
- s3tc: false,
439
- etc: false,
440
- etc1: false,
441
- pvrtc: false,
442
- atc: false,
443
- astc: false,
444
- };
445
- }
446
- result = {
447
- s3tc: !!gl.getExtension('WEBGL_compressed_texture_s3tc'),
448
- etc: !!gl.getExtension('WEBGL_compressed_texture_etc'),
449
- etc1: !!gl.getExtension('WEBGL_compressed_texture_etc1'),
450
- pvrtc: !!gl.getExtension('WEBGL_compressed_texture_pvrtc')
451
- || !!gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'),
452
- atc: !!gl.getExtension('WEBGL_compressed_texture_atc'),
453
- astc: !!gl.getExtension('WEBGL_compressed_texture_astc')
454
- };
455
- try {
456
- console.log('Eva.js Supported Compressed Texture Format List: ' + Object.keys(result).filter(function (type) { return result[type]; }).join(', '));
457
- }
458
- catch (e) { }
459
- return result;
460
- }
461
-
462
- var XLS = eva_js.resourceLoader.XhrLoadStrategy;
463
- var XhrLoadStrategy = XLS;
464
-
465
- var _a$2, _b;
466
- var INTERNAL_FORMATS;
467
- (function (INTERNAL_FORMATS) {
468
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_S3TC_DXT1_EXT"] = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT";
469
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT1_EXT"] = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT";
470
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT3_EXT"] = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT";
471
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT5_EXT"] = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT";
472
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"] = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT";
473
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"] = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT";
474
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"] = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT";
475
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_S3TC_DXT1_EXT"] = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT";
476
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_R11_EAC"] = 37488] = "COMPRESSED_R11_EAC";
477
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_R11_EAC"] = 37489] = "COMPRESSED_SIGNED_R11_EAC";
478
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RG11_EAC"] = 37490] = "COMPRESSED_RG11_EAC";
479
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_RG11_EAC"] = 37491] = "COMPRESSED_SIGNED_RG11_EAC";
480
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_ETC2"] = 37492] = "COMPRESSED_RGB8_ETC2";
481
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA8_ETC2_EAC"] = 37496] = "COMPRESSED_RGBA8_ETC2_EAC";
482
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ETC2"] = 37493] = "COMPRESSED_SRGB8_ETC2";
483
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"] = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC";
484
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2";
485
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2";
486
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_4BPPV1_IMG"] = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG";
487
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"] = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG";
488
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_2BPPV1_IMG"] = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG";
489
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"] = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG";
490
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ETC1_WEBGL"] = 36196] = "COMPRESSED_RGB_ETC1_WEBGL";
491
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ATC_WEBGL"] = 35986] = "COMPRESSED_RGB_ATC_WEBGL";
492
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL"] = 35986] = "COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL";
493
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL"] = 34798] = "COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL";
494
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x10_KHR"] = 37819] = "COMPRESSED_RGBA_ASTC_10x10_KHR";
495
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x5_KHR"] = 37816] = "COMPRESSED_RGBA_ASTC_10x5_KHR";
496
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x6_KHR"] = 37817] = "COMPRESSED_RGBA_ASTC_10x6_KHR";
497
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x8_KHR"] = 37818] = "COMPRESSED_RGBA_ASTC_10x8_KHR";
498
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x10_KHR"] = 37820] = "COMPRESSED_RGBA_ASTC_12x10_KHR";
499
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x12_KHR"] = 37821] = "COMPRESSED_RGBA_ASTC_12x12_KHR";
500
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_4x4_KHR"] = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR";
501
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x4_KHR"] = 37809] = "COMPRESSED_RGBA_ASTC_5x4_KHR";
502
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x5_KHR"] = 37810] = "COMPRESSED_RGBA_ASTC_5x5_KHR";
503
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x5_KHR"] = 37811] = "COMPRESSED_RGBA_ASTC_6x5_KHR";
504
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x6_KHR"] = 37812] = "COMPRESSED_RGBA_ASTC_6x6_KHR";
505
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x5_KHR"] = 37813] = "COMPRESSED_RGBA_ASTC_8x5_KHR";
506
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x6_KHR"] = 37814] = "COMPRESSED_RGBA_ASTC_8x6_KHR";
507
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x8_KHR"] = 37815] = "COMPRESSED_RGBA_ASTC_8x8_KHR";
508
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"] = 3781] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR";
509
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR";
510
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"] = 37849] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR";
511
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"] = 37850] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR";
512
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"] = 37852] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR";
513
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"] = 37853] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR";
514
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"] = 37840] = "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR";
515
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"] = 37841] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR";
516
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"] = 37842] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR";
517
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"] = 37843] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR";
518
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"] = 37844] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR";
519
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"] = 37845] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR";
520
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"] = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR";
521
- INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR";
522
- })(INTERNAL_FORMATS || (INTERNAL_FORMATS = {}));
523
- var INTERNAL_FORMAT_TO_BLOCK_SIZE = (_a$2 = {},
524
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = [4, 4],
525
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = [4, 4],
526
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = [4, 4],
527
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = [4, 4],
528
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = [4, 4],
529
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = [4, 4],
530
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = [4, 4],
531
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = [4, 4],
532
- _a$2[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = [4, 4],
533
- _a$2[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = [4, 4],
534
- _a$2[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = [4, 4],
535
- _a$2[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = [4, 4],
536
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = [4, 4],
537
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = [4, 4],
538
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = [4, 4],
539
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = [4, 4],
540
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4],
541
- _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4],
542
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = [4, 4],
543
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = [4, 4],
544
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = [8, 4],
545
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = [8, 4],
546
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = [4, 4],
547
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = [4, 4],
548
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = [4, 4],
549
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = [4, 4],
550
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = [4, 4],
551
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = [5, 5],
552
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = [6, 6],
553
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = [8, 8],
554
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = [10, 10],
555
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = [12, 12],
556
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x5_KHR] = [10, 5],
557
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x6_KHR] = [10, 6],
558
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x8_KHR] = [10, 8],
559
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x10_KHR] = [12, 10],
560
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x4_KHR] = [5, 4],
561
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x5_KHR] = [6, 5],
562
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x5_KHR] = [8, 5],
563
- _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x6_KHR] = [8, 6],
564
- _a$2);
565
- var INTERNAL_FORMATS_TO_EXTENSION_NAME = (_b = {},
566
- _b[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc',
567
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc',
568
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc',
569
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc',
570
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb',
571
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb',
572
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc_srgb',
573
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc_srgb',
574
- _b[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = 'WEBGL_compressed_texture_etc',
575
- _b[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = 'WEBGL_compressed_texture_etc',
576
- _b[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = 'WEBGL_compressed_texture_etc',
577
- _b[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = 'WEBGL_compressed_texture_etc',
578
- _b[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = 'WEBGL_compressed_texture_etc',
579
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc',
580
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = 'WEBGL_compressed_texture_etc',
581
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc',
582
- _b[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc',
583
- _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc',
584
- _b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc',
585
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc',
586
- _b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc',
587
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc',
588
- _b[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = 'WEBGL_compressed_texture_etc1',
589
- _b[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = 'WEBGL_compressed_texture_atc',
590
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc',
591
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc',
592
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = 'WEBGL_compressed_texture_astc',
593
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = 'WEBGL_compressed_texture_astc',
594
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = 'WEBGL_compressed_texture_astc',
595
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = 'WEBGL_compressed_texture_astc',
596
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = 'WEBGL_compressed_texture_astc',
597
- _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = 'WEBGL_compressed_texture_astc',
598
- _b);
599
-
600
- var CompressedTextureResource = (function () {
601
- function CompressedTextureResource() {
602
- this.levelBuffers = [];
603
- }
604
- CompressedTextureResource.prototype.upload = function (gl) {
605
- var levels = this.levels;
606
- var name = INTERNAL_FORMATS_TO_EXTENSION_NAME[this.internalFormat];
607
- if (!gl[name]) {
608
- gl[name] = true;
609
- if (name === 'WEBGL_compressed_texture_pvrtc') {
610
- gl.getExtension(name) || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
611
- }
612
- else {
613
- gl.getExtension(name);
614
- }
615
- }
616
- for (var i = 0; i < this.levels; ++i) {
617
- var _a = this.levelBuffers[i], levelWidth = _a.levelWidth, levelHeight = _a.levelHeight, levelBuffer = _a.levelBuffer;
618
- gl.compressedTexImage2D(gl.TEXTURE_2D, i, this.internalFormat, levelWidth, levelHeight, 0, levelBuffer);
619
- }
620
- if (levels > 1) {
621
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
622
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
623
- }
624
- else {
625
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
626
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
627
- }
628
- };
629
- return CompressedTextureResource;
630
- }());
631
-
632
- var FILE_HEADER_SIZE = 64;
633
- var KTX_FIELDS = {
634
- FILE_IDENTIFIER: 0,
635
- ENDIANNESS: 12,
636
- GL_TYPE: 16,
637
- GL_TYPE_SIZE: 20,
638
- GL_FORMAT: 24,
639
- GL_INTERNAL_FORMAT: 28,
640
- GL_BASE_INTERNAL_FORMAT: 32,
641
- PIXEL_WIDTH: 36,
642
- PIXEL_HEIGHT: 40,
643
- PIXEL_DEPTH: 44,
644
- NUMBER_OF_ARRAY_ELEMENTS: 48,
645
- NUMBER_OF_FACES: 52,
646
- NUMBER_OF_MIPMAP_LEVELS: 56,
647
- BYTES_OF_KEY_VALUE_DATA: 60
648
- };
649
- var FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A];
650
- var ENDIANNESS = 0x04030201;
651
- var KTXTextureResource = (function (_super) {
652
- __extends(KTXTextureResource, _super);
653
- function KTXTextureResource(source, config) {
654
- var _a;
655
- var _this = _super.call(this) || this;
656
- _this.complete = true;
657
- _this.src = config.url;
658
- var dataView = new DataView(source);
659
- if (!validateKTX(dataView)) {
660
- throw new Error('Not a valid KTX Texture');
661
- }
662
- var littleEndian = dataView.getUint32(KTX_FIELDS.ENDIANNESS, true) === ENDIANNESS;
663
- _this.internalFormat = dataView.getUint32(KTX_FIELDS.GL_INTERNAL_FORMAT, littleEndian);
664
- var pixelWidth = _this.formerWidth = dataView.getUint32(KTX_FIELDS.PIXEL_WIDTH, littleEndian);
665
- var pixelHeight = _this.formerHeight = dataView.getUint32(KTX_FIELDS.PIXEL_HEIGHT, littleEndian) || 1;
666
- var size = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat];
667
- _this.width = pixelWidth % size[0] === 0 ? pixelWidth : (pixelWidth + size[0] - (pixelWidth % size[0]));
668
- _this.height = pixelHeight % size[1] === 0 ? pixelHeight : (pixelHeight + size[1] - (pixelHeight % size[1]));
669
- var src = eva_js.resource.resourcesMap[config.metadata.name].src[config.metadata.key];
670
- var _b = (_a = src === null || src === void 0 ? void 0 : src.size) !== null && _a !== void 0 ? _a : {}, width = _b.width, height = _b.height;
671
- if (width && height) {
672
- _this.naturalWidth = width;
673
- _this.naturalHeight = height;
674
- }
675
- var pixelDepth = dataView.getUint32(KTX_FIELDS.PIXEL_DEPTH, littleEndian) || 1;
676
- var numberOfArrayElements = dataView.getUint32(KTX_FIELDS.NUMBER_OF_ARRAY_ELEMENTS, littleEndian) || 1;
677
- var numberOfFaces = dataView.getUint32(KTX_FIELDS.NUMBER_OF_FACES, littleEndian);
678
- var numberOfMipmapLevels = _this.levels = dataView.getUint32(KTX_FIELDS.NUMBER_OF_MIPMAP_LEVELS, littleEndian);
679
- var bytesOfKeyValueData = dataView.getUint32(KTX_FIELDS.BYTES_OF_KEY_VALUE_DATA, littleEndian);
680
- if (pixelHeight === 0 || pixelDepth !== 1) {
681
- throw new Error('Only 2D textures are supported!');
682
- }
683
- if (numberOfFaces !== 1) {
684
- throw new Error('CubeTextures are not supported!');
685
- }
686
- if (numberOfArrayElements !== 1) {
687
- throw new Error('It does not support array textures!');
688
- }
689
- var mipWidth = pixelWidth;
690
- var mipHeight = pixelHeight;
691
- var imageOffset = FILE_HEADER_SIZE + bytesOfKeyValueData;
692
- for (var mipmapLevel = 0; mipmapLevel < numberOfMipmapLevels; mipmapLevel++) {
693
- var imageSize = dataView.getUint32(imageOffset, littleEndian);
694
- imageOffset += 4;
695
- var size_1 = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat];
696
- var levelWidth = mipWidth % size_1[0] === 0 ? mipWidth : mipWidth + size_1[0] - (mipWidth % size_1[0]);
697
- var levelHeight = mipHeight % size_1[1] === 0 ? mipHeight : mipHeight + size_1[1] - (mipHeight % size_1[1]);
698
- var mip = {
699
- levelID: mipmapLevel,
700
- levelWidth: levelWidth,
701
- levelHeight: levelHeight,
702
- levelBuffer: new Uint8Array(source, imageOffset, imageSize)
703
- };
704
- _this.levelBuffers.push(mip);
705
- imageOffset += imageSize;
706
- imageOffset += 3 - ((imageOffset + 3) % 4);
707
- mipWidth = (mipWidth >> 1) || 1;
708
- mipHeight = (mipHeight >> 1) || 1;
709
- }
710
- return _this;
711
- }
712
- return KTXTextureResource;
713
- }(CompressedTextureResource));
714
- function validateKTX(dataView) {
715
- for (var i = 0; i < FILE_IDENTIFIER.length; i++) {
716
- if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) {
717
- return false;
718
- }
719
- }
720
- return true;
721
- }
722
-
723
- var KTXLoadStrategy = (function (_super) {
724
- __extends(KTXLoadStrategy, _super);
725
- function KTXLoadStrategy() {
726
- return _super !== null && _super.apply(this, arguments) || this;
727
- }
728
- KTXLoadStrategy.prototype._complete = function (type, data) {
729
- _super.prototype._complete.call(this, type, new KTXTextureResource(data, this.config));
730
- };
731
- return KTXLoadStrategy;
732
- }(XhrLoadStrategy));
733
- var KTXLoadStrategy$1 = KTXLoadStrategy;
734
-
735
- var XhrResponseType = eva_js.resourceLoader.XhrResponseType;
736
- function addPreProcessResourceHandler(resource, gl) {
737
- resource.addPreProcessResourceHandler(function normalizeResource(resource) {
738
- var _a, _b, _c;
739
- var textures = (_b = (_a = resource.src) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.texture;
740
- if (!textures)
741
- return;
742
- if (!Array.isArray(textures)) {
743
- textures = [textures];
744
- }
745
- var formats = (_c = getSuportCompressedTextureFormats(gl)) !== null && _c !== void 0 ? _c : {};
746
- var target = textures.find(function (texture) { return formats[texture.type]; });
747
- if (target) {
748
- Object.assign(resource.src.image, target);
749
- }
750
- });
751
- }
752
- function addKTXStragetyAndRegister() {
753
- Object.assign(eva_js.RESOURCE_TYPE_STRATEGY, {
754
- astc: KTXLoadStrategy$1,
755
- etc: KTXLoadStrategy$1,
756
- pvrtc: KTXLoadStrategy$1,
757
- s3tc: KTXLoadStrategy$1,
758
- atc: KTXLoadStrategy$1,
759
- });
760
- KTXLoadStrategy$1.setExtensionXhrType('ktx', XhrResponseType.Buffer);
761
102
  }
762
103
 
763
- var GLTexture = pixi_js.glCore.GLTexture;
764
- var GLTextureMixin = {
765
- isCompressed: false,
766
- uploadNotCompressed: GLTexture.prototype.upload,
767
- upload: function (source) {
768
- if (!(source instanceof CompressedTextureResource)) {
769
- return this.uploadNotCompressed(source);
770
- }
771
- this.bind();
772
- var gl = this.gl;
773
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
774
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST);
775
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
776
- this.isCompressed = true;
777
- source.upload(gl);
778
- },
779
- enableMipmap: function () {
780
- if (this.isCompressed) {
781
- return;
782
- }
783
- var gl = this.gl;
784
- this.bind();
785
- this.mipmap = true;
786
- gl.generateMipmap(gl.TEXTURE_2D);
787
- }
788
- };
789
-
790
- var _a$1;
791
- var oldFrom$1 = Symbol();
792
- var TextureMixin = (_a$1 = {},
793
- _a$1[oldFrom$1] = pixi_js.Texture.from,
794
- _a$1.from = function (source) {
795
- if (!(source instanceof CompressedTextureResource)) {
796
- return this[oldFrom$1](source);
797
- }
798
- return new pixi_js.Texture(pixi_js.BaseTexture.from(source));
799
- },
800
- _a$1);
801
-
802
- var _a;
803
- var oldFrom = Symbol();
804
- var BaseTextureMixin = (_a = {},
805
- _a[oldFrom] = pixi_js.BaseTexture.from,
806
- _a.from = function (source, scaleMode, sourceScale) {
807
- if (!(source instanceof CompressedTextureResource)) {
808
- return this[oldFrom](source, scaleMode, sourceScale);
809
- }
810
- var imageUrl = source.src;
811
- var baseTexture = pixi_js.utils.BaseTextureCache[imageUrl];
812
- if (!baseTexture) {
813
- baseTexture = new pixi_js.BaseTexture(source, scaleMode);
814
- baseTexture.imageUrl = imageUrl;
815
- if (sourceScale) {
816
- baseTexture.sourceScale = sourceScale;
817
- }
818
- pixi_js.BaseTexture.addToCache(baseTexture, imageUrl);
819
- }
820
- return baseTexture;
821
- },
822
- _a);
823
-
824
- function registerCompressedTexture(gl) {
825
- addPreProcessResourceHandler(eva_js.resource, gl);
826
- addKTXStragetyAndRegister();
827
- Object.assign(pixi_js.glCore.GLTexture.prototype, GLTextureMixin);
828
- Object.assign(pixi_js.Texture, TextureMixin);
829
- Object.assign(pixi_js.BaseTexture, BaseTextureMixin);
830
- }
831
-
832
- var RENDERER_TYPE;
833
- (function (RENDERER_TYPE) {
834
- RENDERER_TYPE[RENDERER_TYPE["UNKNOWN"] = 0] = "UNKNOWN";
835
- RENDERER_TYPE[RENDERER_TYPE["WEBGL"] = 1] = "WEBGL";
836
- RENDERER_TYPE[RENDERER_TYPE["CANVAS"] = 2] = "CANVAS";
837
- })(RENDERER_TYPE || (RENDERER_TYPE = {}));
838
- var disableScroll = function (renderer) {
839
- renderer.plugins.interaction.autoPreventDefault = true;
840
- renderer.view.style.touchAction = 'none';
841
- };
842
- var enableScroll = function (renderer) {
843
- renderer.plugins.interaction.autoPreventDefault = false;
844
- renderer.view.style.touchAction = 'auto';
845
- };
846
- var Renderer = (function (_super) {
847
- __extends(Renderer, _super);
848
- function Renderer() {
849
- var _this = _super !== null && _super.apply(this, arguments) || this;
850
- _this.multiApps = [];
851
- return _this;
852
- }
853
- Renderer.prototype.init = function (params) {
854
- var _this = this;
855
- this.params = params;
856
- this.application = this.createApplication(params);
857
- this.containerManager = new ContainerManager$1();
858
- this.rendererManager = new RendererManager$1({
859
- game: this.game,
860
- rendererSystem: this,
861
- });
862
- this.game.canvas = this.application.view;
863
- this.transform = new Transform$1({
864
- system: this,
865
- containerManager: this.containerManager,
866
- });
867
- this.game.on('sceneChanged', function (_a) {
868
- var scene = _a.scene, mode = _a.mode, params = _a.params;
869
- var application;
870
- switch (mode) {
871
- case eva_js.LOAD_SCENE_MODE.SINGLE:
872
- application = _this.application;
873
- break;
874
- case eva_js.LOAD_SCENE_MODE.MULTI_CANVAS:
875
- application = _this.createMultiApplication({ params: params });
876
- break;
877
- }
878
- scene.canvas = application.view;
879
- _this.transform.emit('changeScene', {
880
- scene: scene,
881
- mode: mode,
882
- application: application,
883
- });
884
- });
885
- var gl = this.application.renderer.gl;
886
- if (gl) {
887
- this.suportedCompressedTextureFormats = getSuportCompressedTextureFormats(gl);
888
- registerCompressedTexture(gl);
889
- }
890
- };
891
- Renderer.prototype.registerObserver = function (observerInfo) {
892
- var _a;
893
- var thisObserverInfo = this.constructor.observerInfo;
894
- for (var key in observerInfo) {
895
- if (!thisObserverInfo[key]) {
896
- thisObserverInfo[key] = [];
897
- }
898
- (_a = thisObserverInfo[key]).push.apply(_a, __spread(observerInfo[key]));
899
- }
900
- };
901
- Renderer.prototype.createMultiApplication = function (_a) {
902
- var params = _a.params;
903
- var app = this.createApplication(params);
904
- this.multiApps.push(app);
905
- return app;
906
- };
907
- Renderer.prototype.createApplication = function (params) {
908
- params.view = params.canvas;
909
- if (params.renderType === RENDERER_TYPE.CANVAS) {
910
- params.forceCanvas = true;
911
- }
912
- pixi_js.ticker.shared.autoStart = false;
913
- pixi_js.ticker.shared.stop();
914
- var app = new Application$1(__assign({ sharedTicker: true }, params));
915
- if (params.preventScroll !== undefined) {
916
- console.warn('PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game');
917
- params.preventScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
918
- }
919
- if (params.enableScroll !== undefined) {
920
- params.enableScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
921
- }
922
- if (params.preventScroll === undefined && params.enableScroll === undefined) {
923
- enableScroll(app.renderer);
924
- }
925
- return app;
926
- };
927
- Renderer.prototype.update = function () {
928
- var e_1, _a, e_2, _b;
929
- var changes = this.componentObserver.clear();
930
- try {
931
- for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
932
- var changed = changes_1_1.value;
933
- this.transform.componentChanged(changed);
934
- }
935
- }
936
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
937
- finally {
938
- try {
939
- if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
940
- }
941
- finally { if (e_1) throw e_1.error; }
942
- }
943
- try {
944
- for (var _c = __values(this.game.gameObjects), _d = _c.next(); !_d.done; _d = _c.next()) {
945
- var gameObject = _d.value;
946
- this.containerManager.updateTransform({
947
- name: gameObject.id,
948
- transform: gameObject.transform,
949
- });
950
- this.rendererManager.update(gameObject);
951
- }
952
- }
953
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
954
- finally {
955
- try {
956
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
957
- }
958
- finally { if (e_2) throw e_2.error; }
959
- }
960
- };
961
- Renderer.prototype.lateUpdate = function (e) {
962
- this.transform.update();
963
- this.application.ticker.update(e.time);
964
- };
965
- Renderer.prototype.onDestroy = function () {
966
- var e_3, _a;
967
- this.application.destroy();
968
- try {
969
- for (var _b = __values(this.multiApps), _c = _b.next(); !_c.done; _c = _b.next()) {
970
- var app = _c.value;
971
- app && app.destroy();
972
- }
973
- }
974
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
975
- finally {
976
- try {
977
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
978
- }
979
- finally { if (e_3) throw e_3.error; }
980
- }
981
- this.transform.destroy();
982
- this.transform = null;
983
- this.params = null;
984
- this.rendererManager = null;
985
- this.containerManager = null;
986
- this.application = null;
987
- this.game = null;
988
- this.multiApps = null;
989
- };
990
- Renderer.prototype.resize = function (width, height) {
991
- this.params.width = width;
992
- this.params.height = height;
993
- this.application.renderer.resize(width, height);
994
- };
995
- Renderer.systemName = 'Renderer';
996
- Renderer = __decorate([
997
- eva_js.decorators.componentObserver({
998
- Transform: ['_parent'],
999
- })
1000
- ], Renderer);
1001
- return Renderer;
1002
- }(eva_js.System));
1003
- var RendererSystem = Renderer;
1004
-
1005
- var mixinPIXI = function () {
1006
- pixi_js.BaseTexture.prototype.destroy = function () {
1007
- if (this.imageUrl) {
1008
- delete pixi_js.utils.TextureCache[this.imageUrl];
1009
- this.imageUrl = null;
1010
- }
1011
- this.source = null;
1012
- this.dispose();
1013
- pixi_js.BaseTexture.removeFromCache(this);
1014
- this.textureCacheIds = null;
1015
- this._destroyed = true;
1016
- };
1017
- };
1018
-
1019
- mixinPIXI();
1020
-
1021
104
  function uuid(len) {
1022
105
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
1023
106
  var uuid = [];
@@ -1129,6 +212,7 @@ var A11ySystem = (function (_super) {
1129
212
  var _this = _super.call(this, opt) || this;
1130
213
  _this.cache = new Map();
1131
214
  _this.eventCache = new Map();
215
+ _this.zIndex = ZINDEX;
1132
216
  return _this;
1133
217
  }
1134
218
  Object.defineProperty(A11ySystem.prototype, "ratioX", {
@@ -1170,12 +254,13 @@ var A11ySystem = (function (_super) {
1170
254
  A11ySystem.prototype.init = function (opt) {
1171
255
  if (opt === void 0) { opt = {}; }
1172
256
  return __awaiter(this, void 0, void 0, function () {
1173
- var _a, activate, _b, delay, _c, checkA11yOpen, _d, _e, div;
257
+ var _a, activate, _b, delay, _c, checkA11yOpen, zIndex, _d, _e, div;
1174
258
  return __generator(this, function (_f) {
1175
259
  switch (_f.label) {
1176
260
  case 0:
1177
- _a = opt.activate, activate = _a === void 0 ? exports.A11yActivate.CHECK : _a, _b = opt.delay, delay = _b === void 0 ? 100 : _b, _c = opt.checkA11yOpen, checkA11yOpen = _c === void 0 ? function () { return Promise.resolve(false); } : _c;
261
+ _a = opt.activate, activate = _a === void 0 ? exports.A11yActivate.CHECK : _a, _b = opt.delay, delay = _b === void 0 ? 100 : _b, _c = opt.checkA11yOpen, checkA11yOpen = _c === void 0 ? function () { return Promise.resolve(false); } : _c, zIndex = opt.zIndex;
1178
262
  this.delay = delay;
263
+ this.zIndex = zIndex || this.zIndex;
1179
264
  _d = activate;
1180
265
  switch (_d) {
1181
266
  case exports.A11yActivate.CHECK: return [3, 1];
@@ -1211,7 +296,7 @@ var A11ySystem = (function (_super) {
1211
296
  div = document.createElement('div');
1212
297
  this.div = div;
1213
298
  if (this.game.canvas.parentNode) {
1214
- this.game.canvas.parentNode.appendChild(this.div);
299
+ this.game.canvas.parentNode.insertBefore(this.div, this.game.canvas);
1215
300
  }
1216
301
  return [2];
1217
302
  }
@@ -1232,7 +317,7 @@ var A11ySystem = (function (_super) {
1232
317
  }
1233
318
  };
1234
319
  A11ySystem.prototype.getRenderRect = function () {
1235
- var _a = this.game.getSystem(RendererSystem).params, params = _a === void 0 ? { width: 300, height: 300 } : _a;
320
+ var _a = this.game.getSystem(pluginRenderer.RendererSystem).params, params = _a === void 0 ? { width: 300, height: 300 } : _a;
1236
321
  var renderHeight = params.height, renderWidth = params.width;
1237
322
  return { renderWidth: renderWidth, renderHeight: renderHeight };
1238
323
  };
@@ -1250,7 +335,7 @@ var A11ySystem = (function (_super) {
1250
335
  left: left + pageXOffset + "px",
1251
336
  top: top + pageYOffset + "px",
1252
337
  position: POSITION,
1253
- zIndex: ZINDEX,
338
+ zIndex: this.zIndex,
1254
339
  pointerEvents: PointerEvents.NONE,
1255
340
  background: MaskBackground.NONE,
1256
341
  };
@@ -1453,7 +538,7 @@ var A11ySystem = (function (_super) {
1453
538
  width: width === 0 ? 1 : width * this.ratioX,
1454
539
  height: height === 0 ? 1 : height * this.ratioY,
1455
540
  position: POSITION,
1456
- zIndex: ZINDEX,
541
+ zIndex: this.zIndex,
1457
542
  pointerEvents: PointerEvents.AUTO,
1458
543
  background: this.debug ? MaskBackground.DEBUG : MaskBackground.NONE,
1459
544
  };
@@ -1465,6 +550,7 @@ var A11ySystem = (function (_super) {
1465
550
  this.div.parentElement.removeChild(this.div);
1466
551
  this.cache = null;
1467
552
  this.eventCache = null;
553
+ this.div = null;
1468
554
  };
1469
555
  A11ySystem.systemName = 'A11ySystem';
1470
556
  A11ySystem = __decorate([