@esotericsoftware/spine-canvas 4.2.48 → 4.2.49
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.
|
@@ -9676,7 +9676,7 @@ var spine = (() => {
|
|
|
9676
9676
|
}
|
|
9677
9677
|
};
|
|
9678
9678
|
var BinaryInput = class {
|
|
9679
|
-
constructor(data, strings = new Array(), index = 0, buffer = new DataView(data.buffer)) {
|
|
9679
|
+
constructor(data, strings = new Array(), index = 0, buffer = new DataView(data instanceof ArrayBuffer ? data : data.buffer)) {
|
|
9680
9680
|
this.strings = strings;
|
|
9681
9681
|
this.index = index;
|
|
9682
9682
|
this.buffer = buffer;
|
|
@@ -10273,6 +10273,7 @@ var spine = (() => {
|
|
|
10273
10273
|
clippingPolygon = new Array();
|
|
10274
10274
|
clipOutput = new Array();
|
|
10275
10275
|
clippedVertices = new Array();
|
|
10276
|
+
clippedUVs = new Array();
|
|
10276
10277
|
clippedTriangles = new Array();
|
|
10277
10278
|
scratch = new Array();
|
|
10278
10279
|
clipAttachment = null;
|
|
@@ -10504,6 +10505,83 @@ var spine = (() => {
|
|
|
10504
10505
|
}
|
|
10505
10506
|
}
|
|
10506
10507
|
}
|
|
10508
|
+
clipTrianglesUnpacked(vertices, triangles, trianglesLength, uvs) {
|
|
10509
|
+
let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices, clippedUVs = this.clippedUVs;
|
|
10510
|
+
let clippedTriangles = this.clippedTriangles;
|
|
10511
|
+
let polygons = this.clippingPolygons;
|
|
10512
|
+
let polygonsCount = polygons.length;
|
|
10513
|
+
let index = 0;
|
|
10514
|
+
clippedVertices.length = 0;
|
|
10515
|
+
clippedUVs.length = 0;
|
|
10516
|
+
clippedTriangles.length = 0;
|
|
10517
|
+
for (let i = 0; i < trianglesLength; i += 3) {
|
|
10518
|
+
let vertexOffset = triangles[i] << 1;
|
|
10519
|
+
let x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
|
|
10520
|
+
let u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
|
|
10521
|
+
vertexOffset = triangles[i + 1] << 1;
|
|
10522
|
+
let x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
|
|
10523
|
+
let u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
|
|
10524
|
+
vertexOffset = triangles[i + 2] << 1;
|
|
10525
|
+
let x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
|
10526
|
+
let u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
|
10527
|
+
for (let p = 0; p < polygonsCount; p++) {
|
|
10528
|
+
let s = clippedVertices.length;
|
|
10529
|
+
if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
|
|
10530
|
+
let clipOutputLength = clipOutput.length;
|
|
10531
|
+
if (clipOutputLength == 0)
|
|
10532
|
+
continue;
|
|
10533
|
+
let d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
|
|
10534
|
+
let d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
|
10535
|
+
let clipOutputCount = clipOutputLength >> 1;
|
|
10536
|
+
let clipOutputItems = this.clipOutput;
|
|
10537
|
+
let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + clipOutputCount * 2);
|
|
10538
|
+
let clippedUVsItems = Utils.setArraySize(clippedUVs, s + clipOutputCount * 2);
|
|
10539
|
+
for (let ii = 0; ii < clipOutputLength; ii += 2, s += 2) {
|
|
10540
|
+
let x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
|
|
10541
|
+
clippedVerticesItems[s] = x;
|
|
10542
|
+
clippedVerticesItems[s + 1] = y;
|
|
10543
|
+
let c0 = x - x3, c1 = y - y3;
|
|
10544
|
+
let a = (d0 * c0 + d1 * c1) * d;
|
|
10545
|
+
let b = (d4 * c0 + d2 * c1) * d;
|
|
10546
|
+
let c = 1 - a - b;
|
|
10547
|
+
clippedUVsItems[s] = u1 * a + u2 * b + u3 * c;
|
|
10548
|
+
clippedUVsItems[s + 1] = v1 * a + v2 * b + v3 * c;
|
|
10549
|
+
}
|
|
10550
|
+
s = clippedTriangles.length;
|
|
10551
|
+
let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
|
|
10552
|
+
clipOutputCount--;
|
|
10553
|
+
for (let ii = 1; ii < clipOutputCount; ii++, s += 3) {
|
|
10554
|
+
clippedTrianglesItems[s] = index;
|
|
10555
|
+
clippedTrianglesItems[s + 1] = index + ii;
|
|
10556
|
+
clippedTrianglesItems[s + 2] = index + ii + 1;
|
|
10557
|
+
}
|
|
10558
|
+
index += clipOutputCount + 1;
|
|
10559
|
+
} else {
|
|
10560
|
+
let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + 3 * 2);
|
|
10561
|
+
clippedVerticesItems[s] = x1;
|
|
10562
|
+
clippedVerticesItems[s + 1] = y1;
|
|
10563
|
+
clippedVerticesItems[s + 2] = x2;
|
|
10564
|
+
clippedVerticesItems[s + 3] = y2;
|
|
10565
|
+
clippedVerticesItems[s + 4] = x3;
|
|
10566
|
+
clippedVerticesItems[s + 5] = y3;
|
|
10567
|
+
let clippedUVSItems = Utils.setArraySize(clippedUVs, s + 3 * 2);
|
|
10568
|
+
clippedUVSItems[s] = u1;
|
|
10569
|
+
clippedUVSItems[s + 1] = v1;
|
|
10570
|
+
clippedUVSItems[s + 2] = u2;
|
|
10571
|
+
clippedUVSItems[s + 3] = v2;
|
|
10572
|
+
clippedUVSItems[s + 4] = u3;
|
|
10573
|
+
clippedUVSItems[s + 5] = v3;
|
|
10574
|
+
s = clippedTriangles.length;
|
|
10575
|
+
let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3);
|
|
10576
|
+
clippedTrianglesItems[s] = index;
|
|
10577
|
+
clippedTrianglesItems[s + 1] = index + 1;
|
|
10578
|
+
clippedTrianglesItems[s + 2] = index + 2;
|
|
10579
|
+
index += 3;
|
|
10580
|
+
break;
|
|
10581
|
+
}
|
|
10582
|
+
}
|
|
10583
|
+
}
|
|
10584
|
+
}
|
|
10507
10585
|
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
|
|
10508
10586
|
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
|
|
10509
10587
|
clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {
|