@esotericsoftware/spine-canvas 4.0.12 → 4.1.1

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.
@@ -1,9 +1,6 @@
1
1
  var spine = (() => {
2
2
  var __defProp = Object.defineProperty;
3
3
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
4
- var __require = typeof require !== "undefined" ? require : (x) => {
5
- throw new Error('Dynamic require of "' + x + '" is not supported');
6
- };
7
4
  var __export = (target, all) => {
8
5
  __markAsModule(target);
9
6
  for (var name in all)
@@ -83,6 +80,7 @@ var spine = (() => {
83
80
  ScaleTimeline: () => ScaleTimeline,
84
81
  ScaleXTimeline: () => ScaleXTimeline,
85
82
  ScaleYTimeline: () => ScaleYTimeline,
83
+ SequenceTimeline: () => SequenceTimeline,
86
84
  ShearTimeline: () => ShearTimeline,
87
85
  ShearXTimeline: () => ShearXTimeline,
88
86
  ShearYTimeline: () => ShearYTimeline,
@@ -516,7 +514,7 @@ var spine = (() => {
516
514
  super(name);
517
515
  this.id = _VertexAttachment.nextID++;
518
516
  this.worldVerticesLength = 0;
519
- this.deformAttachment = this;
517
+ this.timelineAttahment = this;
520
518
  }
521
519
  computeWorldVertices(slot, start, count, worldVertices, offset, stride) {
522
520
  count = offset + (count >> 1) * stride;
@@ -588,12 +586,75 @@ var spine = (() => {
588
586
  } else
589
587
  attachment.vertices = null;
590
588
  attachment.worldVerticesLength = this.worldVerticesLength;
591
- attachment.deformAttachment = this.deformAttachment;
589
+ attachment.timelineAttahment = this.timelineAttahment;
592
590
  }
593
591
  };
594
592
  var VertexAttachment = _VertexAttachment;
595
593
  VertexAttachment.nextID = 0;
596
594
 
595
+ // spine-core/src/attachments/Sequence.ts
596
+ var _Sequence = class {
597
+ constructor(count) {
598
+ this.id = _Sequence.nextID();
599
+ this.start = 0;
600
+ this.digits = 0;
601
+ this.setupIndex = 0;
602
+ this.regions = new Array(count);
603
+ }
604
+ copy() {
605
+ let copy = new _Sequence(this.regions.length);
606
+ Utils.arrayCopy(this.regions, 0, copy.regions, 0, this.regions.length);
607
+ copy.start = this.start;
608
+ copy.digits = this.digits;
609
+ copy.setupIndex = this.setupIndex;
610
+ return copy;
611
+ }
612
+ apply(slot, attachment) {
613
+ let index = slot.sequenceIndex;
614
+ if (index == -1)
615
+ index = this.setupIndex;
616
+ if (index >= this.regions.length)
617
+ index = this.regions.length - 1;
618
+ let region = this.regions[index];
619
+ if (attachment.region != region) {
620
+ attachment.region = region;
621
+ attachment.updateRegion();
622
+ }
623
+ }
624
+ getPath(basePath, index) {
625
+ let result = basePath;
626
+ let frame = (this.start + index).toString();
627
+ for (let i = this.digits - frame.length; i > 0; i--)
628
+ result += "0";
629
+ result += frame;
630
+ return result;
631
+ }
632
+ static nextID() {
633
+ return _Sequence._nextID++;
634
+ }
635
+ };
636
+ var Sequence = _Sequence;
637
+ Sequence._nextID = 0;
638
+ var SequenceMode;
639
+ (function(SequenceMode2) {
640
+ SequenceMode2[SequenceMode2["hold"] = 0] = "hold";
641
+ SequenceMode2[SequenceMode2["once"] = 1] = "once";
642
+ SequenceMode2[SequenceMode2["loop"] = 2] = "loop";
643
+ SequenceMode2[SequenceMode2["pingpong"] = 3] = "pingpong";
644
+ SequenceMode2[SequenceMode2["onceReverse"] = 4] = "onceReverse";
645
+ SequenceMode2[SequenceMode2["loopReverse"] = 5] = "loopReverse";
646
+ SequenceMode2[SequenceMode2["pingpongReverse"] = 6] = "pingpongReverse";
647
+ })(SequenceMode || (SequenceMode = {}));
648
+ var SequenceModeValues = [
649
+ 0,
650
+ 1,
651
+ 2,
652
+ 3,
653
+ 4,
654
+ 5,
655
+ 6
656
+ ];
657
+
597
658
  // spine-core/src/Animation.ts
598
659
  var Animation = class {
599
660
  constructor(name, timelines, duration) {
@@ -661,7 +722,8 @@ var spine = (() => {
661
722
  transformConstraint: 15,
662
723
  pathConstraintPosition: 16,
663
724
  pathConstraintSpacing: 17,
664
- pathConstraintMix: 18
725
+ pathConstraintMix: 18,
726
+ sequence: 19
665
727
  };
666
728
  var Timeline = class {
667
729
  constructor(frameCount, propertyIds) {
@@ -1819,7 +1881,7 @@ var spine = (() => {
1819
1881
  if (!slot.bone.active)
1820
1882
  return;
1821
1883
  let slotAttachment = slot.getAttachment();
1822
- if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.deformAttachment != this.attachment)
1884
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != this.attachment)
1823
1885
  return;
1824
1886
  let deform = slot.deform;
1825
1887
  if (deform.length == 0)
@@ -1828,7 +1890,6 @@ var spine = (() => {
1828
1890
  let vertexCount = vertices[0].length;
1829
1891
  let frames = this.frames;
1830
1892
  if (time < frames[0]) {
1831
- let vertexAttachment = slotAttachment;
1832
1893
  switch (blend) {
1833
1894
  case 0:
1834
1895
  deform.length = 0;
@@ -1839,6 +1900,7 @@ var spine = (() => {
1839
1900
  return;
1840
1901
  }
1841
1902
  deform.length = vertexCount;
1903
+ let vertexAttachment = slotAttachment;
1842
1904
  if (!vertexAttachment.bones) {
1843
1905
  let setupVertices = vertexAttachment.vertices;
1844
1906
  for (var i = 0; i < vertexCount; i++)
@@ -2363,6 +2425,81 @@ var spine = (() => {
2363
2425
  }
2364
2426
  }
2365
2427
  };
2428
+ var _SequenceTimeline = class extends Timeline {
2429
+ constructor(frameCount, slotIndex, attachment) {
2430
+ super(frameCount, [
2431
+ Property.sequence + "|" + slotIndex + "|" + attachment.sequence.id
2432
+ ]);
2433
+ this.slotIndex = slotIndex;
2434
+ this.attachment = attachment;
2435
+ }
2436
+ getFrameEntries() {
2437
+ return _SequenceTimeline.ENTRIES;
2438
+ }
2439
+ getSlotIndex() {
2440
+ return this.slotIndex;
2441
+ }
2442
+ getAttachment() {
2443
+ return this.attachment;
2444
+ }
2445
+ setFrame(frame, time, mode, index, delay) {
2446
+ let frames = this.frames;
2447
+ frame *= _SequenceTimeline.ENTRIES;
2448
+ frames[frame] = time;
2449
+ frames[frame + _SequenceTimeline.MODE] = mode | index << 4;
2450
+ frames[frame + _SequenceTimeline.DELAY] = delay;
2451
+ }
2452
+ apply(skeleton, lastTime, time, events, alpha, blend, direction) {
2453
+ let slot = skeleton.slots[this.slotIndex];
2454
+ if (!slot.bone.active)
2455
+ return;
2456
+ let slotAttachment = slot.attachment;
2457
+ let attachment = this.attachment;
2458
+ if (slotAttachment != attachment) {
2459
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != attachment)
2460
+ return;
2461
+ }
2462
+ let frames = this.frames;
2463
+ if (time < frames[0]) {
2464
+ if (blend == 0 || blend == 1)
2465
+ slot.sequenceIndex = -1;
2466
+ return;
2467
+ }
2468
+ let i = Timeline.search(frames, time, _SequenceTimeline.ENTRIES);
2469
+ let before = frames[i];
2470
+ let modeAndIndex = frames[i + _SequenceTimeline.MODE];
2471
+ let delay = frames[i + _SequenceTimeline.DELAY];
2472
+ let index = modeAndIndex >> 4, count = this.attachment.sequence.regions.length;
2473
+ let mode = SequenceModeValues[modeAndIndex & 15];
2474
+ if (mode != SequenceMode.hold) {
2475
+ index += (time - before) / delay + 1e-5 | 0;
2476
+ switch (mode) {
2477
+ case SequenceMode.once:
2478
+ index = Math.min(count - 1, index);
2479
+ break;
2480
+ case SequenceMode.loop:
2481
+ index %= count;
2482
+ break;
2483
+ case SequenceMode.pingpong:
2484
+ let n = (count << 1) - 2;
2485
+ index %= n;
2486
+ if (index >= count)
2487
+ index = n - index;
2488
+ break;
2489
+ case SequenceMode.onceReverse:
2490
+ index = Math.max(count - 1 - index, 0);
2491
+ break;
2492
+ case SequenceMode.loopReverse:
2493
+ index = count - 1 - index % count;
2494
+ }
2495
+ }
2496
+ slot.sequenceIndex = index;
2497
+ }
2498
+ };
2499
+ var SequenceTimeline = _SequenceTimeline;
2500
+ SequenceTimeline.ENTRIES = 3;
2501
+ SequenceTimeline.MODE = 1;
2502
+ SequenceTimeline.DELAY = 2;
2366
2503
 
2367
2504
  // spine-core/src/AnimationState.ts
2368
2505
  var AnimationState = class {
@@ -3456,7 +3593,7 @@ var spine = (() => {
3456
3593
  this.color = new Color(1, 1, 1, 1);
3457
3594
  this.tempColor = new Color(0, 0, 0, 0);
3458
3595
  }
3459
- updateUVs() {
3596
+ updateRegion() {
3460
3597
  let regionUVs = this.regionUVs;
3461
3598
  if (!this.uvs || this.uvs.length != regionUVs.length)
3462
3599
  this.uvs = Utils.newFloatArray(regionUVs.length);
@@ -3544,6 +3681,7 @@ var spine = (() => {
3544
3681
  copy.triangles = new Array(this.triangles.length);
3545
3682
  Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
3546
3683
  copy.hullLength = this.hullLength;
3684
+ copy.sequence = this.sequence.copy();
3547
3685
  if (this.edges) {
3548
3686
  copy.edges = new Array(this.edges.length);
3549
3687
  Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
@@ -3552,14 +3690,20 @@ var spine = (() => {
3552
3690
  copy.height = this.height;
3553
3691
  return copy;
3554
3692
  }
3693
+ computeWorldVertices(slot, start, count, worldVertices, offset, stride) {
3694
+ if (this.sequence != null)
3695
+ this.sequence.apply(slot, this);
3696
+ super.computeWorldVertices(slot, start, count, worldVertices, offset, stride);
3697
+ }
3555
3698
  newLinkedMesh() {
3556
3699
  let copy = new MeshAttachment(this.name);
3557
3700
  copy.region = this.region;
3558
3701
  copy.path = this.path;
3559
3702
  copy.color.setFromColor(this.color);
3560
- copy.deformAttachment = this.deformAttachment;
3703
+ copy.timelineAttahment = this.timelineAttahment;
3561
3704
  copy.setParentMesh(this.parentMesh ? this.parentMesh : this);
3562
- copy.updateUVs();
3705
+ if (copy.region != null)
3706
+ copy.updateRegion();
3563
3707
  return copy;
3564
3708
  }
3565
3709
  };
@@ -3627,7 +3771,7 @@ var spine = (() => {
3627
3771
  this.uvs = Utils.newFloatArray(8);
3628
3772
  this.tempColor = new Color(1, 1, 1, 1);
3629
3773
  }
3630
- updateOffset() {
3774
+ updateRegion() {
3631
3775
  let region = this.region;
3632
3776
  let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
3633
3777
  let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
@@ -3656,9 +3800,6 @@ var spine = (() => {
3656
3800
  offset[5] = localY2Cos + localX2Sin;
3657
3801
  offset[6] = localX2Cos - localYSin;
3658
3802
  offset[7] = localYCos + localX2Sin;
3659
- }
3660
- setRegion(region) {
3661
- this.region = region;
3662
3803
  let uvs = this.uvs;
3663
3804
  if (region.degrees == 90) {
3664
3805
  uvs[2] = region.u;
@@ -3680,7 +3821,10 @@ var spine = (() => {
3680
3821
  uvs[7] = region.v2;
3681
3822
  }
3682
3823
  }
3683
- computeWorldVertices(bone, worldVertices, offset, stride) {
3824
+ computeWorldVertices(slot, worldVertices, offset, stride) {
3825
+ if (this.sequence != null)
3826
+ this.sequence.apply(slot, this);
3827
+ let bone = slot.bone;
3684
3828
  let vertexOffset = this.offset;
3685
3829
  let x = bone.worldX, y = bone.worldY;
3686
3830
  let a = bone.a, b = bone.b, c = bone.c, d = bone.d;
@@ -3720,6 +3864,7 @@ var spine = (() => {
3720
3864
  Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8);
3721
3865
  Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8);
3722
3866
  copy.color.setFromColor(this.color);
3867
+ copy.sequence = this.sequence.copy();
3723
3868
  return copy;
3724
3869
  }
3725
3870
  };
@@ -3762,22 +3907,40 @@ var spine = (() => {
3762
3907
  constructor(atlas) {
3763
3908
  this.atlas = atlas;
3764
3909
  }
3765
- newRegionAttachment(skin, name, path) {
3766
- let region = this.atlas.findRegion(path);
3767
- if (!region)
3768
- throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
3769
- region.renderObject = region;
3910
+ loadSequence(name, basePath, sequence) {
3911
+ let regions = sequence.regions;
3912
+ for (let i = 0, n = regions.length; i < n; i++) {
3913
+ let path = sequence.getPath(basePath, i);
3914
+ regions[i] = this.atlas.findRegion(path);
3915
+ regions[i].renderObject = regions[i];
3916
+ if (regions[i] == null)
3917
+ throw new Error("Region not found in atlas: " + path + " (sequence: " + name + ")");
3918
+ }
3919
+ }
3920
+ newRegionAttachment(skin, name, path, sequence) {
3770
3921
  let attachment = new RegionAttachment(name);
3771
- attachment.setRegion(region);
3922
+ if (sequence != null) {
3923
+ this.loadSequence(name, path, sequence);
3924
+ } else {
3925
+ let region = this.atlas.findRegion(path);
3926
+ if (!region)
3927
+ throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
3928
+ region.renderObject = region;
3929
+ attachment.region = region;
3930
+ }
3772
3931
  return attachment;
3773
3932
  }
3774
- newMeshAttachment(skin, name, path) {
3775
- let region = this.atlas.findRegion(path);
3776
- if (!region)
3777
- throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
3778
- region.renderObject = region;
3933
+ newMeshAttachment(skin, name, path, sequence) {
3779
3934
  let attachment = new MeshAttachment(name);
3780
- attachment.region = region;
3935
+ if (sequence != null) {
3936
+ this.loadSequence(name, path, sequence);
3937
+ } else {
3938
+ let region = this.atlas.findRegion(path);
3939
+ if (!region)
3940
+ throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
3941
+ region.renderObject = region;
3942
+ attachment.region = region;
3943
+ }
3781
3944
  return attachment;
3782
3945
  }
3783
3946
  newBoundingBoxAttachment(skin, name) {
@@ -5084,17 +5247,11 @@ var spine = (() => {
5084
5247
  setAttachment(attachment) {
5085
5248
  if (this.attachment == attachment)
5086
5249
  return;
5087
- if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.deformAttachment != this.attachment.deformAttachment) {
5250
+ if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.timelineAttahment != this.attachment.timelineAttahment) {
5088
5251
  this.deform.length = 0;
5089
5252
  }
5090
5253
  this.attachment = attachment;
5091
- this.attachmentTime = this.bone.skeleton.time;
5092
- }
5093
- setAttachmentTime(time) {
5094
- this.attachmentTime = this.bone.skeleton.time - time;
5095
- }
5096
- getAttachmentTime() {
5097
- return this.bone.skeleton.time - this.attachmentTime;
5254
+ this.sequenceIndex = -1;
5098
5255
  }
5099
5256
  setToSetupPose() {
5100
5257
  this.color.setFromColor(this.data.color);
@@ -5320,7 +5477,6 @@ var spine = (() => {
5320
5477
  var Skeleton = class {
5321
5478
  constructor(data) {
5322
5479
  this._updateCache = new Array();
5323
- this.time = 0;
5324
5480
  this.scaleX = 1;
5325
5481
  this.scaleY = 1;
5326
5482
  this.x = 0;
@@ -5754,7 +5910,7 @@ var spine = (() => {
5754
5910
  if (attachment instanceof RegionAttachment) {
5755
5911
  verticesLength = 8;
5756
5912
  vertices = Utils.setArraySize(temp, verticesLength, 0);
5757
- attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
5913
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
5758
5914
  } else if (attachment instanceof MeshAttachment) {
5759
5915
  let mesh = attachment;
5760
5916
  verticesLength = mesh.worldVerticesLength;
@@ -5774,9 +5930,6 @@ var spine = (() => {
5774
5930
  offset.set(minX, minY);
5775
5931
  size.set(maxX - minX, maxY - minY);
5776
5932
  }
5777
- update(delta) {
5778
- this.time += delta;
5779
- }
5780
5933
  };
5781
5934
 
5782
5935
  // spine-core/src/SkeletonData.ts
@@ -6228,9 +6381,10 @@ var spine = (() => {
6228
6381
  let linkedMesh = this.linkedMeshes[i];
6229
6382
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
6230
6383
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
6231
- linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent : linkedMesh.mesh;
6384
+ linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6232
6385
  linkedMesh.mesh.setParentMesh(parent);
6233
- linkedMesh.mesh.updateUVs();
6386
+ if (linkedMesh.mesh.region != null)
6387
+ linkedMesh.mesh.updateRegion();
6234
6388
  }
6235
6389
  this.linkedMeshes.length = 0;
6236
6390
  n = input.readInt(true);
@@ -6299,9 +6453,10 @@ var spine = (() => {
6299
6453
  let width = input.readFloat();
6300
6454
  let height = input.readFloat();
6301
6455
  let color = input.readInt32();
6456
+ let sequence = this.readSequence(input);
6302
6457
  if (!path)
6303
6458
  path = name;
6304
- let region = this.attachmentLoader.newRegionAttachment(skin, name, path);
6459
+ let region = this.attachmentLoader.newRegionAttachment(skin, name, path, sequence);
6305
6460
  if (!region)
6306
6461
  return null;
6307
6462
  region.path = path;
@@ -6313,7 +6468,9 @@ var spine = (() => {
6313
6468
  region.width = width * scale;
6314
6469
  region.height = height * scale;
6315
6470
  Color.rgba8888ToColor(region.color, color);
6316
- region.updateOffset();
6471
+ region.sequence = sequence;
6472
+ if (sequence == null)
6473
+ region.updateRegion();
6317
6474
  return region;
6318
6475
  }
6319
6476
  case AttachmentType.BoundingBox: {
@@ -6338,6 +6495,7 @@ var spine = (() => {
6338
6495
  let triangles = this.readShortArray(input);
6339
6496
  let vertices = this.readVertices(input, vertexCount);
6340
6497
  let hullLength = input.readInt(true);
6498
+ let sequence = this.readSequence(input);
6341
6499
  let edges = null;
6342
6500
  let width = 0, height = 0;
6343
6501
  if (nonessential) {
@@ -6347,7 +6505,7 @@ var spine = (() => {
6347
6505
  }
6348
6506
  if (!path)
6349
6507
  path = name;
6350
- let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
6508
+ let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path, sequence);
6351
6509
  if (!mesh)
6352
6510
  return null;
6353
6511
  mesh.path = path;
@@ -6357,8 +6515,10 @@ var spine = (() => {
6357
6515
  mesh.worldVerticesLength = vertexCount << 1;
6358
6516
  mesh.triangles = triangles;
6359
6517
  mesh.regionUVs = uvs;
6360
- mesh.updateUVs();
6518
+ if (sequence == null)
6519
+ mesh.updateRegion();
6361
6520
  mesh.hullLength = hullLength << 1;
6521
+ mesh.sequence = sequence;
6362
6522
  if (nonessential) {
6363
6523
  mesh.edges = edges;
6364
6524
  mesh.width = width * scale;
@@ -6371,7 +6531,8 @@ var spine = (() => {
6371
6531
  let color = input.readInt32();
6372
6532
  let skinName = input.readStringRef();
6373
6533
  let parent = input.readStringRef();
6374
- let inheritDeform = input.readBoolean();
6534
+ let inheritTimelines = input.readBoolean();
6535
+ let sequence = this.readSequence(input);
6375
6536
  let width = 0, height = 0;
6376
6537
  if (nonessential) {
6377
6538
  width = input.readFloat();
@@ -6379,16 +6540,17 @@ var spine = (() => {
6379
6540
  }
6380
6541
  if (!path)
6381
6542
  path = name;
6382
- let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
6543
+ let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path, sequence);
6383
6544
  if (!mesh)
6384
6545
  return null;
6385
6546
  mesh.path = path;
6386
6547
  Color.rgba8888ToColor(mesh.color, color);
6548
+ mesh.sequence = sequence;
6387
6549
  if (nonessential) {
6388
6550
  mesh.width = width * scale;
6389
6551
  mesh.height = height * scale;
6390
6552
  }
6391
- this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent, inheritDeform));
6553
+ this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent, inheritTimelines));
6392
6554
  return mesh;
6393
6555
  }
6394
6556
  case AttachmentType.Path: {
@@ -6447,6 +6609,15 @@ var spine = (() => {
6447
6609
  }
6448
6610
  return null;
6449
6611
  }
6612
+ readSequence(input) {
6613
+ if (!input.readBoolean())
6614
+ return null;
6615
+ let sequence = new Sequence(input.readInt(true));
6616
+ sequence.start = input.readInt(true);
6617
+ sequence.digits = input.readInt(true);
6618
+ sequence.setupIndex = input.readInt(true);
6619
+ return sequence;
6620
+ }
6450
6621
  readVertices(input, vertexCount) {
6451
6622
  let scale = this.scale;
6452
6623
  let verticesLength = vertexCount << 1;
@@ -6689,7 +6860,6 @@ var spine = (() => {
6689
6860
  a = a2;
6690
6861
  }
6691
6862
  timelines.push(timeline);
6692
- break;
6693
6863
  }
6694
6864
  }
6695
6865
  }
@@ -6829,49 +6999,66 @@ var spine = (() => {
6829
6999
  for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
6830
7000
  let attachmentName = input.readStringRef();
6831
7001
  let attachment = skin.getAttachment(slotIndex, attachmentName);
6832
- let weighted = attachment.bones;
6833
- let vertices = attachment.vertices;
6834
- let deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
7002
+ let timelineType = input.readByte();
6835
7003
  let frameCount = input.readInt(true);
6836
7004
  let frameLast = frameCount - 1;
6837
- let bezierCount = input.readInt(true);
6838
- let timeline = new DeformTimeline(frameCount, bezierCount, slotIndex, attachment);
6839
- let time = input.readFloat();
6840
- for (let frame = 0, bezier = 0; ; frame++) {
6841
- let deform;
6842
- let end = input.readInt(true);
6843
- if (end == 0)
6844
- deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
6845
- else {
6846
- deform = Utils.newFloatArray(deformLength);
6847
- let start = input.readInt(true);
6848
- end += start;
6849
- if (scale == 1) {
6850
- for (let v = start; v < end; v++)
6851
- deform[v] = input.readFloat();
6852
- } else {
6853
- for (let v = start; v < end; v++)
6854
- deform[v] = input.readFloat() * scale;
6855
- }
6856
- if (!weighted) {
6857
- for (let v = 0, vn = deform.length; v < vn; v++)
6858
- deform[v] += vertices[v];
7005
+ switch (timelineType) {
7006
+ case ATTACHMENT_DEFORM: {
7007
+ let vertexAttachment = attachment;
7008
+ let weighted = vertexAttachment.bones;
7009
+ let vertices = vertexAttachment.vertices;
7010
+ let deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
7011
+ let bezierCount = input.readInt(true);
7012
+ let timeline = new DeformTimeline(frameCount, bezierCount, slotIndex, vertexAttachment);
7013
+ let time = input.readFloat();
7014
+ for (let frame = 0, bezier = 0; ; frame++) {
7015
+ let deform;
7016
+ let end = input.readInt(true);
7017
+ if (end == 0)
7018
+ deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
7019
+ else {
7020
+ deform = Utils.newFloatArray(deformLength);
7021
+ let start = input.readInt(true);
7022
+ end += start;
7023
+ if (scale == 1) {
7024
+ for (let v = start; v < end; v++)
7025
+ deform[v] = input.readFloat();
7026
+ } else {
7027
+ for (let v = start; v < end; v++)
7028
+ deform[v] = input.readFloat() * scale;
7029
+ }
7030
+ if (!weighted) {
7031
+ for (let v = 0, vn = deform.length; v < vn; v++)
7032
+ deform[v] += vertices[v];
7033
+ }
7034
+ }
7035
+ timeline.setFrame(frame, time, deform);
7036
+ if (frame == frameLast)
7037
+ break;
7038
+ let time2 = input.readFloat();
7039
+ switch (input.readByte()) {
7040
+ case CURVE_STEPPED:
7041
+ timeline.setStepped(frame);
7042
+ break;
7043
+ case CURVE_BEZIER:
7044
+ setBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1);
7045
+ }
7046
+ time = time2;
6859
7047
  }
7048
+ timelines.push(timeline);
7049
+ break;
6860
7050
  }
6861
- timeline.setFrame(frame, time, deform);
6862
- if (frame == frameLast)
7051
+ case ATTACHMENT_SEQUENCE: {
7052
+ let timeline = new SequenceTimeline(frameCount, slotIndex, attachment);
7053
+ for (let frame = 0; frame < frameCount; frame++) {
7054
+ let time = input.readFloat();
7055
+ let modeAndIndex = input.readInt32();
7056
+ timeline.setFrame(frame, time, SequenceModeValues[modeAndIndex & 15], modeAndIndex >> 4, input.readFloat());
7057
+ }
7058
+ timelines.push(timeline);
6863
7059
  break;
6864
- let time2 = input.readFloat();
6865
- switch (input.readByte()) {
6866
- case CURVE_STEPPED:
6867
- timeline.setStepped(frame);
6868
- break;
6869
- case CURVE_BEZIER:
6870
- setBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1);
6871
7060
  }
6872
- time = time2;
6873
7061
  }
6874
- timelines.push(timeline);
6875
7062
  }
6876
7063
  }
6877
7064
  }
@@ -7018,7 +7205,7 @@ var spine = (() => {
7018
7205
  this.skin = skin;
7019
7206
  this.slotIndex = slotIndex;
7020
7207
  this.parent = parent;
7021
- this.inheritDeform = inheritDeform;
7208
+ this.inheritTimeline = inheritDeform;
7022
7209
  }
7023
7210
  };
7024
7211
  var Vertices = class {
@@ -7096,6 +7283,8 @@ var spine = (() => {
7096
7283
  var SLOT_RGBA2 = 3;
7097
7284
  var SLOT_RGB2 = 4;
7098
7285
  var SLOT_ALPHA = 5;
7286
+ var ATTACHMENT_DEFORM = 0;
7287
+ var ATTACHMENT_SEQUENCE = 1;
7099
7288
  var PATH_POSITION = 0;
7100
7289
  var PATH_SPACING = 1;
7101
7290
  var PATH_MIX = 2;
@@ -7931,9 +8120,10 @@ var spine = (() => {
7931
8120
  let linkedMesh = this.linkedMeshes[i];
7932
8121
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
7933
8122
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
7934
- linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent : linkedMesh.mesh;
8123
+ linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
7935
8124
  linkedMesh.mesh.setParentMesh(parent);
7936
- linkedMesh.mesh.updateUVs();
8125
+ if (linkedMesh.mesh.region != null)
8126
+ linkedMesh.mesh.updateRegion();
7937
8127
  }
7938
8128
  this.linkedMeshes.length = 0;
7939
8129
  if (root.events) {
@@ -7965,7 +8155,8 @@ var spine = (() => {
7965
8155
  switch (getValue(map, "type", "region")) {
7966
8156
  case "region": {
7967
8157
  let path = getValue(map, "path", name);
7968
- let region = this.attachmentLoader.newRegionAttachment(skin, name, path);
8158
+ let sequence = this.readSequence(getValue(map, "sequence", null));
8159
+ let region = this.attachmentLoader.newRegionAttachment(skin, name, path, sequence);
7969
8160
  if (!region)
7970
8161
  return null;
7971
8162
  region.path = path;
@@ -7976,10 +8167,12 @@ var spine = (() => {
7976
8167
  region.rotation = getValue(map, "rotation", 0);
7977
8168
  region.width = map.width * scale;
7978
8169
  region.height = map.height * scale;
8170
+ region.sequence = sequence;
7979
8171
  let color = getValue(map, "color", null);
7980
8172
  if (color)
7981
8173
  region.color.setFromString(color);
7982
- region.updateOffset();
8174
+ if (region.region != null)
8175
+ region.updateRegion();
7983
8176
  return region;
7984
8177
  }
7985
8178
  case "boundingbox": {
@@ -7995,7 +8188,8 @@ var spine = (() => {
7995
8188
  case "mesh":
7996
8189
  case "linkedmesh": {
7997
8190
  let path = getValue(map, "path", name);
7998
- let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
8191
+ let sequence = this.readSequence(getValue(map, "sequence", null));
8192
+ let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path, sequence);
7999
8193
  if (!mesh)
8000
8194
  return null;
8001
8195
  mesh.path = path;
@@ -8004,16 +8198,18 @@ var spine = (() => {
8004
8198
  mesh.color.setFromString(color);
8005
8199
  mesh.width = getValue(map, "width", 0) * scale;
8006
8200
  mesh.height = getValue(map, "height", 0) * scale;
8201
+ mesh.sequence = sequence;
8007
8202
  let parent = getValue(map, "parent", null);
8008
8203
  if (parent) {
8009
- this.linkedMeshes.push(new LinkedMesh2(mesh, getValue(map, "skin", null), slotIndex, parent, getValue(map, "deform", true)));
8204
+ this.linkedMeshes.push(new LinkedMesh2(mesh, getValue(map, "skin", null), slotIndex, parent, getValue(map, "timelines", true)));
8010
8205
  return mesh;
8011
8206
  }
8012
8207
  let uvs = map.uvs;
8013
8208
  this.readVertices(map, mesh, uvs.length);
8014
8209
  mesh.triangles = map.triangles;
8015
8210
  mesh.regionUVs = uvs;
8016
- mesh.updateUVs();
8211
+ if (mesh.region != null)
8212
+ mesh.updateRegion();
8017
8213
  mesh.edges = getValue(map, "edges", null);
8018
8214
  mesh.hullLength = getValue(map, "hull", 0) * 2;
8019
8215
  return mesh;
@@ -8064,6 +8260,15 @@ var spine = (() => {
8064
8260
  }
8065
8261
  return null;
8066
8262
  }
8263
+ readSequence(map) {
8264
+ if (map == null)
8265
+ return null;
8266
+ let sequence = new Sequence(getValue(map, "count", 0));
8267
+ sequence.start = getValue(map, "start", 1);
8268
+ sequence.digits = getValue(map, "digits", 0);
8269
+ sequence.setupIndex = getValue(map, "setup", 0);
8270
+ return sequence;
8271
+ }
8067
8272
  readVertices(map, attachment, verticesLength) {
8068
8273
  let scale = this.scale;
8069
8274
  attachment.worldVerticesLength = verticesLength;
@@ -8108,7 +8313,7 @@ var spine = (() => {
8108
8313
  let timeline = new AttachmentTimeline(frames, slotIndex);
8109
8314
  for (let frame = 0; frame < frames; frame++) {
8110
8315
  let keyMap = timelineMap[frame];
8111
- timeline.setFrame(frame, getValue(keyMap, "time", 0), keyMap.name);
8316
+ timeline.setFrame(frame, getValue(keyMap, "time", 0), getValue(keyMap, "name", null));
8112
8317
  }
8113
8318
  timelines.push(timeline);
8114
8319
  } else if (timelineName == "rgba") {
@@ -8410,56 +8615,74 @@ var spine = (() => {
8410
8615
  }
8411
8616
  }
8412
8617
  }
8413
- if (map.deform) {
8414
- for (let deformName in map.deform) {
8415
- let deformMap = map.deform[deformName];
8416
- let skin = skeletonData.findSkin(deformName);
8417
- for (let slotName in deformMap) {
8418
- let slotMap = deformMap[slotName];
8419
- let slotIndex = skeletonData.findSlot(slotName).index;
8420
- for (let timelineName in slotMap) {
8421
- let timelineMap = slotMap[timelineName];
8422
- let keyMap = timelineMap[0];
8423
- if (!keyMap)
8424
- continue;
8425
- let attachment = skin.getAttachment(slotIndex, timelineName);
8426
- let weighted = attachment.bones;
8427
- let vertices = attachment.vertices;
8428
- let deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
8429
- let timeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, attachment);
8430
- let time = getValue(keyMap, "time", 0);
8431
- for (let frame = 0, bezier = 0; ; frame++) {
8432
- let deform;
8433
- let verticesValue = getValue(keyMap, "vertices", null);
8434
- if (!verticesValue)
8435
- deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
8436
- else {
8437
- deform = Utils.newFloatArray(deformLength);
8438
- let start = getValue(keyMap, "offset", 0);
8439
- Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
8440
- if (scale != 1) {
8441
- for (let i = start, n = i + verticesValue.length; i < n; i++)
8442
- deform[i] *= scale;
8618
+ if (map.attachments) {
8619
+ for (let attachmentsName in map.attachments) {
8620
+ let attachmentsMap = map.attachments[attachmentsName];
8621
+ let skin = skeletonData.findSkin(attachmentsName);
8622
+ for (let slotMapName in attachmentsMap) {
8623
+ let slotMap = attachmentsMap[slotMapName];
8624
+ let slotIndex = skeletonData.findSlot(slotMapName).index;
8625
+ for (let attachmentMapName in slotMap) {
8626
+ let attachmentMap = slotMap[attachmentMapName];
8627
+ let attachment = skin.getAttachment(slotIndex, attachmentMapName);
8628
+ for (let timelineMapName in attachmentMap) {
8629
+ let timelineMap = attachmentMap[timelineMapName];
8630
+ let keyMap = timelineMap[0];
8631
+ if (!keyMap)
8632
+ continue;
8633
+ if (timelineMapName == "deform") {
8634
+ let weighted = attachment.bones;
8635
+ let vertices = attachment.vertices;
8636
+ let deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
8637
+ let timeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, attachment);
8638
+ let time = getValue(keyMap, "time", 0);
8639
+ for (let frame = 0, bezier = 0; ; frame++) {
8640
+ let deform;
8641
+ let verticesValue = getValue(keyMap, "vertices", null);
8642
+ if (!verticesValue)
8643
+ deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
8644
+ else {
8645
+ deform = Utils.newFloatArray(deformLength);
8646
+ let start = getValue(keyMap, "offset", 0);
8647
+ Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
8648
+ if (scale != 1) {
8649
+ for (let i = start, n = i + verticesValue.length; i < n; i++)
8650
+ deform[i] *= scale;
8651
+ }
8652
+ if (!weighted) {
8653
+ for (let i = 0; i < deformLength; i++)
8654
+ deform[i] += vertices[i];
8655
+ }
8656
+ }
8657
+ timeline.setFrame(frame, time, deform);
8658
+ let nextMap = timelineMap[frame + 1];
8659
+ if (!nextMap) {
8660
+ timeline.shrink(bezier);
8661
+ break;
8662
+ }
8663
+ let time2 = getValue(nextMap, "time", 0);
8664
+ let curve = keyMap.curve;
8665
+ if (curve)
8666
+ bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, 0, 1, 1);
8667
+ time = time2;
8668
+ keyMap = nextMap;
8443
8669
  }
8444
- if (!weighted) {
8445
- for (let i = 0; i < deformLength; i++)
8446
- deform[i] += vertices[i];
8670
+ timelines.push(timeline);
8671
+ } else if (timelineMapName == "sequence") {
8672
+ let timeline = new SequenceTimeline(timelineMap.length, slotIndex, attachment);
8673
+ let lastDelay = 0;
8674
+ for (let frame = 0; frame < timelineMap.length; frame++) {
8675
+ let delay = getValue(keyMap, "delay", lastDelay);
8676
+ let time = getValue(keyMap, "time", 0);
8677
+ let mode = SequenceMode[getValue(keyMap, "mode", "hold")];
8678
+ let index = getValue(keyMap, "index", 0);
8679
+ timeline.setFrame(frame, time, mode, index, delay);
8680
+ lastDelay = delay;
8681
+ keyMap = timelineMap[frame + 1];
8447
8682
  }
8683
+ timelines.push(timeline);
8448
8684
  }
8449
- timeline.setFrame(frame, time, deform);
8450
- let nextMap = timelineMap[frame + 1];
8451
- if (!nextMap) {
8452
- timeline.shrink(bezier);
8453
- break;
8454
- }
8455
- let time2 = getValue(nextMap, "time", 0);
8456
- let curve = keyMap.curve;
8457
- if (curve)
8458
- bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, 0, 1, 1);
8459
- time = time2;
8460
- keyMap = nextMap;
8461
8685
  }
8462
- timelines.push(timeline);
8463
8686
  }
8464
8687
  }
8465
8688
  }
@@ -8523,7 +8746,7 @@ var spine = (() => {
8523
8746
  this.skin = skin;
8524
8747
  this.slotIndex = slotIndex;
8525
8748
  this.parent = parent;
8526
- this.inheritDeform = inheritDeform;
8749
+ this.inheritTimeline = inheritDeform;
8527
8750
  }
8528
8751
  };
8529
8752
  function readTimeline12(keys, timeline, defaultValue, scale) {
@@ -8827,7 +9050,7 @@ var spine = (() => {
8827
9050
  let multiplier = pma ? alpha : 1;
8828
9051
  let color = this.tempColor;
8829
9052
  color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
8830
- region.computeWorldVertices(slot.bone, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
9053
+ region.computeWorldVertices(slot, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
8831
9054
  let vertices = this.vertices;
8832
9055
  let uvs = region.uvs;
8833
9056
  vertices[RegionAttachment.C1R] = color.r;