@eva/plugin-renderer-spine 1.2.2-type.0 → 1.2.4

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.
@@ -184,6 +184,23 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
184
184
  }
185
185
  }
186
186
 
187
+ function __values(o) {
188
+ var s = typeof Symbol === "function" && Symbol.iterator,
189
+ m = s && o[s],
190
+ i = 0;
191
+ if (m) return m.call(o);
192
+ if (o && typeof o.length === "number") return {
193
+ next: function next() {
194
+ if (o && i >= o.length) o = void 0;
195
+ return {
196
+ value: o && o[i++],
197
+ done: !o
198
+ };
199
+ }
200
+ };
201
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
202
+ }
203
+
187
204
  function getIDEPropsPropertyObj(target, propertyKey) {
188
205
  if (!target.constructor.IDEProps) {
189
206
  target.constructor.IDEProps = {};
@@ -214,17 +231,59 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
214
231
  _this.resource = '';
215
232
  _this.animationName = '';
216
233
  _this.autoPlay = true;
234
+ _this.waitExecuteInfos = [];
217
235
  return _this;
218
236
  }
219
237
 
238
+ Object.defineProperty(Spine.prototype, "armature", {
239
+ get: function get() {
240
+ return this._armature;
241
+ },
242
+ set: function set(val) {
243
+ var e_1, _a;
244
+
245
+ this._armature = val;
246
+ if (!val) return;
247
+
248
+ if (this.autoPlay) {
249
+ this.play(this.animationName);
250
+ }
251
+
252
+ try {
253
+ for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
254
+ var info = _c.value;
255
+
256
+ if (info.playType) {
257
+ var name_1 = info.name,
258
+ loop = info.loop,
259
+ track = info.track;
260
+ this.play(name_1, loop, track);
261
+ } else {
262
+ this.stop(info.track);
263
+ }
264
+ }
265
+ } catch (e_1_1) {
266
+ e_1 = {
267
+ error: e_1_1
268
+ };
269
+ } finally {
270
+ try {
271
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
272
+ } finally {
273
+ if (e_1) throw e_1.error;
274
+ }
275
+ }
276
+
277
+ this.waitExecuteInfos = [];
278
+ },
279
+ enumerable: false,
280
+ configurable: true
281
+ });
282
+
220
283
  Spine.prototype.init = function (obj) {
221
284
  if (!obj) return;
222
285
 
223
286
  _extends(this, obj);
224
-
225
- if (this.autoPlay) {
226
- this.play(this.animationName);
227
- }
228
287
  };
229
288
 
230
289
  Spine.prototype.onDestroy = function () {
@@ -235,7 +294,14 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
235
294
  try {
236
295
  if (name) this.animationName = name;
237
296
 
238
- if (!this.armature) {} else {
297
+ if (!this.armature) {
298
+ this.waitExecuteInfos.push({
299
+ playType: true,
300
+ name: name,
301
+ loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
302
+ track: track
303
+ });
304
+ } else {
239
305
  if (track === undefined) {
240
306
  track = 0;
241
307
  }
@@ -249,6 +315,10 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
249
315
 
250
316
  Spine.prototype.stop = function (track) {
251
317
  if (!this.armature) {
318
+ this.waitExecuteInfos.push({
319
+ playType: false,
320
+ track: track
321
+ });
252
322
  return;
253
323
  }
254
324
 
@@ -537,24 +607,26 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
537
607
  };
538
608
 
539
609
  SpineSystem.prototype.add = function (changed, count) {
610
+ var _a, _b;
611
+
540
612
  return __awaiter(this, void 0, void 0, function () {
541
613
  var component, res, spineData, container, armature, tran;
542
614
 
543
615
  var _this = this;
544
616
 
545
- return __generator(this, function (_a) {
546
- switch (_a.label) {
617
+ return __generator(this, function (_c) {
618
+ switch (_c.label) {
547
619
  case 0:
548
620
  component = changed.component;
549
621
  clearTimeout(component.addHandler);
550
622
  return [4, eva_js.resource.getResource(component.resource)];
551
623
 
552
624
  case 1:
553
- res = _a.sent();
625
+ res = _c.sent();
554
626
  return [4, getSpineData(res, this.pixiSpine)];
555
627
 
556
628
  case 2:
557
- spineData = _a.sent();
629
+ spineData = _c.sent();
558
630
 
559
631
  if (!spineData) {
560
632
  component.addHandler = setTimeout(function () {
@@ -576,7 +648,7 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
576
648
  }
577
649
 
578
650
  this.remove(changed);
579
- container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
651
+ container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
580
652
 
581
653
  if (!container) {
582
654
  return [2];
@@ -596,15 +668,6 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
596
668
  armature.update();
597
669
  armature.updateTransform();
598
670
  component.armature = armature;
599
-
600
- if (component.autoPlay) {
601
- try {
602
- armature.state.setAnimation(0, component.animationName, true);
603
- } catch (e) {
604
- console.log(e);
605
- }
606
- }
607
-
608
671
  component.emit('loaded', {
609
672
  resource: component.resource
610
673
  });
@@ -649,17 +712,17 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
649
712
  };
650
713
 
651
714
  SpineSystem.prototype.remove = function (changed) {
652
- var _a, _b;
715
+ var _a, _b, _c, _d;
653
716
 
654
717
  return __awaiter(this, void 0, void 0, function () {
655
718
  var component, armature, container, res;
656
- return __generator(this, function (_c) {
657
- switch (_c.label) {
719
+ return __generator(this, function (_e) {
720
+ switch (_e.label) {
658
721
  case 0:
659
722
  component = changed.component;
660
723
  clearTimeout(component.addHandler);
661
724
  armature = this.armatures[changed.gameObject.id];
662
- container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
725
+ container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
663
726
 
664
727
  if (container && armature) {
665
728
  container.removeChild(armature);
@@ -672,9 +735,9 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
672
735
  return [4, eva_js.resource.getResource(component.lastResource)];
673
736
 
674
737
  case 1:
675
- res = _c.sent();
676
- releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
677
- _c.label = 2;
738
+ res = _e.sent();
739
+ releaseSpineData(res.name, (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src);
740
+ _e.label = 2;
678
741
 
679
742
  case 2:
680
743
  component.armature = null;
@@ -9489,9 +9552,9 @@ var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
9489
9552
  var cachedResource = loader.resources[name];
9490
9553
 
9491
9554
  if (cachedResource) {
9492
- function done() {
9555
+ var done = function done() {
9493
9556
  callback(cachedResource.texture.baseTexture);
9494
- }
9557
+ };
9495
9558
 
9496
9559
  if (cachedResource.texture) {
9497
9560
  done();