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