@esotericsoftware/spine-canvaskit 4.2.87 → 4.2.88

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.
@@ -4552,21 +4552,21 @@ var spine = (() => {
4552
4552
  return this._image;
4553
4553
  }
4554
4554
  };
4555
- var TextureFilter = /* @__PURE__ */ ((TextureFilter3) => {
4556
- TextureFilter3[TextureFilter3["Nearest"] = 9728] = "Nearest";
4557
- TextureFilter3[TextureFilter3["Linear"] = 9729] = "Linear";
4558
- TextureFilter3[TextureFilter3["MipMap"] = 9987] = "MipMap";
4559
- TextureFilter3[TextureFilter3["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
4560
- TextureFilter3[TextureFilter3["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
4561
- TextureFilter3[TextureFilter3["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
4562
- TextureFilter3[TextureFilter3["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
4563
- return TextureFilter3;
4555
+ var TextureFilter = /* @__PURE__ */ ((TextureFilter2) => {
4556
+ TextureFilter2[TextureFilter2["Nearest"] = 9728] = "Nearest";
4557
+ TextureFilter2[TextureFilter2["Linear"] = 9729] = "Linear";
4558
+ TextureFilter2[TextureFilter2["MipMap"] = 9987] = "MipMap";
4559
+ TextureFilter2[TextureFilter2["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
4560
+ TextureFilter2[TextureFilter2["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
4561
+ TextureFilter2[TextureFilter2["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
4562
+ TextureFilter2[TextureFilter2["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
4563
+ return TextureFilter2;
4564
4564
  })(TextureFilter || {});
4565
- var TextureWrap = /* @__PURE__ */ ((TextureWrap3) => {
4566
- TextureWrap3[TextureWrap3["MirroredRepeat"] = 33648] = "MirroredRepeat";
4567
- TextureWrap3[TextureWrap3["ClampToEdge"] = 33071] = "ClampToEdge";
4568
- TextureWrap3[TextureWrap3["Repeat"] = 10497] = "Repeat";
4569
- return TextureWrap3;
4565
+ var TextureWrap = /* @__PURE__ */ ((TextureWrap2) => {
4566
+ TextureWrap2[TextureWrap2["MirroredRepeat"] = 33648] = "MirroredRepeat";
4567
+ TextureWrap2[TextureWrap2["ClampToEdge"] = 33071] = "ClampToEdge";
4568
+ TextureWrap2[TextureWrap2["Repeat"] = 10497] = "Repeat";
4569
+ return TextureWrap2;
4570
4570
  })(TextureWrap || {});
4571
4571
  var TextureRegion = class {
4572
4572
  texture;
@@ -11455,9 +11455,9 @@ var spine = (() => {
11455
11455
  getImage() {
11456
11456
  return this._image;
11457
11457
  }
11458
- setFilters(minFilter, magFilter) {
11458
+ setFilters() {
11459
11459
  }
11460
- setWraps(uWrap, vWrap) {
11460
+ setWraps() {
11461
11461
  }
11462
11462
  dispose() {
11463
11463
  const data = this._image;
@@ -11516,12 +11516,11 @@ var spine = (() => {
11516
11516
  const attachmentLoader = new AtlasAttachmentLoader(atlas);
11517
11517
  const loader = skeletonFile.endsWith(".json") ? new SkeletonJson(attachmentLoader) : new SkeletonBinary(attachmentLoader);
11518
11518
  loader.scale = scale;
11519
- let data = await readFile(skeletonFile);
11520
- if (skeletonFile.endsWith(".json")) {
11521
- data = bufferToUtf8String(data);
11519
+ const data = await readFile(skeletonFile);
11520
+ if (loader instanceof SkeletonJson) {
11521
+ return loader.readSkeletonData(bufferToUtf8String(data));
11522
11522
  }
11523
- const skeletonData = loader.readSkeletonData(data);
11524
- return skeletonData;
11523
+ return loader.readSkeletonData(data);
11525
11524
  }
11526
11525
  var SkeletonDrawable = class {
11527
11526
  skeleton;
@@ -11558,12 +11557,10 @@ var spine = (() => {
11558
11557
  this.ck = ck;
11559
11558
  }
11560
11559
  clipper = new SkeletonClipping();
11561
- tempColor = new Color();
11562
- tempColor2 = new Color();
11563
11560
  static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
11564
11561
  scratchPositions = Utils.newFloatArray(100);
11565
- scratchColors = Utils.newFloatArray(100);
11566
11562
  scratchUVs = Utils.newFloatArray(100);
11563
+ scratchColors = new Uint32Array(100 / 4);
11567
11564
  /**
11568
11565
  * Renders a skeleton or skeleton drawable in its current pose to the canvas.
11569
11566
  * @param canvas the canvas to render to.
@@ -11571,100 +11568,79 @@ var spine = (() => {
11571
11568
  */
11572
11569
  render(canvas, skeleton) {
11573
11570
  if (skeleton instanceof SkeletonDrawable) skeleton = skeleton.skeleton;
11574
- let clipper = this.clipper;
11575
- let drawOrder = skeleton.drawOrder;
11576
- let skeletonColor = skeleton.color;
11571
+ const clipper = this.clipper;
11572
+ const drawOrder = skeleton.drawOrder;
11573
+ const skeletonColor = skeleton.color;
11577
11574
  for (let i = 0, n = drawOrder.length; i < n; i++) {
11578
- let slot = drawOrder[i];
11575
+ const slot = drawOrder[i];
11579
11576
  if (!slot.bone.active) {
11580
11577
  clipper.clipEndWithSlot(slot);
11581
11578
  continue;
11582
11579
  }
11583
- let attachment = slot.getAttachment();
11580
+ const attachment = slot.getAttachment();
11584
11581
  let positions = this.scratchPositions;
11585
- let colors = this.scratchColors;
11586
- let uvs;
11587
- let texture;
11588
11582
  let triangles;
11589
- let attachmentColor;
11590
- let numVertices = 0;
11583
+ let numVertices = 4;
11591
11584
  if (attachment instanceof RegionAttachment) {
11592
- let region = attachment;
11593
- if (positions.length < 8) this.scratchPositions = positions = Utils.newFloatArray(8);
11594
- numVertices = 4;
11595
- region.computeWorldVertices(slot, positions, 0, 2);
11585
+ attachment.computeWorldVertices(slot, positions, 0, 2);
11596
11586
  triangles = _SkeletonRenderer.QUAD_TRIANGLES;
11597
- uvs = region.uvs;
11598
- texture = region.region?.texture;
11599
- attachmentColor = region.color;
11600
11587
  } else if (attachment instanceof MeshAttachment) {
11601
- let mesh = attachment;
11602
- if (positions.length < mesh.worldVerticesLength)
11603
- this.scratchPositions = positions = Utils.newFloatArray(mesh.worldVerticesLength);
11604
- numVertices = mesh.worldVerticesLength >> 1;
11605
- mesh.computeWorldVertices(
11588
+ if (positions.length < attachment.worldVerticesLength) {
11589
+ this.scratchPositions = Utils.newFloatArray(attachment.worldVerticesLength);
11590
+ positions = this.scratchPositions;
11591
+ }
11592
+ numVertices = attachment.worldVerticesLength >> 1;
11593
+ attachment.computeWorldVertices(
11606
11594
  slot,
11607
11595
  0,
11608
- mesh.worldVerticesLength,
11596
+ attachment.worldVerticesLength,
11609
11597
  positions,
11610
11598
  0,
11611
11599
  2
11612
11600
  );
11613
- triangles = mesh.triangles;
11614
- texture = mesh.region?.texture;
11615
- uvs = mesh.uvs;
11616
- attachmentColor = mesh.color;
11601
+ triangles = attachment.triangles;
11617
11602
  } else if (attachment instanceof ClippingAttachment) {
11618
- let clip = attachment;
11619
- clipper.clipStart(slot, clip);
11603
+ clipper.clipStart(slot, attachment);
11620
11604
  continue;
11621
11605
  } else {
11622
11606
  clipper.clipEndWithSlot(slot);
11623
11607
  continue;
11624
11608
  }
11609
+ const texture = attachment.region?.texture;
11625
11610
  if (texture) {
11611
+ let uvs = attachment.uvs;
11612
+ let scaledUvs;
11613
+ let colors = this.scratchColors;
11626
11614
  if (clipper.isClipping()) {
11627
- clipper.clipTrianglesUnpacked(
11628
- positions,
11629
- triangles,
11630
- triangles.length,
11631
- uvs
11632
- );
11633
- if (clipper.clippedVertices.length > 0) {
11634
- if (positions.length < clipper.clippedVertices.length)
11635
- this.scratchPositions = positions = Utils.newFloatArray(clipper.clippedVertices.length);
11636
- numVertices = clipper.clippedVertices.length / 2;
11637
- for (let i2 = 0; i2 < clipper.clippedVertices.length; i2++)
11638
- positions[i2] = clipper.clippedVertices[i2];
11639
- uvs = clipper.clippedUVs;
11640
- triangles = clipper.clippedTriangles;
11641
- } else {
11615
+ clipper.clipTrianglesUnpacked(positions, triangles, triangles.length, uvs);
11616
+ if (clipper.clippedVertices.length <= 0) {
11642
11617
  clipper.clipEndWithSlot(slot);
11643
11618
  continue;
11644
11619
  }
11620
+ positions = clipper.clippedVertices;
11621
+ uvs = scaledUvs = clipper.clippedUVs;
11622
+ triangles = clipper.clippedTriangles;
11623
+ numVertices = clipper.clippedVertices.length / 2;
11624
+ colors = new Uint32Array(numVertices);
11625
+ } else {
11626
+ scaledUvs = this.scratchUVs;
11627
+ if (this.scratchUVs.length < uvs.length)
11628
+ scaledUvs = this.scratchUVs = Utils.newFloatArray(uvs.length);
11629
+ if (colors.length < numVertices)
11630
+ colors = this.scratchColors = new Uint32Array(numVertices);
11645
11631
  }
11646
- let slotColor = slot.color;
11647
- let finalColor = this.tempColor;
11648
- finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
11649
- finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
11650
- finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
11651
- finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
11652
- if (colors.length / 4 < numVertices)
11653
- this.scratchColors = colors = Utils.newFloatArray(numVertices * 4);
11654
- for (let i2 = 0, n2 = numVertices * 4; i2 < n2; i2 += 4) {
11655
- colors[i2] = finalColor.r;
11656
- colors[i2 + 1] = finalColor.g;
11657
- colors[i2 + 2] = finalColor.b;
11658
- colors[i2 + 3] = finalColor.a;
11659
- }
11660
- const scaledUvs = this.scratchUVs.length < uvs.length ? this.scratchUVs = Utils.newFloatArray(uvs.length) : this.scratchUVs;
11661
- const width = texture.getImage().image.width();
11662
- const height = texture.getImage().image.height();
11632
+ const ckImage = texture.getImage();
11633
+ const image = ckImage.image;
11634
+ const width = image.width();
11635
+ const height = image.height();
11663
11636
  for (let i2 = 0; i2 < uvs.length; i2 += 2) {
11664
11637
  scaledUvs[i2] = uvs[i2] * width;
11665
11638
  scaledUvs[i2 + 1] = uvs[i2 + 1] * height;
11666
11639
  }
11667
- const blendMode = slot.data.blendMode;
11640
+ const attachmentColor = attachment.color;
11641
+ const slotColor = slot.color;
11642
+ const finalColor = (MathUtils.clamp(skeletonColor.a * slotColor.a * attachmentColor.a * 255, 0, 255) << 24 | MathUtils.clamp(skeletonColor.r * slotColor.r * attachmentColor.r * 255, 0, 255) << 16 | MathUtils.clamp(skeletonColor.g * slotColor.g * attachmentColor.g * 255, 0, 255) << 8 | MathUtils.clamp(skeletonColor.b * slotColor.b * attachmentColor.b * 255, 0, 255) << 0) >>> 0;
11643
+ for (let i2 = 0, n2 = numVertices; i2 < n2; i2++) colors[i2] = finalColor;
11668
11644
  const vertices = this.ck.MakeVertices(
11669
11645
  this.ck.VertexMode.Triangles,
11670
11646
  positions,
@@ -11673,11 +11649,8 @@ var spine = (() => {
11673
11649
  triangles,
11674
11650
  false
11675
11651
  );
11676
- canvas.drawVertices(
11677
- vertices,
11678
- this.ck.BlendMode.Modulate,
11679
- texture.getImage().paintPerBlendMode.get(blendMode)
11680
- );
11652
+ const ckPaint = ckImage.paintPerBlendMode.get(slot.data.blendMode);
11653
+ if (ckPaint) canvas.drawVertices(vertices, this.ck.BlendMode.Modulate, ckPaint);
11681
11654
  vertices.delete();
11682
11655
  }
11683
11656
  clipper.clipEndWithSlot(slot);