@eva/plugin-renderer 1.2.7-fix.4 → 1.2.7-fix.6
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.
- package/dist/EVA.plugin.renderer.js +450 -201
- package/dist/EVA.plugin.renderer.js.map +1 -0
- package/dist/EVA.plugin.renderer.min.js +1 -1
- package/dist/miniprogram.js +192 -20
- package/dist/plugin-renderer.cjs.js +3 -12
- package/dist/plugin-renderer.cjs.js.map +1 -0
- package/dist/plugin-renderer.cjs.prod.js +1 -1
- package/dist/plugin-renderer.d.ts +2 -2
- package/dist/plugin-renderer.esm.js +2 -11
- package/dist/plugin-renderer.esm.js.map +1 -0
- package/package.json +3 -3
package/dist/miniprogram.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
2
3
|
import { __values, __extends, __decorate, __spread, __assign } from 'tslib';
|
|
3
4
|
import { OBSERVER_TYPE, decorators, resourceLoader, resource, RESOURCE_TYPE_STRATEGY, LOAD_SCENE_MODE, System } from '@eva/eva.js/dist/miniprogram';
|
|
4
5
|
import { Container, Application } from '@eva/renderer-adapter/dist/miniprogram';
|
|
5
6
|
import isEqual from 'lodash-es/isEqual';
|
|
6
7
|
import EventEmitter from 'eventemitter3';
|
|
7
8
|
import { glCore, Texture, BaseTexture, utils, ticker } from '@eva/miniprogram-pixi';
|
|
9
|
+
|
|
8
10
|
var RendererManager = function () {
|
|
9
11
|
function RendererManager(_a) {
|
|
10
12
|
var game = _a.game,
|
|
11
|
-
|
|
13
|
+
rendererSystem = _a.rendererSystem;
|
|
12
14
|
this.renderers = [];
|
|
13
15
|
this.game = game;
|
|
14
16
|
this.rendererSystem = rendererSystem;
|
|
15
17
|
}
|
|
18
|
+
|
|
16
19
|
RendererManager.prototype.register = function () {
|
|
17
20
|
var e_1, _a;
|
|
21
|
+
|
|
18
22
|
var renderers = [];
|
|
23
|
+
|
|
19
24
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
20
25
|
renderers[_i] = arguments[_i];
|
|
21
26
|
}
|
|
27
|
+
|
|
22
28
|
try {
|
|
23
29
|
for (var renderers_1 = __values(renderers), renderers_1_1 = renderers_1.next(); !renderers_1_1.done; renderers_1_1 = renderers_1.next()) {
|
|
24
30
|
var renderer = renderers_1_1.value;
|
|
@@ -39,14 +45,18 @@ var RendererManager = function () {
|
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
};
|
|
48
|
+
|
|
42
49
|
RendererManager.prototype.componentChanged = function (changes) {
|
|
43
50
|
var e_2, _a;
|
|
51
|
+
|
|
44
52
|
var _loop_1 = function _loop_1(changed) {
|
|
45
53
|
var e_3, _a;
|
|
54
|
+
|
|
46
55
|
try {
|
|
47
56
|
for (var _b = (e_3 = void 0, __values(this_1.renderers)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
48
57
|
var renderer = _c.value;
|
|
49
58
|
var props = renderer.observerInfo[changed.componentName];
|
|
59
|
+
|
|
50
60
|
if (props) {
|
|
51
61
|
if ([OBSERVER_TYPE.ADD, OBSERVER_TYPE.REMOVE].indexOf(changed.type) > -1) {
|
|
52
62
|
try {
|
|
@@ -54,11 +64,14 @@ var RendererManager = function () {
|
|
|
54
64
|
} catch (e) {
|
|
55
65
|
console.error("gameObject: " + changed.gameObject.name + ", " + changed.componentName + " is error.", changed, e);
|
|
56
66
|
}
|
|
67
|
+
|
|
57
68
|
continue;
|
|
58
69
|
}
|
|
70
|
+
|
|
59
71
|
var index = props.findIndex(function (prop) {
|
|
60
72
|
return isEqual(prop, changed.prop);
|
|
61
73
|
});
|
|
74
|
+
|
|
62
75
|
if (index > -1) {
|
|
63
76
|
try {
|
|
64
77
|
renderer.componentChanged && renderer.componentChanged(changed);
|
|
@@ -80,10 +93,13 @@ var RendererManager = function () {
|
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
95
|
};
|
|
96
|
+
|
|
83
97
|
var this_1 = this;
|
|
98
|
+
|
|
84
99
|
try {
|
|
85
100
|
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
86
101
|
var changed = changes_1_1.value;
|
|
102
|
+
|
|
87
103
|
_loop_1(changed);
|
|
88
104
|
}
|
|
89
105
|
} catch (e_2_1) {
|
|
@@ -98,18 +114,23 @@ var RendererManager = function () {
|
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
116
|
};
|
|
117
|
+
|
|
101
118
|
RendererManager.prototype.update = function (gameObject) {
|
|
102
119
|
var e_4, _a, e_5, _b;
|
|
120
|
+
|
|
103
121
|
try {
|
|
104
122
|
for (var _c = __values(gameObject.components), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
105
123
|
var component = _d.value;
|
|
124
|
+
|
|
106
125
|
try {
|
|
107
126
|
for (var _e = (e_5 = void 0, __values(this.renderers)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
108
127
|
var renderer = _f.value;
|
|
109
128
|
var cache = [];
|
|
110
129
|
var props = renderer.observerInfo[component.name];
|
|
130
|
+
|
|
111
131
|
if (props && cache.indexOf(gameObject) === -1) {
|
|
112
132
|
cache.push(gameObject);
|
|
133
|
+
|
|
113
134
|
try {
|
|
114
135
|
renderer.rendererUpdate && renderer.rendererUpdate(gameObject);
|
|
115
136
|
} catch (e) {
|
|
@@ -141,40 +162,48 @@ var RendererManager = function () {
|
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
164
|
};
|
|
165
|
+
|
|
144
166
|
return RendererManager;
|
|
145
167
|
}();
|
|
168
|
+
|
|
146
169
|
var RendererManager$1 = RendererManager;
|
|
170
|
+
|
|
147
171
|
var ContainerManager = function () {
|
|
148
172
|
function ContainerManager() {
|
|
149
173
|
this.containerMap = {};
|
|
150
174
|
}
|
|
175
|
+
|
|
151
176
|
ContainerManager.prototype.addContainer = function (_a) {
|
|
152
177
|
var name = _a.name,
|
|
153
|
-
|
|
178
|
+
container = _a.container;
|
|
154
179
|
this.containerMap[name] = container;
|
|
155
180
|
};
|
|
181
|
+
|
|
156
182
|
ContainerManager.prototype.getContainer = function (name) {
|
|
157
183
|
return this.containerMap[name];
|
|
158
184
|
};
|
|
185
|
+
|
|
159
186
|
ContainerManager.prototype.removeContainer = function (name) {
|
|
160
187
|
var _a;
|
|
188
|
+
|
|
161
189
|
(_a = this.containerMap[name]) === null || _a === void 0 ? void 0 : _a.destroy({
|
|
162
190
|
children: true
|
|
163
191
|
});
|
|
164
192
|
delete this.containerMap[name];
|
|
165
193
|
};
|
|
194
|
+
|
|
166
195
|
ContainerManager.prototype.updateTransform = function (_a) {
|
|
167
196
|
var name = _a.name,
|
|
168
|
-
|
|
197
|
+
transform = _a.transform;
|
|
169
198
|
var container = this.containerMap[name];
|
|
170
199
|
if (!container || !transform) return;
|
|
171
200
|
var anchor = transform.anchor,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
201
|
+
origin = transform.origin,
|
|
202
|
+
position = transform.position,
|
|
203
|
+
rotation = transform.rotation,
|
|
204
|
+
scale = transform.scale,
|
|
205
|
+
size = transform.size,
|
|
206
|
+
skew = transform.skew;
|
|
178
207
|
container.rotation = rotation;
|
|
179
208
|
container.scale = scale;
|
|
180
209
|
container.pivot.x = size.width * origin.x;
|
|
@@ -182,39 +211,52 @@ var ContainerManager = function () {
|
|
|
182
211
|
container.skew = skew;
|
|
183
212
|
var x = position.x;
|
|
184
213
|
var y = position.y;
|
|
214
|
+
|
|
185
215
|
if (transform.parent) {
|
|
186
216
|
var parent_1 = transform.parent;
|
|
187
217
|
x = x + parent_1.size.width * anchor.x;
|
|
188
218
|
y = y + parent_1.size.height * anchor.y;
|
|
189
219
|
}
|
|
220
|
+
|
|
190
221
|
container.position = {
|
|
191
222
|
x: x,
|
|
192
223
|
y: y
|
|
193
224
|
};
|
|
194
225
|
};
|
|
226
|
+
|
|
195
227
|
return ContainerManager;
|
|
196
228
|
}();
|
|
229
|
+
|
|
197
230
|
var ContainerManager$1 = ContainerManager;
|
|
231
|
+
|
|
198
232
|
var Transform = function (_super) {
|
|
199
233
|
__extends(Transform, _super);
|
|
234
|
+
|
|
200
235
|
function Transform(_a) {
|
|
201
236
|
var system = _a.system,
|
|
202
|
-
|
|
237
|
+
containerManager = _a.containerManager;
|
|
238
|
+
|
|
203
239
|
var _this = _super.call(this) || this;
|
|
240
|
+
|
|
204
241
|
_this.name = 'Transform';
|
|
205
242
|
_this.waitRemoveIds = [];
|
|
206
243
|
_this.waitChangeScenes = [];
|
|
207
244
|
_this.containerManager = containerManager;
|
|
245
|
+
|
|
208
246
|
_this.init(system);
|
|
247
|
+
|
|
209
248
|
return _this;
|
|
210
249
|
}
|
|
250
|
+
|
|
211
251
|
Transform.prototype.init = function (system) {
|
|
212
252
|
var _this = this;
|
|
253
|
+
|
|
213
254
|
this.system = system;
|
|
214
255
|
this.on('changeScene', function (_a) {
|
|
215
256
|
var scene = _a.scene,
|
|
216
|
-
|
|
217
|
-
|
|
257
|
+
mode = _a.mode,
|
|
258
|
+
application = _a.application;
|
|
259
|
+
|
|
218
260
|
_this.waitChangeScenes.push({
|
|
219
261
|
scene: scene,
|
|
220
262
|
mode: mode,
|
|
@@ -222,8 +264,10 @@ var Transform = function (_super) {
|
|
|
222
264
|
});
|
|
223
265
|
});
|
|
224
266
|
};
|
|
267
|
+
|
|
225
268
|
Transform.prototype.update = function () {
|
|
226
269
|
var e_1, _a, e_2, _b;
|
|
270
|
+
|
|
227
271
|
try {
|
|
228
272
|
for (var _c = __values(this.waitRemoveIds), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
229
273
|
var id = _d.value;
|
|
@@ -240,11 +284,14 @@ var Transform = function (_super) {
|
|
|
240
284
|
if (e_1) throw e_1.error;
|
|
241
285
|
}
|
|
242
286
|
}
|
|
287
|
+
|
|
243
288
|
this.waitRemoveIds = [];
|
|
289
|
+
|
|
244
290
|
try {
|
|
245
291
|
for (var _e = __values(this.waitChangeScenes), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
246
292
|
var sceneInfo = _f.value;
|
|
247
293
|
var container = this.containerManager.getContainer(sceneInfo.scene.id);
|
|
294
|
+
|
|
248
295
|
if (container) {
|
|
249
296
|
sceneInfo.application.stage.removeChildren();
|
|
250
297
|
sceneInfo.application.stage.addChild(container);
|
|
@@ -261,8 +308,10 @@ var Transform = function (_super) {
|
|
|
261
308
|
if (e_2) throw e_2.error;
|
|
262
309
|
}
|
|
263
310
|
}
|
|
311
|
+
|
|
264
312
|
this.waitChangeScenes = [];
|
|
265
313
|
};
|
|
314
|
+
|
|
266
315
|
Transform.prototype.componentChanged = function (changed) {
|
|
267
316
|
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
268
317
|
this.addContainer(changed);
|
|
@@ -272,6 +321,7 @@ var Transform = function (_super) {
|
|
|
272
321
|
this.waitRemoveIds.push(changed.gameObject.id);
|
|
273
322
|
}
|
|
274
323
|
};
|
|
324
|
+
|
|
275
325
|
Transform.prototype.addContainer = function (changed) {
|
|
276
326
|
var container = new Container();
|
|
277
327
|
container.name = changed.gameObject.name;
|
|
@@ -282,12 +332,15 @@ var Transform = function (_super) {
|
|
|
282
332
|
var transform = changed.component;
|
|
283
333
|
transform.worldTransform = container.transform.worldTransform;
|
|
284
334
|
};
|
|
335
|
+
|
|
285
336
|
Transform.prototype.change = function (changed) {
|
|
286
337
|
var transform = changed.component;
|
|
338
|
+
|
|
287
339
|
if (transform.parent) {
|
|
288
340
|
var parentContainer = this.containerManager.getContainer(transform.parent.gameObject.id);
|
|
289
341
|
parentContainer.addChild(this.containerManager.getContainer(changed.gameObject.id));
|
|
290
342
|
var render = changed.gameObject.transform.parent && changed.gameObject.transform.parent.gameObject.getComponent('Render');
|
|
343
|
+
|
|
291
344
|
if (render) {
|
|
292
345
|
render.sortDirty = true;
|
|
293
346
|
}
|
|
@@ -296,6 +349,7 @@ var Transform = function (_super) {
|
|
|
296
349
|
container.parent && container.parent.removeChild(container);
|
|
297
350
|
}
|
|
298
351
|
};
|
|
352
|
+
|
|
299
353
|
Transform.prototype.destroy = function () {
|
|
300
354
|
this.removeAllListeners();
|
|
301
355
|
this.waitRemoveIds = null;
|
|
@@ -303,15 +357,19 @@ var Transform = function (_super) {
|
|
|
303
357
|
this.system = null;
|
|
304
358
|
this.containerManager = null;
|
|
305
359
|
};
|
|
360
|
+
|
|
306
361
|
Transform = __decorate([decorators.componentObserver({
|
|
307
362
|
Transform: ['_parent']
|
|
308
363
|
})], Transform);
|
|
309
364
|
return Transform;
|
|
310
365
|
}(EventEmitter);
|
|
366
|
+
|
|
311
367
|
var Transform$1 = Transform;
|
|
312
368
|
var result = undefined;
|
|
369
|
+
|
|
313
370
|
function getSuportCompressedTextureFormats(gl) {
|
|
314
371
|
if (result) return result;
|
|
372
|
+
|
|
315
373
|
if (!gl) {
|
|
316
374
|
console.warn('WebGL not available for compressed textures. Silently failing.');
|
|
317
375
|
return {
|
|
@@ -323,6 +381,7 @@ function getSuportCompressedTextureFormats(gl) {
|
|
|
323
381
|
astc: false
|
|
324
382
|
};
|
|
325
383
|
}
|
|
384
|
+
|
|
326
385
|
result = {
|
|
327
386
|
s3tc: !!gl.getExtension('WEBGL_compressed_texture_s3tc'),
|
|
328
387
|
etc: !!gl.getExtension('WEBGL_compressed_texture_etc'),
|
|
@@ -331,17 +390,23 @@ function getSuportCompressedTextureFormats(gl) {
|
|
|
331
390
|
atc: !!gl.getExtension('WEBGL_compressed_texture_atc'),
|
|
332
391
|
astc: !!gl.getExtension('WEBGL_compressed_texture_astc')
|
|
333
392
|
};
|
|
393
|
+
|
|
334
394
|
try {
|
|
335
395
|
console.log('Eva.js Supported Compressed Texture Format List: ' + Object.keys(result).filter(function (type) {
|
|
336
396
|
return result[type];
|
|
337
397
|
}).join(', '));
|
|
338
398
|
} catch (e) {}
|
|
399
|
+
|
|
339
400
|
return result;
|
|
340
401
|
}
|
|
402
|
+
|
|
341
403
|
var XLS = resourceLoader.XhrLoadStrategy;
|
|
342
404
|
var XhrLoadStrategy = XLS;
|
|
405
|
+
|
|
343
406
|
var _a, _b;
|
|
407
|
+
|
|
344
408
|
var INTERNAL_FORMATS;
|
|
409
|
+
|
|
345
410
|
(function (INTERNAL_FORMATS) {
|
|
346
411
|
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_S3TC_DXT1_EXT"] = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT";
|
|
347
412
|
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT1_EXT"] = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT";
|
|
@@ -398,30 +463,37 @@ var INTERNAL_FORMATS;
|
|
|
398
463
|
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"] = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR";
|
|
399
464
|
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR";
|
|
400
465
|
})(INTERNAL_FORMATS || (INTERNAL_FORMATS = {}));
|
|
466
|
+
|
|
401
467
|
var INTERNAL_FORMAT_TO_BLOCK_SIZE = (_a = {}, _a[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = [8, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = [8, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = [4, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = [5, 5], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = [6, 6], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = [8, 8], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = [10, 10], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = [12, 12], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x5_KHR] = [10, 5], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x6_KHR] = [10, 6], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x8_KHR] = [10, 8], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x10_KHR] = [12, 10], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x4_KHR] = [5, 4], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x5_KHR] = [6, 5], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x5_KHR] = [8, 5], _a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x6_KHR] = [8, 6], _a);
|
|
402
468
|
var INTERNAL_FORMATS_TO_EXTENSION_NAME = (_b = {}, _b[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc', _b[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', _b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', _b[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', _b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', _b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', _b[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = 'WEBGL_compressed_texture_etc1', _b[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = 'WEBGL_compressed_texture_atc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = 'WEBGL_compressed_texture_astc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = 'WEBGL_compressed_texture_astc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = 'WEBGL_compressed_texture_astc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = 'WEBGL_compressed_texture_astc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = 'WEBGL_compressed_texture_astc', _b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = 'WEBGL_compressed_texture_astc', _b);
|
|
469
|
+
|
|
403
470
|
var CompressedTextureResource = function () {
|
|
404
471
|
function CompressedTextureResource() {
|
|
405
472
|
this.levelBuffers = [];
|
|
406
473
|
}
|
|
474
|
+
|
|
407
475
|
CompressedTextureResource.prototype.upload = function (gl) {
|
|
408
476
|
var levels = this.levels;
|
|
409
477
|
var name = INTERNAL_FORMATS_TO_EXTENSION_NAME[this.internalFormat];
|
|
478
|
+
|
|
410
479
|
if (!gl[name]) {
|
|
411
480
|
gl[name] = true;
|
|
481
|
+
|
|
412
482
|
if (name === 'WEBGL_compressed_texture_pvrtc') {
|
|
413
483
|
gl.getExtension(name) || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
|
|
414
484
|
} else {
|
|
415
485
|
gl.getExtension(name);
|
|
416
486
|
}
|
|
417
487
|
}
|
|
488
|
+
|
|
418
489
|
for (var i = 0; i < this.levels; ++i) {
|
|
419
490
|
var _a = this.levelBuffers[i],
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
491
|
+
levelWidth = _a.levelWidth,
|
|
492
|
+
levelHeight = _a.levelHeight,
|
|
493
|
+
levelBuffer = _a.levelBuffer;
|
|
423
494
|
gl.compressedTexImage2D(gl.TEXTURE_2D, i, this.internalFormat, levelWidth, levelHeight, 0, levelBuffer);
|
|
424
495
|
}
|
|
496
|
+
|
|
425
497
|
if (levels > 1) {
|
|
426
498
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
427
499
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
|
|
@@ -430,8 +502,10 @@ var CompressedTextureResource = function () {
|
|
|
430
502
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
431
503
|
}
|
|
432
504
|
};
|
|
505
|
+
|
|
433
506
|
return CompressedTextureResource;
|
|
434
507
|
}();
|
|
508
|
+
|
|
435
509
|
var FILE_HEADER_SIZE = 64;
|
|
436
510
|
var KTX_FIELDS = {
|
|
437
511
|
FILE_IDENTIFIER: 0,
|
|
@@ -451,17 +525,23 @@ var KTX_FIELDS = {
|
|
|
451
525
|
};
|
|
452
526
|
var FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A];
|
|
453
527
|
var ENDIANNESS = 0x04030201;
|
|
528
|
+
|
|
454
529
|
var KTXTextureResource = function (_super) {
|
|
455
530
|
__extends(KTXTextureResource, _super);
|
|
531
|
+
|
|
456
532
|
function KTXTextureResource(source, config) {
|
|
457
533
|
var _a;
|
|
534
|
+
|
|
458
535
|
var _this = _super.call(this) || this;
|
|
536
|
+
|
|
459
537
|
_this.complete = true;
|
|
460
538
|
_this.src = config.url;
|
|
461
539
|
var dataView = new DataView(source);
|
|
540
|
+
|
|
462
541
|
if (!validateKTX(dataView)) {
|
|
463
542
|
throw new Error('Not a valid KTX Texture');
|
|
464
543
|
}
|
|
544
|
+
|
|
465
545
|
var littleEndian = dataView.getUint32(KTX_FIELDS.ENDIANNESS, true) === ENDIANNESS;
|
|
466
546
|
_this.internalFormat = dataView.getUint32(KTX_FIELDS.GL_INTERNAL_FORMAT, littleEndian);
|
|
467
547
|
var pixelWidth = _this.formerWidth = dataView.getUint32(KTX_FIELDS.PIXEL_WIDTH, littleEndian);
|
|
@@ -470,30 +550,38 @@ var KTXTextureResource = function (_super) {
|
|
|
470
550
|
_this.width = pixelWidth % size[0] === 0 ? pixelWidth : pixelWidth + size[0] - pixelWidth % size[0];
|
|
471
551
|
_this.height = pixelHeight % size[1] === 0 ? pixelHeight : pixelHeight + size[1] - pixelHeight % size[1];
|
|
472
552
|
var src = resource.resourcesMap[config.metadata.name].src[config.metadata.key];
|
|
553
|
+
|
|
473
554
|
var _b = (_a = src === null || src === void 0 ? void 0 : src.size) !== null && _a !== void 0 ? _a : {},
|
|
474
|
-
|
|
475
|
-
|
|
555
|
+
width = _b.width,
|
|
556
|
+
height = _b.height;
|
|
557
|
+
|
|
476
558
|
if (width && height) {
|
|
477
559
|
_this.naturalWidth = width;
|
|
478
560
|
_this.naturalHeight = height;
|
|
479
561
|
}
|
|
562
|
+
|
|
480
563
|
var pixelDepth = dataView.getUint32(KTX_FIELDS.PIXEL_DEPTH, littleEndian) || 1;
|
|
481
564
|
var numberOfArrayElements = dataView.getUint32(KTX_FIELDS.NUMBER_OF_ARRAY_ELEMENTS, littleEndian) || 1;
|
|
482
565
|
var numberOfFaces = dataView.getUint32(KTX_FIELDS.NUMBER_OF_FACES, littleEndian);
|
|
483
566
|
var numberOfMipmapLevels = _this.levels = dataView.getUint32(KTX_FIELDS.NUMBER_OF_MIPMAP_LEVELS, littleEndian);
|
|
484
567
|
var bytesOfKeyValueData = dataView.getUint32(KTX_FIELDS.BYTES_OF_KEY_VALUE_DATA, littleEndian);
|
|
568
|
+
|
|
485
569
|
if (pixelHeight === 0 || pixelDepth !== 1) {
|
|
486
570
|
throw new Error('Only 2D textures are supported!');
|
|
487
571
|
}
|
|
572
|
+
|
|
488
573
|
if (numberOfFaces !== 1) {
|
|
489
574
|
throw new Error('CubeTextures are not supported!');
|
|
490
575
|
}
|
|
576
|
+
|
|
491
577
|
if (numberOfArrayElements !== 1) {
|
|
492
578
|
throw new Error('It does not support array textures!');
|
|
493
579
|
}
|
|
580
|
+
|
|
494
581
|
var mipWidth = pixelWidth;
|
|
495
582
|
var mipHeight = pixelHeight;
|
|
496
583
|
var imageOffset = FILE_HEADER_SIZE + bytesOfKeyValueData;
|
|
584
|
+
|
|
497
585
|
for (var mipmapLevel = 0; mipmapLevel < numberOfMipmapLevels; mipmapLevel++) {
|
|
498
586
|
var imageSize = dataView.getUint32(imageOffset, littleEndian);
|
|
499
587
|
imageOffset += 4;
|
|
@@ -506,53 +594,70 @@ var KTXTextureResource = function (_super) {
|
|
|
506
594
|
levelHeight: levelHeight,
|
|
507
595
|
levelBuffer: new Uint8Array(source, imageOffset, imageSize)
|
|
508
596
|
};
|
|
597
|
+
|
|
509
598
|
_this.levelBuffers.push(mip);
|
|
599
|
+
|
|
510
600
|
imageOffset += imageSize;
|
|
511
601
|
imageOffset += 3 - (imageOffset + 3) % 4;
|
|
512
602
|
mipWidth = mipWidth >> 1 || 1;
|
|
513
603
|
mipHeight = mipHeight >> 1 || 1;
|
|
514
604
|
}
|
|
605
|
+
|
|
515
606
|
return _this;
|
|
516
607
|
}
|
|
608
|
+
|
|
517
609
|
return KTXTextureResource;
|
|
518
610
|
}(CompressedTextureResource);
|
|
611
|
+
|
|
519
612
|
function validateKTX(dataView) {
|
|
520
613
|
for (var i = 0; i < FILE_IDENTIFIER.length; i++) {
|
|
521
614
|
if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) {
|
|
522
615
|
return false;
|
|
523
616
|
}
|
|
524
617
|
}
|
|
618
|
+
|
|
525
619
|
return true;
|
|
526
620
|
}
|
|
621
|
+
|
|
527
622
|
var KTXLoadStrategy = function (_super) {
|
|
528
623
|
__extends(KTXLoadStrategy, _super);
|
|
624
|
+
|
|
529
625
|
function KTXLoadStrategy() {
|
|
530
626
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
531
627
|
}
|
|
628
|
+
|
|
532
629
|
KTXLoadStrategy.prototype._complete = function (type, data) {
|
|
533
630
|
_super.prototype._complete.call(this, type, new KTXTextureResource(data, this.config));
|
|
534
631
|
};
|
|
632
|
+
|
|
535
633
|
return KTXLoadStrategy;
|
|
536
634
|
}(XhrLoadStrategy);
|
|
635
|
+
|
|
537
636
|
var KTXLoadStrategy$1 = KTXLoadStrategy;
|
|
538
637
|
var XhrResponseType = resourceLoader.XhrResponseType;
|
|
638
|
+
|
|
539
639
|
function addPreProcessResourceHandler(resource, gl) {
|
|
540
640
|
resource.addPreProcessResourceHandler(function normalizeResource(resource) {
|
|
541
641
|
var _a, _b, _c;
|
|
642
|
+
|
|
542
643
|
var textures = (_b = (_a = resource.src) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.texture;
|
|
543
644
|
if (!textures) return;
|
|
645
|
+
|
|
544
646
|
if (!Array.isArray(textures)) {
|
|
545
647
|
textures = [textures];
|
|
546
648
|
}
|
|
649
|
+
|
|
547
650
|
var formats = (_c = getSuportCompressedTextureFormats(gl)) !== null && _c !== void 0 ? _c : {};
|
|
548
651
|
var target = textures.find(function (texture) {
|
|
549
652
|
return formats[texture.type];
|
|
550
653
|
});
|
|
654
|
+
|
|
551
655
|
if (target) {
|
|
552
656
|
_extends(resource.src.image, target);
|
|
553
657
|
}
|
|
554
658
|
});
|
|
555
659
|
}
|
|
660
|
+
|
|
556
661
|
function addKTXStragetyAndRegister() {
|
|
557
662
|
_extends(RESOURCE_TYPE_STRATEGY, {
|
|
558
663
|
astc: KTXLoadStrategy$1,
|
|
@@ -561,8 +666,10 @@ function addKTXStragetyAndRegister() {
|
|
|
561
666
|
s3tc: KTXLoadStrategy$1,
|
|
562
667
|
atc: KTXLoadStrategy$1
|
|
563
668
|
});
|
|
669
|
+
|
|
564
670
|
KTXLoadStrategy$1.setExtensionXhrType('ktx', XhrResponseType.Buffer);
|
|
565
671
|
}
|
|
672
|
+
|
|
566
673
|
var GLTexture = glCore.GLTexture;
|
|
567
674
|
var GLTextureMixin = {
|
|
568
675
|
isCompressed: false,
|
|
@@ -571,6 +678,7 @@ var GLTextureMixin = {
|
|
|
571
678
|
if (!(source instanceof CompressedTextureResource)) {
|
|
572
679
|
return this.uploadNotCompressed(source);
|
|
573
680
|
}
|
|
681
|
+
|
|
574
682
|
this.bind();
|
|
575
683
|
var gl = this.gl;
|
|
576
684
|
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
|
|
@@ -583,6 +691,7 @@ var GLTextureMixin = {
|
|
|
583
691
|
if (this.isCompressed) {
|
|
584
692
|
return;
|
|
585
693
|
}
|
|
694
|
+
|
|
586
695
|
var gl = this.gl;
|
|
587
696
|
this.bind();
|
|
588
697
|
this.mipmap = true;
|
|
@@ -595,6 +704,7 @@ var TextureMixin = {
|
|
|
595
704
|
if (!(source instanceof CompressedTextureResource)) {
|
|
596
705
|
return this.oldFrom(source);
|
|
597
706
|
}
|
|
707
|
+
|
|
598
708
|
return new Texture(BaseTexture.from(source));
|
|
599
709
|
}
|
|
600
710
|
};
|
|
@@ -604,49 +714,67 @@ var BaseTextureMixin = {
|
|
|
604
714
|
if (!(source instanceof CompressedTextureResource)) {
|
|
605
715
|
return this.oldFrom(source, scaleMode, sourceScale);
|
|
606
716
|
}
|
|
717
|
+
|
|
607
718
|
var imageUrl = source.src;
|
|
608
719
|
var baseTexture = utils.BaseTextureCache[imageUrl];
|
|
720
|
+
|
|
609
721
|
if (!baseTexture) {
|
|
610
722
|
baseTexture = new BaseTexture(source, scaleMode);
|
|
611
723
|
baseTexture.imageUrl = imageUrl;
|
|
724
|
+
|
|
612
725
|
if (sourceScale) {
|
|
613
726
|
baseTexture.sourceScale = sourceScale;
|
|
614
727
|
}
|
|
728
|
+
|
|
615
729
|
BaseTexture.addToCache(baseTexture, imageUrl);
|
|
616
730
|
}
|
|
731
|
+
|
|
617
732
|
return baseTexture;
|
|
618
733
|
}
|
|
619
734
|
};
|
|
735
|
+
|
|
620
736
|
function registerCompressedTexture(gl) {
|
|
621
737
|
addPreProcessResourceHandler(resource, gl);
|
|
622
738
|
addKTXStragetyAndRegister();
|
|
739
|
+
|
|
623
740
|
_extends(glCore.GLTexture.prototype, GLTextureMixin);
|
|
741
|
+
|
|
624
742
|
_extends(Texture, TextureMixin);
|
|
743
|
+
|
|
625
744
|
_extends(BaseTexture, BaseTextureMixin);
|
|
626
745
|
}
|
|
746
|
+
|
|
627
747
|
var RENDERER_TYPE;
|
|
748
|
+
|
|
628
749
|
(function (RENDERER_TYPE) {
|
|
629
750
|
RENDERER_TYPE[RENDERER_TYPE["UNKNOWN"] = 0] = "UNKNOWN";
|
|
630
751
|
RENDERER_TYPE[RENDERER_TYPE["WEBGL"] = 1] = "WEBGL";
|
|
631
752
|
RENDERER_TYPE[RENDERER_TYPE["CANVAS"] = 2] = "CANVAS";
|
|
632
753
|
})(RENDERER_TYPE || (RENDERER_TYPE = {}));
|
|
754
|
+
|
|
633
755
|
var disableScroll = function disableScroll(renderer) {
|
|
634
756
|
renderer.plugins.interaction.autoPreventDefault = true;
|
|
635
757
|
renderer.view.style.touchAction = 'none';
|
|
636
758
|
};
|
|
759
|
+
|
|
637
760
|
var enableScroll = function enableScroll(renderer) {
|
|
638
761
|
renderer.plugins.interaction.autoPreventDefault = false;
|
|
639
762
|
renderer.view.style.touchAction = 'auto';
|
|
640
763
|
};
|
|
764
|
+
|
|
641
765
|
var Renderer$2 = function (_super) {
|
|
642
766
|
__extends(Renderer, _super);
|
|
767
|
+
|
|
643
768
|
function Renderer() {
|
|
644
769
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
770
|
+
|
|
645
771
|
_this.multiApps = [];
|
|
646
772
|
return _this;
|
|
647
773
|
}
|
|
774
|
+
|
|
648
775
|
Renderer.prototype.init = function (params) {
|
|
649
776
|
var _this = this;
|
|
777
|
+
|
|
650
778
|
this.params = params;
|
|
651
779
|
this.application = this.createApplication(params);
|
|
652
780
|
this.containerManager = new ContainerManager$1();
|
|
@@ -661,20 +789,24 @@ var Renderer$2 = function (_super) {
|
|
|
661
789
|
});
|
|
662
790
|
this.game.on('sceneChanged', function (_a) {
|
|
663
791
|
var scene = _a.scene,
|
|
664
|
-
|
|
665
|
-
|
|
792
|
+
mode = _a.mode,
|
|
793
|
+
params = _a.params;
|
|
666
794
|
var application;
|
|
795
|
+
|
|
667
796
|
switch (mode) {
|
|
668
797
|
case LOAD_SCENE_MODE.SINGLE:
|
|
669
798
|
application = _this.application;
|
|
670
799
|
break;
|
|
800
|
+
|
|
671
801
|
case LOAD_SCENE_MODE.MULTI_CANVAS:
|
|
672
802
|
application = _this.createMultiApplication({
|
|
673
803
|
params: params
|
|
674
804
|
});
|
|
675
805
|
break;
|
|
676
806
|
}
|
|
807
|
+
|
|
677
808
|
scene.canvas = application.view;
|
|
809
|
+
|
|
678
810
|
_this.transform.emit('changeScene', {
|
|
679
811
|
scene: scene,
|
|
680
812
|
mode: mode,
|
|
@@ -682,52 +814,68 @@ var Renderer$2 = function (_super) {
|
|
|
682
814
|
});
|
|
683
815
|
});
|
|
684
816
|
var gl = this.application.renderer.gl;
|
|
817
|
+
|
|
685
818
|
if (gl) {
|
|
686
819
|
this.suportedCompressedTextureFormats = getSuportCompressedTextureFormats(gl);
|
|
687
820
|
registerCompressedTexture(gl);
|
|
688
821
|
}
|
|
689
822
|
};
|
|
823
|
+
|
|
690
824
|
Renderer.prototype.registerObserver = function (observerInfo) {
|
|
691
825
|
var _a;
|
|
826
|
+
|
|
692
827
|
var thisObserverInfo = this.constructor.observerInfo;
|
|
828
|
+
|
|
693
829
|
for (var key in observerInfo) {
|
|
694
830
|
if (!thisObserverInfo[key]) {
|
|
695
831
|
thisObserverInfo[key] = [];
|
|
696
832
|
}
|
|
833
|
+
|
|
697
834
|
(_a = thisObserverInfo[key]).push.apply(_a, __spread(observerInfo[key]));
|
|
698
835
|
}
|
|
699
836
|
};
|
|
837
|
+
|
|
700
838
|
Renderer.prototype.createMultiApplication = function (_a) {
|
|
701
839
|
var params = _a.params;
|
|
702
840
|
var app = this.createApplication(params);
|
|
703
841
|
this.multiApps.push(app);
|
|
704
842
|
return app;
|
|
705
843
|
};
|
|
844
|
+
|
|
706
845
|
Renderer.prototype.createApplication = function (params) {
|
|
707
846
|
params.view = params.canvas;
|
|
847
|
+
|
|
708
848
|
if (params.renderType === RENDERER_TYPE.CANVAS) {
|
|
709
849
|
params.forceCanvas = true;
|
|
710
850
|
}
|
|
851
|
+
|
|
711
852
|
var app = new Application(__assign({
|
|
712
853
|
sharedTicker: true
|
|
713
854
|
}, params));
|
|
714
855
|
ticker.shared.stop();
|
|
715
856
|
ticker.shared.autoStart = false;
|
|
857
|
+
|
|
716
858
|
if (params.preventScroll !== undefined) {
|
|
717
859
|
console.warn('PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game');
|
|
718
860
|
params.preventScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
|
|
719
861
|
}
|
|
862
|
+
|
|
720
863
|
if (params.enableScroll !== undefined) {
|
|
721
864
|
params.enableScroll ? enableScroll(app.renderer) : disableScroll(app.renderer);
|
|
722
865
|
}
|
|
866
|
+
|
|
723
867
|
if (params.preventScroll === undefined && params.enableScroll === undefined) {
|
|
724
868
|
enableScroll(app.renderer);
|
|
725
869
|
}
|
|
870
|
+
|
|
726
871
|
return app;
|
|
727
872
|
};
|
|
873
|
+
|
|
728
874
|
Renderer.prototype.update = function () {
|
|
729
875
|
var e_1, _a, e_2, _b;
|
|
876
|
+
|
|
730
877
|
var changes = this.componentObserver.clear();
|
|
878
|
+
|
|
731
879
|
try {
|
|
732
880
|
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
733
881
|
var changed = changes_1_1.value;
|
|
@@ -744,6 +892,7 @@ var Renderer$2 = function (_super) {
|
|
|
744
892
|
if (e_1) throw e_1.error;
|
|
745
893
|
}
|
|
746
894
|
}
|
|
895
|
+
|
|
747
896
|
try {
|
|
748
897
|
for (var _c = __values(this.game.gameObjects), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
749
898
|
var gameObject = _d.value;
|
|
@@ -765,13 +914,17 @@ var Renderer$2 = function (_super) {
|
|
|
765
914
|
}
|
|
766
915
|
}
|
|
767
916
|
};
|
|
917
|
+
|
|
768
918
|
Renderer.prototype.lateUpdate = function (e) {
|
|
769
919
|
this.transform.update();
|
|
770
920
|
this.application.ticker.update(e.time);
|
|
771
921
|
};
|
|
922
|
+
|
|
772
923
|
Renderer.prototype.onDestroy = function () {
|
|
773
924
|
var e_3, _a;
|
|
925
|
+
|
|
774
926
|
this.application.destroy();
|
|
927
|
+
|
|
775
928
|
try {
|
|
776
929
|
for (var _b = __values(this.multiApps), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
777
930
|
var app = _c.value;
|
|
@@ -788,6 +941,7 @@ var Renderer$2 = function (_super) {
|
|
|
788
941
|
if (e_3) throw e_3.error;
|
|
789
942
|
}
|
|
790
943
|
}
|
|
944
|
+
|
|
791
945
|
this.transform.destroy();
|
|
792
946
|
this.transform = null;
|
|
793
947
|
this.params = null;
|
|
@@ -797,31 +951,42 @@ var Renderer$2 = function (_super) {
|
|
|
797
951
|
this.game = null;
|
|
798
952
|
this.multiApps = null;
|
|
799
953
|
};
|
|
954
|
+
|
|
800
955
|
Renderer.prototype.resize = function (width, height) {
|
|
801
956
|
this.params.width = width;
|
|
802
957
|
this.params.height = height;
|
|
803
958
|
this.application.renderer.resize(width, height);
|
|
804
959
|
};
|
|
960
|
+
|
|
805
961
|
Renderer.systemName = 'Renderer';
|
|
806
962
|
Renderer = __decorate([decorators.componentObserver({
|
|
807
963
|
Transform: ['_parent']
|
|
808
964
|
})], Renderer);
|
|
809
965
|
return Renderer;
|
|
810
966
|
}(System);
|
|
967
|
+
|
|
811
968
|
var Renderer$3 = Renderer$2;
|
|
969
|
+
|
|
812
970
|
var Renderer = function (_super) {
|
|
813
971
|
__extends(Renderer, _super);
|
|
972
|
+
|
|
814
973
|
function Renderer(params) {
|
|
815
974
|
var _this = _super.call(this, params) || this;
|
|
975
|
+
|
|
816
976
|
_this.asyncIdMap = {};
|
|
817
977
|
_this.observerInfo = _this.constructor.observerInfo;
|
|
818
978
|
return _this;
|
|
819
979
|
}
|
|
980
|
+
|
|
820
981
|
Renderer.prototype.componentChanged = function (_changed) {};
|
|
982
|
+
|
|
821
983
|
Renderer.prototype.rendererUpdate = function (_gameObject) {};
|
|
984
|
+
|
|
822
985
|
Renderer.prototype.update = function (e) {
|
|
823
986
|
var e_1, _a;
|
|
987
|
+
|
|
824
988
|
var changes = this.componentObserver.clear();
|
|
989
|
+
|
|
825
990
|
try {
|
|
826
991
|
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
827
992
|
var changed = changes_1_1.value;
|
|
@@ -839,22 +1004,28 @@ var Renderer = function (_super) {
|
|
|
839
1004
|
}
|
|
840
1005
|
}
|
|
841
1006
|
};
|
|
1007
|
+
|
|
842
1008
|
Renderer.prototype.increaseAsyncId = function (id) {
|
|
843
1009
|
this.asyncIdMap[id] = (this.asyncIdMap[id] || 0) + 1;
|
|
844
1010
|
return this.asyncIdMap[id];
|
|
845
1011
|
};
|
|
1012
|
+
|
|
846
1013
|
Renderer.prototype.validateAsyncId = function (id, asyncId) {
|
|
847
1014
|
return this.asyncIdMap[id] === asyncId;
|
|
848
1015
|
};
|
|
1016
|
+
|
|
849
1017
|
return Renderer;
|
|
850
1018
|
}(System);
|
|
1019
|
+
|
|
851
1020
|
var Renderer$1 = Renderer;
|
|
1021
|
+
|
|
852
1022
|
var mixinPIXI = function mixinPIXI() {
|
|
853
1023
|
BaseTexture.prototype.destroy = function () {
|
|
854
1024
|
if (this.imageUrl) {
|
|
855
1025
|
delete utils.TextureCache[this.imageUrl];
|
|
856
1026
|
this.imageUrl = null;
|
|
857
1027
|
}
|
|
1028
|
+
|
|
858
1029
|
this.source = null;
|
|
859
1030
|
this.dispose();
|
|
860
1031
|
BaseTexture.removeFromCache(this);
|
|
@@ -862,5 +1033,6 @@ var mixinPIXI = function mixinPIXI() {
|
|
|
862
1033
|
this._destroyed = true;
|
|
863
1034
|
};
|
|
864
1035
|
};
|
|
1036
|
+
|
|
865
1037
|
mixinPIXI();
|
|
866
1038
|
export { ContainerManager$1 as ContainerManager, RENDERER_TYPE, Renderer$1 as Renderer, RendererManager$1 as RendererManager, Renderer$3 as RendererSystem };
|