@esotericsoftware/spine-webgl 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.
@@ -11033,7 +11033,7 @@ var SkeletonClipping = class {
11033
11033
  t = triangles[i + 2];
11034
11034
  const x3 = vertices[t * stride], y3 = vertices[t * stride + 1];
11035
11035
  const u3 = uvs[t << 1], v3 = uvs[(t << 1) + 1];
11036
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11036
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11037
11037
  for (let p = 0; p < polygonsCount; p++) {
11038
11038
  let s = clippedVertices.length;
11039
11039
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11041,6 +11041,13 @@ var SkeletonClipping = class {
11041
11041
  const clipOutputLength = clipOutput.length;
11042
11042
  if (clipOutputLength === 0) continue;
11043
11043
  let clipOutputCount = clipOutputLength >> 1;
11044
+ if (d === 0) {
11045
+ d0 = y2 - y3;
11046
+ d1 = x3 - x2;
11047
+ d2 = x1 - x3;
11048
+ d4 = y3 - y1;
11049
+ d = 1 / (d0 * d2 - d1 * d4);
11050
+ }
11044
11051
  const cv = Utils.setArraySize(clippedVertices, s + clipOutputCount * stride);
11045
11052
  for (let ii = 0; ii < clipOutputLength; ii += 2, s += stride) {
11046
11053
  const x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
@@ -11240,7 +11247,7 @@ var SkeletonClipping = class {
11240
11247
  const x3 = vertices[vertexStart + v], y3 = vertices[vertexStart + v + 1];
11241
11248
  uv = t << 1;
11242
11249
  const u3 = uvs[uv], v3 = uvs[uv + 1];
11243
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11250
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11244
11251
  for (let p = 0; p < polygonsCount; p++) {
11245
11252
  let s = this.clippedVerticesLength;
11246
11253
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11248,6 +11255,13 @@ var SkeletonClipping = class {
11248
11255
  const clipOutputLength = clipOutput.length;
11249
11256
  if (clipOutputLength === 0) continue;
11250
11257
  let clipOutputCount = clipOutputLength >> 1;
11258
+ if (d === 0) {
11259
+ d0 = y2 - y3;
11260
+ d1 = x3 - x2;
11261
+ d2 = x1 - x3;
11262
+ d4 = y3 - y1;
11263
+ d = 1 / (d0 * d2 - d1 * d4);
11264
+ }
11251
11265
  const newLength = s + clipOutputCount * stride;
11252
11266
  if (clippedVertices.length < newLength) {
11253
11267
  this._clippedVerticesTyped = new Float32Array(newLength * 2);
@@ -11364,16 +11378,15 @@ var SkeletonClipping = class {
11364
11378
  const edgeX = v[i], edgeY = v[i + 1], ex = edgeX - v[i + 2], ey = edgeY - v[i + 3];
11365
11379
  const outputStart = output.length;
11366
11380
  const iv2 = input;
11367
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11368
- x1 = iv2[ii];
11369
- y1 = iv2[ii + 1];
11370
- ii += 2;
11381
+ x1 = iv2[0];
11382
+ y1 = iv2[1];
11383
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11384
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11371
11385
  x2 = iv2[ii];
11372
11386
  y2 = iv2[ii + 1];
11373
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11374
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11387
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11375
11388
  if (s1 > 0) {
11376
- if (s2)
11389
+ if (s2 > 0)
11377
11390
  output.push(x2, y2);
11378
11391
  else {
11379
11392
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11383,7 +11396,7 @@ var SkeletonClipping = class {
11383
11396
  } else
11384
11397
  output.push(x2, y2);
11385
11398
  }
11386
- } else if (s2) {
11399
+ } else if (s2 > 0) {
11387
11400
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11388
11401
  if (t >= 0 && t <= 1) {
11389
11402
  output.push(x1 + ix * t, y1 + iy * t, x2, y2);
@@ -11392,6 +11405,9 @@ var SkeletonClipping = class {
11392
11405
  output.push(x2, y2);
11393
11406
  } else
11394
11407
  clipped = true;
11408
+ x1 = x2;
11409
+ y1 = y2;
11410
+ s1 = s2;
11395
11411
  }
11396
11412
  if (outputStart === output.length) {
11397
11413
  originalOutput.length = 0;
@@ -11439,16 +11455,15 @@ var SkeletonClipping = class {
11439
11455
  const outputStart = output.length, fragmentStart = this.inverseVertices.length;
11440
11456
  this.inverseVertices.push(0);
11441
11457
  iv = input;
11442
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11443
- x1 = iv[ii];
11444
- y1 = iv[ii + 1];
11445
- ii += 2;
11458
+ x1 = iv[0];
11459
+ y1 = iv[1];
11460
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11461
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11446
11462
  x2 = iv[ii];
11447
11463
  y2 = iv[ii + 1];
11448
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11449
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11464
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11450
11465
  if (s1 > 0) {
11451
- if (s2)
11466
+ if (s2 > 0)
11452
11467
  output.push(x2, y2);
11453
11468
  else {
11454
11469
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11459,16 +11474,19 @@ var SkeletonClipping = class {
11459
11474
  } else
11460
11475
  output.push(x2, y2);
11461
11476
  }
11462
- } else if (s2) {
11463
- const dx = x2 - x1, dy = y2 - y1, t = s1 / (dx * ey - dy * ex);
11477
+ } else if (s2 > 0) {
11478
+ const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11464
11479
  if (t >= 0 && t <= 1) {
11465
- const cx = x1 + dx * t, cy = y1 + dy * t;
11480
+ const cx = x1 + ix * t, cy = y1 + iy * t;
11466
11481
  this.inverseVertices.push(cx, cy);
11467
11482
  output.push(cx, cy, x2, y2);
11468
11483
  } else
11469
11484
  output.push(x2, y2);
11470
11485
  } else
11471
11486
  this.inverseVertices.push(x2, y2);
11487
+ x1 = x2;
11488
+ y1 = y2;
11489
+ s1 = s2;
11472
11490
  }
11473
11491
  const fragmentSize = this.inverseVertices.length - fragmentStart - 1;
11474
11492
  if (fragmentSize >= 6)
@@ -12835,17 +12853,21 @@ var SkeletonRendererCore = class {
12835
12853
  this.renderCommands.length = 0;
12836
12854
  const clipper = this.clipping;
12837
12855
  const drawOrder = skeleton.drawOrder.appliedPose;
12838
- for (let i = 0; i < skeleton.slots.length; i++) {
12856
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
12839
12857
  const slot = drawOrder[i];
12840
- const attachment = slot.appliedPose.attachment;
12841
- if (!attachment) {
12858
+ if (!slot.bone.active) {
12842
12859
  clipper.clipEnd(slot);
12843
12860
  continue;
12844
12861
  }
12845
12862
  const pose = slot.appliedPose;
12863
+ const attachment = pose.attachment;
12864
+ if (!attachment) {
12865
+ clipper.clipEnd(slot);
12866
+ continue;
12867
+ }
12846
12868
  const slotColor = pose.color;
12847
12869
  const alpha = slotColor.a;
12848
- if ((alpha === 0 || !slot.bone.active) && !(attachment instanceof ClippingAttachment)) {
12870
+ if (alpha === 0 && !(attachment instanceof ClippingAttachment)) {
12849
12871
  clipper.clipEnd(slot);
12850
12872
  continue;
12851
12873
  }
@@ -12889,9 +12911,15 @@ var SkeletonRendererCore = class {
12889
12911
  indicesCount = indices.length;
12890
12912
  texture = sequence.regions[sequenceIndex]?.texture;
12891
12913
  } else if (attachment instanceof ClippingAttachment) {
12914
+ clipper.clipEnd(slot);
12892
12915
  clipper.clipStart(skeleton, slot, attachment);
12893
12916
  continue;
12894
12917
  } else {
12918
+ clipper.clipEnd(slot);
12919
+ continue;
12920
+ }
12921
+ if (!texture) {
12922
+ clipper.clipEnd(slot);
12895
12923
  continue;
12896
12924
  }
12897
12925
  const skelColor = skeleton.color;