@esotericsoftware/spine-core 4.2.26 → 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.
@@ -76,6 +76,16 @@ var spine = (() => {
76
76
  PathConstraintMixTimeline: () => PathConstraintMixTimeline,
77
77
  PathConstraintPositionTimeline: () => PathConstraintPositionTimeline,
78
78
  PathConstraintSpacingTimeline: () => PathConstraintSpacingTimeline,
79
+ Physics: () => Physics,
80
+ PhysicsConstraintDampingTimeline: () => PhysicsConstraintDampingTimeline,
81
+ PhysicsConstraintGravityTimeline: () => PhysicsConstraintGravityTimeline,
82
+ PhysicsConstraintInertiaTimeline: () => PhysicsConstraintInertiaTimeline,
83
+ PhysicsConstraintMassTimeline: () => PhysicsConstraintMassTimeline,
84
+ PhysicsConstraintMixTimeline: () => PhysicsConstraintMixTimeline,
85
+ PhysicsConstraintResetTimeline: () => PhysicsConstraintResetTimeline,
86
+ PhysicsConstraintStrengthTimeline: () => PhysicsConstraintStrengthTimeline,
87
+ PhysicsConstraintTimeline: () => PhysicsConstraintTimeline,
88
+ PhysicsConstraintWindTimeline: () => PhysicsConstraintWindTimeline,
79
89
  PointAttachment: () => PointAttachment,
80
90
  Pool: () => Pool,
81
91
  PositionMode: () => PositionMode,
@@ -97,7 +107,7 @@ var spine = (() => {
97
107
  ShearTimeline: () => ShearTimeline,
98
108
  ShearXTimeline: () => ShearXTimeline,
99
109
  ShearYTimeline: () => ShearYTimeline,
100
- Skeleton: () => Skeleton,
110
+ Skeleton: () => Skeleton2,
101
111
  SkeletonBinary: () => SkeletonBinary,
102
112
  SkeletonBounds: () => SkeletonBounds,
103
113
  SkeletonClipping: () => SkeletonClipping,
@@ -267,6 +277,9 @@ var spine = (() => {
267
277
  static sinDeg(degrees) {
268
278
  return Math.sin(degrees * _MathUtils.degRad);
269
279
  }
280
+ static atan2Deg(y, x) {
281
+ return Math.atan2(y, x) * _MathUtils.degRad;
282
+ }
270
283
  static signum(value) {
271
284
  return value > 0 ? 1 : value < 0 ? -1 : 0;
272
285
  }
@@ -294,6 +307,7 @@ var spine = (() => {
294
307
  var MathUtils = _MathUtils;
295
308
  __publicField(MathUtils, "PI", 3.1415927);
296
309
  __publicField(MathUtils, "PI2", _MathUtils.PI * 2);
310
+ __publicField(MathUtils, "invPI2", 1 / _MathUtils.PI2);
297
311
  __publicField(MathUtils, "radiansToDegrees", 180 / _MathUtils.PI);
298
312
  __publicField(MathUtils, "radDeg", _MathUtils.radiansToDegrees);
299
313
  __publicField(MathUtils, "degreesToRadians", _MathUtils.PI / 180);
@@ -769,7 +783,15 @@ var spine = (() => {
769
783
  pathConstraintPosition: 16,
770
784
  pathConstraintSpacing: 17,
771
785
  pathConstraintMix: 18,
772
- sequence: 19
786
+ physicsConstraintInertia: 19,
787
+ physicsConstraintStrength: 20,
788
+ physicsConstraintDamping: 21,
789
+ physicsConstraintMass: 22,
790
+ physicsConstraintWind: 23,
791
+ physicsConstraintGravity: 24,
792
+ physicsConstraintMix: 25,
793
+ physicsConstraintReset: 26,
794
+ sequence: 27
773
795
  };
774
796
  var Timeline = class {
775
797
  propertyIds;
@@ -947,6 +969,94 @@ var spine = (() => {
947
969
  /*BEZIER*/
948
970
  );
949
971
  }
972
+ getRelativeValue(time, alpha, blend, current, setup) {
973
+ if (time < this.frames[0]) {
974
+ switch (blend) {
975
+ case 0 /* setup */:
976
+ return setup;
977
+ case 1 /* first */:
978
+ return current + (setup - current) * alpha;
979
+ }
980
+ return current;
981
+ }
982
+ let value = this.getCurveValue(time);
983
+ switch (blend) {
984
+ case 0 /* setup */:
985
+ return setup + value * alpha;
986
+ case 1 /* first */:
987
+ case 2 /* replace */:
988
+ value += setup - current;
989
+ }
990
+ return current + value * alpha;
991
+ }
992
+ getAbsoluteValue(time, alpha, blend, current, setup) {
993
+ if (time < this.frames[0]) {
994
+ switch (blend) {
995
+ case 0 /* setup */:
996
+ return setup;
997
+ case 1 /* first */:
998
+ return current + (setup - current) * alpha;
999
+ }
1000
+ return current;
1001
+ }
1002
+ let value = this.getCurveValue(time);
1003
+ if (blend == 0 /* setup */)
1004
+ return setup + (value - setup) * alpha;
1005
+ return current + (value - current) * alpha;
1006
+ }
1007
+ getAbsoluteValue2(time, alpha, blend, current, setup, value) {
1008
+ if (time < this.frames[0]) {
1009
+ switch (blend) {
1010
+ case 0 /* setup */:
1011
+ return setup;
1012
+ case 1 /* first */:
1013
+ return current + (setup - current) * alpha;
1014
+ }
1015
+ return current;
1016
+ }
1017
+ if (blend == 0 /* setup */)
1018
+ return setup + (value - setup) * alpha;
1019
+ return current + (value - current) * alpha;
1020
+ }
1021
+ getScaleValue(time, alpha, blend, direction, current, setup) {
1022
+ const frames = this.frames;
1023
+ if (time < frames[0]) {
1024
+ switch (blend) {
1025
+ case 0 /* setup */:
1026
+ return setup;
1027
+ case 1 /* first */:
1028
+ return current + (setup - current) * alpha;
1029
+ }
1030
+ return current;
1031
+ }
1032
+ let value = this.getCurveValue(time) * setup;
1033
+ if (alpha == 1) {
1034
+ if (blend == 3 /* add */)
1035
+ return current + value - setup;
1036
+ return value;
1037
+ }
1038
+ if (direction == 1 /* mixOut */) {
1039
+ switch (blend) {
1040
+ case 0 /* setup */:
1041
+ return setup + (Math.abs(value) * MathUtils.signum(setup) - setup) * alpha;
1042
+ case 1 /* first */:
1043
+ case 2 /* replace */:
1044
+ return current + (Math.abs(value) * MathUtils.signum(current) - current) * alpha;
1045
+ }
1046
+ } else {
1047
+ let s = 0;
1048
+ switch (blend) {
1049
+ case 0 /* setup */:
1050
+ s = Math.abs(setup) * MathUtils.signum(value);
1051
+ return s + (value - s) * alpha;
1052
+ case 1 /* first */:
1053
+ case 2 /* replace */:
1054
+ s = Math.abs(current) * MathUtils.signum(value);
1055
+ return s + (value - s) * alpha;
1056
+ }
1057
+ }
1058
+ return current + (value - setup) * alpha;
1059
+ }
950
1060
  };
951
1061
  var CurveTimeline2 = class extends CurveTimeline {
952
1062
  /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
@@ -981,30 +1091,8 @@ var spine = (() => {
981
1091
  }
982
1092
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
983
1093
  let bone = skeleton.bones[this.boneIndex];
984
- if (!bone.active)
985
- return;
986
- let frames = this.frames;
987
- if (time < frames[0]) {
988
- switch (blend) {
989
- case 0 /* setup */:
990
- bone.rotation = bone.data.rotation;
991
- return;
992
- case 1 /* first */:
993
- bone.rotation += (bone.data.rotation - bone.rotation) * alpha;
994
- }
995
- return;
996
- }
997
- let r = this.getCurveValue(time);
998
- switch (blend) {
999
- case 0 /* setup */:
1000
- bone.rotation = bone.data.rotation + r * alpha;
1001
- break;
1002
- case 1 /* first */:
1003
- case 2 /* replace */:
1004
- r += bone.data.rotation - bone.rotation;
1005
- case 3 /* add */:
1006
- bone.rotation += r * alpha;
1007
- }
1094
+ if (bone.active)
1095
+ bone.rotation = this.getRelativeValue(time, alpha, blend, bone.rotation, bone.data.rotation);
1008
1096
  }
1009
1097
  };
1010
1098
  var TranslateTimeline = class extends CurveTimeline2 {
@@ -1120,31 +1208,8 @@ var spine = (() => {
1120
1208
  }
1121
1209
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1122
1210
  let bone = skeleton.bones[this.boneIndex];
1123
- if (!bone.active)
1124
- return;
1125
- let frames = this.frames;
1126
- if (time < frames[0]) {
1127
- switch (blend) {
1128
- case 0 /* setup */:
1129
- bone.x = bone.data.x;
1130
- return;
1131
- case 1 /* first */:
1132
- bone.x += (bone.data.x - bone.x) * alpha;
1133
- }
1134
- return;
1135
- }
1136
- let x = this.getCurveValue(time);
1137
- switch (blend) {
1138
- case 0 /* setup */:
1139
- bone.x = bone.data.x + x * alpha;
1140
- break;
1141
- case 1 /* first */:
1142
- case 2 /* replace */:
1143
- bone.x += (bone.data.x + x - bone.x) * alpha;
1144
- break;
1145
- case 3 /* add */:
1146
- bone.x += x * alpha;
1147
- }
1211
+ if (bone.active)
1212
+ bone.x = this.getRelativeValue(time, alpha, blend, bone.x, bone.data.x);
1148
1213
  }
1149
1214
  };
1150
1215
  var TranslateYTimeline = class extends CurveTimeline1 {
@@ -1155,31 +1220,8 @@ var spine = (() => {
1155
1220
  }
1156
1221
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1157
1222
  let bone = skeleton.bones[this.boneIndex];
1158
- if (!bone.active)
1159
- return;
1160
- let frames = this.frames;
1161
- if (time < frames[0]) {
1162
- switch (blend) {
1163
- case 0 /* setup */:
1164
- bone.y = bone.data.y;
1165
- return;
1166
- case 1 /* first */:
1167
- bone.y += (bone.data.y - bone.y) * alpha;
1168
- }
1169
- return;
1170
- }
1171
- let y = this.getCurveValue(time);
1172
- switch (blend) {
1173
- case 0 /* setup */:
1174
- bone.y = bone.data.y + y * alpha;
1175
- break;
1176
- case 1 /* first */:
1177
- case 2 /* replace */:
1178
- bone.y += (bone.data.y + y - bone.y) * alpha;
1179
- break;
1180
- case 3 /* add */:
1181
- bone.y += y * alpha;
1182
- }
1223
+ if (bone.active)
1224
+ bone.y = this.getRelativeValue(time, alpha, blend, bone.y, bone.data.y);
1183
1225
  }
1184
1226
  };
1185
1227
  var ScaleTimeline = class extends CurveTimeline2 {
@@ -1333,57 +1375,8 @@ var spine = (() => {
1333
1375
  }
1334
1376
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1335
1377
  let bone = skeleton.bones[this.boneIndex];
1336
- if (!bone.active)
1337
- return;
1338
- let frames = this.frames;
1339
- if (time < frames[0]) {
1340
- switch (blend) {
1341
- case 0 /* setup */:
1342
- bone.scaleX = bone.data.scaleX;
1343
- return;
1344
- case 1 /* first */:
1345
- bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
1346
- }
1347
- return;
1348
- }
1349
- let x = this.getCurveValue(time) * bone.data.scaleX;
1350
- if (alpha == 1) {
1351
- if (blend == 3 /* add */)
1352
- bone.scaleX += x - bone.data.scaleX;
1353
- else
1354
- bone.scaleX = x;
1355
- } else {
1356
- let bx = 0;
1357
- if (direction == 1 /* mixOut */) {
1358
- switch (blend) {
1359
- case 0 /* setup */:
1360
- bx = bone.data.scaleX;
1361
- bone.scaleX = bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
1362
- break;
1363
- case 1 /* first */:
1364
- case 2 /* replace */:
1365
- bx = bone.scaleX;
1366
- bone.scaleX = bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
1367
- break;
1368
- case 3 /* add */:
1369
- bone.scaleX += (x - bone.data.scaleX) * alpha;
1370
- }
1371
- } else {
1372
- switch (blend) {
1373
- case 0 /* setup */:
1374
- bx = Math.abs(bone.data.scaleX) * MathUtils.signum(x);
1375
- bone.scaleX = bx + (x - bx) * alpha;
1376
- break;
1377
- case 1 /* first */:
1378
- case 2 /* replace */:
1379
- bx = Math.abs(bone.scaleX) * MathUtils.signum(x);
1380
- bone.scaleX = bx + (x - bx) * alpha;
1381
- break;
1382
- case 3 /* add */:
1383
- bone.scaleX += (x - bone.data.scaleX) * alpha;
1384
- }
1385
- }
1386
- }
1378
+ if (bone.active)
1379
+ bone.scaleX = this.getScaleValue(time, alpha, blend, direction, bone.scaleX, bone.data.scaleX);
1387
1380
  }
1388
1381
  };
1389
1382
  var ScaleYTimeline = class extends CurveTimeline1 {
@@ -1394,57 +1387,8 @@ var spine = (() => {
1394
1387
  }
1395
1388
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1396
1389
  let bone = skeleton.bones[this.boneIndex];
1397
- if (!bone.active)
1398
- return;
1399
- let frames = this.frames;
1400
- if (time < frames[0]) {
1401
- switch (blend) {
1402
- case 0 /* setup */:
1403
- bone.scaleY = bone.data.scaleY;
1404
- return;
1405
- case 1 /* first */:
1406
- bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
1407
- }
1408
- return;
1409
- }
1410
- let y = this.getCurveValue(time) * bone.data.scaleY;
1411
- if (alpha == 1) {
1412
- if (blend == 3 /* add */)
1413
- bone.scaleY += y - bone.data.scaleY;
1414
- else
1415
- bone.scaleY = y;
1416
- } else {
1417
- let by = 0;
1418
- if (direction == 1 /* mixOut */) {
1419
- switch (blend) {
1420
- case 0 /* setup */:
1421
- by = bone.data.scaleY;
1422
- bone.scaleY = by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
1423
- break;
1424
- case 1 /* first */:
1425
- case 2 /* replace */:
1426
- by = bone.scaleY;
1427
- bone.scaleY = by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
1428
- break;
1429
- case 3 /* add */:
1430
- bone.scaleY += (y - bone.data.scaleY) * alpha;
1431
- }
1432
- } else {
1433
- switch (blend) {
1434
- case 0 /* setup */:
1435
- by = Math.abs(bone.data.scaleY) * MathUtils.signum(y);
1436
- bone.scaleY = by + (y - by) * alpha;
1437
- break;
1438
- case 1 /* first */:
1439
- case 2 /* replace */:
1440
- by = Math.abs(bone.scaleY) * MathUtils.signum(y);
1441
- bone.scaleY = by + (y - by) * alpha;
1442
- break;
1443
- case 3 /* add */:
1444
- bone.scaleY += (y - bone.data.scaleY) * alpha;
1445
- }
1446
- }
1447
- }
1390
+ if (bone.active)
1391
+ bone.scaleY = this.getScaleValue(time, alpha, blend, direction, bone.scaleX, bone.data.scaleY);
1448
1392
  }
1449
1393
  };
1450
1394
  var ShearTimeline = class extends CurveTimeline2 {
@@ -1560,31 +1504,8 @@ var spine = (() => {
1560
1504
  }
1561
1505
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1562
1506
  let bone = skeleton.bones[this.boneIndex];
1563
- if (!bone.active)
1564
- return;
1565
- let frames = this.frames;
1566
- if (time < frames[0]) {
1567
- switch (blend) {
1568
- case 0 /* setup */:
1569
- bone.shearX = bone.data.shearX;
1570
- return;
1571
- case 1 /* first */:
1572
- bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
1573
- }
1574
- return;
1575
- }
1576
- let x = this.getCurveValue(time);
1577
- switch (blend) {
1578
- case 0 /* setup */:
1579
- bone.shearX = bone.data.shearX + x * alpha;
1580
- break;
1581
- case 1 /* first */:
1582
- case 2 /* replace */:
1583
- bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
1584
- break;
1585
- case 3 /* add */:
1586
- bone.shearX += x * alpha;
1587
- }
1507
+ if (bone.active)
1508
+ bone.shearX = this.getRelativeValue(time, alpha, blend, bone.shearX, bone.data.shearX);
1588
1509
  }
1589
1510
  };
1590
1511
  var ShearYTimeline = class extends CurveTimeline1 {
@@ -1595,31 +1516,8 @@ var spine = (() => {
1595
1516
  }
1596
1517
  apply(skeleton, lastTime, time, events, alpha, blend, direction) {
1597
1518
  let bone = skeleton.bones[this.boneIndex];
1598
- if (!bone.active)
1599
- return;
1600
- let frames = this.frames;
1601
- if (time < frames[0]) {
1602
- switch (blend) {
1603
- case 0 /* setup */:
1604
- bone.shearY = bone.data.shearY;
1605
- return;
1606
- case 1 /* first */:
1607
- bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
1608
- }
1609
- return;
1610
- }
1611
- let y = this.getCurveValue(time);
1612
- switch (blend) {
1613
- case 0 /* setup */:
1614
- bone.shearY = bone.data.shearY + y * alpha;
1615
- break;
1616
- case 1 /* first */:
1617
- case 2 /* replace */:
1618
- bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
1619
- break;
1620
- case 3 /* add */:
1621
- bone.shearY += y * alpha;
1622
- }
1519
+ if (bone.active)
1520
+ bone.shearY = this.getRelativeValue(time, alpha, blend, bone.shearX, bone.data.shearY);
1623
1521
  }
1624
1522
  };
1625
1523
  var RGBATimeline = class extends CurveTimeline {
@@ -2795,13 +2693,13 @@ var spine = (() => {
2795
2693
  var DrawOrderTimeline = _DrawOrderTimeline;
2796
2694
  __publicField(DrawOrderTimeline, "propertyIds", ["" + Property.drawOrder]);
2797
2695
  var IkConstraintTimeline = class extends CurveTimeline {
2798
- /** The index of the IK constraint slot in {@link Skeleton#ikConstraints} that will be changed. */
2799
- ikConstraintIndex = 0;
2696
+ /** The index of the IK constraint in {@link Skeleton#getIkConstraints()} that will be changed when this timeline is */
2697
+ constraintIndex = 0;
2800
2698
  constructor(frameCount, bezierCount, ikConstraintIndex) {
2801
2699
  super(frameCount, bezierCount, [
2802
2700
  Property.ikConstraint + "|" + ikConstraintIndex
2803
2701
  ]);
2804
- this.ikConstraintIndex = ikConstraintIndex;
2702
+ this.constraintIndex = ikConstraintIndex;
2805
2703
  }
2806
2704
  getFrameEntries() {
2807
2705
  return 6;
@@ -2832,7 +2730,7 @@ var spine = (() => {
2832
2730
  ] = stretch ? 1 : 0;
2833
2731
  }
2834
2732
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
2835
- let constraint = skeleton.ikConstraints[this.ikConstraintIndex];
2733
+ let constraint = skeleton.ikConstraints[this.constraintIndex];
2836
2734
  if (!constraint.active)
2837
2735
  return;
2838
2736
  let frames = this.frames;
@@ -2958,12 +2856,12 @@ var spine = (() => {
2958
2856
  };
2959
2857
  var TransformConstraintTimeline = class extends CurveTimeline {
2960
2858
  /** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */
2961
- transformConstraintIndex = 0;
2859
+ constraintIndex = 0;
2962
2860
  constructor(frameCount, bezierCount, transformConstraintIndex) {
2963
2861
  super(frameCount, bezierCount, [
2964
2862
  Property.transformConstraint + "|" + transformConstraintIndex
2965
2863
  ]);
2966
- this.transformConstraintIndex = transformConstraintIndex;
2864
+ this.constraintIndex = transformConstraintIndex;
2967
2865
  }
2968
2866
  getFrameEntries() {
2969
2867
  return 7;
@@ -2999,7 +2897,7 @@ var spine = (() => {
2999
2897
  ] = mixShearY;
3000
2898
  }
3001
2899
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3002
- let constraint = skeleton.transformConstraints[this.transformConstraintIndex];
2900
+ let constraint = skeleton.transformConstraints[this.constraintIndex];
3003
2901
  if (!constraint.active)
3004
2902
  return;
3005
2903
  let frames = this.frames;
@@ -3180,71 +3078,42 @@ var spine = (() => {
3180
3078
  }
3181
3079
  };
3182
3080
  var PathConstraintPositionTimeline = class extends CurveTimeline1 {
3183
- /** The index of the path constraint slot in {@link Skeleton#pathConstraints} that will be changed. */
3184
- pathConstraintIndex = 0;
3081
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3082
+ * applied. */
3083
+ constraintIndex = 0;
3185
3084
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3186
3085
  super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex);
3187
- this.pathConstraintIndex = pathConstraintIndex;
3086
+ this.constraintIndex = pathConstraintIndex;
3188
3087
  }
3189
3088
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3190
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3191
- if (!constraint.active)
3192
- return;
3193
- let frames = this.frames;
3194
- if (time < frames[0]) {
3195
- switch (blend) {
3196
- case 0 /* setup */:
3197
- constraint.position = constraint.data.position;
3198
- return;
3199
- case 1 /* first */:
3200
- constraint.position += (constraint.data.position - constraint.position) * alpha;
3201
- }
3202
- return;
3203
- }
3204
- let position = this.getCurveValue(time);
3205
- if (blend == 0 /* setup */)
3206
- constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
3207
- else
3208
- constraint.position += (position - constraint.position) * alpha;
3089
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3090
+ if (constraint.active)
3091
+ constraint.position = this.getAbsoluteValue(time, alpha, blend, constraint.position, constraint.data.position);
3209
3092
  }
3210
3093
  };
3211
3094
  var PathConstraintSpacingTimeline = class extends CurveTimeline1 {
3212
- /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */
3213
- pathConstraintIndex = 0;
3095
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3096
+ * applied. */
3097
+ constraintIndex = 0;
3214
3098
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3215
3099
  super(frameCount, bezierCount, Property.pathConstraintSpacing + "|" + pathConstraintIndex);
3216
- this.pathConstraintIndex = pathConstraintIndex;
3100
+ this.constraintIndex = pathConstraintIndex;
3217
3101
  }
3218
3102
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3219
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3220
- if (!constraint.active)
3221
- return;
3222
- let frames = this.frames;
3223
- if (time < frames[0]) {
3224
- switch (blend) {
3225
- case 0 /* setup */:
3226
- constraint.spacing = constraint.data.spacing;
3227
- return;
3228
- case 1 /* first */:
3229
- constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
3230
- }
3231
- return;
3232
- }
3233
- let spacing = this.getCurveValue(time);
3234
- if (blend == 0 /* setup */)
3235
- constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
3236
- else
3237
- constraint.spacing += (spacing - constraint.spacing) * alpha;
3103
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3104
+ if (constraint.active)
3105
+ constraint.spacing = this.getAbsoluteValue(time, alpha, blend, constraint.spacing, constraint.data.spacing);
3238
3106
  }
3239
3107
  };
3240
3108
  var PathConstraintMixTimeline = class extends CurveTimeline {
3241
- /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */
3242
- pathConstraintIndex = 0;
3109
+ /** The index of the path constraint in {@link Skeleton#getPathConstraints()} that will be changed when this timeline is
3110
+ * applied. */
3111
+ constraintIndex = 0;
3243
3112
  constructor(frameCount, bezierCount, pathConstraintIndex) {
3244
3113
  super(frameCount, bezierCount, [
3245
3114
  Property.pathConstraintMix + "|" + pathConstraintIndex
3246
3115
  ]);
3247
- this.pathConstraintIndex = pathConstraintIndex;
3116
+ this.constraintIndex = pathConstraintIndex;
3248
3117
  }
3249
3118
  getFrameEntries() {
3250
3119
  return 4;
@@ -3267,7 +3136,7 @@ var spine = (() => {
3267
3136
  ] = mixY;
3268
3137
  }
3269
3138
  apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3270
- let constraint = skeleton.pathConstraints[this.pathConstraintIndex];
3139
+ let constraint = skeleton.pathConstraints[this.constraintIndex];
3271
3140
  if (!constraint.active)
3272
3141
  return;
3273
3142
  let frames = this.frames;
@@ -3374,6 +3243,196 @@ var spine = (() => {
3374
3243
  }
3375
3244
  }
3376
3245
  };
3246
+ var PhysicsConstraintTimeline = class extends CurveTimeline1 {
3247
+ /** The index of the physics constraint in {@link Skeleton#getPhysicsConstraints()} that will be changed when this timeline
3248
+ * is applied, or -1 if all physics constraints in the skeleton will be changed. */
3249
+ constraintIndex = 0;
3250
+ /** @param physicsConstraintIndex -1 for all physics constraints in the skeleton. */
3251
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3252
+ super(frameCount, bezierCount, property + "|" + physicsConstraintIndex);
3253
+ this.constraintIndex = physicsConstraintIndex;
3254
+ }
3255
+ apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3256
+ let constraint;
3257
+ if (this.constraintIndex == -1) {
3258
+ const value = time >= this.frames[0] ? this.getCurveValue(time) : 0;
3259
+ for (const constraint2 of skeleton.physicsConstraints) {
3260
+ if (constraint2.active && this.global(constraint2.data))
3261
+ this.set(constraint2, this.getAbsoluteValue2(time, alpha, blend, this.get(constraint2), this.setup(constraint2), value));
3262
+ }
3263
+ } else {
3264
+ constraint = skeleton.physicsConstraints[this.constraintIndex];
3265
+ if (constraint.active)
3266
+ this.set(constraint, this.getAbsoluteValue(time, alpha, blend, this.get(constraint), this.setup(constraint)));
3267
+ }
3268
+ }
3269
+ };
3270
+ var PhysicsConstraintInertiaTimeline = class extends PhysicsConstraintTimeline {
3271
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3272
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintInertia);
3273
+ }
3274
+ setup(constraint) {
3275
+ return constraint.data.inertia;
3276
+ }
3277
+ get(constraint) {
3278
+ return constraint.inertia;
3279
+ }
3280
+ set(constraint, value) {
3281
+ constraint.inertia = value;
3282
+ }
3283
+ global(constraint) {
3284
+ return constraint.inertiaGlobal;
3285
+ }
3286
+ };
3287
+ var PhysicsConstraintStrengthTimeline = class extends PhysicsConstraintTimeline {
3288
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3289
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintStrength);
3290
+ }
3291
+ setup(constraint) {
3292
+ return constraint.data.strength;
3293
+ }
3294
+ get(constraint) {
3295
+ return constraint.strength;
3296
+ }
3297
+ set(constraint, value) {
3298
+ constraint.strength = value;
3299
+ }
3300
+ global(constraint) {
3301
+ return constraint.strengthGlobal;
3302
+ }
3303
+ };
3304
+ var PhysicsConstraintDampingTimeline = class extends PhysicsConstraintTimeline {
3305
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3306
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintDamping);
3307
+ }
3308
+ setup(constraint) {
3309
+ return constraint.data.damping;
3310
+ }
3311
+ get(constraint) {
3312
+ return constraint.damping;
3313
+ }
3314
+ set(constraint, value) {
3315
+ constraint.damping = value;
3316
+ }
3317
+ global(constraint) {
3318
+ return constraint.dampingGlobal;
3319
+ }
3320
+ };
3321
+ var PhysicsConstraintMassTimeline = class extends PhysicsConstraintTimeline {
3322
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3323
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintMass);
3324
+ }
3325
+ setup(constraint) {
3326
+ return 1 / constraint.data.massInverse;
3327
+ }
3328
+ get(constraint) {
3329
+ return 1 / constraint.massInverse;
3330
+ }
3331
+ set(constraint, value) {
3332
+ constraint.massInverse = 1 / value;
3333
+ }
3334
+ global(constraint) {
3335
+ return constraint.massGlobal;
3336
+ }
3337
+ };
3338
+ var PhysicsConstraintWindTimeline = class extends PhysicsConstraintTimeline {
3339
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3340
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintWind);
3341
+ }
3342
+ setup(constraint) {
3343
+ return constraint.data.wind;
3344
+ }
3345
+ get(constraint) {
3346
+ return constraint.wind;
3347
+ }
3348
+ set(constraint, value) {
3349
+ constraint.wind = value;
3350
+ }
3351
+ global(constraint) {
3352
+ return constraint.windGlobal;
3353
+ }
3354
+ };
3355
+ var PhysicsConstraintGravityTimeline = class extends PhysicsConstraintTimeline {
3356
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3357
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintGravity);
3358
+ }
3359
+ setup(constraint) {
3360
+ return constraint.data.gravity;
3361
+ }
3362
+ get(constraint) {
3363
+ return constraint.gravity;
3364
+ }
3365
+ set(constraint, value) {
3366
+ constraint.gravity = value;
3367
+ }
3368
+ global(constraint) {
3369
+ return constraint.gravityGlobal;
3370
+ }
3371
+ };
3372
+ var PhysicsConstraintMixTimeline = class extends PhysicsConstraintTimeline {
3373
+ constructor(frameCount, bezierCount, physicsConstraintIndex, property) {
3374
+ super(frameCount, bezierCount, physicsConstraintIndex, Property.physicsConstraintMix);
3375
+ }
3376
+ setup(constraint) {
3377
+ return constraint.data.mix;
3378
+ }
3379
+ get(constraint) {
3380
+ return constraint.mix;
3381
+ }
3382
+ set(constraint, value) {
3383
+ constraint.mix = value;
3384
+ }
3385
+ global(constraint) {
3386
+ return constraint.mixGlobal;
3387
+ }
3388
+ };
3389
+ var _PhysicsConstraintResetTimeline = class extends Timeline {
3390
+ /** The index of the physics constraint in {@link Skeleton#getPhysicsConstraints()} that will be reset when this timeline is
3391
+ * applied, or -1 if all physics constraints in the skeleton will be reset. */
3392
+ constraintIndex;
3393
+ /** @param physicsConstraintIndex -1 for all physics constraints in the skeleton. */
3394
+ constructor(frameCount, physicsConstraintIndex) {
3395
+ super(frameCount, _PhysicsConstraintResetTimeline.propertyIds);
3396
+ this.constraintIndex = physicsConstraintIndex;
3397
+ }
3398
+ getFrameCount() {
3399
+ return this.frames.length;
3400
+ }
3401
+ /** Sets the time for the specified frame.
3402
+ * @param frame Between 0 and <code>frameCount</code>, inclusive. */
3403
+ setFrame(frame, time) {
3404
+ this.frames[frame] = time;
3405
+ }
3406
+ /** Resets the physics constraint when frames > <code>lastTime</code> and <= <code>time</code>. */
3407
+ apply(skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
3408
+ let constraint;
3409
+ if (this.constraintIndex != -1) {
3410
+ constraint = skeleton.physicsConstraints[this.constraintIndex];
3411
+ if (!constraint.active)
3412
+ return;
3413
+ }
3414
+ const frames = this.frames;
3415
+ if (lastTime > time) {
3416
+ this.apply(skeleton, lastTime, Number.MAX_VALUE, [], alpha, blend, direction);
3417
+ lastTime = -1;
3418
+ } else if (lastTime >= frames[frames.length - 1])
3419
+ return;
3420
+ if (time < frames[0])
3421
+ return;
3422
+ if (lastTime < frames[0] || time >= frames[Timeline.search1(frames, lastTime) + 1]) {
3423
+ if (constraint != null)
3424
+ constraint.reset();
3425
+ else {
3426
+ for (const constraint2 of skeleton.physicsConstraints) {
3427
+ if (constraint2.active)
3428
+ constraint2.reset();
3429
+ }
3430
+ }
3431
+ }
3432
+ }
3433
+ };
3434
+ var PhysicsConstraintResetTimeline = _PhysicsConstraintResetTimeline;
3435
+ __publicField(PhysicsConstraintResetTimeline, "propertyIds", [Property.physicsConstraintReset.toString()]);
3377
3436
  var _SequenceTimeline = class extends Timeline {
3378
3437
  slotIndex;
3379
3438
  attachment;
@@ -3580,11 +3639,12 @@ var spine = (() => {
3580
3639
  continue;
3581
3640
  applied = true;
3582
3641
  let blend = i2 == 0 ? 1 /* first */ : current.mixBlend;
3583
- let mix = current.alpha;
3642
+ let alpha = current.alpha;
3584
3643
  if (current.mixingFrom)
3585
- mix *= this.applyMixingFrom(current, skeleton, blend);
3644
+ alpha *= this.applyMixingFrom(current, skeleton, blend);
3586
3645
  else if (current.trackTime >= current.trackEnd && !current.next)
3587
- mix = 0;
3646
+ alpha = 0;
3647
+ let attachments = alpha >= current.alphaAttachmentThreshold;
3588
3648
  let animationLast = current.animationLast, animationTime = current.getAnimationTime(), applyTime = animationTime;
3589
3649
  let applyEvents = events;
3590
3650
  if (current.reverse) {
@@ -3593,14 +3653,16 @@ var spine = (() => {
3593
3653
  }
3594
3654
  let timelines = current.animation.timelines;
3595
3655
  let timelineCount = timelines.length;
3596
- if (i2 == 0 && mix == 1 || blend == 3 /* add */) {
3656
+ if (i2 == 0 && alpha == 1 || blend == 3 /* add */) {
3657
+ if (i2 == 0)
3658
+ attachments = true;
3597
3659
  for (let ii = 0; ii < timelineCount; ii++) {
3598
- Utils.webkit602BugfixHelper(mix, blend);
3660
+ Utils.webkit602BugfixHelper(alpha, blend);
3599
3661
  var timeline = timelines[ii];
3600
3662
  if (timeline instanceof AttachmentTimeline)
3601
- this.applyAttachmentTimeline(timeline, skeleton, applyTime, blend, true);
3663
+ this.applyAttachmentTimeline(timeline, skeleton, applyTime, blend, attachments);
3602
3664
  else
3603
- timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, 0 /* mixIn */);
3665
+ timeline.apply(skeleton, animationLast, applyTime, applyEvents, alpha, blend, 0 /* mixIn */);
3604
3666
  }
3605
3667
  } else {
3606
3668
  let timelineMode = current.timelineMode;
@@ -3612,12 +3674,12 @@ var spine = (() => {
3612
3674
  let timeline2 = timelines[ii];
3613
3675
  let timelineBlend = timelineMode[ii] == SUBSEQUENT ? blend : 0 /* setup */;
3614
3676
  if (!shortestRotation && timeline2 instanceof RotateTimeline) {
3615
- this.applyRotateTimeline(timeline2, skeleton, applyTime, mix, timelineBlend, current.timelinesRotation, ii << 1, firstFrame);
3677
+ this.applyRotateTimeline(timeline2, skeleton, applyTime, alpha, timelineBlend, current.timelinesRotation, ii << 1, firstFrame);
3616
3678
  } else if (timeline2 instanceof AttachmentTimeline) {
3617
- this.applyAttachmentTimeline(timeline2, skeleton, applyTime, blend, true);
3679
+ this.applyAttachmentTimeline(timeline2, skeleton, applyTime, blend, attachments);
3618
3680
  } else {
3619
- Utils.webkit602BugfixHelper(mix, blend);
3620
- timeline2.apply(skeleton, animationLast, applyTime, applyEvents, mix, timelineBlend, 0 /* mixIn */);
3681
+ Utils.webkit602BugfixHelper(alpha, blend);
3682
+ timeline2.apply(skeleton, animationLast, applyTime, applyEvents, alpha, timelineBlend, 0 /* mixIn */);
3621
3683
  }
3622
3684
  }
3623
3685
  }
@@ -3655,7 +3717,7 @@ var spine = (() => {
3655
3717
  if (blend != 1 /* first */)
3656
3718
  blend = from.mixBlend;
3657
3719
  }
3658
- let attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
3720
+ let attachments = mix < from.mixAttachmentThreshold, drawOrder = mix < from.mixDrawOrderThreshold;
3659
3721
  let timelines = from.animation.timelines;
3660
3722
  let timelineCount = timelines.length;
3661
3723
  let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
@@ -3710,7 +3772,7 @@ var spine = (() => {
3710
3772
  if (!shortestRotation && timeline instanceof RotateTimeline)
3711
3773
  this.applyRotateTimeline(timeline, skeleton, applyTime, alpha, timelineBlend, from.timelinesRotation, i << 1, firstFrame);
3712
3774
  else if (timeline instanceof AttachmentTimeline)
3713
- this.applyAttachmentTimeline(timeline, skeleton, applyTime, timelineBlend, attachments);
3775
+ this.applyAttachmentTimeline(timeline, skeleton, applyTime, timelineBlend, attachments && alpha >= from.alphaAttachmentThreshold);
3714
3776
  else {
3715
3777
  Utils.webkit602BugfixHelper(alpha, blend);
3716
3778
  if (drawOrder && timeline instanceof DrawOrderTimeline && timelineBlend == 0 /* setup */)
@@ -3770,7 +3832,7 @@ var spine = (() => {
3770
3832
  r2 = bone.data.rotation + timeline.getCurveValue(time);
3771
3833
  }
3772
3834
  let total = 0, diff = r2 - r1;
3773
- diff -= (16384 - (16384.499999999996 - diff / 360 | 0)) * 360;
3835
+ diff -= Math.ceil(diff / 360 - 0.5) * 360;
3774
3836
  if (diff == 0) {
3775
3837
  total = timelinesRotation[i];
3776
3838
  } else {
@@ -4027,8 +4089,9 @@ var spine = (() => {
4027
4089
  entry.reverse = false;
4028
4090
  entry.shortestRotation = false;
4029
4091
  entry.eventThreshold = 0;
4030
- entry.attachmentThreshold = 0;
4031
- entry.drawOrderThreshold = 0;
4092
+ entry.alphaAttachmentThreshold = 0;
4093
+ entry.mixAttachmentThreshold = 0;
4094
+ entry.mixDrawOrderThreshold = 0;
4032
4095
  entry.animationStart = 0;
4033
4096
  entry.animationEnd = animation.duration;
4034
4097
  entry.animationLast = -1;
@@ -4186,11 +4249,14 @@ var spine = (() => {
4186
4249
  /** When the mix percentage ({@link #mixtime} / {@link #mixDuration}) is less than the
4187
4250
  * `attachmentThreshold`, attachment timelines are applied while this animation is being mixed out. Defaults to
4188
4251
  * 0, so attachment timelines are not applied while this animation is being mixed out. */
4189
- attachmentThreshold = 0;
4190
- /** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the
4191
- * `drawOrderThreshold`, draw order timelines are applied while this animation is being mixed out. Defaults to 0,
4192
- * so draw order timelines are not applied while this animation is being mixed out. */
4193
- drawOrderThreshold = 0;
4252
+ mixAttachmentThreshold = 0;
4253
+ /** When {@link #getAlpha()} is greater than <code>alphaAttachmentThreshold</code>, attachment timelines are applied.
4254
+ * Defaults to 0, so attachment timelines are always applied. */
4255
+ alphaAttachmentThreshold = 0;
4256
+ /** When the mix percentage ({@link #getMixTime()} / {@link #getMixDuration()}) is less than the
4257
+ * <code>mixDrawOrderThreshold</code>, draw order timelines are applied while this animation is being mixed out. Defaults to
4258
+ * 0, so draw order timelines are not applied while this animation is being mixed out. */
4259
+ mixDrawOrderThreshold = 0;
4194
4260
  /** Seconds when this animation starts, both initially and after looping. Defaults to 0.
4195
4261
  *
4196
4262
  * When changing the `animationStart` time, it often makes sense to set {@link #animationLast} to the same
@@ -4260,9 +4326,18 @@ var spine = (() => {
4260
4326
  * When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
4261
4327
  * {@link #delay} is set using the mix duration from the {@link AnimationStateData}, not a mix duration set
4262
4328
  * afterward. */
4263
- mixDuration = 0;
4329
+ _mixDuration = 0;
4264
4330
  interruptAlpha = 0;
4265
4331
  totalAlpha = 0;
4332
+ get mixDuration() {
4333
+ return this._mixDuration;
4334
+ }
4335
+ set mixDuration(mixDuration) {
4336
+ this._mixDuration = mixDuration;
4337
+ if (this.previous != null && this.delay <= 0)
4338
+ this.delay += this.previous.getTrackComplete() - mixDuration;
4339
+ this.delay = this.delay;
4340
+ }
4266
4341
  /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which
4267
4342
  * replaces the values from the lower tracks with the animation values. {@link MixBlend#add} adds the animation values to
4268
4343
  * the values from the lower tracks.
@@ -4326,6 +4401,12 @@ var spine = (() => {
4326
4401
  }
4327
4402
  return this.trackTime;
4328
4403
  }
4404
+ /** Returns true if this track entry has been applied at least once.
4405
+ * <p>
4406
+ * See {@link AnimationState#apply(Skeleton)}. */
4407
+ wasApplied() {
4408
+ return this.nextTrackLast != -1;
4409
+ }
4329
4410
  };
4330
4411
  var EventQueue = class {
4331
4412
  objects = [];
@@ -5026,10 +5107,10 @@ var spine = (() => {
5026
5107
  return point;
5027
5108
  }
5028
5109
  computeWorldRotation(bone) {
5029
- let cos = MathUtils.cosDeg(this.rotation), sin = MathUtils.sinDeg(this.rotation);
5030
- let x = cos * bone.a + sin * bone.b;
5031
- let y = cos * bone.c + sin * bone.d;
5032
- return Math.atan2(y, x) * MathUtils.radDeg;
5110
+ const r = this.rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
5111
+ const x = cos * bone.a + sin * bone.b;
5112
+ const y = cos * bone.c + sin * bone.d;
5113
+ return MathUtils.atan2Deg(y, x);
5033
5114
  }
5034
5115
  copy() {
5035
5116
  let copy = new PointAttachment(this.name);
@@ -5096,7 +5177,7 @@ var spine = (() => {
5096
5177
  let localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
5097
5178
  let localX2 = localX + this.region.width * regionScaleX;
5098
5179
  let localY2 = localY + this.region.height * regionScaleY;
5099
- let radians = this.rotation * Math.PI / 180;
5180
+ let radians = this.rotation * MathUtils.degRad;
5100
5181
  let cos = Math.cos(radians);
5101
5182
  let sin = Math.sin(radians);
5102
5183
  let x = this.x, y = this.y;
@@ -5292,7 +5373,7 @@ var spine = (() => {
5292
5373
  x = 0;
5293
5374
  /** The local y translation. */
5294
5375
  y = 0;
5295
- /** The local rotation. */
5376
+ /** The local rotation in degrees, counter clockwise. */
5296
5377
  rotation = 0;
5297
5378
  /** The local scaleX. */
5298
5379
  scaleX = 1;
@@ -5311,6 +5392,10 @@ var spine = (() => {
5311
5392
  /** The color of the bone as it was in Spine. Available only when nonessential data was exported. Bones are not usually
5312
5393
  * rendered at runtime. */
5313
5394
  color = new Color();
5395
+ /** The bone icon as it was in Spine, or null if nonessential data was not exported. */
5396
+ icon;
5397
+ /** False if the bone was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
5398
+ visible = false;
5314
5399
  constructor(index, name, parent) {
5315
5400
  if (index < 0)
5316
5401
  throw new Error("index must be >= 0.");
@@ -5399,7 +5484,7 @@ var spine = (() => {
5399
5484
  return this.active;
5400
5485
  }
5401
5486
  /** Computes the world transform using the parent bone and this bone's local applied transform. */
5402
- update() {
5487
+ update(physics) {
5403
5488
  this.updateWorldTransformWith(this.ax, this.ay, this.arotation, this.ascaleX, this.ascaleY, this.ashearX, this.ashearY);
5404
5489
  }
5405
5490
  /** Computes the world transform using the parent bone and this bone's local transform.
@@ -5424,13 +5509,13 @@ var spine = (() => {
5424
5509
  let parent = this.parent;
5425
5510
  if (!parent) {
5426
5511
  let skeleton = this.skeleton;
5427
- let rotationY = rotation + 90 + shearY;
5428
- let sx = skeleton.scaleX;
5429
- let sy = skeleton.scaleY;
5430
- this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
5431
- this.b = MathUtils.cosDeg(rotationY) * scaleY * sx;
5432
- this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
5433
- this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
5512
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
5513
+ const rx = (rotation + shearX) * MathUtils.degRad;
5514
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5515
+ this.a = Math.cos(rx) * scaleX * sx;
5516
+ this.b = Math.cos(ry) * scaleY * sx;
5517
+ this.c = Math.sin(rx) * scaleX * sy;
5518
+ this.d = Math.sin(ry) * scaleY * sy;
5434
5519
  this.worldX = x * sx + skeleton.x;
5435
5520
  this.worldY = y * sy + skeleton.y;
5436
5521
  return;
@@ -5440,11 +5525,12 @@ var spine = (() => {
5440
5525
  this.worldY = pc * x + pd * y + parent.worldY;
5441
5526
  switch (this.data.transformMode) {
5442
5527
  case 0 /* Normal */: {
5443
- let rotationY = rotation + 90 + shearY;
5444
- let la = MathUtils.cosDeg(rotation + shearX) * scaleX;
5445
- let lb = MathUtils.cosDeg(rotationY) * scaleY;
5446
- let lc = MathUtils.sinDeg(rotation + shearX) * scaleX;
5447
- let ld = MathUtils.sinDeg(rotationY) * scaleY;
5528
+ const rx = (rotation + shearX) * MathUtils.degRad;
5529
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5530
+ const la = Math.cos(rx) * scaleX;
5531
+ const lb = Math.cos(ry) * scaleY;
5532
+ const lc = Math.sin(rx) * scaleX;
5533
+ const ld = Math.sin(ry) * scaleY;
5448
5534
  this.a = pa * la + pb * lc;
5449
5535
  this.b = pa * lb + pb * ld;
5450
5536
  this.c = pc * la + pd * lc;
@@ -5452,11 +5538,12 @@ var spine = (() => {
5452
5538
  return;
5453
5539
  }
5454
5540
  case 1 /* OnlyTranslation */: {
5455
- let rotationY = rotation + 90 + shearY;
5456
- this.a = MathUtils.cosDeg(rotation + shearX) * scaleX;
5457
- this.b = MathUtils.cosDeg(rotationY) * scaleY;
5458
- this.c = MathUtils.sinDeg(rotation + shearX) * scaleX;
5459
- this.d = MathUtils.sinDeg(rotationY) * scaleY;
5541
+ const rx = (rotation + shearX) * MathUtils.degRad;
5542
+ const ry = (rotation + 90 + shearY) * MathUtils.degRad;
5543
+ this.a = Math.cos(rx) * scaleX;
5544
+ this.b = Math.cos(ry) * scaleY;
5545
+ this.c = Math.sin(rx) * scaleX;
5546
+ this.d = Math.sin(ry) * scaleY;
5460
5547
  break;
5461
5548
  }
5462
5549
  case 2 /* NoRotationOrReflection */: {
@@ -5474,12 +5561,12 @@ var spine = (() => {
5474
5561
  pc = 0;
5475
5562
  prx = 90 - Math.atan2(pd, pb) * MathUtils.radDeg;
5476
5563
  }
5477
- let rx = rotation + shearX - prx;
5478
- let ry = rotation + shearY - prx + 90;
5479
- let la = MathUtils.cosDeg(rx) * scaleX;
5480
- let lb = MathUtils.cosDeg(ry) * scaleY;
5481
- let lc = MathUtils.sinDeg(rx) * scaleX;
5482
- let ld = MathUtils.sinDeg(ry) * scaleY;
5564
+ const rx = (rotation + shearX - prx) * MathUtils.degRad;
5565
+ const ry = (rotation + shearY - prx + 90) * MathUtils.degRad;
5566
+ const la = Math.cos(rx) * scaleX;
5567
+ const lb = Math.cos(ry) * scaleY;
5568
+ const lc = Math.sin(rx) * scaleX;
5569
+ const ld = Math.sin(ry) * scaleY;
5483
5570
  this.a = pa * la - pb * lc;
5484
5571
  this.b = pa * lb - pb * ld;
5485
5572
  this.c = pc * la + pd * lc;
@@ -5488,8 +5575,8 @@ var spine = (() => {
5488
5575
  }
5489
5576
  case 3 /* NoScale */:
5490
5577
  case 4 /* NoScaleOrReflection */: {
5491
- let cos = MathUtils.cosDeg(rotation);
5492
- let sin = MathUtils.sinDeg(rotation);
5578
+ rotation *= MathUtils.degRad;
5579
+ const cos = Math.cos(rotation), sin = Math.sin(rotation);
5493
5580
  let za = (pa * cos + pb * sin) / this.skeleton.scaleX;
5494
5581
  let zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
5495
5582
  let s = Math.sqrt(za * za + zc * zc);
@@ -5500,13 +5587,15 @@ var spine = (() => {
5500
5587
  s = Math.sqrt(za * za + zc * zc);
5501
5588
  if (this.data.transformMode == 3 /* NoScale */ && pa * pd - pb * pc < 0 != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
5502
5589
  s = -s;
5503
- let r = Math.PI / 2 + Math.atan2(zc, za);
5504
- let zb = Math.cos(r) * s;
5505
- let zd = Math.sin(r) * s;
5506
- let la = MathUtils.cosDeg(shearX) * scaleX;
5507
- let lb = MathUtils.cosDeg(90 + shearY) * scaleY;
5508
- let lc = MathUtils.sinDeg(shearX) * scaleX;
5509
- let ld = MathUtils.sinDeg(90 + shearY) * scaleY;
5590
+ rotation = Math.PI / 2 + Math.atan2(zc, za);
5591
+ const zb = Math.cos(rotation) * s;
5592
+ const zd = Math.sin(rotation) * s;
5593
+ shearX *= MathUtils.degRad;
5594
+ shearY = (90 + shearY) * MathUtils.degRad;
5595
+ const la = Math.cos(shearX) * scaleX;
5596
+ const lb = Math.cos(shearY) * scaleY;
5597
+ const lc = Math.sin(shearX) * scaleX;
5598
+ const ld = Math.sin(shearY) * scaleY;
5510
5599
  this.a = za * la + zb * lc;
5511
5600
  this.b = za * lb + zb * ld;
5512
5601
  this.c = zc * la + zd * lc;
@@ -5530,22 +5619,6 @@ var spine = (() => {
5530
5619
  this.shearX = data.shearX;
5531
5620
  this.shearY = data.shearY;
5532
5621
  }
5533
- /** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. */
5534
- getWorldRotationX() {
5535
- return Math.atan2(this.c, this.a) * MathUtils.radDeg;
5536
- }
5537
- /** The world rotation for the Y axis, calculated using {@link #b} and {@link #d}. */
5538
- getWorldRotationY() {
5539
- return Math.atan2(this.d, this.b) * MathUtils.radDeg;
5540
- }
5541
- /** The magnitude (always positive) of the world scale X, calculated using {@link #a} and {@link #c}. */
5542
- getWorldScaleX() {
5543
- return Math.sqrt(this.a * this.a + this.c * this.c);
5544
- }
5545
- /** The magnitude (always positive) of the world scale Y, calculated using {@link #b} and {@link #d}. */
5546
- getWorldScaleY() {
5547
- return Math.sqrt(this.b * this.b + this.d * this.d);
5548
- }
5549
5622
  /** Computes the applied transform values from the world transform.
5550
5623
  *
5551
5624
  * If the world transform is modified (by a constraint, {@link #rotateWorld(float)}, etc) then this method should be called so
@@ -5632,6 +5705,22 @@ var spine = (() => {
5632
5705
  this.arotation = 90 - Math.atan2(rd, rb) * MathUtils.radDeg;
5633
5706
  }
5634
5707
  }
5708
+ /** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. */
5709
+ getWorldRotationX() {
5710
+ return Math.atan2(this.c, this.a) * MathUtils.radDeg;
5711
+ }
5712
+ /** The world rotation for the Y axis, calculated using {@link #b} and {@link #d}. */
5713
+ getWorldRotationY() {
5714
+ return Math.atan2(this.d, this.b) * MathUtils.radDeg;
5715
+ }
5716
+ /** The magnitude (always positive) of the world scale X, calculated using {@link #a} and {@link #c}. */
5717
+ getWorldScaleX() {
5718
+ return Math.sqrt(this.a * this.a + this.c * this.c);
5719
+ }
5720
+ /** The magnitude (always positive) of the world scale Y, calculated using {@link #b} and {@link #d}. */
5721
+ getWorldScaleY() {
5722
+ return Math.sqrt(this.b * this.b + this.d * this.d);
5723
+ }
5635
5724
  /** Transforms a point from world coordinates to the bone's local coordinates. */
5636
5725
  worldToLocal(world) {
5637
5726
  let invDet = 1 / (this.a * this.d - this.b * this.c);
@@ -5647,6 +5736,18 @@ var spine = (() => {
5647
5736
  local.y = x * this.c + y * this.d + this.worldY;
5648
5737
  return local;
5649
5738
  }
5739
+ /** Transforms a point from world coordinates to the parent bone's local coordinates. */
5740
+ worldToParent(world) {
5741
+ if (world == null)
5742
+ throw new Error("world cannot be null.");
5743
+ return this.parent == null ? world : this.parent.worldToLocal(world);
5744
+ }
5745
+ /** Transforms a point from the parent bone's coordinates to world coordinates. */
5746
+ parentToWorld(world) {
5747
+ if (world == null)
5748
+ throw new Error("world cannot be null.");
5749
+ return this.parent == null ? world : this.parent.localToWorld(world);
5750
+ }
5650
5751
  /** Transforms a world rotation to a local rotation. */
5651
5752
  worldToLocalRotation(worldRotation) {
5652
5753
  let sin = MathUtils.sinDeg(worldRotation), cos = MathUtils.cosDeg(worldRotation);
@@ -5660,15 +5761,16 @@ var spine = (() => {
5660
5761
  }
5661
5762
  /** Rotates the world transform the specified amount.
5662
5763
  * <p>
5663
- * After changes are made to the world transform, {@link #updateAppliedTransform()} should be called and {@link #update()} will
5664
- * need to be called on any child bones, recursively. */
5764
+ * After changes are made to the world transform, {@link #updateAppliedTransform()} should be called and
5765
+ * {@link #update(Physics)} will need to be called on any child bones, recursively. */
5665
5766
  rotateWorld(degrees) {
5666
- let a = this.a, b = this.b, c = this.c, d = this.d;
5667
- let cos = MathUtils.cosDeg(degrees), sin = MathUtils.sinDeg(degrees);
5668
- this.a = cos * a - sin * c;
5669
- this.b = cos * b - sin * d;
5670
- this.c = sin * a + cos * c;
5671
- this.d = sin * b + cos * d;
5767
+ degrees *= MathUtils.degRad;
5768
+ const sin = Math.sin(degrees), cos = Math.cos(degrees);
5769
+ const ra = this.a, rb = this.b;
5770
+ this.a = cos * ra - sin * this.c;
5771
+ this.b = cos * rb - sin * this.d;
5772
+ this.c = sin * ra + cos * this.c;
5773
+ this.d = sin * rb + cos * this.d;
5672
5774
  }
5673
5775
  };
5674
5776
 
@@ -6058,7 +6160,15 @@ var spine = (() => {
6058
6160
  isActive() {
6059
6161
  return this.active;
6060
6162
  }
6061
- update() {
6163
+ setToSetupPose() {
6164
+ const data = this.data;
6165
+ this.mix = data.mix;
6166
+ this.softness = data.softness;
6167
+ this.bendDirection = data.bendDirection;
6168
+ this.compress = data.compress;
6169
+ this.stretch = data.stretch;
6170
+ }
6171
+ update(physics) {
6062
6172
  if (this.mix == 0)
6063
6173
  return;
6064
6174
  let target = this.target;
@@ -6117,12 +6227,15 @@ var spine = (() => {
6117
6227
  tx = targetX - bone.worldX;
6118
6228
  ty = targetY - bone.worldY;
6119
6229
  }
6120
- let b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty);
6121
- if (compress && dd < b || stretch && dd > b && b > 1e-4) {
6122
- let s = (dd / b - 1) * alpha + 1;
6123
- sx *= s;
6124
- if (uniform)
6125
- sy *= s;
6230
+ const b = bone.data.length * sx;
6231
+ if (b > 1e-4) {
6232
+ const dd = tx * tx + ty * ty;
6233
+ if (compress && dd < b * b || stretch && dd > b * b) {
6234
+ const s = (Math.sqrt(dd) / b - 1) * alpha + 1;
6235
+ sx *= s;
6236
+ if (uniform)
6237
+ sy *= s;
6238
+ }
6126
6239
  }
6127
6240
  }
6128
6241
  bone.updateWorldTransformWith(
@@ -6423,7 +6536,15 @@ var spine = (() => {
6423
6536
  isActive() {
6424
6537
  return this.active;
6425
6538
  }
6426
- update() {
6539
+ setToSetupPose() {
6540
+ const data = this.data;
6541
+ this.position = data.position;
6542
+ this.spacing = data.spacing;
6543
+ this.mixRotate = data.mixRotate;
6544
+ this.mixX = data.mixX;
6545
+ this.mixY = data.mixY;
6546
+ }
6547
+ update(physics) {
6427
6548
  let attachment = this.target.getAttachment();
6428
6549
  if (!(attachment instanceof PathAttachment))
6429
6550
  return;
@@ -6442,12 +6563,8 @@ var spine = (() => {
6442
6563
  for (let i = 0, n = spacesCount - 1; i < n; i++) {
6443
6564
  let bone = bones[i];
6444
6565
  let setupLength = bone.data.length;
6445
- if (setupLength < _PathConstraint.epsilon)
6446
- lengths[i] = 0;
6447
- else {
6448
- let x = setupLength * bone.a, y = setupLength * bone.c;
6449
- lengths[i] = Math.sqrt(x * x + y * y);
6450
- }
6566
+ let x = setupLength * bone.a, y = setupLength * bone.c;
6567
+ lengths[i] = Math.sqrt(x * x + y * y);
6451
6568
  }
6452
6569
  }
6453
6570
  Utils.arrayFill(spaces, 1, spacesCount, spacing);
@@ -6822,6 +6939,238 @@ var spine = (() => {
6822
6939
  __publicField(PathConstraint, "AFTER", -3);
6823
6940
  __publicField(PathConstraint, "epsilon", 1e-5);
6824
6941
 
6942
+ // spine-core/src/PhysicsConstraint.ts
6943
+ var PhysicsConstraint = class {
6944
+ data;
6945
+ _bone = null;
6946
+ /** The bone constrained by this physics constraint. */
6947
+ set bone(bone) {
6948
+ this._bone = bone;
6949
+ }
6950
+ get bone() {
6951
+ if (!this._bone)
6952
+ throw new Error("Bone not set.");
6953
+ else
6954
+ return this._bone;
6955
+ }
6956
+ inertia = 0;
6957
+ strength = 0;
6958
+ damping = 0;
6959
+ massInverse = 0;
6960
+ wind = 0;
6961
+ gravity = 0;
6962
+ mix = 0;
6963
+ _reset = true;
6964
+ ux = 0;
6965
+ uy = 0;
6966
+ cx = 0;
6967
+ cy = 0;
6968
+ tx = 0;
6969
+ ty = 0;
6970
+ xOffset = 0;
6971
+ xVelocity = 0;
6972
+ yOffset = 0;
6973
+ yVelocity = 0;
6974
+ rotateOffset = 0;
6975
+ rotateVelocity = 0;
6976
+ scaleOffset = 0;
6977
+ scaleVelocity = 0;
6978
+ active = false;
6979
+ skeleton;
6980
+ remaining = 0;
6981
+ lastTime = 0;
6982
+ constructor(data, skeleton) {
6983
+ this.data = data;
6984
+ this.skeleton = skeleton;
6985
+ this.bone = skeleton.bones[data.bone.index];
6986
+ this.inertia = data.inertia;
6987
+ this.strength = data.strength;
6988
+ this.damping = data.damping;
6989
+ this.massInverse = data.massInverse;
6990
+ this.wind = data.wind;
6991
+ this.gravity = data.gravity;
6992
+ this.mix = data.mix;
6993
+ }
6994
+ reset() {
6995
+ this.remaining = 0;
6996
+ this.lastTime = this.skeleton.time;
6997
+ this._reset = true;
6998
+ this.xOffset = 0;
6999
+ this.xVelocity = 0;
7000
+ this.yOffset = 0;
7001
+ this.yVelocity = 0;
7002
+ this.rotateOffset = 0;
7003
+ this.rotateVelocity = 0;
7004
+ this.scaleOffset = 0;
7005
+ this.scaleVelocity = 0;
7006
+ }
7007
+ setToSetupPose() {
7008
+ const data = this.data;
7009
+ this.inertia = data.inertia;
7010
+ this.strength = data.strength;
7011
+ this.damping = data.damping;
7012
+ this.massInverse = data.massInverse;
7013
+ this.wind = data.wind;
7014
+ this.gravity = data.gravity;
7015
+ this.mix = data.mix;
7016
+ }
7017
+ isActive() {
7018
+ return this.active;
7019
+ }
7020
+ /** Applies the constraint to the constrained bones. */
7021
+ update(physics) {
7022
+ const mix = this.mix;
7023
+ if (mix == 0)
7024
+ return;
7025
+ 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;
7026
+ const bone = this.bone;
7027
+ const l = bone.data.length;
7028
+ switch (physics) {
7029
+ case 0 /* none */:
7030
+ return;
7031
+ case 1 /* reset */:
7032
+ this.reset();
7033
+ case 2 /* update */:
7034
+ this.remaining += Math.max(this.skeleton.time - this.lastTime, 0);
7035
+ this.lastTime = this.skeleton.time;
7036
+ const bx = bone.worldX, by = bone.worldY;
7037
+ if (this._reset) {
7038
+ this._reset = false;
7039
+ this.ux = bx;
7040
+ this.uy = by;
7041
+ } else {
7042
+ let remaining = this.remaining, i = this.inertia, step = this.data.step;
7043
+ if (x || y) {
7044
+ if (x) {
7045
+ this.xOffset += (this.ux - bx) * i;
7046
+ this.ux = bx;
7047
+ }
7048
+ if (y) {
7049
+ this.yOffset += (this.uy - by) * i;
7050
+ this.uy = by;
7051
+ }
7052
+ if (remaining >= step) {
7053
+ const m = this.massInverse * step, e = this.strength, w = this.wind * 100, g = this.gravity * -100;
7054
+ const d = Math.pow(this.damping, 60 * step);
7055
+ do {
7056
+ if (x) {
7057
+ this.xVelocity += (w - this.xOffset * e) * m;
7058
+ this.xOffset += this.xVelocity * step;
7059
+ this.xVelocity *= d;
7060
+ }
7061
+ if (y) {
7062
+ this.yVelocity += (g - this.yOffset * e) * m;
7063
+ this.yOffset += this.yVelocity * step;
7064
+ this.yVelocity *= d;
7065
+ }
7066
+ remaining -= step;
7067
+ } while (remaining >= step);
7068
+ }
7069
+ if (x)
7070
+ bone.worldX += this.xOffset * mix * this.data.x;
7071
+ if (y)
7072
+ bone.worldY += this.yOffset * mix * this.data.y;
7073
+ }
7074
+ if (rotateOrShearX || scaleX) {
7075
+ let ca = Math.atan2(bone.c, bone.a), c = 0, s = 0, mr = 0;
7076
+ if (rotateOrShearX) {
7077
+ mr = mix * this.data.rotate;
7078
+ let dx = this.cx - bone.worldX, dy = this.cy - bone.worldY, r = Math.atan2(dy + this.ty, dx + this.tx) - ca - this.rotateOffset * mr;
7079
+ this.rotateOffset += (r - Math.ceil(r * MathUtils.invPI2 - 0.5) * MathUtils.PI2) * i;
7080
+ r = this.rotateOffset * mr + ca;
7081
+ c = Math.cos(r);
7082
+ s = Math.sin(r);
7083
+ if (scaleX) {
7084
+ r = l * bone.getWorldScaleX();
7085
+ if (r > 0)
7086
+ this.scaleOffset += (dx * c + dy * s) * i / r;
7087
+ }
7088
+ } else {
7089
+ c = Math.cos(ca);
7090
+ s = Math.sin(ca);
7091
+ const r = l * bone.getWorldScaleX();
7092
+ if (r > 0)
7093
+ this.scaleOffset += ((this.cx - bone.worldX) * c + (this.cy - bone.worldY) * s) * i / r;
7094
+ }
7095
+ remaining = this.remaining;
7096
+ if (remaining >= step) {
7097
+ const m = this.massInverse * step, e = this.strength, w = this.wind, g = this.gravity;
7098
+ const d = Math.pow(this.damping, 60 * step);
7099
+ while (true) {
7100
+ remaining -= step;
7101
+ if (scaleX) {
7102
+ this.scaleVelocity += (w * c - g * s - this.scaleOffset * e) * m;
7103
+ this.scaleOffset += this.scaleVelocity * step;
7104
+ this.scaleVelocity *= d;
7105
+ }
7106
+ if (rotateOrShearX) {
7107
+ this.rotateVelocity += (-0.01 * l * (w * s + g * c) - this.rotateOffset * e) * m;
7108
+ this.rotateOffset += this.rotateVelocity * step;
7109
+ this.rotateVelocity *= d;
7110
+ if (remaining < step)
7111
+ break;
7112
+ const r = this.rotateOffset * mr + ca;
7113
+ c = Math.cos(r);
7114
+ s = Math.sin(r);
7115
+ } else if (remaining < step)
7116
+ break;
7117
+ }
7118
+ }
7119
+ }
7120
+ this.remaining = remaining;
7121
+ }
7122
+ this.cx = bone.worldX;
7123
+ this.cy = bone.worldY;
7124
+ break;
7125
+ case 3 /* pose */:
7126
+ if (x)
7127
+ bone.worldX += this.xOffset * mix * this.data.x;
7128
+ if (y)
7129
+ bone.worldY += this.yOffset * mix * this.data.y;
7130
+ }
7131
+ if (rotateOrShearX) {
7132
+ let o = this.rotateOffset * mix, s = 0, c = 0, a = 0;
7133
+ if (this.data.shearX > 0) {
7134
+ let r = 0;
7135
+ if (this.data.rotate > 0) {
7136
+ r = o * this.data.rotate;
7137
+ s = Math.sin(r);
7138
+ c = Math.cos(r);
7139
+ a = bone.b;
7140
+ bone.b = c * a - s * bone.d;
7141
+ bone.d = s * a + c * bone.d;
7142
+ }
7143
+ r += o * this.data.shearX;
7144
+ s = Math.sin(r);
7145
+ c = Math.cos(r);
7146
+ a = bone.a;
7147
+ bone.a = c * a - s * bone.c;
7148
+ bone.c = s * a + c * bone.c;
7149
+ } else {
7150
+ o *= this.data.rotate;
7151
+ s = Math.sin(o);
7152
+ c = Math.cos(o);
7153
+ a = bone.a;
7154
+ bone.a = c * a - s * bone.c;
7155
+ bone.c = s * a + c * bone.c;
7156
+ a = bone.b;
7157
+ bone.b = c * a - s * bone.d;
7158
+ bone.d = s * a + c * bone.d;
7159
+ }
7160
+ }
7161
+ if (scaleX) {
7162
+ const s = 1 + this.scaleOffset * mix * this.data.scaleX;
7163
+ bone.a *= s;
7164
+ bone.c *= s;
7165
+ }
7166
+ if (physics != 3 /* pose */) {
7167
+ this.tx = l * bone.a;
7168
+ this.ty = l * bone.c;
7169
+ }
7170
+ bone.updateAppliedTransform();
7171
+ }
7172
+ };
7173
+
6825
7174
  // spine-core/src/Slot.ts
6826
7175
  var Slot = class {
6827
7176
  /** The slot's setup pose data. */
@@ -6932,7 +7281,16 @@ var spine = (() => {
6932
7281
  isActive() {
6933
7282
  return this.active;
6934
7283
  }
6935
- update() {
7284
+ setToSetupPose() {
7285
+ const data = this.data;
7286
+ this.mixRotate = data.mixRotate;
7287
+ this.mixX = data.mixX;
7288
+ this.mixY = data.mixY;
7289
+ this.mixScaleX = data.mixScaleX;
7290
+ this.mixScaleY = data.mixScaleY;
7291
+ this.mixShearY = data.mixShearY;
7292
+ }
7293
+ update(physics) {
6936
7294
  if (this.mixRotate == 0 && this.mixX == 0 && this.mixY == 0 && this.mixScaleX == 0 && this.mixScaleY == 0 && this.mixShearY == 0)
6937
7295
  return;
6938
7296
  if (this.data.local) {
@@ -7072,7 +7430,7 @@ var spine = (() => {
7072
7430
  let rotation = bone.arotation;
7073
7431
  if (mixRotate != 0) {
7074
7432
  let r = target.arotation - rotation + this.data.offsetRotation;
7075
- r -= (16384 - (16384.499999999996 - r / 360 | 0)) * 360;
7433
+ r -= Math.ceil(r / 360 - 0.5) * 360;
7076
7434
  rotation += r * mixRotate;
7077
7435
  }
7078
7436
  let x = bone.ax, y = bone.ay;
@@ -7086,7 +7444,7 @@ var spine = (() => {
7086
7444
  let shearY = bone.ashearY;
7087
7445
  if (mixShearY != 0) {
7088
7446
  let r = target.ashearY - shearY + this.data.offsetShearY;
7089
- r -= (16384 - (16384.499999999996 - r / 360 | 0)) * 360;
7447
+ r -= Math.ceil(r / 360 - 0.5) * 360;
7090
7448
  shearY += r * mixShearY;
7091
7449
  }
7092
7450
  bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
@@ -7125,6 +7483,8 @@ var spine = (() => {
7125
7483
  transformConstraints;
7126
7484
  /** The skeleton's path constraints. */
7127
7485
  pathConstraints;
7486
+ /** The skeleton's physics constraints. */
7487
+ physicsConstraints;
7128
7488
  /** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link #updateCache()}. */
7129
7489
  _updateCache = new Array();
7130
7490
  /** The skeleton's current skin. May be null. */
@@ -7147,6 +7507,10 @@ var spine = (() => {
7147
7507
  x = 0;
7148
7508
  /** Sets the skeleton Y position, which is added to the root bone worldY position. */
7149
7509
  y = 0;
7510
+ /** Returns the skeleton's time. This is used for time-based manipulations, such as {@link PhysicsConstraint}.
7511
+ * <p>
7512
+ * See {@link #update(float)}. */
7513
+ time = 0;
7150
7514
  constructor(data) {
7151
7515
  if (!data)
7152
7516
  throw new Error("data cannot be null.");
@@ -7188,6 +7552,11 @@ var spine = (() => {
7188
7552
  let pathConstraintData = data.pathConstraints[i];
7189
7553
  this.pathConstraints.push(new PathConstraint(pathConstraintData, this));
7190
7554
  }
7555
+ this.physicsConstraints = new Array();
7556
+ for (let i = 0; i < data.physicsConstraints.length; i++) {
7557
+ let physicsConstraintData = data.physicsConstraints[i];
7558
+ this.physicsConstraints.push(new PhysicsConstraint(physicsConstraintData, this));
7559
+ }
7191
7560
  this.color = new Color(1, 1, 1, 1);
7192
7561
  this.updateCache();
7193
7562
  }
@@ -7216,8 +7585,9 @@ var spine = (() => {
7216
7585
  let ikConstraints = this.ikConstraints;
7217
7586
  let transformConstraints = this.transformConstraints;
7218
7587
  let pathConstraints = this.pathConstraints;
7219
- let ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;
7220
- let constraintCount = ikCount + transformCount + pathCount;
7588
+ let physicsConstraints = this.physicsConstraints;
7589
+ let ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length, physicsCount = this.physicsConstraints.length;
7590
+ let constraintCount = ikCount + transformCount + pathCount + physicsCount;
7221
7591
  outer:
7222
7592
  for (let i = 0; i < constraintCount; i++) {
7223
7593
  for (let ii = 0; ii < ikCount; ii++) {
@@ -7241,6 +7611,13 @@ var spine = (() => {
7241
7611
  continue outer;
7242
7612
  }
7243
7613
  }
7614
+ for (let ii = 0; ii < physicsCount; ii++) {
7615
+ const constraint = physicsConstraints[ii];
7616
+ if (constraint.data.order == i) {
7617
+ this.sortPhysicsConstraint(constraint);
7618
+ continue outer;
7619
+ }
7620
+ }
7244
7621
  }
7245
7622
  for (let i = 0, n = bones.length; i < n; i++)
7246
7623
  this.sortBone(bones[i]);
@@ -7339,6 +7716,16 @@ var spine = (() => {
7339
7716
  }
7340
7717
  }
7341
7718
  }
7719
+ sortPhysicsConstraint(constraint) {
7720
+ const bone = constraint.bone;
7721
+ constraint.active = bone.active && !constraint.data.skinRequired || this.skin != null && Utils.contains(this.skin.constraints, constraint.data, true);
7722
+ if (!constraint.active)
7723
+ return;
7724
+ this.sortBone(bone);
7725
+ this._updateCache.push(constraint);
7726
+ this.sortReset(bone.children);
7727
+ bone.sorted = true;
7728
+ }
7342
7729
  sortBone(bone) {
7343
7730
  if (!bone)
7344
7731
  return;
@@ -7364,7 +7751,9 @@ var spine = (() => {
7364
7751
  *
7365
7752
  * See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine
7366
7753
  * Runtimes Guide. */
7367
- updateWorldTransform() {
7754
+ updateWorldTransform(physics) {
7755
+ if (!physics)
7756
+ throw new Error("physics is undefined");
7368
7757
  let bones = this.bones;
7369
7758
  for (let i = 0, n = bones.length; i < n; i++) {
7370
7759
  let bone = bones[i];
@@ -7378,20 +7767,21 @@ var spine = (() => {
7378
7767
  }
7379
7768
  let updateCache = this._updateCache;
7380
7769
  for (let i = 0, n = updateCache.length; i < n; i++)
7381
- updateCache[i].update();
7770
+ updateCache[i].update(physics);
7382
7771
  }
7383
- updateWorldTransformWith(parent) {
7772
+ updateWorldTransformWith(physics, parent) {
7384
7773
  let rootBone = this.getRootBone();
7385
7774
  if (!rootBone)
7386
7775
  throw new Error("Root bone must not be null.");
7387
7776
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
7388
7777
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
7389
7778
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
7390
- let rotationY = rootBone.rotation + 90 + rootBone.shearY;
7391
- let la = MathUtils.cosDeg(rootBone.rotation + rootBone.shearX) * rootBone.scaleX;
7392
- let lb = MathUtils.cosDeg(rotationY) * rootBone.scaleY;
7393
- let lc = MathUtils.sinDeg(rootBone.rotation + rootBone.shearX) * rootBone.scaleX;
7394
- let ld = MathUtils.sinDeg(rotationY) * rootBone.scaleY;
7779
+ const rx = (rootBone.rotation + rootBone.shearX) * MathUtils.degRad;
7780
+ const ry = (rootBone.rotation + 90 + rootBone.shearY) * MathUtils.degRad;
7781
+ const la = Math.cos(rx) * rootBone.scaleX;
7782
+ const lb = Math.cos(ry) * rootBone.scaleY;
7783
+ const lc = Math.sin(rx) * rootBone.scaleX;
7784
+ const ld = Math.sin(ry) * rootBone.scaleY;
7395
7785
  rootBone.a = (pa * la + pb * lc) * this.scaleX;
7396
7786
  rootBone.b = (pa * lb + pb * ld) * this.scaleX;
7397
7787
  rootBone.c = (pc * la + pd * lc) * this.scaleY;
@@ -7400,7 +7790,7 @@ var spine = (() => {
7400
7790
  for (let i = 0, n = updateCache.length; i < n; i++) {
7401
7791
  let updatable = updateCache[i];
7402
7792
  if (updatable != rootBone)
7403
- updatable.update();
7793
+ updatable.update(physics);
7404
7794
  }
7405
7795
  }
7406
7796
  /** Sets the bones, constraints, and slots to their setup pose values. */
@@ -7410,39 +7800,16 @@ var spine = (() => {
7410
7800
  }
7411
7801
  /** Sets the bones and constraints to their setup pose values. */
7412
7802
  setBonesToSetupPose() {
7413
- let bones = this.bones;
7414
- for (let i = 0, n = bones.length; i < n; i++)
7415
- bones[i].setToSetupPose();
7416
- let ikConstraints = this.ikConstraints;
7417
- for (let i = 0, n = ikConstraints.length; i < n; i++) {
7418
- let constraint = ikConstraints[i];
7419
- constraint.mix = constraint.data.mix;
7420
- constraint.softness = constraint.data.softness;
7421
- constraint.bendDirection = constraint.data.bendDirection;
7422
- constraint.compress = constraint.data.compress;
7423
- constraint.stretch = constraint.data.stretch;
7424
- }
7425
- let transformConstraints = this.transformConstraints;
7426
- for (let i = 0, n = transformConstraints.length; i < n; i++) {
7427
- let constraint = transformConstraints[i];
7428
- let data = constraint.data;
7429
- constraint.mixRotate = data.mixRotate;
7430
- constraint.mixX = data.mixX;
7431
- constraint.mixY = data.mixY;
7432
- constraint.mixScaleX = data.mixScaleX;
7433
- constraint.mixScaleY = data.mixScaleY;
7434
- constraint.mixShearY = data.mixShearY;
7435
- }
7436
- let pathConstraints = this.pathConstraints;
7437
- for (let i = 0, n = pathConstraints.length; i < n; i++) {
7438
- let constraint = pathConstraints[i];
7439
- let data = constraint.data;
7440
- constraint.position = data.position;
7441
- constraint.spacing = data.spacing;
7442
- constraint.mixRotate = data.mixRotate;
7443
- constraint.mixX = data.mixX;
7444
- constraint.mixY = data.mixY;
7445
- }
7803
+ for (const bone of this.bones)
7804
+ bone.setToSetupPose();
7805
+ for (const constraint of this.ikConstraints)
7806
+ constraint.setToSetupPose();
7807
+ for (const constraint of this.transformConstraints)
7808
+ constraint.setToSetupPose();
7809
+ for (const constraint of this.pathConstraints)
7810
+ constraint.setToSetupPose();
7811
+ for (const constraint of this.physicsConstraints)
7812
+ constraint.setToSetupPose();
7446
7813
  }
7447
7814
  /** Sets the slots and draw order to their setup pose values. */
7448
7815
  setSlotsToSetupPose() {
@@ -7580,13 +7947,7 @@ var spine = (() => {
7580
7947
  findIkConstraint(constraintName) {
7581
7948
  if (!constraintName)
7582
7949
  throw new Error("constraintName cannot be null.");
7583
- let ikConstraints = this.ikConstraints;
7584
- for (let i = 0, n = ikConstraints.length; i < n; i++) {
7585
- let ikConstraint = ikConstraints[i];
7586
- if (ikConstraint.data.name == constraintName)
7587
- return ikConstraint;
7588
- }
7589
- return null;
7950
+ return this.ikConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7590
7951
  }
7591
7952
  /** Finds a transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of
7592
7953
  * this method than to call it repeatedly.
@@ -7594,13 +7955,7 @@ var spine = (() => {
7594
7955
  findTransformConstraint(constraintName) {
7595
7956
  if (!constraintName)
7596
7957
  throw new Error("constraintName cannot be null.");
7597
- let transformConstraints = this.transformConstraints;
7598
- for (let i = 0, n = transformConstraints.length; i < n; i++) {
7599
- let constraint = transformConstraints[i];
7600
- if (constraint.data.name == constraintName)
7601
- return constraint;
7602
- }
7603
- return null;
7958
+ return this.transformConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7604
7959
  }
7605
7960
  /** Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method
7606
7961
  * than to call it repeatedly.
@@ -7608,13 +7963,14 @@ var spine = (() => {
7608
7963
  findPathConstraint(constraintName) {
7609
7964
  if (!constraintName)
7610
7965
  throw new Error("constraintName cannot be null.");
7611
- let pathConstraints = this.pathConstraints;
7612
- for (let i = 0, n = pathConstraints.length; i < n; i++) {
7613
- let constraint = pathConstraints[i];
7614
- if (constraint.data.name == constraintName)
7615
- return constraint;
7616
- }
7617
- return null;
7966
+ return this.pathConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7967
+ }
7968
+ /** Finds a physics constraint by comparing each physics constraint's name. It is more efficient to cache the results of this
7969
+ * method than to call it repeatedly. */
7970
+ findPhysicsConstraint(constraintName) {
7971
+ if (constraintName == null)
7972
+ throw new Error("constraintName cannot be null.");
7973
+ return this.physicsConstraints.find((constraint) => constraint.data.name == constraintName) ?? null;
7618
7974
  }
7619
7975
  /** 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 }`.
7620
7976
  * Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */
@@ -7665,9 +8021,20 @@ var spine = (() => {
7665
8021
  offset.set(minX, minY);
7666
8022
  size.set(maxX - minX, maxY - minY);
7667
8023
  }
8024
+ /** Increments the skeleton's {@link #time}. */
8025
+ update(delta) {
8026
+ this.time += delta;
8027
+ }
7668
8028
  };
7669
- var Skeleton = _Skeleton;
7670
- __publicField(Skeleton, "yDown", false);
8029
+ var Skeleton2 = _Skeleton;
8030
+ __publicField(Skeleton2, "yDown", false);
8031
+ var Physics = /* @__PURE__ */ ((Physics2) => {
8032
+ Physics2[Physics2["none"] = 0] = "none";
8033
+ Physics2[Physics2["reset"] = 1] = "reset";
8034
+ Physics2[Physics2["update"] = 2] = "update";
8035
+ Physics2[Physics2["pose"] = 3] = "pose";
8036
+ return Physics2;
8037
+ })(Physics || {});
7671
8038
 
7672
8039
  // spine-core/src/SkeletonData.ts
7673
8040
  var SkeletonData = class {
@@ -7695,6 +8062,8 @@ var spine = (() => {
7695
8062
  transformConstraints = new Array();
7696
8063
  /** The skeleton's path constraints. */
7697
8064
  pathConstraints = new Array();
8065
+ /** The skeleton's physics constraints. */
8066
+ physicsConstraints = new Array();
7698
8067
  /** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */
7699
8068
  x = 0;
7700
8069
  /** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */
@@ -7790,9 +8159,9 @@ var spine = (() => {
7790
8159
  findIkConstraint(constraintName) {
7791
8160
  if (!constraintName)
7792
8161
  throw new Error("constraintName cannot be null.");
7793
- let ikConstraints = this.ikConstraints;
8162
+ const ikConstraints = this.ikConstraints;
7794
8163
  for (let i = 0, n = ikConstraints.length; i < n; i++) {
7795
- let constraint = ikConstraints[i];
8164
+ const constraint = ikConstraints[i];
7796
8165
  if (constraint.name == constraintName)
7797
8166
  return constraint;
7798
8167
  }
@@ -7804,9 +8173,9 @@ var spine = (() => {
7804
8173
  findTransformConstraint(constraintName) {
7805
8174
  if (!constraintName)
7806
8175
  throw new Error("constraintName cannot be null.");
7807
- let transformConstraints = this.transformConstraints;
8176
+ const transformConstraints = this.transformConstraints;
7808
8177
  for (let i = 0, n = transformConstraints.length; i < n; i++) {
7809
- let constraint = transformConstraints[i];
8178
+ const constraint = transformConstraints[i];
7810
8179
  if (constraint.name == constraintName)
7811
8180
  return constraint;
7812
8181
  }
@@ -7818,9 +8187,23 @@ var spine = (() => {
7818
8187
  findPathConstraint(constraintName) {
7819
8188
  if (!constraintName)
7820
8189
  throw new Error("constraintName cannot be null.");
7821
- let pathConstraints = this.pathConstraints;
8190
+ const pathConstraints = this.pathConstraints;
7822
8191
  for (let i = 0, n = pathConstraints.length; i < n; i++) {
7823
- let constraint = pathConstraints[i];
8192
+ const constraint = pathConstraints[i];
8193
+ if (constraint.name == constraintName)
8194
+ return constraint;
8195
+ }
8196
+ return null;
8197
+ }
8198
+ /** Finds a physics constraint by comparing each physics constraint's name. It is more efficient to cache the results of this method
8199
+ * than to call it multiple times.
8200
+ * @return May be null. */
8201
+ findPhysicsConstraint(constraintName) {
8202
+ if (!constraintName)
8203
+ throw new Error("constraintName cannot be null.");
8204
+ const physicsConstraints = this.physicsConstraints;
8205
+ for (let i = 0, n = physicsConstraints.length; i < n; i++) {
8206
+ const constraint = physicsConstraints[i];
7824
8207
  if (constraint.name == constraintName)
7825
8208
  return constraint;
7826
8209
  }
@@ -7842,6 +8225,9 @@ var spine = (() => {
7842
8225
  attachments = new Array();
7843
8226
  bones = Array();
7844
8227
  constraints = new Array();
8228
+ /** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */
8229
+ color = new Color(0.99607843, 0.61960787, 0.30980393, 1);
8230
+ // fe9e4fff
7845
8231
  constructor(name) {
7846
8232
  if (!name)
7847
8233
  throw new Error("name cannot be null.");
@@ -8015,6 +8401,8 @@ var spine = (() => {
8015
8401
  attachmentName = null;
8016
8402
  /** The blend mode for drawing the slot's attachment. */
8017
8403
  blendMode = BlendMode.Normal;
8404
+ /** False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. */
8405
+ visible = true;
8018
8406
  constructor(index, name, boneData) {
8019
8407
  if (index < 0)
8020
8408
  throw new Error("index must be >= 0.");