@esotericsoftware/spine-webgl 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.
@@ -6515,21 +6515,22 @@ ${error}` : ""}`);
6515
6515
  modifyLocal(skeleton) {
6516
6516
  if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
6517
6517
  this.world = 0;
6518
- this.resetWorld(skeleton._update);
6518
+ this.resetWorld(skeleton, skeleton._update);
6519
6519
  }
6520
- modifyWorld(update) {
6520
+ modifyWorld(skeleton) {
6521
+ const update = skeleton._update;
6521
6522
  this.local = update;
6522
6523
  this.world = update;
6523
- this.resetWorld(update);
6524
+ this.resetWorld(skeleton, update);
6524
6525
  }
6525
- resetWorld(update) {
6526
+ resetWorld(skeleton, update) {
6526
6527
  const children = this.bone.children;
6527
6528
  for (let i = 0, n = children.length; i < n; i++) {
6528
6529
  const child = children[i].appliedPose;
6529
6530
  if (child.world === update) {
6531
+ if (child.local === update) child.updateLocalTransform(skeleton);
6530
6532
  child.world = 0;
6531
- child.local = 0;
6532
- child.resetWorld(update);
6533
+ child.resetWorld(skeleton, update);
6533
6534
  }
6534
6535
  }
6535
6536
  }
@@ -7322,8 +7323,9 @@ ${error}` : ""}`);
7322
7323
  const bone = this.slot.bone.appliedPose;
7323
7324
  offsetRotation *= bone.a * bone.d - bone.b * bone.c > 0 ? MathUtils.degRad : -MathUtils.degRad;
7324
7325
  }
7325
- for (let i = 0, ip = 3, u = skeleton._update; i < boneCount; i++, ip += 3) {
7326
+ for (let i = 0, ip = 3; i < boneCount; i++, ip += 3) {
7326
7327
  const bone = bones[i];
7328
+ bone.modifyWorld(skeleton);
7327
7329
  bone.worldX += (boneX - bone.worldX) * mixX;
7328
7330
  bone.worldY += (boneY - bone.worldY) * mixY;
7329
7331
  const x = positions[ip], y = positions[ip + 1], dx = x - boneX, dy = y - boneY;
@@ -7367,7 +7369,6 @@ ${error}` : ""}`);
7367
7369
  bone.c = sin * a + cos * c;
7368
7370
  bone.d = sin * b + cos * d;
7369
7371
  }
7370
- bone.modifyWorld(u);
7371
7372
  }
7372
7373
  }
7373
7374
  computeWorldPositions(skeleton, path, spacesCount, tangents) {
@@ -8280,9 +8281,9 @@ ${error}` : ""}`);
8280
8281
  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;
8281
8282
  const bone = this.bone;
8282
8283
  let l = bone.bone.data.length, t = this.data.step, z = 0;
8284
+ if (physics === 0 /* none */) return;
8285
+ bone.modifyWorld(skeleton);
8283
8286
  switch (physics) {
8284
- case 0 /* none */:
8285
- return;
8286
8287
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: fall through expected
8287
8288
  case 1 /* reset */:
8288
8289
  this.reset(skeleton);
@@ -8460,7 +8461,6 @@ ${error}` : ""}`);
8460
8461
  this.tx = l * bone.a;
8461
8462
  this.ty = l * bone.c;
8462
8463
  }
8463
- bone.modifyWorld(skeleton._update);
8464
8464
  }
8465
8465
  sort(skeleton) {
8466
8466
  const bone = this.bone.bone;
@@ -9027,14 +9027,14 @@ ${error}` : ""}`);
9027
9027
  const source = this.source.appliedPose;
9028
9028
  if (localSource) source.validateLocalTransform(skeleton);
9029
9029
  const fromItems = data.properties;
9030
- const fn = data.properties.length, update = skeleton._update;
9030
+ const fn = data.properties.length;
9031
9031
  const bones = this.bones;
9032
9032
  for (let i = 0, n = this.bones.length; i < n; i++) {
9033
9033
  const bone = bones[i];
9034
9034
  if (localTarget)
9035
9035
  bone.modifyLocal(skeleton);
9036
9036
  else
9037
- bone.modifyWorld(update);
9037
+ bone.modifyWorld(skeleton);
9038
9038
  for (let f = 0; f < fn; f++) {
9039
9039
  const from = fromItems[f];
9040
9040
  const value = from.value(skeleton, source, localSource, offsets) - from.offset;
@@ -11262,7 +11262,7 @@ ${error}` : ""}`);
11262
11262
  t = triangles[i + 2];
11263
11263
  const x3 = vertices[t * stride], y3 = vertices[t * stride + 1];
11264
11264
  const u3 = uvs[t << 1], v3 = uvs[(t << 1) + 1];
11265
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11265
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11266
11266
  for (let p = 0; p < polygonsCount; p++) {
11267
11267
  let s = clippedVertices.length;
11268
11268
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11270,6 +11270,13 @@ ${error}` : ""}`);
11270
11270
  const clipOutputLength = clipOutput.length;
11271
11271
  if (clipOutputLength === 0) continue;
11272
11272
  let clipOutputCount = clipOutputLength >> 1;
11273
+ if (d === 0) {
11274
+ d0 = y2 - y3;
11275
+ d1 = x3 - x2;
11276
+ d2 = x1 - x3;
11277
+ d4 = y3 - y1;
11278
+ d = 1 / (d0 * d2 - d1 * d4);
11279
+ }
11273
11280
  const cv = Utils.setArraySize(clippedVertices, s + clipOutputCount * stride);
11274
11281
  for (let ii = 0; ii < clipOutputLength; ii += 2, s += stride) {
11275
11282
  const x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
@@ -11469,7 +11476,7 @@ ${error}` : ""}`);
11469
11476
  const x3 = vertices[vertexStart + v], y3 = vertices[vertexStart + v + 1];
11470
11477
  uv = t << 1;
11471
11478
  const u3 = uvs[uv], v3 = uvs[uv + 1];
11472
- const d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1, d = 1 / (d0 * d2 + d1 * (y1 - y3));
11479
+ let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
11473
11480
  for (let p = 0; p < polygonsCount; p++) {
11474
11481
  let s = this.clippedVerticesLength;
11475
11482
  if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
@@ -11477,6 +11484,13 @@ ${error}` : ""}`);
11477
11484
  const clipOutputLength = clipOutput.length;
11478
11485
  if (clipOutputLength === 0) continue;
11479
11486
  let clipOutputCount = clipOutputLength >> 1;
11487
+ if (d === 0) {
11488
+ d0 = y2 - y3;
11489
+ d1 = x3 - x2;
11490
+ d2 = x1 - x3;
11491
+ d4 = y3 - y1;
11492
+ d = 1 / (d0 * d2 - d1 * d4);
11493
+ }
11480
11494
  const newLength = s + clipOutputCount * stride;
11481
11495
  if (clippedVertices.length < newLength) {
11482
11496
  this._clippedVerticesTyped = new Float32Array(newLength * 2);
@@ -11593,16 +11607,15 @@ ${error}` : ""}`);
11593
11607
  const edgeX = v[i], edgeY = v[i + 1], ex = edgeX - v[i + 2], ey = edgeY - v[i + 3];
11594
11608
  const outputStart = output.length;
11595
11609
  const iv2 = input;
11596
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11597
- x1 = iv2[ii];
11598
- y1 = iv2[ii + 1];
11599
- ii += 2;
11610
+ x1 = iv2[0];
11611
+ y1 = iv2[1];
11612
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11613
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11600
11614
  x2 = iv2[ii];
11601
11615
  y2 = iv2[ii + 1];
11602
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11603
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11616
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11604
11617
  if (s1 > 0) {
11605
- if (s2)
11618
+ if (s2 > 0)
11606
11619
  output.push(x2, y2);
11607
11620
  else {
11608
11621
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11612,7 +11625,7 @@ ${error}` : ""}`);
11612
11625
  } else
11613
11626
  output.push(x2, y2);
11614
11627
  }
11615
- } else if (s2) {
11628
+ } else if (s2 > 0) {
11616
11629
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11617
11630
  if (t >= 0 && t <= 1) {
11618
11631
  output.push(x1 + ix * t, y1 + iy * t, x2, y2);
@@ -11621,6 +11634,9 @@ ${error}` : ""}`);
11621
11634
  output.push(x2, y2);
11622
11635
  } else
11623
11636
  clipped = true;
11637
+ x1 = x2;
11638
+ y1 = y2;
11639
+ s1 = s2;
11624
11640
  }
11625
11641
  if (outputStart === output.length) {
11626
11642
  originalOutput.length = 0;
@@ -11668,16 +11684,15 @@ ${error}` : ""}`);
11668
11684
  const outputStart = output.length, fragmentStart = this.inverseVertices.length;
11669
11685
  this.inverseVertices.push(0);
11670
11686
  iv = input;
11671
- for (let ii = 0, nn = input.length - 2; ii < nn; ) {
11672
- x1 = iv[ii];
11673
- y1 = iv[ii + 1];
11674
- ii += 2;
11687
+ x1 = iv[0];
11688
+ y1 = iv[1];
11689
+ let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11690
+ for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
11675
11691
  x2 = iv[ii];
11676
11692
  y2 = iv[ii + 1];
11677
- const s2 = ey * (edgeX - x2) > ex * (edgeY - y2);
11678
- const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
11693
+ const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
11679
11694
  if (s1 > 0) {
11680
- if (s2)
11695
+ if (s2 > 0)
11681
11696
  output.push(x2, y2);
11682
11697
  else {
11683
11698
  const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
@@ -11688,16 +11703,19 @@ ${error}` : ""}`);
11688
11703
  } else
11689
11704
  output.push(x2, y2);
11690
11705
  }
11691
- } else if (s2) {
11692
- const dx = x2 - x1, dy = y2 - y1, t = s1 / (dx * ey - dy * ex);
11706
+ } else if (s2 > 0) {
11707
+ const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
11693
11708
  if (t >= 0 && t <= 1) {
11694
- const cx = x1 + dx * t, cy = y1 + dy * t;
11709
+ const cx = x1 + ix * t, cy = y1 + iy * t;
11695
11710
  this.inverseVertices.push(cx, cy);
11696
11711
  output.push(cx, cy, x2, y2);
11697
11712
  } else
11698
11713
  output.push(x2, y2);
11699
11714
  } else
11700
11715
  this.inverseVertices.push(x2, y2);
11716
+ x1 = x2;
11717
+ y1 = y2;
11718
+ s1 = s2;
11701
11719
  }
11702
11720
  const fragmentSize = this.inverseVertices.length - fragmentStart - 1;
11703
11721
  if (fragmentSize >= 6)
@@ -13064,17 +13082,21 @@ ${error}` : ""}`);
13064
13082
  this.renderCommands.length = 0;
13065
13083
  const clipper = this.clipping;
13066
13084
  const drawOrder = skeleton.drawOrder.appliedPose;
13067
- for (let i = 0; i < skeleton.slots.length; i++) {
13085
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
13068
13086
  const slot = drawOrder[i];
13069
- const attachment = slot.appliedPose.attachment;
13070
- if (!attachment) {
13087
+ if (!slot.bone.active) {
13071
13088
  clipper.clipEnd(slot);
13072
13089
  continue;
13073
13090
  }
13074
13091
  const pose = slot.appliedPose;
13092
+ const attachment = pose.attachment;
13093
+ if (!attachment) {
13094
+ clipper.clipEnd(slot);
13095
+ continue;
13096
+ }
13075
13097
  const slotColor = pose.color;
13076
13098
  const alpha = slotColor.a;
13077
- if ((alpha === 0 || !slot.bone.active) && !(attachment instanceof ClippingAttachment)) {
13099
+ if (alpha === 0 && !(attachment instanceof ClippingAttachment)) {
13078
13100
  clipper.clipEnd(slot);
13079
13101
  continue;
13080
13102
  }
@@ -13118,9 +13140,15 @@ ${error}` : ""}`);
13118
13140
  indicesCount = indices.length;
13119
13141
  texture = sequence.regions[sequenceIndex]?.texture;
13120
13142
  } else if (attachment instanceof ClippingAttachment) {
13143
+ clipper.clipEnd(slot);
13121
13144
  clipper.clipStart(skeleton, slot, attachment);
13122
13145
  continue;
13123
13146
  } else {
13147
+ clipper.clipEnd(slot);
13148
+ continue;
13149
+ }
13150
+ if (!texture) {
13151
+ clipper.clipEnd(slot);
13124
13152
  continue;
13125
13153
  }
13126
13154
  const skelColor = skeleton.color;