@eva/plugin-renderer-spine 1.2.2-alpha.4 → 1.2.2-alpha.5
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.
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var spineBase = require('@eva/spine-base');
|
|
5
6
|
var pixi_js = require('pixi.js');
|
|
6
|
-
var eva_js = require('@eva/eva.js');
|
|
7
|
-
var pluginRenderer = require('@eva/plugin-renderer');
|
|
8
|
-
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
9
7
|
|
|
10
8
|
/*! *****************************************************************************
|
|
11
9
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -34,506 +32,8 @@ function __extends$1(d, b) {
|
|
|
34
32
|
extendStatics(d, b);
|
|
35
33
|
function __() { this.constructor = d; }
|
|
36
34
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function __decorate(decorators, target, key, desc) {
|
|
40
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
42
|
-
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;
|
|
43
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
47
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
49
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
50
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
51
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
52
|
-
});
|
|
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
35
|
}
|
|
93
36
|
|
|
94
|
-
var Spine$2 = (function (_super) {
|
|
95
|
-
__extends$1(Spine, _super);
|
|
96
|
-
function Spine() {
|
|
97
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
98
|
-
_this.resource = '';
|
|
99
|
-
_this.animationName = '';
|
|
100
|
-
_this.autoPlay = true;
|
|
101
|
-
_this.waitExecuteInfos = [];
|
|
102
|
-
return _this;
|
|
103
|
-
}
|
|
104
|
-
Object.defineProperty(Spine.prototype, "armature", {
|
|
105
|
-
get: function () {
|
|
106
|
-
return this._armature;
|
|
107
|
-
},
|
|
108
|
-
set: function (val) {
|
|
109
|
-
var e_1, _a;
|
|
110
|
-
this._armature = val;
|
|
111
|
-
if (!val)
|
|
112
|
-
return;
|
|
113
|
-
if (this.autoPlay) {
|
|
114
|
-
this.play(this.animationName);
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
118
|
-
var info = _c.value;
|
|
119
|
-
if (info.playType) {
|
|
120
|
-
var name_1 = info.name, loop = info.loop, track = info.track;
|
|
121
|
-
this.play(name_1, loop, track);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
this.stop(info.track);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
129
|
-
finally {
|
|
130
|
-
try {
|
|
131
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
132
|
-
}
|
|
133
|
-
finally { if (e_1) throw e_1.error; }
|
|
134
|
-
}
|
|
135
|
-
this.waitExecuteInfos = [];
|
|
136
|
-
},
|
|
137
|
-
enumerable: false,
|
|
138
|
-
configurable: true
|
|
139
|
-
});
|
|
140
|
-
Spine.prototype.init = function (obj) {
|
|
141
|
-
if (!obj)
|
|
142
|
-
return;
|
|
143
|
-
Object.assign(this, obj);
|
|
144
|
-
};
|
|
145
|
-
Spine.prototype.onDestroy = function () {
|
|
146
|
-
this.destroied = true;
|
|
147
|
-
};
|
|
148
|
-
Spine.prototype.play = function (name, loop, track) {
|
|
149
|
-
try {
|
|
150
|
-
if (name)
|
|
151
|
-
this.animationName = name;
|
|
152
|
-
if (!this.armature) {
|
|
153
|
-
this.waitExecuteInfos.push({
|
|
154
|
-
playType: true,
|
|
155
|
-
name: name,
|
|
156
|
-
loop: loop,
|
|
157
|
-
track: track
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
if (track === undefined) {
|
|
162
|
-
track = 0;
|
|
163
|
-
}
|
|
164
|
-
this.armature.state.setAnimation(track, this.animationName, loop);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
console.log(e);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
Spine.prototype.stop = function (track) {
|
|
172
|
-
if (!this.armature) {
|
|
173
|
-
this.waitExecuteInfos.push({
|
|
174
|
-
playType: false,
|
|
175
|
-
track: track
|
|
176
|
-
});
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (track === undefined) {
|
|
180
|
-
track = 0;
|
|
181
|
-
}
|
|
182
|
-
this.armature.state.setEmptyAnimation(track, 0);
|
|
183
|
-
};
|
|
184
|
-
Spine.prototype.addAnimation = function (name, delay, loop, track) {
|
|
185
|
-
try {
|
|
186
|
-
if (!this.armature) {
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
if (track === undefined) {
|
|
190
|
-
track = 0;
|
|
191
|
-
}
|
|
192
|
-
this.armature.state.addAnimation(track, name, loop, delay);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
console.log(e);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
Spine.prototype.setMix = function (from, to, duration) {
|
|
200
|
-
if (!this.armature) ;
|
|
201
|
-
else {
|
|
202
|
-
this.armature.stateData.setMix(from, to, duration);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
Spine.prototype.getAnim = function (track) {
|
|
206
|
-
if (track === void 0) { track = 0; }
|
|
207
|
-
try {
|
|
208
|
-
if (!this.armature) {
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
return this.armature.state.tracks[track].animation.name;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
catch (e) {
|
|
215
|
-
console.log(e);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
Spine.prototype.setDefaultMix = function (duration) {
|
|
219
|
-
if (!this.armature) ;
|
|
220
|
-
else {
|
|
221
|
-
this.armature.stateData.defaultMix = duration;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
Spine.prototype.setAttachment = function (slotName, attachmentName) {
|
|
225
|
-
if (!this.armature) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
this.armature.skeleton.setAttachment(slotName, attachmentName);
|
|
229
|
-
};
|
|
230
|
-
Spine.prototype.getBone = function (boneName) {
|
|
231
|
-
if (!this.armature) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
return this.armature.skeleton.findBone(boneName);
|
|
235
|
-
};
|
|
236
|
-
Spine.componentName = 'Spine';
|
|
237
|
-
__decorate([
|
|
238
|
-
inspectorDecorator.type('string')
|
|
239
|
-
], Spine.prototype, "resource", void 0);
|
|
240
|
-
__decorate([
|
|
241
|
-
inspectorDecorator.type('string')
|
|
242
|
-
], Spine.prototype, "animationName", void 0);
|
|
243
|
-
__decorate([
|
|
244
|
-
inspectorDecorator.type('boolean')
|
|
245
|
-
], Spine.prototype, "autoPlay", void 0);
|
|
246
|
-
return Spine;
|
|
247
|
-
}(eva_js.Component));
|
|
248
|
-
var SpineBase = Spine$2;
|
|
249
|
-
|
|
250
|
-
var texCache = {};
|
|
251
|
-
function cacheImage(data) {
|
|
252
|
-
var oldImg = data.image;
|
|
253
|
-
return {
|
|
254
|
-
tex: pixi_js.Texture.from(oldImg),
|
|
255
|
-
count: 0,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function retainTexture(name, data) {
|
|
259
|
-
var cache = texCache[name];
|
|
260
|
-
if (!cache) {
|
|
261
|
-
cache = cacheImage(data);
|
|
262
|
-
texCache[name] = cache;
|
|
263
|
-
}
|
|
264
|
-
cache.count++;
|
|
265
|
-
return cache.tex;
|
|
266
|
-
}
|
|
267
|
-
function getTexture(imageSrc, data) {
|
|
268
|
-
var cache = texCache[imageSrc];
|
|
269
|
-
if (!cache) {
|
|
270
|
-
cache = cacheImage(data);
|
|
271
|
-
texCache[imageSrc] = cache;
|
|
272
|
-
}
|
|
273
|
-
return cache.tex;
|
|
274
|
-
}
|
|
275
|
-
function releaseTexture(imageSrc) {
|
|
276
|
-
if (!imageSrc)
|
|
277
|
-
return;
|
|
278
|
-
setTimeout(function () {
|
|
279
|
-
var cache = texCache[imageSrc];
|
|
280
|
-
if (cache) {
|
|
281
|
-
cache.count--;
|
|
282
|
-
if (cache.count <= 0) {
|
|
283
|
-
if (cache.tex) {
|
|
284
|
-
cache.tex.destroy(true);
|
|
285
|
-
cache.tex = null;
|
|
286
|
-
}
|
|
287
|
-
delete texCache[imageSrc];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}, 100);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var dataMap = {};
|
|
294
|
-
function createSpineData(name, data, scale, pixiSpine) {
|
|
295
|
-
var spineData = null;
|
|
296
|
-
var img = getTexture(data.image.src, data);
|
|
297
|
-
new pixiSpine.core.TextureAtlas(data.atlas, function (line, callback) {
|
|
298
|
-
callback(img.baseTexture);
|
|
299
|
-
}, function (spineAtlas) {
|
|
300
|
-
if (spineAtlas) {
|
|
301
|
-
var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
|
|
302
|
-
var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
|
|
303
|
-
if (scale) {
|
|
304
|
-
spineJsonParser.scale = scale;
|
|
305
|
-
}
|
|
306
|
-
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
var obj = { spineData: spineData, ref: 0, imageSrc: data.image.src };
|
|
310
|
-
dataMap[name] = obj;
|
|
311
|
-
return obj;
|
|
312
|
-
}
|
|
313
|
-
function getSpineData(res, pixiSpine) {
|
|
314
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
-
var data;
|
|
316
|
-
return __generator(this, function (_a) {
|
|
317
|
-
data = dataMap[res.name];
|
|
318
|
-
if (!data) {
|
|
319
|
-
if (res.complete) {
|
|
320
|
-
data = createSpineData(res.name, res.data, res.scale, pixiSpine);
|
|
321
|
-
}
|
|
322
|
-
else if (!data) {
|
|
323
|
-
return [2];
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
retainTexture(res.data.image.src, res.data);
|
|
327
|
-
data.ref++;
|
|
328
|
-
return [2, data.spineData];
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
function releaseSpineData(resourceName, imageSrc) {
|
|
333
|
-
var data = dataMap[resourceName];
|
|
334
|
-
if (!data) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
data.ref--;
|
|
338
|
-
if (data.ref <= 0) {
|
|
339
|
-
releaseTexture(imageSrc);
|
|
340
|
-
delete dataMap[resourceName];
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
var MaxRetryCount = 20;
|
|
345
|
-
var SpineSystem$2 = (function (_super) {
|
|
346
|
-
__extends$1(SpineSystem, _super);
|
|
347
|
-
function SpineSystem() {
|
|
348
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
349
|
-
_this.armatures = {};
|
|
350
|
-
return _this;
|
|
351
|
-
}
|
|
352
|
-
SpineSystem.prototype.init = function (_a) {
|
|
353
|
-
var _this = this;
|
|
354
|
-
var pixiSpine = _a.pixiSpine;
|
|
355
|
-
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
356
|
-
this.renderSystem.rendererManager.register(this);
|
|
357
|
-
this.pixiSpine = pixiSpine;
|
|
358
|
-
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
359
|
-
var objs = _this.game.gameObjects;
|
|
360
|
-
var toAdd = [];
|
|
361
|
-
for (var k in _this.armatures) {
|
|
362
|
-
var id = +k;
|
|
363
|
-
for (var i = 0; i < objs.length; ++i) {
|
|
364
|
-
var obj = objs[i];
|
|
365
|
-
if (obj.id === id) {
|
|
366
|
-
var sp = obj.getComponent(SpineBase);
|
|
367
|
-
if (sp) {
|
|
368
|
-
_this.remove({
|
|
369
|
-
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
370
|
-
gameObject: obj,
|
|
371
|
-
component: sp,
|
|
372
|
-
componentName: SpineBase.componentName,
|
|
373
|
-
});
|
|
374
|
-
toAdd.push({
|
|
375
|
-
type: eva_js.OBSERVER_TYPE.ADD,
|
|
376
|
-
gameObject: obj,
|
|
377
|
-
component: sp,
|
|
378
|
-
componentName: SpineBase.componentName,
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
setTimeout(function () {
|
|
386
|
-
toAdd.forEach(function (obj) {
|
|
387
|
-
_this.add(obj);
|
|
388
|
-
});
|
|
389
|
-
}, 1000);
|
|
390
|
-
}, false);
|
|
391
|
-
};
|
|
392
|
-
SpineSystem.prototype.update = function (e) {
|
|
393
|
-
for (var key in this.armatures) {
|
|
394
|
-
this.armatures[key].update(e.deltaTime * 0.001);
|
|
395
|
-
this.armatures[key].updateTransform();
|
|
396
|
-
}
|
|
397
|
-
_super.prototype.update.call(this);
|
|
398
|
-
};
|
|
399
|
-
SpineSystem.prototype.componentChanged = function (changed) {
|
|
400
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
-
return __generator(this, function (_a) {
|
|
402
|
-
if (changed.componentName === 'Spine') {
|
|
403
|
-
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
404
|
-
this.add(changed);
|
|
405
|
-
}
|
|
406
|
-
else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
407
|
-
switch (changed.prop.prop[0]) {
|
|
408
|
-
case 'resource':
|
|
409
|
-
this.change(changed);
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
414
|
-
this.remove(changed);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return [2];
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
SpineSystem.prototype.add = function (changed, count) {
|
|
422
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
423
|
-
var component, res, spineData, container, armature, tran;
|
|
424
|
-
var _this = this;
|
|
425
|
-
return __generator(this, function (_a) {
|
|
426
|
-
switch (_a.label) {
|
|
427
|
-
case 0:
|
|
428
|
-
component = changed.component;
|
|
429
|
-
clearTimeout(component.addHandler);
|
|
430
|
-
return [4, eva_js.resource.getResource(component.resource)];
|
|
431
|
-
case 1:
|
|
432
|
-
res = _a.sent();
|
|
433
|
-
return [4, getSpineData(res, this.pixiSpine)];
|
|
434
|
-
case 2:
|
|
435
|
-
spineData = _a.sent();
|
|
436
|
-
if (!spineData) {
|
|
437
|
-
component.addHandler = setTimeout(function () {
|
|
438
|
-
if (!component.destroied) {
|
|
439
|
-
if (count === undefined) {
|
|
440
|
-
count = MaxRetryCount;
|
|
441
|
-
}
|
|
442
|
-
count--;
|
|
443
|
-
if (count > 0) {
|
|
444
|
-
_this.add(changed, count);
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
console.log('retry exceed max times', component.resource);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}, 1000);
|
|
451
|
-
return [2];
|
|
452
|
-
}
|
|
453
|
-
this.remove(changed);
|
|
454
|
-
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
455
|
-
if (!container) {
|
|
456
|
-
return [2];
|
|
457
|
-
}
|
|
458
|
-
component.lastResource = component.resource;
|
|
459
|
-
armature = new this.pixiSpine.Spine(spineData);
|
|
460
|
-
this.armatures[changed.gameObject.id] = armature;
|
|
461
|
-
if (changed.gameObject && changed.gameObject.transform) {
|
|
462
|
-
tran = changed.gameObject.transform;
|
|
463
|
-
armature.x = tran.size.width * tran.origin.x;
|
|
464
|
-
armature.y = tran.size.height * tran.origin.y;
|
|
465
|
-
}
|
|
466
|
-
container.addChildAt(armature, 0);
|
|
467
|
-
armature.update();
|
|
468
|
-
armature.updateTransform();
|
|
469
|
-
component.armature = armature;
|
|
470
|
-
component.emit('loaded', { resource: component.resource });
|
|
471
|
-
armature.state.addListener({
|
|
472
|
-
start: function (track, event) {
|
|
473
|
-
component.emit('start', { track: track, name: track.animation.name });
|
|
474
|
-
},
|
|
475
|
-
complete: function (track, event) {
|
|
476
|
-
component.emit('complete', { track: track, name: track.animation.name });
|
|
477
|
-
},
|
|
478
|
-
interrupt: function (track, event) {
|
|
479
|
-
component.emit('interrupt', { track: track, name: track.animation.name });
|
|
480
|
-
},
|
|
481
|
-
end: function (track, event) {
|
|
482
|
-
component.emit('end', { track: track, name: track.animation.name });
|
|
483
|
-
},
|
|
484
|
-
event: function (track, event) {
|
|
485
|
-
component.emit('event', track, event);
|
|
486
|
-
},
|
|
487
|
-
});
|
|
488
|
-
return [2];
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
};
|
|
493
|
-
SpineSystem.prototype.change = function (changed) {
|
|
494
|
-
this.remove(changed);
|
|
495
|
-
this.add(changed);
|
|
496
|
-
};
|
|
497
|
-
SpineSystem.prototype.remove = function (changed) {
|
|
498
|
-
var _a, _b;
|
|
499
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
500
|
-
var component, armature, container, res;
|
|
501
|
-
return __generator(this, function (_c) {
|
|
502
|
-
switch (_c.label) {
|
|
503
|
-
case 0:
|
|
504
|
-
component = changed.component;
|
|
505
|
-
clearTimeout(component.addHandler);
|
|
506
|
-
armature = this.armatures[changed.gameObject.id];
|
|
507
|
-
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
508
|
-
if (container && armature) {
|
|
509
|
-
container.removeChild(armature);
|
|
510
|
-
}
|
|
511
|
-
if (!component.armature) return [3, 2];
|
|
512
|
-
component.armature.destroy({ children: true });
|
|
513
|
-
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
514
|
-
case 1:
|
|
515
|
-
res = _c.sent();
|
|
516
|
-
releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
|
|
517
|
-
_c.label = 2;
|
|
518
|
-
case 2:
|
|
519
|
-
component.armature = null;
|
|
520
|
-
delete this.armatures[changed.gameObject.id];
|
|
521
|
-
if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
|
|
522
|
-
return [2];
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
};
|
|
527
|
-
SpineSystem.systemName = 'SpineSystem';
|
|
528
|
-
SpineSystem = __decorate([
|
|
529
|
-
eva_js.decorators.componentObserver({
|
|
530
|
-
Spine: ['resource'],
|
|
531
|
-
})
|
|
532
|
-
], SpineSystem);
|
|
533
|
-
return SpineSystem;
|
|
534
|
-
}(pluginRenderer.Renderer));
|
|
535
|
-
var SpineSystemBase = SpineSystem$2;
|
|
536
|
-
|
|
537
37
|
// https://github.com/pixijs/spine/tree/pixi4
|
|
538
38
|
|
|
539
39
|
var VERSION = '4.8.9';
|
|
@@ -8185,7 +7685,7 @@ var SpineSystem = (function (_super) {
|
|
|
8185
7685
|
_super.prototype.init.call(this, { pixiSpine: pixiSpine });
|
|
8186
7686
|
};
|
|
8187
7687
|
return SpineSystem;
|
|
8188
|
-
}(
|
|
7688
|
+
}(spineBase.SpineSystem));
|
|
8189
7689
|
var SpineSystem$1 = SpineSystem;
|
|
8190
7690
|
|
|
8191
7691
|
var Spine = (function (_super) {
|
|
@@ -8194,7 +7694,7 @@ var Spine = (function (_super) {
|
|
|
8194
7694
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
8195
7695
|
}
|
|
8196
7696
|
return Spine;
|
|
8197
|
-
}(
|
|
7697
|
+
}(spineBase.Spine));
|
|
8198
7698
|
var Spine$1 = Spine;
|
|
8199
7699
|
|
|
8200
7700
|
exports.Spine = Spine$1;
|