@esotericsoftware/spine-webgl 4.2.48 → 4.2.50

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.
@@ -9716,7 +9716,7 @@ var spine = (() => {
9716
9716
  }
9717
9717
  };
9718
9718
  var BinaryInput = class {
9719
- constructor(data, strings = new Array(), index = 0, buffer = new DataView(data.buffer)) {
9719
+ constructor(data, strings = new Array(), index = 0, buffer = new DataView(data instanceof ArrayBuffer ? data : data.buffer)) {
9720
9720
  this.strings = strings;
9721
9721
  this.index = index;
9722
9722
  this.buffer = buffer;
@@ -10313,6 +10313,7 @@ var spine = (() => {
10313
10313
  clippingPolygon = new Array();
10314
10314
  clipOutput = new Array();
10315
10315
  clippedVertices = new Array();
10316
+ clippedUVs = new Array();
10316
10317
  clippedTriangles = new Array();
10317
10318
  scratch = new Array();
10318
10319
  clipAttachment = null;
@@ -10544,6 +10545,83 @@ var spine = (() => {
10544
10545
  }
10545
10546
  }
10546
10547
  }
10548
+ clipTrianglesUnpacked(vertices, triangles, trianglesLength, uvs) {
10549
+ let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices, clippedUVs = this.clippedUVs;
10550
+ let clippedTriangles = this.clippedTriangles;
10551
+ let polygons = this.clippingPolygons;
10552
+ let polygonsCount = polygons.length;
10553
+ let index = 0;
10554
+ clippedVertices.length = 0;
10555
+ clippedUVs.length = 0;
10556
+ clippedTriangles.length = 0;
10557
+ for (let i = 0; i < trianglesLength; i += 3) {
10558
+ let vertexOffset = triangles[i] << 1;
10559
+ let x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
10560
+ let u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
10561
+ vertexOffset = triangles[i + 1] << 1;
10562
+ let x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
10563
+ let u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
10564
+ vertexOffset = triangles[i + 2] << 1;
10565
+ let x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
10566
+ let u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
10567
+ for (let p = 0; p < polygonsCount; p++) {
10568
+ let s = clippedVertices.length;
10569
+ if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
10570
+ let clipOutputLength = clipOutput.length;
10571
+ if (clipOutputLength == 0)
10572
+ continue;
10573
+ let d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
10574
+ let d = 1 / (d0 * d2 + d1 * (y1 - y3));
10575
+ let clipOutputCount = clipOutputLength >> 1;
10576
+ let clipOutputItems = this.clipOutput;
10577
+ let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + clipOutputCount * 2);
10578
+ let clippedUVsItems = Utils.setArraySize(clippedUVs, s + clipOutputCount * 2);
10579
+ for (let ii = 0; ii < clipOutputLength; ii += 2, s += 2) {
10580
+ let x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
10581
+ clippedVerticesItems[s] = x;
10582
+ clippedVerticesItems[s + 1] = y;
10583
+ let c0 = x - x3, c1 = y - y3;
10584
+ let a = (d0 * c0 + d1 * c1) * d;
10585
+ let b = (d4 * c0 + d2 * c1) * d;
10586
+ let c = 1 - a - b;
10587
+ clippedUVsItems[s] = u1 * a + u2 * b + u3 * c;
10588
+ clippedUVsItems[s + 1] = v1 * a + v2 * b + v3 * c;
10589
+ }
10590
+ s = clippedTriangles.length;
10591
+ let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
10592
+ clipOutputCount--;
10593
+ for (let ii = 1; ii < clipOutputCount; ii++, s += 3) {
10594
+ clippedTrianglesItems[s] = index;
10595
+ clippedTrianglesItems[s + 1] = index + ii;
10596
+ clippedTrianglesItems[s + 2] = index + ii + 1;
10597
+ }
10598
+ index += clipOutputCount + 1;
10599
+ } else {
10600
+ let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + 3 * 2);
10601
+ clippedVerticesItems[s] = x1;
10602
+ clippedVerticesItems[s + 1] = y1;
10603
+ clippedVerticesItems[s + 2] = x2;
10604
+ clippedVerticesItems[s + 3] = y2;
10605
+ clippedVerticesItems[s + 4] = x3;
10606
+ clippedVerticesItems[s + 5] = y3;
10607
+ let clippedUVSItems = Utils.setArraySize(clippedUVs, s + 3 * 2);
10608
+ clippedUVSItems[s] = u1;
10609
+ clippedUVSItems[s + 1] = v1;
10610
+ clippedUVSItems[s + 2] = u2;
10611
+ clippedUVSItems[s + 3] = v2;
10612
+ clippedUVSItems[s + 4] = u3;
10613
+ clippedUVSItems[s + 5] = v3;
10614
+ s = clippedTriangles.length;
10615
+ let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3);
10616
+ clippedTrianglesItems[s] = index;
10617
+ clippedTrianglesItems[s + 1] = index + 1;
10618
+ clippedTrianglesItems[s + 2] = index + 2;
10619
+ index += 3;
10620
+ break;
10621
+ }
10622
+ }
10623
+ }
10624
+ }
10547
10625
  /** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
10548
10626
  * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
10549
10627
  clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {