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