@esotericsoftware/spine-canvas 4.3.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -301,6 +301,8 @@ var spine = (() => {
301
301
  }
302
302
  };
303
303
  var MathUtils = class _MathUtils {
304
+ static epsilon = 1e-5;
305
+ static epsilon2 = _MathUtils.epsilon * _MathUtils.epsilon;
304
306
  // biome-ignore lint/suspicious/noApproximativeNumericConstant: reference runtime
305
307
  static PI = 3.1415927;
306
308
  static PI2 = _MathUtils.PI * 2;
@@ -6098,73 +6100,70 @@ ${error}` : ""}`);
6098
6100
  return;
6099
6101
  }
6100
6102
  case 1 /* OnlyTranslation */: {
6103
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
6101
6104
  const rx = (rotation + shearX) * MathUtils.degRad;
6102
6105
  const ry = (rotation + 90 + shearY) * MathUtils.degRad;
6103
- this.a = Math.cos(rx) * scaleX;
6104
- this.b = Math.cos(ry) * scaleY;
6105
- this.c = Math.sin(rx) * scaleX;
6106
- this.d = Math.sin(ry) * scaleY;
6106
+ this.a = Math.cos(rx) * scaleX * sx;
6107
+ this.b = Math.cos(ry) * scaleY * sx;
6108
+ this.c = Math.sin(rx) * scaleX * sy;
6109
+ this.d = Math.sin(ry) * scaleY * sy;
6107
6110
  break;
6108
6111
  }
6109
6112
  case 2 /* NoRotationOrReflection */: {
6110
- const sx = 1 / skeleton.scaleX, sy = 1 / skeleton.scaleY;
6111
- pa *= sx;
6112
- pc *= sy;
6113
+ const sx = skeleton.scaleX, sy = skeleton.scaleY, sxi = 1 / sx, syi = 1 / sy;
6114
+ pa *= sxi;
6115
+ pc *= syi;
6113
6116
  let s = pa * pa + pc * pc;
6114
- let prx = 0;
6115
- if (s > 1e-4) {
6116
- s = Math.abs(pa * pd * sy - pb * sx * pc) / s;
6117
+ let r = 0;
6118
+ if (s > MathUtils.epsilon2) {
6119
+ s = Math.abs(pa * pd * syi - pb * sxi * pc) / s;
6117
6120
  pb = pc * s;
6118
6121
  pd = pa * s;
6119
- prx = MathUtils.atan2Deg(pc, pa);
6122
+ r = rotation - MathUtils.atan2Deg(pc, pa);
6120
6123
  } else {
6121
6124
  pa = 0;
6122
6125
  pc = 0;
6123
- prx = 90 - MathUtils.atan2Deg(pd, pb);
6126
+ r = rotation - 90 + MathUtils.atan2Deg(pd, pb);
6124
6127
  }
6125
- const rx = (rotation + shearX - prx) * MathUtils.degRad;
6126
- const ry = (rotation + shearY - prx + 90) * MathUtils.degRad;
6128
+ const rx = (r + shearX) * MathUtils.degRad;
6129
+ const ry = (r + shearY + 90) * MathUtils.degRad;
6127
6130
  const la = Math.cos(rx) * scaleX;
6128
6131
  const lb = Math.cos(ry) * scaleY;
6129
6132
  const lc = Math.sin(rx) * scaleX;
6130
6133
  const ld = Math.sin(ry) * scaleY;
6131
- this.a = pa * la - pb * lc;
6132
- this.b = pa * lb - pb * ld;
6133
- this.c = pc * la + pd * lc;
6134
- this.d = pc * lb + pd * ld;
6134
+ this.a = (pa * la - pb * lc) * sx;
6135
+ this.b = (pa * lb - pb * ld) * sx;
6136
+ this.c = (pc * la + pd * lc) * sy;
6137
+ this.d = (pc * lb + pd * ld) * sy;
6135
6138
  break;
6136
6139
  }
6137
6140
  case 3 /* NoScale */:
6138
6141
  case 4 /* NoScaleOrReflection */: {
6139
- let r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6140
- let za = (pa * cos + pb * sin) / skeleton.scaleX;
6141
- let zc = (pc * cos + pd * sin) / skeleton.scaleY;
6142
- let s = Math.sqrt(za * za + zc * zc);
6143
- if (s > 1e-5) s = 1 / s;
6142
+ const sx = skeleton.scaleX, sy = skeleton.scaleY, sxi = 1 / sx, syi = 1 / sy;
6143
+ const r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6144
+ let za = (pa * cos + pb * sin) * sxi;
6145
+ let zc = (pc * cos + pd * sin) * syi;
6146
+ const s = 1 / Math.sqrt(za * za + zc * zc);
6144
6147
  za *= s;
6145
6148
  zc *= s;
6146
- s = Math.sqrt(za * za + zc * zc);
6147
- if (this.inherit === 3 /* NoScale */ && pa * pd - pb * pc < 0 !== (skeleton.scaleX < 0 !== skeleton.scaleY < 0)) s = -s;
6148
- r = Math.PI / 2 + Math.atan2(zc, za);
6149
- const zb = Math.cos(r) * s;
6150
- const zd = Math.sin(r) * s;
6149
+ let zb = -zc, zd = za;
6150
+ if (this.inherit === 3 /* NoScale */ && pa * pd - pb * pc < 0 !== (sx < 0 !== sy < 0)) {
6151
+ zb = -zb;
6152
+ zd = -zd;
6153
+ }
6151
6154
  const rx = shearX * MathUtils.degRad;
6152
6155
  const ry = (90 + shearY) * MathUtils.degRad;
6153
6156
  const la = Math.cos(rx) * scaleX;
6154
6157
  const lb = Math.cos(ry) * scaleY;
6155
6158
  const lc = Math.sin(rx) * scaleX;
6156
6159
  const ld = Math.sin(ry) * scaleY;
6157
- this.a = za * la + zb * lc;
6158
- this.b = za * lb + zb * ld;
6159
- this.c = zc * la + zd * lc;
6160
- this.d = zc * lb + zd * ld;
6160
+ this.a = (za * la + zb * lc) * sx;
6161
+ this.b = (za * lb + zb * ld) * sx;
6162
+ this.c = (zc * la + zd * lc) * sy;
6163
+ this.d = (zc * lb + zd * ld) * sy;
6161
6164
  break;
6162
6165
  }
6163
6166
  }
6164
- this.a *= skeleton.scaleX;
6165
- this.b *= skeleton.scaleX;
6166
- this.c *= skeleton.scaleY;
6167
- this.d *= skeleton.scaleY;
6168
6167
  }
6169
6168
  /** Computes the local transform values from the world transform.
6170
6169
  *
@@ -6177,79 +6176,118 @@ ${error}` : ""}`);
6177
6176
  updateLocalTransform(skeleton) {
6178
6177
  this.local = 0;
6179
6178
  this.world = skeleton._update;
6179
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
6180
6180
  if (!this.bone.parent) {
6181
- this.x = this.worldX - skeleton.x;
6182
- this.y = this.worldY - skeleton.y;
6183
- const a = this.a, b = this.b, c = this.c, d = this.d;
6184
- this.rotation = MathUtils.atan2Deg(c, a);
6185
- this.scaleX = Math.sqrt(a * a + c * c);
6186
- this.scaleY = Math.sqrt(b * b + d * d);
6187
- this.shearX = 0;
6188
- this.shearY = MathUtils.atan2Deg(a * b + c * d, a * d - b * c);
6181
+ const sxi = 1 / sx, syi = 1 / sy;
6182
+ this.x = (this.worldX - skeleton.x) * sxi;
6183
+ this.y = (this.worldY - skeleton.y) * syi;
6184
+ this.set5(this.a * sxi, this.b * sxi, this.c * syi, this.d * syi, 0);
6189
6185
  return;
6190
6186
  }
6191
6187
  const parent = this.bone.parent.appliedPose;
6192
6188
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
6193
- let pid = 1 / (pa * pd - pb * pc);
6194
- let ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
6189
+ const pad = pa * pd - pb * pc, pid = 1 / (pa * pd - pb * pc);
6190
+ const ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
6195
6191
  const dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;
6196
6192
  this.x = dx * ia - dy * ib;
6197
6193
  this.y = dy * id - dx * ic;
6198
- let ra, rb, rc, rd;
6199
- if (this.inherit === 1 /* OnlyTranslation */) {
6200
- ra = this.a;
6201
- rb = this.b;
6202
- rc = this.c;
6203
- rd = this.d;
6194
+ switch (this.inherit) {
6195
+ case 0 /* Normal */:
6196
+ this.set5(ia * this.a - ib * this.c, ia * this.b - ib * this.d, id * this.c - ic * this.a, id * this.d - ic * this.b, 0);
6197
+ break;
6198
+ case 1 /* OnlyTranslation */: {
6199
+ const sxi = 1 / sx, syi = 1 / sy;
6200
+ this.set5(this.a * sxi, this.b * sxi, this.c * syi, this.d * syi, 0);
6201
+ break;
6202
+ }
6203
+ case 2 /* NoRotationOrReflection */: {
6204
+ const sxi = 1 / sx, syi = 1 / sy;
6205
+ pa *= sxi;
6206
+ pc *= syi;
6207
+ const wa = this.a * sxi, wb = this.b * sxi, wc = this.c * syi, wd = this.d * syi;
6208
+ const s = 1 / (pa * pa + pc * pc), det = 1 / Math.abs(pad * sxi * syi);
6209
+ this.set5(
6210
+ (pa * wa + pc * wc) * s,
6211
+ (pa * wb + pc * wd) * s,
6212
+ (pa * wc - pc * wa) * det,
6213
+ (pa * wd - pc * wb) * det,
6214
+ MathUtils.atan2Deg(pc, pa)
6215
+ );
6216
+ break;
6217
+ }
6218
+ case 3 /* NoScale */:
6219
+ case 4 /* NoScaleOrReflection */: {
6220
+ const sxi = 1 / sx, syi = 1 / sy;
6221
+ const wa = this.a * sxi, wb = this.b * sxi, wc = this.c * syi, wd = this.d * syi;
6222
+ let tx = pd * this.a - pb * this.c, ty = pa * this.c - pc * this.a;
6223
+ if (pad < 0) {
6224
+ tx = -tx;
6225
+ ty = -ty;
6226
+ }
6227
+ let r = MathUtils.atan2Deg(ty, tx);
6228
+ this.rotation = r;
6229
+ r *= MathUtils.degRad;
6230
+ const cos = Math.cos(r), sin = Math.sin(r);
6231
+ let za = (pa * cos + pb * sin) * sxi;
6232
+ let zc = (pc * cos + pd * sin) * syi;
6233
+ const s = 1 / Math.sqrt(za * za + zc * zc);
6234
+ za *= s;
6235
+ zc *= s;
6236
+ const si = this.inherit === 3 /* NoScale */ && pad < 0 !== (sx < 0 !== sy < 0) ? -1 : 1;
6237
+ this.set4(za * wa + zc * wc, za * wb + zc * wd, (za * wc - zc * wa) * si, (za * wd - zc * wb) * si);
6238
+ }
6239
+ }
6240
+ }
6241
+ set4(ra, rb, rc, rd) {
6242
+ const x = ra * ra + rc * rc, y = rb * rb + rd * rd;
6243
+ if (x > MathUtils.epsilon2) {
6244
+ this.shearX = MathUtils.atan2Deg(rc, ra);
6245
+ this.scaleX = Math.sqrt(x);
6204
6246
  } else {
6205
- switch (this.inherit) {
6206
- case 2 /* NoRotationOrReflection */: {
6207
- const s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
6208
- pb = -pc * skeleton.scaleX * s / skeleton.scaleY;
6209
- pd = pa * skeleton.scaleY * s / skeleton.scaleX;
6210
- pid = 1 / (pa * pd - pb * pc);
6211
- ia = pd * pid;
6212
- ib = pb * pid;
6213
- break;
6214
- }
6215
- case 3 /* NoScale */:
6216
- case 4 /* NoScaleOrReflection */: {
6217
- let r = this.rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6218
- pa = (pa * cos + pb * sin) / skeleton.scaleX;
6219
- pc = (pc * cos + pd * sin) / skeleton.scaleY;
6220
- let s = Math.sqrt(pa * pa + pc * pc);
6221
- if (s > 1e-5) s = 1 / s;
6222
- pa *= s;
6223
- pc *= s;
6224
- s = Math.sqrt(pa * pa + pc * pc);
6225
- if (this.inherit === 3 /* NoScale */ && pid < 0 !== (skeleton.scaleX < 0 !== skeleton.scaleY < 0)) s = -s;
6226
- r = MathUtils.PI / 2 + Math.atan2(pc, pa);
6227
- pb = Math.cos(r) * s;
6228
- pd = Math.sin(r) * s;
6229
- pid = 1 / (pa * pd - pb * pc);
6230
- ia = pd * pid;
6231
- ib = pb * pid;
6232
- ic = pc * pid;
6233
- id = pa * pid;
6234
- }
6235
- }
6236
- ra = ia * this.a - ib * this.c;
6237
- rb = ia * this.b - ib * this.d;
6238
- rc = id * this.c - ic * this.a;
6239
- rd = id * this.d - ic * this.b;
6247
+ this.shearX = 0;
6248
+ this.scaleX = 0;
6240
6249
  }
6250
+ this.scaleY = Math.sqrt(y);
6251
+ if (y > MathUtils.epsilon2) {
6252
+ this.shearY = MathUtils.atan2Deg(rd, rb);
6253
+ if (ra * rd - rb * rc < 0) {
6254
+ this.scaleY = -this.scaleY;
6255
+ this.shearY += 90;
6256
+ } else
6257
+ this.shearY -= 90;
6258
+ if (this.shearY > 180)
6259
+ this.shearY -= 360;
6260
+ else if (this.shearY <= -180)
6261
+ this.shearY += 360;
6262
+ } else
6263
+ this.shearY = 0;
6264
+ }
6265
+ set5(ra, rb, rc, rd, ro) {
6241
6266
  this.shearX = 0;
6242
- this.scaleX = Math.sqrt(ra * ra + rc * rc);
6243
- if (this.scaleX > 1e-4) {
6244
- const det = ra * rd - rb * rc;
6245
- this.scaleY = det / this.scaleX;
6246
- this.shearY = -MathUtils.atan2Deg(ra * rb + rc * rd, det);
6247
- this.rotation = MathUtils.atan2Deg(rc, ra);
6267
+ const x = ra * ra + rc * rc, y = rb * rb + rd * rd;
6268
+ if (x > MathUtils.epsilon2) {
6269
+ const r = MathUtils.atan2Deg(rc, ra);
6270
+ this.rotation = r + ro;
6271
+ this.scaleX = Math.sqrt(x);
6272
+ this.scaleY = Math.sqrt(y);
6273
+ if (y > MathUtils.epsilon2) {
6274
+ this.shearY = MathUtils.atan2Deg(rd, rb);
6275
+ if (ra * rd - rb * rc < 0) {
6276
+ this.scaleY = -this.scaleY;
6277
+ this.shearY += 90 - r;
6278
+ } else
6279
+ this.shearY -= 90 + r;
6280
+ if (this.shearY > 180)
6281
+ this.shearY -= 360;
6282
+ else if (this.shearY <= -180)
6283
+ this.shearY += 360;
6284
+ } else
6285
+ this.shearY = 0;
6248
6286
  } else {
6249
6287
  this.scaleX = 0;
6250
- this.scaleY = Math.sqrt(rb * rb + rd * rd);
6288
+ this.scaleY = Math.sqrt(y);
6251
6289
  this.shearY = 0;
6252
- this.rotation = 90 - MathUtils.atan2Deg(rd, rb);
6290
+ this.rotation = y > MathUtils.epsilon2 ? MathUtils.atan2Deg(rd, rb) - 90 + ro : ro;
6253
6291
  }
6254
6292
  }
6255
6293
  /** If the world transform has been modified by constraints and the local transform no longer matches,
@@ -6494,6 +6532,12 @@ ${error}` : ""}`);
6494
6532
  super(name, setup);
6495
6533
  }
6496
6534
  };
6535
+ var ScaleYMode = /* @__PURE__ */ ((ScaleYMode2) => {
6536
+ ScaleYMode2[ScaleYMode2["None"] = 0] = "None";
6537
+ ScaleYMode2[ScaleYMode2["Uniform"] = 1] = "Uniform";
6538
+ ScaleYMode2[ScaleYMode2["Volume"] = 2] = "Volume";
6539
+ return ScaleYMode2;
6540
+ })(ScaleYMode || {});
6497
6541
 
6498
6542
  // spine-core/src/Event.ts
6499
6543
  var Event = class {
@@ -6565,43 +6609,6 @@ ${error}` : ""}`);
6565
6609
  }
6566
6610
  };
6567
6611
 
6568
- // spine-core/src/IkConstraintData.ts
6569
- var IkConstraintData = class extends ConstraintData {
6570
- /** The bones that are constrained by this IK constraint. */
6571
- bones = [];
6572
- _target = null;
6573
- /** The bone that is the IK target. */
6574
- set target(boneData) {
6575
- this._target = boneData;
6576
- }
6577
- get target() {
6578
- if (!this._target) throw new Error("target cannot be null.");
6579
- return this._target;
6580
- }
6581
- /** Determines how the {@link BonePose.scaleY} changes when {@link IkConstraintPose.compress} or
6582
- * {@link IkConstraintPose.stretch} set {@link BonePose.scaleX}. */
6583
- _scaleYMode = 0 /* None */;
6584
- set scaleYMode(scaleYMode) {
6585
- this._scaleYMode = scaleYMode;
6586
- }
6587
- get scaleYMode() {
6588
- if (this._scaleYMode == null) throw new Error("scaleYMode cannot be null.");
6589
- return this._scaleYMode;
6590
- }
6591
- constructor(name) {
6592
- super(name, new IkConstraintPose());
6593
- }
6594
- create(skeleton) {
6595
- return new IkConstraint(this, skeleton);
6596
- }
6597
- };
6598
- var ScaleYMode = /* @__PURE__ */ ((ScaleYMode2) => {
6599
- ScaleYMode2[ScaleYMode2["None"] = 0] = "None";
6600
- ScaleYMode2[ScaleYMode2["Uniform"] = 1] = "Uniform";
6601
- ScaleYMode2[ScaleYMode2["Volume"] = 2] = "Volume";
6602
- return ScaleYMode2;
6603
- })(ScaleYMode || {});
6604
-
6605
6612
  // spine-core/src/IkConstraint.ts
6606
6613
  var IkConstraint = class _IkConstraint extends Constraint {
6607
6614
  /** The 1 or 2 bones that will be modified by this IK constraint. */
@@ -6688,7 +6695,7 @@ ${error}` : ""}`);
6688
6695
  break;
6689
6696
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: reference runtime
6690
6697
  case 2 /* NoRotationOrReflection */: {
6691
- const s = Math.abs(pa * pd - pb * pc) / Math.max(1e-4, pa * pa + pc * pc);
6698
+ const s = Math.abs(pa * pd - pb * pc) / Math.max(MathUtils.epsilon, pa * pa + pc * pc);
6692
6699
  const sa = pa / skeleton.scaleX;
6693
6700
  const sc = pc / skeleton.scaleY;
6694
6701
  pb = -sc * s * skeleton.scaleX;
@@ -6699,7 +6706,7 @@ ${error}` : ""}`);
6699
6706
  default: {
6700
6707
  const x = targetX - p.worldX, y = targetY - p.worldY;
6701
6708
  const d = pa * pd - pb * pc;
6702
- if (Math.abs(d) <= 1e-4) {
6709
+ if (Math.abs(d) <= MathUtils.epsilon) {
6703
6710
  tx = 0;
6704
6711
  ty = 0;
6705
6712
  } else {
@@ -6712,7 +6719,7 @@ ${error}` : ""}`);
6712
6719
  if (bone.scaleX < 0) rotationIK += 180;
6713
6720
  if (rotationIK > 180)
6714
6721
  rotationIK -= 360;
6715
- else if (rotationIK < -180)
6722
+ else if (rotationIK <= -180)
6716
6723
  rotationIK += 360;
6717
6724
  bone.rotation += rotationIK * mix;
6718
6725
  if (compress || stretch) {
@@ -6723,7 +6730,7 @@ ${error}` : ""}`);
6723
6730
  ty = targetY - bone.worldY;
6724
6731
  }
6725
6732
  const b = bone.bone.data.length * bone.scaleX;
6726
- if (b > 1e-4) {
6733
+ if (b > MathUtils.epsilon) {
6727
6734
  const dd = tx * tx + ty * ty;
6728
6735
  if (compress && dd < b * b || stretch && dd > b * b) {
6729
6736
  const s = (Math.sqrt(dd) / b - 1) * mix + 1;
@@ -6733,7 +6740,7 @@ ${error}` : ""}`);
6733
6740
  bone.scaleY *= s;
6734
6741
  break;
6735
6742
  case 2 /* Volume */:
6736
- bone.scaleY /= s;
6743
+ bone.scaleY /= s < 0.7 ? 0.25 + 0.642857 * s : s;
6737
6744
  }
6738
6745
  }
6739
6746
  }
@@ -6765,7 +6772,7 @@ ${error}` : ""}`);
6765
6772
  } else
6766
6773
  os2 = 0;
6767
6774
  let cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;
6768
- const u = Math.abs(psx - psy) <= 1e-4;
6775
+ const u = Math.abs(psx - psy) <= MathUtils.epsilon;
6769
6776
  if (!u || stretch) {
6770
6777
  child.y = 0;
6771
6778
  cwx = a * child.x + parent.worldX;
@@ -6780,10 +6787,10 @@ ${error}` : ""}`);
6780
6787
  c = pp.c;
6781
6788
  d = pp.d;
6782
6789
  let id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
6783
- id = Math.abs(id) <= 1e-4 ? 0 : 1 / id;
6790
+ id = Math.abs(id) <= MathUtils.epsilon ? 0 : 1 / id;
6784
6791
  const dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
6785
6792
  let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.bone.data.length * csx, a1, a2;
6786
- if (l1 < 1e-4) {
6793
+ if (l1 < MathUtils.epsilon) {
6787
6794
  _IkConstraint.apply(skeleton, parent, targetX, targetY, false, stretch, 0 /* None */, mix);
6788
6795
  child.rotation = 0;
6789
6796
  return;
@@ -6821,7 +6828,7 @@ ${error}` : ""}`);
6821
6828
  parent.scaleY *= a;
6822
6829
  break;
6823
6830
  case 2 /* Volume */:
6824
- parent.scaleY /= a;
6831
+ parent.scaleY /= a < 0.7 ? 0.25 + 0.642857 * a : a;
6825
6832
  }
6826
6833
  }
6827
6834
  } else
@@ -6883,18 +6890,49 @@ ${error}` : ""}`);
6883
6890
  a1 = (a1 - os) * MathUtils.radDeg + os1 - parent.rotation;
6884
6891
  if (a1 > 180)
6885
6892
  a1 -= 360;
6886
- else if (a1 < -180)
6893
+ else if (a1 <= -180)
6887
6894
  a1 += 360;
6888
6895
  parent.rotation += a1 * mix;
6889
6896
  a2 = ((a2 + os) * MathUtils.radDeg - child.shearX) * s2 + os2 - child.rotation;
6890
6897
  if (a2 > 180)
6891
6898
  a2 -= 360;
6892
- else if (a2 < -180)
6899
+ else if (a2 <= -180)
6893
6900
  a2 += 360;
6894
6901
  child.rotation += a2 * mix;
6895
6902
  }
6896
6903
  };
6897
6904
 
6905
+ // spine-core/src/IkConstraintData.ts
6906
+ var IkConstraintData = class extends ConstraintData {
6907
+ /** The bones that are constrained by this IK constraint. */
6908
+ bones = [];
6909
+ _target = null;
6910
+ /** The bone that is the IK target. */
6911
+ set target(boneData) {
6912
+ this._target = boneData;
6913
+ }
6914
+ get target() {
6915
+ if (!this._target) throw new Error("target cannot be null.");
6916
+ return this._target;
6917
+ }
6918
+ /** Determines how the {@link BonePose.scaleY} changes when {@link IkConstraintPose.compress} or
6919
+ * {@link IkConstraintPose.stretch} set {@link BonePose.scaleX}. */
6920
+ _scaleYMode = 0 /* None */;
6921
+ set scaleYMode(scaleYMode) {
6922
+ this._scaleYMode = scaleYMode;
6923
+ }
6924
+ get scaleYMode() {
6925
+ if (this._scaleYMode == null) throw new Error("scaleYMode cannot be null.");
6926
+ return this._scaleYMode;
6927
+ }
6928
+ constructor(name) {
6929
+ super(name, new IkConstraintPose());
6930
+ }
6931
+ create(skeleton) {
6932
+ return new IkConstraint(this, skeleton);
6933
+ }
6934
+ };
6935
+
6898
6936
  // spine-core/src/PathConstraintPose.ts
6899
6937
  var PathConstraintPose = class {
6900
6938
  /** The position along the path. */
@@ -6968,7 +7006,6 @@ ${error}` : ""}`);
6968
7006
  static NONE = -1;
6969
7007
  static BEFORE = -2;
6970
7008
  static AFTER = -3;
6971
- static epsilon = 1e-5;
6972
7009
  /** The path constraint's setup pose data. */
6973
7010
  data;
6974
7011
  /** The bones that will be modified by this path constraint. */
@@ -7024,7 +7061,7 @@ ${error}` : ""}`);
7024
7061
  for (let i = 0, n = spacesCount - 1; i < n; ) {
7025
7062
  const bone = bones[i];
7026
7063
  const setupLength = bone.bone.data.length;
7027
- if (setupLength < _PathConstraint.epsilon) {
7064
+ if (setupLength < MathUtils.epsilon) {
7028
7065
  if (scale) lengths[i] = 0;
7029
7066
  spaces[++i] = spacing;
7030
7067
  } else {
@@ -7047,7 +7084,7 @@ ${error}` : ""}`);
7047
7084
  for (let i = 0, n = spacesCount - 1; i < n; ) {
7048
7085
  const bone = bones[i];
7049
7086
  const setupLength = bone.bone.data.length;
7050
- if (setupLength < _PathConstraint.epsilon) {
7087
+ if (setupLength < MathUtils.epsilon) {
7051
7088
  if (scale) lengths[i] = 0;
7052
7089
  spaces[++i] = spacing;
7053
7090
  } else {
@@ -8188,9 +8225,20 @@ ${error}` : ""}`);
8188
8225
  }
8189
8226
  }
8190
8227
  if (scaleX) {
8191
- const s = 1 + (this.scaleOffset - this.scaleLag * z) * mix * this.data.scaleX;
8228
+ let s = 1 + (this.scaleOffset - this.scaleLag * z) * mix * this.data.scaleX;
8192
8229
  bone.a *= s;
8193
8230
  bone.c *= s;
8231
+ switch (this.data.scaleYMode) {
8232
+ case 1 /* Uniform */:
8233
+ bone.b *= s;
8234
+ bone.d *= s;
8235
+ break;
8236
+ case 2 /* Volume */:
8237
+ s = Math.abs(s);
8238
+ s = s >= 0.7 ? 1 / s : 4 - 3.67347 * s;
8239
+ bone.b *= s;
8240
+ bone.d *= s;
8241
+ }
8194
8242
  }
8195
8243
  if (physics !== 3 /* pose */) {
8196
8244
  this.tx = l * bone.a;
@@ -8249,6 +8297,16 @@ ${error}` : ""}`);
8249
8297
  gravityGlobal = false;
8250
8298
  /** True when this constraint's mix is controlled by global slider timelines. */
8251
8299
  mixGlobal = false;
8300
+ /** Determines how the {@link BonePose.scaleY} changes when {@link PhysicsConstraintData.scaleX} sets
8301
+ * {@link BonePose.scaleX}. */
8302
+ _scaleYMode = 0 /* None */;
8303
+ get scaleYMode() {
8304
+ return this._scaleYMode;
8305
+ }
8306
+ set scaleYMode(scaleYMode) {
8307
+ if (scaleYMode == null) throw new Error("scaleYMode cannot be null.");
8308
+ this._scaleYMode = scaleYMode;
8309
+ }
8252
8310
  constructor(name) {
8253
8311
  super(name, new PhysicsConstraintPose());
8254
8312
  }
@@ -9301,7 +9359,17 @@ ${error}` : ""}`);
9301
9359
  if ((flags & 2) !== 0) data.x = input.readFloat();
9302
9360
  if ((flags & 4) !== 0) data.y = input.readFloat();
9303
9361
  if ((flags & 8) !== 0) data.rotate = input.readFloat();
9304
- if ((flags & 16) !== 0) data.scaleX = input.readFloat();
9362
+ if ((flags & 16) !== 0) {
9363
+ let scaleX = input.readFloat();
9364
+ if (scaleX < -2) {
9365
+ data.scaleYMode = 2 /* Volume */;
9366
+ scaleX = -2 - scaleX;
9367
+ } else if (scaleX < 0) {
9368
+ data.scaleYMode = 1 /* Uniform */;
9369
+ scaleX = -1 - scaleX;
9370
+ }
9371
+ data.scaleX = scaleX;
9372
+ }
9305
9373
  if ((flags & 32) !== 0) data.shearX = input.readFloat();
9306
9374
  data.limit = ((flags & 64) !== 0 ? input.readFloat() : 5e3) * scale;
9307
9375
  data.step = 1 / input.readUnsignedByte();
@@ -11724,6 +11792,8 @@ ${error}` : ""}`);
11724
11792
  data.y = getValue(constraintMap, "y", 0);
11725
11793
  data.rotate = getValue(constraintMap, "rotate", 0);
11726
11794
  data.scaleX = getValue(constraintMap, "scaleX", 0);
11795
+ const scaleY = getValue(constraintMap, "scaleY", null);
11796
+ if (scaleY != null) data.scaleYMode = Utils.enumValue(ScaleYMode, scaleY);
11727
11797
  data.shearX = getValue(constraintMap, "shearX", 0);
11728
11798
  data.limit = getValue(constraintMap, "limit", 5e3) * scale;
11729
11799
  data.step = 1 / getValue(constraintMap, "fps", 60);