@eva/plugin-renderer-spine 1.2.2-alpha.0 → 1.2.2-alpha.4
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.renderer.spine.js +666 -581
- package/dist/EVA.plugin.renderer.spine.min.js +1 -1
- package/dist/miniprogram.js +8880 -0
- package/dist/plugin-renderer-spine.cjs.js +586 -523
- package/dist/plugin-renderer-spine.cjs.prod.js +1 -1
- package/dist/plugin-renderer-spine.d.ts +6 -43
- package/dist/plugin-renderer-spine.esm.js +589 -526
- package/package.json +4 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
window.EVA = window.EVA || {};
|
|
4
|
+
window.EVA.plugin = window.EVA.plugin || {};
|
|
5
|
+
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var _EVA_IIFE_spine = function (exports, pixi_js, eva_js, pluginRenderer) {
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
var _extendStatics = function extendStatics(d, b) {
|
|
@@ -184,6 +184,23 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
function __values(o) {
|
|
188
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
189
|
+
m = s && o[s],
|
|
190
|
+
i = 0;
|
|
191
|
+
if (m) return m.call(o);
|
|
192
|
+
if (o && typeof o.length === "number") return {
|
|
193
|
+
next: function next() {
|
|
194
|
+
if (o && i >= o.length) o = void 0;
|
|
195
|
+
return {
|
|
196
|
+
value: o && o[i++],
|
|
197
|
+
done: !o
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
202
|
+
}
|
|
203
|
+
|
|
187
204
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
188
205
|
if (!target.constructor.IDEProps) {
|
|
189
206
|
target.constructor.IDEProps = {};
|
|
@@ -205,7 +222,7 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
205
222
|
};
|
|
206
223
|
}
|
|
207
224
|
|
|
208
|
-
var Spine = function (_super) {
|
|
225
|
+
var Spine$2 = function (_super) {
|
|
209
226
|
__extends$1(Spine, _super);
|
|
210
227
|
|
|
211
228
|
function Spine() {
|
|
@@ -214,17 +231,59 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
214
231
|
_this.resource = '';
|
|
215
232
|
_this.animationName = '';
|
|
216
233
|
_this.autoPlay = true;
|
|
234
|
+
_this.waitExecuteInfos = [];
|
|
217
235
|
return _this;
|
|
218
236
|
}
|
|
219
237
|
|
|
238
|
+
Object.defineProperty(Spine.prototype, "armature", {
|
|
239
|
+
get: function get() {
|
|
240
|
+
return this._armature;
|
|
241
|
+
},
|
|
242
|
+
set: function set(val) {
|
|
243
|
+
var e_1, _a;
|
|
244
|
+
|
|
245
|
+
this._armature = val;
|
|
246
|
+
if (!val) return;
|
|
247
|
+
|
|
248
|
+
if (this.autoPlay) {
|
|
249
|
+
this.play(this.animationName);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
254
|
+
var info = _c.value;
|
|
255
|
+
|
|
256
|
+
if (info.playType) {
|
|
257
|
+
var name_1 = info.name,
|
|
258
|
+
loop = info.loop,
|
|
259
|
+
track = info.track;
|
|
260
|
+
this.play(name_1, loop, track);
|
|
261
|
+
} else {
|
|
262
|
+
this.stop(info.track);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} catch (e_1_1) {
|
|
266
|
+
e_1 = {
|
|
267
|
+
error: e_1_1
|
|
268
|
+
};
|
|
269
|
+
} finally {
|
|
270
|
+
try {
|
|
271
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
272
|
+
} finally {
|
|
273
|
+
if (e_1) throw e_1.error;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
this.waitExecuteInfos = [];
|
|
278
|
+
},
|
|
279
|
+
enumerable: false,
|
|
280
|
+
configurable: true
|
|
281
|
+
});
|
|
282
|
+
|
|
220
283
|
Spine.prototype.init = function (obj) {
|
|
221
284
|
if (!obj) return;
|
|
222
285
|
|
|
223
286
|
_extends(this, obj);
|
|
224
|
-
|
|
225
|
-
if (this.autoPlay) {
|
|
226
|
-
this.play(this.animationName);
|
|
227
|
-
}
|
|
228
287
|
};
|
|
229
288
|
|
|
230
289
|
Spine.prototype.onDestroy = function () {
|
|
@@ -235,7 +294,14 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
235
294
|
try {
|
|
236
295
|
if (name) this.animationName = name;
|
|
237
296
|
|
|
238
|
-
if (!this.armature) {
|
|
297
|
+
if (!this.armature) {
|
|
298
|
+
this.waitExecuteInfos.push({
|
|
299
|
+
playType: true,
|
|
300
|
+
name: name,
|
|
301
|
+
loop: loop,
|
|
302
|
+
track: track
|
|
303
|
+
});
|
|
304
|
+
} else {
|
|
239
305
|
if (track === undefined) {
|
|
240
306
|
track = 0;
|
|
241
307
|
}
|
|
@@ -249,6 +315,10 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
249
315
|
|
|
250
316
|
Spine.prototype.stop = function (track) {
|
|
251
317
|
if (!this.armature) {
|
|
318
|
+
this.waitExecuteInfos.push({
|
|
319
|
+
playType: false,
|
|
320
|
+
track: track
|
|
321
|
+
});
|
|
252
322
|
return;
|
|
253
323
|
}
|
|
254
324
|
|
|
@@ -326,169 +396,527 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
326
396
|
return Spine;
|
|
327
397
|
}(eva_js.Component);
|
|
328
398
|
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var loader = pixi_js.loaders.shared;
|
|
332
|
-
var PIXI = {
|
|
333
|
-
Texture: pixi_js.Texture,
|
|
334
|
-
Rectangle: pixi_js.Rectangle,
|
|
335
|
-
Sprite: pixi_js.Sprite,
|
|
336
|
-
Graphics: pixi_js.Graphics,
|
|
337
|
-
mesh: pixi_js.mesh,
|
|
338
|
-
Matrix: pixi_js.Matrix,
|
|
339
|
-
Container: pixi_js.Container,
|
|
340
|
-
VERSION: VERSION,
|
|
341
|
-
loaders: pixi_js.loaders,
|
|
342
|
-
loader: loader,
|
|
343
|
-
SCALE_MODES: pixi_js.SCALE_MODES,
|
|
344
|
-
utils: pixi_js.utils,
|
|
345
|
-
TransformBase: pixi_js.TransformBase,
|
|
346
|
-
TransformStatic: pixi_js.TransformStatic,
|
|
347
|
-
DisplayObject: pixi_js.DisplayObject,
|
|
348
|
-
Polygon: pixi_js.Polygon,
|
|
349
|
-
BaseTexture: pixi_js.BaseTexture
|
|
350
|
-
};
|
|
399
|
+
var SpineBase = Spine$2;
|
|
400
|
+
var texCache = {};
|
|
351
401
|
|
|
352
|
-
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
} || function (d, b) {
|
|
358
|
-
for (var p in b) {
|
|
359
|
-
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
360
|
-
}
|
|
402
|
+
function cacheImage(data) {
|
|
403
|
+
var oldImg = data.image;
|
|
404
|
+
return {
|
|
405
|
+
tex: pixi_js.Texture.from(oldImg),
|
|
406
|
+
count: 0
|
|
361
407
|
};
|
|
408
|
+
}
|
|
362
409
|
|
|
363
|
-
|
|
364
|
-
|
|
410
|
+
function retainTexture(name, data) {
|
|
411
|
+
var cache = texCache[name];
|
|
365
412
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
413
|
+
if (!cache) {
|
|
414
|
+
cache = cacheImage(data);
|
|
415
|
+
texCache[name] = cache;
|
|
416
|
+
}
|
|
369
417
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
418
|
+
cache.count++;
|
|
419
|
+
return cache.tex;
|
|
420
|
+
}
|
|
373
421
|
|
|
374
|
-
|
|
422
|
+
function getTexture(imageSrc, data) {
|
|
423
|
+
var cache = texCache[imageSrc];
|
|
375
424
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (name == null) throw new Error('name cannot be null.');
|
|
381
|
-
if (timelines == null) throw new Error('timelines cannot be null.');
|
|
382
|
-
this.name = name;
|
|
383
|
-
this.timelines = timelines;
|
|
384
|
-
this.duration = duration;
|
|
385
|
-
}
|
|
425
|
+
if (!cache) {
|
|
426
|
+
cache = cacheImage(data);
|
|
427
|
+
texCache[imageSrc] = cache;
|
|
428
|
+
}
|
|
386
429
|
|
|
387
|
-
|
|
388
|
-
|
|
430
|
+
return cache.tex;
|
|
431
|
+
}
|
|
389
432
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
433
|
+
function releaseTexture(imageSrc) {
|
|
434
|
+
if (!imageSrc) return;
|
|
435
|
+
setTimeout(function () {
|
|
436
|
+
var cache = texCache[imageSrc];
|
|
394
437
|
|
|
395
|
-
|
|
438
|
+
if (cache) {
|
|
439
|
+
cache.count--;
|
|
396
440
|
|
|
397
|
-
|
|
398
|
-
|
|
441
|
+
if (cache.count <= 0) {
|
|
442
|
+
if (cache.tex) {
|
|
443
|
+
cache.tex.destroy(true);
|
|
444
|
+
cache.tex = null;
|
|
399
445
|
}
|
|
400
|
-
};
|
|
401
446
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
447
|
+
delete texCache[imageSrc];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}, 100);
|
|
451
|
+
}
|
|
406
452
|
|
|
407
|
-
|
|
408
|
-
var high = values.length / step - 2;
|
|
409
|
-
if (high == 0) return step;
|
|
410
|
-
var current = high >>> 1;
|
|
453
|
+
var dataMap = {};
|
|
411
454
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
455
|
+
function createSpineData(name, data, scale, pixiSpine) {
|
|
456
|
+
var spineData = null;
|
|
457
|
+
var img = getTexture(data.image.src, data);
|
|
458
|
+
new pixiSpine.core.TextureAtlas(data.atlas, function (line, callback) {
|
|
459
|
+
callback(img.baseTexture);
|
|
460
|
+
}, function (spineAtlas) {
|
|
461
|
+
if (spineAtlas) {
|
|
462
|
+
var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
|
|
463
|
+
var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
|
|
418
464
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
465
|
+
if (scale) {
|
|
466
|
+
spineJsonParser.scale = scale;
|
|
467
|
+
}
|
|
423
468
|
|
|
424
|
-
|
|
425
|
-
|
|
469
|
+
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
var obj = {
|
|
473
|
+
spineData: spineData,
|
|
474
|
+
ref: 0,
|
|
475
|
+
imageSrc: data.image.src
|
|
476
|
+
};
|
|
477
|
+
dataMap[name] = obj;
|
|
478
|
+
return obj;
|
|
479
|
+
}
|
|
426
480
|
|
|
427
|
-
|
|
428
|
-
|
|
481
|
+
function getSpineData(res, pixiSpine) {
|
|
482
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
483
|
+
var data;
|
|
484
|
+
return __generator(this, function (_a) {
|
|
485
|
+
data = dataMap[res.name];
|
|
429
486
|
|
|
430
|
-
|
|
431
|
-
|
|
487
|
+
if (!data) {
|
|
488
|
+
if (res.complete) {
|
|
489
|
+
data = createSpineData(res.name, res.data, res.scale, pixiSpine);
|
|
490
|
+
} else if (!data) {
|
|
491
|
+
return [2];
|
|
492
|
+
}
|
|
493
|
+
}
|
|
432
494
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
495
|
+
retainTexture(res.data.image.src, res.data);
|
|
496
|
+
data.ref++;
|
|
497
|
+
return [2, data.spineData];
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
439
501
|
|
|
440
|
-
|
|
502
|
+
function releaseSpineData(resourceName, imageSrc) {
|
|
503
|
+
var data = dataMap[resourceName];
|
|
441
504
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
})(MixDirection = core.MixDirection || (core.MixDirection = {}));
|
|
505
|
+
if (!data) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
446
508
|
|
|
447
|
-
|
|
509
|
+
data.ref--;
|
|
448
510
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
TimelineType[TimelineType['attachment'] = 4] = 'attachment';
|
|
455
|
-
TimelineType[TimelineType['color'] = 5] = 'color';
|
|
456
|
-
TimelineType[TimelineType['deform'] = 6] = 'deform';
|
|
457
|
-
TimelineType[TimelineType['event'] = 7] = 'event';
|
|
458
|
-
TimelineType[TimelineType['drawOrder'] = 8] = 'drawOrder';
|
|
459
|
-
TimelineType[TimelineType['ikConstraint'] = 9] = 'ikConstraint';
|
|
460
|
-
TimelineType[TimelineType['transformConstraint'] = 10] = 'transformConstraint';
|
|
461
|
-
TimelineType[TimelineType['pathConstraintPosition'] = 11] = 'pathConstraintPosition';
|
|
462
|
-
TimelineType[TimelineType['pathConstraintSpacing'] = 12] = 'pathConstraintSpacing';
|
|
463
|
-
TimelineType[TimelineType['pathConstraintMix'] = 13] = 'pathConstraintMix';
|
|
464
|
-
TimelineType[TimelineType['twoColor'] = 14] = 'twoColor';
|
|
465
|
-
})(TimelineType = core.TimelineType || (core.TimelineType = {}));
|
|
511
|
+
if (data.ref <= 0) {
|
|
512
|
+
releaseTexture(imageSrc);
|
|
513
|
+
delete dataMap[resourceName];
|
|
514
|
+
}
|
|
515
|
+
}
|
|
466
516
|
|
|
467
|
-
|
|
468
|
-
function CurveTimeline(frameCount) {
|
|
469
|
-
if (frameCount <= 0) throw new Error('frameCount must be > 0: ' + frameCount);
|
|
470
|
-
this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
|
|
471
|
-
}
|
|
517
|
+
var MaxRetryCount = 20;
|
|
472
518
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
};
|
|
519
|
+
var SpineSystem$2 = function (_super) {
|
|
520
|
+
__extends$1(SpineSystem, _super);
|
|
476
521
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
};
|
|
522
|
+
function SpineSystem() {
|
|
523
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
480
524
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
525
|
+
_this.armatures = {};
|
|
526
|
+
return _this;
|
|
527
|
+
}
|
|
484
528
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
529
|
+
SpineSystem.prototype.init = function (_a) {
|
|
530
|
+
var _this = this;
|
|
531
|
+
|
|
532
|
+
var pixiSpine = _a.pixiSpine;
|
|
533
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
534
|
+
this.renderSystem.rendererManager.register(this);
|
|
535
|
+
this.pixiSpine = pixiSpine;
|
|
536
|
+
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
537
|
+
var objs = _this.game.gameObjects;
|
|
538
|
+
var toAdd = [];
|
|
539
|
+
|
|
540
|
+
for (var k in _this.armatures) {
|
|
541
|
+
var id = +k;
|
|
542
|
+
|
|
543
|
+
for (var i = 0; i < objs.length; ++i) {
|
|
544
|
+
var obj = objs[i];
|
|
545
|
+
|
|
546
|
+
if (obj.id === id) {
|
|
547
|
+
var sp = obj.getComponent(SpineBase);
|
|
548
|
+
|
|
549
|
+
if (sp) {
|
|
550
|
+
_this.remove({
|
|
551
|
+
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
552
|
+
gameObject: obj,
|
|
553
|
+
component: sp,
|
|
554
|
+
componentName: SpineBase.componentName
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
toAdd.push({
|
|
558
|
+
type: eva_js.OBSERVER_TYPE.ADD,
|
|
559
|
+
gameObject: obj,
|
|
560
|
+
component: sp,
|
|
561
|
+
componentName: SpineBase.componentName
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
setTimeout(function () {
|
|
571
|
+
toAdd.forEach(function (obj) {
|
|
572
|
+
_this.add(obj);
|
|
573
|
+
});
|
|
574
|
+
}, 1000);
|
|
575
|
+
}, false);
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
SpineSystem.prototype.update = function (e) {
|
|
579
|
+
for (var key in this.armatures) {
|
|
580
|
+
this.armatures[key].update(e.deltaTime * 0.001);
|
|
581
|
+
this.armatures[key].updateTransform();
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
_super.prototype.update.call(this);
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
SpineSystem.prototype.componentChanged = function (changed) {
|
|
588
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
589
|
+
return __generator(this, function (_a) {
|
|
590
|
+
if (changed.componentName === 'Spine') {
|
|
591
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
592
|
+
this.add(changed);
|
|
593
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
594
|
+
switch (changed.prop.prop[0]) {
|
|
595
|
+
case 'resource':
|
|
596
|
+
this.change(changed);
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
600
|
+
this.remove(changed);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return [2];
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
SpineSystem.prototype.add = function (changed, count) {
|
|
610
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
611
|
+
var component, res, spineData, container, armature, tran;
|
|
612
|
+
|
|
613
|
+
var _this = this;
|
|
614
|
+
|
|
615
|
+
return __generator(this, function (_a) {
|
|
616
|
+
switch (_a.label) {
|
|
617
|
+
case 0:
|
|
618
|
+
component = changed.component;
|
|
619
|
+
clearTimeout(component.addHandler);
|
|
620
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
621
|
+
|
|
622
|
+
case 1:
|
|
623
|
+
res = _a.sent();
|
|
624
|
+
return [4, getSpineData(res, this.pixiSpine)];
|
|
625
|
+
|
|
626
|
+
case 2:
|
|
627
|
+
spineData = _a.sent();
|
|
628
|
+
|
|
629
|
+
if (!spineData) {
|
|
630
|
+
component.addHandler = setTimeout(function () {
|
|
631
|
+
if (!component.destroied) {
|
|
632
|
+
if (count === undefined) {
|
|
633
|
+
count = MaxRetryCount;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
count--;
|
|
637
|
+
|
|
638
|
+
if (count > 0) {
|
|
639
|
+
_this.add(changed, count);
|
|
640
|
+
} else {
|
|
641
|
+
console.log('retry exceed max times', component.resource);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}, 1000);
|
|
645
|
+
return [2];
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
this.remove(changed);
|
|
649
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
650
|
+
|
|
651
|
+
if (!container) {
|
|
652
|
+
return [2];
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
component.lastResource = component.resource;
|
|
656
|
+
armature = new this.pixiSpine.Spine(spineData);
|
|
657
|
+
this.armatures[changed.gameObject.id] = armature;
|
|
658
|
+
|
|
659
|
+
if (changed.gameObject && changed.gameObject.transform) {
|
|
660
|
+
tran = changed.gameObject.transform;
|
|
661
|
+
armature.x = tran.size.width * tran.origin.x;
|
|
662
|
+
armature.y = tran.size.height * tran.origin.y;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
container.addChildAt(armature, 0);
|
|
666
|
+
armature.update();
|
|
667
|
+
armature.updateTransform();
|
|
668
|
+
component.armature = armature;
|
|
669
|
+
component.emit('loaded', {
|
|
670
|
+
resource: component.resource
|
|
671
|
+
});
|
|
672
|
+
armature.state.addListener({
|
|
673
|
+
start: function start(track, event) {
|
|
674
|
+
component.emit('start', {
|
|
675
|
+
track: track,
|
|
676
|
+
name: track.animation.name
|
|
677
|
+
});
|
|
678
|
+
},
|
|
679
|
+
complete: function complete(track, event) {
|
|
680
|
+
component.emit('complete', {
|
|
681
|
+
track: track,
|
|
682
|
+
name: track.animation.name
|
|
683
|
+
});
|
|
684
|
+
},
|
|
685
|
+
interrupt: function interrupt(track, event) {
|
|
686
|
+
component.emit('interrupt', {
|
|
687
|
+
track: track,
|
|
688
|
+
name: track.animation.name
|
|
689
|
+
});
|
|
690
|
+
},
|
|
691
|
+
end: function end(track, event) {
|
|
692
|
+
component.emit('end', {
|
|
693
|
+
track: track,
|
|
694
|
+
name: track.animation.name
|
|
695
|
+
});
|
|
696
|
+
},
|
|
697
|
+
event: function event(track, _event) {
|
|
698
|
+
component.emit('event', track, _event);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
return [2];
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
SpineSystem.prototype.change = function (changed) {
|
|
708
|
+
this.remove(changed);
|
|
709
|
+
this.add(changed);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
SpineSystem.prototype.remove = function (changed) {
|
|
713
|
+
var _a, _b;
|
|
714
|
+
|
|
715
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
716
|
+
var component, armature, container, res;
|
|
717
|
+
return __generator(this, function (_c) {
|
|
718
|
+
switch (_c.label) {
|
|
719
|
+
case 0:
|
|
720
|
+
component = changed.component;
|
|
721
|
+
clearTimeout(component.addHandler);
|
|
722
|
+
armature = this.armatures[changed.gameObject.id];
|
|
723
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
724
|
+
|
|
725
|
+
if (container && armature) {
|
|
726
|
+
container.removeChild(armature);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
if (!component.armature) return [3, 2];
|
|
730
|
+
component.armature.destroy({
|
|
731
|
+
children: true
|
|
732
|
+
});
|
|
733
|
+
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
734
|
+
|
|
735
|
+
case 1:
|
|
736
|
+
res = _c.sent();
|
|
737
|
+
releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
|
|
738
|
+
_c.label = 2;
|
|
739
|
+
|
|
740
|
+
case 2:
|
|
741
|
+
component.armature = null;
|
|
742
|
+
delete this.armatures[changed.gameObject.id];
|
|
743
|
+
if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
|
|
744
|
+
return [2];
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
SpineSystem.systemName = 'SpineSystem';
|
|
751
|
+
SpineSystem = __decorate([eva_js.decorators.componentObserver({
|
|
752
|
+
Spine: ['resource']
|
|
753
|
+
})], SpineSystem);
|
|
754
|
+
return SpineSystem;
|
|
755
|
+
}(pluginRenderer.Renderer);
|
|
756
|
+
|
|
757
|
+
var SpineSystemBase = SpineSystem$2;
|
|
758
|
+
var VERSION = '4.8.9';
|
|
759
|
+
var loader = pixi_js.loaders.shared;
|
|
760
|
+
var PIXI = {
|
|
761
|
+
Texture: pixi_js.Texture,
|
|
762
|
+
Rectangle: pixi_js.Rectangle,
|
|
763
|
+
Sprite: pixi_js.Sprite,
|
|
764
|
+
Graphics: pixi_js.Graphics,
|
|
765
|
+
mesh: pixi_js.mesh,
|
|
766
|
+
Matrix: pixi_js.Matrix,
|
|
767
|
+
Container: pixi_js.Container,
|
|
768
|
+
VERSION: VERSION,
|
|
769
|
+
loaders: pixi_js.loaders,
|
|
770
|
+
loader: loader,
|
|
771
|
+
SCALE_MODES: pixi_js.SCALE_MODES,
|
|
772
|
+
utils: pixi_js.utils,
|
|
773
|
+
TransformBase: pixi_js.TransformBase,
|
|
774
|
+
TransformStatic: pixi_js.TransformStatic,
|
|
775
|
+
DisplayObject: pixi_js.DisplayObject,
|
|
776
|
+
Polygon: pixi_js.Polygon,
|
|
777
|
+
BaseTexture: pixi_js.BaseTexture
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
var __extends = undefined && undefined.__extends || function () {
|
|
781
|
+
var extendStatics = Object.setPrototypeOf || {
|
|
782
|
+
__proto__: []
|
|
783
|
+
} instanceof Array && function (d, b) {
|
|
784
|
+
d.__proto__ = b;
|
|
785
|
+
} || function (d, b) {
|
|
786
|
+
for (var p in b) {
|
|
787
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
return function (d, b) {
|
|
792
|
+
extendStatics(d, b);
|
|
793
|
+
|
|
794
|
+
function __() {
|
|
795
|
+
this.constructor = d;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
799
|
+
};
|
|
800
|
+
}();
|
|
801
|
+
|
|
802
|
+
var pixi_spine;
|
|
803
|
+
|
|
804
|
+
(function (pixi_spine) {
|
|
805
|
+
(function (core) {
|
|
806
|
+
var Animation = function () {
|
|
807
|
+
function Animation(name, timelines, duration) {
|
|
808
|
+
if (name == null) throw new Error('name cannot be null.');
|
|
809
|
+
if (timelines == null) throw new Error('timelines cannot be null.');
|
|
810
|
+
this.name = name;
|
|
811
|
+
this.timelines = timelines;
|
|
812
|
+
this.duration = duration;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
|
|
816
|
+
if (skeleton == null) throw new Error('skeleton cannot be null.');
|
|
817
|
+
|
|
818
|
+
if (loop && this.duration != 0) {
|
|
819
|
+
time %= this.duration;
|
|
820
|
+
if (lastTime > 0) lastTime %= this.duration;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
var timelines = this.timelines;
|
|
824
|
+
|
|
825
|
+
for (var i = 0, n = timelines.length; i < n; i++) {
|
|
826
|
+
timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
Animation.binarySearch = function (values, target, step) {
|
|
831
|
+
if (step === void 0) {
|
|
832
|
+
step = 1;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
var low = 0;
|
|
836
|
+
var high = values.length / step - 2;
|
|
837
|
+
if (high == 0) return step;
|
|
838
|
+
var current = high >>> 1;
|
|
839
|
+
|
|
840
|
+
while (true) {
|
|
841
|
+
if (values[(current + 1) * step] <= target) low = current + 1;else high = current;
|
|
842
|
+
if (low == high) return (low + 1) * step;
|
|
843
|
+
current = low + high >>> 1;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
Animation.linearSearch = function (values, target, step) {
|
|
848
|
+
for (var i = 0, last = values.length - step; i <= last; i += step) {
|
|
849
|
+
if (values[i] > target) return i;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
return -1;
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
return Animation;
|
|
856
|
+
}();
|
|
857
|
+
|
|
858
|
+
core.Animation = Animation;
|
|
859
|
+
var MixBlend;
|
|
860
|
+
|
|
861
|
+
(function (MixBlend) {
|
|
862
|
+
MixBlend[MixBlend['setup'] = 0] = 'setup';
|
|
863
|
+
MixBlend[MixBlend['first'] = 1] = 'first';
|
|
864
|
+
MixBlend[MixBlend['replace'] = 2] = 'replace';
|
|
865
|
+
MixBlend[MixBlend['add'] = 3] = 'add';
|
|
866
|
+
})(MixBlend = core.MixBlend || (core.MixBlend = {}));
|
|
867
|
+
|
|
868
|
+
var MixDirection;
|
|
869
|
+
|
|
870
|
+
(function (MixDirection) {
|
|
871
|
+
MixDirection[MixDirection['in'] = 0] = 'in';
|
|
872
|
+
MixDirection[MixDirection['out'] = 1] = 'out';
|
|
873
|
+
})(MixDirection = core.MixDirection || (core.MixDirection = {}));
|
|
874
|
+
|
|
875
|
+
var TimelineType;
|
|
876
|
+
|
|
877
|
+
(function (TimelineType) {
|
|
878
|
+
TimelineType[TimelineType['rotate'] = 0] = 'rotate';
|
|
879
|
+
TimelineType[TimelineType['translate'] = 1] = 'translate';
|
|
880
|
+
TimelineType[TimelineType['scale'] = 2] = 'scale';
|
|
881
|
+
TimelineType[TimelineType['shear'] = 3] = 'shear';
|
|
882
|
+
TimelineType[TimelineType['attachment'] = 4] = 'attachment';
|
|
883
|
+
TimelineType[TimelineType['color'] = 5] = 'color';
|
|
884
|
+
TimelineType[TimelineType['deform'] = 6] = 'deform';
|
|
885
|
+
TimelineType[TimelineType['event'] = 7] = 'event';
|
|
886
|
+
TimelineType[TimelineType['drawOrder'] = 8] = 'drawOrder';
|
|
887
|
+
TimelineType[TimelineType['ikConstraint'] = 9] = 'ikConstraint';
|
|
888
|
+
TimelineType[TimelineType['transformConstraint'] = 10] = 'transformConstraint';
|
|
889
|
+
TimelineType[TimelineType['pathConstraintPosition'] = 11] = 'pathConstraintPosition';
|
|
890
|
+
TimelineType[TimelineType['pathConstraintSpacing'] = 12] = 'pathConstraintSpacing';
|
|
891
|
+
TimelineType[TimelineType['pathConstraintMix'] = 13] = 'pathConstraintMix';
|
|
892
|
+
TimelineType[TimelineType['twoColor'] = 14] = 'twoColor';
|
|
893
|
+
})(TimelineType = core.TimelineType || (core.TimelineType = {}));
|
|
894
|
+
|
|
895
|
+
var CurveTimeline = function () {
|
|
896
|
+
function CurveTimeline(frameCount) {
|
|
897
|
+
if (frameCount <= 0) throw new Error('frameCount must be > 0: ' + frameCount);
|
|
898
|
+
this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
CurveTimeline.prototype.getFrameCount = function () {
|
|
902
|
+
return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
CurveTimeline.prototype.setLinear = function (frameIndex) {
|
|
906
|
+
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
CurveTimeline.prototype.setStepped = function (frameIndex) {
|
|
910
|
+
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
CurveTimeline.prototype.getCurveType = function (frameIndex) {
|
|
914
|
+
var index = frameIndex * CurveTimeline.BEZIER_SIZE;
|
|
915
|
+
if (index == this.curves.length) return CurveTimeline.LINEAR;
|
|
916
|
+
var type = this.curves[index];
|
|
917
|
+
if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR;
|
|
918
|
+
if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED;
|
|
919
|
+
return CurveTimeline.BEZIER;
|
|
492
920
|
};
|
|
493
921
|
|
|
494
922
|
CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {
|
|
@@ -9080,478 +9508,135 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
9080
9508
|
|
|
9081
9509
|
var createSkeletonWithRawAtlas = function createSkeletonWithRawAtlas(rawData) {
|
|
9082
9510
|
new pixi_spine.core.TextureAtlas(rawData, adapter, function (spineAtlas) {
|
|
9083
|
-
if (spineAtlas) {
|
|
9084
|
-
var spineJsonParser = new pixi_spine.core.SkeletonJson(new pixi_spine.core.AtlasAttachmentLoader(spineAtlas));
|
|
9085
|
-
|
|
9086
|
-
if (metadataSkeletonScale) {
|
|
9087
|
-
spineJsonParser.scale = metadataSkeletonScale;
|
|
9088
|
-
}
|
|
9089
|
-
|
|
9090
|
-
resource.spineData = spineJsonParser.readSkeletonData(resource.data);
|
|
9091
|
-
resource.spineAtlas = spineAtlas;
|
|
9092
|
-
}
|
|
9093
|
-
|
|
9094
|
-
next();
|
|
9095
|
-
});
|
|
9096
|
-
};
|
|
9097
|
-
|
|
9098
|
-
if (resource.metadata && resource.metadata.atlasRawData) {
|
|
9099
|
-
createSkeletonWithRawAtlas(resource.metadata.atlasRawData);
|
|
9100
|
-
} else {
|
|
9101
|
-
this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) {
|
|
9102
|
-
if (!atlasResource.error) {
|
|
9103
|
-
createSkeletonWithRawAtlas(atlasResource.data);
|
|
9104
|
-
} else {
|
|
9105
|
-
next();
|
|
9106
|
-
}
|
|
9107
|
-
});
|
|
9108
|
-
}
|
|
9109
|
-
};
|
|
9110
|
-
}
|
|
9111
|
-
|
|
9112
|
-
pixi_spine.atlasParser = atlasParser;
|
|
9113
|
-
|
|
9114
|
-
function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) {
|
|
9115
|
-
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9116
|
-
baseUrl += '/';
|
|
9117
|
-
}
|
|
9118
|
-
|
|
9119
|
-
return function (line, callback) {
|
|
9120
|
-
var name = namePrefix + line;
|
|
9121
|
-
var url = baseUrl + line;
|
|
9122
|
-
var cachedResource = loader.resources[name];
|
|
9123
|
-
|
|
9124
|
-
if (cachedResource) {
|
|
9125
|
-
var done = function done() {
|
|
9126
|
-
callback(cachedResource.texture.baseTexture);
|
|
9127
|
-
};
|
|
9128
|
-
|
|
9129
|
-
if (cachedResource.texture) {
|
|
9130
|
-
done();
|
|
9131
|
-
} else {
|
|
9132
|
-
cachedResource.onAfterMiddleware.add(done);
|
|
9133
|
-
}
|
|
9134
|
-
} else {
|
|
9135
|
-
loader.add(name, url, imageOptions, function (resource) {
|
|
9136
|
-
if (!resource.error) {
|
|
9137
|
-
callback(resource.texture.baseTexture);
|
|
9138
|
-
} else {
|
|
9139
|
-
callback(null);
|
|
9140
|
-
}
|
|
9141
|
-
});
|
|
9142
|
-
}
|
|
9143
|
-
};
|
|
9144
|
-
}
|
|
9145
|
-
|
|
9146
|
-
pixi_spine.imageLoaderAdapter = imageLoaderAdapter;
|
|
9147
|
-
|
|
9148
|
-
function syncImageLoaderAdapter(baseUrl, crossOrigin) {
|
|
9149
|
-
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9150
|
-
baseUrl += '/';
|
|
9151
|
-
}
|
|
9152
|
-
|
|
9153
|
-
return function (line, callback) {
|
|
9154
|
-
callback(PIXI.BaseTexture.fromImage(line, crossOrigin));
|
|
9155
|
-
};
|
|
9156
|
-
}
|
|
9157
|
-
|
|
9158
|
-
pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter;
|
|
9159
|
-
|
|
9160
|
-
function staticImageLoader(pages) {
|
|
9161
|
-
return function (line, callback) {
|
|
9162
|
-
var page = pages[line] || pages['default'];
|
|
9163
|
-
if (page && page.baseTexture) callback(page.baseTexture);else callback(page);
|
|
9164
|
-
};
|
|
9165
|
-
}
|
|
9166
|
-
|
|
9167
|
-
pixi_spine.staticImageLoader = staticImageLoader;
|
|
9168
|
-
|
|
9169
|
-
if (PIXI.loaders.Loader) {
|
|
9170
|
-
PIXI.loaders.Loader.addPixiMiddleware(atlasParser);
|
|
9171
|
-
PIXI.loader.use(atlasParser());
|
|
9172
|
-
}
|
|
9173
|
-
})(pixi_spine || (pixi_spine = {}));
|
|
9174
|
-
|
|
9175
|
-
var pixispine = pixi_spine;
|
|
9176
|
-
var texCache = {};
|
|
9177
|
-
|
|
9178
|
-
function cacheImage(data) {
|
|
9179
|
-
var oldImg = data.image;
|
|
9180
|
-
return {
|
|
9181
|
-
tex: pixi_js.Texture.from(oldImg),
|
|
9182
|
-
count: 0
|
|
9183
|
-
};
|
|
9184
|
-
}
|
|
9185
|
-
|
|
9186
|
-
function retainTexture(name, data) {
|
|
9187
|
-
var cache = texCache[name];
|
|
9188
|
-
|
|
9189
|
-
if (!cache) {
|
|
9190
|
-
cache = cacheImage(data);
|
|
9191
|
-
texCache[name] = cache;
|
|
9192
|
-
}
|
|
9193
|
-
|
|
9194
|
-
cache.count++;
|
|
9195
|
-
return cache.tex;
|
|
9196
|
-
}
|
|
9197
|
-
|
|
9198
|
-
function getTexture(imageSrc, data) {
|
|
9199
|
-
var cache = texCache[imageSrc];
|
|
9200
|
-
|
|
9201
|
-
if (!cache) {
|
|
9202
|
-
cache = cacheImage(data);
|
|
9203
|
-
texCache[imageSrc] = cache;
|
|
9204
|
-
}
|
|
9205
|
-
|
|
9206
|
-
return cache.tex;
|
|
9207
|
-
}
|
|
9208
|
-
|
|
9209
|
-
function releaseTexture(imageSrc) {
|
|
9210
|
-
if (!imageSrc) return;
|
|
9211
|
-
setTimeout(function () {
|
|
9212
|
-
var cache = texCache[imageSrc];
|
|
9213
|
-
|
|
9214
|
-
if (cache) {
|
|
9215
|
-
cache.count--;
|
|
9216
|
-
|
|
9217
|
-
if (cache.count <= 0) {
|
|
9218
|
-
if (cache.tex) {
|
|
9219
|
-
cache.tex.destroy(true);
|
|
9220
|
-
cache.tex = null;
|
|
9221
|
-
}
|
|
9222
|
-
|
|
9223
|
-
delete texCache[imageSrc];
|
|
9224
|
-
}
|
|
9225
|
-
}
|
|
9226
|
-
}, 100);
|
|
9227
|
-
}
|
|
9228
|
-
|
|
9229
|
-
var dataMap = {};
|
|
9230
|
-
|
|
9231
|
-
function createSpineData(name, data, scale) {
|
|
9232
|
-
var spineData = null;
|
|
9233
|
-
var img = getTexture(data.image.src, data);
|
|
9234
|
-
new pixispine.core.TextureAtlas(data.atlas, function (line, callback) {
|
|
9235
|
-
callback(img.baseTexture);
|
|
9236
|
-
}, function (spineAtlas) {
|
|
9237
|
-
if (spineAtlas) {
|
|
9238
|
-
var attachmentLoader = new pixispine.core.AtlasAttachmentLoader(spineAtlas);
|
|
9239
|
-
var spineJsonParser = new pixispine.core.SkeletonJson(attachmentLoader);
|
|
9240
|
-
|
|
9241
|
-
if (scale) {
|
|
9242
|
-
spineJsonParser.scale = scale;
|
|
9243
|
-
}
|
|
9244
|
-
|
|
9245
|
-
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
9246
|
-
}
|
|
9247
|
-
});
|
|
9248
|
-
var obj = {
|
|
9249
|
-
spineData: spineData,
|
|
9250
|
-
ref: 0,
|
|
9251
|
-
imageSrc: data.image.src
|
|
9252
|
-
};
|
|
9253
|
-
dataMap[name] = obj;
|
|
9254
|
-
return obj;
|
|
9255
|
-
}
|
|
9256
|
-
|
|
9257
|
-
eva_js.resource.registerInstance('SPINE', function (info) {
|
|
9258
|
-
return createSpineData(info.name, info.data, info.scale);
|
|
9259
|
-
});
|
|
9260
|
-
eva_js.resource.registerDestroy('SPINE', function (info) {
|
|
9261
|
-
if (info.instance) {
|
|
9262
|
-
releaseTexture(info.data.image.src);
|
|
9263
|
-
info.instance = null;
|
|
9264
|
-
}
|
|
9265
|
-
});
|
|
9266
|
-
|
|
9267
|
-
function getSpineData(res) {
|
|
9268
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9269
|
-
var data;
|
|
9270
|
-
return __generator(this, function (_a) {
|
|
9271
|
-
data = dataMap[res.name];
|
|
9272
|
-
|
|
9273
|
-
if (!data) {
|
|
9274
|
-
if (res.complete) {
|
|
9275
|
-
data = createSpineData(res.name, res.data, res.scale);
|
|
9276
|
-
} else if (!data) {
|
|
9277
|
-
return [2];
|
|
9278
|
-
}
|
|
9279
|
-
}
|
|
9280
|
-
|
|
9281
|
-
retainTexture(res.data.image.src, res.data);
|
|
9282
|
-
data.ref++;
|
|
9283
|
-
return [2, data.spineData];
|
|
9284
|
-
});
|
|
9285
|
-
});
|
|
9286
|
-
}
|
|
9287
|
-
|
|
9288
|
-
function releaseSpineData(resourceName, imageSrc) {
|
|
9289
|
-
var data = dataMap[resourceName];
|
|
9290
|
-
|
|
9291
|
-
if (!data) {
|
|
9292
|
-
return;
|
|
9293
|
-
}
|
|
9294
|
-
|
|
9295
|
-
data.ref--;
|
|
9296
|
-
|
|
9297
|
-
if (data.ref <= 0) {
|
|
9298
|
-
releaseTexture(imageSrc);
|
|
9299
|
-
delete dataMap[resourceName];
|
|
9300
|
-
}
|
|
9301
|
-
}
|
|
9302
|
-
|
|
9303
|
-
var MaxRetryCount = 20;
|
|
9304
|
-
|
|
9305
|
-
var SpineSystem = function (_super) {
|
|
9306
|
-
__extends$1(SpineSystem, _super);
|
|
9307
|
-
|
|
9308
|
-
function SpineSystem() {
|
|
9309
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9310
|
-
|
|
9311
|
-
_this.armatures = {};
|
|
9312
|
-
return _this;
|
|
9313
|
-
}
|
|
9314
|
-
|
|
9315
|
-
SpineSystem.prototype.init = function () {
|
|
9316
|
-
var _this = this;
|
|
9317
|
-
|
|
9318
|
-
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
9319
|
-
this.renderSystem.rendererManager.register(this);
|
|
9320
|
-
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
9321
|
-
var objs = _this.game.gameObjects;
|
|
9322
|
-
var toAdd = [];
|
|
9323
|
-
|
|
9324
|
-
for (var k in _this.armatures) {
|
|
9325
|
-
var id = +k;
|
|
9326
|
-
|
|
9327
|
-
for (var i = 0; i < objs.length; ++i) {
|
|
9328
|
-
var obj = objs[i];
|
|
9329
|
-
|
|
9330
|
-
if (obj.id === id) {
|
|
9331
|
-
var sp = obj.getComponent(Spine$1);
|
|
9332
|
-
|
|
9333
|
-
if (sp) {
|
|
9334
|
-
_this.remove({
|
|
9335
|
-
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
9336
|
-
gameObject: obj,
|
|
9337
|
-
component: sp,
|
|
9338
|
-
componentName: Spine$1.componentName
|
|
9339
|
-
});
|
|
9511
|
+
if (spineAtlas) {
|
|
9512
|
+
var spineJsonParser = new pixi_spine.core.SkeletonJson(new pixi_spine.core.AtlasAttachmentLoader(spineAtlas));
|
|
9340
9513
|
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
gameObject: obj,
|
|
9344
|
-
component: sp,
|
|
9345
|
-
componentName: Spine$1.componentName
|
|
9346
|
-
});
|
|
9514
|
+
if (metadataSkeletonScale) {
|
|
9515
|
+
spineJsonParser.scale = metadataSkeletonScale;
|
|
9347
9516
|
}
|
|
9348
9517
|
|
|
9349
|
-
|
|
9518
|
+
resource.spineData = spineJsonParser.readSkeletonData(resource.data);
|
|
9519
|
+
resource.spineAtlas = spineAtlas;
|
|
9350
9520
|
}
|
|
9351
|
-
}
|
|
9352
|
-
}
|
|
9353
9521
|
|
|
9354
|
-
|
|
9355
|
-
toAdd.forEach(function (obj) {
|
|
9356
|
-
_this.add(obj);
|
|
9522
|
+
next();
|
|
9357
9523
|
});
|
|
9358
|
-
}
|
|
9359
|
-
}, false);
|
|
9360
|
-
};
|
|
9361
|
-
|
|
9362
|
-
SpineSystem.prototype.update = function (e) {
|
|
9363
|
-
for (var key in this.armatures) {
|
|
9364
|
-
this.armatures[key].update(e.deltaTime * 0.001);
|
|
9365
|
-
this.armatures[key].updateTransform();
|
|
9366
|
-
}
|
|
9367
|
-
|
|
9368
|
-
_super.prototype.update.call(this);
|
|
9369
|
-
};
|
|
9524
|
+
};
|
|
9370
9525
|
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
if (
|
|
9376
|
-
|
|
9377
|
-
} else
|
|
9378
|
-
|
|
9379
|
-
case 'resource':
|
|
9380
|
-
this.change(changed);
|
|
9381
|
-
break;
|
|
9382
|
-
}
|
|
9383
|
-
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
9384
|
-
this.remove(changed);
|
|
9526
|
+
if (resource.metadata && resource.metadata.atlasRawData) {
|
|
9527
|
+
createSkeletonWithRawAtlas(resource.metadata.atlasRawData);
|
|
9528
|
+
} else {
|
|
9529
|
+
this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) {
|
|
9530
|
+
if (!atlasResource.error) {
|
|
9531
|
+
createSkeletonWithRawAtlas(atlasResource.data);
|
|
9532
|
+
} else {
|
|
9533
|
+
next();
|
|
9385
9534
|
}
|
|
9386
|
-
}
|
|
9535
|
+
});
|
|
9536
|
+
}
|
|
9537
|
+
};
|
|
9538
|
+
}
|
|
9387
9539
|
|
|
9388
|
-
|
|
9389
|
-
});
|
|
9390
|
-
});
|
|
9391
|
-
};
|
|
9540
|
+
pixi_spine.atlasParser = atlasParser;
|
|
9392
9541
|
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9542
|
+
function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) {
|
|
9543
|
+
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9544
|
+
baseUrl += '/';
|
|
9545
|
+
}
|
|
9396
9546
|
|
|
9397
|
-
|
|
9547
|
+
return function (line, callback) {
|
|
9548
|
+
var name = namePrefix + line;
|
|
9549
|
+
var url = baseUrl + line;
|
|
9550
|
+
var cachedResource = loader.resources[name];
|
|
9398
9551
|
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
clearTimeout(component.addHandler);
|
|
9404
|
-
return [4, eva_js.resource.getResource(component.resource)];
|
|
9552
|
+
if (cachedResource) {
|
|
9553
|
+
var done = function done() {
|
|
9554
|
+
callback(cachedResource.texture.baseTexture);
|
|
9555
|
+
};
|
|
9405
9556
|
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9557
|
+
if (cachedResource.texture) {
|
|
9558
|
+
done();
|
|
9559
|
+
} else {
|
|
9560
|
+
cachedResource.onAfterMiddleware.add(done);
|
|
9561
|
+
}
|
|
9562
|
+
} else {
|
|
9563
|
+
loader.add(name, url, imageOptions, function (resource) {
|
|
9564
|
+
if (!resource.error) {
|
|
9565
|
+
callback(resource.texture.baseTexture);
|
|
9566
|
+
} else {
|
|
9567
|
+
callback(null);
|
|
9568
|
+
}
|
|
9569
|
+
});
|
|
9570
|
+
}
|
|
9571
|
+
};
|
|
9572
|
+
}
|
|
9409
9573
|
|
|
9410
|
-
|
|
9411
|
-
spineData = _a.sent();
|
|
9574
|
+
pixi_spine.imageLoaderAdapter = imageLoaderAdapter;
|
|
9412
9575
|
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
count = MaxRetryCount;
|
|
9418
|
-
}
|
|
9576
|
+
function syncImageLoaderAdapter(baseUrl, crossOrigin) {
|
|
9577
|
+
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9578
|
+
baseUrl += '/';
|
|
9579
|
+
}
|
|
9419
9580
|
|
|
9420
|
-
|
|
9581
|
+
return function (line, callback) {
|
|
9582
|
+
callback(PIXI.BaseTexture.fromImage(line, crossOrigin));
|
|
9583
|
+
};
|
|
9584
|
+
}
|
|
9421
9585
|
|
|
9422
|
-
|
|
9423
|
-
_this.add(changed, count);
|
|
9424
|
-
} else {
|
|
9425
|
-
console.log('retry exceed max times', component.resource);
|
|
9426
|
-
}
|
|
9427
|
-
}
|
|
9428
|
-
}, 1000);
|
|
9429
|
-
return [2];
|
|
9430
|
-
}
|
|
9586
|
+
pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter;
|
|
9431
9587
|
|
|
9432
|
-
|
|
9433
|
-
|
|
9588
|
+
function staticImageLoader(pages) {
|
|
9589
|
+
return function (line, callback) {
|
|
9590
|
+
var page = pages[line] || pages['default'];
|
|
9591
|
+
if (page && page.baseTexture) callback(page.baseTexture);else callback(page);
|
|
9592
|
+
};
|
|
9593
|
+
}
|
|
9434
9594
|
|
|
9435
|
-
|
|
9436
|
-
return [2];
|
|
9437
|
-
}
|
|
9595
|
+
pixi_spine.staticImageLoader = staticImageLoader;
|
|
9438
9596
|
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9597
|
+
if (PIXI.loaders.Loader) {
|
|
9598
|
+
PIXI.loaders.Loader.addPixiMiddleware(atlasParser);
|
|
9599
|
+
PIXI.loader.use(atlasParser());
|
|
9600
|
+
}
|
|
9601
|
+
})(pixi_spine || (pixi_spine = {}));
|
|
9442
9602
|
|
|
9443
|
-
|
|
9444
|
-
tran = changed.gameObject.transform;
|
|
9445
|
-
armature.x = tran.size.width * tran.origin.x;
|
|
9446
|
-
armature.y = tran.size.height * tran.origin.y;
|
|
9447
|
-
}
|
|
9603
|
+
var pixiSpine = pixi_spine;
|
|
9448
9604
|
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
armature.updateTransform();
|
|
9452
|
-
component.armature = armature;
|
|
9605
|
+
var SpineSystem = function (_super) {
|
|
9606
|
+
__extends$1(SpineSystem, _super);
|
|
9453
9607
|
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
} catch (e) {
|
|
9458
|
-
console.log(e);
|
|
9459
|
-
}
|
|
9460
|
-
}
|
|
9608
|
+
function SpineSystem() {
|
|
9609
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9610
|
+
}
|
|
9461
9611
|
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
armature.state.addListener({
|
|
9466
|
-
start: function start(track, event) {
|
|
9467
|
-
component.emit('start', {
|
|
9468
|
-
track: track,
|
|
9469
|
-
name: track.animation.name
|
|
9470
|
-
});
|
|
9471
|
-
},
|
|
9472
|
-
complete: function complete(track, event) {
|
|
9473
|
-
component.emit('complete', {
|
|
9474
|
-
track: track,
|
|
9475
|
-
name: track.animation.name
|
|
9476
|
-
});
|
|
9477
|
-
},
|
|
9478
|
-
interrupt: function interrupt(track, event) {
|
|
9479
|
-
component.emit('interrupt', {
|
|
9480
|
-
track: track,
|
|
9481
|
-
name: track.animation.name
|
|
9482
|
-
});
|
|
9483
|
-
},
|
|
9484
|
-
end: function end(track, event) {
|
|
9485
|
-
component.emit('end', {
|
|
9486
|
-
track: track,
|
|
9487
|
-
name: track.animation.name
|
|
9488
|
-
});
|
|
9489
|
-
},
|
|
9490
|
-
event: function event(track, _event) {
|
|
9491
|
-
component.emit('event', track, _event);
|
|
9492
|
-
}
|
|
9493
|
-
});
|
|
9494
|
-
return [2];
|
|
9495
|
-
}
|
|
9496
|
-
});
|
|
9612
|
+
SpineSystem.prototype.init = function () {
|
|
9613
|
+
_super.prototype.init.call(this, {
|
|
9614
|
+
pixiSpine: pixiSpine
|
|
9497
9615
|
});
|
|
9498
9616
|
};
|
|
9499
9617
|
|
|
9500
|
-
SpineSystem
|
|
9501
|
-
|
|
9502
|
-
this.add(changed);
|
|
9503
|
-
};
|
|
9504
|
-
|
|
9505
|
-
SpineSystem.prototype.remove = function (changed) {
|
|
9506
|
-
var _a, _b;
|
|
9507
|
-
|
|
9508
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9509
|
-
var component, armature, container, res;
|
|
9510
|
-
return __generator(this, function (_c) {
|
|
9511
|
-
switch (_c.label) {
|
|
9512
|
-
case 0:
|
|
9513
|
-
component = changed.component;
|
|
9514
|
-
clearTimeout(component.addHandler);
|
|
9515
|
-
armature = this.armatures[changed.gameObject.id];
|
|
9516
|
-
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
9517
|
-
|
|
9518
|
-
if (container && armature) {
|
|
9519
|
-
container.removeChild(armature);
|
|
9520
|
-
}
|
|
9618
|
+
return SpineSystem;
|
|
9619
|
+
}(SpineSystemBase);
|
|
9521
9620
|
|
|
9522
|
-
|
|
9523
|
-
component.armature.destroy({
|
|
9524
|
-
children: true
|
|
9525
|
-
});
|
|
9526
|
-
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
9621
|
+
var SpineSystem$1 = SpineSystem;
|
|
9527
9622
|
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
|
|
9531
|
-
_c.label = 2;
|
|
9623
|
+
var Spine = function (_super) {
|
|
9624
|
+
__extends$1(Spine, _super);
|
|
9532
9625
|
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
|
|
9537
|
-
return [2];
|
|
9538
|
-
}
|
|
9539
|
-
});
|
|
9540
|
-
});
|
|
9541
|
-
};
|
|
9626
|
+
function Spine() {
|
|
9627
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9628
|
+
}
|
|
9542
9629
|
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
Spine: ['resource']
|
|
9546
|
-
})], SpineSystem);
|
|
9547
|
-
return SpineSystem;
|
|
9548
|
-
}(pluginRenderer.Renderer);
|
|
9630
|
+
return Spine;
|
|
9631
|
+
}(SpineBase);
|
|
9549
9632
|
|
|
9550
|
-
var
|
|
9633
|
+
var Spine$1 = Spine;
|
|
9551
9634
|
exports.Spine = Spine$1;
|
|
9552
9635
|
exports.SpineSystem = SpineSystem$1;
|
|
9553
9636
|
Object.defineProperty(exports, '__esModule', {
|
|
9554
9637
|
value: true
|
|
9555
9638
|
});
|
|
9556
9639
|
return exports;
|
|
9557
|
-
}({}, EVA, EVA.plugin.renderer
|
|
9640
|
+
}({}, PIXI, EVA, EVA.plugin.renderer);
|
|
9641
|
+
|
|
9642
|
+
window.EVA.plugin.renderer.spine = window.EVA.plugin.renderer.spine || _EVA_IIFE_spine;
|