@esotericsoftware/spine-canvaskit 4.2.86 → 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.
- package/dist/esm/spine-canvaskit.min.mjs +2 -2
- package/dist/esm/spine-canvaskit.mjs +65 -82
- package/dist/esm/spine-canvaskit.mjs.map +2 -2
- package/dist/iife/spine-canvaskit.js +65 -82
- package/dist/iife/spine-canvaskit.js.map +2 -2
- package/dist/iife/spine-canvaskit.min.js +2 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +59 -63
- package/package.json +2 -2
|
@@ -4406,21 +4406,21 @@ var Texture = class {
|
|
|
4406
4406
|
return this._image;
|
|
4407
4407
|
}
|
|
4408
4408
|
};
|
|
4409
|
-
var TextureFilter = /* @__PURE__ */ ((
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
return
|
|
4409
|
+
var TextureFilter = /* @__PURE__ */ ((TextureFilter2) => {
|
|
4410
|
+
TextureFilter2[TextureFilter2["Nearest"] = 9728] = "Nearest";
|
|
4411
|
+
TextureFilter2[TextureFilter2["Linear"] = 9729] = "Linear";
|
|
4412
|
+
TextureFilter2[TextureFilter2["MipMap"] = 9987] = "MipMap";
|
|
4413
|
+
TextureFilter2[TextureFilter2["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
|
|
4414
|
+
TextureFilter2[TextureFilter2["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
|
|
4415
|
+
TextureFilter2[TextureFilter2["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
|
|
4416
|
+
TextureFilter2[TextureFilter2["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
|
|
4417
|
+
return TextureFilter2;
|
|
4418
4418
|
})(TextureFilter || {});
|
|
4419
|
-
var TextureWrap = /* @__PURE__ */ ((
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
return
|
|
4419
|
+
var TextureWrap = /* @__PURE__ */ ((TextureWrap2) => {
|
|
4420
|
+
TextureWrap2[TextureWrap2["MirroredRepeat"] = 33648] = "MirroredRepeat";
|
|
4421
|
+
TextureWrap2[TextureWrap2["ClampToEdge"] = 33071] = "ClampToEdge";
|
|
4422
|
+
TextureWrap2[TextureWrap2["Repeat"] = 10497] = "Repeat";
|
|
4423
|
+
return TextureWrap2;
|
|
4424
4424
|
})(TextureWrap || {});
|
|
4425
4425
|
var TextureRegion = class {
|
|
4426
4426
|
texture;
|
|
@@ -11309,9 +11309,9 @@ var CanvasKitTexture = class _CanvasKitTexture extends Texture {
|
|
|
11309
11309
|
getImage() {
|
|
11310
11310
|
return this._image;
|
|
11311
11311
|
}
|
|
11312
|
-
setFilters(
|
|
11312
|
+
setFilters() {
|
|
11313
11313
|
}
|
|
11314
|
-
setWraps(
|
|
11314
|
+
setWraps() {
|
|
11315
11315
|
}
|
|
11316
11316
|
dispose() {
|
|
11317
11317
|
const data = this._image;
|
|
@@ -11370,12 +11370,11 @@ async function loadSkeletonData(skeletonFile, atlas, readFile, scale = 1) {
|
|
|
11370
11370
|
const attachmentLoader = new AtlasAttachmentLoader(atlas);
|
|
11371
11371
|
const loader = skeletonFile.endsWith(".json") ? new SkeletonJson(attachmentLoader) : new SkeletonBinary(attachmentLoader);
|
|
11372
11372
|
loader.scale = scale;
|
|
11373
|
-
|
|
11374
|
-
if (
|
|
11375
|
-
|
|
11373
|
+
const data = await readFile(skeletonFile);
|
|
11374
|
+
if (loader instanceof SkeletonJson) {
|
|
11375
|
+
return loader.readSkeletonData(bufferToUtf8String(data));
|
|
11376
11376
|
}
|
|
11377
|
-
|
|
11378
|
-
return skeletonData;
|
|
11377
|
+
return loader.readSkeletonData(data);
|
|
11379
11378
|
}
|
|
11380
11379
|
var SkeletonDrawable = class {
|
|
11381
11380
|
skeleton;
|
|
@@ -11412,12 +11411,10 @@ var SkeletonRenderer = class _SkeletonRenderer {
|
|
|
11412
11411
|
this.ck = ck;
|
|
11413
11412
|
}
|
|
11414
11413
|
clipper = new SkeletonClipping();
|
|
11415
|
-
tempColor = new Color();
|
|
11416
|
-
tempColor2 = new Color();
|
|
11417
11414
|
static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
|
|
11418
11415
|
scratchPositions = Utils.newFloatArray(100);
|
|
11419
|
-
scratchColors = Utils.newFloatArray(100);
|
|
11420
11416
|
scratchUVs = Utils.newFloatArray(100);
|
|
11417
|
+
scratchColors = new Uint32Array(100 / 4);
|
|
11421
11418
|
/**
|
|
11422
11419
|
* Renders a skeleton or skeleton drawable in its current pose to the canvas.
|
|
11423
11420
|
* @param canvas the canvas to render to.
|
|
@@ -11425,90 +11422,79 @@ var SkeletonRenderer = class _SkeletonRenderer {
|
|
|
11425
11422
|
*/
|
|
11426
11423
|
render(canvas, skeleton) {
|
|
11427
11424
|
if (skeleton instanceof SkeletonDrawable) skeleton = skeleton.skeleton;
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11425
|
+
const clipper = this.clipper;
|
|
11426
|
+
const drawOrder = skeleton.drawOrder;
|
|
11427
|
+
const skeletonColor = skeleton.color;
|
|
11431
11428
|
for (let i = 0, n = drawOrder.length; i < n; i++) {
|
|
11432
|
-
|
|
11429
|
+
const slot = drawOrder[i];
|
|
11433
11430
|
if (!slot.bone.active) {
|
|
11434
11431
|
clipper.clipEndWithSlot(slot);
|
|
11435
11432
|
continue;
|
|
11436
11433
|
}
|
|
11437
|
-
|
|
11434
|
+
const attachment = slot.getAttachment();
|
|
11438
11435
|
let positions = this.scratchPositions;
|
|
11439
|
-
let colors = this.scratchColors;
|
|
11440
|
-
let uvs;
|
|
11441
|
-
let texture;
|
|
11442
11436
|
let triangles;
|
|
11443
|
-
let
|
|
11444
|
-
let numVertices = 0;
|
|
11437
|
+
let numVertices = 4;
|
|
11445
11438
|
if (attachment instanceof RegionAttachment) {
|
|
11446
|
-
|
|
11447
|
-
positions = positions.length < 8 ? Utils.newFloatArray(8) : positions;
|
|
11448
|
-
numVertices = 4;
|
|
11449
|
-
region.computeWorldVertices(slot, positions, 0, 2);
|
|
11439
|
+
attachment.computeWorldVertices(slot, positions, 0, 2);
|
|
11450
11440
|
triangles = _SkeletonRenderer.QUAD_TRIANGLES;
|
|
11451
|
-
uvs = region.uvs;
|
|
11452
|
-
texture = region.region?.texture;
|
|
11453
|
-
attachmentColor = region.color;
|
|
11454
11441
|
} else if (attachment instanceof MeshAttachment) {
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11442
|
+
if (positions.length < attachment.worldVerticesLength) {
|
|
11443
|
+
this.scratchPositions = Utils.newFloatArray(attachment.worldVerticesLength);
|
|
11444
|
+
positions = this.scratchPositions;
|
|
11445
|
+
}
|
|
11446
|
+
numVertices = attachment.worldVerticesLength >> 1;
|
|
11447
|
+
attachment.computeWorldVertices(
|
|
11459
11448
|
slot,
|
|
11460
11449
|
0,
|
|
11461
|
-
|
|
11450
|
+
attachment.worldVerticesLength,
|
|
11462
11451
|
positions,
|
|
11463
11452
|
0,
|
|
11464
11453
|
2
|
|
11465
11454
|
);
|
|
11466
|
-
triangles =
|
|
11467
|
-
texture = mesh.region?.texture;
|
|
11468
|
-
uvs = mesh.uvs;
|
|
11469
|
-
attachmentColor = mesh.color;
|
|
11455
|
+
triangles = attachment.triangles;
|
|
11470
11456
|
} else if (attachment instanceof ClippingAttachment) {
|
|
11471
|
-
|
|
11472
|
-
clipper.clipStart(slot, clip);
|
|
11457
|
+
clipper.clipStart(slot, attachment);
|
|
11473
11458
|
continue;
|
|
11474
11459
|
} else {
|
|
11475
11460
|
clipper.clipEndWithSlot(slot);
|
|
11476
11461
|
continue;
|
|
11477
11462
|
}
|
|
11463
|
+
const texture = attachment.region?.texture;
|
|
11478
11464
|
if (texture) {
|
|
11465
|
+
let uvs = attachment.uvs;
|
|
11466
|
+
let scaledUvs;
|
|
11467
|
+
let colors = this.scratchColors;
|
|
11479
11468
|
if (clipper.isClipping()) {
|
|
11480
|
-
clipper.clipTrianglesUnpacked(
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
);
|
|
11469
|
+
clipper.clipTrianglesUnpacked(positions, triangles, triangles.length, uvs);
|
|
11470
|
+
if (clipper.clippedVertices.length <= 0) {
|
|
11471
|
+
clipper.clipEndWithSlot(slot);
|
|
11472
|
+
continue;
|
|
11473
|
+
}
|
|
11486
11474
|
positions = clipper.clippedVertices;
|
|
11487
|
-
uvs = clipper.clippedUVs;
|
|
11475
|
+
uvs = scaledUvs = clipper.clippedUVs;
|
|
11488
11476
|
triangles = clipper.clippedTriangles;
|
|
11477
|
+
numVertices = clipper.clippedVertices.length / 2;
|
|
11478
|
+
colors = new Uint32Array(numVertices);
|
|
11479
|
+
} else {
|
|
11480
|
+
scaledUvs = this.scratchUVs;
|
|
11481
|
+
if (this.scratchUVs.length < uvs.length)
|
|
11482
|
+
scaledUvs = this.scratchUVs = Utils.newFloatArray(uvs.length);
|
|
11483
|
+
if (colors.length < numVertices)
|
|
11484
|
+
colors = this.scratchColors = new Uint32Array(numVertices);
|
|
11489
11485
|
}
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
|
|
11495
|
-
finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
|
|
11496
|
-
if (colors.length / 4 < numVertices)
|
|
11497
|
-
colors = Utils.newFloatArray(numVertices * 4);
|
|
11498
|
-
for (let i2 = 0, n2 = numVertices * 4; i2 < n2; i2 += 4) {
|
|
11499
|
-
colors[i2] = finalColor.r;
|
|
11500
|
-
colors[i2 + 1] = finalColor.g;
|
|
11501
|
-
colors[i2 + 2] = finalColor.b;
|
|
11502
|
-
colors[i2 + 3] = finalColor.a;
|
|
11503
|
-
}
|
|
11504
|
-
const scaledUvs = this.scratchUVs.length < uvs.length ? Utils.newFloatArray(uvs.length) : this.scratchUVs;
|
|
11505
|
-
const width = texture.getImage().image.width();
|
|
11506
|
-
const height = texture.getImage().image.height();
|
|
11486
|
+
const ckImage = texture.getImage();
|
|
11487
|
+
const image = ckImage.image;
|
|
11488
|
+
const width = image.width();
|
|
11489
|
+
const height = image.height();
|
|
11507
11490
|
for (let i2 = 0; i2 < uvs.length; i2 += 2) {
|
|
11508
11491
|
scaledUvs[i2] = uvs[i2] * width;
|
|
11509
11492
|
scaledUvs[i2 + 1] = uvs[i2 + 1] * height;
|
|
11510
11493
|
}
|
|
11511
|
-
const
|
|
11494
|
+
const attachmentColor = attachment.color;
|
|
11495
|
+
const slotColor = slot.color;
|
|
11496
|
+
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;
|
|
11497
|
+
for (let i2 = 0, n2 = numVertices; i2 < n2; i2++) colors[i2] = finalColor;
|
|
11512
11498
|
const vertices = this.ck.MakeVertices(
|
|
11513
11499
|
this.ck.VertexMode.Triangles,
|
|
11514
11500
|
positions,
|
|
@@ -11517,11 +11503,8 @@ var SkeletonRenderer = class _SkeletonRenderer {
|
|
|
11517
11503
|
triangles,
|
|
11518
11504
|
false
|
|
11519
11505
|
);
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
this.ck.BlendMode.Modulate,
|
|
11523
|
-
texture.getImage().paintPerBlendMode.get(blendMode)
|
|
11524
|
-
);
|
|
11506
|
+
const ckPaint = ckImage.paintPerBlendMode.get(slot.data.blendMode);
|
|
11507
|
+
if (ckPaint) canvas.drawVertices(vertices, this.ck.BlendMode.Modulate, ckPaint);
|
|
11525
11508
|
vertices.delete();
|
|
11526
11509
|
}
|
|
11527
11510
|
clipper.clipEndWithSlot(slot);
|