@eva/plugin-renderer-sprite 1.2.6 → 1.2.7-editor.2
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.sprite.js +324 -54
- package/dist/EVA.plugin.renderer.sprite.min.js +1 -1
- package/dist/miniprogram.js +36 -36
- package/dist/plugin-renderer-sprite.cjs.js +39 -31
- package/dist/plugin-renderer-sprite.cjs.prod.js +1 -1
- package/dist/plugin-renderer-sprite.esm.js +40 -32
- package/package.json +4 -4
|
@@ -5,22 +5,24 @@ window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
|
5
5
|
var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
var _extendStatics = function extendStatics(d, b) {
|
|
9
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
8
|
+
var _extendStatics$ = function extendStatics$1(d, b) {
|
|
9
|
+
_extendStatics$ = Object.setPrototypeOf || {
|
|
10
10
|
__proto__: []
|
|
11
11
|
} instanceof Array && function (d, b) {
|
|
12
12
|
d.__proto__ = b;
|
|
13
13
|
} || function (d, b) {
|
|
14
14
|
for (var p in b) {
|
|
15
|
-
if (
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
return _extendStatics(d, b);
|
|
19
|
+
return _extendStatics$(d, b);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
function __extends(d, b) {
|
|
23
|
-
|
|
22
|
+
function __extends$1(d, b) {
|
|
23
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
24
|
+
|
|
25
|
+
_extendStatics$(d, b);
|
|
24
26
|
|
|
25
27
|
function __() {
|
|
26
28
|
this.constructor = d;
|
|
@@ -29,6 +31,22 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
29
31
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
var _assign = function __assign() {
|
|
35
|
+
_assign = Object.assign || function __assign(t) {
|
|
36
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
37
|
+
s = arguments[i];
|
|
38
|
+
|
|
39
|
+
for (var p in s) {
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return _assign.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
|
|
32
50
|
function __decorate(decorators, target, key, desc) {
|
|
33
51
|
var c = arguments.length,
|
|
34
52
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -39,6 +57,10 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
39
57
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
58
|
}
|
|
41
59
|
|
|
60
|
+
function __metadata(metadataKey, metadataValue) {
|
|
61
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
62
|
+
}
|
|
63
|
+
|
|
42
64
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
65
|
function adopt(value) {
|
|
44
66
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -199,29 +221,111 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
199
221
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
200
222
|
}
|
|
201
223
|
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
224
|
+
var SymbolKeysNotSupportedError = function (_super) {
|
|
225
|
+
__extends$1(SymbolKeysNotSupportedError, _super);
|
|
226
|
+
|
|
227
|
+
function SymbolKeysNotSupportedError() {
|
|
228
|
+
var _newTarget = this.constructor;
|
|
229
|
+
|
|
230
|
+
var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
|
|
231
|
+
|
|
232
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
233
|
+
return _this;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return SymbolKeysNotSupportedError;
|
|
237
|
+
}(Error);
|
|
238
|
+
|
|
239
|
+
(function (_super) {
|
|
240
|
+
__extends$1(StaticGetPropertiesIsNotAFunctionError, _super);
|
|
241
|
+
|
|
242
|
+
function StaticGetPropertiesIsNotAFunctionError() {
|
|
243
|
+
var _newTarget = this.constructor;
|
|
244
|
+
|
|
245
|
+
var _this = _super.call(this, 'getProperties is not a function!') || this;
|
|
246
|
+
|
|
247
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
248
|
+
return _this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return StaticGetPropertiesIsNotAFunctionError;
|
|
252
|
+
})(Error);
|
|
253
|
+
|
|
254
|
+
var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
|
|
255
|
+
|
|
256
|
+
function transformBasicType(type) {
|
|
257
|
+
if (type === String) {
|
|
258
|
+
return 'string';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (type === Number) {
|
|
262
|
+
return 'number';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (type === Boolean) {
|
|
266
|
+
return 'boolean';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return 'unknown';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function defineTypes(target, key, options, returnTypeFunction) {
|
|
273
|
+
var type = Reflect.getMetadata('design:type', target, key);
|
|
274
|
+
var isArray = type === Array;
|
|
275
|
+
var str = transformBasicType(type);
|
|
276
|
+
|
|
277
|
+
if (str !== 'unknown') {
|
|
278
|
+
type = str;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (returnTypeFunction) {
|
|
282
|
+
var returnType = returnTypeFunction();
|
|
283
|
+
|
|
284
|
+
if (Array.isArray(returnType)) {
|
|
285
|
+
isArray = true;
|
|
286
|
+
type = returnType[0];
|
|
287
|
+
} else {
|
|
288
|
+
type = returnType;
|
|
289
|
+
}
|
|
205
290
|
}
|
|
206
291
|
|
|
207
|
-
|
|
208
|
-
|
|
292
|
+
var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
|
|
293
|
+
properties[key] = _assign({
|
|
294
|
+
type: type,
|
|
295
|
+
isArray: isArray
|
|
296
|
+
}, options);
|
|
297
|
+
Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
|
|
301
|
+
if (typeof returnTypeFuncOrOptions === 'function') {
|
|
302
|
+
return {
|
|
303
|
+
returnTypeFunc: returnTypeFuncOrOptions,
|
|
304
|
+
options: maybeOptions || {}
|
|
305
|
+
};
|
|
209
306
|
}
|
|
210
307
|
|
|
211
|
-
|
|
212
|
-
|
|
308
|
+
return {
|
|
309
|
+
options: returnTypeFuncOrOptions || {}
|
|
310
|
+
};
|
|
213
311
|
}
|
|
214
312
|
|
|
215
|
-
function
|
|
313
|
+
function Field(returnTypeFunction, maybeOptions) {
|
|
216
314
|
return function (target, propertyKey) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
315
|
+
if (typeof propertyKey === 'symbol') {
|
|
316
|
+
throw new SymbolKeysNotSupportedError();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
320
|
+
options = _a.options,
|
|
321
|
+
returnTypeFunc = _a.returnTypeFunc;
|
|
322
|
+
|
|
323
|
+
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
220
324
|
};
|
|
221
325
|
}
|
|
222
326
|
|
|
223
327
|
var Sprite$3 = function (_super) {
|
|
224
|
-
__extends(Sprite, _super);
|
|
328
|
+
__extends$1(Sprite, _super);
|
|
225
329
|
|
|
226
330
|
function Sprite() {
|
|
227
331
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -240,15 +344,94 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
240
344
|
|
|
241
345
|
Sprite.componentName = 'Sprite';
|
|
242
346
|
|
|
243
|
-
__decorate([
|
|
347
|
+
__decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "resource", void 0);
|
|
244
348
|
|
|
245
|
-
__decorate([
|
|
349
|
+
__decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "spriteName", void 0);
|
|
246
350
|
|
|
247
351
|
return Sprite;
|
|
248
352
|
}(eva_js.Component);
|
|
249
353
|
|
|
250
354
|
var Sprite$4 = Sprite$3;
|
|
251
355
|
|
|
356
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
357
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
358
|
+
__proto__: []
|
|
359
|
+
} instanceof Array && function (d, b) {
|
|
360
|
+
d.__proto__ = b;
|
|
361
|
+
} || function (d, b) {
|
|
362
|
+
for (var p in b) {
|
|
363
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
return _extendStatics(d, b);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
function __extends(d, b) {
|
|
371
|
+
_extendStatics(d, b);
|
|
372
|
+
|
|
373
|
+
function __() {
|
|
374
|
+
this.constructor = d;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
(function (_super) {
|
|
381
|
+
__extends(Application, _super);
|
|
382
|
+
|
|
383
|
+
function Application(params) {
|
|
384
|
+
var _this = this;
|
|
385
|
+
|
|
386
|
+
params.autoStart = false;
|
|
387
|
+
_this = _super.call(this, params) || this;
|
|
388
|
+
return _this;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return Application;
|
|
392
|
+
})(pixi_js.Application);
|
|
393
|
+
|
|
394
|
+
(function (_super) {
|
|
395
|
+
__extends(Container, _super);
|
|
396
|
+
|
|
397
|
+
function Container() {
|
|
398
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return Container;
|
|
402
|
+
})(pixi_js.Container);
|
|
403
|
+
|
|
404
|
+
(function (_super) {
|
|
405
|
+
__extends(Graphics, _super);
|
|
406
|
+
|
|
407
|
+
function Graphics() {
|
|
408
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return Graphics;
|
|
412
|
+
})(pixi_js.Graphics);
|
|
413
|
+
|
|
414
|
+
(function (_super) {
|
|
415
|
+
__extends(NinePatch, _super);
|
|
416
|
+
|
|
417
|
+
function NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight) {
|
|
418
|
+
var _this = this;
|
|
419
|
+
|
|
420
|
+
var texture;
|
|
421
|
+
|
|
422
|
+
if (img === 'string') {
|
|
423
|
+
texture = pixi_js.Texture.fromFrame(img);
|
|
424
|
+
} else {
|
|
425
|
+
texture = pixi_js.Texture.from(img);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
_this = _super.call(this, texture, leftWidth, topHeight, rightWidth, bottomHeight) || this;
|
|
429
|
+
return _this;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return NinePatch;
|
|
433
|
+
})(pixi_js.mesh.NineSlicePlane);
|
|
434
|
+
|
|
252
435
|
var Sprite$2 = function () {
|
|
253
436
|
function Sprite(image) {
|
|
254
437
|
this._image = null;
|
|
@@ -289,7 +472,94 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
289
472
|
return Sprite;
|
|
290
473
|
}();
|
|
291
474
|
|
|
292
|
-
var
|
|
475
|
+
var Sprite$1$1 = Sprite$2;
|
|
476
|
+
|
|
477
|
+
(function () {
|
|
478
|
+
function SpriteAnimation(_a) {
|
|
479
|
+
var frames = _a.frames;
|
|
480
|
+
this.animatedSprite = new pixi_js.extras.AnimatedSprite(frames);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
SpriteAnimation.prototype.play = function () {
|
|
484
|
+
this.animatedSprite.play();
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
SpriteAnimation.prototype.stop = function () {
|
|
488
|
+
this.animatedSprite.stop();
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
492
|
+
this.animatedSprite.gotoAndPlay(frameNumber);
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
496
|
+
this.animatedSprite.gotoAndStop(frameNumber);
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
Object.defineProperty(SpriteAnimation.prototype, "speed", {
|
|
500
|
+
get: function get() {
|
|
501
|
+
return this.animatedSprite.animationSpeed;
|
|
502
|
+
},
|
|
503
|
+
set: function set(val) {
|
|
504
|
+
this.animatedSprite.animationSpeed = val;
|
|
505
|
+
},
|
|
506
|
+
enumerable: false,
|
|
507
|
+
configurable: true
|
|
508
|
+
});
|
|
509
|
+
return SpriteAnimation;
|
|
510
|
+
})();
|
|
511
|
+
|
|
512
|
+
(function (_super) {
|
|
513
|
+
__extends(Text, _super);
|
|
514
|
+
|
|
515
|
+
function Text(text, style) {
|
|
516
|
+
return _super.call(this, text, style) || this;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return Text;
|
|
520
|
+
})(pixi_js.Text);
|
|
521
|
+
|
|
522
|
+
var PIXITilingSprite = pixi_js.extras.TilingSprite;
|
|
523
|
+
|
|
524
|
+
(function () {
|
|
525
|
+
function TilingSprite(image) {
|
|
526
|
+
this._image = null;
|
|
527
|
+
this._image = image;
|
|
528
|
+
|
|
529
|
+
if (image) {
|
|
530
|
+
if (image instanceof HTMLImageElement) {
|
|
531
|
+
this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.from(image));
|
|
532
|
+
} else if (image instanceof pixi_js.Texture) {
|
|
533
|
+
this.tilingSprite = new PIXITilingSprite(image);
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.EMPTY);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
Object.defineProperty(TilingSprite.prototype, "image", {
|
|
541
|
+
get: function get() {
|
|
542
|
+
return this._image;
|
|
543
|
+
},
|
|
544
|
+
set: function set(val) {
|
|
545
|
+
if (this._image === val) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (val instanceof HTMLImageElement) {
|
|
550
|
+
this.tilingSprite.texture = pixi_js.Texture.from(val);
|
|
551
|
+
} else if (val instanceof pixi_js.Texture) {
|
|
552
|
+
this.tilingSprite.texture = val;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
this._image = val;
|
|
556
|
+
},
|
|
557
|
+
enumerable: false,
|
|
558
|
+
configurable: true
|
|
559
|
+
});
|
|
560
|
+
return TilingSprite;
|
|
561
|
+
})();
|
|
562
|
+
|
|
293
563
|
var resourceKeySplit = '_s|r|c_';
|
|
294
564
|
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, function (_a) {
|
|
295
565
|
var name = _a.name,
|
|
@@ -352,7 +622,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
352
622
|
});
|
|
353
623
|
|
|
354
624
|
var Sprite = function (_super) {
|
|
355
|
-
__extends(Sprite, _super);
|
|
625
|
+
__extends$1(Sprite, _super);
|
|
356
626
|
|
|
357
627
|
function Sprite() {
|
|
358
628
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -380,52 +650,52 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
380
650
|
|
|
381
651
|
Sprite.prototype.componentChanged = function (changed) {
|
|
382
652
|
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
var _this = this;
|
|
386
|
-
|
|
653
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
387
654
|
return __generator(this, function (_a) {
|
|
388
655
|
switch (_a.label) {
|
|
389
656
|
case 0:
|
|
390
|
-
if (!(changed.componentName === 'Sprite')) return [3,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
400
|
-
return [2];
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
sprite_1.image = instance[component_1.resource + resourceKeySplit + component_1.spriteName];
|
|
404
|
-
return [2];
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
this.sprites[changed.gameObject.id] = sprite_1;
|
|
409
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
410
|
-
return [3, 4];
|
|
657
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
658
|
+
gameObjectId = changed.gameObject.id;
|
|
659
|
+
component = changed.component;
|
|
660
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
661
|
+
sprite = new Sprite$1$1(null);
|
|
662
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
663
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
664
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
665
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
411
666
|
|
|
412
667
|
case 1:
|
|
413
|
-
|
|
414
|
-
|
|
668
|
+
instance = _a.sent().instance;
|
|
669
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
670
|
+
|
|
671
|
+
if (!instance) {
|
|
672
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
673
|
+
return [2];
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
677
|
+
return [3, 5];
|
|
415
678
|
|
|
416
679
|
case 2:
|
|
680
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
681
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
682
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
683
|
+
|
|
684
|
+
case 3:
|
|
417
685
|
instance = _a.sent().instance;
|
|
686
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
418
687
|
|
|
419
688
|
if (!instance) {
|
|
420
689
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
421
690
|
return [2];
|
|
422
691
|
}
|
|
423
692
|
|
|
424
|
-
this.sprites[changed.gameObject.id].image = instance[
|
|
425
|
-
return [3,
|
|
693
|
+
this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
694
|
+
return [3, 5];
|
|
426
695
|
|
|
427
|
-
case
|
|
696
|
+
case 4:
|
|
428
697
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
698
|
+
this.increaseAsyncId(gameObjectId);
|
|
429
699
|
sprite = this.sprites[changed.gameObject.id];
|
|
430
700
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
431
701
|
sprite.sprite.destroy({
|
|
@@ -434,9 +704,9 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
434
704
|
delete this.sprites[changed.gameObject.id];
|
|
435
705
|
}
|
|
436
706
|
|
|
437
|
-
_a.label =
|
|
707
|
+
_a.label = 5;
|
|
438
708
|
|
|
439
|
-
case
|
|
709
|
+
case 5:
|
|
440
710
|
return [2];
|
|
441
711
|
}
|
|
442
712
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return
|
|
1
|
+
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};function s(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var l=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return o(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}o(t,e)}(Error);var h="IDE_PROPERTY_METADATA";function y(e,t,r,n){var i=Reflect.getMetadata("design:type",e,t),o=i===Array,s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(i);if("unknown"!==s&&(i=s),n){var c=n();Array.isArray(c)?(o=!0,i=c[0]):i=c}var u=Reflect.getMetadata(h,e.constructor)||{};u[t]=a({type:i,isArray:o},r),Reflect.defineMetadata(h,u,e.constructor)}function d(e,t){return function(r,n){if("symbol"==typeof n)throw new l;var i=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);y(r,n,i.options,i.returnTypeFunc)}}var m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},t.componentName="Sprite",s([d(),c("design:type",String)],t.prototype,"resource",void 0),s([d(),c("design:type",String)],t.prototype,"spriteName",void 0),t}(t.Component),g=m,b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},b(e,t)};function v(e,t){function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}!function(e){function t(t){return t.autoStart=!1,e.call(this,t)||this}v(t,e)}(n.Application),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}v(t,e)}(n.Container),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}v(t,e)}(n.Graphics),function(e){function t(t,r,i,o,a){var s;return s="string"===t?n.Texture.fromFrame(t):n.Texture.from(t),e.call(this,s,r,i,o,a)||this}v(t,e)}(n.mesh.NineSlicePlane);var S=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),w=S;!function(){function e(e){var t=e.frames;this.animatedSprite=new n.extras.AnimatedSprite(t)}e.prototype.play=function(){this.animatedSprite.play()},e.prototype.stop=function(){this.animatedSprite.stop()},e.prototype.gotoAndPlay=function(e){this.animatedSprite.gotoAndPlay(e)},e.prototype.gotoAndStop=function(e){this.animatedSprite.gotoAndStop(e)},Object.defineProperty(e.prototype,"speed",{get:function(){return this.animatedSprite.animationSpeed},set:function(e){this.animatedSprite.animationSpeed=e},enumerable:!1,configurable:!0})}(),function(e){function t(t,r){return e.call(this,t,r)||this}v(t,e)}(n.Text);var E=n.extras.TilingSprite;!function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.tilingSprite=new E(n.Texture.from(e)):e instanceof n.Texture&&(this.tilingSprite=new E(e)):this.tilingSprite=new E(n.Texture.EMPTY)}Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?this.tilingSprite.texture=n.Texture.from(e):e instanceof n.Texture&&(this.tilingSprite.texture=e),this._image=e)},enumerable:!1,configurable:!0})}();var O="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,a=r.json,s=n.BaseTexture.from(r.image),c=a.frames||{},u=a.animations||{},p={};for(var l in c){p[t+O+l]=c[l]}for(var l in u){var h=[];if(u[l]&&u[l].length>=0)try{for(var y=(i=void 0,f(u[l])),d=y.next();!d.done;d=y.next()){var m=d.value,g=t+O+m;h.push(g)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}u[l]=h}a.frames=p;var b=new n.Spritesheet(s,a);b.parse((function(){var t=b.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var _=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return u(this,void 0,void 0,(function(){var r,n,i,o,a;return p(this,(function(s){switch(s.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new w(null),this.sprites[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(a.image=o[n.resource+O+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+O+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),a=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),s.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),A=_;return e.Sprite=g,e.SpriteSystem=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
|
|
1
|
+
import { __extends, __decorate, __metadata, __values, __awaiter, __generator } from 'tslib';
|
|
2
2
|
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
3
|
-
import {
|
|
3
|
+
import { Field } from '@eva/inspector-decorator';
|
|
4
4
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
5
|
import { Sprite as Sprite$4 } from '@eva/renderer-adapter/dist/miniprogram';
|
|
6
6
|
import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
|
|
@@ -25,9 +25,9 @@ var Sprite$2 = function (_super) {
|
|
|
25
25
|
|
|
26
26
|
Sprite.componentName = 'Sprite';
|
|
27
27
|
|
|
28
|
-
__decorate([
|
|
28
|
+
__decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "resource", void 0);
|
|
29
29
|
|
|
30
|
-
__decorate([
|
|
30
|
+
__decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "spriteName", void 0);
|
|
31
31
|
|
|
32
32
|
return Sprite;
|
|
33
33
|
}(Component);
|
|
@@ -123,52 +123,52 @@ var Sprite = function (_super) {
|
|
|
123
123
|
|
|
124
124
|
Sprite.prototype.componentChanged = function (changed) {
|
|
125
125
|
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
var _this = this;
|
|
129
|
-
|
|
126
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
130
127
|
return __generator(this, function (_a) {
|
|
131
128
|
switch (_a.label) {
|
|
132
129
|
case 0:
|
|
133
|
-
if (!(changed.componentName === 'Sprite')) return [3,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
143
|
-
return [2];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
sprite_1.image = instance[component_1.resource + resourceKeySplit + component_1.spriteName];
|
|
147
|
-
return [2];
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
this.sprites[changed.gameObject.id] = sprite_1;
|
|
152
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
153
|
-
return [3, 4];
|
|
130
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
131
|
+
gameObjectId = changed.gameObject.id;
|
|
132
|
+
component = changed.component;
|
|
133
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
134
|
+
sprite = new Sprite$4(null);
|
|
135
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
136
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
137
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
138
|
+
return [4, resource.getResource(component.resource)];
|
|
154
139
|
|
|
155
140
|
case 1:
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
instance = _a.sent().instance;
|
|
142
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
143
|
+
|
|
144
|
+
if (!instance) {
|
|
145
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
146
|
+
return [2];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
150
|
+
return [3, 5];
|
|
158
151
|
|
|
159
152
|
case 2:
|
|
153
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
154
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
155
|
+
return [4, resource.getResource(component.resource)];
|
|
156
|
+
|
|
157
|
+
case 3:
|
|
160
158
|
instance = _a.sent().instance;
|
|
159
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
161
160
|
|
|
162
161
|
if (!instance) {
|
|
163
162
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
164
163
|
return [2];
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
this.sprites[changed.gameObject.id].image = instance[
|
|
168
|
-
return [3,
|
|
166
|
+
this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
167
|
+
return [3, 5];
|
|
169
168
|
|
|
170
|
-
case
|
|
169
|
+
case 4:
|
|
171
170
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
171
|
+
this.increaseAsyncId(gameObjectId);
|
|
172
172
|
sprite = this.sprites[changed.gameObject.id];
|
|
173
173
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
174
174
|
sprite.sprite.destroy({
|
|
@@ -177,9 +177,9 @@ var Sprite = function (_super) {
|
|
|
177
177
|
delete this.sprites[changed.gameObject.id];
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
_a.label =
|
|
180
|
+
_a.label = 5;
|
|
181
181
|
|
|
182
|
-
case
|
|
182
|
+
case 5:
|
|
183
183
|
return [2];
|
|
184
184
|
}
|
|
185
185
|
});
|
|
@@ -43,6 +43,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
43
43
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function __metadata(metadataKey, metadataValue) {
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
47
51
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48
52
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -107,10 +111,12 @@ var Sprite$3 = (function (_super) {
|
|
|
107
111
|
};
|
|
108
112
|
Sprite.componentName = 'Sprite';
|
|
109
113
|
__decorate([
|
|
110
|
-
inspectorDecorator.
|
|
114
|
+
inspectorDecorator.Field(),
|
|
115
|
+
__metadata("design:type", String)
|
|
111
116
|
], Sprite.prototype, "resource", void 0);
|
|
112
117
|
__decorate([
|
|
113
|
-
inspectorDecorator.
|
|
118
|
+
inspectorDecorator.Field(),
|
|
119
|
+
__metadata("design:type", String)
|
|
114
120
|
], Sprite.prototype, "spriteName", void 0);
|
|
115
121
|
return Sprite;
|
|
116
122
|
}(eva_js.Component));
|
|
@@ -227,52 +233,54 @@ var Sprite = (function (_super) {
|
|
|
227
233
|
};
|
|
228
234
|
Sprite.prototype.componentChanged = function (changed) {
|
|
229
235
|
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
-
var
|
|
231
|
-
var _this = this;
|
|
236
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
232
237
|
return __generator(this, function (_a) {
|
|
233
238
|
switch (_a.label) {
|
|
234
239
|
case 0:
|
|
235
|
-
if (!(changed.componentName === 'Sprite')) return [3,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
245
|
-
return [2];
|
|
246
|
-
}
|
|
247
|
-
sprite_1.image = instance[component_1.resource + resourceKeySplit + component_1.spriteName];
|
|
248
|
-
return [2];
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
this.sprites[changed.gameObject.id] = sprite_1;
|
|
253
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
254
|
-
return [3, 4];
|
|
240
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
241
|
+
gameObjectId = changed.gameObject.id;
|
|
242
|
+
component = changed.component;
|
|
243
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
244
|
+
sprite = new SpriteEngine(null);
|
|
245
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
246
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
247
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
248
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
255
249
|
case 1:
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
instance = (_a.sent()).instance;
|
|
251
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
252
|
+
return [2];
|
|
253
|
+
if (!instance) {
|
|
254
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
255
|
+
return [2];
|
|
256
|
+
}
|
|
257
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
258
|
+
return [3, 5];
|
|
258
259
|
case 2:
|
|
260
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
261
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
262
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
263
|
+
case 3:
|
|
259
264
|
instance = (_a.sent()).instance;
|
|
265
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
266
|
+
return [2];
|
|
260
267
|
if (!instance) {
|
|
261
268
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
262
269
|
return [2];
|
|
263
270
|
}
|
|
264
271
|
this.sprites[changed.gameObject.id].image =
|
|
265
|
-
instance[
|
|
266
|
-
return [3,
|
|
267
|
-
case
|
|
272
|
+
instance[component.resource + resourceKeySplit + component.spriteName];
|
|
273
|
+
return [3, 5];
|
|
274
|
+
case 4:
|
|
268
275
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
276
|
+
this.increaseAsyncId(gameObjectId);
|
|
269
277
|
sprite = this.sprites[changed.gameObject.id];
|
|
270
278
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
271
279
|
sprite.sprite.destroy({ children: true });
|
|
272
280
|
delete this.sprites[changed.gameObject.id];
|
|
273
281
|
}
|
|
274
|
-
_a.label =
|
|
275
|
-
case
|
|
282
|
+
_a.label = 5;
|
|
283
|
+
case 5: return [2];
|
|
276
284
|
}
|
|
277
285
|
});
|
|
278
286
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var p=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([t.Field(),a("design:type",String)],r.prototype,"resource",void 0),s([t.Field(),a("design:type",String)],r.prototype,"spriteName",void 0),r}(e.Component),l=p,f=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),h=f;e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},p=s.animations||{},l={};for(var f in c){l[t+"_s|r|c_"+f]=c[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var d=(i=void 0,u(p[f])),m=d.next();!m.done;m=d.next()){var y=m.value,g=t+"_s|r|c_"+y;h.push(g)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var v=new n.Spritesheet(a,s);v.parse((function(){var t=v.textures;e(t)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var d=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Sprite",e.sprites={},e}return o(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(t){return r=this,n=void 0,o=function(){var r,n,i,o,s;return c(this,(function(a){switch(a.label){case 0:return"Sprite"!==t.componentName?[3,5]:(r=t.gameObject.id,n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new h(null),this.sprites[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[t.gameObject.id].image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]),a.label=5;case 5:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(s,a)}c((o=o.apply(r,n||[])).next())}));var r,n,i,o},n.systemName="Sprite",n=s([e.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);exports.Sprite=l,exports.SpriteSystem=d;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Field } from '@eva/inspector-decorator';
|
|
3
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
4
4
|
import { Texture, Sprite as Sprite$5, BaseTexture, Spritesheet } from 'pixi.js';
|
|
5
5
|
|
|
@@ -39,6 +39,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
39
39
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function __metadata(metadataKey, metadataValue) {
|
|
43
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
47
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
48
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -103,10 +107,12 @@ var Sprite$3 = (function (_super) {
|
|
|
103
107
|
};
|
|
104
108
|
Sprite.componentName = 'Sprite';
|
|
105
109
|
__decorate([
|
|
106
|
-
|
|
110
|
+
Field(),
|
|
111
|
+
__metadata("design:type", String)
|
|
107
112
|
], Sprite.prototype, "resource", void 0);
|
|
108
113
|
__decorate([
|
|
109
|
-
|
|
114
|
+
Field(),
|
|
115
|
+
__metadata("design:type", String)
|
|
110
116
|
], Sprite.prototype, "spriteName", void 0);
|
|
111
117
|
return Sprite;
|
|
112
118
|
}(Component));
|
|
@@ -223,52 +229,54 @@ var Sprite = (function (_super) {
|
|
|
223
229
|
};
|
|
224
230
|
Sprite.prototype.componentChanged = function (changed) {
|
|
225
231
|
return __awaiter(this, void 0, void 0, function () {
|
|
226
|
-
var
|
|
227
|
-
var _this = this;
|
|
232
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
228
233
|
return __generator(this, function (_a) {
|
|
229
234
|
switch (_a.label) {
|
|
230
235
|
case 0:
|
|
231
|
-
if (!(changed.componentName === 'Sprite')) return [3,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
241
|
-
return [2];
|
|
242
|
-
}
|
|
243
|
-
sprite_1.image = instance[component_1.resource + resourceKeySplit + component_1.spriteName];
|
|
244
|
-
return [2];
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
this.sprites[changed.gameObject.id] = sprite_1;
|
|
249
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
250
|
-
return [3, 4];
|
|
236
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
237
|
+
gameObjectId = changed.gameObject.id;
|
|
238
|
+
component = changed.component;
|
|
239
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
240
|
+
sprite = new SpriteEngine(null);
|
|
241
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
242
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
243
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
244
|
+
return [4, resource.getResource(component.resource)];
|
|
251
245
|
case 1:
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
instance = (_a.sent()).instance;
|
|
247
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
248
|
+
return [2];
|
|
249
|
+
if (!instance) {
|
|
250
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
251
|
+
return [2];
|
|
252
|
+
}
|
|
253
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
254
|
+
return [3, 5];
|
|
254
255
|
case 2:
|
|
256
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
257
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
258
|
+
return [4, resource.getResource(component.resource)];
|
|
259
|
+
case 3:
|
|
255
260
|
instance = (_a.sent()).instance;
|
|
261
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
262
|
+
return [2];
|
|
256
263
|
if (!instance) {
|
|
257
264
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
258
265
|
return [2];
|
|
259
266
|
}
|
|
260
267
|
this.sprites[changed.gameObject.id].image =
|
|
261
|
-
instance[
|
|
262
|
-
return [3,
|
|
263
|
-
case
|
|
268
|
+
instance[component.resource + resourceKeySplit + component.spriteName];
|
|
269
|
+
return [3, 5];
|
|
270
|
+
case 4:
|
|
264
271
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
272
|
+
this.increaseAsyncId(gameObjectId);
|
|
265
273
|
sprite = this.sprites[changed.gameObject.id];
|
|
266
274
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
267
275
|
sprite.sprite.destroy({ children: true });
|
|
268
276
|
delete this.sprites[changed.gameObject.id];
|
|
269
277
|
}
|
|
270
|
-
_a.label =
|
|
271
|
-
case
|
|
278
|
+
_a.label = 5;
|
|
279
|
+
case 5: return [2];
|
|
272
280
|
}
|
|
273
281
|
});
|
|
274
282
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7-editor.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-sprite",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/inspector-decorator": "
|
|
22
|
-
"@eva/plugin-renderer": "1.2.
|
|
23
|
-
"@eva/eva.js": "1.2.
|
|
21
|
+
"@eva/inspector-decorator": "0.1.0-alpha.1",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7-editor.2",
|
|
23
|
+
"@eva/eva.js": "1.2.7-editor.2",
|
|
24
24
|
"pixi.js": "^4.8.7"
|
|
25
25
|
}
|
|
26
26
|
}
|