@eva/spine-base 2.0.0-beta.1 → 2.0.0-beta.11
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
package/dist/spine-base.cjs.js
CHANGED
|
@@ -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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.play(
|
|
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
|
-
|
|
130
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
75
|
+
}
|
|
76
|
+
onDestroy() {
|
|
147
77
|
this.destroied = true;
|
|
148
|
-
}
|
|
149
|
-
|
|
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
|
|
86
|
+
name,
|
|
157
87
|
loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
|
|
158
|
-
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
|
-
|
|
101
|
+
}
|
|
102
|
+
stop(track) {
|
|
173
103
|
if (!this.armature) {
|
|
174
104
|
this.waitExecuteInfos.push({
|
|
175
105
|
playType: false,
|
|
176
|
-
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
+
}
|
|
148
|
+
setDefaultMix(duration) {
|
|
220
149
|
if (!this.armature) ;
|
|
221
150
|
else {
|
|
222
151
|
this.armature.stateData.defaultMix = duration;
|
|
223
152
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
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
|
-
|
|
159
|
+
}
|
|
160
|
+
getBone(boneName) {
|
|
232
161
|
if (!this.armature) {
|
|
233
162
|
return;
|
|
234
163
|
}
|
|
235
164
|
return this.armature.skeleton.findBone(boneName);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
181
|
+
let texCache = {};
|
|
255
182
|
function cacheImage(data) {
|
|
256
|
-
|
|
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
|
-
|
|
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(
|
|
275
|
-
|
|
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
|
-
|
|
216
|
+
let dataMap = {};
|
|
290
217
|
function createSpineData(name, data, scale, pixiSpine) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
299
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
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',
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
for (
|
|
352
|
-
|
|
353
|
-
for (
|
|
354
|
-
|
|
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
|
-
|
|
276
|
+
let sp = obj.getComponent(Spine);
|
|
357
277
|
if (sp) {
|
|
358
|
-
|
|
278
|
+
this.remove({
|
|
359
279
|
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
360
280
|
gameObject: obj,
|
|
361
281
|
component: sp,
|
|
362
|
-
componentName: Spine
|
|
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
|
|
288
|
+
componentName: Spine.componentName,
|
|
369
289
|
});
|
|
370
290
|
}
|
|
371
291
|
break;
|
|
372
292
|
}
|
|
373
293
|
}
|
|
374
294
|
}
|
|
375
|
-
setTimeout(
|
|
376
|
-
toAdd.forEach(
|
|
377
|
-
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
toAdd.forEach(obj => {
|
|
297
|
+
this.add(obj);
|
|
378
298
|
});
|
|
379
299
|
}, 1000);
|
|
380
300
|
}, false);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
for (
|
|
301
|
+
}
|
|
302
|
+
update(e) {
|
|
303
|
+
for (let key in this.armatures) {
|
|
384
304
|
this.armatures[key].update(e.deltaTime * 0.001);
|
|
385
305
|
}
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
390
|
-
|
|
391
|
-
if (changed.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
407
|
-
|
|
321
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
322
|
+
this.remove(changed);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
408
325
|
});
|
|
409
|
-
}
|
|
410
|
-
|
|
326
|
+
}
|
|
327
|
+
add(changed, count) {
|
|
411
328
|
var _a, _b;
|
|
412
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return [2];
|
|
346
|
+
count--;
|
|
347
|
+
if (count > 0) {
|
|
348
|
+
this.add(changed, count);
|
|
453
349
|
}
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
-
|
|
395
|
+
}
|
|
396
|
+
change(changed) {
|
|
492
397
|
this.remove(changed);
|
|
493
398
|
this.add(changed);
|
|
494
|
-
}
|
|
495
|
-
|
|
399
|
+
}
|
|
400
|
+
remove(changed) {
|
|
496
401
|
var _a, _b, _c, _d;
|
|
497
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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
|
|
432
|
+
exports.Spine = Spine;
|
|
539
433
|
exports.SpineSystem = SpineSystem$1;
|