@esotericsoftware/spine-core 4.3.8 → 4.3.10

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.
@@ -6472,21 +6472,22 @@ ${error}` : ""}`);
6472
6472
  modifyLocal(skeleton) {
6473
6473
  if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
6474
6474
  this.world = 0;
6475
- this.resetWorld(skeleton._update);
6475
+ this.resetWorld(skeleton, skeleton._update);
6476
6476
  }
6477
- modifyWorld(update) {
6477
+ modifyWorld(skeleton) {
6478
+ const update = skeleton._update;
6478
6479
  this.local = update;
6479
6480
  this.world = update;
6480
- this.resetWorld(update);
6481
+ this.resetWorld(skeleton, update);
6481
6482
  }
6482
- resetWorld(update) {
6483
+ resetWorld(skeleton, update) {
6483
6484
  const children = this.bone.children;
6484
6485
  for (let i = 0, n = children.length; i < n; i++) {
6485
6486
  const child = children[i].appliedPose;
6486
6487
  if (child.world === update) {
6488
+ if (child.local === update) child.updateLocalTransform(skeleton);
6487
6489
  child.world = 0;
6488
- child.local = 0;
6489
- child.resetWorld(update);
6490
+ child.resetWorld(skeleton, update);
6490
6491
  }
6491
6492
  }
6492
6493
  }
@@ -7279,8 +7280,9 @@ ${error}` : ""}`);
7279
7280
  const bone = this.slot.bone.appliedPose;
7280
7281
  offsetRotation *= bone.a * bone.d - bone.b * bone.c > 0 ? MathUtils.degRad : -MathUtils.degRad;
7281
7282
  }
7282
- for (let i = 0, ip = 3, u = skeleton._update; i < boneCount; i++, ip += 3) {
7283
+ for (let i = 0, ip = 3; i < boneCount; i++, ip += 3) {
7283
7284
  const bone = bones[i];
7285
+ bone.modifyWorld(skeleton);
7284
7286
  bone.worldX += (boneX - bone.worldX) * mixX;
7285
7287
  bone.worldY += (boneY - bone.worldY) * mixY;
7286
7288
  const x = positions[ip], y = positions[ip + 1], dx = x - boneX, dy = y - boneY;
@@ -7324,7 +7326,6 @@ ${error}` : ""}`);
7324
7326
  bone.c = sin * a + cos * c;
7325
7327
  bone.d = sin * b + cos * d;
7326
7328
  }
7327
- bone.modifyWorld(u);
7328
7329
  }
7329
7330
  }
7330
7331
  computeWorldPositions(skeleton, path, spacesCount, tangents) {
@@ -8237,9 +8238,9 @@ ${error}` : ""}`);
8237
8238
  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;
8238
8239
  const bone = this.bone;
8239
8240
  let l = bone.bone.data.length, t = this.data.step, z = 0;
8241
+ if (physics === 0 /* none */) return;
8242
+ bone.modifyWorld(skeleton);
8240
8243
  switch (physics) {
8241
- case 0 /* none */:
8242
- return;
8243
8244
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: fall through expected
8244
8245
  case 1 /* reset */:
8245
8246
  this.reset(skeleton);
@@ -8417,7 +8418,6 @@ ${error}` : ""}`);
8417
8418
  this.tx = l * bone.a;
8418
8419
  this.ty = l * bone.c;
8419
8420
  }
8420
- bone.modifyWorld(skeleton._update);
8421
8421
  }
8422
8422
  sort(skeleton) {
8423
8423
  const bone = this.bone.bone;
@@ -8984,14 +8984,14 @@ ${error}` : ""}`);
8984
8984
  const source = this.source.appliedPose;
8985
8985
  if (localSource) source.validateLocalTransform(skeleton);
8986
8986
  const fromItems = data.properties;
8987
- const fn = data.properties.length, update = skeleton._update;
8987
+ const fn = data.properties.length;
8988
8988
  const bones = this.bones;
8989
8989
  for (let i = 0, n = this.bones.length; i < n; i++) {
8990
8990
  const bone = bones[i];
8991
8991
  if (localTarget)
8992
8992
  bone.modifyLocal(skeleton);
8993
8993
  else
8994
- bone.modifyWorld(update);
8994
+ bone.modifyWorld(skeleton);
8995
8995
  for (let f = 0; f < fn; f++) {
8996
8996
  const from = fromItems[f];
8997
8997
  const value = from.value(skeleton, source, localSource, offsets) - from.offset;
@@ -11219,7 +11219,7 @@ ${error}` : ""}`);
11219
11219
  t = triangles[i + 2];
11220
11220
  const x3 = vertices[t * stride], y3 = vertices[t * stride + 1];
11221
11221
  const u3 = uvs[t << 1], v3 = uvs[(t << 1) + 1];
11222
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11222
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11223
11223
  for (let p = 0; p < polygonsCount; p++) {
11224
11224
  let s = clippedVertices.length;
11225
11225
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11227,6 +11227,13 @@ ${error}` : ""}`);
11227
11227
  const clipOutputLength = clipOutput.length;
11228
11228
  if (clipOutputLength === 0) continue;
11229
11229
  let clipOutputCount = clipOutputLength >> 1;
11230
+ if (d === 0) {
11231
+ d0 = y2 - y3;
11232
+ d1 = x3 - x2;
11233
+ d2 = x1 - x3;
11234
+ d4 = y3 - y1;
11235
+ d = 1 / (d0 * d2 - d1 * d4);
11236
+ }
11230
11237
  const cv = Utils.setArraySize(clippedVertices, s + clipOutputCount * stride);
11231
11238
  for (let ii = 0; ii < clipOutputLength; ii += 2, s += stride) {
11232
11239
  const x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
@@ -11426,7 +11433,7 @@ ${error}` : ""}`);
11426
11433
  const x3 = vertices[vertexStart + v], y3 = vertices[vertexStart + v + 1];
11427
11434
  uv = t << 1;
11428
11435
  const u3 = uvs[uv], v3 = uvs[uv + 1];
11429
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11436
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11430
11437
  for (let p = 0; p < polygonsCount; p++) {
11431
11438
  let s = this.clippedVerticesLength;
11432
11439
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11434,6 +11441,13 @@ ${error}` : ""}`);
11434
11441
  const clipOutputLength = clipOutput.length;
11435
11442
  if (clipOutputLength === 0) continue;
11436
11443
  let clipOutputCount = clipOutputLength >> 1;
11444
+ if (d === 0) {
11445
+ d0 = y2 - y3;
11446
+ d1 = x3 - x2;
11447
+ d2 = x1 - x3;
11448
+ d4 = y3 - y1;
11449
+ d = 1 / (d0 * d2 - d1 * d4);
11450
+ }
11437
11451
  const newLength = s + clipOutputCount * stride;
11438
11452
  if (clippedVertices.length < newLength) {
11439
11453
  this._clippedVerticesTyped = new Float32Array(newLength * 2);
@@ -11550,16 +11564,15 @@ ${error}` : ""}`);
11550
11564
  const edgeX = v[i], edgeY = v[i + 1], ex = edgeX - v[i + 2], ey = edgeY - v[i + 3];
11551
11565
  const outputStart = output.length;
11552
11566
  const iv2 = input;
11553
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11554
- x1 = iv2[ii];
11555
- y1 = iv2[ii + 1];
11556
- ii += 2;
11567
+ x1 = iv2[0];
11568
+ y1 = iv2[1];
11569
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11570
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11557
11571
  x2 = iv2[ii];
11558
11572
  y2 = iv2[ii + 1];
11559
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11560
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11573
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11561
11574
  if (s1 > 0) {
11562
- if (s2)
11575
+ if (s2 > 0)
11563
11576
  output.push(x2, y2);
11564
11577
  else {
11565
11578
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11569,7 +11582,7 @@ ${error}` : ""}`);
11569
11582
  } else
11570
11583
  output.push(x2, y2);
11571
11584
  }
11572
- } else if (s2) {
11585
+ } else if (s2 > 0) {
11573
11586
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11574
11587
  if (t >= 0 && t <= 1) {
11575
11588
  output.push(x1 + ix * t, y1 + iy * t, x2, y2);
@@ -11578,6 +11591,9 @@ ${error}` : ""}`);
11578
11591
  output.push(x2, y2);
11579
11592
  } else
11580
11593
  clipped = true;
11594
+ x1 = x2;
11595
+ y1 = y2;
11596
+ s1 = s2;
11581
11597
  }
11582
11598
  if (outputStart === output.length) {
11583
11599
  originalOutput.length = 0;
@@ -11625,16 +11641,15 @@ ${error}` : ""}`);
11625
11641
  const outputStart = output.length, fragmentStart = this.inverseVertices.length;
11626
11642
  this.inverseVertices.push(0);
11627
11643
  iv = input;
11628
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11629
- x1 = iv[ii];
11630
- y1 = iv[ii + 1];
11631
- ii += 2;
11644
+ x1 = iv[0];
11645
+ y1 = iv[1];
11646
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11647
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11632
11648
  x2 = iv[ii];
11633
11649
  y2 = iv[ii + 1];
11634
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11635
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11650
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11636
11651
  if (s1 > 0) {
11637
- if (s2)
11652
+ if (s2 > 0)
11638
11653
  output.push(x2, y2);
11639
11654
  else {
11640
11655
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11645,16 +11660,19 @@ ${error}` : ""}`);
11645
11660
  } else
11646
11661
  output.push(x2, y2);
11647
11662
  }
11648
- } else if (s2) {
11649
- const dx = x2 - x1, dy = y2 - y1, t = s1 / (dx * ey - dy * ex);
11663
+ } else if (s2 > 0) {
11664
+ const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11650
11665
  if (t >= 0 && t <= 1) {
11651
- const cx = x1 + dx * t, cy = y1 + dy * t;
11666
+ const cx = x1 + ix * t, cy = y1 + iy * t;
11652
11667
  this.inverseVertices.push(cx, cy);
11653
11668
  output.push(cx, cy, x2, y2);
11654
11669
  } else
11655
11670
  output.push(x2, y2);
11656
11671
  } else
11657
11672
  this.inverseVertices.push(x2, y2);
11673
+ x1 = x2;
11674
+ y1 = y2;
11675
+ s1 = s2;
11658
11676
  }
11659
11677
  const fragmentSize = this.inverseVertices.length - fragmentStart - 1;
11660
11678
  if (fragmentSize >= 6)
@@ -13021,17 +13039,21 @@ ${error}` : ""}`);
13021
13039
  this.renderCommands.length = 0;
13022
13040
  const clipper = this.clipping;
13023
13041
  const drawOrder = skeleton.drawOrder.appliedPose;
13024
- for (let i = 0; i < skeleton.slots.length; i++) {
13042
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
13025
13043
  const slot = drawOrder[i];
13026
- const attachment = slot.appliedPose.attachment;
13027
- if (!attachment) {
13044
+ if (!slot.bone.active) {
13028
13045
  clipper.clipEnd(slot);
13029
13046
  continue;
13030
13047
  }
13031
13048
  const pose = slot.appliedPose;
13049
+ const attachment = pose.attachment;
13050
+ if (!attachment) {
13051
+ clipper.clipEnd(slot);
13052
+ continue;
13053
+ }
13032
13054
  const slotColor = pose.color;
13033
13055
  const alpha = slotColor.a;
13034
- if ((alpha === 0 || !slot.bone.active) && !(attachment instanceof ClippingAttachment)) {
13056
+ if (alpha === 0 && !(attachment instanceof ClippingAttachment)) {
13035
13057
  clipper.clipEnd(slot);
13036
13058
  continue;
13037
13059
  }
@@ -13075,9 +13097,15 @@ ${error}` : ""}`);
13075
13097
  indicesCount = indices.length;
13076
13098
  texture = sequence.regions[sequenceIndex]?.texture;
13077
13099
  } else if (attachment instanceof ClippingAttachment) {
13100
+ clipper.clipEnd(slot);
13078
13101
  clipper.clipStart(skeleton, slot, attachment);
13079
13102
  continue;
13080
13103
  } else {
13104
+ clipper.clipEnd(slot);
13105
+ continue;
13106
+ }
13107
+ if (!texture) {
13108
+ clipper.clipEnd(slot);
13081
13109
  continue;
13082
13110
  }
13083
13111
  const skelColor = skeleton.color;