@esotericsoftware/spine-canvaskit 4.2.54 → 4.2.56

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.
@@ -11760,7 +11760,7 @@ var spine = (() => {
11760
11760
  case 1 /* Additive */:
11761
11761
  return ck.BlendMode.Plus;
11762
11762
  case 2 /* Multiply */:
11763
- return ck.BlendMode.Modulate;
11763
+ return ck.BlendMode.SrcOver;
11764
11764
  case 3 /* Screen */:
11765
11765
  return ck.BlendMode.Screen;
11766
11766
  default:
@@ -11804,9 +11804,19 @@ var spine = (() => {
11804
11804
  throw new Error(`Could not load image ${path}`);
11805
11805
  const paintPerBlendMode = /* @__PURE__ */ new Map();
11806
11806
  const shaders = [];
11807
- for (const blendMode of [0 /* Normal */, 1 /* Additive */, 2 /* Multiply */, 3 /* Screen */]) {
11807
+ for (const blendMode of [
11808
+ 0 /* Normal */,
11809
+ 1 /* Additive */,
11810
+ 2 /* Multiply */,
11811
+ 3 /* Screen */
11812
+ ]) {
11808
11813
  const paint = new ck.Paint();
11809
- const shader = image.makeShaderOptions(ck.TileMode.Clamp, ck.TileMode.Clamp, ck.FilterMode.Linear, ck.MipmapMode.Linear);
11814
+ const shader = image.makeShaderOptions(
11815
+ ck.TileMode.Clamp,
11816
+ ck.TileMode.Clamp,
11817
+ ck.FilterMode.Linear,
11818
+ ck.MipmapMode.Linear
11819
+ );
11810
11820
  paint.setShader(shader);
11811
11821
  paint.setBlendMode(toCkBlendMode(ck, blendMode));
11812
11822
  paintPerBlendMode.set(blendMode, paint);
@@ -11820,15 +11830,24 @@ var spine = (() => {
11820
11830
  const slashIndex = atlasFile.lastIndexOf("/");
11821
11831
  const parentDir = slashIndex >= 0 ? atlasFile.substring(0, slashIndex + 1) + "/" : "";
11822
11832
  for (const page of atlas.pages) {
11823
- const texture = await CanvasKitTexture.fromFile(ck, parentDir + page.name, readFile);
11833
+ const texture = await CanvasKitTexture.fromFile(
11834
+ ck,
11835
+ parentDir + page.name,
11836
+ readFile
11837
+ );
11824
11838
  page.setTexture(texture);
11825
11839
  }
11826
11840
  return atlas;
11827
11841
  }
11828
- async function loadSkeletonData(skeletonFile, atlas, readFile) {
11842
+ async function loadSkeletonData(skeletonFile, atlas, readFile, scale = 1) {
11829
11843
  const attachmentLoader = new AtlasAttachmentLoader(atlas);
11830
11844
  const loader = skeletonFile.endsWith(".json") ? new SkeletonJson(attachmentLoader) : new SkeletonBinary(attachmentLoader);
11831
- const skeletonData = loader.readSkeletonData(await readFile(skeletonFile));
11845
+ loader.scale = scale;
11846
+ let data = await readFile(skeletonFile);
11847
+ if (skeletonFile.endsWith(".json")) {
11848
+ data = bufferToUtf8String(data);
11849
+ }
11850
+ const skeletonData = loader.readSkeletonData(data);
11832
11851
  return skeletonData;
11833
11852
  }
11834
11853
  var SkeletonDrawable = class {
@@ -11839,7 +11858,9 @@ var spine = (() => {
11839
11858
  */
11840
11859
  constructor(skeletonData) {
11841
11860
  this.skeleton = new Skeleton(skeletonData);
11842
- this.animationState = new AnimationState(new AnimationStateData(skeletonData));
11861
+ this.animationState = new AnimationState(
11862
+ new AnimationStateData(skeletonData)
11863
+ );
11843
11864
  }
11844
11865
  /**
11845
11866
  * Updates the animation state and skeleton time by the delta time. Applies the
@@ -11907,7 +11928,14 @@ var spine = (() => {
11907
11928
  let mesh = attachment;
11908
11929
  positions = positions.length < mesh.worldVerticesLength ? Utils.newFloatArray(mesh.worldVerticesLength) : positions;
11909
11930
  numVertices = mesh.worldVerticesLength >> 1;
11910
- mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, positions, 0, 2);
11931
+ mesh.computeWorldVertices(
11932
+ slot,
11933
+ 0,
11934
+ mesh.worldVerticesLength,
11935
+ positions,
11936
+ 0,
11937
+ 2
11938
+ );
11911
11939
  triangles = mesh.triangles;
11912
11940
  texture = mesh.region?.texture;
11913
11941
  uvs = mesh.uvs;
@@ -11922,7 +11950,12 @@ var spine = (() => {
11922
11950
  }
11923
11951
  if (texture) {
11924
11952
  if (clipper.isClipping()) {
11925
- clipper.clipTrianglesUnpacked(positions, triangles, triangles.length, uvs);
11953
+ clipper.clipTrianglesUnpacked(
11954
+ positions,
11955
+ triangles,
11956
+ triangles.length,
11957
+ uvs
11958
+ );
11926
11959
  positions = clipper.clippedVertices;
11927
11960
  uvs = clipper.clippedUVs;
11928
11961
  triangles = clipper.clippedTriangles;
@@ -11949,8 +11982,19 @@ var spine = (() => {
11949
11982
  scaledUvs[i2 + 1] = uvs[i2 + 1] * height;
11950
11983
  }
11951
11984
  const blendMode = slot.data.blendMode;
11952
- const vertices = this.ck.MakeVertices(this.ck.VertexMode.Triangles, positions, scaledUvs, colors, triangles, false);
11953
- canvas.drawVertices(vertices, this.ck.BlendMode.Modulate, texture.getImage().paintPerBlendMode.get(blendMode));
11985
+ const vertices = this.ck.MakeVertices(
11986
+ this.ck.VertexMode.Triangles,
11987
+ positions,
11988
+ scaledUvs,
11989
+ colors,
11990
+ triangles,
11991
+ false
11992
+ );
11993
+ canvas.drawVertices(
11994
+ vertices,
11995
+ this.ck.BlendMode.Modulate,
11996
+ texture.getImage().paintPerBlendMode.get(blendMode)
11997
+ );
11954
11998
  vertices.delete();
11955
11999
  }
11956
12000
  clipper.clipEndWithSlot(slot);