@esotericsoftware/spine-canvas 4.3.9 → 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.
@@ -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;