@esotericsoftware/spine-canvas 4.2.25 → 4.2.27

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.
@@ -4,6 +4,7 @@ var spine = (() => {
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,6 +18,10 @@ var spine = (() => {
17
18
  return to;
18
19
  };
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var __publicField = (obj, key, value) => {
22
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
+ return value;
24
+ };
20
25
 
21
26
  // spine-canvas/src/index.ts
22
27
  var src_exports = {};
@@ -73,6 +78,16 @@ var spine = (() => {
73
78
  PathConstraintMixTimeline: () => PathConstraintMixTimeline,
74
79
  PathConstraintPositionTimeline: () => PathConstraintPositionTimeline,
75
80
  PathConstraintSpacingTimeline: () => PathConstraintSpacingTimeline,
81
+ Physics: () => Physics,
82
+ PhysicsConstraintDampingTimeline: () => PhysicsConstraintDampingTimeline,
83
+ PhysicsConstraintGravityTimeline: () => PhysicsConstraintGravityTimeline,
84
+ PhysicsConstraintInertiaTimeline: () => PhysicsConstraintInertiaTimeline,
85
+ PhysicsConstraintMassTimeline: () => PhysicsConstraintMassTimeline,
86
+ PhysicsConstraintMixTimeline: () => PhysicsConstraintMixTimeline,
87
+ PhysicsConstraintResetTimeline: () => PhysicsConstraintResetTimeline,
88
+ PhysicsConstraintStrengthTimeline: () => PhysicsConstraintStrengthTimeline,
89
+ PhysicsConstraintTimeline: () => PhysicsConstraintTimeline,
90
+ PhysicsConstraintWindTimeline: () => PhysicsConstraintWindTimeline,
76
91
  PointAttachment: () => PointAttachment,
77
92
  Pool: () => Pool,
78
93
  PositionMode: () => PositionMode,
@@ -94,7 +109,7 @@ var spine = (() => {
94
109
  ShearTimeline: () => ShearTimeline,
95
110
  ShearXTimeline: () => ShearXTimeline,
96
111
  ShearYTimeline: () => ShearYTimeline,
97
- Skeleton: () => Skeleton,
112
+ Skeleton: () => Skeleton2,
98
113
  SkeletonBinary: () => SkeletonBinary,
99
114
  SkeletonBounds: () => SkeletonBounds,
100
115
  SkeletonClipping: () => SkeletonClipping,
@@ -133,9 +148,7 @@ var spine = (() => {
133
148
 
134
149
  // spine-core/src/Utils.ts
135
150
  var IntSet = class {
136
- constructor() {
137
- this.array = new Array();
138
- }
151
+ array = new Array();
139
152
  add(value) {
140
153
  let contains = this.contains(value);
141
154
  this.array[value | 0] = value | 0;
@@ -152,10 +165,8 @@ var spine = (() => {
152
165
  }
153
166
  };
154
167
  var StringSet = class {
155
- constructor() {
156
- this.entries = {};
157
- this.size = 0;
158
- }
168
+ entries = {};
169
+ size = 0;
159
170
  add(value) {
160
171
  let contains = this.entries[value];
161
172
  this.entries[value] = true;
@@ -250,11 +261,11 @@ var spine = (() => {
250
261
  }
251
262
  };
252
263
  var Color = _Color;
253
- Color.WHITE = new _Color(1, 1, 1, 1);
254
- Color.RED = new _Color(1, 0, 0, 1);
255
- Color.GREEN = new _Color(0, 1, 0, 1);
256
- Color.BLUE = new _Color(0, 0, 1, 1);
257
- Color.MAGENTA = new _Color(1, 0, 1, 1);
264
+ __publicField(Color, "WHITE", new _Color(1, 1, 1, 1));
265
+ __publicField(Color, "RED", new _Color(1, 0, 0, 1));
266
+ __publicField(Color, "GREEN", new _Color(0, 1, 0, 1));
267
+ __publicField(Color, "BLUE", new _Color(0, 0, 1, 1));
268
+ __publicField(Color, "MAGENTA", new _Color(1, 0, 1, 1));
258
269
  var _MathUtils = class {
259
270
  static clamp(value, min, max) {
260
271
  if (value < min)
@@ -269,6 +280,9 @@ var spine = (() => {
269
280
  static sinDeg(degrees) {
270
281
  return Math.sin(degrees * _MathUtils.degRad);
271
282
  }
283
+ static atan2Deg(y, x) {
284
+ return Math.atan2(y, x) * _MathUtils.degRad;
285
+ }
272
286
  static signum(value) {
273
287
  return value > 0 ? 1 : value < 0 ? -1 : 0;
274
288
  }
@@ -294,21 +308,22 @@ var spine = (() => {
294
308
  }
295
309
  };
296
310
  var MathUtils = _MathUtils;
297
- MathUtils.PI = 3.1415927;
298
- MathUtils.PI2 = _MathUtils.PI * 2;
299
- MathUtils.radiansToDegrees = 180 / _MathUtils.PI;
300
- MathUtils.radDeg = _MathUtils.radiansToDegrees;
301
- MathUtils.degreesToRadians = _MathUtils.PI / 180;
302
- MathUtils.degRad = _MathUtils.degreesToRadians;
311
+ __publicField(MathUtils, "PI", 3.1415927);
312
+ __publicField(MathUtils, "PI2", _MathUtils.PI * 2);
313
+ __publicField(MathUtils, "invPI2", 1 / _MathUtils.PI2);
314
+ __publicField(MathUtils, "radiansToDegrees", 180 / _MathUtils.PI);
315
+ __publicField(MathUtils, "radDeg", _MathUtils.radiansToDegrees);
316
+ __publicField(MathUtils, "degreesToRadians", _MathUtils.PI / 180);
317
+ __publicField(MathUtils, "degRad", _MathUtils.degreesToRadians);
303
318
  var Interpolation = class {
304
319
  apply(start, end, a) {
305
320
  return start + (end - start) * this.applyInternal(a);
306
321
  }
307
322
  };
308
323
  var Pow = class extends Interpolation {
324
+ power = 2;
309
325
  constructor(power) {
310
326
  super();
311
- this.power = 2;
312
327
  this.power = power;
313
328
  }
314
329
  applyInternal(a) {
@@ -397,7 +412,7 @@ var spine = (() => {
397
412
  }
398
413
  };
399
414
  var Utils = _Utils;
400
- Utils.SUPPORTS_TYPED_ARRAYS = typeof Float32Array !== "undefined";
415
+ __publicField(Utils, "SUPPORTS_TYPED_ARRAYS", typeof Float32Array !== "undefined");
401
416
  var DebugUtils = class {
402
417
  static logBones(skeleton) {
403
418
  for (let i = 0; i < skeleton.bones.length; i++) {
@@ -407,8 +422,9 @@ var spine = (() => {
407
422
  }
408
423
  };
409
424
  var Pool = class {
425
+ items = new Array();
426
+ instantiator;
410
427
  constructor(instantiator) {
411
- this.items = new Array();
412
428
  this.instantiator = instantiator;
413
429
  }
414
430
  obtain() {
@@ -452,15 +468,13 @@ var spine = (() => {
452
468
  }
453
469
  };
454
470
  var TimeKeeper = class {
455
- constructor() {
456
- this.maxDelta = 0.064;
457
- this.framesPerSecond = 0;
458
- this.delta = 0;
459
- this.totalTime = 0;
460
- this.lastTime = Date.now() / 1e3;
461
- this.frameCount = 0;
462
- this.frameTime = 0;
463
- }
471
+ maxDelta = 0.064;
472
+ framesPerSecond = 0;
473
+ delta = 0;
474
+ totalTime = 0;
475
+ lastTime = Date.now() / 1e3;
476
+ frameCount = 0;
477
+ frameTime = 0;
464
478
  update() {
465
479
  let now = Date.now() / 1e3;
466
480
  this.delta = now - this.lastTime;
@@ -478,11 +492,12 @@ var spine = (() => {
478
492
  }
479
493
  };
480
494
  var WindowedMean = class {
495
+ values;
496
+ addedValues = 0;
497
+ lastValue = 0;
498
+ mean = 0;
499
+ dirty = true;
481
500
  constructor(windowSize = 32) {
482
- this.addedValues = 0;
483
- this.lastValue = 0;
484
- this.mean = 0;
485
- this.dirty = true;
486
501
  this.values = new Array(windowSize);
487
502
  }
488
503
  hasEnoughData() {
@@ -513,6 +528,7 @@ var spine = (() => {
513
528
 
514
529
  // spine-core/src/attachments/Attachment.ts
515
530
  var Attachment = class {
531
+ name;
516
532
  constructor(name) {
517
533
  if (!name)
518
534
  throw new Error("name cannot be null.");
@@ -520,24 +536,24 @@ var spine = (() => {
520
536
  }
521
537
  };
522
538
  var _VertexAttachment = class extends Attachment {
539
+ /** The unique ID for this attachment. */
540
+ id = _VertexAttachment.nextID++;
541
+ /** The bones which affect the {@link #getVertices()}. The array entries are, for each vertex, the number of bones affecting
542
+ * the vertex followed by that many bone indices, which is the index of the bone in {@link Skeleton#bones}. Will be null
543
+ * if this attachment has no weights. */
544
+ bones = null;
545
+ /** The vertex positions in the bone's coordinate system. For a non-weighted attachment, the values are `x,y`
546
+ * entries for each vertex. For a weighted attachment, the values are `x,y,weight` entries for each bone affecting
547
+ * each vertex. */
548
+ vertices = [];
549
+ /** The maximum number of world vertex values that can be output by
550
+ * {@link #computeWorldVertices()} using the `count` parameter. */
551
+ worldVerticesLength = 0;
552
+ /** Timelines for the timeline attachment are also applied to this attachment.
553
+ * May be null if no attachment-specific timelines should be applied. */
554
+ timelineAttachment = this;
523
555
  constructor(name) {
524
556
  super(name);
525
- /** The unique ID for this attachment. */
526
- this.id = _VertexAttachment.nextID++;
527
- /** The bones which affect the {@link #getVertices()}. The array entries are, for each vertex, the number of bones affecting
528
- * the vertex followed by that many bone indices, which is the index of the bone in {@link Skeleton#bones}. Will be null
529
- * if this attachment has no weights. */
530
- this.bones = null;
531
- /** The vertex positions in the bone's coordinate system. For a non-weighted attachment, the values are `x,y`
532
- * entries for each vertex. For a weighted attachment, the values are `x,y,weight` entries for each bone affecting
533
- * each vertex. */
534
- this.vertices = [];
535
- /** The maximum number of world vertex values that can be output by
536
- * {@link #computeWorldVertices()} using the `count` parameter. */
537
- this.worldVerticesLength = 0;
538
- /** Timelines for the timeline attachment are also applied to this attachment.
539
- * May be null if no attachment-specific timelines should be applied. */
540
- this.timelineAttachment = this;
541
557
  }
542
558
  /** Transforms the attachment's local {@link #vertices} to world coordinates. If the slot's {@link Slot#deform} is
543
559
  * not empty, it is used to deform the vertices.
@@ -624,16 +640,17 @@ var spine = (() => {
624
640
  }
625
641
  };
626
642
  var VertexAttachment = _VertexAttachment;
627
- VertexAttachment.nextID = 0;
643
+ __publicField(VertexAttachment, "nextID", 0);
628
644
 
629
645
  // spine-core/src/attachments/Sequence.ts
630
646
  var _Sequence = class {
647
+ id = _Sequence.nextID();
648
+ regions;
649
+ start = 0;
650
+ digits = 0;
651
+ /** The index of the region to show for the setup pose. */
652
+ setupIndex = 0;
631
653
  constructor(count) {
632
- this.id = _Sequence.nextID();
633
- this.start = 0;
634
- this.digits = 0;
635
- /** The index of the region to show for the setup pose. */
636
- this.setupIndex = 0;
637
654
  this.regions = new Array(count);
638
655
  }
639
656
  copy() {
@@ -669,7 +686,7 @@ var spine = (() => {
669
686
  }
670
687
  };
671
688
  var Sequence = _Sequence;
672
- Sequence._nextID = 0;
689
+ __publicField(Sequence, "_nextID", 0);
673
690
  var SequenceMode = /* @__PURE__ */ ((SequenceMode2) => {
674
691
  SequenceMode2[SequenceMode2["hold"] = 0] = "hold";
675
692
  SequenceMode2[SequenceMode2["once"] = 1] = "once";
@@ -692,9 +709,13 @@ var spine = (() => {
692
709
 
693
710
  // spine-core/src/Animation.ts
694
711
  var Animation = class {
712
+ /** The animation's name, which is unique across all animations in the skeleton. */
713
+ name;
714
+ timelines = [];
715
+ timelineIds = new StringSet();
716
+ /** The duration of the animation in seconds, which is the highest time of all keys in the timeline. */
717
+ duration;
695
718
  constructor(name, timelines, duration) {
696
- this.timelines = [];
697
- this.timelineIds = new StringSet();
698
719
  if (!name)
699
720
  throw new Error("name cannot be null.");
700
721
  this.name = name;
@@ -765,9 +786,19 @@ var spine = (() => {
765
786
  pathConstraintPosition: 16,
766
787
  pathConstraintSpacing: 17,
767
788
  pathConstraintMix: 18,
768
- sequence: 19
789
+ physicsConstraintInertia: 19,
790
+ physicsConstraintStrength: 20,
791
+ physicsConstraintDamping: 21,
792
+ physicsConstraintMass: 22,
793
+ physicsConstraintWind: 23,
794
+ physicsConstraintGravity: 24,
795
+ physicsConstraintMix: 25,
796
+ physicsConstraintReset: 26,
797
+ sequence: 27
769
798
  };
770
799
  var Timeline = class {
800
+ propertyIds;
801
+ frames;
771
802
  constructor(frameCount, propertyIds) {
772
803
  this.propertyIds = propertyIds;
773
804
  this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());
@@ -800,6 +831,7 @@ var spine = (() => {
800
831
  }
801
832
  };
802
833
  var CurveTimeline = class extends Timeline {
834
+ curves;
803
835
  // type, x, y, ...
804
836
  constructor(frameCount, bezierCount, propertyIds) {
805
837
  super(frameCount, propertyIds);
@@ -940,6 +972,94 @@ var spine = (() => {
940
972
  /*BEZIER*/
941
973
  );
942
974
  }
975
+ getRelativeValue(time, alpha, blend, current, setup) {
976
+ if (time < this.frames[0]) {
977
+ switch (blend) {
978
+ case 0 /* setup */:
979
+ return setup;
980
+ case 1 /* first */:
981
+ return current + (setup - current) * alpha;
982
+ }
983
+ return current;
984
+ }
985
+ let value = this.getCurveValue(time);
986
+ switch (blend) {
987
+ case 0 /* setup */:
988
+ return setup + value * alpha;
989
+ case 1 /* first */:
990
+ case 2 /* replace */:
991
+ value += setup - current;
992
+ }
993
+ return current + value * alpha;
994
+ }
995
+ getAbsoluteValue(time, alpha, blend, current, setup) {
996
+ if (time < this.frames[0]) {
997
+ switch (blend) {
998
+ case 0 /* setup */:
999
+ return setup;
1000
+ case 1 /* first */:
1001
+ return current + (setup - current) * alpha;
1002
+ }
1003
+ return current;
1004
+ }
1005
+ let value = this.getCurveValue(time);
1006
+ if (blend == 0 /* setup */)
1007
+ return setup + (value - setup) * alpha;
1008
+ return current + (value - current) * alpha;
1009
+ }
1010
+ getAbsoluteValue2(time, alpha, blend, current, setup, value) {
1011
+ if (time < this.frames[0]) {
1012
+ switch (blend) {
1013
+ case 0 /* setup */:
1014
+ return setup;
1015
+ case 1 /* first */:
1016
+ return current + (setup - current) * alpha;
1017
+ }
1018
+ return current;
1019
+ }
1020
+ if (blend == 0 /* setup */)
1021
+ return setup + (value - setup) * alpha;
1022
+ return current + (value - current) * alpha;
1023
+ }
1024
+ getScaleValue(time, alpha, blend, direction, current, setup) {
1025
+ const frames = this.frames;
1026
+ if (time < frames[0]) {
1027
+ switch (blend) {
1028
+ case 0 /* setup */:
1029
+ return setup;
1030
+ case 1 /* first */:
1031
+ return current + (setup - current) * alpha;
1032
+ }
1033
+ return current;
1034
+ }
1035
+ let value = this.getCurveValue(time) * setup;
1036
+ if (alpha == 1) {
1037
+ if (blend == 3 /* add */)
1038
+ return current + value - setup;
1039
+ return value;
1040
+ }
1041
+ if (direction == 1 /* mixOut */) {
1042
+ switch (blend) {
1043
+ case 0 /* setup */:
1044
+ return setup + (Math.abs(value) * MathUtils.signum(setup) - setup) * alpha;
1045
+ case 1 /* first */:
1046
+ case 2 /* replace */:
1047
+ return current + (Math.abs(value) * MathUtils.signum(current) - current) * alpha;
1048
+ }
1049
+ } else {
1050
+ let s = 0;
1051
+ switch (blend) {
1052
+ case 0 /* setup */:
1053
+ s = Math.abs(setup) * MathUtils.signum(value);
1054
+ return s + (value - s) * alpha;
1055
+ case 1 /* first */:
1056
+ case 2 /* replace */:
1057
+ s = Math.abs(current) * MathUtils.signum(value);
1058
+ return s + (value - s) * alpha;
1059
+ }
1060
+ }
1061
+ return current + (value - setup) * alpha;
1062
+ }
943
1063
  };
944
1064
  var CurveTimeline2 = class extends CurveTimeline {
945
1065
  /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
@@ -967,40 +1087,19 @@ var spine = (() => {
967
1087
  }
968
1088
  };
969
1089
  var RotateTimeline = class extends CurveTimeline1 {
1090
+ boneIndex = 0;
970
1091
  constructor(frameCount, bezierCount, boneIndex) {
971
1092
  super(frameCount, bezierCount, Property.rotate + "|" + boneIndex);
972
- this.boneIndex = 0;
973
1093
  this.boneIndex = boneIndex;
974
1094
  }
975
1095
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
976
1096
  let bone = skeleton.bones[this.boneIndex];
977
- if (!bone.active)
978
- return;
979
- let frames = this.frames;
980
- if (time < frames[0]) {
981
- switch (blend) {
982
- case 0 /* setup */:
983
- bone.rotation = bone.data.rotation;
984
- return;
985
- case 1 /* first */:
986
- bone.rotation += (bone.data.rotation - bone.rotation) * alpha;
987
- }
988
- return;
989
- }
990
- let r = this.getCurveValue(time);
991
- switch (blend) {
992
- case 0 /* setup */:
993
- bone.rotation = bone.data.rotation + r * alpha;
994
- break;
995
- case 1 /* first */:
996
- case 2 /* replace */:
997
- r += bone.data.rotation - bone.rotation;
998
- case 3 /* add */:
999
- bone.rotation += r * alpha;
1000
- }
1097
+ if (bone.active)
1098
+ bone.rotation = this.getRelativeValue(time, alpha, blend, bone.rotation, bone.data.rotation);
1001
1099
  }
1002
1100
  };
1003
1101
  var TranslateTimeline = class extends CurveTimeline2 {
1102
+ boneIndex = 0;
1004
1103
  constructor(frameCount, bezierCount, boneIndex) {
1005
1104
  super(
1006
1105
  frameCount,
@@ -1008,7 +1107,6 @@ var spine = (() => {
1008
1107
  Property.x + "|" + boneIndex,
1009
1108
  Property.y + "|" + boneIndex
1010
1109
  );
1011
- this.boneIndex = 0;
1012
1110
  this.boneIndex = boneIndex;
1013
1111
  }
1014
1112
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
@@ -1106,76 +1204,31 @@ var spine = (() => {
1106
1204
  }
1107
1205
  };
1108
1206
  var TranslateXTimeline = class extends CurveTimeline1 {
1207
+ boneIndex = 0;
1109
1208
  constructor(frameCount, bezierCount, boneIndex) {
1110
1209
  super(frameCount, bezierCount, Property.x + "|" + boneIndex);
1111
- this.boneIndex = 0;
1112
1210
  this.boneIndex = boneIndex;
1113
1211
  }
1114
1212
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1115
1213
  let bone = skeleton.bones[this.boneIndex];
1116
- if (!bone.active)
1117
- return;
1118
- let frames = this.frames;
1119
- if (time < frames[0]) {
1120
- switch (blend) {
1121
- case 0 /* setup */:
1122
- bone.x = bone.data.x;
1123
- return;
1124
- case 1 /* first */:
1125
- bone.x += (bone.data.x - bone.x) * alpha;
1126
- }
1127
- return;
1128
- }
1129
- let x = this.getCurveValue(time);
1130
- switch (blend) {
1131
- case 0 /* setup */:
1132
- bone.x = bone.data.x + x * alpha;
1133
- break;
1134
- case 1 /* first */:
1135
- case 2 /* replace */:
1136
- bone.x += (bone.data.x + x - bone.x) * alpha;
1137
- break;
1138
- case 3 /* add */:
1139
- bone.x += x * alpha;
1140
- }
1214
+ if (bone.active)
1215
+ bone.x = this.getRelativeValue(time, alpha, blend, bone.x, bone.data.x);
1141
1216
  }
1142
1217
  };
1143
1218
  var TranslateYTimeline = class extends CurveTimeline1 {
1219
+ boneIndex = 0;
1144
1220
  constructor(frameCount, bezierCount, boneIndex) {
1145
1221
  super(frameCount, bezierCount, Property.y + "|" + boneIndex);
1146
- this.boneIndex = 0;
1147
1222
  this.boneIndex = boneIndex;
1148
1223
  }
1149
1224
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1150
1225
  let bone = skeleton.bones[this.boneIndex];
1151
- if (!bone.active)
1152
- return;
1153
- let frames = this.frames;
1154
- if (time < frames[0]) {
1155
- switch (blend) {
1156
- case 0 /* setup */:
1157
- bone.y = bone.data.y;
1158
- return;
1159
- case 1 /* first */:
1160
- bone.y += (bone.data.y - bone.y) * alpha;
1161
- }
1162
- return;
1163
- }
1164
- let y = this.getCurveValue(time);
1165
- switch (blend) {
1166
- case 0 /* setup */:
1167
- bone.y = bone.data.y + y * alpha;
1168
- break;
1169
- case 1 /* first */:
1170
- case 2 /* replace */:
1171
- bone.y += (bone.data.y + y - bone.y) * alpha;
1172
- break;
1173
- case 3 /* add */:
1174
- bone.y += y * alpha;
1175
- }
1226
+ if (bone.active)
1227
+ bone.y = this.getRelativeValue(time, alpha, blend, bone.y, bone.data.y);
1176
1228
  }
1177
1229
  };
1178
1230
  var ScaleTimeline = class extends CurveTimeline2 {
1231
+ boneIndex = 0;
1179
1232
  constructor(frameCount, bezierCount, boneIndex) {
1180
1233
  super(
1181
1234
  frameCount,
@@ -1183,7 +1236,6 @@ var spine = (() => {
1183
1236
  Property.scaleX + "|" + boneIndex,
1184
1237
  Property.scaleY + "|" + boneIndex
1185
1238
  );
1186
- this.boneIndex = 0;
1187
1239
  this.boneIndex = boneIndex;
1188
1240
  }
1189
1241
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
@@ -1319,128 +1371,31 @@ var spine = (() => {
1319
1371
  }
1320
1372
  };
1321
1373
  var ScaleXTimeline = class extends CurveTimeline1 {
1374
+ boneIndex = 0;
1322
1375
  constructor(frameCount, bezierCount, boneIndex) {
1323
1376
  super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex);
1324
- this.boneIndex = 0;
1325
1377
  this.boneIndex = boneIndex;
1326
1378
  }
1327
1379
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1328
1380
  let bone = skeleton.bones[this.boneIndex];
1329
- if (!bone.active)
1330
- return;
1331
- let frames = this.frames;
1332
- if (time < frames[0]) {
1333
- switch (blend) {
1334
- case 0 /* setup */:
1335
- bone.scaleX = bone.data.scaleX;
1336
- return;
1337
- case 1 /* first */:
1338
- bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
1339
- }
1340
- return;
1341
- }
1342
- let x = this.getCurveValue(time) * bone.data.scaleX;
1343
- if (alpha == 1) {
1344
- if (blend == 3 /* add */)
1345
- bone.scaleX += x - bone.data.scaleX;
1346
- else
1347
- bone.scaleX = x;
1348
- } else {
1349
- let bx = 0;
1350
- if (direction == 1 /* mixOut */) {
1351
- switch (blend) {
1352
- case 0 /* setup */:
1353
- bx = bone.data.scaleX;
1354
- bone.scaleX = bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
1355
- break;
1356
- case 1 /* first */:
1357
- case 2 /* replace */:
1358
- bx = bone.scaleX;
1359
- bone.scaleX = bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
1360
- break;
1361
- case 3 /* add */:
1362
- bone.scaleX += (x - bone.data.scaleX) * alpha;
1363
- }
1364
- } else {
1365
- switch (blend) {
1366
- case 0 /* setup */:
1367
- bx = Math.abs(bone.data.scaleX) * MathUtils.signum(x);
1368
- bone.scaleX = bx + (x - bx) * alpha;
1369
- break;
1370
- case 1 /* first */:
1371
- case 2 /* replace */:
1372
- bx = Math.abs(bone.scaleX) * MathUtils.signum(x);
1373
- bone.scaleX = bx + (x - bx) * alpha;
1374
- break;
1375
- case 3 /* add */:
1376
- bone.scaleX += (x - bone.data.scaleX) * alpha;
1377
- }
1378
- }
1379
- }
1381
+ if (bone.active)
1382
+ bone.scaleX = this.getScaleValue(time, alpha, blend, direction, bone.scaleX, bone.data.scaleX);
1380
1383
  }
1381
1384
  };
1382
1385
  var ScaleYTimeline = class extends CurveTimeline1 {
1386
+ boneIndex = 0;
1383
1387
  constructor(frameCount, bezierCount, boneIndex) {
1384
1388
  super(frameCount, bezierCount, Property.scaleY + "|" + boneIndex);
1385
- this.boneIndex = 0;
1386
1389
  this.boneIndex = boneIndex;
1387
1390
  }
1388
1391
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1389
1392
  let bone = skeleton.bones[this.boneIndex];
1390
- if (!bone.active)
1391
- return;
1392
- let frames = this.frames;
1393
- if (time < frames[0]) {
1394
- switch (blend) {
1395
- case 0 /* setup */:
1396
- bone.scaleY = bone.data.scaleY;
1397
- return;
1398
- case 1 /* first */:
1399
- bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
1400
- }
1401
- return;
1402
- }
1403
- let y = this.getCurveValue(time) * bone.data.scaleY;
1404
- if (alpha == 1) {
1405
- if (blend == 3 /* add */)
1406
- bone.scaleY += y - bone.data.scaleY;
1407
- else
1408
- bone.scaleY = y;
1409
- } else {
1410
- let by = 0;
1411
- if (direction == 1 /* mixOut */) {
1412
- switch (blend) {
1413
- case 0 /* setup */:
1414
- by = bone.data.scaleY;
1415
- bone.scaleY = by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
1416
- break;
1417
- case 1 /* first */:
1418
- case 2 /* replace */:
1419
- by = bone.scaleY;
1420
- bone.scaleY = by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
1421
- break;
1422
- case 3 /* add */:
1423
- bone.scaleY += (y - bone.data.scaleY) * alpha;
1424
- }
1425
- } else {
1426
- switch (blend) {
1427
- case 0 /* setup */:
1428
- by = Math.abs(bone.data.scaleY) * MathUtils.signum(y);
1429
- bone.scaleY = by + (y - by) * alpha;
1430
- break;
1431
- case 1 /* first */:
1432
- case 2 /* replace */:
1433
- by = Math.abs(bone.scaleY) * MathUtils.signum(y);
1434
- bone.scaleY = by + (y - by) * alpha;
1435
- break;
1436
- case 3 /* add */:
1437
- bone.scaleY += (y - bone.data.scaleY) * alpha;
1438
- }
1439
- }
1440
- }
1393
+ if (bone.active)
1394
+ bone.scaleY = this.getScaleValue(time, alpha, blend, direction, bone.scaleX, bone.data.scaleY);
1441
1395
  }
1442
1396
  };
1443
1397
  var ShearTimeline = class extends CurveTimeline2 {
1398
+ boneIndex = 0;
1444
1399
  constructor(frameCount, bezierCount, boneIndex) {
1445
1400
  super(
1446
1401
  frameCount,
@@ -1448,7 +1403,6 @@ var spine = (() => {
1448
1403
  Property.shearX + "|" + boneIndex,
1449
1404
  Property.shearY + "|" + boneIndex
1450
1405
  );
1451
- this.boneIndex = 0;
1452
1406
  this.boneIndex = boneIndex;
1453
1407
  }
1454
1408
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
@@ -1546,82 +1500,36 @@ var spine = (() => {
1546
1500
  }
1547
1501
  };
1548
1502
  var ShearXTimeline = class extends CurveTimeline1 {
1503
+ boneIndex = 0;
1549
1504
  constructor(frameCount, bezierCount, boneIndex) {
1550
1505
  super(frameCount, bezierCount, Property.shearX + "|" + boneIndex);
1551
- this.boneIndex = 0;
1552
1506
  this.boneIndex = boneIndex;
1553
1507
  }
1554
1508
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1555
1509
  let bone = skeleton.bones[this.boneIndex];
1556
- if (!bone.active)
1557
- return;
1558
- let frames = this.frames;
1559
- if (time < frames[0]) {
1560
- switch (blend) {
1561
- case 0 /* setup */:
1562
- bone.shearX = bone.data.shearX;
1563
- return;
1564
- case 1 /* first */:
1565
- bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
1566
- }
1567
- return;
1568
- }
1569
- let x = this.getCurveValue(time);
1570
- switch (blend) {
1571
- case 0 /* setup */:
1572
- bone.shearX = bone.data.shearX + x * alpha;
1573
- break;
1574
- case 1 /* first */:
1575
- case 2 /* replace */:
1576
- bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
1577
- break;
1578
- case 3 /* add */:
1579
- bone.shearX += x * alpha;
1580
- }
1510
+ if (bone.active)
1511
+ bone.shearX = this.getRelativeValue(time, alpha, blend, bone.shearX, bone.data.shearX);
1581
1512
  }
1582
1513
  };
1583
1514
  var ShearYTimeline = class extends CurveTimeline1 {
1515
+ boneIndex = 0;
1584
1516
  constructor(frameCount, bezierCount, boneIndex) {
1585
1517
  super(frameCount, bezierCount, Property.shearY + "|" + boneIndex);
1586
- this.boneIndex = 0;
1587
1518
  this.boneIndex = boneIndex;
1588
1519
  }
1589
1520
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1590
1521
  let bone = skeleton.bones[this.boneIndex];
1591
- if (!bone.active)
1592
- return;
1593
- let frames = this.frames;
1594
- if (time < frames[0]) {
1595
- switch (blend) {
1596
- case 0 /* setup */:
1597
- bone.shearY = bone.data.shearY;
1598
- return;
1599
- case 1 /* first */:
1600
- bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
1601
- }
1602
- return;
1603
- }
1604
- let y = this.getCurveValue(time);
1605
- switch (blend) {
1606
- case 0 /* setup */:
1607
- bone.shearY = bone.data.shearY + y * alpha;
1608
- break;
1609
- case 1 /* first */:
1610
- case 2 /* replace */:
1611
- bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
1612
- break;
1613
- case 3 /* add */:
1614
- bone.shearY += y * alpha;
1615
- }
1522
+ if (bone.active)
1523
+ bone.shearY = this.getRelativeValue(time, alpha, blend, bone.shearX, bone.data.shearY);
1616
1524
  }
1617
1525
  };
1618
1526
  var RGBATimeline = class extends CurveTimeline {
1527
+ slotIndex = 0;
1619
1528
  constructor(frameCount, bezierCount, slotIndex) {
1620
1529
  super(frameCount, bezierCount, [
1621
1530
  Property.rgb + "|" + slotIndex,
1622
1531
  Property.alpha + "|" + slotIndex
1623
1532
  ]);
1624
- this.slotIndex = 0;
1625
1533
  this.slotIndex = slotIndex;
1626
1534
  }
1627
1535
  getFrameEntries() {
@@ -1779,11 +1687,11 @@ var spine = (() => {
1779
1687
  }
1780
1688
  };
1781
1689
  var RGBTimeline = class extends CurveTimeline {
1690
+ slotIndex = 0;
1782
1691
  constructor(frameCount, bezierCount, slotIndex) {
1783
1692
  super(frameCount, bezierCount, [
1784
1693
  Property.rgb + "|" + slotIndex
1785
1694
  ]);
1786
- this.slotIndex = 0;
1787
1695
  this.slotIndex = slotIndex;
1788
1696
  }
1789
1697
  getFrameEntries() {
@@ -1922,9 +1830,9 @@ var spine = (() => {
1922
1830
  }
1923
1831
  };
1924
1832
  var AlphaTimeline = class extends CurveTimeline1 {
1833
+ slotIndex = 0;
1925
1834
  constructor(frameCount, bezierCount, slotIndex) {
1926
1835
  super(frameCount, bezierCount, Property.alpha + "|" + slotIndex);
1927
- this.slotIndex = 0;
1928
1836
  this.slotIndex = slotIndex;
1929
1837
  }
1930
1838
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
@@ -1954,13 +1862,13 @@ var spine = (() => {
1954
1862
  }
1955
1863
  };
1956
1864
  var RGBA2Timeline = class extends CurveTimeline {
1865
+ slotIndex = 0;
1957
1866
  constructor(frameCount, bezierCount, slotIndex) {
1958
1867
  super(frameCount, bezierCount, [
1959
1868
  Property.rgb + "|" + slotIndex,
1960
1869
  Property.alpha + "|" + slotIndex,
1961
1870
  Property.rgb2 + "|" + slotIndex
1962
1871
  ]);
1963
- this.slotIndex = 0;
1964
1872
  this.slotIndex = slotIndex;
1965
1873
  }
1966
1874
  getFrameEntries() {
@@ -2201,12 +2109,12 @@ var spine = (() => {
2201
2109
  }
2202
2110
  };
2203
2111
  var RGB2Timeline = class extends CurveTimeline {
2112
+ slotIndex = 0;
2204
2113
  constructor(frameCount, bezierCount, slotIndex) {
2205
2114
  super(frameCount, bezierCount, [
2206
2115
  Property.rgb + "|" + slotIndex,
2207
2116
  Property.rgb2 + "|" + slotIndex
2208
2117
  ]);
2209
- this.slotIndex = 0;
2210
2118
  this.slotIndex = slotIndex;
2211
2119
  }
2212
2120
  getFrameEntries() {
@@ -2432,11 +2340,13 @@ var spine = (() => {
2432
2340
  }
2433
2341
  };
2434
2342
  var AttachmentTimeline = class extends Timeline {
2343
+ slotIndex = 0;
2344
+ /** The attachment name for each key frame. May contain null values to clear the attachment. */
2345
+ attachmentNames;
2435
2346
  constructor(frameCount, slotIndex) {
2436
2347
  super(frameCount, [
2437
2348
  Property.attachment + "|" + slotIndex
2438
2349
  ]);
2439
- this.slotIndex = 0;
2440
2350
  this.slotIndex = slotIndex;
2441
2351
  this.attachmentNames = new Array(frameCount);
2442
2352
  }
@@ -2469,11 +2379,15 @@ var spine = (() => {
2469
2379
  }
2470
2380
  };
2471
2381
  var DeformTimeline = class extends CurveTimeline {
2382
+ slotIndex = 0;
2383
+ /** The attachment that will be deformed. */
2384
+ attachment;
2385
+ /** The vertices for each key frame. */
2386
+ vertices;
2472
2387
  constructor(frameCount, bezierCount, slotIndex, attachment) {
2473
2388
  super(frameCount, bezierCount, [
2474
2389
  Property.deform + "|" + slotIndex + "|" + attachment.id
2475
2390
  ]);
2476
- this.slotIndex = 0;
2477
2391
  this.slotIndex = slotIndex;
2478
2392
  this.attachment = attachment;
2479
2393
  this.vertices = new Array(frameCount);
@@ -2694,6 +2608,8 @@ var spine = (() => {
2694
2608
  }
2695
2609
  };
2696
2610
  var _EventTimeline = class extends Timeline {
2611
+ /** The event for each key frame. */
2612
+ events;
2697
2613
  constructor(frameCount) {
2698
2614
  super(frameCount, _EventTimeline.propertyIds);
2699
2615
  this.events = new Array(frameCount);
@@ -2736,8 +2652,10 @@ var spine = (() => {
2736
2652
  }
2737
2653
  };
2738
2654
  var EventTimeline = _EventTimeline;
2739
- EventTimeline.propertyIds = ["" + Property.event];
2655
+ __publicField(EventTimeline, "propertyIds", ["" + Property.event]);
2740
2656
  var _DrawOrderTimeline = class extends Timeline {
2657
+ /** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */
2658
+ drawOrders;
2741
2659
  constructor(frameCount) {
2742
2660
  super(frameCount, _DrawOrderTimeline.propertyIds);
2743
2661
  this.drawOrders = new Array(frameCount);
@@ -2776,15 +2694,15 @@ var spine = (() => {
2776
2694
  }
2777
2695
  };
2778
2696
  var DrawOrderTimeline = _DrawOrderTimeline;
2779
- DrawOrderTimeline.propertyIds = ["" + Property.drawOrder];
2697
+ __publicField(DrawOrderTimeline, "propertyIds", ["" + Property.drawOrder]);
2780
2698
  var IkConstraintTimeline = class extends CurveTimeline {
2699
+ /** The index of the IK constraint in {@link Skeleton#getIkConstraints()} that will be changed when this timeline is */
2700
+ constraintIndex = 0;
2781
2701
  constructor(frameCount, bezierCount, ikConstraintIndex) {
2782
2702
  super(frameCount, bezierCount, [
2783
2703
  Property.ikConstraint + "|" + ikConstraintIndex
2784
2704
  ]);
2785
- /** The index of the IK constraint slot in {@link Skeleton#ikConstraints} that will be changed. */
2786
- this.ikConstraintIndex = 0;
2787
- this.ikConstraintIndex = ikConstraintIndex;
2705
+ this.constraintIndex = ikConstraintIndex;
2788
2706
  }
2789
2707
  getFrameEntries() {
2790
2708
  return 6;
@@ -2815,7 +2733,7 @@ var spine = (() => {
2815
2733
  ] = stretch ? 1 : 0;
2816
2734
  }
2817
2735
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
2818
- let constraint = skeleton.ikConstraints[this.ikConstraintIndex];
2736
+ let constraint = skeleton.ikConstraints[this.constraintIndex];
2819
2737
  if (!constraint.active)
2820
2738
  return;
2821
2739
  let frames = this.frames;
@@ -2940,13 +2858,13 @@ var spine = (() => {
2940
2858
  }
2941
2859
  };
2942
2860
  var TransformConstraintTimeline = class extends CurveTimeline {
2861
+ /** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */
2862
+ constraintIndex = 0;
2943
2863
  constructor(frameCount, bezierCount, transformConstraintIndex) {
2944
2864
  super(frameCount, bezierCount, [
2945
2865
  Property.transformConstraint + "|" + transformConstraintIndex
2946
2866
  ]);
2947
- /** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */
2948
- this.transformConstraintIndex = 0;
2949
- this.transformConstraintIndex = transformConstraintIndex;
2867
+ this.constraintIndex = transformConstraintIndex;
2950
2868
  }
2951
2869
  getFrameEntries() {
2952
2870
  return 7;
@@ -2982,7 +2900,7 @@ var spine = (() => {
2982
2900
  ] = mixShearY;
2983
2901
  }
2984
2902
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
2985
- let constraint = skeleton.transformConstraints[this.transformConstraintIndex];
2903
+ let constraint = skeleton.transformConstraints[this.constraintIndex];
2986
2904
  if (!constraint.active)
2987
2905
  return;
2988
2906
  let frames = this.frames;
@@ -3163,71 +3081,42 @@ var spine = (() => {
3163
3081
  }
3164
3082
  };
3165
3083
  var PathConstraintPositionTimeline = class extends CurveTimeline1 {
3084
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3085
+ * applied. */
3086
+ constraintIndex = 0;
3166
3087
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3167
3088
  super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex);
3168
- /** The index of the path constraint slot in {@link Skeleton#pathConstraints} that will be changed. */
3169
- this.pathConstraintIndex = 0;
3170
- this.pathConstraintIndex = pathConstraintIndex;
3089
+ this.constraintIndex = pathConstraintIndex;
3171
3090
  }
3172
3091
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3173
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3174
- if (!constraint.active)
3175
- return;
3176
- let frames = this.frames;
3177
- if (time < frames[0]) {
3178
- switch (blend) {
3179
- case 0 /* setup */:
3180
- constraint.position = constraint.data.position;
3181
- return;
3182
- case 1 /* first */:
3183
- constraint.position += (constraint.data.position - constraint.position) * alpha;
3184
- }
3185
- return;
3186
- }
3187
- let position = this.getCurveValue(time);
3188
- if (blend == 0 /* setup */)
3189
- constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
3190
- else
3191
- constraint.position += (position - constraint.position) * alpha;
3092
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3093
+ if (constraint.active)
3094
+ constraint.position = this.getAbsoluteValue(time, alpha, blend, constraint.position, constraint.data.position);
3192
3095
  }
3193
3096
  };
3194
3097
  var PathConstraintSpacingTimeline = class extends CurveTimeline1 {
3098
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3099
+ * applied. */
3100
+ constraintIndex = 0;
3195
3101
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3196
3102
  super(frameCount, bezierCount, Property.pathConstraintSpacing + "|" + pathConstraintIndex);
3197
- /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */
3198
- this.pathConstraintIndex = 0;
3199
- this.pathConstraintIndex = pathConstraintIndex;
3103
+ this.constraintIndex = pathConstraintIndex;
3200
3104
  }
3201
3105
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3202
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3203
- if (!constraint.active)
3204
- return;
3205
- let frames = this.frames;
3206
- if (time < frames[0]) {
3207
- switch (blend) {
3208
- case 0 /* setup */:
3209
- constraint.spacing = constraint.data.spacing;
3210
- return;
3211
- case 1 /* first */:
3212
- constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
3213
- }
3214
- return;
3215
- }
3216
- let spacing = this.getCurveValue(time);
3217
- if (blend == 0 /* setup */)
3218
- constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
3219
- else
3220
- constraint.spacing += (spacing - constraint.spacing) * alpha;
3106
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3107
+ if (constraint.active)
3108
+ constraint.spacing = this.getAbsoluteValue(time, alpha, blend, constraint.spacing, constraint.data.spacing);
3221
3109
  }
3222
3110
  };
3223
3111
  var PathConstraintMixTimeline = class extends CurveTimeline {
3112
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3113
+ * applied. */
3114
+ constraintIndex = 0;
3224
3115
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3225
3116
  super(frameCount, bezierCount, [
3226
3117
  Property.pathConstraintMix + "|" + pathConstraintIndex
3227
3118
  ]);
3228
- /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */
3229
- this.pathConstraintIndex = 0;
3230
- this.pathConstraintIndex = pathConstraintIndex;
3119
+ this.constraintIndex = pathConstraintIndex;
3231
3120
  }
3232
3121
  getFrameEntries() {
3233
3122
  return 4;
@@ -3250,7 +3139,7 @@ var spine = (() => {
3250
3139
  ] = mixY;
3251
3140
  }
3252
3141
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3253
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3142
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3254
3143
  if (!constraint.active)
3255
3144
  return;
3256
3145
  let frames = this.frames;
@@ -3357,7 +3246,199 @@ var spine = (() => {
3357
3246
  }
3358
3247
  }
3359
3248
  };
3249
+ var PhysicsConstraintTimeline = class extends CurveTimeline1 {
3250
+ /** The index of the physics constraint in {@link Skeleton#getPhysicsConstraints()} that will be changed when this timeline
3251
+ * is applied, or -1 if all physics constraints in the skeleton will be changed. */
3252
+ constraintIndex = 0;
3253
+ /** @param physicsConstraintIndex -1 for all physics constraints in the skeleton. */
3254
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3255
+ super(frameCount, bezierCount, property + "|" + physicsConstraintIndex);
3256
+ this.constraintIndex = physicsConstraintIndex;
3257
+ }
3258
+ apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3259
+ let constraint;
3260
+ if (this.constraintIndex == -1) {
3261
+ const value = time >= this.frames[0] ? this.getCurveValue(time) : 0;
3262
+ for (const constraint2 of skeleton.physicsConstraints) {
3263
+ if (constraint2.active && this.global(constraint2.data))
3264
+ this.set(constraint2, this.getAbsoluteValue2(time, alpha, blend, this.get(constraint2), this.setup(constraint2), value));
3265
+ }
3266
+ } else {
3267
+ constraint = skeleton.physicsConstraints[this.constraintIndex];
3268
+ if (constraint.active)
3269
+ this.set(constraint, this.getAbsoluteValue(time, alpha, blend, this.get(constraint), this.setup(constraint)));
3270
+ }
3271
+ }
3272
+ };
3273
+ var PhysicsConstraintInertiaTimeline = class extends PhysicsConstraintTimeline {
3274
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3275
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintInertia);
3276
+ }
3277
+ setup(constraint) {
3278
+ return constraint.data.inertia;
3279
+ }
3280
+ get(constraint) {
3281
+ return constraint.inertia;
3282
+ }
3283
+ set(constraint, value) {
3284
+ constraint.inertia = value;
3285
+ }
3286
+ global(constraint) {
3287
+ return constraint.inertiaGlobal;
3288
+ }
3289
+ };
3290
+ var PhysicsConstraintStrengthTimeline = class extends PhysicsConstraintTimeline {
3291
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3292
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintStrength);
3293
+ }
3294
+ setup(constraint) {
3295
+ return constraint.data.strength;
3296
+ }
3297
+ get(constraint) {
3298
+ return constraint.strength;
3299
+ }
3300
+ set(constraint, value) {
3301
+ constraint.strength = value;
3302
+ }
3303
+ global(constraint) {
3304
+ return constraint.strengthGlobal;
3305
+ }
3306
+ };
3307
+ var PhysicsConstraintDampingTimeline = class extends PhysicsConstraintTimeline {
3308
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3309
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintDamping);
3310
+ }
3311
+ setup(constraint) {
3312
+ return constraint.data.damping;
3313
+ }
3314
+ get(constraint) {
3315
+ return constraint.damping;
3316
+ }
3317
+ set(constraint, value) {
3318
+ constraint.damping = value;
3319
+ }
3320
+ global(constraint) {
3321
+ return constraint.dampingGlobal;
3322
+ }
3323
+ };
3324
+ var PhysicsConstraintMassTimeline = class extends PhysicsConstraintTimeline {
3325
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3326
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintMass);
3327
+ }
3328
+ setup(constraint) {
3329
+ return 1 / constraint.data.massInverse;
3330
+ }
3331
+ get(constraint) {
3332
+ return 1 / constraint.massInverse;
3333
+ }
3334
+ set(constraint, value) {
3335
+ constraint.massInverse = 1 / value;
3336
+ }
3337
+ global(constraint) {
3338
+ return constraint.massGlobal;
3339
+ }
3340
+ };
3341
+ var PhysicsConstraintWindTimeline = class extends PhysicsConstraintTimeline {
3342
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3343
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintWind);
3344
+ }
3345
+ setup(constraint) {
3346
+ return constraint.data.wind;
3347
+ }
3348
+ get(constraint) {
3349
+ return constraint.wind;
3350
+ }
3351
+ set(constraint, value) {
3352
+ constraint.wind = value;
3353
+ }
3354
+ global(constraint) {
3355
+ return constraint.windGlobal;
3356
+ }
3357
+ };
3358
+ var PhysicsConstraintGravityTimeline = class extends PhysicsConstraintTimeline {
3359
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3360
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintGravity);
3361
+ }
3362
+ setup(constraint) {
3363
+ return constraint.data.gravity;
3364
+ }
3365
+ get(constraint) {
3366
+ return constraint.gravity;
3367
+ }
3368
+ set(constraint, value) {
3369
+ constraint.gravity = value;
3370
+ }
3371
+ global(constraint) {
3372
+ return constraint.gravityGlobal;
3373
+ }
3374
+ };
3375
+ var PhysicsConstraintMixTimeline = class extends PhysicsConstraintTimeline {
3376
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3377
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintMix);
3378
+ }
3379
+ setup(constraint) {
3380
+ return constraint.data.mix;
3381
+ }
3382
+ get(constraint) {
3383
+ return constraint.mix;
3384
+ }
3385
+ set(constraint, value) {
3386
+ constraint.mix = value;
3387
+ }
3388
+ global(constraint) {
3389
+ return constraint.mixGlobal;
3390
+ }
3391
+ };
3392
+ var _PhysicsConstraintResetTimeline = class extends Timeline {
3393
+ /** The index of the physics constraint in {@link Skeleton#getPhysicsConstraints()} that will be reset when this timeline is
3394
+ * applied, or -1 if all physics constraints in the skeleton will be reset. */
3395
+ constraintIndex;
3396
+ /** @param physicsConstraintIndex -1 for all physics constraints in the skeleton. */
3397
+ constructor(frameCount, physicsConstraintIndex) {
3398
+ super(frameCount, _PhysicsConstraintResetTimeline.propertyIds);
3399
+ this.constraintIndex = physicsConstraintIndex;
3400
+ }
3401
+ getFrameCount() {
3402
+ return this.frames.length;
3403
+ }
3404
+ /** Sets the time for the specified frame.
3405
+ * @param frame Between 0 and <code>frameCount</code>, inclusive. */
3406
+ setFrame(frame, time) {
3407
+ this.frames[frame] = time;
3408
+ }
3409
+ /** Resets the physics constraint when frames > <code>lastTime</code> and <= <code>time</code>. */
3410
+ apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3411
+ let constraint;
3412
+ if (this.constraintIndex != -1) {
3413
+ constraint = skeleton.physicsConstraints[this.constraintIndex];
3414
+ if (!constraint.active)
3415
+ return;
3416
+ }
3417
+ const frames = this.frames;
3418
+ if (lastTime > time) {
3419
+ this.apply(skeleton, lastTime, Number.MAX_VALUE, [], alpha, blend, direction);
3420
+ lastTime = -1;
3421
+ } else if (lastTime >= frames[frames.length - 1])
3422
+ return;
3423
+ if (time < frames[0])
3424
+ return;
3425
+ if (lastTime < frames[0] || time >= frames[Timeline.search1(frames, lastTime) + 1]) {
3426
+ if (constraint != null)
3427
+ constraint.reset();
3428
+ else {
3429
+ for (const constraint2 of skeleton.physicsConstraints) {
3430
+ if (constraint2.active)
3431
+ constraint2.reset();
3432
+ }
3433
+ }
3434
+ }
3435
+ }
3436
+ };
3437
+ var PhysicsConstraintResetTimeline = _PhysicsConstraintResetTimeline;
3438
+ __publicField(PhysicsConstraintResetTimeline, "propertyIds", [Property.physicsConstraintReset.toString()]);
3360
3439
  var _SequenceTimeline = class extends Timeline {
3440
+ slotIndex;
3441
+ attachment;
3361
3442
  constructor(frameCount, slotIndex, attachment) {
3362
3443
  super(frameCount, [
3363
3444
  Property.sequence + "|" + slotIndex + "|" + attachment.sequence.id
@@ -3442,32 +3523,34 @@ var spine = (() => {
3442
3523
  }
3443
3524
  };
3444
3525
  var SequenceTimeline = _SequenceTimeline;
3445
- SequenceTimeline.ENTRIES = 3;
3446
- SequenceTimeline.MODE = 1;
3447
- SequenceTimeline.DELAY = 2;
3526
+ __publicField(SequenceTimeline, "ENTRIES", 3);
3527
+ __publicField(SequenceTimeline, "MODE", 1);
3528
+ __publicField(SequenceTimeline, "DELAY", 2);
3448
3529
 
3449
3530
  // spine-core/src/AnimationState.ts
3450
3531
  var _AnimationState = class {
3532
+ static emptyAnimation() {
3533
+ return _AnimationState._emptyAnimation;
3534
+ }
3535
+ /** The AnimationStateData to look up mix durations. */
3536
+ data;
3537
+ /** The list of tracks that currently have animations, which may contain null entries. */
3538
+ tracks = new Array();
3539
+ /** Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower
3540
+ * or faster. Defaults to 1.
3541
+ *
3542
+ * See TrackEntry {@link TrackEntry#timeScale} for affecting a single animation. */
3543
+ timeScale = 1;
3544
+ unkeyedState = 0;
3545
+ events = new Array();
3546
+ listeners = new Array();
3547
+ queue = new EventQueue(this);
3548
+ propertyIDs = new StringSet();
3549
+ animationsChanged = false;
3550
+ trackEntryPool = new Pool(() => new TrackEntry());
3451
3551
  constructor(data) {
3452
- /** The list of tracks that currently have animations, which may contain null entries. */
3453
- this.tracks = new Array();
3454
- /** Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower
3455
- * or faster. Defaults to 1.
3456
- *
3457
- * See TrackEntry {@link TrackEntry#timeScale} for affecting a single animation. */
3458
- this.timeScale = 1;
3459
- this.unkeyedState = 0;
3460
- this.events = new Array();
3461
- this.listeners = new Array();
3462
- this.queue = new EventQueue(this);
3463
- this.propertyIDs = new StringSet();
3464
- this.animationsChanged = false;
3465
- this.trackEntryPool = new Pool(() => new TrackEntry());
3466
3552
  this.data = data;
3467
3553
  }
3468
- static emptyAnimation() {
3469
- return _AnimationState._emptyAnimation;
3470
- }
3471
3554
  /** Increments each track entry {@link TrackEntry#trackTime()}, setting queued animations as current if needed. */
3472
3555
  update(delta) {
3473
3556
  delta *= this.timeScale;
@@ -3559,11 +3642,12 @@ var spine = (() => {
3559
3642
  continue;
3560
3643
  applied = true;
3561
3644
  let blend = i2 == 0 ? 1 /* first */ : current.mixBlend;
3562
- let mix = current.alpha;
3645
+ let alpha = current.alpha;
3563
3646
  if (current.mixingFrom)
3564
- mix *= this.applyMixingFrom(current, skeleton, blend);
3647
+ alpha *= this.applyMixingFrom(current, skeleton, blend);
3565
3648
  else if (current.trackTime >= current.trackEnd && !current.next)
3566
- mix = 0;
3649
+ alpha = 0;
3650
+ let attachments = alpha >= current.alphaAttachmentThreshold;
3567
3651
  let animationLast = current.animationLast, animationTime = current.getAnimationTime(), applyTime = animationTime;
3568
3652
  let applyEvents = events;
3569
3653
  if (current.reverse) {
@@ -3572,14 +3656,16 @@ var spine = (() => {
3572
3656
  }
3573
3657
  let timelines = current.animation.timelines;
3574
3658
  let timelineCount = timelines.length;
3575
- if (i2 == 0 && mix == 1 || blend == 3 /* add */) {
3659
+ if (i2 == 0 && alpha == 1 || blend == 3 /* add */) {
3660
+ if (i2 == 0)
3661
+ attachments = true;
3576
3662
  for (let ii = 0; ii < timelineCount; ii++) {
3577
- Utils.webkit602BugfixHelper(mix, blend);
3663
+ Utils.webkit602BugfixHelper(alpha, blend);
3578
3664
  var timeline = timelines[ii];
3579
3665
  if (timeline instanceof AttachmentTimeline)
3580
- this.applyAttachmentTimeline(timeline, skeleton, applyTime, blend, true);
3666
+ this.applyAttachmentTimeline(timeline, skeleton, applyTime, blend, attachments);
3581
3667
  else
3582
- timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, 0 /* mixIn */);
3668
+ timeline.apply(skeleton, animationLast, applyTime, applyEvents, alpha, blend, 0 /* mixIn */);
3583
3669
  }
3584
3670
  } else {
3585
3671
  let timelineMode = current.timelineMode;
@@ -3591,12 +3677,12 @@ var spine = (() => {
3591
3677
  let timeline2 = timelines[ii];
3592
3678
  let timelineBlend = timelineMode[ii] == SUBSEQUENT ? blend : 0 /* setup */;
3593
3679
  if (!shortestRotation && timeline2 instanceof RotateTimeline) {
3594
- this.applyRotateTimeline(timeline2, skeleton, applyTime, mix, timelineBlend, current.timelinesRotation, ii << 1, firstFrame);
3680
+ this.applyRotateTimeline(timeline2, skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation, ii << 1, firstFrame);
3595
3681
  } else if (timeline2 instanceof AttachmentTimeline) {
3596
- this.applyAttachmentTimeline(timeline2, skeleton, applyTime, blend, true);
3682
+ this.applyAttachmentTimeline(timeline2, skeleton, applyTime, blend, attachments);
3597
3683
  } else {
3598
- Utils.webkit602BugfixHelper(mix, blend);
3599
- timeline2.apply(skeleton, animationLast, applyTime, applyEvents, mix, timelineBlend, 0 /* mixIn */);
3684
+ Utils.webkit602BugfixHelper(alpha, blend);
3685
+ timeline2.apply(skeleton, animationLast, applyTime, applyEvents, alpha, timelineBlend, 0 /* mixIn */);
3600
3686
  }
3601
3687
  }
3602
3688
  }
@@ -3634,7 +3720,7 @@ var spine = (() => {
3634
3720
  if (blend != 1 /* first */)
3635
3721
  blend = from.mixBlend;
3636
3722
  }
3637
- let attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
3723
+ let attachments = mix < from.mixAttachmentThreshold, drawOrder = mix < from.mixDrawOrderThreshold;
3638
3724
  let timelines = from.animation.timelines;
3639
3725
  let timelineCount = timelines.length;
3640
3726
  let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
@@ -3689,7 +3775,7 @@ var spine = (() => {
3689
3775
  if (!shortestRotation && timeline instanceof RotateTimeline)
3690
3776
  this.applyRotateTimeline(timeline, skeleton, applyTime, alpha, timelineBlend, from.timelinesRotation, i << 1, firstFrame);
3691
3777
  else if (timeline instanceof AttachmentTimeline)
3692
- this.applyAttachmentTimeline(timeline, skeleton, applyTime, timelineBlend, attachments);
3778
+ this.applyAttachmentTimeline(timeline, skeleton, applyTime, timelineBlend, attachments && alpha >= from.alphaAttachmentThreshold);
3693
3779
  else {
3694
3780
  Utils.webkit602BugfixHelper(alpha, blend);
3695
3781
  if (drawOrder && timeline instanceof DrawOrderTimeline && timelineBlend == 0 /* setup */)
@@ -3749,7 +3835,7 @@ var spine = (() => {
3749
3835
  r2 = bone.data.rotation + timeline.getCurveValue(time);
3750
3836
  }
3751
3837
  let total = 0, diff = r2 - r1;
3752
- diff -= (16384 - (16384.499999999996 - diff / 360 | 0)) * 360;
3838
+ diff -= Math.ceil(diff / 360 - 0.5) * 360;
3753
3839
  if (diff == 0) {
3754
3840
  total = timelinesRotation[i];
3755
3841
  } else {
@@ -4006,8 +4092,9 @@ var spine = (() => {
4006
4092
  entry.reverse = false;
4007
4093
  entry.shortestRotation = false;
4008
4094
  entry.eventThreshold = 0;
4009
- entry.attachmentThreshold = 0;
4010
- entry.drawOrderThreshold = 0;
4095
+ entry.alphaAttachmentThreshold = 0;
4096
+ entry.mixAttachmentThreshold = 0;
4097
+ entry.mixDrawOrderThreshold = 0;
4011
4098
  entry.animationStart = 0;
4012
4099
  entry.animationEnd = animation.duration;
4013
4100
  entry.animationLast = -1;
@@ -4119,141 +4206,151 @@ var spine = (() => {
4119
4206
  }
4120
4207
  };
4121
4208
  var AnimationState = _AnimationState;
4122
- AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
4209
+ __publicField(AnimationState, "_emptyAnimation", new Animation("<empty>", [], 0));
4123
4210
  var TrackEntry = class {
4124
- constructor() {
4125
- /** The animation to apply for this track entry. */
4126
- this.animation = null;
4127
- this.previous = null;
4128
- /** The animation queued to start after this animation, or null. `next` makes up a linked list. */
4129
- this.next = null;
4130
- /** The track entry for the previous animation when mixing from the previous animation to this animation, or null if no
4131
- * mixing is currently occuring. When mixing from multiple animations, `mixingFrom` makes up a linked list. */
4132
- this.mixingFrom = null;
4133
- /** The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is
4134
- * currently occuring. When mixing to multiple animations, `mixingTo` makes up a linked list. */
4135
- this.mixingTo = null;
4136
- /** The listener for events generated by this track entry, or null.
4137
- *
4138
- * A track entry returned from {@link AnimationState#setAnimation()} is already the current animation
4139
- * for the track, so the track entry listener {@link AnimationStateListener#start()} will not be called. */
4140
- this.listener = null;
4141
- /** The index of the track where this track entry is either current or queued.
4142
- *
4143
- * See {@link AnimationState#getCurrent()}. */
4144
- this.trackIndex = 0;
4145
- /** If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its
4146
- * duration. */
4147
- this.loop = false;
4148
- /** If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
4149
- * of being mixed out.
4150
- *
4151
- * When mixing between animations that key the same property, if a lower track also keys that property then the value will
4152
- * briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
4153
- * while the second animation mixes from 0% to 100%. Setting `holdPrevious` to true applies the first animation
4154
- * at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
4155
- * keys the property, only when a higher track also keys the property.
4156
- *
4157
- * Snapping will occur if `holdPrevious` is true and this animation does not key all the same properties as the
4158
- * previous animation. */
4159
- this.holdPrevious = false;
4160
- this.reverse = false;
4161
- this.shortestRotation = false;
4162
- /** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the
4163
- * `eventThreshold`, event timelines are applied while this animation is being mixed out. Defaults to 0, so event
4164
- * timelines are not applied while this animation is being mixed out. */
4165
- this.eventThreshold = 0;
4166
- /** When the mix percentage ({@link #mixtime} / {@link #mixDuration}) is less than the
4167
- * `attachmentThreshold`, attachment timelines are applied while this animation is being mixed out. Defaults to
4168
- * 0, so attachment timelines are not applied while this animation is being mixed out. */
4169
- this.attachmentThreshold = 0;
4170
- /** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the
4171
- * `drawOrderThreshold`, draw order timelines are applied while this animation is being mixed out. Defaults to 0,
4172
- * so draw order timelines are not applied while this animation is being mixed out. */
4173
- this.drawOrderThreshold = 0;
4174
- /** Seconds when this animation starts, both initially and after looping. Defaults to 0.
4175
- *
4176
- * When changing the `animationStart` time, it often makes sense to set {@link #animationLast} to the same
4177
- * value to prevent timeline keys before the start time from triggering. */
4178
- this.animationStart = 0;
4179
- /** Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
4180
- * loop back to {@link #animationStart} at this time. Defaults to the animation {@link Animation#duration}. */
4181
- this.animationEnd = 0;
4182
- /** The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
4183
- * animation is applied, event timelines will fire all events between the `animationLast` time (exclusive) and
4184
- * `animationTime` (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation
4185
- * is applied. */
4186
- this.animationLast = 0;
4187
- this.nextAnimationLast = 0;
4188
- /** Seconds to postpone playing the animation. When this track entry is the current track entry, `delay`
4189
- * postpones incrementing the {@link #trackTime}. When this track entry is queued, `delay` is the time from
4190
- * the start of the previous animation to when this track entry will become the current track entry (ie when the previous
4191
- * track entry {@link TrackEntry#trackTime} >= this track entry's `delay`).
4192
- *
4193
- * {@link #timeScale} affects the delay. */
4194
- this.delay = 0;
4195
- /** Current time in seconds this track entry has been the current track entry. The track time determines
4196
- * {@link #animationTime}. The track time can be set to start the animation at a time other than 0, without affecting
4197
- * looping. */
4198
- this.trackTime = 0;
4199
- this.trackLast = 0;
4200
- this.nextTrackLast = 0;
4201
- /** The track time in seconds when this animation will be removed from the track. Defaults to the highest possible float
4202
- * value, meaning the animation will be applied until a new animation is set or the track is cleared. If the track end time
4203
- * is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the
4204
- * properties keyed by the animation are set to the setup pose and the track is cleared.
4205
- *
4206
- * It may be desired to use {@link AnimationState#addEmptyAnimation()} rather than have the animation
4207
- * abruptly cease being applied. */
4208
- this.trackEnd = 0;
4209
- /** Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or
4210
- * faster. Defaults to 1.
4211
- *
4212
- * {@link #mixTime} is not affected by track entry time scale, so {@link #mixDuration} may need to be adjusted to
4213
- * match the animation speed.
4214
- *
4215
- * When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
4216
- * {@link #delay} is set using the mix duration from the {@link AnimationStateData}, assuming time scale to be 1. If
4217
- * the time scale is not 1, the delay may need to be adjusted.
4218
- *
4219
- * See AnimationState {@link AnimationState#timeScale} for affecting all animations. */
4220
- this.timeScale = 0;
4221
- /** Values < 1 mix this animation with the skeleton's current pose (usually the pose resulting from lower tracks). Defaults
4222
- * to 1, which overwrites the skeleton's current pose with this animation.
4223
- *
4224
- * Typically track 0 is used to completely pose the skeleton, then alpha is used on higher tracks. It doesn't make sense to
4225
- * use alpha on track 0 if the skeleton pose is from the last frame render. */
4226
- this.alpha = 0;
4227
- /** Seconds from 0 to the {@link #getMixDuration()} when mixing from the previous animation to this animation. May be
4228
- * slightly more than `mixDuration` when the mix is complete. */
4229
- this.mixTime = 0;
4230
- /** Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData
4231
- * {@link AnimationStateData#getMix()} based on the animation before this animation (if any).
4232
- *
4233
- * A mix duration of 0 still mixes out over one frame to provide the track entry being mixed out a chance to revert the
4234
- * properties it was animating.
4235
- *
4236
- * The `mixDuration` can be set manually rather than use the value from
4237
- * {@link AnimationStateData#getMix()}. In that case, the `mixDuration` can be set for a new
4238
- * track entry only before {@link AnimationState#update(float)} is first called.
4239
- *
4240
- * When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
4241
- * {@link #delay} is set using the mix duration from the {@link AnimationStateData}, not a mix duration set
4242
- * afterward. */
4243
- this.mixDuration = 0;
4244
- this.interruptAlpha = 0;
4245
- this.totalAlpha = 0;
4246
- /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which
4247
- * replaces the values from the lower tracks with the animation values. {@link MixBlend#add} adds the animation values to
4248
- * the values from the lower tracks.
4249
- *
4250
- * The `mixBlend` can be set for a new track entry only before {@link AnimationState#apply()} is first
4251
- * called. */
4252
- this.mixBlend = 2 /* replace */;
4253
- this.timelineMode = new Array();
4254
- this.timelineHoldMix = new Array();
4255
- this.timelinesRotation = new Array();
4256
- }
4211
+ /** The animation to apply for this track entry. */
4212
+ animation = null;
4213
+ previous = null;
4214
+ /** The animation queued to start after this animation, or null. `next` makes up a linked list. */
4215
+ next = null;
4216
+ /** The track entry for the previous animation when mixing from the previous animation to this animation, or null if no
4217
+ * mixing is currently occuring. When mixing from multiple animations, `mixingFrom` makes up a linked list. */
4218
+ mixingFrom = null;
4219
+ /** The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is
4220
+ * currently occuring. When mixing to multiple animations, `mixingTo` makes up a linked list. */
4221
+ mixingTo = null;
4222
+ /** The listener for events generated by this track entry, or null.
4223
+ *
4224
+ * A track entry returned from {@link AnimationState#setAnimation()} is already the current animation
4225
+ * for the track, so the track entry listener {@link AnimationStateListener#start()} will not be called. */
4226
+ listener = null;
4227
+ /** The index of the track where this track entry is either current or queued.
4228
+ *
4229
+ * See {@link AnimationState#getCurrent()}. */
4230
+ trackIndex = 0;
4231
+ /** If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its
4232
+ * duration. */
4233
+ loop = false;
4234
+ /** If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
4235
+ * of being mixed out.
4236
+ *
4237
+ * When mixing between animations that key the same property, if a lower track also keys that property then the value will
4238
+ * briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
4239
+ * while the second animation mixes from 0% to 100%. Setting `holdPrevious` to true applies the first animation
4240
+ * at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
4241
+ * keys the property, only when a higher track also keys the property.
4242
+ *
4243
+ * Snapping will occur if `holdPrevious` is true and this animation does not key all the same properties as the
4244
+ * previous animation. */
4245
+ holdPrevious = false;
4246
+ reverse = false;
4247
+ shortestRotation = false;
4248
+ /** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the
4249
+ * `eventThreshold`, event timelines are applied while this animation is being mixed out. Defaults to 0, so event
4250
+ * timelines are not applied while this animation is being mixed out. */
4251
+ eventThreshold = 0;
4252
+ /** When the mix percentage ({@link #mixtime} / {@link #mixDuration}) is less than the
4253
+ * `attachmentThreshold`, attachment timelines are applied while this animation is being mixed out. Defaults to
4254
+ * 0, so attachment timelines are not applied while this animation is being mixed out. */
4255
+ mixAttachmentThreshold = 0;
4256
+ /** When {@link #getAlpha()} is greater than <code>alphaAttachmentThreshold</code>, attachment timelines are applied.
4257
+ * Defaults to 0, so attachment timelines are always applied. */
4258
+ alphaAttachmentThreshold = 0;
4259
+ /** When the mix percentage ({@link #getMixTime()} / {@link #getMixDuration()}) is less than the
4260
+ * <code>mixDrawOrderThreshold</code>, draw order timelines are applied while this animation is being mixed out. Defaults to
4261
+ * 0, so draw order timelines are not applied while this animation is being mixed out. */
4262
+ mixDrawOrderThreshold = 0;
4263
+ /** Seconds when this animation starts, both initially and after looping. Defaults to 0.
4264
+ *
4265
+ * When changing the `animationStart` time, it often makes sense to set {@link #animationLast} to the same
4266
+ * value to prevent timeline keys before the start time from triggering. */
4267
+ animationStart = 0;
4268
+ /** Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
4269
+ * loop back to {@link #animationStart} at this time. Defaults to the animation {@link Animation#duration}. */
4270
+ animationEnd = 0;
4271
+ /** The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
4272
+ * animation is applied, event timelines will fire all events between the `animationLast` time (exclusive) and
4273
+ * `animationTime` (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation
4274
+ * is applied. */
4275
+ animationLast = 0;
4276
+ nextAnimationLast = 0;
4277
+ /** Seconds to postpone playing the animation. When this track entry is the current track entry, `delay`
4278
+ * postpones incrementing the {@link #trackTime}. When this track entry is queued, `delay` is the time from
4279
+ * the start of the previous animation to when this track entry will become the current track entry (ie when the previous
4280
+ * track entry {@link TrackEntry#trackTime} >= this track entry's `delay`).
4281
+ *
4282
+ * {@link #timeScale} affects the delay. */
4283
+ delay = 0;
4284
+ /** Current time in seconds this track entry has been the current track entry. The track time determines
4285
+ * {@link #animationTime}. The track time can be set to start the animation at a time other than 0, without affecting
4286
+ * looping. */
4287
+ trackTime = 0;
4288
+ trackLast = 0;
4289
+ nextTrackLast = 0;
4290
+ /** The track time in seconds when this animation will be removed from the track. Defaults to the highest possible float
4291
+ * value, meaning the animation will be applied until a new animation is set or the track is cleared. If the track end time
4292
+ * is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the
4293
+ * properties keyed by the animation are set to the setup pose and the track is cleared.
4294
+ *
4295
+ * It may be desired to use {@link AnimationState#addEmptyAnimation()} rather than have the animation
4296
+ * abruptly cease being applied. */
4297
+ trackEnd = 0;
4298
+ /** Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or
4299
+ * faster. Defaults to 1.
4300
+ *
4301
+ * {@link #mixTime} is not affected by track entry time scale, so {@link #mixDuration} may need to be adjusted to
4302
+ * match the animation speed.
4303
+ *
4304
+ * When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
4305
+ * {@link #delay} is set using the mix duration from the {@link AnimationStateData}, assuming time scale to be 1. If
4306
+ * the time scale is not 1, the delay may need to be adjusted.
4307
+ *
4308
+ * See AnimationState {@link AnimationState#timeScale} for affecting all animations. */
4309
+ timeScale = 0;
4310
+ /** Values < 1 mix this animation with the skeleton's current pose (usually the pose resulting from lower tracks). Defaults
4311
+ * to 1, which overwrites the skeleton's current pose with this animation.
4312
+ *
4313
+ * Typically track 0 is used to completely pose the skeleton, then alpha is used on higher tracks. It doesn't make sense to
4314
+ * use alpha on track 0 if the skeleton pose is from the last frame render. */
4315
+ alpha = 0;
4316
+ /** Seconds from 0 to the {@link #getMixDuration()} when mixing from the previous animation to this animation. May be
4317
+ * slightly more than `mixDuration` when the mix is complete. */
4318
+ mixTime = 0;
4319
+ /** Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData
4320
+ * {@link AnimationStateData#getMix()} based on the animation before this animation (if any).
4321
+ *
4322
+ * A mix duration of 0 still mixes out over one frame to provide the track entry being mixed out a chance to revert the
4323
+ * properties it was animating.
4324
+ *
4325
+ * The `mixDuration` can be set manually rather than use the value from
4326
+ * {@link AnimationStateData#getMix()}. In that case, the `mixDuration` can be set for a new
4327
+ * track entry only before {@link AnimationState#update(float)} is first called.
4328
+ *
4329
+ * When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
4330
+ * {@link #delay} is set using the mix duration from the {@link AnimationStateData}, not a mix duration set
4331
+ * afterward. */
4332
+ _mixDuration = 0;
4333
+ interruptAlpha = 0;
4334
+ totalAlpha = 0;
4335
+ get mixDuration() {
4336
+ return this._mixDuration;
4337
+ }
4338
+ set mixDuration(mixDuration) {
4339
+ this._mixDuration = mixDuration;
4340
+ if (this.previous != null && this.delay <= 0)
4341
+ this.delay += this.previous.getTrackComplete() - mixDuration;
4342
+ this.delay = this.delay;
4343
+ }
4344
+ /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which
4345
+ * replaces the values from the lower tracks with the animation values. {@link MixBlend#add} adds the animation values to
4346
+ * the values from the lower tracks.
4347
+ *
4348
+ * The `mixBlend` can be set for a new track entry only before {@link AnimationState#apply()} is first
4349
+ * called. */
4350
+ mixBlend = 2 /* replace */;
4351
+ timelineMode = new Array();
4352
+ timelineHoldMix = new Array();
4353
+ timelinesRotation = new Array();
4257
4354
  reset() {
4258
4355
  this.next = null;
4259
4356
  this.previous = null;
@@ -4307,11 +4404,18 @@ var spine = (() => {
4307
4404
  }
4308
4405
  return this.trackTime;
4309
4406
  }
4407
+ /** Returns true if this track entry has been applied at least once.
4408
+ * <p>
4409
+ * See {@link AnimationState#apply(Skeleton)}. */
4410
+ wasApplied() {
4411
+ return this.nextTrackLast != -1;
4412
+ }
4310
4413
  };
4311
4414
  var EventQueue = class {
4415
+ objects = [];
4416
+ drainDisabled = false;
4417
+ animState;
4312
4418
  constructor(animState) {
4313
- this.objects = [];
4314
- this.drainDisabled = false;
4315
4419
  this.animState = animState;
4316
4420
  }
4317
4421
  start(entry) {
@@ -4448,10 +4552,12 @@ var spine = (() => {
4448
4552
 
4449
4553
  // spine-core/src/AnimationStateData.ts
4450
4554
  var AnimationStateData = class {
4555
+ /** The SkeletonData to look up animations when they are specified by name. */
4556
+ skeletonData;
4557
+ animationToMixTime = {};
4558
+ /** The mix duration to use when no mix duration has been defined between two animations. */
4559
+ defaultMix = 0;
4451
4560
  constructor(skeletonData) {
4452
- this.animationToMixTime = {};
4453
- /** The mix duration to use when no mix duration has been defined between two animations. */
4454
- this.defaultMix = 0;
4455
4561
  if (!skeletonData)
4456
4562
  throw new Error("skeletonData cannot be null.");
4457
4563
  this.skeletonData = skeletonData;
@@ -4490,9 +4596,9 @@ var spine = (() => {
4490
4596
 
4491
4597
  // spine-core/src/attachments/BoundingBoxAttachment.ts
4492
4598
  var BoundingBoxAttachment = class extends VertexAttachment {
4599
+ color = new Color(1, 1, 1, 1);
4493
4600
  constructor(name) {
4494
4601
  super(name);
4495
- this.color = new Color(1, 1, 1, 1);
4496
4602
  }
4497
4603
  copy() {
4498
4604
  let copy = new BoundingBoxAttachment(this.name);
@@ -4504,16 +4610,16 @@ var spine = (() => {
4504
4610
 
4505
4611
  // spine-core/src/attachments/ClippingAttachment.ts
4506
4612
  var ClippingAttachment = class extends VertexAttachment {
4613
+ /** Clipping is performed between the clipping polygon's slot and the end slot. Returns null if clipping is done until the end of
4614
+ * the skeleton's rendering. */
4615
+ endSlot = null;
4616
+ // Nonessential.
4617
+ /** The color of the clipping polygon as it was in Spine. Available only when nonessential data was exported. Clipping polygons
4618
+ * are not usually rendered at runtime. */
4619
+ color = new Color(0.2275, 0.2275, 0.8078, 1);
4507
4620
  // ce3a3aff
4508
4621
  constructor(name) {
4509
4622
  super(name);
4510
- /** Clipping is performed between the clipping polygon's slot and the end slot. Returns null if clipping is done until the end of
4511
- * the skeleton's rendering. */
4512
- this.endSlot = null;
4513
- // Nonessential.
4514
- /** The color of the clipping polygon as it was in Spine. Available only when nonessential data was exported. Clipping polygons
4515
- * are not usually rendered at runtime. */
4516
- this.color = new Color(0.2275, 0.2275, 0.8078, 1);
4517
4623
  }
4518
4624
  copy() {
4519
4625
  let copy = new ClippingAttachment(this.name);
@@ -4526,6 +4632,7 @@ var spine = (() => {
4526
4632
 
4527
4633
  // spine-core/src/Texture.ts
4528
4634
  var Texture = class {
4635
+ _image;
4529
4636
  constructor(image) {
4530
4637
  this._image = image;
4531
4638
  }
@@ -4550,19 +4657,18 @@ var spine = (() => {
4550
4657
  return TextureWrap3;
4551
4658
  })(TextureWrap || {});
4552
4659
  var TextureRegion = class {
4553
- constructor() {
4554
- this.u = 0;
4555
- this.v = 0;
4556
- this.u2 = 0;
4557
- this.v2 = 0;
4558
- this.width = 0;
4559
- this.height = 0;
4560
- this.degrees = 0;
4561
- this.offsetX = 0;
4562
- this.offsetY = 0;
4563
- this.originalWidth = 0;
4564
- this.originalHeight = 0;
4565
- }
4660
+ texture;
4661
+ u = 0;
4662
+ v = 0;
4663
+ u2 = 0;
4664
+ v2 = 0;
4665
+ width = 0;
4666
+ height = 0;
4667
+ degrees = 0;
4668
+ offsetX = 0;
4669
+ offsetY = 0;
4670
+ originalWidth = 0;
4671
+ originalHeight = 0;
4566
4672
  };
4567
4673
  var FakeTexture = class extends Texture {
4568
4674
  setFilters(minFilter, magFilter) {
@@ -4575,9 +4681,9 @@ var spine = (() => {
4575
4681
 
4576
4682
  // spine-core/src/TextureAtlas.ts
4577
4683
  var TextureAtlas = class {
4684
+ pages = new Array();
4685
+ regions = new Array();
4578
4686
  constructor(atlasText) {
4579
- this.pages = new Array();
4580
- this.regions = new Array();
4581
4687
  let reader = new TextureAtlasReader(atlasText);
4582
4688
  let entry = new Array(4);
4583
4689
  let pageFields = {};
@@ -4725,15 +4831,15 @@ var spine = (() => {
4725
4831
  page.setTexture(assetManager.get(pathPrefix + page.name));
4726
4832
  }
4727
4833
  dispose() {
4728
- var _a;
4729
4834
  for (let i = 0; i < this.pages.length; i++) {
4730
- (_a = this.pages[i].texture) == null ? void 0 : _a.dispose();
4835
+ this.pages[i].texture?.dispose();
4731
4836
  }
4732
4837
  }
4733
4838
  };
4734
4839
  var TextureAtlasReader = class {
4840
+ lines;
4841
+ index = 0;
4735
4842
  constructor(text) {
4736
- this.index = 0;
4737
4843
  this.lines = text.split(/\r\n|\r|\n/);
4738
4844
  }
4739
4845
  readLine() {
@@ -4765,16 +4871,17 @@ var spine = (() => {
4765
4871
  }
4766
4872
  };
4767
4873
  var TextureAtlasPage = class {
4874
+ name;
4875
+ minFilter = 9728 /* Nearest */;
4876
+ magFilter = 9728 /* Nearest */;
4877
+ uWrap = 33071 /* ClampToEdge */;
4878
+ vWrap = 33071 /* ClampToEdge */;
4879
+ texture = null;
4880
+ width = 0;
4881
+ height = 0;
4882
+ pma = false;
4883
+ regions = new Array();
4768
4884
  constructor(name) {
4769
- this.minFilter = 9728 /* Nearest */;
4770
- this.magFilter = 9728 /* Nearest */;
4771
- this.uWrap = 33071 /* ClampToEdge */;
4772
- this.vWrap = 33071 /* ClampToEdge */;
4773
- this.texture = null;
4774
- this.width = 0;
4775
- this.height = 0;
4776
- this.pma = false;
4777
- this.regions = new Array();
4778
4885
  this.name = name;
4779
4886
  }
4780
4887
  setTexture(texture) {
@@ -4786,18 +4893,20 @@ var spine = (() => {
4786
4893
  }
4787
4894
  };
4788
4895
  var TextureAtlasRegion = class extends TextureRegion {
4896
+ page;
4897
+ name;
4898
+ x = 0;
4899
+ y = 0;
4900
+ offsetX = 0;
4901
+ offsetY = 0;
4902
+ originalWidth = 0;
4903
+ originalHeight = 0;
4904
+ index = 0;
4905
+ degrees = 0;
4906
+ names = null;
4907
+ values = null;
4789
4908
  constructor(page, name) {
4790
4909
  super();
4791
- this.x = 0;
4792
- this.y = 0;
4793
- this.offsetX = 0;
4794
- this.offsetY = 0;
4795
- this.originalWidth = 0;
4796
- this.originalHeight = 0;
4797
- this.index = 0;
4798
- this.degrees = 0;
4799
- this.names = null;
4800
- this.values = null;
4801
4910
  this.page = page;
4802
4911
  this.name = name;
4803
4912
  page.regions.push(this);
@@ -4806,31 +4915,33 @@ var spine = (() => {
4806
4915
 
4807
4916
  // spine-core/src/attachments/MeshAttachment.ts
4808
4917
  var MeshAttachment = class extends VertexAttachment {
4918
+ region = null;
4919
+ /** The name of the texture region for this attachment. */
4920
+ path;
4921
+ /** The UV pair for each vertex, normalized within the texture region. */
4922
+ regionUVs = [];
4923
+ /** The UV pair for each vertex, normalized within the entire texture.
4924
+ *
4925
+ * See {@link #updateUVs}. */
4926
+ uvs = [];
4927
+ /** Triplets of vertex indices which describe the mesh's triangulation. */
4928
+ triangles = [];
4929
+ /** The color to tint the mesh. */
4930
+ color = new Color(1, 1, 1, 1);
4931
+ /** The width of the mesh's image. Available only when nonessential data was exported. */
4932
+ width = 0;
4933
+ /** The height of the mesh's image. Available only when nonessential data was exported. */
4934
+ height = 0;
4935
+ /** The number of entries at the beginning of {@link #vertices} that make up the mesh hull. */
4936
+ hullLength = 0;
4937
+ /** Vertex index pairs describing edges for controling triangulation. Mesh triangles will never cross edges. Only available if
4938
+ * nonessential data was exported. Triangulation is not performed at runtime. */
4939
+ edges = [];
4940
+ parentMesh = null;
4941
+ sequence = null;
4942
+ tempColor = new Color(0, 0, 0, 0);
4809
4943
  constructor(name, path) {
4810
4944
  super(name);
4811
- this.region = null;
4812
- /** The UV pair for each vertex, normalized within the texture region. */
4813
- this.regionUVs = [];
4814
- /** The UV pair for each vertex, normalized within the entire texture.
4815
- *
4816
- * See {@link #updateUVs}. */
4817
- this.uvs = [];
4818
- /** Triplets of vertex indices which describe the mesh's triangulation. */
4819
- this.triangles = [];
4820
- /** The color to tint the mesh. */
4821
- this.color = new Color(1, 1, 1, 1);
4822
- /** The width of the mesh's image. Available only when nonessential data was exported. */
4823
- this.width = 0;
4824
- /** The height of the mesh's image. Available only when nonessential data was exported. */
4825
- this.height = 0;
4826
- /** The number of entries at the beginning of {@link #vertices} that make up the mesh hull. */
4827
- this.hullLength = 0;
4828
- /** Vertex index pairs describing edges for controling triangulation. Mesh triangles will never cross edges. Only available if
4829
- * nonessential data was exported. Triangulation is not performed at runtime. */
4830
- this.edges = [];
4831
- this.parentMesh = null;
4832
- this.sequence = null;
4833
- this.tempColor = new Color(0, 0, 0, 0);
4834
4945
  this.path = path;
4835
4946
  }
4836
4947
  /** Calculates {@link #uvs} using the {@link #regionUVs} and region. Must be called if the region, the region's properties, or
@@ -4957,18 +5068,18 @@ var spine = (() => {
4957
5068
 
4958
5069
  // spine-core/src/attachments/PathAttachment.ts
4959
5070
  var PathAttachment = class extends VertexAttachment {
5071
+ /** The lengths along the path in the setup pose from the start of the path to the end of each Bezier curve. */
5072
+ lengths = [];
5073
+ /** If true, the start and end knots are connected. */
5074
+ closed = false;
5075
+ /** If true, additional calculations are performed to make calculating positions along the path more accurate. If false, fewer
5076
+ * calculations are performed but calculating positions along the path is less accurate. */
5077
+ constantSpeed = false;
5078
+ /** The color of the path as it was in Spine. Available only when nonessential data was exported. Paths are not usually
5079
+ * rendered at runtime. */
5080
+ color = new Color(1, 1, 1, 1);
4960
5081
  constructor(name) {
4961
5082
  super(name);
4962
- /** The lengths along the path in the setup pose from the start of the path to the end of each Bezier curve. */
4963
- this.lengths = [];
4964
- /** If true, the start and end knots are connected. */
4965
- this.closed = false;
4966
- /** If true, additional calculations are performed to make calculating positions along the path more accurate. If false, fewer
4967
- * calculations are performed but calculating positions along the path is less accurate. */
4968
- this.constantSpeed = false;
4969
- /** The color of the path as it was in Spine. Available only when nonessential data was exported. Paths are not usually
4970
- * rendered at runtime. */
4971
- this.color = new Color(1, 1, 1, 1);
4972
5083
  }
4973
5084
  copy() {
4974
5085
  let copy = new PathAttachment(this.name);
@@ -4984,14 +5095,14 @@ var spine = (() => {
4984
5095
 
4985
5096
  // spine-core/src/attachments/PointAttachment.ts
4986
5097
  var PointAttachment = class extends VertexAttachment {
5098
+ x = 0;
5099
+ y = 0;
5100
+ rotation = 0;
5101
+ /** The color of the point attachment as it was in Spine. Available only when nonessential data was exported. Point attachments
5102
+ * are not usually rendered at runtime. */
5103
+ color = new Color(0.38, 0.94, 0, 1);
4987
5104
  constructor(name) {
4988
5105
  super(name);
4989
- this.x = 0;
4990
- this.y = 0;
4991
- this.rotation = 0;
4992
- /** The color of the point attachment as it was in Spine. Available only when nonessential data was exported. Point attachments
4993
- * are not usually rendered at runtime. */
4994
- this.color = new Color(0.38, 0.94, 0, 1);
4995
5106
  }
4996
5107
  computeWorldPosition(bone, point) {
4997
5108
  point.x = this.x * bone.a + this.y * bone.b + bone.worldX;
@@ -4999,10 +5110,10 @@ var spine = (() => {
4999
5110
  return point;
5000
5111
  }
5001
5112
  computeWorldRotation(bone) {
5002
- let cos = MathUtils.cosDeg(this.rotation), sin = MathUtils.sinDeg(this.rotation);
5003
- let x = cos * bone.a + sin * bone.b;
5004
- let y = cos * bone.c + sin * bone.d;
5005
- return Math.atan2(y, x) * MathUtils.radDeg;
5113
+ const r = this.rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
5114
+ const x = cos * bone.a + sin * bone.b;
5115
+ const y = cos * bone.c + sin * bone.d;
5116
+ return MathUtils.atan2Deg(y, x);
5006
5117
  }
5007
5118
  copy() {
5008
5119
  let copy = new PointAttachment(this.name);
@@ -5016,32 +5127,34 @@ var spine = (() => {
5016
5127
 
5017
5128
  // spine-core/src/attachments/RegionAttachment.ts
5018
5129
  var _RegionAttachment = class extends Attachment {
5130
+ /** The local x translation. */
5131
+ x = 0;
5132
+ /** The local y translation. */
5133
+ y = 0;
5134
+ /** The local scaleX. */
5135
+ scaleX = 1;
5136
+ /** The local scaleY. */
5137
+ scaleY = 1;
5138
+ /** The local rotation. */
5139
+ rotation = 0;
5140
+ /** The width of the region attachment in Spine. */
5141
+ width = 0;
5142
+ /** The height of the region attachment in Spine. */
5143
+ height = 0;
5144
+ /** The color to tint the region attachment. */
5145
+ color = new Color(1, 1, 1, 1);
5146
+ /** The name of the texture region for this attachment. */
5147
+ path;
5148
+ region = null;
5149
+ sequence = null;
5150
+ /** For each of the 4 vertices, a pair of <code>x,y</code> values that is the local position of the vertex.
5151
+ *
5152
+ * See {@link #updateOffset()}. */
5153
+ offset = Utils.newFloatArray(8);
5154
+ uvs = Utils.newFloatArray(8);
5155
+ tempColor = new Color(1, 1, 1, 1);
5019
5156
  constructor(name, path) {
5020
5157
  super(name);
5021
- /** The local x translation. */
5022
- this.x = 0;
5023
- /** The local y translation. */
5024
- this.y = 0;
5025
- /** The local scaleX. */
5026
- this.scaleX = 1;
5027
- /** The local scaleY. */
5028
- this.scaleY = 1;
5029
- /** The local rotation. */
5030
- this.rotation = 0;
5031
- /** The width of the region attachment in Spine. */
5032
- this.width = 0;
5033
- /** The height of the region attachment in Spine. */
5034
- this.height = 0;
5035
- /** The color to tint the region attachment. */
5036
- this.color = new Color(1, 1, 1, 1);
5037
- this.region = null;
5038
- this.sequence = null;
5039
- /** For each of the 4 vertices, a pair of <code>x,y</code> values that is the local position of the vertex.
5040
- *
5041
- * See {@link #updateOffset()}. */
5042
- this.offset = Utils.newFloatArray(8);
5043
- this.uvs = Utils.newFloatArray(8);
5044
- this.tempColor = new Color(1, 1, 1, 1);
5045
5158
  this.path = path;
5046
5159
  }
5047
5160
  /** Calculates the {@link #offset} using the region settings. Must be called after changing region settings. */
@@ -5067,7 +5180,7 @@ var spine = (() => {
5067
5180
  let localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
5068
5181
  let localX2 = localX + this.region.width * regionScaleX;
5069
5182
  let localY2 = localY + this.region.height * regionScaleY;
5070
- let radians = this.rotation * Math.PI / 180;
5183
+ let radians = this.rotation * MathUtils.degRad;
5071
5184
  let cos = Math.cos(radians);
5072
5185
  let sin = Math.sin(radians);
5073
5186
  let x = this.x, y = this.y;
@@ -5162,41 +5275,42 @@ var spine = (() => {
5162
5275
  }
5163
5276
  };
5164
5277
  var RegionAttachment = _RegionAttachment;
5165
- RegionAttachment.X1 = 0;
5166
- RegionAttachment.Y1 = 1;
5167
- RegionAttachment.C1R = 2;
5168
- RegionAttachment.C1G = 3;
5169
- RegionAttachment.C1B = 4;
5170
- RegionAttachment.C1A = 5;
5171
- RegionAttachment.U1 = 6;
5172
- RegionAttachment.V1 = 7;
5173
- RegionAttachment.X2 = 8;
5174
- RegionAttachment.Y2 = 9;
5175
- RegionAttachment.C2R = 10;
5176
- RegionAttachment.C2G = 11;
5177
- RegionAttachment.C2B = 12;
5178
- RegionAttachment.C2A = 13;
5179
- RegionAttachment.U2 = 14;
5180
- RegionAttachment.V2 = 15;
5181
- RegionAttachment.X3 = 16;
5182
- RegionAttachment.Y3 = 17;
5183
- RegionAttachment.C3R = 18;
5184
- RegionAttachment.C3G = 19;
5185
- RegionAttachment.C3B = 20;
5186
- RegionAttachment.C3A = 21;
5187
- RegionAttachment.U3 = 22;
5188
- RegionAttachment.V3 = 23;
5189
- RegionAttachment.X4 = 24;
5190
- RegionAttachment.Y4 = 25;
5191
- RegionAttachment.C4R = 26;
5192
- RegionAttachment.C4G = 27;
5193
- RegionAttachment.C4B = 28;
5194
- RegionAttachment.C4A = 29;
5195
- RegionAttachment.U4 = 30;
5196
- RegionAttachment.V4 = 31;
5278
+ __publicField(RegionAttachment, "X1", 0);
5279
+ __publicField(RegionAttachment, "Y1", 1);
5280
+ __publicField(RegionAttachment, "C1R", 2);
5281
+ __publicField(RegionAttachment, "C1G", 3);
5282
+ __publicField(RegionAttachment, "C1B", 4);
5283
+ __publicField(RegionAttachment, "C1A", 5);
5284
+ __publicField(RegionAttachment, "U1", 6);
5285
+ __publicField(RegionAttachment, "V1", 7);
5286
+ __publicField(RegionAttachment, "X2", 8);
5287
+ __publicField(RegionAttachment, "Y2", 9);
5288
+ __publicField(RegionAttachment, "C2R", 10);
5289
+ __publicField(RegionAttachment, "C2G", 11);
5290
+ __publicField(RegionAttachment, "C2B", 12);
5291
+ __publicField(RegionAttachment, "C2A", 13);
5292
+ __publicField(RegionAttachment, "U2", 14);
5293
+ __publicField(RegionAttachment, "V2", 15);
5294
+ __publicField(RegionAttachment, "X3", 16);
5295
+ __publicField(RegionAttachment, "Y3", 17);
5296
+ __publicField(RegionAttachment, "C3R", 18);
5297
+ __publicField(RegionAttachment, "C3G", 19);
5298
+ __publicField(RegionAttachment, "C3B", 20);
5299
+ __publicField(RegionAttachment, "C3A", 21);
5300
+ __publicField(RegionAttachment, "U3", 22);
5301
+ __publicField(RegionAttachment, "V3", 23);
5302
+ __publicField(RegionAttachment, "X4", 24);
5303
+ __publicField(RegionAttachment, "Y4", 25);
5304
+ __publicField(RegionAttachment, "C4R", 26);
5305
+ __publicField(RegionAttachment, "C4G", 27);
5306
+ __publicField(RegionAttachment, "C4B", 28);
5307
+ __publicField(RegionAttachment, "C4A", 29);
5308
+ __publicField(RegionAttachment, "U4", 30);
5309
+ __publicField(RegionAttachment, "V4", 31);
5197
5310
 
5198
5311
  // spine-core/src/AtlasAttachmentLoader.ts
5199
5312
  var AtlasAttachmentLoader = class {
5313
+ atlas;
5200
5314
  constructor(atlas) {
5201
5315
  this.atlas = atlas;
5202
5316
  }
@@ -5250,36 +5364,42 @@ var spine = (() => {
5250
5364
 
5251
5365
  // spine-core/src/BoneData.ts
5252
5366
  var BoneData = class {
5367
+ /** The index of the bone in {@link Skeleton#getBones()}. */
5368
+ index = 0;
5369
+ /** The name of the bone, which is unique across all bones in the skeleton. */
5370
+ name;
5371
+ /** @returns May be null. */
5372
+ parent = null;
5373
+ /** The bone's length. */
5374
+ length = 0;
5375
+ /** The local x translation. */
5376
+ x = 0;
5377
+ /** The local y translation. */
5378
+ y = 0;
5379
+ /** The local rotation in degrees, counter clockwise. */
5380
+ rotation = 0;
5381
+ /** The local scaleX. */
5382
+ scaleX = 1;
5383
+ /** The local scaleY. */
5384
+ scaleY = 1;
5385
+ /** The local shearX. */
5386
+ shearX = 0;
5387
+ /** The local shearX. */
5388
+ shearY = 0;
5389
+ /** The transform mode for how parent world transforms affect this bone. */
5390
+ transformMode = TransformMode.Normal;
5391
+ /** When true, {@link Skeleton#updateWorldTransform()} only updates this bone if the {@link Skeleton#skin} contains this
5392
+ * bone.
5393
+ * @see Skin#bones */
5394
+ skinRequired = false;
5395
+ /** The color of the bone as it was in Spine. Available only when nonessential data was exported. Bones are not usually
5396
+ * rendered at runtime. */
5397
+ color = new Color();
5398
+ /** The bone icon as it was in Spine, or null if nonessential data was not exported. */
5399
+ icon;
5400
+ /** False if the bone was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
5401
+ visible = false;
5253
5402
  constructor(index, name, parent) {
5254
- /** The index of the bone in {@link Skeleton#getBones()}. */
5255
- this.index = 0;
5256
- /** @returns May be null. */
5257
- this.parent = null;
5258
- /** The bone's length. */
5259
- this.length = 0;
5260
- /** The local x translation. */
5261
- this.x = 0;
5262
- /** The local y translation. */
5263
- this.y = 0;
5264
- /** The local rotation. */
5265
- this.rotation = 0;
5266
- /** The local scaleX. */
5267
- this.scaleX = 1;
5268
- /** The local scaleY. */
5269
- this.scaleY = 1;
5270
- /** The local shearX. */
5271
- this.shearX = 0;
5272
- /** The local shearX. */
5273
- this.shearY = 0;
5274
- /** The transform mode for how parent world transforms affect this bone. */
5275
- this.transformMode = TransformMode.Normal;
5276
- /** When true, {@link Skeleton#updateWorldTransform()} only updates this bone if the {@link Skeleton#skin} contains this
5277
- * bone.
5278
- * @see Skin#bones */
5279
- this.skinRequired = false;
5280
- /** The color of the bone as it was in Spine. Available only when nonessential data was exported. Bones are not usually
5281
- * rendered at runtime. */
5282
- this.color = new Color();
5283
5403
  if (index < 0)
5284
5404
  throw new Error("index must be >= 0.");
5285
5405
  if (!name)
@@ -5300,54 +5420,58 @@ var spine = (() => {
5300
5420
 
5301
5421
  // spine-core/src/Bone.ts
5302
5422
  var Bone = class {
5423
+ /** The bone's setup pose data. */
5424
+ data;
5425
+ /** The skeleton this bone belongs to. */
5426
+ skeleton;
5427
+ /** The parent bone, or null if this is the root bone. */
5428
+ parent = null;
5429
+ /** The immediate children of this bone. */
5430
+ children = new Array();
5431
+ /** The local x translation. */
5432
+ x = 0;
5433
+ /** The local y translation. */
5434
+ y = 0;
5435
+ /** The local rotation in degrees, counter clockwise. */
5436
+ rotation = 0;
5437
+ /** The local scaleX. */
5438
+ scaleX = 0;
5439
+ /** The local scaleY. */
5440
+ scaleY = 0;
5441
+ /** The local shearX. */
5442
+ shearX = 0;
5443
+ /** The local shearY. */
5444
+ shearY = 0;
5445
+ /** The applied local x translation. */
5446
+ ax = 0;
5447
+ /** The applied local y translation. */
5448
+ ay = 0;
5449
+ /** The applied local rotation in degrees, counter clockwise. */
5450
+ arotation = 0;
5451
+ /** The applied local scaleX. */
5452
+ ascaleX = 0;
5453
+ /** The applied local scaleY. */
5454
+ ascaleY = 0;
5455
+ /** The applied local shearX. */
5456
+ ashearX = 0;
5457
+ /** The applied local shearY. */
5458
+ ashearY = 0;
5459
+ /** Part of the world transform matrix for the X axis. If changed, {@link #updateAppliedTransform()} should be called. */
5460
+ a = 0;
5461
+ /** Part of the world transform matrix for the Y axis. If changed, {@link #updateAppliedTransform()} should be called. */
5462
+ b = 0;
5463
+ /** Part of the world transform matrix for the X axis. If changed, {@link #updateAppliedTransform()} should be called. */
5464
+ c = 0;
5465
+ /** Part of the world transform matrix for the Y axis. If changed, {@link #updateAppliedTransform()} should be called. */
5466
+ d = 0;
5467
+ /** The world X position. If changed, {@link #updateAppliedTransform()} should be called. */
5468
+ worldY = 0;
5469
+ /** The world Y position. If changed, {@link #updateAppliedTransform()} should be called. */
5470
+ worldX = 0;
5471
+ sorted = false;
5472
+ active = false;
5303
5473
  /** @param parent May be null. */
5304
5474
  constructor(data, skeleton, parent) {
5305
- /** The parent bone, or null if this is the root bone. */
5306
- this.parent = null;
5307
- /** The immediate children of this bone. */
5308
- this.children = new Array();
5309
- /** The local x translation. */
5310
- this.x = 0;
5311
- /** The local y translation. */
5312
- this.y = 0;
5313
- /** The local rotation in degrees, counter clockwise. */
5314
- this.rotation = 0;
5315
- /** The local scaleX. */
5316
- this.scaleX = 0;
5317
- /** The local scaleY. */
5318
- this.scaleY = 0;
5319
- /** The local shearX. */
5320
- this.shearX = 0;
5321
- /** The local shearY. */
5322
- this.shearY = 0;
5323
- /** The applied local x translation. */
5324
- this.ax = 0;
5325
- /** The applied local y translation. */
5326
- this.ay = 0;
5327
- /** The applied local rotation in degrees, counter clockwise. */
5328
- this.arotation = 0;
5329
- /** The applied local scaleX. */
5330
- this.ascaleX = 0;
5331
- /** The applied local scaleY. */
5332
- this.ascaleY = 0;
5333
- /** The applied local shearX. */
5334
- this.ashearX = 0;
5335
- /** The applied local shearY. */
5336
- this.ashearY = 0;
5337
- /** Part of the world transform matrix for the X axis. If changed, {@link #updateAppliedTransform()} should be called. */
5338
- this.a = 0;
5339
- /** Part of the world transform matrix for the Y axis. If changed, {@link #updateAppliedTransform()} should be called. */
5340
- this.b = 0;
5341
- /** Part of the world transform matrix for the X axis. If changed, {@link #updateAppliedTransform()} should be called. */
5342
- this.c = 0;
5343
- /** Part of the world transform matrix for the Y axis. If changed, {@link #updateAppliedTransform()} should be called. */
5344
- this.d = 0;
5345
- /** The world X position. If changed, {@link #updateAppliedTransform()} should be called. */
5346
- this.worldY = 0;
5347
- /** The world Y position. If changed, {@link #updateAppliedTransform()} should be called. */
5348
- this.worldX = 0;
5349
- this.sorted = false;
5350
- this.active = false;
5351
5475
  if (!data)
5352
5476
  throw new Error("data cannot be null.");
5353
5477
  if (!skeleton)
@@ -5363,7 +5487,7 @@ var spine = (() => {
5363
5487
  return this.active;
5364
5488
  }
5365
5489
  /** Computes the world transform using the parent bone and this bone's local applied transform. */
5366
- update() {
5490
+ update(physics) {
5367
5491
  this.updateWorldTransformWith(this.ax, this.ay, this.arotation, this.ascaleX, this.ascaleY, this.ashearX, this.ashearY);
5368
5492
  }
5369
5493
  /** Computes the world transform using the parent bone and this bone's local transform.
@@ -5388,13 +5512,13 @@ var spine = (() => {
5388
5512
  let parent = this.parent;
5389
5513
  if (!parent) {
5390
5514
  let skeleton = this.skeleton;
5391
- let rotationY = rotation + 90 + shearY;
5392
- let sx = skeleton.scaleX;
5393
- let sy = skeleton.scaleY;
5394
- this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
5395
- this.b = MathUtils.cosDeg(rotationY) * scaleY * sx;
5396
- this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
5397
- this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
5515
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
5516
+ const rx = (rotation + shearX) * MathUtils.degRad;
5517
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5518
+ this.a = Math.cos(rx) * scaleX * sx;
5519
+ this.b = Math.cos(ry) * scaleY * sx;
5520
+ this.c = Math.sin(rx) * scaleX * sy;
5521
+ this.d = Math.sin(ry) * scaleY * sy;
5398
5522
  this.worldX = x * sx + skeleton.x;
5399
5523
  this.worldY = y * sy + skeleton.y;
5400
5524
  return;
@@ -5404,11 +5528,12 @@ var spine = (() => {
5404
5528
  this.worldY = pc * x + pd * y + parent.worldY;
5405
5529
  switch (this.data.transformMode) {
5406
5530
  case 0 /* Normal */: {
5407
- let rotationY = rotation + 90 + shearY;
5408
- let la = MathUtils.cosDeg(rotation + shearX) * scaleX;
5409
- let lb = MathUtils.cosDeg(rotationY) * scaleY;
5410
- let lc = MathUtils.sinDeg(rotation + shearX) * scaleX;
5411
- let ld = MathUtils.sinDeg(rotationY) * scaleY;
5531
+ const rx = (rotation + shearX) * MathUtils.degRad;
5532
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5533
+ const la = Math.cos(rx) * scaleX;
5534
+ const lb = Math.cos(ry) * scaleY;
5535
+ const lc = Math.sin(rx) * scaleX;
5536
+ const ld = Math.sin(ry) * scaleY;
5412
5537
  this.a = pa * la + pb * lc;
5413
5538
  this.b = pa * lb + pb * ld;
5414
5539
  this.c = pc * la + pd * lc;
@@ -5416,11 +5541,12 @@ var spine = (() => {
5416
5541
  return;
5417
5542
  }
5418
5543
  case 1 /* OnlyTranslation */: {
5419
- let rotationY = rotation + 90 + shearY;
5420
- this.a = MathUtils.cosDeg(rotation + shearX) * scaleX;
5421
- this.b = MathUtils.cosDeg(rotationY) * scaleY;
5422
- this.c = MathUtils.sinDeg(rotation + shearX) * scaleX;
5423
- this.d = MathUtils.sinDeg(rotationY) * scaleY;
5544
+ const rx = (rotation + shearX) * MathUtils.degRad;
5545
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5546
+ this.a = Math.cos(rx) * scaleX;
5547
+ this.b = Math.cos(ry) * scaleY;
5548
+ this.c = Math.sin(rx) * scaleX;
5549
+ this.d = Math.sin(ry) * scaleY;
5424
5550
  break;
5425
5551
  }
5426
5552
  case 2 /* NoRotationOrReflection */: {
@@ -5438,12 +5564,12 @@ var spine = (() => {
5438
5564
  pc = 0;
5439
5565
  prx = 90 - Math.atan2(pd, pb) * MathUtils.radDeg;
5440
5566
  }
5441
- let rx = rotation + shearX - prx;
5442
- let ry = rotation + shearY - prx + 90;
5443
- let la = MathUtils.cosDeg(rx) * scaleX;
5444
- let lb = MathUtils.cosDeg(ry) * scaleY;
5445
- let lc = MathUtils.sinDeg(rx) * scaleX;
5446
- let ld = MathUtils.sinDeg(ry) * scaleY;
5567
+ const rx = (rotation + shearX - prx) * MathUtils.degRad;
5568
+ const ry = (rotation + shearY - prx + 90) * MathUtils.degRad;
5569
+ const la = Math.cos(rx) * scaleX;
5570
+ const lb = Math.cos(ry) * scaleY;
5571
+ const lc = Math.sin(rx) * scaleX;
5572
+ const ld = Math.sin(ry) * scaleY;
5447
5573
  this.a = pa * la - pb * lc;
5448
5574
  this.b = pa * lb - pb * ld;
5449
5575
  this.c = pc * la + pd * lc;
@@ -5452,8 +5578,8 @@ var spine = (() => {
5452
5578
  }
5453
5579
  case 3 /* NoScale */:
5454
5580
  case 4 /* NoScaleOrReflection */: {
5455
- let cos = MathUtils.cosDeg(rotation);
5456
- let sin = MathUtils.sinDeg(rotation);
5581
+ rotation *= MathUtils.degRad;
5582
+ const cos = Math.cos(rotation), sin = Math.sin(rotation);
5457
5583
  let za = (pa * cos + pb * sin) / this.skeleton.scaleX;
5458
5584
  let zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
5459
5585
  let s = Math.sqrt(za * za + zc * zc);
@@ -5464,13 +5590,15 @@ var spine = (() => {
5464
5590
  s = Math.sqrt(za * za + zc * zc);
5465
5591
  if (this.data.transformMode == 3 /* NoScale */ && pa * pd - pb * pc < 0 != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
5466
5592
  s = -s;
5467
- let r = Math.PI / 2 + Math.atan2(zc, za);
5468
- let zb = Math.cos(r) * s;
5469
- let zd = Math.sin(r) * s;
5470
- let la = MathUtils.cosDeg(shearX) * scaleX;
5471
- let lb = MathUtils.cosDeg(90 + shearY) * scaleY;
5472
- let lc = MathUtils.sinDeg(shearX) * scaleX;
5473
- let ld = MathUtils.sinDeg(90 + shearY) * scaleY;
5593
+ rotation = Math.PI / 2 + Math.atan2(zc, za);
5594
+ const zb = Math.cos(rotation) * s;
5595
+ const zd = Math.sin(rotation) * s;
5596
+ shearX *= MathUtils.degRad;
5597
+ shearY = (90 + shearY) * MathUtils.degRad;
5598
+ const la = Math.cos(shearX) * scaleX;
5599
+ const lb = Math.cos(shearY) * scaleY;
5600
+ const lc = Math.sin(shearX) * scaleX;
5601
+ const ld = Math.sin(shearY) * scaleY;
5474
5602
  this.a = za * la + zb * lc;
5475
5603
  this.b = za * lb + zb * ld;
5476
5604
  this.c = zc * la + zd * lc;
@@ -5494,22 +5622,6 @@ var spine = (() => {
5494
5622
  this.shearX = data.shearX;
5495
5623
  this.shearY = data.shearY;
5496
5624
  }
5497
- /** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. */
5498
- getWorldRotationX() {
5499
- return Math.atan2(this.c, this.a) * MathUtils.radDeg;
5500
- }
5501
- /** The world rotation for the Y axis, calculated using {@link #b} and {@link #d}. */
5502
- getWorldRotationY() {
5503
- return Math.atan2(this.d, this.b) * MathUtils.radDeg;
5504
- }
5505
- /** The magnitude (always positive) of the world scale X, calculated using {@link #a} and {@link #c}. */
5506
- getWorldScaleX() {
5507
- return Math.sqrt(this.a * this.a + this.c * this.c);
5508
- }
5509
- /** The magnitude (always positive) of the world scale Y, calculated using {@link #b} and {@link #d}. */
5510
- getWorldScaleY() {
5511
- return Math.sqrt(this.b * this.b + this.d * this.d);
5512
- }
5513
5625
  /** Computes the applied transform values from the world transform.
5514
5626
  *
5515
5627
  * If the world transform is modified (by a constraint, {@link #rotateWorld(float)}, etc) then this method should be called so
@@ -5596,6 +5708,22 @@ var spine = (() => {
5596
5708
  this.arotation = 90 - Math.atan2(rd, rb) * MathUtils.radDeg;
5597
5709
  }
5598
5710
  }
5711
+ /** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. */
5712
+ getWorldRotationX() {
5713
+ return Math.atan2(this.c, this.a) * MathUtils.radDeg;
5714
+ }
5715
+ /** The world rotation for the Y axis, calculated using {@link #b} and {@link #d}. */
5716
+ getWorldRotationY() {
5717
+ return Math.atan2(this.d, this.b) * MathUtils.radDeg;
5718
+ }
5719
+ /** The magnitude (always positive) of the world scale X, calculated using {@link #a} and {@link #c}. */
5720
+ getWorldScaleX() {
5721
+ return Math.sqrt(this.a * this.a + this.c * this.c);
5722
+ }
5723
+ /** The magnitude (always positive) of the world scale Y, calculated using {@link #b} and {@link #d}. */
5724
+ getWorldScaleY() {
5725
+ return Math.sqrt(this.b * this.b + this.d * this.d);
5726
+ }
5599
5727
  /** Transforms a point from world coordinates to the bone's local coordinates. */
5600
5728
  worldToLocal(world) {
5601
5729
  let invDet = 1 / (this.a * this.d - this.b * this.c);
@@ -5611,6 +5739,18 @@ var spine = (() => {
5611
5739
  local.y = x * this.c + y * this.d + this.worldY;
5612
5740
  return local;
5613
5741
  }
5742
+ /** Transforms a point from world coordinates to the parent bone's local coordinates. */
5743
+ worldToParent(world) {
5744
+ if (world == null)
5745
+ throw new Error("world cannot be null.");
5746
+ return this.parent == null ? world : this.parent.worldToLocal(world);
5747
+ }
5748
+ /** Transforms a point from the parent bone's coordinates to world coordinates. */
5749
+ parentToWorld(world) {
5750
+ if (world == null)
5751
+ throw new Error("world cannot be null.");
5752
+ return this.parent == null ? world : this.parent.localToWorld(world);
5753
+ }
5614
5754
  /** Transforms a world rotation to a local rotation. */
5615
5755
  worldToLocalRotation(worldRotation) {
5616
5756
  let sin = MathUtils.sinDeg(worldRotation), cos = MathUtils.cosDeg(worldRotation);
@@ -5624,15 +5764,16 @@ var spine = (() => {
5624
5764
  }
5625
5765
  /** Rotates the world transform the specified amount.
5626
5766
  * <p>
5627
- * After changes are made to the world transform, {@link #updateAppliedTransform()} should be called and {@link #update()} will
5628
- * need to be called on any child bones, recursively. */
5767
+ * After changes are made to the world transform, {@link #updateAppliedTransform()} should be called and
5768
+ * {@link #update(Physics)} will need to be called on any child bones, recursively. */
5629
5769
  rotateWorld(degrees) {
5630
- let a = this.a, b = this.b, c = this.c, d = this.d;
5631
- let cos = MathUtils.cosDeg(degrees), sin = MathUtils.sinDeg(degrees);
5632
- this.a = cos * a - sin * c;
5633
- this.b = cos * b - sin * d;
5634
- this.c = sin * a + cos * c;
5635
- this.d = sin * b + cos * d;
5770
+ degrees *= MathUtils.degRad;
5771
+ const sin = Math.sin(degrees), cos = Math.cos(degrees);
5772
+ const ra = this.a, rb = this.b;
5773
+ this.a = cos * ra - sin * this.c;
5774
+ this.b = cos * rb - sin * this.d;
5775
+ this.c = sin * ra + cos * this.c;
5776
+ this.d = sin * rb + cos * this.d;
5636
5777
  }
5637
5778
  };
5638
5779
 
@@ -5647,12 +5788,14 @@ var spine = (() => {
5647
5788
 
5648
5789
  // spine-core/src/AssetManagerBase.ts
5649
5790
  var AssetManagerBase = class {
5791
+ pathPrefix = "";
5792
+ textureLoader;
5793
+ downloader;
5794
+ assets = {};
5795
+ errors = {};
5796
+ toLoad = 0;
5797
+ loaded = 0;
5650
5798
  constructor(textureLoader, pathPrefix = "", downloader = new Downloader()) {
5651
- this.pathPrefix = "";
5652
- this.assets = {};
5653
- this.errors = {};
5654
- this.toLoad = 0;
5655
- this.loaded = 0;
5656
5799
  this.textureLoader = textureLoader;
5657
5800
  this.pathPrefix = pathPrefix;
5658
5801
  this.downloader = downloader;
@@ -5837,10 +5980,8 @@ var spine = (() => {
5837
5980
  }
5838
5981
  };
5839
5982
  var Downloader = class {
5840
- constructor() {
5841
- this.callbacks = {};
5842
- this.rawDataUris = {};
5843
- }
5983
+ callbacks = {};
5984
+ rawDataUris = {};
5844
5985
  dataUriToString(dataUri) {
5845
5986
  if (!dataUri.startsWith("data:")) {
5846
5987
  throw new Error("Not a data URI.");
@@ -5947,13 +6088,14 @@ var spine = (() => {
5947
6088
 
5948
6089
  // spine-core/src/Event.ts
5949
6090
  var Event = class {
6091
+ data;
6092
+ intValue = 0;
6093
+ floatValue = 0;
6094
+ stringValue = null;
6095
+ time = 0;
6096
+ volume = 0;
6097
+ balance = 0;
5950
6098
  constructor(time, data) {
5951
- this.intValue = 0;
5952
- this.floatValue = 0;
5953
- this.stringValue = null;
5954
- this.time = 0;
5955
- this.volume = 0;
5956
- this.balance = 0;
5957
6099
  if (!data)
5958
6100
  throw new Error("data cannot be null.");
5959
6101
  this.time = time;
@@ -5963,32 +6105,39 @@ var spine = (() => {
5963
6105
 
5964
6106
  // spine-core/src/EventData.ts
5965
6107
  var EventData = class {
6108
+ name;
6109
+ intValue = 0;
6110
+ floatValue = 0;
6111
+ stringValue = null;
6112
+ audioPath = null;
6113
+ volume = 0;
6114
+ balance = 0;
5966
6115
  constructor(name) {
5967
- this.intValue = 0;
5968
- this.floatValue = 0;
5969
- this.stringValue = null;
5970
- this.audioPath = null;
5971
- this.volume = 0;
5972
- this.balance = 0;
5973
6116
  this.name = name;
5974
6117
  }
5975
6118
  };
5976
6119
 
5977
6120
  // spine-core/src/IkConstraint.ts
5978
6121
  var IkConstraint = class {
6122
+ /** The IK constraint's setup pose data. */
6123
+ data;
6124
+ /** The bones that will be modified by this IK constraint. */
6125
+ bones;
6126
+ /** The bone that is the IK target. */
6127
+ target;
6128
+ /** Controls the bend direction of the IK bones, either 1 or -1. */
6129
+ bendDirection = 0;
6130
+ /** When true and only a single bone is being constrained, if the target is too close, the bone is scaled to reach it. */
6131
+ compress = false;
6132
+ /** When true, if the target is out of range, the parent bone is scaled to reach it. If more than one bone is being constrained
6133
+ * and the parent bone has local nonuniform scale, stretch is not applied. */
6134
+ stretch = false;
6135
+ /** A percentage (0-1) that controls the mix between the constrained and unconstrained rotations. */
6136
+ mix = 1;
6137
+ /** For two bone IK, the distance from the maximum reach of the bones that rotation will slow. */
6138
+ softness = 0;
6139
+ active = false;
5979
6140
  constructor(data, skeleton) {
5980
- /** Controls the bend direction of the IK bones, either 1 or -1. */
5981
- this.bendDirection = 0;
5982
- /** When true and only a single bone is being constrained, if the target is too close, the bone is scaled to reach it. */
5983
- this.compress = false;
5984
- /** When true, if the target is out of range, the parent bone is scaled to reach it. If more than one bone is being constrained
5985
- * and the parent bone has local nonuniform scale, stretch is not applied. */
5986
- this.stretch = false;
5987
- /** A percentage (0-1) that controls the mix between the constrained and unconstrained rotations. */
5988
- this.mix = 1;
5989
- /** For two bone IK, the distance from the maximum reach of the bones that rotation will slow. */
5990
- this.softness = 0;
5991
- this.active = false;
5992
6141
  if (!data)
5993
6142
  throw new Error("data cannot be null.");
5994
6143
  if (!skeleton)
@@ -6014,7 +6163,15 @@ var spine = (() => {
6014
6163
  isActive() {
6015
6164
  return this.active;
6016
6165
  }
6017
- update() {
6166
+ setToSetupPose() {
6167
+ const data = this.data;
6168
+ this.mix = data.mix;
6169
+ this.softness = data.softness;
6170
+ this.bendDirection = data.bendDirection;
6171
+ this.compress = data.compress;
6172
+ this.stretch = data.stretch;
6173
+ }
6174
+ update(physics) {
6018
6175
  if (this.mix == 0)
6019
6176
  return;
6020
6177
  let target = this.target;
@@ -6073,12 +6230,15 @@ var spine = (() => {
6073
6230
  tx = targetX - bone.worldX;
6074
6231
  ty = targetY - bone.worldY;
6075
6232
  }
6076
- let b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty);
6077
- if (compress && dd < b || stretch && dd > b && b > 1e-4) {
6078
- let s = (dd / b - 1) * alpha + 1;
6079
- sx *= s;
6080
- if (uniform)
6081
- sy *= s;
6233
+ const b = bone.data.length * sx;
6234
+ if (b > 1e-4) {
6235
+ const dd = tx * tx + ty * ty;
6236
+ if (compress && dd < b * b || stretch && dd > b * b) {
6237
+ const s = (Math.sqrt(dd) / b - 1) * alpha + 1;
6238
+ sx *= s;
6239
+ if (uniform)
6240
+ sy *= s;
6241
+ }
6082
6242
  }
6083
6243
  }
6084
6244
  bone.updateWorldTransformWith(
@@ -6246,27 +6406,10 @@ var spine = (() => {
6246
6406
 
6247
6407
  // spine-core/src/IkConstraintData.ts
6248
6408
  var IkConstraintData = class extends ConstraintData {
6249
- constructor(name) {
6250
- super(name, 0, false);
6251
- /** The bones that are constrained by this IK constraint. */
6252
- this.bones = new Array();
6253
- /** The bone that is the IK target. */
6254
- this._target = null;
6255
- /** Controls the bend direction of the IK bones, either 1 or -1. */
6256
- this.bendDirection = 1;
6257
- /** When true and only a single bone is being constrained, if the target is too close, the bone is scaled to reach it. */
6258
- this.compress = false;
6259
- /** When true, if the target is out of range, the parent bone is scaled to reach it. If more than one bone is being constrained
6260
- * and the parent bone has local nonuniform scale, stretch is not applied. */
6261
- this.stretch = false;
6262
- /** When true, only a single bone is being constrained, and {@link #getCompress()} or {@link #getStretch()} is used, the bone
6263
- * is scaled on both the X and Y axes. */
6264
- this.uniform = false;
6265
- /** A percentage (0-1) that controls the mix between the constrained and unconstrained rotations. */
6266
- this.mix = 1;
6267
- /** For two bone IK, the distance from the maximum reach of the bones that rotation will slow. */
6268
- this.softness = 0;
6269
- }
6409
+ /** The bones that are constrained by this IK constraint. */
6410
+ bones = new Array();
6411
+ /** The bone that is the IK target. */
6412
+ _target = null;
6270
6413
  set target(boneData) {
6271
6414
  this._target = boneData;
6272
6415
  }
@@ -6276,32 +6419,31 @@ var spine = (() => {
6276
6419
  else
6277
6420
  return this._target;
6278
6421
  }
6422
+ /** Controls the bend direction of the IK bones, either 1 or -1. */
6423
+ bendDirection = 1;
6424
+ /** When true and only a single bone is being constrained, if the target is too close, the bone is scaled to reach it. */
6425
+ compress = false;
6426
+ /** When true, if the target is out of range, the parent bone is scaled to reach it. If more than one bone is being constrained
6427
+ * and the parent bone has local nonuniform scale, stretch is not applied. */
6428
+ stretch = false;
6429
+ /** When true, only a single bone is being constrained, and {@link #getCompress()} or {@link #getStretch()} is used, the bone
6430
+ * is scaled on both the X and Y axes. */
6431
+ uniform = false;
6432
+ /** A percentage (0-1) that controls the mix between the constrained and unconstrained rotations. */
6433
+ mix = 1;
6434
+ /** For two bone IK, the distance from the maximum reach of the bones that rotation will slow. */
6435
+ softness = 0;
6436
+ constructor(name) {
6437
+ super(name, 0, false);
6438
+ }
6279
6439
  };
6280
6440
 
6281
6441
  // spine-core/src/PathConstraintData.ts
6282
6442
  var PathConstraintData = class extends ConstraintData {
6283
- constructor(name) {
6284
- super(name, 0, false);
6285
- /** The bones that will be modified by this path constraint. */
6286
- this.bones = new Array();
6287
- /** The slot whose path attachment will be used to constrained the bones. */
6288
- this._target = null;
6289
- /** The mode for positioning the first bone on the path. */
6290
- this.positionMode = PositionMode.Fixed;
6291
- /** The mode for positioning the bones after the first bone on the path. */
6292
- this.spacingMode = SpacingMode.Fixed;
6293
- /** The mode for adjusting the rotation of the bones. */
6294
- this.rotateMode = RotateMode.Chain;
6295
- /** An offset added to the constrained bone rotation. */
6296
- this.offsetRotation = 0;
6297
- /** The position along the path. */
6298
- this.position = 0;
6299
- /** The spacing between bones. */
6300
- this.spacing = 0;
6301
- this.mixRotate = 0;
6302
- this.mixX = 0;
6303
- this.mixY = 0;
6304
- }
6443
+ /** The bones that will be modified by this path constraint. */
6444
+ bones = new Array();
6445
+ /** The slot whose path attachment will be used to constrained the bones. */
6446
+ _target = null;
6305
6447
  set target(slotData) {
6306
6448
  this._target = slotData;
6307
6449
  }
@@ -6311,6 +6453,24 @@ var spine = (() => {
6311
6453
  else
6312
6454
  return this._target;
6313
6455
  }
6456
+ /** The mode for positioning the first bone on the path. */
6457
+ positionMode = PositionMode.Fixed;
6458
+ /** The mode for positioning the bones after the first bone on the path. */
6459
+ spacingMode = SpacingMode.Fixed;
6460
+ /** The mode for adjusting the rotation of the bones. */
6461
+ rotateMode = RotateMode.Chain;
6462
+ /** An offset added to the constrained bone rotation. */
6463
+ offsetRotation = 0;
6464
+ /** The position along the path. */
6465
+ position = 0;
6466
+ /** The spacing between bones. */
6467
+ spacing = 0;
6468
+ mixRotate = 0;
6469
+ mixX = 0;
6470
+ mixY = 0;
6471
+ constructor(name) {
6472
+ super(name, 0, false);
6473
+ }
6314
6474
  };
6315
6475
  var PositionMode = /* @__PURE__ */ ((PositionMode2) => {
6316
6476
  PositionMode2[PositionMode2["Fixed"] = 0] = "Fixed";
@@ -6333,21 +6493,27 @@ var spine = (() => {
6333
6493
 
6334
6494
  // spine-core/src/PathConstraint.ts
6335
6495
  var _PathConstraint = class {
6496
+ /** The path constraint's setup pose data. */
6497
+ data;
6498
+ /** The bones that will be modified by this path constraint. */
6499
+ bones;
6500
+ /** The slot whose path attachment will be used to constrained the bones. */
6501
+ target;
6502
+ /** The position along the path. */
6503
+ position = 0;
6504
+ /** The spacing between bones. */
6505
+ spacing = 0;
6506
+ mixRotate = 0;
6507
+ mixX = 0;
6508
+ mixY = 0;
6509
+ spaces = new Array();
6510
+ positions = new Array();
6511
+ world = new Array();
6512
+ curves = new Array();
6513
+ lengths = new Array();
6514
+ segments = new Array();
6515
+ active = false;
6336
6516
  constructor(data, skeleton) {
6337
- /** The position along the path. */
6338
- this.position = 0;
6339
- /** The spacing between bones. */
6340
- this.spacing = 0;
6341
- this.mixRotate = 0;
6342
- this.mixX = 0;
6343
- this.mixY = 0;
6344
- this.spaces = new Array();
6345
- this.positions = new Array();
6346
- this.world = new Array();
6347
- this.curves = new Array();
6348
- this.lengths = new Array();
6349
- this.segments = new Array();
6350
- this.active = false;
6351
6517
  if (!data)
6352
6518
  throw new Error("data cannot be null.");
6353
6519
  if (!skeleton)
@@ -6373,7 +6539,15 @@ var spine = (() => {
6373
6539
  isActive() {
6374
6540
  return this.active;
6375
6541
  }
6376
- update() {
6542
+ setToSetupPose() {
6543
+ const data = this.data;
6544
+ this.position = data.position;
6545
+ this.spacing = data.spacing;
6546
+ this.mixRotate = data.mixRotate;
6547
+ this.mixX = data.mixX;
6548
+ this.mixY = data.mixY;
6549
+ }
6550
+ update(physics) {
6377
6551
  let attachment = this.target.getAttachment();
6378
6552
  if (!(attachment instanceof PathAttachment))
6379
6553
  return;
@@ -6392,12 +6566,8 @@ var spine = (() => {
6392
6566
  for (let i = 0, n = spacesCount - 1; i < n; i++) {
6393
6567
  let bone = bones[i];
6394
6568
  let setupLength = bone.data.length;
6395
- if (setupLength < _PathConstraint.epsilon)
6396
- lengths[i] = 0;
6397
- else {
6398
- let x = setupLength * bone.a, y = setupLength * bone.c;
6399
- lengths[i] = Math.sqrt(x * x + y * y);
6400
- }
6569
+ let x = setupLength * bone.a, y = setupLength * bone.c;
6570
+ lengths[i] = Math.sqrt(x * x + y * y);
6401
6571
  }
6402
6572
  }
6403
6573
  Utils.arrayFill(spaces, 1, spacesCount, spacing);
@@ -6767,27 +6937,266 @@ var spine = (() => {
6767
6937
  }
6768
6938
  };
6769
6939
  var PathConstraint = _PathConstraint;
6770
- PathConstraint.NONE = -1;
6771
- PathConstraint.BEFORE = -2;
6772
- PathConstraint.AFTER = -3;
6773
- PathConstraint.epsilon = 1e-5;
6940
+ __publicField(PathConstraint, "NONE", -1);
6941
+ __publicField(PathConstraint, "BEFORE", -2);
6942
+ __publicField(PathConstraint, "AFTER", -3);
6943
+ __publicField(PathConstraint, "epsilon", 1e-5);
6944
+
6945
+ // spine-core/src/PhysicsConstraint.ts
6946
+ var PhysicsConstraint = class {
6947
+ data;
6948
+ _bone = null;
6949
+ /** The bone constrained by this physics constraint. */
6950
+ set bone(bone) {
6951
+ this._bone = bone;
6952
+ }
6953
+ get bone() {
6954
+ if (!this._bone)
6955
+ throw new Error("Bone not set.");
6956
+ else
6957
+ return this._bone;
6958
+ }
6959
+ inertia = 0;
6960
+ strength = 0;
6961
+ damping = 0;
6962
+ massInverse = 0;
6963
+ wind = 0;
6964
+ gravity = 0;
6965
+ mix = 0;
6966
+ _reset = true;
6967
+ ux = 0;
6968
+ uy = 0;
6969
+ cx = 0;
6970
+ cy = 0;
6971
+ tx = 0;
6972
+ ty = 0;
6973
+ xOffset = 0;
6974
+ xVelocity = 0;
6975
+ yOffset = 0;
6976
+ yVelocity = 0;
6977
+ rotateOffset = 0;
6978
+ rotateVelocity = 0;
6979
+ scaleOffset = 0;
6980
+ scaleVelocity = 0;
6981
+ active = false;
6982
+ skeleton;
6983
+ remaining = 0;
6984
+ lastTime = 0;
6985
+ constructor(data, skeleton) {
6986
+ this.data = data;
6987
+ this.skeleton = skeleton;
6988
+ this.bone = skeleton.bones[data.bone.index];
6989
+ this.inertia = data.inertia;
6990
+ this.strength = data.strength;
6991
+ this.damping = data.damping;
6992
+ this.massInverse = data.massInverse;
6993
+ this.wind = data.wind;
6994
+ this.gravity = data.gravity;
6995
+ this.mix = data.mix;
6996
+ }
6997
+ reset() {
6998
+ this.remaining = 0;
6999
+ this.lastTime = this.skeleton.time;
7000
+ this._reset = true;
7001
+ this.xOffset = 0;
7002
+ this.xVelocity = 0;
7003
+ this.yOffset = 0;
7004
+ this.yVelocity = 0;
7005
+ this.rotateOffset = 0;
7006
+ this.rotateVelocity = 0;
7007
+ this.scaleOffset = 0;
7008
+ this.scaleVelocity = 0;
7009
+ }
7010
+ setToSetupPose() {
7011
+ const data = this.data;
7012
+ this.inertia = data.inertia;
7013
+ this.strength = data.strength;
7014
+ this.damping = data.damping;
7015
+ this.massInverse = data.massInverse;
7016
+ this.wind = data.wind;
7017
+ this.gravity = data.gravity;
7018
+ this.mix = data.mix;
7019
+ }
7020
+ isActive() {
7021
+ return this.active;
7022
+ }
7023
+ /** Applies the constraint to the constrained bones. */
7024
+ update(physics) {
7025
+ const mix = this.mix;
7026
+ if (mix == 0)
7027
+ return;
7028
+ const x = this.data.x > 0, y = this.data.y > 0, rotateOrShearX = this.data.rotate > 0 || this.data.shearX > 0, scaleX = this.data.scaleX > 0;
7029
+ const bone = this.bone;
7030
+ const l = bone.data.length;
7031
+ switch (physics) {
7032
+ case 0 /* none */:
7033
+ return;
7034
+ case 1 /* reset */:
7035
+ this.reset();
7036
+ case 2 /* update */:
7037
+ this.remaining += Math.max(this.skeleton.time - this.lastTime, 0);
7038
+ this.lastTime = this.skeleton.time;
7039
+ const bx = bone.worldX, by = bone.worldY;
7040
+ if (this._reset) {
7041
+ this._reset = false;
7042
+ this.ux = bx;
7043
+ this.uy = by;
7044
+ } else {
7045
+ let remaining = this.remaining, i = this.inertia, step = this.data.step;
7046
+ if (x || y) {
7047
+ if (x) {
7048
+ this.xOffset += (this.ux - bx) * i;
7049
+ this.ux = bx;
7050
+ }
7051
+ if (y) {
7052
+ this.yOffset += (this.uy - by) * i;
7053
+ this.uy = by;
7054
+ }
7055
+ if (remaining >= step) {
7056
+ const m = this.massInverse * step, e = this.strength, w = this.wind * 100, g = this.gravity * -100;
7057
+ const d = Math.pow(this.damping, 60 * step);
7058
+ do {
7059
+ if (x) {
7060
+ this.xVelocity += (w - this.xOffset * e) * m;
7061
+ this.xOffset += this.xVelocity * step;
7062
+ this.xVelocity *= d;
7063
+ }
7064
+ if (y) {
7065
+ this.yVelocity += (g - this.yOffset * e) * m;
7066
+ this.yOffset += this.yVelocity * step;
7067
+ this.yVelocity *= d;
7068
+ }
7069
+ remaining -= step;
7070
+ } while (remaining >= step);
7071
+ }
7072
+ if (x)
7073
+ bone.worldX += this.xOffset * mix * this.data.x;
7074
+ if (y)
7075
+ bone.worldY += this.yOffset * mix * this.data.y;
7076
+ }
7077
+ if (rotateOrShearX || scaleX) {
7078
+ let ca = Math.atan2(bone.c, bone.a), c = 0, s = 0, mr = 0;
7079
+ if (rotateOrShearX) {
7080
+ mr = mix * this.data.rotate;
7081
+ let dx = this.cx - bone.worldX, dy = this.cy - bone.worldY, r = Math.atan2(dy + this.ty, dx + this.tx) - ca - this.rotateOffset * mr;
7082
+ this.rotateOffset += (r - Math.ceil(r * MathUtils.invPI2 - 0.5) * MathUtils.PI2) * i;
7083
+ r = this.rotateOffset * mr + ca;
7084
+ c = Math.cos(r);
7085
+ s = Math.sin(r);
7086
+ if (scaleX) {
7087
+ r = l * bone.getWorldScaleX();
7088
+ if (r > 0)
7089
+ this.scaleOffset += (dx * c + dy * s) * i / r;
7090
+ }
7091
+ } else {
7092
+ c = Math.cos(ca);
7093
+ s = Math.sin(ca);
7094
+ const r = l * bone.getWorldScaleX();
7095
+ if (r > 0)
7096
+ this.scaleOffset += ((this.cx - bone.worldX) * c + (this.cy - bone.worldY) * s) * i / r;
7097
+ }
7098
+ remaining = this.remaining;
7099
+ if (remaining >= step) {
7100
+ const m = this.massInverse * step, e = this.strength, w = this.wind, g = this.gravity;
7101
+ const d = Math.pow(this.damping, 60 * step);
7102
+ while (true) {
7103
+ remaining -= step;
7104
+ if (scaleX) {
7105
+ this.scaleVelocity += (w * c - g * s - this.scaleOffset * e) * m;
7106
+ this.scaleOffset += this.scaleVelocity * step;
7107
+ this.scaleVelocity *= d;
7108
+ }
7109
+ if (rotateOrShearX) {
7110
+ this.rotateVelocity += (-0.01 * l * (w * s + g * c) - this.rotateOffset * e) * m;
7111
+ this.rotateOffset += this.rotateVelocity * step;
7112
+ this.rotateVelocity *= d;
7113
+ if (remaining < step)
7114
+ break;
7115
+ const r = this.rotateOffset * mr + ca;
7116
+ c = Math.cos(r);
7117
+ s = Math.sin(r);
7118
+ } else if (remaining < step)
7119
+ break;
7120
+ }
7121
+ }
7122
+ }
7123
+ this.remaining = remaining;
7124
+ }
7125
+ this.cx = bone.worldX;
7126
+ this.cy = bone.worldY;
7127
+ break;
7128
+ case 3 /* pose */:
7129
+ if (x)
7130
+ bone.worldX += this.xOffset * mix * this.data.x;
7131
+ if (y)
7132
+ bone.worldY += this.yOffset * mix * this.data.y;
7133
+ }
7134
+ if (rotateOrShearX) {
7135
+ let o = this.rotateOffset * mix, s = 0, c = 0, a = 0;
7136
+ if (this.data.shearX > 0) {
7137
+ let r = 0;
7138
+ if (this.data.rotate > 0) {
7139
+ r = o * this.data.rotate;
7140
+ s = Math.sin(r);
7141
+ c = Math.cos(r);
7142
+ a = bone.b;
7143
+ bone.b = c * a - s * bone.d;
7144
+ bone.d = s * a + c * bone.d;
7145
+ }
7146
+ r += o * this.data.shearX;
7147
+ s = Math.sin(r);
7148
+ c = Math.cos(r);
7149
+ a = bone.a;
7150
+ bone.a = c * a - s * bone.c;
7151
+ bone.c = s * a + c * bone.c;
7152
+ } else {
7153
+ o *= this.data.rotate;
7154
+ s = Math.sin(o);
7155
+ c = Math.cos(o);
7156
+ a = bone.a;
7157
+ bone.a = c * a - s * bone.c;
7158
+ bone.c = s * a + c * bone.c;
7159
+ a = bone.b;
7160
+ bone.b = c * a - s * bone.d;
7161
+ bone.d = s * a + c * bone.d;
7162
+ }
7163
+ }
7164
+ if (scaleX) {
7165
+ const s = 1 + this.scaleOffset * mix * this.data.scaleX;
7166
+ bone.a *= s;
7167
+ bone.c *= s;
7168
+ }
7169
+ if (physics != 3 /* pose */) {
7170
+ this.tx = l * bone.a;
7171
+ this.ty = l * bone.c;
7172
+ }
7173
+ bone.updateAppliedTransform();
7174
+ }
7175
+ };
6774
7176
 
6775
7177
  // spine-core/src/Slot.ts
6776
7178
  var Slot = class {
7179
+ /** The slot's setup pose data. */
7180
+ data;
7181
+ /** The bone this slot belongs to. */
7182
+ bone;
7183
+ /** The color used to tint the slot's attachment. If {@link #getDarkColor()} is set, this is used as the light color for two
7184
+ * color tinting. */
7185
+ color;
7186
+ /** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
7187
+ * color's alpha is not used. */
7188
+ darkColor = null;
7189
+ attachment = null;
7190
+ attachmentState = 0;
7191
+ /** The index of the texture region to display when the slot's attachment has a {@link Sequence}. -1 represents the
7192
+ * {@link Sequence#getSetupIndex()}. */
7193
+ sequenceIndex = -1;
7194
+ /** Values to deform the slot's attachment. For an unweighted mesh, the entries are local positions for each vertex. For a
7195
+ * weighted mesh, the entries are an offset for each vertex which will be added to the mesh's local vertex positions.
7196
+ *
7197
+ * See {@link VertexAttachment#computeWorldVertices()} and {@link DeformTimeline}. */
7198
+ deform = new Array();
6777
7199
  constructor(data, bone) {
6778
- /** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
6779
- * color's alpha is not used. */
6780
- this.darkColor = null;
6781
- this.attachment = null;
6782
- this.attachmentState = 0;
6783
- /** The index of the texture region to display when the slot's attachment has a {@link Sequence}. -1 represents the
6784
- * {@link Sequence#getSetupIndex()}. */
6785
- this.sequenceIndex = -1;
6786
- /** Values to deform the slot's attachment. For an unweighted mesh, the entries are local positions for each vertex. For a
6787
- * weighted mesh, the entries are an offset for each vertex which will be added to the mesh's local vertex positions.
6788
- *
6789
- * See {@link VertexAttachment#computeWorldVertices()} and {@link DeformTimeline}. */
6790
- this.deform = new Array();
6791
7200
  if (!data)
6792
7201
  throw new Error("data cannot be null.");
6793
7202
  if (!bone)
@@ -6834,15 +7243,21 @@ var spine = (() => {
6834
7243
 
6835
7244
  // spine-core/src/TransformConstraint.ts
6836
7245
  var TransformConstraint = class {
7246
+ /** The transform constraint's setup pose data. */
7247
+ data;
7248
+ /** The bones that will be modified by this transform constraint. */
7249
+ bones;
7250
+ /** The target bone whose world transform will be copied to the constrained bones. */
7251
+ target;
7252
+ mixRotate = 0;
7253
+ mixX = 0;
7254
+ mixY = 0;
7255
+ mixScaleX = 0;
7256
+ mixScaleY = 0;
7257
+ mixShearY = 0;
7258
+ temp = new Vector2();
7259
+ active = false;
6837
7260
  constructor(data, skeleton) {
6838
- this.mixRotate = 0;
6839
- this.mixX = 0;
6840
- this.mixY = 0;
6841
- this.mixScaleX = 0;
6842
- this.mixScaleY = 0;
6843
- this.mixShearY = 0;
6844
- this.temp = new Vector2();
6845
- this.active = false;
6846
7261
  if (!data)
6847
7262
  throw new Error("data cannot be null.");
6848
7263
  if (!skeleton)
@@ -6869,7 +7284,16 @@ var spine = (() => {
6869
7284
  isActive() {
6870
7285
  return this.active;
6871
7286
  }
6872
- update() {
7287
+ setToSetupPose() {
7288
+ const data = this.data;
7289
+ this.mixRotate = data.mixRotate;
7290
+ this.mixX = data.mixX;
7291
+ this.mixY = data.mixY;
7292
+ this.mixScaleX = data.mixScaleX;
7293
+ this.mixScaleY = data.mixScaleY;
7294
+ this.mixShearY = data.mixShearY;
7295
+ }
7296
+ update(physics) {
6873
7297
  if (this.mixRotate == 0 && this.mixX == 0 && this.mixY == 0 && this.mixScaleX == 0 && this.mixScaleY == 0 && this.mixShearY == 0)
6874
7298
  return;
6875
7299
  if (this.data.local) {
@@ -7009,7 +7433,7 @@ var spine = (() => {
7009
7433
  let rotation = bone.arotation;
7010
7434
  if (mixRotate != 0) {
7011
7435
  let r = target.arotation - rotation + this.data.offsetRotation;
7012
- r -= (16384 - (16384.499999999996 - r / 360 | 0)) * 360;
7436
+ r -= Math.ceil(r / 360 - 0.5) * 360;
7013
7437
  rotation += r * mixRotate;
7014
7438
  }
7015
7439
  let x = bone.ax, y = bone.ay;
@@ -7023,7 +7447,7 @@ var spine = (() => {
7023
7447
  let shearY = bone.ashearY;
7024
7448
  if (mixShearY != 0) {
7025
7449
  let r = target.ashearY - shearY + this.data.offsetShearY;
7026
- r -= (16384 - (16384.499999999996 - r / 360 | 0)) * 360;
7450
+ r -= Math.ceil(r / 360 - 0.5) * 360;
7027
7451
  shearY += r * mixShearY;
7028
7452
  }
7029
7453
  bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
@@ -7048,21 +7472,49 @@ var spine = (() => {
7048
7472
 
7049
7473
  // spine-core/src/Skeleton.ts
7050
7474
  var _Skeleton = class {
7475
+ /** The skeleton's setup pose data. */
7476
+ data;
7477
+ /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
7478
+ bones;
7479
+ /** The skeleton's slots. */
7480
+ slots;
7481
+ /** The skeleton's slots in the order they should be drawn. The returned array may be modified to change the draw order. */
7482
+ drawOrder;
7483
+ /** The skeleton's IK constraints. */
7484
+ ikConstraints;
7485
+ /** The skeleton's transform constraints. */
7486
+ transformConstraints;
7487
+ /** The skeleton's path constraints. */
7488
+ pathConstraints;
7489
+ /** The skeleton's physics constraints. */
7490
+ physicsConstraints;
7491
+ /** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link #updateCache()}. */
7492
+ _updateCache = new Array();
7493
+ /** The skeleton's current skin. May be null. */
7494
+ skin = null;
7495
+ /** The color to tint all the skeleton's attachments. */
7496
+ color;
7497
+ /** Scales the entire skeleton on the X axis. This affects all bones, even if the bone's transform mode disallows scale
7498
+ * inheritance. */
7499
+ scaleX = 1;
7500
+ /** Scales the entire skeleton on the Y axis. This affects all bones, even if the bone's transform mode disallows scale
7501
+ * inheritance. */
7502
+ _scaleY = 1;
7503
+ get scaleY() {
7504
+ return _Skeleton.yDown ? -this._scaleY : this._scaleY;
7505
+ }
7506
+ set scaleY(scaleY) {
7507
+ this._scaleY = scaleY;
7508
+ }
7509
+ /** Sets the skeleton X position, which is added to the root bone worldX position. */
7510
+ x = 0;
7511
+ /** Sets the skeleton Y position, which is added to the root bone worldY position. */
7512
+ y = 0;
7513
+ /** Returns the skeleton's time. This is used for time-based manipulations, such as {@link PhysicsConstraint}.
7514
+ * <p>
7515
+ * See {@link #update(float)}. */
7516
+ time = 0;
7051
7517
  constructor(data) {
7052
- /** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link #updateCache()}. */
7053
- this._updateCache = new Array();
7054
- /** The skeleton's current skin. May be null. */
7055
- this.skin = null;
7056
- /** Scales the entire skeleton on the X axis. This affects all bones, even if the bone's transform mode disallows scale
7057
- * inheritance. */
7058
- this.scaleX = 1;
7059
- /** Scales the entire skeleton on the Y axis. This affects all bones, even if the bone's transform mode disallows scale
7060
- * inheritance. */
7061
- this._scaleY = 1;
7062
- /** Sets the skeleton X position, which is added to the root bone worldX position. */
7063
- this.x = 0;
7064
- /** Sets the skeleton Y position, which is added to the root bone worldY position. */
7065
- this.y = 0;
7066
7518
  if (!data)
7067
7519
  throw new Error("data cannot be null.");
7068
7520
  this.data = data;
@@ -7103,15 +7555,14 @@ var spine = (() => {
7103
7555
  let pathConstraintData = data.pathConstraints[i];
7104
7556
  this.pathConstraints.push(new PathConstraint(pathConstraintData, this));
7105
7557
  }
7558
+ this.physicsConstraints = new Array();
7559
+ for (let i = 0; i < data.physicsConstraints.length; i++) {
7560
+ let physicsConstraintData = data.physicsConstraints[i];
7561
+ this.physicsConstraints.push(new PhysicsConstraint(physicsConstraintData, this));
7562
+ }
7106
7563
  this.color = new Color(1, 1, 1, 1);
7107
7564
  this.updateCache();
7108
7565
  }
7109
- get scaleY() {
7110
- return _Skeleton.yDown ? -this._scaleY : this._scaleY;
7111
- }
7112
- set scaleY(scaleY) {
7113
- this._scaleY = scaleY;
7114
- }
7115
7566
  /** Caches information about bones and constraints. Must be called if the {@link #getSkin()} is modified or if bones,
7116
7567
  * constraints, or weighted path attachments are added or removed. */
7117
7568
  updateCache() {
@@ -7137,8 +7588,9 @@ var spine = (() => {
7137
7588
  let ikConstraints = this.ikConstraints;
7138
7589
  let transformConstraints = this.transformConstraints;
7139
7590
  let pathConstraints = this.pathConstraints;
7140
- let ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;
7141
- let constraintCount = ikCount + transformCount + pathCount;
7591
+ let physicsConstraints = this.physicsConstraints;
7592
+ let ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length, physicsCount = this.physicsConstraints.length;
7593
+ let constraintCount = ikCount + transformCount + pathCount + physicsCount;
7142
7594
  outer:
7143
7595
  for (let i = 0; i < constraintCount; i++) {
7144
7596
  for (let ii = 0; ii < ikCount; ii++) {
@@ -7162,6 +7614,13 @@ var spine = (() => {
7162
7614
  continue outer;
7163
7615
  }
7164
7616
  }
7617
+ for (let ii = 0; ii < physicsCount; ii++) {
7618
+ const constraint = physicsConstraints[ii];
7619
+ if (constraint.data.order == i) {
7620
+ this.sortPhysicsConstraint(constraint);
7621
+ continue outer;
7622
+ }
7623
+ }
7165
7624
  }
7166
7625
  for (let i = 0, n = bones.length; i < n; i++)
7167
7626
  this.sortBone(bones[i]);
@@ -7260,6 +7719,16 @@ var spine = (() => {
7260
7719
  }
7261
7720
  }
7262
7721
  }
7722
+ sortPhysicsConstraint(constraint) {
7723
+ const bone = constraint.bone;
7724
+ constraint.active = bone.active && !constraint.data.skinRequired || this.skin != null && Utils.contains(this.skin.constraints, constraint.data, true);
7725
+ if (!constraint.active)
7726
+ return;
7727
+ this.sortBone(bone);
7728
+ this._updateCache.push(constraint);
7729
+ this.sortReset(bone.children);
7730
+ bone.sorted = true;
7731
+ }
7263
7732
  sortBone(bone) {
7264
7733
  if (!bone)
7265
7734
  return;
@@ -7285,7 +7754,9 @@ var spine = (() => {
7285
7754
  *
7286
7755
  * See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine
7287
7756
  * Runtimes Guide. */
7288
- updateWorldTransform() {
7757
+ updateWorldTransform(physics) {
7758
+ if (!physics)
7759
+ throw new Error("physics is undefined");
7289
7760
  let bones = this.bones;
7290
7761
  for (let i = 0, n = bones.length; i < n; i++) {
7291
7762
  let bone = bones[i];
@@ -7299,20 +7770,21 @@ var spine = (() => {
7299
7770
  }
7300
7771
  let updateCache = this._updateCache;
7301
7772
  for (let i = 0, n = updateCache.length; i < n; i++)
7302
- updateCache[i].update();
7773
+ updateCache[i].update(physics);
7303
7774
  }
7304
- updateWorldTransformWith(parent) {
7775
+ updateWorldTransformWith(physics, parent) {
7305
7776
  let rootBone = this.getRootBone();
7306
7777
  if (!rootBone)
7307
7778
  throw new Error("Root bone must not be null.");
7308
7779
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
7309
7780
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
7310
7781
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
7311
- let rotationY = rootBone.rotation + 90 + rootBone.shearY;
7312
- let la = MathUtils.cosDeg(rootBone.rotation + rootBone.shearX) * rootBone.scaleX;
7313
- let lb = MathUtils.cosDeg(rotationY) * rootBone.scaleY;
7314
- let lc = MathUtils.sinDeg(rootBone.rotation + rootBone.shearX) * rootBone.scaleX;
7315
- let ld = MathUtils.sinDeg(rotationY) * rootBone.scaleY;
7782
+ const rx = (rootBone.rotation + rootBone.shearX) * MathUtils.degRad;
7783
+ const ry = (rootBone.rotation + 90 + rootBone.shearY) * MathUtils.degRad;
7784
+ const la = Math.cos(rx) * rootBone.scaleX;
7785
+ const lb = Math.cos(ry) * rootBone.scaleY;
7786
+ const lc = Math.sin(rx) * rootBone.scaleX;
7787
+ const ld = Math.sin(ry) * rootBone.scaleY;
7316
7788
  rootBone.a = (pa * la + pb * lc) * this.scaleX;
7317
7789
  rootBone.b = (pa * lb + pb * ld) * this.scaleX;
7318
7790
  rootBone.c = (pc * la + pd * lc) * this.scaleY;
@@ -7321,7 +7793,7 @@ var spine = (() => {
7321
7793
  for (let i = 0, n = updateCache.length; i < n; i++) {
7322
7794
  let updatable = updateCache[i];
7323
7795
  if (updatable != rootBone)
7324
- updatable.update();
7796
+ updatable.update(physics);
7325
7797
  }
7326
7798
  }
7327
7799
  /** Sets the bones, constraints, and slots to their setup pose values. */
@@ -7331,39 +7803,16 @@ var spine = (() => {
7331
7803
  }
7332
7804
  /** Sets the bones and constraints to their setup pose values. */
7333
7805
  setBonesToSetupPose() {
7334
- let bones = this.bones;
7335
- for (let i = 0, n = bones.length; i < n; i++)
7336
- bones[i].setToSetupPose();
7337
- let ikConstraints = this.ikConstraints;
7338
- for (let i = 0, n = ikConstraints.length; i < n; i++) {
7339
- let constraint = ikConstraints[i];
7340
- constraint.mix = constraint.data.mix;
7341
- constraint.softness = constraint.data.softness;
7342
- constraint.bendDirection = constraint.data.bendDirection;
7343
- constraint.compress = constraint.data.compress;
7344
- constraint.stretch = constraint.data.stretch;
7345
- }
7346
- let transformConstraints = this.transformConstraints;
7347
- for (let i = 0, n = transformConstraints.length; i < n; i++) {
7348
- let constraint = transformConstraints[i];
7349
- let data = constraint.data;
7350
- constraint.mixRotate = data.mixRotate;
7351
- constraint.mixX = data.mixX;
7352
- constraint.mixY = data.mixY;
7353
- constraint.mixScaleX = data.mixScaleX;
7354
- constraint.mixScaleY = data.mixScaleY;
7355
- constraint.mixShearY = data.mixShearY;
7356
- }
7357
- let pathConstraints = this.pathConstraints;
7358
- for (let i = 0, n = pathConstraints.length; i < n; i++) {
7359
- let constraint = pathConstraints[i];
7360
- let data = constraint.data;
7361
- constraint.position = data.position;
7362
- constraint.spacing = data.spacing;
7363
- constraint.mixRotate = data.mixRotate;
7364
- constraint.mixX = data.mixX;
7365
- constraint.mixY = data.mixY;
7366
- }
7806
+ for (const bone of this.bones)
7807
+ bone.setToSetupPose();
7808
+ for (const constraint of this.ikConstraints)
7809
+ constraint.setToSetupPose();
7810
+ for (const constraint of this.transformConstraints)
7811
+ constraint.setToSetupPose();
7812
+ for (const constraint of this.pathConstraints)
7813
+ constraint.setToSetupPose();
7814
+ for (const constraint of this.physicsConstraints)
7815
+ constraint.setToSetupPose();
7367
7816
  }
7368
7817
  /** Sets the slots and draw order to their setup pose values. */
7369
7818
  setSlotsToSetupPose() {
@@ -7501,13 +7950,7 @@ var spine = (() => {
7501
7950
  findIkConstraint(constraintName) {
7502
7951
  if (!constraintName)
7503
7952
  throw new Error("constraintName cannot be null.");
7504
- let ikConstraints = this.ikConstraints;
7505
- for (let i = 0, n = ikConstraints.length; i < n; i++) {
7506
- let ikConstraint = ikConstraints[i];
7507
- if (ikConstraint.data.name == constraintName)
7508
- return ikConstraint;
7509
- }
7510
- return null;
7953
+ return this.ikConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7511
7954
  }
7512
7955
  /** Finds a transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of
7513
7956
  * this method than to call it repeatedly.
@@ -7515,13 +7958,7 @@ var spine = (() => {
7515
7958
  findTransformConstraint(constraintName) {
7516
7959
  if (!constraintName)
7517
7960
  throw new Error("constraintName cannot be null.");
7518
- let transformConstraints = this.transformConstraints;
7519
- for (let i = 0, n = transformConstraints.length; i < n; i++) {
7520
- let constraint = transformConstraints[i];
7521
- if (constraint.data.name == constraintName)
7522
- return constraint;
7523
- }
7524
- return null;
7961
+ return this.transformConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7525
7962
  }
7526
7963
  /** Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method
7527
7964
  * than to call it repeatedly.
@@ -7529,13 +7966,14 @@ var spine = (() => {
7529
7966
  findPathConstraint(constraintName) {
7530
7967
  if (!constraintName)
7531
7968
  throw new Error("constraintName cannot be null.");
7532
- let pathConstraints = this.pathConstraints;
7533
- for (let i = 0, n = pathConstraints.length; i < n; i++) {
7534
- let constraint = pathConstraints[i];
7535
- if (constraint.data.name == constraintName)
7536
- return constraint;
7537
- }
7538
- return null;
7969
+ return this.pathConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7970
+ }
7971
+ /** Finds a physics constraint by comparing each physics constraint's name. It is more efficient to cache the results of this
7972
+ * method than to call it repeatedly. */
7973
+ findPhysicsConstraint(constraintName) {
7974
+ if (constraintName == null)
7975
+ throw new Error("constraintName cannot be null.");
7976
+ return this.physicsConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7539
7977
  }
7540
7978
  /** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose as `{ x: number, y: number, width: number, height: number }`.
7541
7979
  * Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */
@@ -7586,57 +8024,68 @@ var spine = (() => {
7586
8024
  offset.set(minX, minY);
7587
8025
  size.set(maxX - minX, maxY - minY);
7588
8026
  }
8027
+ /** Increments the skeleton's {@link #time}. */
8028
+ update(delta) {
8029
+ this.time += delta;
8030
+ }
7589
8031
  };
7590
- var Skeleton = _Skeleton;
7591
- Skeleton.yDown = false;
8032
+ var Skeleton2 = _Skeleton;
8033
+ __publicField(Skeleton2, "yDown", false);
8034
+ var Physics = /* @__PURE__ */ ((Physics2) => {
8035
+ Physics2[Physics2["none"] = 0] = "none";
8036
+ Physics2[Physics2["reset"] = 1] = "reset";
8037
+ Physics2[Physics2["update"] = 2] = "update";
8038
+ Physics2[Physics2["pose"] = 3] = "pose";
8039
+ return Physics2;
8040
+ })(Physics || {});
7592
8041
 
7593
8042
  // spine-core/src/SkeletonData.ts
7594
8043
  var SkeletonData = class {
7595
- constructor() {
7596
- /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */
7597
- this.name = null;
7598
- /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
7599
- this.bones = new Array();
7600
- // Ordered parents first.
7601
- /** The skeleton's slots. */
7602
- this.slots = new Array();
7603
- // Setup pose draw order.
7604
- this.skins = new Array();
7605
- /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
7606
- *
7607
- * See {@link Skeleton#getAttachmentByName()}.
7608
- * May be null. */
7609
- this.defaultSkin = null;
7610
- /** The skeleton's events. */
7611
- this.events = new Array();
7612
- /** The skeleton's animations. */
7613
- this.animations = new Array();
7614
- /** The skeleton's IK constraints. */
7615
- this.ikConstraints = new Array();
7616
- /** The skeleton's transform constraints. */
7617
- this.transformConstraints = new Array();
7618
- /** The skeleton's path constraints. */
7619
- this.pathConstraints = new Array();
7620
- /** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */
7621
- this.x = 0;
7622
- /** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */
7623
- this.y = 0;
7624
- /** The width of the skeleton's axis aligned bounding box in the setup pose. */
7625
- this.width = 0;
7626
- /** The height of the skeleton's axis aligned bounding box in the setup pose. */
7627
- this.height = 0;
7628
- /** The Spine version used to export the skeleton data, or null. */
7629
- this.version = null;
7630
- /** The skeleton data hash. This value will change if any of the skeleton data has changed. May be null. */
7631
- this.hash = null;
7632
- // Nonessential
7633
- /** The dopesheet FPS in Spine. Available only when nonessential data was exported. */
7634
- this.fps = 0;
7635
- /** The path to the images directory as defined in Spine. Available only when nonessential data was exported. May be null. */
7636
- this.imagesPath = null;
7637
- /** The path to the audio directory as defined in Spine. Available only when nonessential data was exported. May be null. */
7638
- this.audioPath = null;
7639
- }
8044
+ /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */
8045
+ name = null;
8046
+ /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
8047
+ bones = new Array();
8048
+ // Ordered parents first.
8049
+ /** The skeleton's slots. */
8050
+ slots = new Array();
8051
+ // Setup pose draw order.
8052
+ skins = new Array();
8053
+ /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
8054
+ *
8055
+ * See {@link Skeleton#getAttachmentByName()}.
8056
+ * May be null. */
8057
+ defaultSkin = null;
8058
+ /** The skeleton's events. */
8059
+ events = new Array();
8060
+ /** The skeleton's animations. */
8061
+ animations = new Array();
8062
+ /** The skeleton's IK constraints. */
8063
+ ikConstraints = new Array();
8064
+ /** The skeleton's transform constraints. */
8065
+ transformConstraints = new Array();
8066
+ /** The skeleton's path constraints. */
8067
+ pathConstraints = new Array();
8068
+ /** The skeleton's physics constraints. */
8069
+ physicsConstraints = new Array();
8070
+ /** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */
8071
+ x = 0;
8072
+ /** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */
8073
+ y = 0;
8074
+ /** The width of the skeleton's axis aligned bounding box in the setup pose. */
8075
+ width = 0;
8076
+ /** The height of the skeleton's axis aligned bounding box in the setup pose. */
8077
+ height = 0;
8078
+ /** The Spine version used to export the skeleton data, or null. */
8079
+ version = null;
8080
+ /** The skeleton data hash. This value will change if any of the skeleton data has changed. May be null. */
8081
+ hash = null;
8082
+ // Nonessential
8083
+ /** The dopesheet FPS in Spine. Available only when nonessential data was exported. */
8084
+ fps = 0;
8085
+ /** The path to the images directory as defined in Spine. Available only when nonessential data was exported. May be null. */
8086
+ imagesPath = null;
8087
+ /** The path to the audio directory as defined in Spine. Available only when nonessential data was exported. May be null. */
8088
+ audioPath = null;
7640
8089
  /** Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it
7641
8090
  * multiple times.
7642
8091
  * @returns May be null. */
@@ -7713,9 +8162,9 @@ var spine = (() => {
7713
8162
  findIkConstraint(constraintName) {
7714
8163
  if (!constraintName)
7715
8164
  throw new Error("constraintName cannot be null.");
7716
- let ikConstraints = this.ikConstraints;
8165
+ const ikConstraints = this.ikConstraints;
7717
8166
  for (let i = 0, n = ikConstraints.length; i < n; i++) {
7718
- let constraint = ikConstraints[i];
8167
+ const constraint = ikConstraints[i];
7719
8168
  if (constraint.name == constraintName)
7720
8169
  return constraint;
7721
8170
  }
@@ -7727,9 +8176,9 @@ var spine = (() => {
7727
8176
  findTransformConstraint(constraintName) {
7728
8177
  if (!constraintName)
7729
8178
  throw new Error("constraintName cannot be null.");
7730
- let transformConstraints = this.transformConstraints;
8179
+ const transformConstraints = this.transformConstraints;
7731
8180
  for (let i = 0, n = transformConstraints.length; i < n; i++) {
7732
- let constraint = transformConstraints[i];
8181
+ const constraint = transformConstraints[i];
7733
8182
  if (constraint.name == constraintName)
7734
8183
  return constraint;
7735
8184
  }
@@ -7741,9 +8190,23 @@ var spine = (() => {
7741
8190
  findPathConstraint(constraintName) {
7742
8191
  if (!constraintName)
7743
8192
  throw new Error("constraintName cannot be null.");
7744
- let pathConstraints = this.pathConstraints;
8193
+ const pathConstraints = this.pathConstraints;
7745
8194
  for (let i = 0, n = pathConstraints.length; i < n; i++) {
7746
- let constraint = pathConstraints[i];
8195
+ const constraint = pathConstraints[i];
8196
+ if (constraint.name == constraintName)
8197
+ return constraint;
8198
+ }
8199
+ return null;
8200
+ }
8201
+ /** Finds a physics constraint by comparing each physics constraint's name. It is more efficient to cache the results of this method
8202
+ * than to call it multiple times.
8203
+ * @return May be null. */
8204
+ findPhysicsConstraint(constraintName) {
8205
+ if (!constraintName)
8206
+ throw new Error("constraintName cannot be null.");
8207
+ const physicsConstraints = this.physicsConstraints;
8208
+ for (let i = 0, n = physicsConstraints.length; i < n; i++) {
8209
+ const constraint = physicsConstraints[i];
7747
8210
  if (constraint.name == constraintName)
7748
8211
  return constraint;
7749
8212
  }
@@ -7760,10 +8223,15 @@ var spine = (() => {
7760
8223
  }
7761
8224
  };
7762
8225
  var Skin = class {
8226
+ /** The skin's name, which is unique across all skins in the skeleton. */
8227
+ name;
8228
+ attachments = new Array();
8229
+ bones = Array();
8230
+ constraints = new Array();
8231
+ /** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */
8232
+ color = new Color(0.99607843, 0.61960787, 0.30980393, 1);
8233
+ // fe9e4fff
7763
8234
  constructor(name) {
7764
- this.attachments = new Array();
7765
- this.bones = Array();
7766
- this.constraints = new Array();
7767
8235
  if (!name)
7768
8236
  throw new Error("name cannot be null.");
7769
8237
  this.name = name;
@@ -7920,19 +8388,25 @@ var spine = (() => {
7920
8388
 
7921
8389
  // spine-core/src/SlotData.ts
7922
8390
  var SlotData = class {
8391
+ /** The index of the slot in {@link Skeleton#getSlots()}. */
8392
+ index = 0;
8393
+ /** The name of the slot, which is unique across all slots in the skeleton. */
8394
+ name;
8395
+ /** The bone this slot belongs to. */
8396
+ boneData;
8397
+ /** The color used to tint the slot's attachment. If {@link #getDarkColor()} is set, this is used as the light color for two
8398
+ * color tinting. */
8399
+ color = new Color(1, 1, 1, 1);
8400
+ /** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
8401
+ * color's alpha is not used. */
8402
+ darkColor = null;
8403
+ /** The name of the attachment that is visible for this slot in the setup pose, or null if no attachment is visible. */
8404
+ attachmentName = null;
8405
+ /** The blend mode for drawing the slot's attachment. */
8406
+ blendMode = BlendMode.Normal;
8407
+ /** False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
8408
+ visible = true;
7923
8409
  constructor(index, name, boneData) {
7924
- /** The index of the slot in {@link Skeleton#getSlots()}. */
7925
- this.index = 0;
7926
- /** The color used to tint the slot's attachment. If {@link #getDarkColor()} is set, this is used as the light color for two
7927
- * color tinting. */
7928
- this.color = new Color(1, 1, 1, 1);
7929
- /** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
7930
- * color's alpha is not used. */
7931
- this.darkColor = null;
7932
- /** The name of the attachment that is visible for this slot in the setup pose, or null if no attachment is visible. */
7933
- this.attachmentName = null;
7934
- /** The blend mode for drawing the slot's attachment. */
7935
- this.blendMode = BlendMode.Normal;
7936
8410
  if (index < 0)
7937
8411
  throw new Error("index must be >= 0.");
7938
8412
  if (!name)
@@ -7954,33 +8428,10 @@ var spine = (() => {
7954
8428
 
7955
8429
  // spine-core/src/TransformConstraintData.ts
7956
8430
  var TransformConstraintData = class extends ConstraintData {
7957
- constructor(name) {
7958
- super(name, 0, false);
7959
- /** The bones that will be modified by this transform constraint. */
7960
- this.bones = new Array();
7961
- /** The target bone whose world transform will be copied to the constrained bones. */
7962
- this._target = null;
7963
- this.mixRotate = 0;
7964
- this.mixX = 0;
7965
- this.mixY = 0;
7966
- this.mixScaleX = 0;
7967
- this.mixScaleY = 0;
7968
- this.mixShearY = 0;
7969
- /** An offset added to the constrained bone rotation. */
7970
- this.offsetRotation = 0;
7971
- /** An offset added to the constrained bone X translation. */
7972
- this.offsetX = 0;
7973
- /** An offset added to the constrained bone Y translation. */
7974
- this.offsetY = 0;
7975
- /** An offset added to the constrained bone scaleX. */
7976
- this.offsetScaleX = 0;
7977
- /** An offset added to the constrained bone scaleY. */
7978
- this.offsetScaleY = 0;
7979
- /** An offset added to the constrained bone shearY. */
7980
- this.offsetShearY = 0;
7981
- this.relative = false;
7982
- this.local = false;
7983
- }
8431
+ /** The bones that will be modified by this transform constraint. */
8432
+ bones = new Array();
8433
+ /** The target bone whose world transform will be copied to the constrained bones. */
8434
+ _target = null;
7984
8435
  set target(boneData) {
7985
8436
  this._target = boneData;
7986
8437
  }
@@ -7990,17 +8441,41 @@ var spine = (() => {
7990
8441
  else
7991
8442
  return this._target;
7992
8443
  }
8444
+ mixRotate = 0;
8445
+ mixX = 0;
8446
+ mixY = 0;
8447
+ mixScaleX = 0;
8448
+ mixScaleY = 0;
8449
+ mixShearY = 0;
8450
+ /** An offset added to the constrained bone rotation. */
8451
+ offsetRotation = 0;
8452
+ /** An offset added to the constrained bone X translation. */
8453
+ offsetX = 0;
8454
+ /** An offset added to the constrained bone Y translation. */
8455
+ offsetY = 0;
8456
+ /** An offset added to the constrained bone scaleX. */
8457
+ offsetScaleX = 0;
8458
+ /** An offset added to the constrained bone scaleY. */
8459
+ offsetScaleY = 0;
8460
+ /** An offset added to the constrained bone shearY. */
8461
+ offsetShearY = 0;
8462
+ relative = false;
8463
+ local = false;
8464
+ constructor(name) {
8465
+ super(name, 0, false);
8466
+ }
7993
8467
  };
7994
8468
 
7995
8469
  // spine-core/src/SkeletonBinary.ts
7996
8470
  var SkeletonBinary = class {
8471
+ /** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
8472
+ * runtime than were used in Spine.
8473
+ *
8474
+ * See [Scaling](http://esotericsoftware.com/spine-loading-skeleton-data#Scaling) in the Spine Runtimes Guide. */
8475
+ scale = 1;
8476
+ attachmentLoader;
8477
+ linkedMeshes = new Array();
7997
8478
  constructor(attachmentLoader) {
7998
- /** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
7999
- * runtime than were used in Spine.
8000
- *
8001
- * See [Scaling](http://esotericsoftware.com/spine-loading-skeleton-data#Scaling) in the Spine Runtimes Guide. */
8002
- this.scale = 1;
8003
- this.linkedMeshes = new Array();
8004
8479
  this.attachmentLoader = attachmentLoader;
8005
8480
  }
8006
8481
  readSkeletonData(binary) {
@@ -9014,6 +9489,11 @@ var spine = (() => {
9014
9489
  }
9015
9490
  };
9016
9491
  var LinkedMesh = class {
9492
+ parent;
9493
+ skin;
9494
+ slotIndex;
9495
+ mesh;
9496
+ inheritTimeline;
9017
9497
  constructor(mesh, skin, slotIndex, parent, inheritDeform) {
9018
9498
  this.mesh = mesh;
9019
9499
  this.skin = skin;
@@ -9107,23 +9587,21 @@ var spine = (() => {
9107
9587
 
9108
9588
  // spine-core/src/SkeletonBounds.ts
9109
9589
  var SkeletonBounds = class {
9110
- constructor() {
9111
- /** The left edge of the axis aligned bounding box. */
9112
- this.minX = 0;
9113
- /** The bottom edge of the axis aligned bounding box. */
9114
- this.minY = 0;
9115
- /** The right edge of the axis aligned bounding box. */
9116
- this.maxX = 0;
9117
- /** The top edge of the axis aligned bounding box. */
9118
- this.maxY = 0;
9119
- /** The visible bounding boxes. */
9120
- this.boundingBoxes = new Array();
9121
- /** The world vertices for the bounding box polygons. */
9122
- this.polygons = new Array();
9123
- this.polygonPool = new Pool(() => {
9124
- return Utils.newFloatArray(16);
9125
- });
9126
- }
9590
+ /** The left edge of the axis aligned bounding box. */
9591
+ minX = 0;
9592
+ /** The bottom edge of the axis aligned bounding box. */
9593
+ minY = 0;
9594
+ /** The right edge of the axis aligned bounding box. */
9595
+ maxX = 0;
9596
+ /** The top edge of the axis aligned bounding box. */
9597
+ maxY = 0;
9598
+ /** The visible bounding boxes. */
9599
+ boundingBoxes = new Array();
9600
+ /** The world vertices for the bounding box polygons. */
9601
+ polygons = new Array();
9602
+ polygonPool = new Pool(() => {
9603
+ return Utils.newFloatArray(16);
9604
+ });
9127
9605
  /** Clears any previous polygons, finds all visible bounding box attachments, and computes the world vertices for each bounding
9128
9606
  * box's polygon.
9129
9607
  * @param updateAabb If true, the axis aligned bounding box containing all the polygons is computed. If false, the
@@ -9294,19 +9772,17 @@ var spine = (() => {
9294
9772
 
9295
9773
  // spine-core/src/Triangulator.ts
9296
9774
  var Triangulator = class {
9297
- constructor() {
9298
- this.convexPolygons = new Array();
9299
- this.convexPolygonsIndices = new Array();
9300
- this.indicesArray = new Array();
9301
- this.isConcaveArray = new Array();
9302
- this.triangles = new Array();
9303
- this.polygonPool = new Pool(() => {
9304
- return new Array();
9305
- });
9306
- this.polygonIndicesPool = new Pool(() => {
9307
- return new Array();
9308
- });
9309
- }
9775
+ convexPolygons = new Array();
9776
+ convexPolygonsIndices = new Array();
9777
+ indicesArray = new Array();
9778
+ isConcaveArray = new Array();
9779
+ triangles = new Array();
9780
+ polygonPool = new Pool(() => {
9781
+ return new Array();
9782
+ });
9783
+ polygonIndicesPool = new Pool(() => {
9784
+ return new Array();
9785
+ });
9310
9786
  triangulate(verticesArray) {
9311
9787
  let vertices = verticesArray;
9312
9788
  let vertexCount = verticesArray.length >> 1;
@@ -9510,16 +9986,14 @@ var spine = (() => {
9510
9986
 
9511
9987
  // spine-core/src/SkeletonClipping.ts
9512
9988
  var SkeletonClipping = class {
9513
- constructor() {
9514
- this.triangulator = new Triangulator();
9515
- this.clippingPolygon = new Array();
9516
- this.clipOutput = new Array();
9517
- this.clippedVertices = new Array();
9518
- this.clippedTriangles = new Array();
9519
- this.scratch = new Array();
9520
- this.clipAttachment = null;
9521
- this.clippingPolygons = null;
9522
- }
9989
+ triangulator = new Triangulator();
9990
+ clippingPolygon = new Array();
9991
+ clipOutput = new Array();
9992
+ clippedVertices = new Array();
9993
+ clippedTriangles = new Array();
9994
+ scratch = new Array();
9995
+ clipAttachment = null;
9996
+ clippingPolygons = null;
9523
9997
  clipStart(slot, clip) {
9524
9998
  if (this.clipAttachment)
9525
9999
  return 0;
@@ -9799,13 +10273,14 @@ var spine = (() => {
9799
10273
 
9800
10274
  // spine-core/src/SkeletonJson.ts
9801
10275
  var SkeletonJson = class {
10276
+ attachmentLoader;
10277
+ /** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
10278
+ * runtime than were used in Spine.
10279
+ *
10280
+ * See [Scaling](http://esotericsoftware.com/spine-loading-skeleton-data#Scaling) in the Spine Runtimes Guide. */
10281
+ scale = 1;
10282
+ linkedMeshes = new Array();
9802
10283
  constructor(attachmentLoader) {
9803
- /** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
9804
- * runtime than were used in Spine.
9805
- *
9806
- * See [Scaling](http://esotericsoftware.com/spine-loading-skeleton-data#Scaling) in the Spine Runtimes Guide. */
9807
- this.scale = 1;
9808
- this.linkedMeshes = new Array();
9809
10284
  this.attachmentLoader = attachmentLoader;
9810
10285
  }
9811
10286
  readSkeletonData(json) {
@@ -10667,6 +11142,11 @@ var spine = (() => {
10667
11142
  }
10668
11143
  };
10669
11144
  var LinkedMesh2 = class {
11145
+ parent;
11146
+ skin;
11147
+ slotIndex;
11148
+ mesh;
11149
+ inheritTimeline;
10670
11150
  constructor(mesh, skin, slotIndex, parent, inheritDeform) {
10671
11151
  this.mesh = mesh;
10672
11152
  this.skin = skin;
@@ -10776,11 +11256,12 @@ var spine = (() => {
10776
11256
  // spine-canvas/src/SkeletonRenderer.ts
10777
11257
  var worldVertices = Utils.newFloatArray(8);
10778
11258
  var _SkeletonRenderer = class {
11259
+ ctx;
11260
+ triangleRendering = false;
11261
+ debugRendering = false;
11262
+ vertices = Utils.newFloatArray(8 * 1024);
11263
+ tempColor = new Color();
10779
11264
  constructor(context) {
10780
- this.triangleRendering = false;
10781
- this.debugRendering = false;
10782
- this.vertices = Utils.newFloatArray(8 * 1024);
10783
- this.tempColor = new Color();
10784
11265
  this.ctx = context;
10785
11266
  }
10786
11267
  draw(skeleton) {
@@ -10999,8 +11480,8 @@ var spine = (() => {
10999
11480
  }
11000
11481
  };
11001
11482
  var SkeletonRenderer = _SkeletonRenderer;
11002
- SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
11003
- SkeletonRenderer.VERTEX_SIZE = 2 + 2 + 4;
11483
+ __publicField(SkeletonRenderer, "QUAD_TRIANGLES", [0, 1, 2, 2, 3, 0]);
11484
+ __publicField(SkeletonRenderer, "VERTEX_SIZE", 2 + 2 + 4);
11004
11485
  return __toCommonJS(src_exports);
11005
11486
  })();
11006
11487
  //# sourceMappingURL=spine-canvas.js.map