@esotericsoftware/spine-phaser-v3 4.2.90 → 4.2.92

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.
@@ -177,7 +177,7 @@ var spine = (() => {
177
177
  SkeletonData: () => SkeletonData,
178
178
  SkeletonDebugRenderer: () => SkeletonDebugRenderer,
179
179
  SkeletonJson: () => SkeletonJson,
180
- SkeletonRenderer: () => SkeletonRenderer,
180
+ SkeletonRenderer: () => SkeletonRenderer2,
181
181
  Skin: () => Skin,
182
182
  SkinEntry: () => SkinEntry,
183
183
  SkinsAndAnimationBoundsProvider: () => SkinsAndAnimationBoundsProvider,
@@ -230,16 +230,6 @@ var spine = (() => {
230
230
  };
231
231
  }
232
232
 
233
- // spine-phaser-v3/src/SpinePlugin.ts
234
- var Phaser2 = __toESM(__require("Phaser"), 1);
235
-
236
- // spine-phaser-v3/src/keys.ts
237
- var SPINE_SKELETON_FILE_CACHE_KEY = "esotericsoftware.spine.skeletonFile.cache";
238
- var SPINE_ATLAS_CACHE_KEY = "esotericsoftware.spine.atlas.cache";
239
- var SPINE_SKELETON_DATA_FILE_TYPE = "spineSkeletonData";
240
- var SPINE_ATLAS_FILE_TYPE = "spineAtlasData";
241
- var SPINE_GAME_OBJECT_TYPE = "spine";
242
-
243
233
  // spine-core/src/Utils.ts
244
234
  var IntSet = class {
245
235
  array = new Array();
@@ -11522,6 +11512,250 @@ var spine = (() => {
11522
11512
  }
11523
11513
  })();
11524
11514
 
11515
+ // spine-canvas/src/CanvasTexture.ts
11516
+ var CanvasTexture = class extends Texture {
11517
+ constructor(image) {
11518
+ super(image);
11519
+ }
11520
+ setFilters(minFilter, magFilter) {
11521
+ }
11522
+ setWraps(uWrap, vWrap) {
11523
+ }
11524
+ dispose() {
11525
+ }
11526
+ };
11527
+
11528
+ // spine-canvas/src/SkeletonRenderer.ts
11529
+ var worldVertices = Utils.newFloatArray(8);
11530
+ var SkeletonRenderer = class _SkeletonRenderer {
11531
+ static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
11532
+ static VERTEX_SIZE = 2 + 2 + 4;
11533
+ ctx;
11534
+ triangleRendering = false;
11535
+ debugRendering = false;
11536
+ vertices = Utils.newFloatArray(8 * 1024);
11537
+ tempColor = new Color();
11538
+ constructor(context) {
11539
+ this.ctx = context;
11540
+ }
11541
+ draw(skeleton) {
11542
+ if (this.triangleRendering) this.drawTriangles(skeleton);
11543
+ else this.drawImages(skeleton);
11544
+ }
11545
+ drawImages(skeleton) {
11546
+ let ctx = this.ctx;
11547
+ let color = this.tempColor;
11548
+ let skeletonColor = skeleton.color;
11549
+ let drawOrder = skeleton.drawOrder;
11550
+ if (this.debugRendering) ctx.strokeStyle = "green";
11551
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
11552
+ let slot = drawOrder[i];
11553
+ let bone = slot.bone;
11554
+ if (!bone.active) continue;
11555
+ let attachment = slot.getAttachment();
11556
+ if (!(attachment instanceof RegionAttachment)) continue;
11557
+ attachment.computeWorldVertices(slot, worldVertices, 0, 2);
11558
+ let region = attachment.region;
11559
+ let image = region.texture.getImage();
11560
+ let slotColor = slot.color;
11561
+ let regionColor = attachment.color;
11562
+ color.set(
11563
+ skeletonColor.r * slotColor.r * regionColor.r,
11564
+ skeletonColor.g * slotColor.g * regionColor.g,
11565
+ skeletonColor.b * slotColor.b * regionColor.b,
11566
+ skeletonColor.a * slotColor.a * regionColor.a
11567
+ );
11568
+ ctx.save();
11569
+ ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
11570
+ ctx.translate(attachment.offset[0], attachment.offset[1]);
11571
+ ctx.rotate(attachment.rotation * Math.PI / 180);
11572
+ let atlasScale = attachment.width / region.originalWidth;
11573
+ ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
11574
+ let w = region.width, h = region.height;
11575
+ ctx.translate(w / 2, h / 2);
11576
+ if (attachment.region.degrees == 90) {
11577
+ let t = w;
11578
+ w = h;
11579
+ h = t;
11580
+ ctx.rotate(-Math.PI / 2);
11581
+ }
11582
+ ctx.scale(1, -1);
11583
+ ctx.translate(-w / 2, -h / 2);
11584
+ ctx.globalAlpha = color.a;
11585
+ ctx.drawImage(image, image.width * region.u, image.height * region.v, w, h, 0, 0, w, h);
11586
+ if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
11587
+ ctx.restore();
11588
+ }
11589
+ }
11590
+ drawTriangles(skeleton) {
11591
+ let ctx = this.ctx;
11592
+ let color = this.tempColor;
11593
+ let skeletonColor = skeleton.color;
11594
+ let drawOrder = skeleton.drawOrder;
11595
+ let blendMode = null;
11596
+ let vertices = this.vertices;
11597
+ let triangles = null;
11598
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
11599
+ let slot = drawOrder[i];
11600
+ let attachment = slot.getAttachment();
11601
+ let texture;
11602
+ let region;
11603
+ if (attachment instanceof RegionAttachment) {
11604
+ let regionAttachment = attachment;
11605
+ vertices = this.computeRegionVertices(slot, regionAttachment, false);
11606
+ triangles = _SkeletonRenderer.QUAD_TRIANGLES;
11607
+ texture = regionAttachment.region.texture.getImage();
11608
+ } else if (attachment instanceof MeshAttachment) {
11609
+ let mesh = attachment;
11610
+ vertices = this.computeMeshVertices(slot, mesh, false);
11611
+ triangles = mesh.triangles;
11612
+ texture = mesh.region.texture.getImage();
11613
+ } else
11614
+ continue;
11615
+ if (texture) {
11616
+ if (slot.data.blendMode != blendMode) blendMode = slot.data.blendMode;
11617
+ let slotColor = slot.color;
11618
+ let attachmentColor = attachment.color;
11619
+ color.set(
11620
+ skeletonColor.r * slotColor.r * attachmentColor.r,
11621
+ skeletonColor.g * slotColor.g * attachmentColor.g,
11622
+ skeletonColor.b * slotColor.b * attachmentColor.b,
11623
+ skeletonColor.a * slotColor.a * attachmentColor.a
11624
+ );
11625
+ ctx.globalAlpha = color.a;
11626
+ for (var j = 0; j < triangles.length; j += 3) {
11627
+ let t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
11628
+ let x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
11629
+ let x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
11630
+ let x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
11631
+ this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
11632
+ if (this.debugRendering) {
11633
+ ctx.strokeStyle = "green";
11634
+ ctx.beginPath();
11635
+ ctx.moveTo(x0, y0);
11636
+ ctx.lineTo(x1, y1);
11637
+ ctx.lineTo(x2, y2);
11638
+ ctx.lineTo(x0, y0);
11639
+ ctx.stroke();
11640
+ }
11641
+ }
11642
+ }
11643
+ }
11644
+ this.ctx.globalAlpha = 1;
11645
+ }
11646
+ // Adapted from http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
11647
+ // Apache 2 licensed
11648
+ drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
11649
+ let ctx = this.ctx;
11650
+ const width = img.width - 1;
11651
+ const height = img.height - 1;
11652
+ u0 *= width;
11653
+ v0 *= height;
11654
+ u1 *= width;
11655
+ v1 *= height;
11656
+ u2 *= width;
11657
+ v2 *= height;
11658
+ ctx.beginPath();
11659
+ ctx.moveTo(x0, y0);
11660
+ ctx.lineTo(x1, y1);
11661
+ ctx.lineTo(x2, y2);
11662
+ ctx.closePath();
11663
+ x1 -= x0;
11664
+ y1 -= y0;
11665
+ x2 -= x0;
11666
+ y2 -= y0;
11667
+ u1 -= u0;
11668
+ v1 -= v0;
11669
+ u2 -= u0;
11670
+ v2 -= v0;
11671
+ let det = u1 * v2 - u2 * v1;
11672
+ if (det == 0) return;
11673
+ det = 1 / det;
11674
+ const a = (v2 * x1 - v1 * x2) * det;
11675
+ const b = (v2 * y1 - v1 * y2) * det;
11676
+ const c = (u1 * x2 - u2 * x1) * det;
11677
+ const d = (u1 * y2 - u2 * y1) * det;
11678
+ const e = x0 - a * u0 - c * v0;
11679
+ const f = y0 - b * u0 - d * v0;
11680
+ ctx.save();
11681
+ ctx.transform(a, b, c, d, e, f);
11682
+ ctx.clip();
11683
+ ctx.drawImage(img, 0, 0);
11684
+ ctx.restore();
11685
+ }
11686
+ computeRegionVertices(slot, region, pma) {
11687
+ let skeletonColor = slot.bone.skeleton.color;
11688
+ let slotColor = slot.color;
11689
+ let regionColor = region.color;
11690
+ let alpha = skeletonColor.a * slotColor.a * regionColor.a;
11691
+ let multiplier = pma ? alpha : 1;
11692
+ let color = this.tempColor;
11693
+ color.set(
11694
+ skeletonColor.r * slotColor.r * regionColor.r * multiplier,
11695
+ skeletonColor.g * slotColor.g * regionColor.g * multiplier,
11696
+ skeletonColor.b * slotColor.b * regionColor.b * multiplier,
11697
+ alpha
11698
+ );
11699
+ region.computeWorldVertices(slot, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
11700
+ let vertices = this.vertices;
11701
+ let uvs = region.uvs;
11702
+ vertices[RegionAttachment.C1R] = color.r;
11703
+ vertices[RegionAttachment.C1G] = color.g;
11704
+ vertices[RegionAttachment.C1B] = color.b;
11705
+ vertices[RegionAttachment.C1A] = color.a;
11706
+ vertices[RegionAttachment.U1] = uvs[0];
11707
+ vertices[RegionAttachment.V1] = uvs[1];
11708
+ vertices[RegionAttachment.C2R] = color.r;
11709
+ vertices[RegionAttachment.C2G] = color.g;
11710
+ vertices[RegionAttachment.C2B] = color.b;
11711
+ vertices[RegionAttachment.C2A] = color.a;
11712
+ vertices[RegionAttachment.U2] = uvs[2];
11713
+ vertices[RegionAttachment.V2] = uvs[3];
11714
+ vertices[RegionAttachment.C3R] = color.r;
11715
+ vertices[RegionAttachment.C3G] = color.g;
11716
+ vertices[RegionAttachment.C3B] = color.b;
11717
+ vertices[RegionAttachment.C3A] = color.a;
11718
+ vertices[RegionAttachment.U3] = uvs[4];
11719
+ vertices[RegionAttachment.V3] = uvs[5];
11720
+ vertices[RegionAttachment.C4R] = color.r;
11721
+ vertices[RegionAttachment.C4G] = color.g;
11722
+ vertices[RegionAttachment.C4B] = color.b;
11723
+ vertices[RegionAttachment.C4A] = color.a;
11724
+ vertices[RegionAttachment.U4] = uvs[6];
11725
+ vertices[RegionAttachment.V4] = uvs[7];
11726
+ return vertices;
11727
+ }
11728
+ computeMeshVertices(slot, mesh, pma) {
11729
+ let skeletonColor = slot.bone.skeleton.color;
11730
+ let slotColor = slot.color;
11731
+ let regionColor = mesh.color;
11732
+ let alpha = skeletonColor.a * slotColor.a * regionColor.a;
11733
+ let multiplier = pma ? alpha : 1;
11734
+ let color = this.tempColor;
11735
+ color.set(
11736
+ skeletonColor.r * slotColor.r * regionColor.r * multiplier,
11737
+ skeletonColor.g * slotColor.g * regionColor.g * multiplier,
11738
+ skeletonColor.b * slotColor.b * regionColor.b * multiplier,
11739
+ alpha
11740
+ );
11741
+ let vertexCount = mesh.worldVerticesLength / 2;
11742
+ let vertices = this.vertices;
11743
+ if (vertices.length < mesh.worldVerticesLength) this.vertices = vertices = Utils.newFloatArray(mesh.worldVerticesLength);
11744
+ mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
11745
+ let uvs = mesh.uvs;
11746
+ for (let i = 0, u = 0, v = 2; i < vertexCount; i++) {
11747
+ vertices[v++] = color.r;
11748
+ vertices[v++] = color.g;
11749
+ vertices[v++] = color.b;
11750
+ vertices[v++] = color.a;
11751
+ vertices[v++] = uvs[u++];
11752
+ vertices[v++] = uvs[u++];
11753
+ v += 2;
11754
+ }
11755
+ return vertices;
11756
+ }
11757
+ };
11758
+
11525
11759
  // spine-webgl/src/WebGL.ts
11526
11760
  var ManagedWebGLRenderingContext = class {
11527
11761
  canvas;
@@ -13360,7 +13594,7 @@ void main () {
13360
13594
  this.numFloats = numFloats;
13361
13595
  }
13362
13596
  };
13363
- var SkeletonRenderer = class _SkeletonRenderer {
13597
+ var SkeletonRenderer2 = class _SkeletonRenderer {
13364
13598
  static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
13365
13599
  premultipliedAlpha = false;
13366
13600
  tempColor = new Color();
@@ -13578,7 +13812,7 @@ void main () {
13578
13812
  this.batcher = new PolygonBatcher(this.context, twoColorTint);
13579
13813
  this.shapesShader = Shader.newColored(this.context);
13580
13814
  this.shapes = new ShapeRenderer(this.context);
13581
- this.skeletonRenderer = new SkeletonRenderer(this.context, twoColorTint);
13815
+ this.skeletonRenderer = new SkeletonRenderer2(this.context, twoColorTint);
13582
13816
  this.skeletonDebugRenderer = new SkeletonDebugRenderer(this.context);
13583
13817
  }
13584
13818
  dispose() {
@@ -14178,6 +14412,16 @@ void main () {
14178
14412
  }
14179
14413
  };
14180
14414
 
14415
+ // spine-phaser-v3/src/SpinePlugin.ts
14416
+ var Phaser2 = __toESM(__require("Phaser"), 1);
14417
+
14418
+ // spine-phaser-v3/src/keys.ts
14419
+ var SPINE_SKELETON_FILE_CACHE_KEY = "esotericsoftware.spine.skeletonFile.cache";
14420
+ var SPINE_ATLAS_CACHE_KEY = "esotericsoftware.spine.atlas.cache";
14421
+ var SPINE_SKELETON_DATA_FILE_TYPE = "spineSkeletonData";
14422
+ var SPINE_ATLAS_FILE_TYPE = "spineAtlasData";
14423
+ var SPINE_GAME_OBJECT_TYPE = "spine";
14424
+
14181
14425
  // spine-phaser-v3/src/mixins.ts
14182
14426
  var components = Phaser.GameObjects.Components;
14183
14427
  var ComputedSize = components.ComputedSize;
@@ -14462,251 +14706,8 @@ void main () {
14462
14706
  }
14463
14707
  };
14464
14708
 
14465
- // spine-canvas/src/CanvasTexture.ts
14466
- var CanvasTexture = class extends Texture {
14467
- constructor(image) {
14468
- super(image);
14469
- }
14470
- setFilters(minFilter, magFilter) {
14471
- }
14472
- setWraps(uWrap, vWrap) {
14473
- }
14474
- dispose() {
14475
- }
14476
- };
14477
-
14478
- // spine-canvas/src/SkeletonRenderer.ts
14479
- var worldVertices = Utils.newFloatArray(8);
14480
- var SkeletonRenderer2 = class _SkeletonRenderer {
14481
- static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
14482
- static VERTEX_SIZE = 2 + 2 + 4;
14483
- ctx;
14484
- triangleRendering = false;
14485
- debugRendering = false;
14486
- vertices = Utils.newFloatArray(8 * 1024);
14487
- tempColor = new Color();
14488
- constructor(context) {
14489
- this.ctx = context;
14490
- }
14491
- draw(skeleton) {
14492
- if (this.triangleRendering) this.drawTriangles(skeleton);
14493
- else this.drawImages(skeleton);
14494
- }
14495
- drawImages(skeleton) {
14496
- let ctx = this.ctx;
14497
- let color = this.tempColor;
14498
- let skeletonColor = skeleton.color;
14499
- let drawOrder = skeleton.drawOrder;
14500
- if (this.debugRendering) ctx.strokeStyle = "green";
14501
- for (let i = 0, n = drawOrder.length; i < n; i++) {
14502
- let slot = drawOrder[i];
14503
- let bone = slot.bone;
14504
- if (!bone.active) continue;
14505
- let attachment = slot.getAttachment();
14506
- if (!(attachment instanceof RegionAttachment)) continue;
14507
- attachment.computeWorldVertices(slot, worldVertices, 0, 2);
14508
- let region = attachment.region;
14509
- let image = region.texture.getImage();
14510
- let slotColor = slot.color;
14511
- let regionColor = attachment.color;
14512
- color.set(
14513
- skeletonColor.r * slotColor.r * regionColor.r,
14514
- skeletonColor.g * slotColor.g * regionColor.g,
14515
- skeletonColor.b * slotColor.b * regionColor.b,
14516
- skeletonColor.a * slotColor.a * regionColor.a
14517
- );
14518
- ctx.save();
14519
- ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
14520
- ctx.translate(attachment.offset[0], attachment.offset[1]);
14521
- ctx.rotate(attachment.rotation * Math.PI / 180);
14522
- let atlasScale = attachment.width / region.originalWidth;
14523
- ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
14524
- let w = region.width, h = region.height;
14525
- ctx.translate(w / 2, h / 2);
14526
- if (attachment.region.degrees == 90) {
14527
- let t = w;
14528
- w = h;
14529
- h = t;
14530
- ctx.rotate(-Math.PI / 2);
14531
- }
14532
- ctx.scale(1, -1);
14533
- ctx.translate(-w / 2, -h / 2);
14534
- ctx.globalAlpha = color.a;
14535
- ctx.drawImage(image, image.width * region.u, image.height * region.v, w, h, 0, 0, w, h);
14536
- if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
14537
- ctx.restore();
14538
- }
14539
- }
14540
- drawTriangles(skeleton) {
14541
- let ctx = this.ctx;
14542
- let color = this.tempColor;
14543
- let skeletonColor = skeleton.color;
14544
- let drawOrder = skeleton.drawOrder;
14545
- let blendMode = null;
14546
- let vertices = this.vertices;
14547
- let triangles = null;
14548
- for (let i = 0, n = drawOrder.length; i < n; i++) {
14549
- let slot = drawOrder[i];
14550
- let attachment = slot.getAttachment();
14551
- let texture;
14552
- let region;
14553
- if (attachment instanceof RegionAttachment) {
14554
- let regionAttachment = attachment;
14555
- vertices = this.computeRegionVertices(slot, regionAttachment, false);
14556
- triangles = _SkeletonRenderer.QUAD_TRIANGLES;
14557
- texture = regionAttachment.region.texture.getImage();
14558
- } else if (attachment instanceof MeshAttachment) {
14559
- let mesh = attachment;
14560
- vertices = this.computeMeshVertices(slot, mesh, false);
14561
- triangles = mesh.triangles;
14562
- texture = mesh.region.texture.getImage();
14563
- } else
14564
- continue;
14565
- if (texture) {
14566
- if (slot.data.blendMode != blendMode) blendMode = slot.data.blendMode;
14567
- let slotColor = slot.color;
14568
- let attachmentColor = attachment.color;
14569
- color.set(
14570
- skeletonColor.r * slotColor.r * attachmentColor.r,
14571
- skeletonColor.g * slotColor.g * attachmentColor.g,
14572
- skeletonColor.b * slotColor.b * attachmentColor.b,
14573
- skeletonColor.a * slotColor.a * attachmentColor.a
14574
- );
14575
- ctx.globalAlpha = color.a;
14576
- for (var j = 0; j < triangles.length; j += 3) {
14577
- let t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
14578
- let x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
14579
- let x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
14580
- let x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
14581
- this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
14582
- if (this.debugRendering) {
14583
- ctx.strokeStyle = "green";
14584
- ctx.beginPath();
14585
- ctx.moveTo(x0, y0);
14586
- ctx.lineTo(x1, y1);
14587
- ctx.lineTo(x2, y2);
14588
- ctx.lineTo(x0, y0);
14589
- ctx.stroke();
14590
- }
14591
- }
14592
- }
14593
- }
14594
- this.ctx.globalAlpha = 1;
14595
- }
14596
- // Adapted from http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
14597
- // Apache 2 licensed
14598
- drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
14599
- let ctx = this.ctx;
14600
- const width = img.width - 1;
14601
- const height = img.height - 1;
14602
- u0 *= width;
14603
- v0 *= height;
14604
- u1 *= width;
14605
- v1 *= height;
14606
- u2 *= width;
14607
- v2 *= height;
14608
- ctx.beginPath();
14609
- ctx.moveTo(x0, y0);
14610
- ctx.lineTo(x1, y1);
14611
- ctx.lineTo(x2, y2);
14612
- ctx.closePath();
14613
- x1 -= x0;
14614
- y1 -= y0;
14615
- x2 -= x0;
14616
- y2 -= y0;
14617
- u1 -= u0;
14618
- v1 -= v0;
14619
- u2 -= u0;
14620
- v2 -= v0;
14621
- let det = u1 * v2 - u2 * v1;
14622
- if (det == 0) return;
14623
- det = 1 / det;
14624
- const a = (v2 * x1 - v1 * x2) * det;
14625
- const b = (v2 * y1 - v1 * y2) * det;
14626
- const c = (u1 * x2 - u2 * x1) * det;
14627
- const d = (u1 * y2 - u2 * y1) * det;
14628
- const e = x0 - a * u0 - c * v0;
14629
- const f = y0 - b * u0 - d * v0;
14630
- ctx.save();
14631
- ctx.transform(a, b, c, d, e, f);
14632
- ctx.clip();
14633
- ctx.drawImage(img, 0, 0);
14634
- ctx.restore();
14635
- }
14636
- computeRegionVertices(slot, region, pma) {
14637
- let skeletonColor = slot.bone.skeleton.color;
14638
- let slotColor = slot.color;
14639
- let regionColor = region.color;
14640
- let alpha = skeletonColor.a * slotColor.a * regionColor.a;
14641
- let multiplier = pma ? alpha : 1;
14642
- let color = this.tempColor;
14643
- color.set(
14644
- skeletonColor.r * slotColor.r * regionColor.r * multiplier,
14645
- skeletonColor.g * slotColor.g * regionColor.g * multiplier,
14646
- skeletonColor.b * slotColor.b * regionColor.b * multiplier,
14647
- alpha
14648
- );
14649
- region.computeWorldVertices(slot, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
14650
- let vertices = this.vertices;
14651
- let uvs = region.uvs;
14652
- vertices[RegionAttachment.C1R] = color.r;
14653
- vertices[RegionAttachment.C1G] = color.g;
14654
- vertices[RegionAttachment.C1B] = color.b;
14655
- vertices[RegionAttachment.C1A] = color.a;
14656
- vertices[RegionAttachment.U1] = uvs[0];
14657
- vertices[RegionAttachment.V1] = uvs[1];
14658
- vertices[RegionAttachment.C2R] = color.r;
14659
- vertices[RegionAttachment.C2G] = color.g;
14660
- vertices[RegionAttachment.C2B] = color.b;
14661
- vertices[RegionAttachment.C2A] = color.a;
14662
- vertices[RegionAttachment.U2] = uvs[2];
14663
- vertices[RegionAttachment.V2] = uvs[3];
14664
- vertices[RegionAttachment.C3R] = color.r;
14665
- vertices[RegionAttachment.C3G] = color.g;
14666
- vertices[RegionAttachment.C3B] = color.b;
14667
- vertices[RegionAttachment.C3A] = color.a;
14668
- vertices[RegionAttachment.U3] = uvs[4];
14669
- vertices[RegionAttachment.V3] = uvs[5];
14670
- vertices[RegionAttachment.C4R] = color.r;
14671
- vertices[RegionAttachment.C4G] = color.g;
14672
- vertices[RegionAttachment.C4B] = color.b;
14673
- vertices[RegionAttachment.C4A] = color.a;
14674
- vertices[RegionAttachment.U4] = uvs[6];
14675
- vertices[RegionAttachment.V4] = uvs[7];
14676
- return vertices;
14677
- }
14678
- computeMeshVertices(slot, mesh, pma) {
14679
- let skeletonColor = slot.bone.skeleton.color;
14680
- let slotColor = slot.color;
14681
- let regionColor = mesh.color;
14682
- let alpha = skeletonColor.a * slotColor.a * regionColor.a;
14683
- let multiplier = pma ? alpha : 1;
14684
- let color = this.tempColor;
14685
- color.set(
14686
- skeletonColor.r * slotColor.r * regionColor.r * multiplier,
14687
- skeletonColor.g * slotColor.g * regionColor.g * multiplier,
14688
- skeletonColor.b * slotColor.b * regionColor.b * multiplier,
14689
- alpha
14690
- );
14691
- let vertexCount = mesh.worldVerticesLength / 2;
14692
- let vertices = this.vertices;
14693
- if (vertices.length < mesh.worldVerticesLength) this.vertices = vertices = Utils.newFloatArray(mesh.worldVerticesLength);
14694
- mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
14695
- let uvs = mesh.uvs;
14696
- for (let i = 0, u = 0, v = 2; i < vertexCount; i++) {
14697
- vertices[v++] = color.r;
14698
- vertices[v++] = color.g;
14699
- vertices[v++] = color.b;
14700
- vertices[v++] = color.a;
14701
- vertices[v++] = uvs[u++];
14702
- vertices[v++] = uvs[u++];
14703
- v += 2;
14704
- }
14705
- return vertices;
14706
- }
14707
- };
14708
-
14709
14709
  // spine-phaser-v3/src/SpinePlugin.ts
14710
+ Skeleton.yDown = true;
14710
14711
  var SpinePlugin = class _SpinePlugin extends Phaser2.Plugins.ScenePlugin {
14711
14712
  game;
14712
14713
  isWebGL;
@@ -14780,29 +14781,25 @@ void main () {
14780
14781
  }
14781
14782
  static rendererId = 0;
14782
14783
  boot() {
14783
- Skeleton.yDown = true;
14784
- if (this.isWebGL) {
14785
- if (!_SpinePlugin.gameWebGLRenderer) {
14786
- _SpinePlugin.gameWebGLRenderer = new SceneRenderer(this.game.renderer.canvas, this.gl, true);
14787
- }
14788
- this.onResize();
14789
- this.game.scale.on(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14790
- } else {
14791
- if (!this.canvasRenderer) {
14792
- this.canvasRenderer = new SkeletonRenderer2(this.scene.sys.context);
14793
- }
14784
+ if (this.isWebGL && this.gl) {
14785
+ _SpinePlugin.gameWebGLRenderer ||= new SceneRenderer(this.game.renderer.canvas, this.gl, true);
14786
+ } else if (this.scene) {
14787
+ this.canvasRenderer ||= new SkeletonRenderer(this.scene.sys.context);
14788
+ }
14789
+ this.onResize();
14790
+ if (this.systems) {
14791
+ this.systems.events.once("destroy", this.destroy, this);
14792
+ this.systems.events.on("start", this.onStart, this);
14793
+ this.systems.events.on("shutdown", this.shutdown, this);
14794
14794
  }
14795
- var eventEmitter = this.systems.events;
14796
- eventEmitter.once("shutdown", this.shutdown, this);
14797
- eventEmitter.once("destroy", this.destroy, this);
14798
14795
  this.game.events.once("destroy", this.gameDestroy, this);
14799
14796
  }
14800
14797
  onResize() {
14801
- var phaserRenderer = this.game.renderer;
14802
- var sceneRenderer = this.webGLRenderer;
14798
+ const phaserRenderer = this.game.renderer;
14799
+ const sceneRenderer = this.webGLRenderer;
14803
14800
  if (phaserRenderer && sceneRenderer) {
14804
- var viewportWidth = phaserRenderer.width;
14805
- var viewportHeight = phaserRenderer.height;
14801
+ const viewportWidth = phaserRenderer.width;
14802
+ const viewportHeight = phaserRenderer.height;
14806
14803
  sceneRenderer.camera.position.x = viewportWidth / 2;
14807
14804
  sceneRenderer.camera.position.y = viewportHeight / 2;
14808
14805
  sceneRenderer.camera.up.y = -1;
@@ -14810,14 +14807,18 @@ void main () {
14810
14807
  sceneRenderer.camera.setViewport(viewportWidth, viewportHeight);
14811
14808
  }
14812
14809
  }
14810
+ onStart() {
14811
+ this.game.scale.on(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14812
+ }
14813
14813
  shutdown() {
14814
- this.systems.events.off("shutdown", this.shutdown, this);
14815
14814
  if (this.isWebGL) {
14816
14815
  this.game.scale.off(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14817
14816
  }
14818
14817
  }
14819
14818
  destroy() {
14820
14819
  this.shutdown();
14820
+ this.systems?.events.off("start", this.onStart, this);
14821
+ this.systems?.events.off("shutdown", this.shutdown, this);
14821
14822
  }
14822
14823
  gameDestroy() {
14823
14824
  this.pluginManager.removeGameObject(window.SPINE_GAME_OBJECT_TYPE ? window.SPINE_GAME_OBJECT_TYPE : SPINE_GAME_OBJECT_TYPE, true, true);