@eva/plugin-renderer-spine 1.2.1 → 1.2.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.renderer.spine.js +615 -591
- package/dist/EVA.plugin.renderer.spine.min.js +1 -1
- package/dist/miniprogram.js +8880 -0
- package/dist/plugin-renderer-spine.cjs.js +545 -529
- 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 +548 -532
- package/package.json +3 -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) {
|
|
@@ -205,7 +205,7 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
var Spine = function (_super) {
|
|
208
|
+
var Spine$2 = function (_super) {
|
|
209
209
|
__extends$1(Spine, _super);
|
|
210
210
|
|
|
211
211
|
function Spine() {
|
|
@@ -326,187 +326,554 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
326
326
|
return Spine;
|
|
327
327
|
}(eva_js.Component);
|
|
328
328
|
|
|
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
|
-
};
|
|
329
|
+
var SpineBase = Spine$2;
|
|
330
|
+
var texCache = {};
|
|
351
331
|
|
|
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
|
-
}
|
|
332
|
+
function cacheImage(data) {
|
|
333
|
+
var oldImg = data.image;
|
|
334
|
+
return {
|
|
335
|
+
tex: pixi_js.Texture.from(oldImg),
|
|
336
|
+
count: 0
|
|
361
337
|
};
|
|
338
|
+
}
|
|
362
339
|
|
|
363
|
-
|
|
364
|
-
|
|
340
|
+
function retainTexture(name, data) {
|
|
341
|
+
var cache = texCache[name];
|
|
365
342
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
if (!cache) {
|
|
344
|
+
cache = cacheImage(data);
|
|
345
|
+
texCache[name] = cache;
|
|
346
|
+
}
|
|
369
347
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
348
|
+
cache.count++;
|
|
349
|
+
return cache.tex;
|
|
350
|
+
}
|
|
373
351
|
|
|
374
|
-
|
|
352
|
+
function getTexture(imageSrc, data) {
|
|
353
|
+
var cache = texCache[imageSrc];
|
|
375
354
|
|
|
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
|
-
}
|
|
355
|
+
if (!cache) {
|
|
356
|
+
cache = cacheImage(data);
|
|
357
|
+
texCache[imageSrc] = cache;
|
|
358
|
+
}
|
|
386
359
|
|
|
387
|
-
|
|
388
|
-
|
|
360
|
+
return cache.tex;
|
|
361
|
+
}
|
|
389
362
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
363
|
+
function releaseTexture(imageSrc) {
|
|
364
|
+
if (!imageSrc) return;
|
|
365
|
+
setTimeout(function () {
|
|
366
|
+
var cache = texCache[imageSrc];
|
|
394
367
|
|
|
395
|
-
|
|
368
|
+
if (cache) {
|
|
369
|
+
cache.count--;
|
|
396
370
|
|
|
397
|
-
|
|
398
|
-
|
|
371
|
+
if (cache.count <= 0) {
|
|
372
|
+
if (cache.tex) {
|
|
373
|
+
cache.tex.destroy(true);
|
|
374
|
+
cache.tex = null;
|
|
399
375
|
}
|
|
400
|
-
};
|
|
401
376
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
377
|
+
delete texCache[imageSrc];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}, 100);
|
|
381
|
+
}
|
|
406
382
|
|
|
407
|
-
|
|
408
|
-
var high = values.length / step - 2;
|
|
409
|
-
if (high == 0) return step;
|
|
410
|
-
var current = high >>> 1;
|
|
383
|
+
var dataMap = {};
|
|
411
384
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
385
|
+
function createSpineData(name, data, scale, pixiSpine) {
|
|
386
|
+
var spineData = null;
|
|
387
|
+
var img = getTexture(data.image.src, data);
|
|
388
|
+
new pixiSpine.core.TextureAtlas(data.atlas, function (line, callback) {
|
|
389
|
+
callback(img.baseTexture);
|
|
390
|
+
}, function (spineAtlas) {
|
|
391
|
+
if (spineAtlas) {
|
|
392
|
+
var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
|
|
393
|
+
var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
|
|
418
394
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
395
|
+
if (scale) {
|
|
396
|
+
spineJsonParser.scale = scale;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
var obj = {
|
|
403
|
+
spineData: spineData,
|
|
404
|
+
ref: 0,
|
|
405
|
+
imageSrc: data.image.src
|
|
406
|
+
};
|
|
407
|
+
dataMap[name] = obj;
|
|
408
|
+
return obj;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function getSpineData(res, pixiSpine) {
|
|
412
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
413
|
+
var data;
|
|
414
|
+
return __generator(this, function (_a) {
|
|
415
|
+
data = dataMap[res.name];
|
|
416
|
+
|
|
417
|
+
if (!data) {
|
|
418
|
+
if (res.complete) {
|
|
419
|
+
data = createSpineData(res.name, res.data, res.scale, pixiSpine);
|
|
420
|
+
} else if (!data) {
|
|
421
|
+
return [2];
|
|
422
422
|
}
|
|
423
|
+
}
|
|
423
424
|
|
|
424
|
-
|
|
425
|
-
|
|
425
|
+
retainTexture(res.data.image.src, res.data);
|
|
426
|
+
data.ref++;
|
|
427
|
+
return [2, data.spineData];
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
}
|
|
426
431
|
|
|
427
|
-
|
|
428
|
-
|
|
432
|
+
function releaseSpineData(resourceName, imageSrc) {
|
|
433
|
+
var data = dataMap[resourceName];
|
|
429
434
|
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
if (!data) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
432
438
|
|
|
433
|
-
|
|
434
|
-
MixBlend[MixBlend['setup'] = 0] = 'setup';
|
|
435
|
-
MixBlend[MixBlend['first'] = 1] = 'first';
|
|
436
|
-
MixBlend[MixBlend['replace'] = 2] = 'replace';
|
|
437
|
-
MixBlend[MixBlend['add'] = 3] = 'add';
|
|
438
|
-
})(MixBlend = core.MixBlend || (core.MixBlend = {}));
|
|
439
|
+
data.ref--;
|
|
439
440
|
|
|
440
|
-
|
|
441
|
+
if (data.ref <= 0) {
|
|
442
|
+
releaseTexture(imageSrc);
|
|
443
|
+
delete dataMap[resourceName];
|
|
444
|
+
}
|
|
445
|
+
}
|
|
441
446
|
|
|
442
|
-
|
|
443
|
-
MixDirection[MixDirection['in'] = 0] = 'in';
|
|
444
|
-
MixDirection[MixDirection['out'] = 1] = 'out';
|
|
445
|
-
})(MixDirection = core.MixDirection || (core.MixDirection = {}));
|
|
447
|
+
var MaxRetryCount = 20;
|
|
446
448
|
|
|
447
|
-
|
|
449
|
+
var SpineSystem$2 = function (_super) {
|
|
450
|
+
__extends$1(SpineSystem, _super);
|
|
448
451
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
TimelineType[TimelineType['translate'] = 1] = 'translate';
|
|
452
|
-
TimelineType[TimelineType['scale'] = 2] = 'scale';
|
|
453
|
-
TimelineType[TimelineType['shear'] = 3] = 'shear';
|
|
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 = {}));
|
|
452
|
+
function SpineSystem() {
|
|
453
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
466
454
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
|
|
471
|
-
}
|
|
455
|
+
_this.armatures = {};
|
|
456
|
+
return _this;
|
|
457
|
+
}
|
|
472
458
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
};
|
|
459
|
+
SpineSystem.prototype.init = function (_a) {
|
|
460
|
+
var _this = this;
|
|
476
461
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
462
|
+
var pixiSpine = _a.pixiSpine;
|
|
463
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
464
|
+
this.renderSystem.rendererManager.register(this);
|
|
465
|
+
this.pixiSpine = pixiSpine;
|
|
466
|
+
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
467
|
+
var objs = _this.game.gameObjects;
|
|
468
|
+
var toAdd = [];
|
|
480
469
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
};
|
|
470
|
+
for (var k in _this.armatures) {
|
|
471
|
+
var id = +k;
|
|
484
472
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if (index == this.curves.length) return CurveTimeline.LINEAR;
|
|
488
|
-
var type = this.curves[index];
|
|
489
|
-
if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR;
|
|
490
|
-
if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED;
|
|
491
|
-
return CurveTimeline.BEZIER;
|
|
492
|
-
};
|
|
473
|
+
for (var i = 0; i < objs.length; ++i) {
|
|
474
|
+
var obj = objs[i];
|
|
493
475
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
tmpy = (-cy1 * 2 + cy2) * 0.03;
|
|
497
|
-
var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006,
|
|
498
|
-
dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
|
|
499
|
-
var ddfx = tmpx * 2 + dddfx,
|
|
500
|
-
ddfy = tmpy * 2 + dddfy;
|
|
501
|
-
var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667,
|
|
502
|
-
dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
|
|
503
|
-
var i = frameIndex * CurveTimeline.BEZIER_SIZE;
|
|
504
|
-
var curves = this.curves;
|
|
505
|
-
curves[i++] = CurveTimeline.BEZIER;
|
|
506
|
-
var x = dfx,
|
|
507
|
-
y = dfy;
|
|
476
|
+
if (obj.id === id) {
|
|
477
|
+
var sp = obj.getComponent(SpineBase);
|
|
508
478
|
|
|
509
|
-
|
|
479
|
+
if (sp) {
|
|
480
|
+
_this.remove({
|
|
481
|
+
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
482
|
+
gameObject: obj,
|
|
483
|
+
component: sp,
|
|
484
|
+
componentName: SpineBase.componentName
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
toAdd.push({
|
|
488
|
+
type: eva_js.OBSERVER_TYPE.ADD,
|
|
489
|
+
gameObject: obj,
|
|
490
|
+
component: sp,
|
|
491
|
+
componentName: SpineBase.componentName
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
setTimeout(function () {
|
|
501
|
+
toAdd.forEach(function (obj) {
|
|
502
|
+
_this.add(obj);
|
|
503
|
+
});
|
|
504
|
+
}, 1000);
|
|
505
|
+
}, false);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
SpineSystem.prototype.update = function (e) {
|
|
509
|
+
for (var key in this.armatures) {
|
|
510
|
+
this.armatures[key].update(e.deltaTime * 0.001);
|
|
511
|
+
this.armatures[key].updateTransform();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
_super.prototype.update.call(this);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
SpineSystem.prototype.componentChanged = function (changed) {
|
|
518
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
519
|
+
return __generator(this, function (_a) {
|
|
520
|
+
if (changed.componentName === 'Spine') {
|
|
521
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
522
|
+
this.add(changed);
|
|
523
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
524
|
+
switch (changed.prop.prop[0]) {
|
|
525
|
+
case 'resource':
|
|
526
|
+
this.change(changed);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
530
|
+
this.remove(changed);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return [2];
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
SpineSystem.prototype.add = function (changed, count) {
|
|
540
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
541
|
+
var component, res, spineData, container, armature, tran;
|
|
542
|
+
|
|
543
|
+
var _this = this;
|
|
544
|
+
|
|
545
|
+
return __generator(this, function (_a) {
|
|
546
|
+
switch (_a.label) {
|
|
547
|
+
case 0:
|
|
548
|
+
component = changed.component;
|
|
549
|
+
clearTimeout(component.addHandler);
|
|
550
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
551
|
+
|
|
552
|
+
case 1:
|
|
553
|
+
res = _a.sent();
|
|
554
|
+
return [4, getSpineData(res, this.pixiSpine)];
|
|
555
|
+
|
|
556
|
+
case 2:
|
|
557
|
+
spineData = _a.sent();
|
|
558
|
+
|
|
559
|
+
if (!spineData) {
|
|
560
|
+
component.addHandler = setTimeout(function () {
|
|
561
|
+
if (!component.destroied) {
|
|
562
|
+
if (count === undefined) {
|
|
563
|
+
count = MaxRetryCount;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
count--;
|
|
567
|
+
|
|
568
|
+
if (count > 0) {
|
|
569
|
+
_this.add(changed, count);
|
|
570
|
+
} else {
|
|
571
|
+
console.log('retry exceed max times', component.resource);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}, 1000);
|
|
575
|
+
return [2];
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
this.remove(changed);
|
|
579
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
580
|
+
|
|
581
|
+
if (!container) {
|
|
582
|
+
return [2];
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
component.lastResource = component.resource;
|
|
586
|
+
armature = new this.pixiSpine.Spine(spineData);
|
|
587
|
+
this.armatures[changed.gameObject.id] = armature;
|
|
588
|
+
|
|
589
|
+
if (changed.gameObject && changed.gameObject.transform) {
|
|
590
|
+
tran = changed.gameObject.transform;
|
|
591
|
+
armature.x = tran.size.width * tran.origin.x;
|
|
592
|
+
armature.y = tran.size.height * tran.origin.y;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
container.addChildAt(armature, 0);
|
|
596
|
+
armature.update();
|
|
597
|
+
armature.updateTransform();
|
|
598
|
+
component.armature = armature;
|
|
599
|
+
|
|
600
|
+
if (component.autoPlay) {
|
|
601
|
+
try {
|
|
602
|
+
armature.state.setAnimation(0, component.animationName, true);
|
|
603
|
+
} catch (e) {
|
|
604
|
+
console.log(e);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
component.emit('loaded', {
|
|
609
|
+
resource: component.resource
|
|
610
|
+
});
|
|
611
|
+
armature.state.addListener({
|
|
612
|
+
start: function start(track, event) {
|
|
613
|
+
component.emit('start', {
|
|
614
|
+
track: track,
|
|
615
|
+
name: track.animation.name
|
|
616
|
+
});
|
|
617
|
+
},
|
|
618
|
+
complete: function complete(track, event) {
|
|
619
|
+
component.emit('complete', {
|
|
620
|
+
track: track,
|
|
621
|
+
name: track.animation.name
|
|
622
|
+
});
|
|
623
|
+
},
|
|
624
|
+
interrupt: function interrupt(track, event) {
|
|
625
|
+
component.emit('interrupt', {
|
|
626
|
+
track: track,
|
|
627
|
+
name: track.animation.name
|
|
628
|
+
});
|
|
629
|
+
},
|
|
630
|
+
end: function end(track, event) {
|
|
631
|
+
component.emit('end', {
|
|
632
|
+
track: track,
|
|
633
|
+
name: track.animation.name
|
|
634
|
+
});
|
|
635
|
+
},
|
|
636
|
+
event: function event(track, _event) {
|
|
637
|
+
component.emit('event', track, _event);
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
return [2];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
SpineSystem.prototype.change = function (changed) {
|
|
647
|
+
this.remove(changed);
|
|
648
|
+
this.add(changed);
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
SpineSystem.prototype.remove = function (changed) {
|
|
652
|
+
var _a, _b;
|
|
653
|
+
|
|
654
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
655
|
+
var component, armature, container, res;
|
|
656
|
+
return __generator(this, function (_c) {
|
|
657
|
+
switch (_c.label) {
|
|
658
|
+
case 0:
|
|
659
|
+
component = changed.component;
|
|
660
|
+
clearTimeout(component.addHandler);
|
|
661
|
+
armature = this.armatures[changed.gameObject.id];
|
|
662
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
663
|
+
|
|
664
|
+
if (container && armature) {
|
|
665
|
+
container.removeChild(armature);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
if (!component.armature) return [3, 2];
|
|
669
|
+
component.armature.destroy({
|
|
670
|
+
children: true
|
|
671
|
+
});
|
|
672
|
+
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
673
|
+
|
|
674
|
+
case 1:
|
|
675
|
+
res = _c.sent();
|
|
676
|
+
releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
|
|
677
|
+
_c.label = 2;
|
|
678
|
+
|
|
679
|
+
case 2:
|
|
680
|
+
component.armature = null;
|
|
681
|
+
delete this.armatures[changed.gameObject.id];
|
|
682
|
+
if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
|
|
683
|
+
return [2];
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
SpineSystem.systemName = 'SpineSystem';
|
|
690
|
+
SpineSystem = __decorate([eva_js.decorators.componentObserver({
|
|
691
|
+
Spine: ['resource']
|
|
692
|
+
})], SpineSystem);
|
|
693
|
+
return SpineSystem;
|
|
694
|
+
}(pluginRenderer.Renderer);
|
|
695
|
+
|
|
696
|
+
var SpineSystemBase = SpineSystem$2;
|
|
697
|
+
var VERSION = '4.8.9';
|
|
698
|
+
var loader = pixi_js.loaders.shared;
|
|
699
|
+
var PIXI = {
|
|
700
|
+
Texture: pixi_js.Texture,
|
|
701
|
+
Rectangle: pixi_js.Rectangle,
|
|
702
|
+
Sprite: pixi_js.Sprite,
|
|
703
|
+
Graphics: pixi_js.Graphics,
|
|
704
|
+
mesh: pixi_js.mesh,
|
|
705
|
+
Matrix: pixi_js.Matrix,
|
|
706
|
+
Container: pixi_js.Container,
|
|
707
|
+
VERSION: VERSION,
|
|
708
|
+
loaders: pixi_js.loaders,
|
|
709
|
+
loader: loader,
|
|
710
|
+
SCALE_MODES: pixi_js.SCALE_MODES,
|
|
711
|
+
utils: pixi_js.utils,
|
|
712
|
+
TransformBase: pixi_js.TransformBase,
|
|
713
|
+
TransformStatic: pixi_js.TransformStatic,
|
|
714
|
+
DisplayObject: pixi_js.DisplayObject,
|
|
715
|
+
Polygon: pixi_js.Polygon,
|
|
716
|
+
BaseTexture: pixi_js.BaseTexture
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
var __extends = undefined && undefined.__extends || function () {
|
|
720
|
+
var extendStatics = Object.setPrototypeOf || {
|
|
721
|
+
__proto__: []
|
|
722
|
+
} instanceof Array && function (d, b) {
|
|
723
|
+
d.__proto__ = b;
|
|
724
|
+
} || function (d, b) {
|
|
725
|
+
for (var p in b) {
|
|
726
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
return function (d, b) {
|
|
731
|
+
extendStatics(d, b);
|
|
732
|
+
|
|
733
|
+
function __() {
|
|
734
|
+
this.constructor = d;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
738
|
+
};
|
|
739
|
+
}();
|
|
740
|
+
|
|
741
|
+
var pixi_spine;
|
|
742
|
+
|
|
743
|
+
(function (pixi_spine) {
|
|
744
|
+
(function (core) {
|
|
745
|
+
var Animation = function () {
|
|
746
|
+
function Animation(name, timelines, duration) {
|
|
747
|
+
if (name == null) throw new Error('name cannot be null.');
|
|
748
|
+
if (timelines == null) throw new Error('timelines cannot be null.');
|
|
749
|
+
this.name = name;
|
|
750
|
+
this.timelines = timelines;
|
|
751
|
+
this.duration = duration;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
|
|
755
|
+
if (skeleton == null) throw new Error('skeleton cannot be null.');
|
|
756
|
+
|
|
757
|
+
if (loop && this.duration != 0) {
|
|
758
|
+
time %= this.duration;
|
|
759
|
+
if (lastTime > 0) lastTime %= this.duration;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
var timelines = this.timelines;
|
|
763
|
+
|
|
764
|
+
for (var i = 0, n = timelines.length; i < n; i++) {
|
|
765
|
+
timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
Animation.binarySearch = function (values, target, step) {
|
|
770
|
+
if (step === void 0) {
|
|
771
|
+
step = 1;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
var low = 0;
|
|
775
|
+
var high = values.length / step - 2;
|
|
776
|
+
if (high == 0) return step;
|
|
777
|
+
var current = high >>> 1;
|
|
778
|
+
|
|
779
|
+
while (true) {
|
|
780
|
+
if (values[(current + 1) * step] <= target) low = current + 1;else high = current;
|
|
781
|
+
if (low == high) return (low + 1) * step;
|
|
782
|
+
current = low + high >>> 1;
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
Animation.linearSearch = function (values, target, step) {
|
|
787
|
+
for (var i = 0, last = values.length - step; i <= last; i += step) {
|
|
788
|
+
if (values[i] > target) return i;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
return -1;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
return Animation;
|
|
795
|
+
}();
|
|
796
|
+
|
|
797
|
+
core.Animation = Animation;
|
|
798
|
+
var MixBlend;
|
|
799
|
+
|
|
800
|
+
(function (MixBlend) {
|
|
801
|
+
MixBlend[MixBlend['setup'] = 0] = 'setup';
|
|
802
|
+
MixBlend[MixBlend['first'] = 1] = 'first';
|
|
803
|
+
MixBlend[MixBlend['replace'] = 2] = 'replace';
|
|
804
|
+
MixBlend[MixBlend['add'] = 3] = 'add';
|
|
805
|
+
})(MixBlend = core.MixBlend || (core.MixBlend = {}));
|
|
806
|
+
|
|
807
|
+
var MixDirection;
|
|
808
|
+
|
|
809
|
+
(function (MixDirection) {
|
|
810
|
+
MixDirection[MixDirection['in'] = 0] = 'in';
|
|
811
|
+
MixDirection[MixDirection['out'] = 1] = 'out';
|
|
812
|
+
})(MixDirection = core.MixDirection || (core.MixDirection = {}));
|
|
813
|
+
|
|
814
|
+
var TimelineType;
|
|
815
|
+
|
|
816
|
+
(function (TimelineType) {
|
|
817
|
+
TimelineType[TimelineType['rotate'] = 0] = 'rotate';
|
|
818
|
+
TimelineType[TimelineType['translate'] = 1] = 'translate';
|
|
819
|
+
TimelineType[TimelineType['scale'] = 2] = 'scale';
|
|
820
|
+
TimelineType[TimelineType['shear'] = 3] = 'shear';
|
|
821
|
+
TimelineType[TimelineType['attachment'] = 4] = 'attachment';
|
|
822
|
+
TimelineType[TimelineType['color'] = 5] = 'color';
|
|
823
|
+
TimelineType[TimelineType['deform'] = 6] = 'deform';
|
|
824
|
+
TimelineType[TimelineType['event'] = 7] = 'event';
|
|
825
|
+
TimelineType[TimelineType['drawOrder'] = 8] = 'drawOrder';
|
|
826
|
+
TimelineType[TimelineType['ikConstraint'] = 9] = 'ikConstraint';
|
|
827
|
+
TimelineType[TimelineType['transformConstraint'] = 10] = 'transformConstraint';
|
|
828
|
+
TimelineType[TimelineType['pathConstraintPosition'] = 11] = 'pathConstraintPosition';
|
|
829
|
+
TimelineType[TimelineType['pathConstraintSpacing'] = 12] = 'pathConstraintSpacing';
|
|
830
|
+
TimelineType[TimelineType['pathConstraintMix'] = 13] = 'pathConstraintMix';
|
|
831
|
+
TimelineType[TimelineType['twoColor'] = 14] = 'twoColor';
|
|
832
|
+
})(TimelineType = core.TimelineType || (core.TimelineType = {}));
|
|
833
|
+
|
|
834
|
+
var CurveTimeline = function () {
|
|
835
|
+
function CurveTimeline(frameCount) {
|
|
836
|
+
if (frameCount <= 0) throw new Error('frameCount must be > 0: ' + frameCount);
|
|
837
|
+
this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
CurveTimeline.prototype.getFrameCount = function () {
|
|
841
|
+
return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
CurveTimeline.prototype.setLinear = function (frameIndex) {
|
|
845
|
+
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
CurveTimeline.prototype.setStepped = function (frameIndex) {
|
|
849
|
+
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
CurveTimeline.prototype.getCurveType = function (frameIndex) {
|
|
853
|
+
var index = frameIndex * CurveTimeline.BEZIER_SIZE;
|
|
854
|
+
if (index == this.curves.length) return CurveTimeline.LINEAR;
|
|
855
|
+
var type = this.curves[index];
|
|
856
|
+
if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR;
|
|
857
|
+
if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED;
|
|
858
|
+
return CurveTimeline.BEZIER;
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {
|
|
862
|
+
var tmpx = (-cx1 * 2 + cx2) * 0.03,
|
|
863
|
+
tmpy = (-cy1 * 2 + cy2) * 0.03;
|
|
864
|
+
var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006,
|
|
865
|
+
dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
|
|
866
|
+
var ddfx = tmpx * 2 + dddfx,
|
|
867
|
+
ddfy = tmpy * 2 + dddfy;
|
|
868
|
+
var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667,
|
|
869
|
+
dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
|
|
870
|
+
var i = frameIndex * CurveTimeline.BEZIER_SIZE;
|
|
871
|
+
var curves = this.curves;
|
|
872
|
+
curves[i++] = CurveTimeline.BEZIER;
|
|
873
|
+
var x = dfx,
|
|
874
|
+
y = dfy;
|
|
875
|
+
|
|
876
|
+
for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
|
|
510
877
|
curves[i] = x;
|
|
511
878
|
curves[i + 1] = y;
|
|
512
879
|
dfx += ddfx;
|
|
@@ -9081,477 +9448,134 @@ this.EVA.plugin.renderer.spine = function (exports, eva_js, pluginRenderer, pixi
|
|
|
9081
9448
|
var createSkeletonWithRawAtlas = function createSkeletonWithRawAtlas(rawData) {
|
|
9082
9449
|
new pixi_spine.core.TextureAtlas(rawData, adapter, function (spineAtlas) {
|
|
9083
9450
|
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
|
-
});
|
|
9340
|
-
|
|
9341
|
-
toAdd.push({
|
|
9342
|
-
type: eva_js.OBSERVER_TYPE.ADD,
|
|
9343
|
-
gameObject: obj,
|
|
9344
|
-
component: sp,
|
|
9345
|
-
componentName: Spine$1.componentName
|
|
9346
|
-
});
|
|
9451
|
+
var spineJsonParser = new pixi_spine.core.SkeletonJson(new pixi_spine.core.AtlasAttachmentLoader(spineAtlas));
|
|
9452
|
+
|
|
9453
|
+
if (metadataSkeletonScale) {
|
|
9454
|
+
spineJsonParser.scale = metadataSkeletonScale;
|
|
9347
9455
|
}
|
|
9348
9456
|
|
|
9349
|
-
|
|
9457
|
+
resource.spineData = spineJsonParser.readSkeletonData(resource.data);
|
|
9458
|
+
resource.spineAtlas = spineAtlas;
|
|
9350
9459
|
}
|
|
9351
|
-
}
|
|
9352
|
-
}
|
|
9353
9460
|
|
|
9354
|
-
|
|
9355
|
-
toAdd.forEach(function (obj) {
|
|
9356
|
-
_this.add(obj);
|
|
9461
|
+
next();
|
|
9357
9462
|
});
|
|
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
|
-
};
|
|
9463
|
+
};
|
|
9370
9464
|
|
|
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);
|
|
9465
|
+
if (resource.metadata && resource.metadata.atlasRawData) {
|
|
9466
|
+
createSkeletonWithRawAtlas(resource.metadata.atlasRawData);
|
|
9467
|
+
} else {
|
|
9468
|
+
this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) {
|
|
9469
|
+
if (!atlasResource.error) {
|
|
9470
|
+
createSkeletonWithRawAtlas(atlasResource.data);
|
|
9471
|
+
} else {
|
|
9472
|
+
next();
|
|
9385
9473
|
}
|
|
9386
|
-
}
|
|
9474
|
+
});
|
|
9475
|
+
}
|
|
9476
|
+
};
|
|
9477
|
+
}
|
|
9387
9478
|
|
|
9388
|
-
|
|
9389
|
-
});
|
|
9390
|
-
});
|
|
9391
|
-
};
|
|
9479
|
+
pixi_spine.atlasParser = atlasParser;
|
|
9392
9480
|
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9481
|
+
function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) {
|
|
9482
|
+
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9483
|
+
baseUrl += '/';
|
|
9484
|
+
}
|
|
9396
9485
|
|
|
9397
|
-
|
|
9486
|
+
return function (line, callback) {
|
|
9487
|
+
var name = namePrefix + line;
|
|
9488
|
+
var url = baseUrl + line;
|
|
9489
|
+
var cachedResource = loader.resources[name];
|
|
9398
9490
|
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
clearTimeout(component.addHandler);
|
|
9404
|
-
return [4, eva_js.resource.getResource(component.resource)];
|
|
9491
|
+
if (cachedResource) {
|
|
9492
|
+
var done = function done() {
|
|
9493
|
+
callback(cachedResource.texture.baseTexture);
|
|
9494
|
+
};
|
|
9405
9495
|
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9496
|
+
if (cachedResource.texture) {
|
|
9497
|
+
done();
|
|
9498
|
+
} else {
|
|
9499
|
+
cachedResource.onAfterMiddleware.add(done);
|
|
9500
|
+
}
|
|
9501
|
+
} else {
|
|
9502
|
+
loader.add(name, url, imageOptions, function (resource) {
|
|
9503
|
+
if (!resource.error) {
|
|
9504
|
+
callback(resource.texture.baseTexture);
|
|
9505
|
+
} else {
|
|
9506
|
+
callback(null);
|
|
9507
|
+
}
|
|
9508
|
+
});
|
|
9509
|
+
}
|
|
9510
|
+
};
|
|
9511
|
+
}
|
|
9409
9512
|
|
|
9410
|
-
|
|
9411
|
-
spineData = _a.sent();
|
|
9513
|
+
pixi_spine.imageLoaderAdapter = imageLoaderAdapter;
|
|
9412
9514
|
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
count = MaxRetryCount;
|
|
9418
|
-
}
|
|
9515
|
+
function syncImageLoaderAdapter(baseUrl, crossOrigin) {
|
|
9516
|
+
if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) {
|
|
9517
|
+
baseUrl += '/';
|
|
9518
|
+
}
|
|
9419
9519
|
|
|
9420
|
-
|
|
9520
|
+
return function (line, callback) {
|
|
9521
|
+
callback(PIXI.BaseTexture.fromImage(line, crossOrigin));
|
|
9522
|
+
};
|
|
9523
|
+
}
|
|
9421
9524
|
|
|
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
|
-
}
|
|
9525
|
+
pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter;
|
|
9431
9526
|
|
|
9432
|
-
|
|
9433
|
-
|
|
9527
|
+
function staticImageLoader(pages) {
|
|
9528
|
+
return function (line, callback) {
|
|
9529
|
+
var page = pages[line] || pages['default'];
|
|
9530
|
+
if (page && page.baseTexture) callback(page.baseTexture);else callback(page);
|
|
9531
|
+
};
|
|
9532
|
+
}
|
|
9434
9533
|
|
|
9435
|
-
|
|
9436
|
-
return [2];
|
|
9437
|
-
}
|
|
9534
|
+
pixi_spine.staticImageLoader = staticImageLoader;
|
|
9438
9535
|
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9536
|
+
if (PIXI.loaders.Loader) {
|
|
9537
|
+
PIXI.loaders.Loader.addPixiMiddleware(atlasParser);
|
|
9538
|
+
PIXI.loader.use(atlasParser());
|
|
9539
|
+
}
|
|
9540
|
+
})(pixi_spine || (pixi_spine = {}));
|
|
9442
9541
|
|
|
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
|
-
}
|
|
9542
|
+
var pixiSpine = pixi_spine;
|
|
9448
9543
|
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
armature.updateTransform();
|
|
9452
|
-
component.armature = armature;
|
|
9544
|
+
var SpineSystem = function (_super) {
|
|
9545
|
+
__extends$1(SpineSystem, _super);
|
|
9453
9546
|
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
} catch (e) {
|
|
9458
|
-
console.log(e);
|
|
9459
|
-
}
|
|
9460
|
-
}
|
|
9547
|
+
function SpineSystem() {
|
|
9548
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9549
|
+
}
|
|
9461
9550
|
|
|
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
|
-
});
|
|
9551
|
+
SpineSystem.prototype.init = function () {
|
|
9552
|
+
_super.prototype.init.call(this, {
|
|
9553
|
+
pixiSpine: pixiSpine
|
|
9497
9554
|
});
|
|
9498
9555
|
};
|
|
9499
9556
|
|
|
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
|
-
}
|
|
9557
|
+
return SpineSystem;
|
|
9558
|
+
}(SpineSystemBase);
|
|
9521
9559
|
|
|
9522
|
-
|
|
9523
|
-
component.armature.destroy({
|
|
9524
|
-
children: true
|
|
9525
|
-
});
|
|
9526
|
-
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
9560
|
+
var SpineSystem$1 = SpineSystem;
|
|
9527
9561
|
|
|
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;
|
|
9562
|
+
var Spine = function (_super) {
|
|
9563
|
+
__extends$1(Spine, _super);
|
|
9532
9564
|
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) ;
|
|
9537
|
-
return [2];
|
|
9538
|
-
}
|
|
9539
|
-
});
|
|
9540
|
-
});
|
|
9541
|
-
};
|
|
9565
|
+
function Spine() {
|
|
9566
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
9567
|
+
}
|
|
9542
9568
|
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
Spine: ['resource']
|
|
9546
|
-
})], SpineSystem);
|
|
9547
|
-
return SpineSystem;
|
|
9548
|
-
}(pluginRenderer.Renderer);
|
|
9569
|
+
return Spine;
|
|
9570
|
+
}(SpineBase);
|
|
9549
9571
|
|
|
9550
|
-
var
|
|
9572
|
+
var Spine$1 = Spine;
|
|
9551
9573
|
exports.Spine = Spine$1;
|
|
9552
9574
|
exports.SpineSystem = SpineSystem$1;
|
|
9553
9575
|
Object.defineProperty(exports, '__esModule', {
|
|
9554
9576
|
value: true
|
|
9555
9577
|
});
|
|
9556
9578
|
return exports;
|
|
9557
|
-
}({}, EVA, EVA.plugin.renderer
|
|
9579
|
+
}({}, PIXI, EVA, EVA.plugin.renderer);
|
|
9580
|
+
|
|
9581
|
+
window.EVA.plugin.renderer.spine = window.EVA.plugin.renderer.spine || _EVA_IIFE_spine;
|