@esotericsoftware/spine-webgl 4.3.8 → 4.3.10
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/esm/spine-webgl.mjs
CHANGED
|
@@ -6286,21 +6286,22 @@ var BonePose = class {
|
|
|
6286
6286
|
modifyLocal(skeleton) {
|
|
6287
6287
|
if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
|
|
6288
6288
|
this.world = 0;
|
|
6289
|
-
this.resetWorld(skeleton._update);
|
|
6289
|
+
this.resetWorld(skeleton, skeleton._update);
|
|
6290
6290
|
}
|
|
6291
|
-
modifyWorld(
|
|
6291
|
+
modifyWorld(skeleton) {
|
|
6292
|
+
const update = skeleton._update;
|
|
6292
6293
|
this.local = update;
|
|
6293
6294
|
this.world = update;
|
|
6294
|
-
this.resetWorld(update);
|
|
6295
|
+
this.resetWorld(skeleton, update);
|
|
6295
6296
|
}
|
|
6296
|
-
resetWorld(update) {
|
|
6297
|
+
resetWorld(skeleton, update) {
|
|
6297
6298
|
const children = this.bone.children;
|
|
6298
6299
|
for (let i = 0, n = children.length; i < n; i++) {
|
|
6299
6300
|
const child = children[i].appliedPose;
|
|
6300
6301
|
if (child.world === update) {
|
|
6302
|
+
if (child.local === update) child.updateLocalTransform(skeleton);
|
|
6301
6303
|
child.world = 0;
|
|
6302
|
-
child.
|
|
6303
|
-
child.resetWorld(update);
|
|
6304
|
+
child.resetWorld(skeleton, update);
|
|
6304
6305
|
}
|
|
6305
6306
|
}
|
|
6306
6307
|
}
|
|
@@ -7093,8 +7094,9 @@ var PathConstraint = class _PathConstraint extends Constraint {
|
|
|
7093
7094
|
const bone = this.slot.bone.appliedPose;
|
|
7094
7095
|
offsetRotation *= bone.a * bone.d - bone.b * bone.c > 0 ? MathUtils.degRad : -MathUtils.degRad;
|
|
7095
7096
|
}
|
|
7096
|
-
for (let i = 0, ip = 3
|
|
7097
|
+
for (let i = 0, ip = 3; i < boneCount; i++, ip += 3) {
|
|
7097
7098
|
const bone = bones[i];
|
|
7099
|
+
bone.modifyWorld(skeleton);
|
|
7098
7100
|
bone.worldX += (boneX - bone.worldX) * mixX;
|
|
7099
7101
|
bone.worldY += (boneY - bone.worldY) * mixY;
|
|
7100
7102
|
const x = positions[ip], y = positions[ip + 1], dx = x - boneX, dy = y - boneY;
|
|
@@ -7138,7 +7140,6 @@ var PathConstraint = class _PathConstraint extends Constraint {
|
|
|
7138
7140
|
bone.c = sin * a + cos * c;
|
|
7139
7141
|
bone.d = sin * b + cos * d;
|
|
7140
7142
|
}
|
|
7141
|
-
bone.modifyWorld(u);
|
|
7142
7143
|
}
|
|
7143
7144
|
}
|
|
7144
7145
|
computeWorldPositions(skeleton, path, spacesCount, tangents) {
|
|
@@ -8051,9 +8052,9 @@ var PhysicsConstraint = class _PhysicsConstraint extends Constraint {
|
|
|
8051
8052
|
const x = this.data.x > 0, y = this.data.y > 0, rotateOrShearX = this.data.rotate > 0 || this.data.shearX > 0, scaleX = this.data.scaleX > 0;
|
|
8052
8053
|
const bone = this.bone;
|
|
8053
8054
|
let l = bone.bone.data.length, t = this.data.step, z = 0;
|
|
8055
|
+
if (physics === 0 /* none */) return;
|
|
8056
|
+
bone.modifyWorld(skeleton);
|
|
8054
8057
|
switch (physics) {
|
|
8055
|
-
case 0 /* none */:
|
|
8056
|
-
return;
|
|
8057
8058
|
// biome-ignore lint/suspicious/noFallthroughSwitchClause: fall through expected
|
|
8058
8059
|
case 1 /* reset */:
|
|
8059
8060
|
this.reset(skeleton);
|
|
@@ -8231,7 +8232,6 @@ var PhysicsConstraint = class _PhysicsConstraint extends Constraint {
|
|
|
8231
8232
|
this.tx = l * bone.a;
|
|
8232
8233
|
this.ty = l * bone.c;
|
|
8233
8234
|
}
|
|
8234
|
-
bone.modifyWorld(skeleton._update);
|
|
8235
8235
|
}
|
|
8236
8236
|
sort(skeleton) {
|
|
8237
8237
|
const bone = this.bone.bone;
|
|
@@ -8798,14 +8798,14 @@ var TransformConstraint = class _TransformConstraint extends Constraint {
|
|
|
8798
8798
|
const source = this.source.appliedPose;
|
|
8799
8799
|
if (localSource) source.validateLocalTransform(skeleton);
|
|
8800
8800
|
const fromItems = data.properties;
|
|
8801
|
-
const fn = data.properties.length
|
|
8801
|
+
const fn = data.properties.length;
|
|
8802
8802
|
const bones = this.bones;
|
|
8803
8803
|
for (let i = 0, n = this.bones.length; i < n; i++) {
|
|
8804
8804
|
const bone = bones[i];
|
|
8805
8805
|
if (localTarget)
|
|
8806
8806
|
bone.modifyLocal(skeleton);
|
|
8807
8807
|
else
|
|
8808
|
-
bone.modifyWorld(
|
|
8808
|
+
bone.modifyWorld(skeleton);
|
|
8809
8809
|
for (let f = 0; f < fn; f++) {
|
|
8810
8810
|
const from = fromItems[f];
|
|
8811
8811
|
const value = from.value(skeleton, source, localSource, offsets) - from.offset;
|
|
@@ -11033,7 +11033,7 @@ var SkeletonClipping = class {
|
|
|
11033
11033
|
t = triangles[i + 2];
|
|
11034
11034
|
const x3 = vertices[t * stride], y3 = vertices[t * stride + 1];
|
|
11035
11035
|
const u3 = uvs[t << 1], v3 = uvs[(t << 1) + 1];
|
|
11036
|
-
|
|
11036
|
+
let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
|
|
11037
11037
|
for (let p = 0; p < polygonsCount; p++) {
|
|
11038
11038
|
let s = clippedVertices.length;
|
|
11039
11039
|
if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
|
|
@@ -11041,6 +11041,13 @@ var SkeletonClipping = class {
|
|
|
11041
11041
|
const clipOutputLength = clipOutput.length;
|
|
11042
11042
|
if (clipOutputLength === 0) continue;
|
|
11043
11043
|
let clipOutputCount = clipOutputLength >> 1;
|
|
11044
|
+
if (d === 0) {
|
|
11045
|
+
d0 = y2 - y3;
|
|
11046
|
+
d1 = x3 - x2;
|
|
11047
|
+
d2 = x1 - x3;
|
|
11048
|
+
d4 = y3 - y1;
|
|
11049
|
+
d = 1 / (d0 * d2 - d1 * d4);
|
|
11050
|
+
}
|
|
11044
11051
|
const cv = Utils.setArraySize(clippedVertices, s + clipOutputCount * stride);
|
|
11045
11052
|
for (let ii = 0; ii < clipOutputLength; ii += 2, s += stride) {
|
|
11046
11053
|
const x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
|
|
@@ -11240,7 +11247,7 @@ var SkeletonClipping = class {
|
|
|
11240
11247
|
const x3 = vertices[vertexStart + v], y3 = vertices[vertexStart + v + 1];
|
|
11241
11248
|
uv = t << 1;
|
|
11242
11249
|
const u3 = uvs[uv], v3 = uvs[uv + 1];
|
|
11243
|
-
|
|
11250
|
+
let d0 = 0, d1 = 0, d2 = 0, d4 = 0, d = 0;
|
|
11244
11251
|
for (let p = 0; p < polygonsCount; p++) {
|
|
11245
11252
|
let s = this.clippedVerticesLength;
|
|
11246
11253
|
if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p])) {
|
|
@@ -11248,6 +11255,13 @@ var SkeletonClipping = class {
|
|
|
11248
11255
|
const clipOutputLength = clipOutput.length;
|
|
11249
11256
|
if (clipOutputLength === 0) continue;
|
|
11250
11257
|
let clipOutputCount = clipOutputLength >> 1;
|
|
11258
|
+
if (d === 0) {
|
|
11259
|
+
d0 = y2 - y3;
|
|
11260
|
+
d1 = x3 - x2;
|
|
11261
|
+
d2 = x1 - x3;
|
|
11262
|
+
d4 = y3 - y1;
|
|
11263
|
+
d = 1 / (d0 * d2 - d1 * d4);
|
|
11264
|
+
}
|
|
11251
11265
|
const newLength = s + clipOutputCount * stride;
|
|
11252
11266
|
if (clippedVertices.length < newLength) {
|
|
11253
11267
|
this._clippedVerticesTyped = new Float32Array(newLength * 2);
|
|
@@ -11364,16 +11378,15 @@ var SkeletonClipping = class {
|
|
|
11364
11378
|
const edgeX = v[i], edgeY = v[i + 1], ex = edgeX - v[i + 2], ey = edgeY - v[i + 3];
|
|
11365
11379
|
const outputStart = output.length;
|
|
11366
11380
|
const iv2 = input;
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11381
|
+
x1 = iv2[0];
|
|
11382
|
+
y1 = iv2[1];
|
|
11383
|
+
let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
|
|
11384
|
+
for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
|
|
11371
11385
|
x2 = iv2[ii];
|
|
11372
11386
|
y2 = iv2[ii + 1];
|
|
11373
|
-
const s2 = ey * (edgeX - x2)
|
|
11374
|
-
const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
|
|
11387
|
+
const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
|
|
11375
11388
|
if (s1 > 0) {
|
|
11376
|
-
if (s2)
|
|
11389
|
+
if (s2 > 0)
|
|
11377
11390
|
output.push(x2, y2);
|
|
11378
11391
|
else {
|
|
11379
11392
|
const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
|
|
@@ -11383,7 +11396,7 @@ var SkeletonClipping = class {
|
|
|
11383
11396
|
} else
|
|
11384
11397
|
output.push(x2, y2);
|
|
11385
11398
|
}
|
|
11386
|
-
} else if (s2) {
|
|
11399
|
+
} else if (s2 > 0) {
|
|
11387
11400
|
const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
|
|
11388
11401
|
if (t >= 0 && t <= 1) {
|
|
11389
11402
|
output.push(x1 + ix * t, y1 + iy * t, x2, y2);
|
|
@@ -11392,6 +11405,9 @@ var SkeletonClipping = class {
|
|
|
11392
11405
|
output.push(x2, y2);
|
|
11393
11406
|
} else
|
|
11394
11407
|
clipped = true;
|
|
11408
|
+
x1 = x2;
|
|
11409
|
+
y1 = y2;
|
|
11410
|
+
s1 = s2;
|
|
11395
11411
|
}
|
|
11396
11412
|
if (outputStart === output.length) {
|
|
11397
11413
|
originalOutput.length = 0;
|
|
@@ -11439,16 +11455,15 @@ var SkeletonClipping = class {
|
|
|
11439
11455
|
const outputStart = output.length, fragmentStart = this.inverseVertices.length;
|
|
11440
11456
|
this.inverseVertices.push(0);
|
|
11441
11457
|
iv = input;
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11458
|
+
x1 = iv[0];
|
|
11459
|
+
y1 = iv[1];
|
|
11460
|
+
let s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
|
|
11461
|
+
for (let ii = 2, nn = input.length - 2; ii <= nn; ii += 2) {
|
|
11446
11462
|
x2 = iv[ii];
|
|
11447
11463
|
y2 = iv[ii + 1];
|
|
11448
|
-
const s2 = ey * (edgeX - x2)
|
|
11449
|
-
const s1 = ey * (edgeX - x1) - ex * (edgeY - y1);
|
|
11464
|
+
const s2 = ey * (edgeX - x2) - ex * (edgeY - y2);
|
|
11450
11465
|
if (s1 > 0) {
|
|
11451
|
-
if (s2)
|
|
11466
|
+
if (s2 > 0)
|
|
11452
11467
|
output.push(x2, y2);
|
|
11453
11468
|
else {
|
|
11454
11469
|
const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
|
|
@@ -11459,16 +11474,19 @@ var SkeletonClipping = class {
|
|
|
11459
11474
|
} else
|
|
11460
11475
|
output.push(x2, y2);
|
|
11461
11476
|
}
|
|
11462
|
-
} else if (s2) {
|
|
11463
|
-
const
|
|
11477
|
+
} else if (s2 > 0) {
|
|
11478
|
+
const ix = x2 - x1, iy = y2 - y1, t = s1 / (ix * ey - iy * ex);
|
|
11464
11479
|
if (t >= 0 && t <= 1) {
|
|
11465
|
-
const cx = x1 +
|
|
11480
|
+
const cx = x1 + ix * t, cy = y1 + iy * t;
|
|
11466
11481
|
this.inverseVertices.push(cx, cy);
|
|
11467
11482
|
output.push(cx, cy, x2, y2);
|
|
11468
11483
|
} else
|
|
11469
11484
|
output.push(x2, y2);
|
|
11470
11485
|
} else
|
|
11471
11486
|
this.inverseVertices.push(x2, y2);
|
|
11487
|
+
x1 = x2;
|
|
11488
|
+
y1 = y2;
|
|
11489
|
+
s1 = s2;
|
|
11472
11490
|
}
|
|
11473
11491
|
const fragmentSize = this.inverseVertices.length - fragmentStart - 1;
|
|
11474
11492
|
if (fragmentSize >= 6)
|
|
@@ -12835,17 +12853,21 @@ var SkeletonRendererCore = class {
|
|
|
12835
12853
|
this.renderCommands.length = 0;
|
|
12836
12854
|
const clipper = this.clipping;
|
|
12837
12855
|
const drawOrder = skeleton.drawOrder.appliedPose;
|
|
12838
|
-
for (let i = 0; i <
|
|
12856
|
+
for (let i = 0, n = drawOrder.length; i < n; i++) {
|
|
12839
12857
|
const slot = drawOrder[i];
|
|
12840
|
-
|
|
12841
|
-
if (!attachment) {
|
|
12858
|
+
if (!slot.bone.active) {
|
|
12842
12859
|
clipper.clipEnd(slot);
|
|
12843
12860
|
continue;
|
|
12844
12861
|
}
|
|
12845
12862
|
const pose = slot.appliedPose;
|
|
12863
|
+
const attachment = pose.attachment;
|
|
12864
|
+
if (!attachment) {
|
|
12865
|
+
clipper.clipEnd(slot);
|
|
12866
|
+
continue;
|
|
12867
|
+
}
|
|
12846
12868
|
const slotColor = pose.color;
|
|
12847
12869
|
const alpha = slotColor.a;
|
|
12848
|
-
if (
|
|
12870
|
+
if (alpha === 0 && !(attachment instanceof ClippingAttachment)) {
|
|
12849
12871
|
clipper.clipEnd(slot);
|
|
12850
12872
|
continue;
|
|
12851
12873
|
}
|
|
@@ -12889,9 +12911,15 @@ var SkeletonRendererCore = class {
|
|
|
12889
12911
|
indicesCount = indices.length;
|
|
12890
12912
|
texture = sequence.regions[sequenceIndex]?.texture;
|
|
12891
12913
|
} else if (attachment instanceof ClippingAttachment) {
|
|
12914
|
+
clipper.clipEnd(slot);
|
|
12892
12915
|
clipper.clipStart(skeleton, slot, attachment);
|
|
12893
12916
|
continue;
|
|
12894
12917
|
} else {
|
|
12918
|
+
clipper.clipEnd(slot);
|
|
12919
|
+
continue;
|
|
12920
|
+
}
|
|
12921
|
+
if (!texture) {
|
|
12922
|
+
clipper.clipEnd(slot);
|
|
12895
12923
|
continue;
|
|
12896
12924
|
}
|
|
12897
12925
|
const skelColor = skeleton.color;
|