@esotericsoftware/spine-core 4.3.0 → 4.3.2

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