@eva/spine-base 2.0.0-beta.1 → 2.0.0-beta.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.
@@ -21,20 +21,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
21
21
  See the Apache Version 2.0 License for specific language governing permissions
22
22
  and limitations under the License.
23
23
  ***************************************************************************** */
24
- /* global Reflect, Promise */
25
-
26
- var extendStatics = function(d, b) {
27
- extendStatics = Object.setPrototypeOf ||
28
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30
- return extendStatics(d, b);
31
- };
32
-
33
- function __extends(d, b) {
34
- extendStatics(d, b);
35
- function __() { this.constructor = d; }
36
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
- }
38
24
 
39
25
  function __decorate(decorators, target, key, desc) {
40
26
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -50,112 +36,56 @@ function __awaiter(thisArg, _arguments, P, generator) {
50
36
  function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
51
37
  step((generator = generator.apply(thisArg, _arguments || [])).next());
52
38
  });
53
- }
54
-
55
- function __generator(thisArg, body) {
56
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
57
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
- function verb(n) { return function (v) { return step([n, v]); }; }
59
- function step(op) {
60
- if (f) throw new TypeError("Generator is already executing.");
61
- while (_) try {
62
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
- if (y = 0, t) op = [op[0] & 2, t.value];
64
- switch (op[0]) {
65
- case 0: case 1: t = op; break;
66
- case 4: _.label++; return { value: op[1], done: false };
67
- case 5: _.label++; y = op[1]; op = [0]; continue;
68
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
- default:
70
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
- if (t[2]) _.ops.pop();
75
- _.trys.pop(); continue;
76
- }
77
- op = body.call(thisArg, _);
78
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
- }
81
- }
82
-
83
- function __values(o) {
84
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
85
- if (m) return m.call(o);
86
- return {
87
- next: function () {
88
- if (o && i >= o.length) o = void 0;
89
- return { value: o && o[i++], done: !o };
90
- }
91
- };
92
39
  }
93
40
 
94
- var Spine = (function (_super) {
95
- __extends(Spine, _super);
96
- function Spine() {
97
- var _this = _super !== null && _super.apply(this, arguments) || this;
98
- _this.resource = '';
99
- _this.scale = 1;
100
- _this.animationName = '';
101
- _this.autoPlay = true;
102
- _this.waitExecuteInfos = [];
103
- return _this;
41
+ class Spine extends eva_js.Component {
42
+ constructor() {
43
+ super(...arguments);
44
+ this.resource = '';
45
+ this.scale = 1;
46
+ this.animationName = '';
47
+ this.autoPlay = true;
48
+ this.waitExecuteInfos = [];
104
49
  }
105
- Object.defineProperty(Spine.prototype, "armature", {
106
- get: function () {
107
- return this._armature;
108
- },
109
- set: function (val) {
110
- var e_1, _a;
111
- this._armature = val;
112
- if (!val)
113
- return;
114
- if (this.autoPlay) {
115
- this.play(this.animationName);
116
- }
117
- try {
118
- for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
119
- var info = _c.value;
120
- if (info.playType) {
121
- var name_1 = info.name, loop = info.loop, track = info.track;
122
- this.play(name_1, loop, track);
123
- }
124
- else {
125
- this.stop(info.track);
126
- }
127
- }
50
+ set armature(val) {
51
+ this._armature = val;
52
+ if (!val)
53
+ return;
54
+ if (this.autoPlay) {
55
+ this.play(this.animationName);
56
+ }
57
+ for (const info of this.waitExecuteInfos) {
58
+ if (info.playType) {
59
+ const { name, loop, track } = info;
60
+ this.play(name, loop, track);
128
61
  }
129
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
130
- finally {
131
- try {
132
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
133
- }
134
- finally { if (e_1) throw e_1.error; }
62
+ else {
63
+ this.stop(info.track);
135
64
  }
136
- this.waitExecuteInfos = [];
137
- },
138
- enumerable: false,
139
- configurable: true
140
- });
141
- Spine.prototype.init = function (obj) {
65
+ }
66
+ this.waitExecuteInfos = [];
67
+ }
68
+ get armature() {
69
+ return this._armature;
70
+ }
71
+ init(obj) {
142
72
  if (!obj)
143
73
  return;
144
74
  Object.assign(this, obj);
145
- };
146
- Spine.prototype.onDestroy = function () {
75
+ }
76
+ onDestroy() {
147
77
  this.destroied = true;
148
- };
149
- Spine.prototype.play = function (name, loop, track) {
78
+ }
79
+ play(name, loop, track) {
150
80
  try {
151
81
  if (name)
152
82
  this.animationName = name;
153
83
  if (!this.armature) {
154
84
  this.waitExecuteInfos.push({
155
85
  playType: true,
156
- name: name,
86
+ name,
157
87
  loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
158
- track: track,
88
+ track,
159
89
  });
160
90
  }
161
91
  else {
@@ -168,12 +98,12 @@ var Spine = (function (_super) {
168
98
  catch (e) {
169
99
  console.log(e);
170
100
  }
171
- };
172
- Spine.prototype.stop = function (track) {
101
+ }
102
+ stop(track) {
173
103
  if (!this.armature) {
174
104
  this.waitExecuteInfos.push({
175
105
  playType: false,
176
- track: track,
106
+ track,
177
107
  });
178
108
  return;
179
109
  }
@@ -181,8 +111,8 @@ var Spine = (function (_super) {
181
111
  track = 0;
182
112
  }
183
113
  this.armature.state.setEmptyAnimation(track, 0);
184
- };
185
- Spine.prototype.addAnimation = function (name, delay, loop, track) {
114
+ }
115
+ addAnimation(name, delay, loop, track) {
186
116
  try {
187
117
  if (!this.armature) {
188
118
  }
@@ -196,15 +126,14 @@ var Spine = (function (_super) {
196
126
  catch (e) {
197
127
  console.log(e);
198
128
  }
199
- };
200
- Spine.prototype.setMix = function (from, to, duration) {
129
+ }
130
+ setMix(from, to, duration) {
201
131
  if (!this.armature) ;
202
132
  else {
203
133
  this.armature.stateData.setMix(from, to, duration);
204
134
  }
205
- };
206
- Spine.prototype.getAnim = function (track) {
207
- if (track === void 0) { track = 0; }
135
+ }
136
+ getAnim(track = 0) {
208
137
  try {
209
138
  if (!this.armature) {
210
139
  }
@@ -215,52 +144,50 @@ var Spine = (function (_super) {
215
144
  catch (e) {
216
145
  console.log(e);
217
146
  }
218
- };
219
- Spine.prototype.setDefaultMix = function (duration) {
147
+ }
148
+ setDefaultMix(duration) {
220
149
  if (!this.armature) ;
221
150
  else {
222
151
  this.armature.stateData.defaultMix = duration;
223
152
  }
224
- };
225
- Spine.prototype.setAttachment = function (slotName, attachmentName) {
153
+ }
154
+ setAttachment(slotName, attachmentName) {
226
155
  if (!this.armature) {
227
156
  return;
228
157
  }
229
158
  this.armature.skeleton.setAttachment(slotName, attachmentName);
230
- };
231
- Spine.prototype.getBone = function (boneName) {
159
+ }
160
+ getBone(boneName) {
232
161
  if (!this.armature) {
233
162
  return;
234
163
  }
235
164
  return this.armature.skeleton.findBone(boneName);
236
- };
237
- Spine.componentName = 'Spine';
238
- __decorate([
239
- inspectorDecorator.type('string')
240
- ], Spine.prototype, "resource", void 0);
241
- __decorate([
242
- inspectorDecorator.type('number')
243
- ], Spine.prototype, "scale", void 0);
244
- __decorate([
245
- inspectorDecorator.type('string')
246
- ], Spine.prototype, "animationName", void 0);
247
- __decorate([
248
- inspectorDecorator.type('boolean')
249
- ], Spine.prototype, "autoPlay", void 0);
250
- return Spine;
251
- }(eva_js.Component));
252
- var Spine$1 = Spine;
165
+ }
166
+ }
167
+ Spine.componentName = 'Spine';
168
+ __decorate([
169
+ inspectorDecorator.type('string')
170
+ ], Spine.prototype, "resource", void 0);
171
+ __decorate([
172
+ inspectorDecorator.type('number')
173
+ ], Spine.prototype, "scale", void 0);
174
+ __decorate([
175
+ inspectorDecorator.type('string')
176
+ ], Spine.prototype, "animationName", void 0);
177
+ __decorate([
178
+ inspectorDecorator.type('boolean')
179
+ ], Spine.prototype, "autoPlay", void 0);
253
180
 
254
- var texCache = {};
181
+ let texCache = {};
255
182
  function cacheImage(data) {
256
- var oldImg = data.image;
183
+ const oldImg = data.image;
257
184
  return {
258
185
  tex: oldImg instanceof pixi_js.Texture ? oldImg : pixi_js.Texture.from(oldImg),
259
186
  count: 0,
260
187
  };
261
188
  }
262
189
  function retainTexture(name, data) {
263
- var cache = texCache[name];
190
+ let cache = texCache[name];
264
191
  if (!cache) {
265
192
  cache = cacheImage(data);
266
193
  texCache[name] = cache;
@@ -271,8 +198,8 @@ function retainTexture(name, data) {
271
198
  function releaseTexture(imageSrc) {
272
199
  if (!imageSrc)
273
200
  return;
274
- setTimeout(function () {
275
- var cache = texCache[imageSrc];
201
+ setTimeout(() => {
202
+ const cache = texCache[imageSrc];
276
203
  if (cache) {
277
204
  cache.count--;
278
205
  if (cache.count <= 0) {
@@ -286,41 +213,38 @@ function releaseTexture(imageSrc) {
286
213
  }, 100);
287
214
  }
288
215
 
289
- var dataMap = {};
216
+ let dataMap = {};
290
217
  function createSpineData(name, data, scale, pixiSpine) {
291
- var skeletonAsset = data.ske;
292
- var atlasAsset = data.atlas;
293
- var attachmentLoader = new pixiSpine.AtlasAttachmentLoader(atlasAsset);
294
- var parser = skeletonAsset instanceof Uint8Array
218
+ const skeletonAsset = data.ske;
219
+ const atlasAsset = data.atlas;
220
+ const attachmentLoader = new pixiSpine.AtlasAttachmentLoader(atlasAsset);
221
+ const parser = skeletonAsset instanceof Uint8Array
295
222
  ? new pixiSpine.SkeletonBinary(attachmentLoader)
296
223
  : new pixiSpine.SkeletonJson(attachmentLoader);
297
224
  parser.scale = scale || 1;
298
- var skeletonData = parser.readSkeletonData(skeletonAsset);
299
- var obj = { spineData: skeletonData, ref: 0, imageSrc: data.image.label };
225
+ const skeletonData = parser.readSkeletonData(skeletonAsset);
226
+ const obj = { spineData: skeletonData, ref: 0, imageSrc: data.image.label };
300
227
  dataMap[name] = obj;
301
228
  return obj;
302
229
  }
303
230
  function getSpineData(res, scale, pixiSpine) {
304
- return __awaiter(this, void 0, void 0, function () {
305
- var data;
306
- return __generator(this, function (_a) {
307
- data = dataMap[res.name];
308
- if (!data) {
309
- if (res.complete) {
310
- data = createSpineData(res.name, res.data, scale, pixiSpine);
311
- }
312
- else if (!data) {
313
- return [2];
314
- }
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ let data = dataMap[res.name];
233
+ if (!data) {
234
+ if (res.complete) {
235
+ data = createSpineData(res.name, res.data, scale, pixiSpine);
315
236
  }
316
- retainTexture(res.data.image.label, res.data);
317
- data.ref++;
318
- return [2, data.spineData];
319
- });
237
+ else if (!data) {
238
+ return;
239
+ }
240
+ }
241
+ retainTexture(res.data.image.label, res.data);
242
+ data.ref++;
243
+ return data.spineData;
320
244
  });
321
245
  }
322
246
  function releaseSpineData(resourceName, imageSrc) {
323
- var data = dataMap[resourceName];
247
+ const data = dataMap[resourceName];
324
248
  if (!data) {
325
249
  return;
326
250
  }
@@ -331,209 +255,179 @@ function releaseSpineData(resourceName, imageSrc) {
331
255
  }
332
256
  }
333
257
 
334
- var MaxRetryCount = 20;
335
- var SpineSystem = (function (_super) {
336
- __extends(SpineSystem, _super);
337
- function SpineSystem() {
338
- var _this = _super !== null && _super.apply(this, arguments) || this;
339
- _this.armatures = {};
340
- return _this;
258
+ const MaxRetryCount = 20;
259
+ let SpineSystem = class SpineSystem extends pluginRenderer.Renderer {
260
+ constructor() {
261
+ super(...arguments);
262
+ this.armatures = {};
341
263
  }
342
- SpineSystem.prototype.init = function (_a) {
343
- var _this = this;
344
- var pixiSpine = _a.pixiSpine;
264
+ init({ pixiSpine }) {
345
265
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
346
266
  this.renderSystem.rendererManager.register(this);
347
267
  this.pixiSpine = pixiSpine;
348
- this.game.canvas.addEventListener('webglcontextrestored', function () {
349
- var objs = _this.game.gameObjects;
350
- var toAdd = [];
351
- for (var k in _this.armatures) {
352
- var id = +k;
353
- for (var i = 0; i < objs.length; ++i) {
354
- var obj = objs[i];
268
+ this.game.canvas.addEventListener('webglcontextrestored', () => {
269
+ const objs = this.game.gameObjects;
270
+ let toAdd = [];
271
+ for (let k in this.armatures) {
272
+ const id = +k;
273
+ for (let i = 0; i < objs.length; ++i) {
274
+ let obj = objs[i];
355
275
  if (obj.id === id) {
356
- var sp = obj.getComponent(Spine$1);
276
+ let sp = obj.getComponent(Spine);
357
277
  if (sp) {
358
- _this.remove({
278
+ this.remove({
359
279
  type: eva_js.OBSERVER_TYPE.REMOVE,
360
280
  gameObject: obj,
361
281
  component: sp,
362
- componentName: Spine$1.componentName,
282
+ componentName: Spine.componentName,
363
283
  });
364
284
  toAdd.push({
365
285
  type: eva_js.OBSERVER_TYPE.ADD,
366
286
  gameObject: obj,
367
287
  component: sp,
368
- componentName: Spine$1.componentName,
288
+ componentName: Spine.componentName,
369
289
  });
370
290
  }
371
291
  break;
372
292
  }
373
293
  }
374
294
  }
375
- setTimeout(function () {
376
- toAdd.forEach(function (obj) {
377
- _this.add(obj);
295
+ setTimeout(() => {
296
+ toAdd.forEach(obj => {
297
+ this.add(obj);
378
298
  });
379
299
  }, 1000);
380
300
  }, false);
381
- };
382
- SpineSystem.prototype.update = function (e) {
383
- for (var key in this.armatures) {
301
+ }
302
+ update(e) {
303
+ for (let key in this.armatures) {
384
304
  this.armatures[key].update(e.deltaTime * 0.001);
385
305
  }
386
- _super.prototype.update.call(this);
387
- };
388
- SpineSystem.prototype.componentChanged = function (changed) {
389
- return __awaiter(this, void 0, void 0, function () {
390
- return __generator(this, function (_a) {
391
- if (changed.componentName === 'Spine') {
392
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
393
- this.add(changed);
394
- }
395
- else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
396
- switch (changed.prop.prop[0]) {
397
- case 'resource':
398
- this.change(changed);
399
- break;
400
- }
401
- }
402
- else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
403
- this.remove(changed);
306
+ super.update();
307
+ }
308
+ componentChanged(changed) {
309
+ return __awaiter(this, void 0, void 0, function* () {
310
+ if (changed.componentName === 'Spine') {
311
+ if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
312
+ this.add(changed);
313
+ }
314
+ else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
315
+ switch (changed.prop.prop[0]) {
316
+ case 'resource':
317
+ this.change(changed);
318
+ break;
404
319
  }
405
320
  }
406
- return [2];
407
- });
321
+ else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
322
+ this.remove(changed);
323
+ }
324
+ }
408
325
  });
409
- };
410
- SpineSystem.prototype.add = function (changed, count) {
326
+ }
327
+ add(changed, count) {
411
328
  var _a, _b;
412
- return __awaiter(this, void 0, void 0, function () {
413
- var component, gameObjectId, asyncId, res, spineData, container, armature, tran;
414
- var _this = this;
415
- return __generator(this, function (_c) {
416
- switch (_c.label) {
417
- case 0:
418
- component = changed.component;
419
- clearTimeout(component.addHandler);
420
- gameObjectId = changed.gameObject.id;
421
- asyncId = this.increaseAsyncId(gameObjectId);
422
- return [4, eva_js.resource.getResource(component.resource)];
423
- case 1:
424
- res = _c.sent();
425
- if (!this.validateAsyncId(gameObjectId, asyncId))
426
- return [2];
427
- return [4, getSpineData(res, component.scale, this.pixiSpine)];
428
- case 2:
429
- spineData = _c.sent();
430
- if (!this.validateAsyncId(gameObjectId, asyncId))
431
- return [2];
432
- if (!spineData) {
433
- component.addHandler = setTimeout(function () {
434
- if (!component.destroied) {
435
- if (count === undefined) {
436
- count = MaxRetryCount;
437
- }
438
- count--;
439
- if (count > 0) {
440
- _this.add(changed, count);
441
- }
442
- else {
443
- console.log('retry exceed max times', component.resource);
444
- }
445
- }
446
- }, 1000);
447
- return [2];
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const component = changed.component;
331
+ clearTimeout(component.addHandler);
332
+ const gameObjectId = changed.gameObject.id;
333
+ const asyncId = this.increaseAsyncId(gameObjectId);
334
+ const res = yield eva_js.resource.getResource(component.resource);
335
+ if (!this.validateAsyncId(gameObjectId, asyncId))
336
+ return;
337
+ const spineData = yield getSpineData(res, component.scale, this.pixiSpine);
338
+ if (!this.validateAsyncId(gameObjectId, asyncId))
339
+ return;
340
+ if (!spineData) {
341
+ component.addHandler = setTimeout(() => {
342
+ if (!component.destroied) {
343
+ if (count === undefined) {
344
+ count = MaxRetryCount;
448
345
  }
449
- this.remove(changed);
450
- container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
451
- if (!container) {
452
- return [2];
346
+ count--;
347
+ if (count > 0) {
348
+ this.add(changed, count);
453
349
  }
454
- component.lastResource = component.resource;
455
- armature = new this.pixiSpine.Spine({
456
- skeletonData: spineData,
457
- autoUpdate: false,
458
- });
459
- this.armatures[changed.gameObject.id] = armature;
460
- if (changed.gameObject && changed.gameObject.transform) {
461
- tran = changed.gameObject.transform;
462
- armature.x = tran.size.width * tran.origin.x;
463
- armature.y = tran.size.height * tran.origin.y;
350
+ else {
351
+ console.log('retry exceed max times', component.resource);
464
352
  }
465
- container.addChildAt(armature, 0);
466
- armature.update();
467
- component.armature = armature;
468
- component.emit('loaded', { resource: component.resource });
469
- armature.state.addListener({
470
- start: function (track, event) {
471
- component.emit('start', { track: track, name: track.animation.name });
472
- },
473
- complete: function (track, event) {
474
- component.emit('complete', { track: track, name: track.animation.name });
475
- },
476
- interrupt: function (track, event) {
477
- component.emit('interrupt', { track: track, name: track.animation.name });
478
- },
479
- end: function (track, event) {
480
- component.emit('end', { track: track, name: track.animation.name });
481
- },
482
- event: function (track, event) {
483
- component.emit('event', track, event);
484
- },
485
- });
486
- return [2];
487
- }
353
+ }
354
+ }, 1000);
355
+ return;
356
+ }
357
+ this.remove(changed);
358
+ const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
359
+ if (!container) {
360
+ return;
361
+ }
362
+ component.lastResource = component.resource;
363
+ const armature = new this.pixiSpine.Spine({
364
+ skeletonData: spineData,
365
+ autoUpdate: false,
366
+ });
367
+ this.armatures[changed.gameObject.id] = armature;
368
+ if (changed.gameObject && changed.gameObject.transform) {
369
+ const tran = changed.gameObject.transform;
370
+ armature.x = tran.size.width * tran.origin.x;
371
+ armature.y = tran.size.height * tran.origin.y;
372
+ }
373
+ container.addChildAt(armature, 0);
374
+ armature.update();
375
+ component.armature = armature;
376
+ component.emit('loaded', { resource: component.resource });
377
+ armature.state.addListener({
378
+ start: (track, event) => {
379
+ component.emit('start', { track, name: track.animation.name });
380
+ },
381
+ complete: (track, event) => {
382
+ component.emit('complete', { track, name: track.animation.name });
383
+ },
384
+ interrupt: (track, event) => {
385
+ component.emit('interrupt', { track, name: track.animation.name });
386
+ },
387
+ end: (track, event) => {
388
+ component.emit('end', { track, name: track.animation.name });
389
+ },
390
+ event: (track, event) => {
391
+ component.emit('event', track, event);
392
+ },
488
393
  });
489
394
  });
490
- };
491
- SpineSystem.prototype.change = function (changed) {
395
+ }
396
+ change(changed) {
492
397
  this.remove(changed);
493
398
  this.add(changed);
494
- };
495
- SpineSystem.prototype.remove = function (changed) {
399
+ }
400
+ remove(changed) {
496
401
  var _a, _b, _c, _d;
497
- return __awaiter(this, void 0, void 0, function () {
498
- var component, armature, container, res;
499
- return __generator(this, function (_e) {
500
- switch (_e.label) {
501
- case 0:
502
- this.increaseAsyncId(changed.gameObject.id);
503
- component = changed.component;
504
- clearTimeout(component.addHandler);
505
- armature = this.armatures[changed.gameObject.id];
506
- container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
507
- if (container && armature) {
508
- container.removeChild(armature);
509
- }
510
- if (!component.armature) return [3, 2];
511
- component.armature.destroy({ children: true });
512
- return [4, eva_js.resource.getResource(component.lastResource)];
513
- case 1:
514
- res = _e.sent();
515
- releaseSpineData(res.name, (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src);
516
- _e.label = 2;
517
- case 2:
518
- component.armature = null;
519
- delete this.armatures[changed.gameObject.id];
520
- if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
521
- return [2];
522
- }
523
- });
402
+ return __awaiter(this, void 0, void 0, function* () {
403
+ this.increaseAsyncId(changed.gameObject.id);
404
+ const component = changed.component;
405
+ clearTimeout(component.addHandler);
406
+ const armature = this.armatures[changed.gameObject.id];
407
+ const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
408
+ if (container && armature) {
409
+ container.removeChild(armature);
410
+ }
411
+ if (component.armature) {
412
+ component.armature.destroy({ children: true });
413
+ const res = yield eva_js.resource.getResource(component.lastResource);
414
+ releaseSpineData(res.name, (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src);
415
+ }
416
+ component.armature = null;
417
+ delete this.armatures[changed.gameObject.id];
418
+ if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
524
419
  });
525
- };
526
- SpineSystem.systemName = 'SpineSystem';
527
- SpineSystem = __decorate([
528
- eva_js.decorators.componentObserver({
529
- Spine: ['resource'],
530
- })
531
- ], SpineSystem);
532
- return SpineSystem;
533
- }(pluginRenderer.Renderer));
420
+ }
421
+ };
422
+ SpineSystem.systemName = 'SpineSystem';
423
+ SpineSystem = __decorate([
424
+ eva_js.decorators.componentObserver({
425
+ Spine: ['resource'],
426
+ })
427
+ ], SpineSystem);
534
428
  var SpineSystem$1 = SpineSystem;
535
429
 
536
430
  eva_js.resource.registerResourceType('SPINE');
537
431
 
538
- exports.Spine = Spine$1;
432
+ exports.Spine = Spine;
539
433
  exports.SpineSystem = SpineSystem$1;