@esotericsoftware/spine-canvaskit 4.2.55 → 4.2.57
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.
- package/dist/iife/spine-canvaskit.js +94 -24
- package/dist/iife/spine-canvaskit.js.map +2 -2
- package/dist/iife/spine-canvaskit.min.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -21
- package/package.json +2 -2
|
@@ -1554,6 +1554,11 @@ var spine = (() => {
|
|
|
1554
1554
|
let bone = skeleton.bones[this.boneIndex];
|
|
1555
1555
|
if (!bone.active)
|
|
1556
1556
|
return;
|
|
1557
|
+
if (direction == 1 /* mixOut */) {
|
|
1558
|
+
if (blend == 0 /* setup */)
|
|
1559
|
+
bone.inherit = bone.data.inherit;
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1557
1562
|
let frames = this.frames;
|
|
1558
1563
|
if (time < frames[0]) {
|
|
1559
1564
|
if (blend == 0 /* setup */ || blend == 1 /* first */)
|
|
@@ -6415,8 +6420,9 @@ var spine = (() => {
|
|
|
6415
6420
|
q = -(c1 + q) * 0.5;
|
|
6416
6421
|
let r0 = q / c2, r1 = c / q;
|
|
6417
6422
|
let r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
|
|
6418
|
-
|
|
6419
|
-
|
|
6423
|
+
r0 = dd - r * r;
|
|
6424
|
+
if (r0 >= 0) {
|
|
6425
|
+
y = Math.sqrt(r0) * bendDir;
|
|
6420
6426
|
a1 = ta - Math.atan2(y, r);
|
|
6421
6427
|
a2 = Math.atan2(y / psy, (r - l1) / psx);
|
|
6422
6428
|
break outer;
|
|
@@ -7099,25 +7105,28 @@ var spine = (() => {
|
|
|
7099
7105
|
case 1 /* reset */:
|
|
7100
7106
|
this.reset();
|
|
7101
7107
|
case 2 /* update */:
|
|
7108
|
+
const skeleton = this.skeleton;
|
|
7102
7109
|
const delta = Math.max(this.skeleton.time - this.lastTime, 0);
|
|
7103
7110
|
this.remaining += delta;
|
|
7104
|
-
this.lastTime =
|
|
7111
|
+
this.lastTime = skeleton.time;
|
|
7105
7112
|
const bx = bone.worldX, by = bone.worldY;
|
|
7106
7113
|
if (this._reset) {
|
|
7107
7114
|
this._reset = false;
|
|
7108
7115
|
this.ux = bx;
|
|
7109
7116
|
this.uy = by;
|
|
7110
7117
|
} else {
|
|
7111
|
-
let a = this.remaining, i = this.inertia,
|
|
7118
|
+
let a = this.remaining, i = this.inertia, t = this.data.step, f = this.skeleton.data.referenceScale, d = -1;
|
|
7119
|
+
let qx = this.data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
|
|
7120
|
+
qx *= Math.abs(skeleton.scaleX);
|
|
7112
7121
|
if (x || y) {
|
|
7113
7122
|
if (x) {
|
|
7114
7123
|
const u = (this.ux - bx) * i;
|
|
7115
|
-
this.xOffset += u >
|
|
7124
|
+
this.xOffset += u > qx ? qx : u < -qx ? -qx : u;
|
|
7116
7125
|
this.ux = bx;
|
|
7117
7126
|
}
|
|
7118
7127
|
if (y) {
|
|
7119
7128
|
const u = (this.uy - by) * i;
|
|
7120
|
-
this.yOffset += u >
|
|
7129
|
+
this.yOffset += u > qy ? qy : u < -qy ? -qy : u;
|
|
7121
7130
|
this.uy = by;
|
|
7122
7131
|
}
|
|
7123
7132
|
if (a >= t) {
|
|
@@ -7145,14 +7154,14 @@ var spine = (() => {
|
|
|
7145
7154
|
if (rotateOrShearX || scaleX) {
|
|
7146
7155
|
let ca = Math.atan2(bone.c, bone.a), c = 0, s = 0, mr = 0;
|
|
7147
7156
|
let dx = this.cx - bone.worldX, dy = this.cy - bone.worldY;
|
|
7148
|
-
if (dx >
|
|
7149
|
-
dx =
|
|
7150
|
-
else if (dx < -
|
|
7151
|
-
dx = -
|
|
7152
|
-
if (dy >
|
|
7153
|
-
dy =
|
|
7154
|
-
else if (dy < -
|
|
7155
|
-
dy = -
|
|
7157
|
+
if (dx > qx)
|
|
7158
|
+
dx = qx;
|
|
7159
|
+
else if (dx < -qx)
|
|
7160
|
+
dx = -qx;
|
|
7161
|
+
if (dy > qy)
|
|
7162
|
+
dy = qy;
|
|
7163
|
+
else if (dy < -qy)
|
|
7164
|
+
dy = -qy;
|
|
7156
7165
|
if (rotateOrShearX) {
|
|
7157
7166
|
mr = (this.data.rotate + this.data.shearX) * mix;
|
|
7158
7167
|
let r = Math.atan2(dy + this.ty, dx + this.tx) - ca - this.rotateOffset * mr;
|
|
@@ -10313,7 +10322,28 @@ var spine = (() => {
|
|
|
10313
10322
|
isClipping() {
|
|
10314
10323
|
return this.clipAttachment != null;
|
|
10315
10324
|
}
|
|
10316
|
-
clipTriangles(vertices,
|
|
10325
|
+
clipTriangles(vertices, verticesLengthOrTriangles, trianglesOrTrianglesLength, trianglesLengthOrUvs, uvsOrLight, lightOrDark, darkOrTwoColor, twoColorParam) {
|
|
10326
|
+
let triangles;
|
|
10327
|
+
let trianglesLength;
|
|
10328
|
+
let uvs;
|
|
10329
|
+
let light;
|
|
10330
|
+
let dark;
|
|
10331
|
+
let twoColor;
|
|
10332
|
+
if (typeof verticesLengthOrTriangles === "number") {
|
|
10333
|
+
triangles = trianglesOrTrianglesLength;
|
|
10334
|
+
trianglesLength = trianglesLengthOrUvs;
|
|
10335
|
+
uvs = uvsOrLight;
|
|
10336
|
+
light = lightOrDark;
|
|
10337
|
+
dark = darkOrTwoColor;
|
|
10338
|
+
twoColor = twoColorParam;
|
|
10339
|
+
} else {
|
|
10340
|
+
triangles = verticesLengthOrTriangles;
|
|
10341
|
+
trianglesLength = trianglesOrTrianglesLength;
|
|
10342
|
+
uvs = trianglesLengthOrUvs;
|
|
10343
|
+
light = uvsOrLight;
|
|
10344
|
+
dark = lightOrDark;
|
|
10345
|
+
twoColor = darkOrTwoColor;
|
|
10346
|
+
}
|
|
10317
10347
|
if (uvs && light && dark && typeof twoColor === "boolean")
|
|
10318
10348
|
this.clipTrianglesRender(vertices, triangles, trianglesLength, uvs, light, dark, twoColor);
|
|
10319
10349
|
else
|
|
@@ -11804,9 +11834,19 @@ var spine = (() => {
|
|
|
11804
11834
|
throw new Error(`Could not load image ${path}`);
|
|
11805
11835
|
const paintPerBlendMode = /* @__PURE__ */ new Map();
|
|
11806
11836
|
const shaders = [];
|
|
11807
|
-
for (const blendMode of [
|
|
11837
|
+
for (const blendMode of [
|
|
11838
|
+
0 /* Normal */,
|
|
11839
|
+
1 /* Additive */,
|
|
11840
|
+
2 /* Multiply */,
|
|
11841
|
+
3 /* Screen */
|
|
11842
|
+
]) {
|
|
11808
11843
|
const paint = new ck.Paint();
|
|
11809
|
-
const shader = image.makeShaderOptions(
|
|
11844
|
+
const shader = image.makeShaderOptions(
|
|
11845
|
+
ck.TileMode.Clamp,
|
|
11846
|
+
ck.TileMode.Clamp,
|
|
11847
|
+
ck.FilterMode.Linear,
|
|
11848
|
+
ck.MipmapMode.Linear
|
|
11849
|
+
);
|
|
11810
11850
|
paint.setShader(shader);
|
|
11811
11851
|
paint.setBlendMode(toCkBlendMode(ck, blendMode));
|
|
11812
11852
|
paintPerBlendMode.set(blendMode, paint);
|
|
@@ -11820,14 +11860,19 @@ var spine = (() => {
|
|
|
11820
11860
|
const slashIndex = atlasFile.lastIndexOf("/");
|
|
11821
11861
|
const parentDir = slashIndex >= 0 ? atlasFile.substring(0, slashIndex + 1) + "/" : "";
|
|
11822
11862
|
for (const page of atlas.pages) {
|
|
11823
|
-
const texture = await CanvasKitTexture.fromFile(
|
|
11863
|
+
const texture = await CanvasKitTexture.fromFile(
|
|
11864
|
+
ck,
|
|
11865
|
+
parentDir + page.name,
|
|
11866
|
+
readFile
|
|
11867
|
+
);
|
|
11824
11868
|
page.setTexture(texture);
|
|
11825
11869
|
}
|
|
11826
11870
|
return atlas;
|
|
11827
11871
|
}
|
|
11828
|
-
async function loadSkeletonData(skeletonFile, atlas, readFile) {
|
|
11872
|
+
async function loadSkeletonData(skeletonFile, atlas, readFile, scale = 1) {
|
|
11829
11873
|
const attachmentLoader = new AtlasAttachmentLoader(atlas);
|
|
11830
11874
|
const loader = skeletonFile.endsWith(".json") ? new SkeletonJson(attachmentLoader) : new SkeletonBinary(attachmentLoader);
|
|
11875
|
+
loader.scale = scale;
|
|
11831
11876
|
let data = await readFile(skeletonFile);
|
|
11832
11877
|
if (skeletonFile.endsWith(".json")) {
|
|
11833
11878
|
data = bufferToUtf8String(data);
|
|
@@ -11843,7 +11888,9 @@ var spine = (() => {
|
|
|
11843
11888
|
*/
|
|
11844
11889
|
constructor(skeletonData) {
|
|
11845
11890
|
this.skeleton = new Skeleton(skeletonData);
|
|
11846
|
-
this.animationState = new AnimationState(
|
|
11891
|
+
this.animationState = new AnimationState(
|
|
11892
|
+
new AnimationStateData(skeletonData)
|
|
11893
|
+
);
|
|
11847
11894
|
}
|
|
11848
11895
|
/**
|
|
11849
11896
|
* Updates the animation state and skeleton time by the delta time. Applies the
|
|
@@ -11911,7 +11958,14 @@ var spine = (() => {
|
|
|
11911
11958
|
let mesh = attachment;
|
|
11912
11959
|
positions = positions.length < mesh.worldVerticesLength ? Utils.newFloatArray(mesh.worldVerticesLength) : positions;
|
|
11913
11960
|
numVertices = mesh.worldVerticesLength >> 1;
|
|
11914
|
-
mesh.computeWorldVertices(
|
|
11961
|
+
mesh.computeWorldVertices(
|
|
11962
|
+
slot,
|
|
11963
|
+
0,
|
|
11964
|
+
mesh.worldVerticesLength,
|
|
11965
|
+
positions,
|
|
11966
|
+
0,
|
|
11967
|
+
2
|
|
11968
|
+
);
|
|
11915
11969
|
triangles = mesh.triangles;
|
|
11916
11970
|
texture = mesh.region?.texture;
|
|
11917
11971
|
uvs = mesh.uvs;
|
|
@@ -11926,7 +11980,12 @@ var spine = (() => {
|
|
|
11926
11980
|
}
|
|
11927
11981
|
if (texture) {
|
|
11928
11982
|
if (clipper.isClipping()) {
|
|
11929
|
-
clipper.clipTrianglesUnpacked(
|
|
11983
|
+
clipper.clipTrianglesUnpacked(
|
|
11984
|
+
positions,
|
|
11985
|
+
triangles,
|
|
11986
|
+
triangles.length,
|
|
11987
|
+
uvs
|
|
11988
|
+
);
|
|
11930
11989
|
positions = clipper.clippedVertices;
|
|
11931
11990
|
uvs = clipper.clippedUVs;
|
|
11932
11991
|
triangles = clipper.clippedTriangles;
|
|
@@ -11953,8 +12012,19 @@ var spine = (() => {
|
|
|
11953
12012
|
scaledUvs[i2 + 1] = uvs[i2 + 1] * height;
|
|
11954
12013
|
}
|
|
11955
12014
|
const blendMode = slot.data.blendMode;
|
|
11956
|
-
const vertices = this.ck.MakeVertices(
|
|
11957
|
-
|
|
12015
|
+
const vertices = this.ck.MakeVertices(
|
|
12016
|
+
this.ck.VertexMode.Triangles,
|
|
12017
|
+
positions,
|
|
12018
|
+
scaledUvs,
|
|
12019
|
+
colors,
|
|
12020
|
+
triangles,
|
|
12021
|
+
false
|
|
12022
|
+
);
|
|
12023
|
+
canvas.drawVertices(
|
|
12024
|
+
vertices,
|
|
12025
|
+
this.ck.BlendMode.Modulate,
|
|
12026
|
+
texture.getImage().paintPerBlendMode.get(blendMode)
|
|
12027
|
+
);
|
|
11958
12028
|
vertices.delete();
|
|
11959
12029
|
}
|
|
11960
12030
|
clipper.clipEndWithSlot(slot);
|