@esotericsoftware/spine-webgl 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.
@@ -341,6 +341,8 @@ var spine = (() => {
341
341
  }
342
342
  };
343
343
  var MathUtils = class _MathUtils {
344
+ static epsilon = 1e-5;
345
+ static epsilon2 = _MathUtils.epsilon * _MathUtils.epsilon;
344
346
  // biome-ignore lint/suspicious/noApproximativeNumericConstant: reference runtime
345
347
  static PI = 3.1415927;
346
348
  static PI2 = _MathUtils.PI * 2;
@@ -6138,73 +6140,70 @@ ${error}` : ""}`);
6138
6140
  return;
6139
6141
  }
6140
6142
  case 1 /* OnlyTranslation */: {
6143
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
6141
6144
  const rx = (rotation + shearX) * MathUtils.degRad;
6142
6145
  const ry = (rotation + 90 + shearY) * MathUtils.degRad;
6143
- this.a = Math.cos(rx) * scaleX;
6144
- this.b = Math.cos(ry) * scaleY;
6145
- this.c = Math.sin(rx) * scaleX;
6146
- this.d = Math.sin(ry) * scaleY;
6146
+ this.a = Math.cos(rx) * scaleX * sx;
6147
+ this.b = Math.cos(ry) * scaleY * sx;
6148
+ this.c = Math.sin(rx) * scaleX * sy;
6149
+ this.d = Math.sin(ry) * scaleY * sy;
6147
6150
  break;
6148
6151
  }
6149
6152
  case 2 /* NoRotationOrReflection */: {
6150
- const sx = 1 / skeleton.scaleX, sy = 1 / skeleton.scaleY;
6151
- pa *= sx;
6152
- pc *= sy;
6153
+ const sx = skeleton.scaleX, sy = skeleton.scaleY, sxi = 1 / sx, syi = 1 / sy;
6154
+ pa *= sxi;
6155
+ pc *= syi;
6153
6156
  let s = pa * pa + pc * pc;
6154
- let prx = 0;
6155
- if (s > 1e-4) {
6156
- s = Math.abs(pa * pd * sy - pb * sx * pc) / s;
6157
+ let r = 0;
6158
+ if (s > MathUtils.epsilon2) {
6159
+ s = Math.abs(pa * pd * syi - pb * sxi * pc) / s;
6157
6160
  pb = pc * s;
6158
6161
  pd = pa * s;
6159
- prx = MathUtils.atan2Deg(pc, pa);
6162
+ r = rotation - MathUtils.atan2Deg(pc, pa);
6160
6163
  } else {
6161
6164
  pa = 0;
6162
6165
  pc = 0;
6163
- prx = 90 - MathUtils.atan2Deg(pd, pb);
6166
+ r = rotation - 90 + MathUtils.atan2Deg(pd, pb);
6164
6167
  }
6165
- const rx = (rotation + shearX - prx) * MathUtils.degRad;
6166
- const ry = (rotation + shearY - prx + 90) * MathUtils.degRad;
6168
+ const rx = (r + shearX) * MathUtils.degRad;
6169
+ const ry = (r + shearY + 90) * MathUtils.degRad;
6167
6170
  const la = Math.cos(rx) * scaleX;
6168
6171
  const lb = Math.cos(ry) * scaleY;
6169
6172
  const lc = Math.sin(rx) * scaleX;
6170
6173
  const ld = Math.sin(ry) * scaleY;
6171
- this.a = pa * la - pb * lc;
6172
- this.b = pa * lb - pb * ld;
6173
- this.c = pc * la + pd * lc;
6174
- this.d = pc * lb + pd * ld;
6174
+ this.a = (pa * la - pb * lc) * sx;
6175
+ this.b = (pa * lb - pb * ld) * sx;
6176
+ this.c = (pc * la + pd * lc) * sy;
6177
+ this.d = (pc * lb + pd * ld) * sy;
6175
6178
  break;
6176
6179
  }
6177
6180
  case 3 /* NoScale */:
6178
6181
  case 4 /* NoScaleOrReflection */: {
6179
- let r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6180
- let za = (pa * cos + pb * sin) / skeleton.scaleX;
6181
- let zc = (pc * cos + pd * sin) / skeleton.scaleY;
6182
- let s = Math.sqrt(za * za + zc * zc);
6183
- if (s > 1e-5) s = 1 / s;
6182
+ const sx = skeleton.scaleX, sy = skeleton.scaleY, sxi = 1 / sx, syi = 1 / sy;
6183
+ const r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6184
+ let za = (pa * cos + pb * sin) * sxi;
6185
+ let zc = (pc * cos + pd * sin) * syi;
6186
+ const s = 1 / Math.sqrt(za * za + zc * zc);
6184
6187
  za *= s;
6185
6188
  zc *= s;
6186
- s = Math.sqrt(za * za + zc * zc);
6187
- if (this.inherit === 3 /* NoScale */ && pa * pd - pb * pc < 0 !== (skeleton.scaleX < 0 !== skeleton.scaleY < 0)) s = -s;
6188
- r = Math.PI / 2 + Math.atan2(zc, za);
6189
- const zb = Math.cos(r) * s;
6190
- const zd = Math.sin(r) * s;
6189
+ let zb = -zc, zd = za;
6190
+ if (this.inherit === 3 /* NoScale */ && pa * pd - pb * pc < 0 !== (sx < 0 !== sy < 0)) {
6191
+ zb = -zb;
6192
+ zd = -zd;
6193
+ }
6191
6194
  const rx = shearX * MathUtils.degRad;
6192
6195
  const ry = (90 + shearY) * MathUtils.degRad;
6193
6196
  const la = Math.cos(rx) * scaleX;
6194
6197
  const lb = Math.cos(ry) * scaleY;
6195
6198
  const lc = Math.sin(rx) * scaleX;
6196
6199
  const ld = Math.sin(ry) * scaleY;
6197
- this.a = za * la + zb * lc;
6198
- this.b = za * lb + zb * ld;
6199
- this.c = zc * la + zd * lc;
6200
- this.d = zc * lb + zd * ld;
6200
+ this.a = (za * la + zb * lc) * sx;
6201
+ this.b = (za * lb + zb * ld) * sx;
6202
+ this.c = (zc * la + zd * lc) * sy;
6203
+ this.d = (zc * lb + zd * ld) * sy;
6201
6204
  break;
6202
6205
  }
6203
6206
  }
6204
- this.a *= skeleton.scaleX;
6205
- this.b *= skeleton.scaleX;
6206
- this.c *= skeleton.scaleY;
6207
- this.d *= skeleton.scaleY;
6208
6207
  }
6209
6208
  /** Computes the local transform values from the world transform.
6210
6209
  *
@@ -6217,79 +6216,118 @@ ${error}` : ""}`);
6217
6216
  updateLocalTransform(skeleton) {
6218
6217
  this.local = 0;
6219
6218
  this.world = skeleton._update;
6219
+ const sx = skeleton.scaleX, sy = skeleton.scaleY;
6220
6220
  if (!this.bone.parent) {
6221
- this.x = this.worldX - skeleton.x;
6222
- this.y = this.worldY - skeleton.y;
6223
- const a = this.a, b = this.b, c = this.c, d = this.d;
6224
- this.rotation = MathUtils.atan2Deg(c, a);
6225
- this.scaleX = Math.sqrt(a * a + c * c);
6226
- this.scaleY = Math.sqrt(b * b + d * d);
6227
- this.shearX = 0;
6228
- this.shearY = MathUtils.atan2Deg(a * b + c * d, a * d - b * c);
6221
+ const sxi = 1 / sx, syi = 1 / sy;
6222
+ this.x = (this.worldX - skeleton.x) * sxi;
6223
+ this.y = (this.worldY - skeleton.y) * syi;
6224
+ this.set5(this.a * sxi, this.b * sxi, this.c * syi, this.d * syi, 0);
6229
6225
  return;
6230
6226
  }
6231
6227
  const parent = this.bone.parent.appliedPose;
6232
6228
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
6233
- let pid = 1 / (pa * pd - pb * pc);
6234
- let ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
6229
+ const pad = pa * pd - pb * pc, pid = 1 / (pa * pd - pb * pc);
6230
+ const ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
6235
6231
  const dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;
6236
6232
  this.x = dx * ia - dy * ib;
6237
6233
  this.y = dy * id - dx * ic;
6238
- let ra, rb, rc, rd;
6239
- if (this.inherit === 1 /* OnlyTranslation */) {
6240
- ra = this.a;
6241
- rb = this.b;
6242
- rc = this.c;
6243
- rd = this.d;
6234
+ switch (this.inherit) {
6235
+ case 0 /* Normal */:
6236
+ 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);
6237
+ break;
6238
+ case 1 /* OnlyTranslation */: {
6239
+ const sxi = 1 / sx, syi = 1 / sy;
6240
+ this.set5(this.a * sxi, this.b * sxi, this.c * syi, this.d * syi, 0);
6241
+ break;
6242
+ }
6243
+ case 2 /* NoRotationOrReflection */: {
6244
+ const sxi = 1 / sx, syi = 1 / sy;
6245
+ pa *= sxi;
6246
+ pc *= syi;
6247
+ const wa = this.a * sxi, wb = this.b * sxi, wc = this.c * syi, wd = this.d * syi;
6248
+ const s = 1 / (pa * pa + pc * pc), det = 1 / Math.abs(pad * sxi * syi);
6249
+ this.set5(
6250
+ (pa * wa + pc * wc) * s,
6251
+ (pa * wb + pc * wd) * s,
6252
+ (pa * wc - pc * wa) * det,
6253
+ (pa * wd - pc * wb) * det,
6254
+ MathUtils.atan2Deg(pc, pa)
6255
+ );
6256
+ break;
6257
+ }
6258
+ case 3 /* NoScale */:
6259
+ case 4 /* NoScaleOrReflection */: {
6260
+ const sxi = 1 / sx, syi = 1 / sy;
6261
+ const wa = this.a * sxi, wb = this.b * sxi, wc = this.c * syi, wd = this.d * syi;
6262
+ let tx = pd * this.a - pb * this.c, ty = pa * this.c - pc * this.a;
6263
+ if (pad < 0) {
6264
+ tx = -tx;
6265
+ ty = -ty;
6266
+ }
6267
+ let r = MathUtils.atan2Deg(ty, tx);
6268
+ this.rotation = r;
6269
+ r *= MathUtils.degRad;
6270
+ const cos = Math.cos(r), sin = Math.sin(r);
6271
+ let za = (pa * cos + pb * sin) * sxi;
6272
+ let zc = (pc * cos + pd * sin) * syi;
6273
+ const s = 1 / Math.sqrt(za * za + zc * zc);
6274
+ za *= s;
6275
+ zc *= s;
6276
+ const si = this.inherit === 3 /* NoScale */ && pad < 0 !== (sx < 0 !== sy < 0) ? -1 : 1;
6277
+ this.set4(za * wa + zc * wc, za * wb + zc * wd, (za * wc - zc * wa) * si, (za * wd - zc * wb) * si);
6278
+ }
6279
+ }
6280
+ }
6281
+ set4(ra, rb, rc, rd) {
6282
+ const x = ra * ra + rc * rc, y = rb * rb + rd * rd;
6283
+ if (x > MathUtils.epsilon2) {
6284
+ this.shearX = MathUtils.atan2Deg(rc, ra);
6285
+ this.scaleX = Math.sqrt(x);
6244
6286
  } else {
6245
- switch (this.inherit) {
6246
- case 2 /* NoRotationOrReflection */: {
6247
- const s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
6248
- pb = -pc * skeleton.scaleX * s / skeleton.scaleY;
6249
- pd = pa * skeleton.scaleY * s / skeleton.scaleX;
6250
- pid = 1 / (pa * pd - pb * pc);
6251
- ia = pd * pid;
6252
- ib = pb * pid;
6253
- break;
6254
- }
6255
- case 3 /* NoScale */:
6256
- case 4 /* NoScaleOrReflection */: {
6257
- let r = this.rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
6258
- pa = (pa * cos + pb * sin) / skeleton.scaleX;
6259
- pc = (pc * cos + pd * sin) / skeleton.scaleY;
6260
- let s = Math.sqrt(pa * pa + pc * pc);
6261
- if (s > 1e-5) s = 1 / s;
6262
- pa *= s;
6263
- pc *= s;
6264
- s = Math.sqrt(pa * pa + pc * pc);
6265
- if (this.inherit === 3 /* NoScale */ && pid < 0 !== (skeleton.scaleX < 0 !== skeleton.scaleY < 0)) s = -s;
6266
- r = MathUtils.PI / 2 + Math.atan2(pc, pa);
6267
- pb = Math.cos(r) * s;
6268
- pd = Math.sin(r) * s;
6269
- pid = 1 / (pa * pd - pb * pc);
6270
- ia = pd * pid;
6271
- ib = pb * pid;
6272
- ic = pc * pid;
6273
- id = pa * pid;
6274
- }
6275
- }
6276
- ra = ia * this.a - ib * this.c;
6277
- rb = ia * this.b - ib * this.d;
6278
- rc = id * this.c - ic * this.a;
6279
- rd = id * this.d - ic * this.b;
6287
+ this.shearX = 0;
6288
+ this.scaleX = 0;
6280
6289
  }
6290
+ this.scaleY = Math.sqrt(y);
6291
+ if (y > MathUtils.epsilon2) {
6292
+ this.shearY = MathUtils.atan2Deg(rd, rb);
6293
+ if (ra * rd - rb * rc < 0) {
6294
+ this.scaleY = -this.scaleY;
6295
+ this.shearY += 90;
6296
+ } else
6297
+ this.shearY -= 90;
6298
+ if (this.shearY > 180)
6299
+ this.shearY -= 360;
6300
+ else if (this.shearY <= -180)
6301
+ this.shearY += 360;
6302
+ } else
6303
+ this.shearY = 0;
6304
+ }
6305
+ set5(ra, rb, rc, rd, ro) {
6281
6306
  this.shearX = 0;
6282
- this.scaleX = Math.sqrt(ra * ra + rc * rc);
6283
- if (this.scaleX > 1e-4) {
6284
- const det = ra * rd - rb * rc;
6285
- this.scaleY = det / this.scaleX;
6286
- this.shearY = -MathUtils.atan2Deg(ra * rb + rc * rd, det);
6287
- this.rotation = MathUtils.atan2Deg(rc, ra);
6307
+ const x = ra * ra + rc * rc, y = rb * rb + rd * rd;
6308
+ if (x > MathUtils.epsilon2) {
6309
+ const r = MathUtils.atan2Deg(rc, ra);
6310
+ this.rotation = r + ro;
6311
+ this.scaleX = Math.sqrt(x);
6312
+ this.scaleY = Math.sqrt(y);
6313
+ if (y > MathUtils.epsilon2) {
6314
+ this.shearY = MathUtils.atan2Deg(rd, rb);
6315
+ if (ra * rd - rb * rc < 0) {
6316
+ this.scaleY = -this.scaleY;
6317
+ this.shearY += 90 - r;
6318
+ } else
6319
+ this.shearY -= 90 + r;
6320
+ if (this.shearY > 180)
6321
+ this.shearY -= 360;
6322
+ else if (this.shearY <= -180)
6323
+ this.shearY += 360;
6324
+ } else
6325
+ this.shearY = 0;
6288
6326
  } else {
6289
6327
  this.scaleX = 0;
6290
- this.scaleY = Math.sqrt(rb * rb + rd * rd);
6328
+ this.scaleY = Math.sqrt(y);
6291
6329
  this.shearY = 0;
6292
- this.rotation = 90 - MathUtils.atan2Deg(rd, rb);
6330
+ this.rotation = y > MathUtils.epsilon2 ? MathUtils.atan2Deg(rd, rb) - 90 + ro : ro;
6293
6331
  }
6294
6332
  }
6295
6333
  /** If the world transform has been modified by constraints and the local transform no longer matches,
@@ -6534,6 +6572,12 @@ ${error}` : ""}`);
6534
6572
  super(name, setup);
6535
6573
  }
6536
6574
  };
6575
+ var ScaleYMode = /* @__PURE__ */ ((ScaleYMode2) => {
6576
+ ScaleYMode2[ScaleYMode2["None"] = 0] = "None";
6577
+ ScaleYMode2[ScaleYMode2["Uniform"] = 1] = "Uniform";
6578
+ ScaleYMode2[ScaleYMode2["Volume"] = 2] = "Volume";
6579
+ return ScaleYMode2;
6580
+ })(ScaleYMode || {});
6537
6581
 
6538
6582
  // spine-core/src/Event.ts
6539
6583
  var Event = class {
@@ -6605,43 +6649,6 @@ ${error}` : ""}`);
6605
6649
  }
6606
6650
  };
6607
6651
 
6608
- // spine-core/src/IkConstraintData.ts
6609
- var IkConstraintData = class extends ConstraintData {
6610
- /** The bones that are constrained by this IK constraint. */
6611
- bones = [];
6612
- _target = null;
6613
- /** The bone that is the IK target. */
6614
- set target(boneData) {
6615
- this._target = boneData;
6616
- }
6617
- get target() {
6618
- if (!this._target) throw new Error("target cannot be null.");
6619
- return this._target;
6620
- }
6621
- /** Determines how the {@link BonePose.scaleY} changes when {@link IkConstraintPose.compress} or
6622
- * {@link IkConstraintPose.stretch} set {@link BonePose.scaleX}. */
6623
- _scaleYMode = 0 /* None */;
6624
- set scaleYMode(scaleYMode) {
6625
- this._scaleYMode = scaleYMode;
6626
- }
6627
- get scaleYMode() {
6628
- if (this._scaleYMode == null) throw new Error("scaleYMode cannot be null.");
6629
- return this._scaleYMode;
6630
- }
6631
- constructor(name) {
6632
- super(name, new IkConstraintPose());
6633
- }
6634
- create(skeleton) {
6635
- return new IkConstraint(this, skeleton);
6636
- }
6637
- };
6638
- var ScaleYMode = /* @__PURE__ */ ((ScaleYMode2) => {
6639
- ScaleYMode2[ScaleYMode2["None"] = 0] = "None";
6640
- ScaleYMode2[ScaleYMode2["Uniform"] = 1] = "Uniform";
6641
- ScaleYMode2[ScaleYMode2["Volume"] = 2] = "Volume";
6642
- return ScaleYMode2;
6643
- })(ScaleYMode || {});
6644
-
6645
6652
  // spine-core/src/IkConstraint.ts
6646
6653
  var IkConstraint = class _IkConstraint extends Constraint {
6647
6654
  /** The 1 or 2 bones that will be modified by this IK constraint. */
@@ -6728,7 +6735,7 @@ ${error}` : ""}`);
6728
6735
  break;
6729
6736
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: reference runtime
6730
6737
  case 2 /* NoRotationOrReflection */: {
6731
- const s = Math.abs(pa * pd - pb * pc) / Math.max(1e-4, pa * pa + pc * pc);
6738
+ const s = Math.abs(pa * pd - pb * pc) / Math.max(MathUtils.epsilon, pa * pa + pc * pc);
6732
6739
  const sa = pa / skeleton.scaleX;
6733
6740
  const sc = pc / skeleton.scaleY;
6734
6741
  pb = -sc * s * skeleton.scaleX;
@@ -6739,7 +6746,7 @@ ${error}` : ""}`);
6739
6746
  default: {
6740
6747
  const x = targetX - p.worldX, y = targetY - p.worldY;
6741
6748
  const d = pa * pd - pb * pc;
6742
- if (Math.abs(d) <= 1e-4) {
6749
+ if (Math.abs(d) <= MathUtils.epsilon) {
6743
6750
  tx = 0;
6744
6751
  ty = 0;
6745
6752
  } else {
@@ -6752,7 +6759,7 @@ ${error}` : ""}`);
6752
6759
  if (bone.scaleX < 0) rotationIK += 180;
6753
6760
  if (rotationIK > 180)
6754
6761
  rotationIK -= 360;
6755
- else if (rotationIK < -180)
6762
+ else if (rotationIK <= -180)
6756
6763
  rotationIK += 360;
6757
6764
  bone.rotation += rotationIK * mix;
6758
6765
  if (compress || stretch) {
@@ -6763,7 +6770,7 @@ ${error}` : ""}`);
6763
6770
  ty = targetY - bone.worldY;
6764
6771
  }
6765
6772
  const b = bone.bone.data.length * bone.scaleX;
6766
- if (b > 1e-4) {
6773
+ if (b > MathUtils.epsilon) {
6767
6774
  const dd = tx * tx + ty * ty;
6768
6775
  if (compress && dd < b * b || stretch && dd > b * b) {
6769
6776
  const s = (Math.sqrt(dd) / b - 1) * mix + 1;
@@ -6773,7 +6780,7 @@ ${error}` : ""}`);
6773
6780
  bone.scaleY *= s;
6774
6781
  break;
6775
6782
  case 2 /* Volume */:
6776
- bone.scaleY /= s;
6783
+ bone.scaleY /= s < 0.7 ? 0.25 + 0.642857 * s : s;
6777
6784
  }
6778
6785
  }
6779
6786
  }
@@ -6805,7 +6812,7 @@ ${error}` : ""}`);
6805
6812
  } else
6806
6813
  os2 = 0;
6807
6814
  let cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;
6808
- const u = Math.abs(psx - psy) <= 1e-4;
6815
+ const u = Math.abs(psx - psy) <= MathUtils.epsilon;
6809
6816
  if (!u || stretch) {
6810
6817
  child.y = 0;
6811
6818
  cwx = a * child.x + parent.worldX;
@@ -6820,10 +6827,10 @@ ${error}` : ""}`);
6820
6827
  c = pp.c;
6821
6828
  d = pp.d;
6822
6829
  let id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
6823
- id = Math.abs(id) <= 1e-4 ? 0 : 1 / id;
6830
+ id = Math.abs(id) <= MathUtils.epsilon ? 0 : 1 / id;
6824
6831
  const dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
6825
6832
  let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.bone.data.length * csx, a1, a2;
6826
- if (l1 < 1e-4) {
6833
+ if (l1 < MathUtils.epsilon) {
6827
6834
  _IkConstraint.apply(skeleton, parent, targetX, targetY, false, stretch, 0 /* None */, mix);
6828
6835
  child.rotation = 0;
6829
6836
  return;
@@ -6861,7 +6868,7 @@ ${error}` : ""}`);
6861
6868
  parent.scaleY *= a;
6862
6869
  break;
6863
6870
  case 2 /* Volume */:
6864
- parent.scaleY /= a;
6871
+ parent.scaleY /= a < 0.7 ? 0.25 + 0.642857 * a : a;
6865
6872
  }
6866
6873
  }
6867
6874
  } else
@@ -6923,18 +6930,49 @@ ${error}` : ""}`);
6923
6930
  a1 = (a1 - os) * MathUtils.radDeg + os1 - parent.rotation;
6924
6931
  if (a1 > 180)
6925
6932
  a1 -= 360;
6926
- else if (a1 < -180)
6933
+ else if (a1 <= -180)
6927
6934
  a1 += 360;
6928
6935
  parent.rotation += a1 * mix;
6929
6936
  a2 = ((a2 + os) * MathUtils.radDeg - child.shearX) * s2 + os2 - child.rotation;
6930
6937
  if (a2 > 180)
6931
6938
  a2 -= 360;
6932
- else if (a2 < -180)
6939
+ else if (a2 <= -180)
6933
6940
  a2 += 360;
6934
6941
  child.rotation += a2 * mix;
6935
6942
  }
6936
6943
  };
6937
6944
 
6945
+ // spine-core/src/IkConstraintData.ts
6946
+ var IkConstraintData = class extends ConstraintData {
6947
+ /** The bones that are constrained by this IK constraint. */
6948
+ bones = [];
6949
+ _target = null;
6950
+ /** The bone that is the IK target. */
6951
+ set target(boneData) {
6952
+ this._target = boneData;
6953
+ }
6954
+ get target() {
6955
+ if (!this._target) throw new Error("target cannot be null.");
6956
+ return this._target;
6957
+ }
6958
+ /** Determines how the {@link BonePose.scaleY} changes when {@link IkConstraintPose.compress} or
6959
+ * {@link IkConstraintPose.stretch} set {@link BonePose.scaleX}. */
6960
+ _scaleYMode = 0 /* None */;
6961
+ set scaleYMode(scaleYMode) {
6962
+ this._scaleYMode = scaleYMode;
6963
+ }
6964
+ get scaleYMode() {
6965
+ if (this._scaleYMode == null) throw new Error("scaleYMode cannot be null.");
6966
+ return this._scaleYMode;
6967
+ }
6968
+ constructor(name) {
6969
+ super(name, new IkConstraintPose());
6970
+ }
6971
+ create(skeleton) {
6972
+ return new IkConstraint(this, skeleton);
6973
+ }
6974
+ };
6975
+
6938
6976
  // spine-core/src/PathConstraintPose.ts
6939
6977
  var PathConstraintPose = class {
6940
6978
  /** The position along the path. */
@@ -7008,7 +7046,6 @@ ${error}` : ""}`);
7008
7046
  static NONE = -1;
7009
7047
  static BEFORE = -2;
7010
7048
  static AFTER = -3;
7011
- static epsilon = 1e-5;
7012
7049
  /** The path constraint's setup pose data. */
7013
7050
  data;
7014
7051
  /** The bones that will be modified by this path constraint. */
@@ -7064,7 +7101,7 @@ ${error}` : ""}`);
7064
7101
  for (let i = 0, n = spacesCount - 1; i < n; ) {
7065
7102
  const bone = bones[i];
7066
7103
  const setupLength = bone.bone.data.length;
7067
- if (setupLength < _PathConstraint.epsilon) {
7104
+ if (setupLength < MathUtils.epsilon) {
7068
7105
  if (scale) lengths[i] = 0;
7069
7106
  spaces[++i] = spacing;
7070
7107
  } else {
@@ -7087,7 +7124,7 @@ ${error}` : ""}`);
7087
7124
  for (let i = 0, n = spacesCount - 1; i < n; ) {
7088
7125
  const bone = bones[i];
7089
7126
  const setupLength = bone.bone.data.length;
7090
- if (setupLength < _PathConstraint.epsilon) {
7127
+ if (setupLength < MathUtils.epsilon) {
7091
7128
  if (scale) lengths[i] = 0;
7092
7129
  spaces[++i] = spacing;
7093
7130
  } else {
@@ -8228,9 +8265,20 @@ ${error}` : ""}`);
8228
8265
  }
8229
8266
  }
8230
8267
  if (scaleX) {
8231
- const s = 1 + (this.scaleOffset - this.scaleLag * z) * mix * this.data.scaleX;
8268
+ let s = 1 + (this.scaleOffset - this.scaleLag * z) * mix * this.data.scaleX;
8232
8269
  bone.a *= s;
8233
8270
  bone.c *= s;
8271
+ switch (this.data.scaleYMode) {
8272
+ case 1 /* Uniform */:
8273
+ bone.b *= s;
8274
+ bone.d *= s;
8275
+ break;
8276
+ case 2 /* Volume */:
8277
+ s = Math.abs(s);
8278
+ s = s >= 0.7 ? 1 / s : 4 - 3.67347 * s;
8279
+ bone.b *= s;
8280
+ bone.d *= s;
8281
+ }
8234
8282
  }
8235
8283
  if (physics !== 3 /* pose */) {
8236
8284
  this.tx = l * bone.a;
@@ -8289,6 +8337,16 @@ ${error}` : ""}`);
8289
8337
  gravityGlobal = false;
8290
8338
  /** True when this constraint's mix is controlled by global slider timelines. */
8291
8339
  mixGlobal = false;
8340
+ /** Determines how the {@link BonePose.scaleY} changes when {@link PhysicsConstraintData.scaleX} sets
8341
+ * {@link BonePose.scaleX}. */
8342
+ _scaleYMode = 0 /* None */;
8343
+ get scaleYMode() {
8344
+ return this._scaleYMode;
8345
+ }
8346
+ set scaleYMode(scaleYMode) {
8347
+ if (scaleYMode == null) throw new Error("scaleYMode cannot be null.");
8348
+ this._scaleYMode = scaleYMode;
8349
+ }
8292
8350
  constructor(name) {
8293
8351
  super(name, new PhysicsConstraintPose());
8294
8352
  }
@@ -9341,7 +9399,17 @@ ${error}` : ""}`);
9341
9399
  if ((flags & 2) !== 0) data.x = input.readFloat();
9342
9400
  if ((flags & 4) !== 0) data.y = input.readFloat();
9343
9401
  if ((flags & 8) !== 0) data.rotate = input.readFloat();
9344
- if ((flags & 16) !== 0) data.scaleX = input.readFloat();
9402
+ if ((flags & 16) !== 0) {
9403
+ let scaleX = input.readFloat();
9404
+ if (scaleX < -2) {
9405
+ data.scaleYMode = 2 /* Volume */;
9406
+ scaleX = -2 - scaleX;
9407
+ } else if (scaleX < 0) {
9408
+ data.scaleYMode = 1 /* Uniform */;
9409
+ scaleX = -1 - scaleX;
9410
+ }
9411
+ data.scaleX = scaleX;
9412
+ }
9345
9413
  if ((flags & 32) !== 0) data.shearX = input.readFloat();
9346
9414
  data.limit = ((flags & 64) !== 0 ? input.readFloat() : 5e3) * scale;
9347
9415
  data.step = 1 / input.readUnsignedByte();
@@ -11764,6 +11832,8 @@ ${error}` : ""}`);
11764
11832
  data.y = getValue(constraintMap, "y", 0);
11765
11833
  data.rotate = getValue(constraintMap, "rotate", 0);
11766
11834
  data.scaleX = getValue(constraintMap, "scaleX", 0);
11835
+ const scaleY = getValue(constraintMap, "scaleY", null);
11836
+ if (scaleY != null) data.scaleYMode = Utils.enumValue(ScaleYMode, scaleY);
11767
11837
  data.shearX = getValue(constraintMap, "shearX", 0);
11768
11838
  data.limit = getValue(constraintMap, "limit", 5e3) * scale;
11769
11839
  data.step = 1 / getValue(constraintMap, "fps", 60);
@@ -14898,10 +14968,12 @@ void main () {
14898
14968
  twoColorTint = false;
14899
14969
  renderable = new Renderable([], 0, 0);
14900
14970
  clipper = new SkeletonClipping();
14901
- temp = new Vector2();
14902
- temp2 = new Vector2();
14903
- temp3 = new Color();
14904
- temp4 = new Color();
14971
+ /**
14972
+ * Batches additive slots together with normal slots by rendering additive slots with premultiplied alpha RGB and zero alpha,
14973
+ * while using normal PMA blending. This reduces draw calls for normal/additive/normal sequences with the same texture.
14974
+ * Disable this if rendering to a transparent target and the accumulated destination alpha from additive blending must be preserved.
14975
+ */
14976
+ pmaAdditiveBatching = true;
14905
14977
  constructor(context, twoColorTint = true) {
14906
14978
  this.twoColorTint = twoColorTint;
14907
14979
  if (twoColorTint)
@@ -14980,7 +15052,9 @@ void main () {
14980
15052
  finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r * alpha;
14981
15053
  finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g * alpha;
14982
15054
  finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b * alpha;
14983
- finalColor.a = alpha;
15055
+ const slotBlendMode = slot.data.blendMode;
15056
+ const additiveBlend = this.pmaAdditiveBatching && slotBlendMode === 1 /* Additive */;
15057
+ finalColor.a = additiveBlend ? 0 : alpha;
14984
15058
  const darkColor = this.tempColor2;
14985
15059
  if (!pose.darkColor)
14986
15060
  darkColor.set(0, 0, 0, 1);
@@ -14990,9 +15064,9 @@ void main () {
14990
15064
  darkColor.b = pose.darkColor.b * alpha;
14991
15065
  darkColor.a = 1;
14992
15066
  }
14993
- const slotBlendMode = slot.data.blendMode;
14994
- if (slotBlendMode !== blendMode) {
14995
- blendMode = slotBlendMode;
15067
+ const batchBlendMode = additiveBlend ? 0 /* Normal */ : slotBlendMode;
15068
+ if (batchBlendMode !== blendMode) {
15069
+ blendMode = batchBlendMode;
14996
15070
  batcher.setBlendMode(blendMode);
14997
15071
  }
14998
15072
  if (clipper.isClipping() && clipper.clipTriangles(renderable.vertices, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint, vertexSize)) {
@@ -15007,7 +15081,7 @@ void main () {
15007
15081
  verts[v] = finalColor.r;
15008
15082
  verts[v + 1] = finalColor.g;
15009
15083
  verts[v + 2] = finalColor.b;
15010
- verts[v + 3] = alpha;
15084
+ verts[v + 3] = finalColor.a;
15011
15085
  verts[v + 4] = uvs[u];
15012
15086
  verts[v + 5] = uvs[u + 1];
15013
15087
  }
@@ -15016,7 +15090,7 @@ void main () {
15016
15090
  verts[v] = finalColor.r;
15017
15091
  verts[v + 1] = finalColor.g;
15018
15092
  verts[v + 2] = finalColor.b;
15019
- verts[v + 3] = alpha;
15093
+ verts[v + 3] = finalColor.a;
15020
15094
  verts[v + 4] = uvs[u];
15021
15095
  verts[v + 5] = uvs[u + 1];
15022
15096
  verts[v + 6] = darkColor.r;