@eva/spine-base 2.1.0-beta.1 → 2.1.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/spine-base",
3
- "version": "2.1.0-beta.1",
3
+ "version": "2.1.0-beta.3",
4
4
  "description": "@eva/spine-base",
5
5
  "main": "index.js",
6
6
  "module": "dist/spine-base.esm.js",
@@ -18,8 +18,8 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "2.1.0-beta.1",
22
- "@eva/plugin-renderer": "2.1.0-beta.1",
21
+ "@eva/eva.js": "2.1.0-beta.3",
22
+ "@eva/plugin-renderer": "2.1.0-beta.3",
23
23
  "@eva/inspector-decorator": "^2.0.0-beta.0",
24
24
  "pixi.js": "^8.17.0"
25
25
  }
@@ -1,687 +0,0 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- globalThis.EVA = globalThis.EVA || {};
3
- globalThis.EVA.plugin = globalThis.EVA.plugin || {};
4
- var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
5
- 'use strict';
6
- function __decorate(decorators, target, key, desc) {
7
- var c = arguments.length,
8
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
9
- d;
10
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
- return c > 3 && r && Object.defineProperty(target, key, r), r;
12
- }
13
- function __metadata(metadataKey, metadataValue) {
14
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
15
- }
16
- function __awaiter(thisArg, _arguments, P, generator) {
17
- function adopt(value) {
18
- return value instanceof P ? value : new P(function (resolve) {
19
- resolve(value);
20
- });
21
- }
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- }
30
- function rejected(value) {
31
- try {
32
- step(generator["throw"](value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- }
37
- function step(result) {
38
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
39
- }
40
- step((generator = generator.apply(thisArg, _arguments || [])).next());
41
- });
42
- }
43
- function __rest(s, e) {
44
- var t = {};
45
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
46
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
47
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
48
- }
49
- return t;
50
- }
51
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
52
- var e = new Error(message);
53
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
54
- };
55
- class SymbolKeysNotSupportedError extends Error {
56
- constructor() {
57
- super('Symbol keys are not supported yet!');
58
- Object.setPrototypeOf(this, new.target.prototype);
59
- }
60
- }
61
- const IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
62
- function transformBasicType(type) {
63
- if (type === String) {
64
- return 'string';
65
- }
66
- if (type === Number) {
67
- return 'number';
68
- }
69
- if (type === Boolean) {
70
- return 'boolean';
71
- }
72
- return 'unknown';
73
- }
74
- function defineLegacyIDEProp(target, propertyKey, patch) {
75
- const constructor = target.constructor;
76
- const current = constructor.IDEProps || {};
77
- current[propertyKey] = _extends(_extends({
78
- key: propertyKey
79
- }, current[propertyKey]), patch);
80
- constructor.IDEProps = current;
81
- }
82
- function defineTypes(target, key, options, returnTypeFunction) {
83
- let type = Reflect.getMetadata('design:type', target, key);
84
- let isArray = type === Array;
85
- const str = transformBasicType(type);
86
- if (str !== 'unknown') {
87
- type = str;
88
- }
89
- if (returnTypeFunction) {
90
- const returnType = returnTypeFunction();
91
- if (Array.isArray(returnType)) {
92
- isArray = true;
93
- type = returnType[0];
94
- } else {
95
- type = returnType;
96
- }
97
- }
98
- const properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
99
- const current = properties[key] || {};
100
- const property = _extends(_extends(_extends({}, current), {
101
- type,
102
- isArray: isArray
103
- }), options);
104
- properties[key] = property;
105
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
106
- const legacyProperty = __rest(property, ["isArray"]);
107
- defineLegacyIDEProp(target, key, legacyProperty);
108
- }
109
- function type(type) {
110
- return Field({
111
- type
112
- });
113
- }
114
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
115
- if (typeof returnTypeFuncOrOptions === 'function') {
116
- return {
117
- returnTypeFunc: returnTypeFuncOrOptions,
118
- options: maybeOptions || {}
119
- };
120
- }
121
- return {
122
- options: returnTypeFuncOrOptions || {}
123
- };
124
- }
125
- function Field(returnTypeFunction, maybeOptions) {
126
- return (target, propertyKey) => {
127
- if (typeof propertyKey === 'symbol') {
128
- throw new SymbolKeysNotSupportedError();
129
- }
130
- const {
131
- options,
132
- returnTypeFunc
133
- } = getTypeDecoratorParams(returnTypeFunction, maybeOptions);
134
- defineTypes(target, propertyKey, options, returnTypeFunc);
135
- };
136
- }
137
- var ExecuteMode;
138
- (function (ExecuteMode) {
139
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
140
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
141
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
142
- })(ExecuteMode || (ExecuteMode = {}));
143
- class Spine extends eva_js.Component {
144
- constructor(params) {
145
- super(params);
146
- this.resource = '';
147
- this.scale = 1;
148
- this.animationName = '';
149
- this.autoPlay = true;
150
- this.keepResource = false;
151
- this.timeScale = 1;
152
- this.skin = '';
153
- this._slotGameObjects = new Map();
154
- this._pendingSlotObjects = [];
155
- this.waitExecuteInfos = [];
156
- this.listenerBound = false;
157
- this.paused = false;
158
- this.init(params);
159
- }
160
- set armature(val) {
161
- this._armature = val;
162
- if (!val) return;
163
- this.applyTimeScale();
164
- if (this.skin) this.setSkin(this.skin);
165
- if (this.autoPlay) {
166
- this.play(this.animationName);
167
- }
168
- for (const info of this.waitExecuteInfos) {
169
- if (info.playType) {
170
- const {
171
- name,
172
- loop,
173
- track
174
- } = info;
175
- this.play(name, loop, track);
176
- } else {
177
- this.stop(info.track);
178
- }
179
- }
180
- this.waitExecuteInfos = [];
181
- }
182
- get armature() {
183
- return this._armature;
184
- }
185
- init(obj) {
186
- if (obj) _extends(this, obj);
187
- if (!this.listenerBound) {
188
- this.listenerBound = true;
189
- this.on('start', event => {
190
- var _a;
191
- (_a = this.onStart) === null || _a === void 0 ? void 0 : _a.call(this, event);
192
- });
193
- this.on('complete', event => {
194
- var _a;
195
- (_a = this.onComplete) === null || _a === void 0 ? void 0 : _a.call(this, event);
196
- });
197
- this.on('event', (track, event) => {
198
- var _a;
199
- (_a = this.onEvent) === null || _a === void 0 ? void 0 : _a.call(this, track, event);
200
- });
201
- }
202
- }
203
- onDestroy() {
204
- this.destroied = true;
205
- }
206
- load() {
207
- return this.armature;
208
- }
209
- destroy() {
210
- this.onDestroy();
211
- if (this.armature && !this.armature.destroyed) {
212
- this._destroySlotGameObjects();
213
- this.armature.destroy({
214
- children: true
215
- });
216
- }
217
- this.armature = null;
218
- }
219
- pause() {
220
- this.paused = true;
221
- this.applyTimeScale();
222
- }
223
- resume() {
224
- this.paused = false;
225
- this.applyTimeScale();
226
- }
227
- setSkin(name) {
228
- var _a, _b, _c, _d, _e;
229
- this.skin = name;
230
- if (!((_a = this.armature) === null || _a === void 0 ? void 0 : _a.skeleton)) return;
231
- if (this.armature.skeleton.setSkinByName) {
232
- this.armature.skeleton.setSkinByName(name);
233
- } else if (this.armature.skeleton.setSkin) {
234
- const skin = ((_c = (_b = this.armature.skeleton.data) === null || _b === void 0 ? void 0 : _b.findSkin) === null || _c === void 0 ? void 0 : _c.call(_b, name)) || name;
235
- this.armature.skeleton.setSkin(skin);
236
- }
237
- (_e = (_d = this.armature.skeleton).setSlotsToSetupPose) === null || _e === void 0 ? void 0 : _e.call(_d);
238
- }
239
- play(name, loopAnimation, track) {
240
- try {
241
- const loop = loopAnimation !== null && loopAnimation !== void 0 ? loopAnimation : this.autoPlay;
242
- if (name) this.animationName = name;
243
- if (!this.armature) {
244
- this.waitExecuteInfos.push({
245
- playType: true,
246
- name,
247
- loop,
248
- track
249
- });
250
- } else {
251
- if (track === undefined) {
252
- track = 0;
253
- }
254
- this.applyTimeScale();
255
- this.armature.state.setAnimation(track, this.animationName, loop);
256
- }
257
- } catch (e) {
258
- console.log(e);
259
- }
260
- }
261
- stop(track) {
262
- if (!this.armature) {
263
- this.waitExecuteInfos.push({
264
- playType: false,
265
- track
266
- });
267
- return;
268
- }
269
- if (track === undefined) {
270
- track = 0;
271
- }
272
- this.armature.state.setEmptyAnimation(track, 0);
273
- }
274
- applyTimeScale() {
275
- var _a;
276
- if (!((_a = this.armature) === null || _a === void 0 ? void 0 : _a.state)) return;
277
- this.armature.state.timeScale = this.paused ? 0 : this.timeScale;
278
- }
279
- addAnimation(name, delay, loop, track) {
280
- try {
281
- if (!this.armature) {} else {
282
- if (track === undefined) {
283
- track = 0;
284
- }
285
- this.armature.state.addAnimation(track, name, loop, delay);
286
- }
287
- } catch (e) {
288
- console.log(e);
289
- }
290
- }
291
- setMix(from, to, duration) {
292
- if (!this.armature) ;else {
293
- this.armature.state.data.setMix(from, to, duration);
294
- }
295
- }
296
- getAnim(track = 0) {
297
- try {
298
- if (!this.armature) {} else {
299
- return this.armature.state.tracks[track].animation.name;
300
- }
301
- } catch (e) {
302
- console.log(e);
303
- }
304
- }
305
- setDefaultMix(duration) {
306
- if (!this.armature) ;else {
307
- this.armature.state.data.defaultMix = duration;
308
- }
309
- }
310
- setAttachment(slotName, attachmentName) {
311
- if (!this.armature) {
312
- return;
313
- }
314
- this.armature.skeleton.setAttachment(slotName, attachmentName);
315
- }
316
- getBone(boneName) {
317
- if (!this.armature) {
318
- return;
319
- }
320
- return this.armature.skeleton.findBone(boneName);
321
- }
322
- addSlotObject(slot, gameObject, options) {
323
- if (!this.armature) {
324
- console.warn('Spine armature is not ready, cannot addSlotObject');
325
- return;
326
- }
327
- if (!this._containerManager) {
328
- console.warn('ContainerManager is not available');
329
- return;
330
- }
331
- const container = this._containerManager.getContainer(gameObject.id);
332
- if (!container) {
333
- this._pendingSlotObjects.push({
334
- slot,
335
- gameObject,
336
- options
337
- });
338
- return;
339
- }
340
- this._doAddSlotObject(slot, gameObject, container, options);
341
- }
342
- _doAddSlotObject(slot, gameObject, container, options) {
343
- const wrapper = new pixi_js.Container();
344
- wrapper.addChild(container);
345
- this.armature.addSlotObject(slot, wrapper, options);
346
- this._slotGameObjects.set(gameObject, {
347
- slot,
348
- wrapper
349
- });
350
- this._syncTransformTree(gameObject);
351
- }
352
- _syncTransformTree(gameObject) {
353
- var _a;
354
- if (!this._containerManager) return;
355
- this._containerManager.updateTransform({
356
- name: gameObject.id,
357
- transform: gameObject.transform
358
- });
359
- if ((_a = gameObject.transform) === null || _a === void 0 ? void 0 : _a.children) {
360
- for (const childTransform of gameObject.transform.children) {
361
- if (childTransform.gameObject) {
362
- this._syncTransformTree(childTransform.gameObject);
363
- }
364
- }
365
- }
366
- }
367
- _flushPendingSlotObjects() {
368
- if (this._pendingSlotObjects.length === 0) return;
369
- if (!this.armature || !this._containerManager) return;
370
- const still = [];
371
- for (const pending of this._pendingSlotObjects) {
372
- const container = this._containerManager.getContainer(pending.gameObject.id);
373
- if (container) {
374
- this._doAddSlotObject(pending.slot, pending.gameObject, container, pending.options);
375
- } else {
376
- still.push(pending);
377
- }
378
- }
379
- this._pendingSlotObjects = still;
380
- }
381
- removeSlotObject(gameObject) {
382
- this._pendingSlotObjects = this._pendingSlotObjects.filter(p => p.gameObject !== gameObject);
383
- const entry = this._slotGameObjects.get(gameObject);
384
- if (entry && this.armature) {
385
- this.armature.removeSlotObject(entry.wrapper);
386
- entry.wrapper.destroy({
387
- children: false
388
- });
389
- }
390
- this._slotGameObjects.delete(gameObject);
391
- }
392
- _destroySlotGameObjects() {
393
- for (const [gameObject, entry] of this._slotGameObjects) {
394
- if (!gameObject.destroyed) {
395
- if (this.armature) {
396
- this.armature.removeSlotObject(entry.wrapper);
397
- }
398
- entry.wrapper.destroy({
399
- children: false
400
- });
401
- gameObject.destroy();
402
- }
403
- }
404
- this._slotGameObjects.clear();
405
- this._pendingSlotObjects = [];
406
- }
407
- }
408
- Spine.componentName = 'Spine';
409
- __decorate([type('string'), __metadata("design:type", String)], Spine.prototype, "resource", void 0);
410
- __decorate([type('number'), __metadata("design:type", Number)], Spine.prototype, "scale", void 0);
411
- __decorate([type('string'), __metadata("design:type", String)], Spine.prototype, "animationName", void 0);
412
- __decorate([type('boolean'), __metadata("design:type", Boolean)], Spine.prototype, "autoPlay", void 0);
413
- __decorate([type('boolean'), __metadata("design:type", Boolean)], Spine.prototype, "keepResource", void 0);
414
- __decorate([type('number'), __metadata("design:type", Number)], Spine.prototype, "timeScale", void 0);
415
- __decorate([type('string'), __metadata("design:type", String)], Spine.prototype, "skin", void 0);
416
- let dataMap = {};
417
- function resolveImageSrc(image) {
418
- var _a, _b, _c, _d, _e;
419
- if (!image) return '';
420
- if (typeof image === 'string') return image;
421
- return image.label || ((_a = image.source) === null || _a === void 0 ? void 0 : _a.label) || ((_c = (_b = image.source) === null || _b === void 0 ? void 0 : _b.resource) === null || _c === void 0 ? void 0 : _c.src) || ((_d = image.source) === null || _d === void 0 ? void 0 : _d._sourceOrigin) || image.src || ((_e = image.baseTexture) === null || _e === void 0 ? void 0 : _e.cacheId) || '';
422
- }
423
- function createSpineData(name, data, scale, pixiSpine) {
424
- const skeletonAsset = data.ske;
425
- const atlasAsset = data.atlas;
426
- const attachmentLoader = new pixiSpine.AtlasAttachmentLoader(atlasAsset);
427
- const parser = skeletonAsset instanceof Uint8Array ? new pixiSpine.SkeletonBinary(attachmentLoader) : new pixiSpine.SkeletonJson(attachmentLoader);
428
- parser.scale = scale || 1;
429
- const skeletonData = parser.readSkeletonData(skeletonAsset);
430
- const obj = {
431
- spineData: skeletonData,
432
- ref: 0,
433
- imageSrc: resolveImageSrc(data.image)
434
- };
435
- dataMap[name] = obj;
436
- return obj;
437
- }
438
- function getSpineData(res, scale, pixiSpine) {
439
- return __awaiter(this, void 0, void 0, function* () {
440
- let data = dataMap[res.name];
441
- if (!data) {
442
- if (res.complete) {
443
- data = createSpineData(res.name, res.data, scale, pixiSpine);
444
- } else if (!data) {
445
- return;
446
- }
447
- }
448
- data.ref++;
449
- return data.spineData;
450
- });
451
- }
452
- function releaseSpineData(res, _imageSrc) {
453
- const resourceName = res.name;
454
- const data = dataMap[resourceName];
455
- if (!data) {
456
- return;
457
- }
458
- data.ref--;
459
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
460
- if (data.ref <= 0) {
461
- eva_js.resource.destroy(resourceName);
462
- delete dataMap[resourceName];
463
- }
464
- }), 100);
465
- }
466
- const MaxRetryCount = 20;
467
- let SpineSystem = class SpineSystem extends pluginRenderer.Renderer {
468
- constructor() {
469
- super(...arguments);
470
- this.armatures = {};
471
- this._spineComponents = {};
472
- }
473
- init({
474
- pixiSpine
475
- }) {
476
- this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
477
- this.renderSystem.rendererManager.register(this);
478
- this.pixiSpine = pixiSpine;
479
- this.game.canvas.addEventListener('webglcontextrestored', () => {
480
- const objs = this.game.gameObjects;
481
- let toAdd = [];
482
- for (let k in this.armatures) {
483
- const id = +k;
484
- for (let i = 0; i < objs.length; ++i) {
485
- let obj = objs[i];
486
- if (obj.id === id) {
487
- let sp = obj.getComponent(Spine);
488
- if (sp) {
489
- this.remove({
490
- type: eva_js.OBSERVER_TYPE.REMOVE,
491
- gameObject: obj,
492
- component: sp,
493
- componentName: Spine.componentName
494
- });
495
- toAdd.push({
496
- type: eva_js.OBSERVER_TYPE.ADD,
497
- gameObject: obj,
498
- component: sp,
499
- componentName: Spine.componentName
500
- });
501
- }
502
- break;
503
- }
504
- }
505
- }
506
- setTimeout(() => {
507
- toAdd.forEach(obj => {
508
- this.add(obj);
509
- });
510
- }, 1000);
511
- }, false);
512
- }
513
- update(e) {
514
- super.update();
515
- for (let key in this.armatures) {
516
- const armature = this.armatures[key];
517
- const component = this._spineComponents[key];
518
- if (!armature || armature.destroyed || (component === null || component === void 0 ? void 0 : component.destroied)) {
519
- delete this.armatures[key];
520
- delete this._spineComponents[key];
521
- continue;
522
- }
523
- armature.update(e.deltaTime * 0.001);
524
- }
525
- for (let key in this._spineComponents) {
526
- const component = this._spineComponents[key];
527
- if (!component || component.destroied) {
528
- delete this._spineComponents[key];
529
- continue;
530
- }
531
- component._flushPendingSlotObjects();
532
- }
533
- }
534
- componentChanged(changed) {
535
- return __awaiter(this, void 0, void 0, function* () {
536
- if (changed.componentName === 'Spine') {
537
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
538
- this.add(changed);
539
- } else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
540
- switch (changed.prop.prop[0]) {
541
- case 'resource':
542
- this.change(changed);
543
- break;
544
- }
545
- } else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
546
- this.remove(changed);
547
- }
548
- }
549
- });
550
- }
551
- add(changed, count) {
552
- var _a, _b, _c;
553
- return __awaiter(this, void 0, void 0, function* () {
554
- const component = changed.component;
555
- clearTimeout(component.addHandler);
556
- const gameObjectId = changed.gameObject.id;
557
- const asyncId = this.increaseAsyncId(gameObjectId);
558
- const res = yield eva_js.resource.getResource(component.resource);
559
- if (!this.validateAsyncId(gameObjectId, asyncId) || component.destroied || changed.gameObject.destroyed) return;
560
- const spineData = yield getSpineData(res, component.scale, this.pixiSpine);
561
- if (!this.validateAsyncId(gameObjectId, asyncId) || component.destroied || changed.gameObject.destroyed) return;
562
- if (!spineData) {
563
- component.addHandler = setTimeout(() => {
564
- if (!component.destroied && !changed.gameObject.destroyed) {
565
- if (count === undefined) {
566
- count = MaxRetryCount;
567
- }
568
- count--;
569
- if (count > 0) {
570
- this.add(changed, count);
571
- } else {
572
- console.log('retry exceed max times', component.resource);
573
- }
574
- }
575
- }, 1000);
576
- return;
577
- }
578
- this.remove(changed);
579
- 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);
580
- if (!container || component.destroied || changed.gameObject.destroyed) {
581
- return;
582
- }
583
- component.lastResource = component.resource;
584
- const armature = new this.pixiSpine.Spine({
585
- skeletonData: spineData,
586
- autoUpdate: false
587
- });
588
- this.armatures[changed.gameObject.id] = armature;
589
- this._spineComponents[changed.gameObject.id] = component;
590
- if (changed.gameObject && changed.gameObject.transform) {
591
- const tran = changed.gameObject.transform;
592
- armature.x = tran.size.width * tran.origin.x;
593
- armature.y = tran.size.height * tran.origin.y;
594
- }
595
- container.addChildAt(armature, 0);
596
- armature.update();
597
- component._containerManager = (_c = this.renderSystem) === null || _c === void 0 ? void 0 : _c.containerManager;
598
- component.armature = armature;
599
- component.emit('loaded', {
600
- resource: component.resource
601
- });
602
- armature.state.addListener({
603
- start: (track, event) => {
604
- component.emit('start', {
605
- track,
606
- name: track.animation.name
607
- });
608
- },
609
- complete: (track, event) => {
610
- component.emit('complete', {
611
- track,
612
- name: track.animation.name
613
- });
614
- },
615
- interrupt: (track, event) => {
616
- component.emit('interrupt', {
617
- track,
618
- name: track.animation.name
619
- });
620
- },
621
- end: (track, event) => {
622
- component.emit('end', {
623
- track,
624
- name: track.animation.name
625
- });
626
- },
627
- event: (track, event) => {
628
- component.emit('event', track, event);
629
- }
630
- });
631
- });
632
- }
633
- change(changed) {
634
- this.remove(changed);
635
- this.add(changed);
636
- }
637
- remove(changed) {
638
- var _a, _b, _c, _d, _e, _f;
639
- return __awaiter(this, void 0, void 0, function* () {
640
- const gameObjectId = changed.gameObject.id;
641
- this.increaseAsyncId(gameObjectId);
642
- const component = changed.component;
643
- clearTimeout(component.addHandler);
644
- const armature = this.armatures[gameObjectId];
645
- const container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(gameObjectId);
646
- if (container && armature) {
647
- container.removeChild(armature);
648
- }
649
- const componentArmature = component.armature;
650
- component.armature = null;
651
- delete this.armatures[gameObjectId];
652
- delete this._spineComponents[gameObjectId];
653
- if (componentArmature) {
654
- component._destroySlotGameObjects();
655
- if (!componentArmature.destroyed) {
656
- componentArmature.destroy({
657
- children: true
658
- });
659
- }
660
- if (!component.keepResource && component.lastResource) {
661
- try {
662
- const res = yield eva_js.resource.getResource(component.lastResource);
663
- const imageSrc = ((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src) || ((_f = (_e = res.data) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.label);
664
- releaseSpineData(res, imageSrc);
665
- } catch (error) {
666
- console.warn('Failed to release Spine resource', component.lastResource, error);
667
- }
668
- }
669
- }
670
- if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
671
- });
672
- }
673
- };
674
- SpineSystem.systemName = 'SpineSystem';
675
- SpineSystem = __decorate([eva_js.decorators.componentObserver({
676
- Spine: ['resource']
677
- })], SpineSystem);
678
- var SpineSystem$1 = SpineSystem;
679
- eva_js.resource.registerResourceType('SPINE');
680
- exports.Spine = Spine;
681
- exports.SpineSystem = SpineSystem$1;
682
- Object.defineProperty(exports, '__esModule', {
683
- value: true
684
- });
685
- return exports;
686
- }({}, EVA, EVA.plugin.renderer, PIXI);
687
- globalThis.EVA.plugin.spineBase = globalThis.EVA.plugin.spineBase || _EVA_IIFE_spineBase;