@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.
@@ -7,16 +7,6 @@ if (typeof window !== "undefined" && window.Phaser) {
7
7
  };
8
8
  }
9
9
 
10
- // spine-phaser-v3/src/SpinePlugin.ts
11
- import * as Phaser2 from "Phaser";
12
-
13
- // spine-phaser-v3/src/keys.ts
14
- var SPINE_SKELETON_FILE_CACHE_KEY = "esotericsoftware.spine.skeletonFile.cache";
15
- var SPINE_ATLAS_CACHE_KEY = "esotericsoftware.spine.atlas.cache";
16
- var SPINE_SKELETON_DATA_FILE_TYPE = "spineSkeletonData";
17
- var SPINE_ATLAS_FILE_TYPE = "spineAtlasData";
18
- var SPINE_GAME_OBJECT_TYPE = "spine";
19
-
20
10
  // spine-core/src/Utils.ts
21
11
  var IntSet = class {
22
12
  array = new Array();
@@ -11299,6 +11289,250 @@ function getValue(map, property, defaultValue) {
11299
11289
  }
11300
11290
  })();
11301
11291
 
11292
+ // spine-canvas/src/CanvasTexture.ts
11293
+ var CanvasTexture = class extends Texture {
11294
+ constructor(image) {
11295
+ super(image);
11296
+ }
11297
+ setFilters(minFilter, magFilter) {
11298
+ }
11299
+ setWraps(uWrap, vWrap) {
11300
+ }
11301
+ dispose() {
11302
+ }
11303
+ };
11304
+
11305
+ // spine-canvas/src/SkeletonRenderer.ts
11306
+ var worldVertices = Utils.newFloatArray(8);
11307
+ var SkeletonRenderer = class _SkeletonRenderer {
11308
+ static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
11309
+ static VERTEX_SIZE = 2 + 2 + 4;
11310
+ ctx;
11311
+ triangleRendering = false;
11312
+ debugRendering = false;
11313
+ vertices = Utils.newFloatArray(8 * 1024);
11314
+ tempColor = new Color();
11315
+ constructor(context) {
11316
+ this.ctx = context;
11317
+ }
11318
+ draw(skeleton) {
11319
+ if (this.triangleRendering) this.drawTriangles(skeleton);
11320
+ else this.drawImages(skeleton);
11321
+ }
11322
+ drawImages(skeleton) {
11323
+ let ctx = this.ctx;
11324
+ let color = this.tempColor;
11325
+ let skeletonColor = skeleton.color;
11326
+ let drawOrder = skeleton.drawOrder;
11327
+ if (this.debugRendering) ctx.strokeStyle = "green";
11328
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
11329
+ let slot = drawOrder[i];
11330
+ let bone = slot.bone;
11331
+ if (!bone.active) continue;
11332
+ let attachment = slot.getAttachment();
11333
+ if (!(attachment instanceof RegionAttachment)) continue;
11334
+ attachment.computeWorldVertices(slot, worldVertices, 0, 2);
11335
+ let region = attachment.region;
11336
+ let image = region.texture.getImage();
11337
+ let slotColor = slot.color;
11338
+ let regionColor = attachment.color;
11339
+ color.set(
11340
+ skeletonColor.r * slotColor.r * regionColor.r,
11341
+ skeletonColor.g * slotColor.g * regionColor.g,
11342
+ skeletonColor.b * slotColor.b * regionColor.b,
11343
+ skeletonColor.a * slotColor.a * regionColor.a
11344
+ );
11345
+ ctx.save();
11346
+ ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
11347
+ ctx.translate(attachment.offset[0], attachment.offset[1]);
11348
+ ctx.rotate(attachment.rotation * Math.PI / 180);
11349
+ let atlasScale = attachment.width / region.originalWidth;
11350
+ ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
11351
+ let w = region.width, h = region.height;
11352
+ ctx.translate(w / 2, h / 2);
11353
+ if (attachment.region.degrees == 90) {
11354
+ let t = w;
11355
+ w = h;
11356
+ h = t;
11357
+ ctx.rotate(-Math.PI / 2);
11358
+ }
11359
+ ctx.scale(1, -1);
11360
+ ctx.translate(-w / 2, -h / 2);
11361
+ ctx.globalAlpha = color.a;
11362
+ ctx.drawImage(image, image.width * region.u, image.height * region.v, w, h, 0, 0, w, h);
11363
+ if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
11364
+ ctx.restore();
11365
+ }
11366
+ }
11367
+ drawTriangles(skeleton) {
11368
+ let ctx = this.ctx;
11369
+ let color = this.tempColor;
11370
+ let skeletonColor = skeleton.color;
11371
+ let drawOrder = skeleton.drawOrder;
11372
+ let blendMode = null;
11373
+ let vertices = this.vertices;
11374
+ let triangles = null;
11375
+ for (let i = 0, n = drawOrder.length; i < n; i++) {
11376
+ let slot = drawOrder[i];
11377
+ let attachment = slot.getAttachment();
11378
+ let texture;
11379
+ let region;
11380
+ if (attachment instanceof RegionAttachment) {
11381
+ let regionAttachment = attachment;
11382
+ vertices = this.computeRegionVertices(slot, regionAttachment, false);
11383
+ triangles = _SkeletonRenderer.QUAD_TRIANGLES;
11384
+ texture = regionAttachment.region.texture.getImage();
11385
+ } else if (attachment instanceof MeshAttachment) {
11386
+ let mesh = attachment;
11387
+ vertices = this.computeMeshVertices(slot, mesh, false);
11388
+ triangles = mesh.triangles;
11389
+ texture = mesh.region.texture.getImage();
11390
+ } else
11391
+ continue;
11392
+ if (texture) {
11393
+ if (slot.data.blendMode != blendMode) blendMode = slot.data.blendMode;
11394
+ let slotColor = slot.color;
11395
+ let attachmentColor = attachment.color;
11396
+ color.set(
11397
+ skeletonColor.r * slotColor.r * attachmentColor.r,
11398
+ skeletonColor.g * slotColor.g * attachmentColor.g,
11399
+ skeletonColor.b * slotColor.b * attachmentColor.b,
11400
+ skeletonColor.a * slotColor.a * attachmentColor.a
11401
+ );
11402
+ ctx.globalAlpha = color.a;
11403
+ for (var j = 0; j < triangles.length; j += 3) {
11404
+ let t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
11405
+ let x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
11406
+ let x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
11407
+ let x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
11408
+ this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
11409
+ if (this.debugRendering) {
11410
+ ctx.strokeStyle = "green";
11411
+ ctx.beginPath();
11412
+ ctx.moveTo(x0, y0);
11413
+ ctx.lineTo(x1, y1);
11414
+ ctx.lineTo(x2, y2);
11415
+ ctx.lineTo(x0, y0);
11416
+ ctx.stroke();
11417
+ }
11418
+ }
11419
+ }
11420
+ }
11421
+ this.ctx.globalAlpha = 1;
11422
+ }
11423
+ // Adapted from http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
11424
+ // Apache 2 licensed
11425
+ drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
11426
+ let ctx = this.ctx;
11427
+ const width = img.width - 1;
11428
+ const height = img.height - 1;
11429
+ u0 *= width;
11430
+ v0 *= height;
11431
+ u1 *= width;
11432
+ v1 *= height;
11433
+ u2 *= width;
11434
+ v2 *= height;
11435
+ ctx.beginPath();
11436
+ ctx.moveTo(x0, y0);
11437
+ ctx.lineTo(x1, y1);
11438
+ ctx.lineTo(x2, y2);
11439
+ ctx.closePath();
11440
+ x1 -= x0;
11441
+ y1 -= y0;
11442
+ x2 -= x0;
11443
+ y2 -= y0;
11444
+ u1 -= u0;
11445
+ v1 -= v0;
11446
+ u2 -= u0;
11447
+ v2 -= v0;
11448
+ let det = u1 * v2 - u2 * v1;
11449
+ if (det == 0) return;
11450
+ det = 1 / det;
11451
+ const a = (v2 * x1 - v1 * x2) * det;
11452
+ const b = (v2 * y1 - v1 * y2) * det;
11453
+ const c = (u1 * x2 - u2 * x1) * det;
11454
+ const d = (u1 * y2 - u2 * y1) * det;
11455
+ const e = x0 - a * u0 - c * v0;
11456
+ const f = y0 - b * u0 - d * v0;
11457
+ ctx.save();
11458
+ ctx.transform(a, b, c, d, e, f);
11459
+ ctx.clip();
11460
+ ctx.drawImage(img, 0, 0);
11461
+ ctx.restore();
11462
+ }
11463
+ computeRegionVertices(slot, region, pma) {
11464
+ let skeletonColor = slot.bone.skeleton.color;
11465
+ let slotColor = slot.color;
11466
+ let regionColor = region.color;
11467
+ let alpha = skeletonColor.a * slotColor.a * regionColor.a;
11468
+ let multiplier = pma ? alpha : 1;
11469
+ let color = this.tempColor;
11470
+ color.set(
11471
+ skeletonColor.r * slotColor.r * regionColor.r * multiplier,
11472
+ skeletonColor.g * slotColor.g * regionColor.g * multiplier,
11473
+ skeletonColor.b * slotColor.b * regionColor.b * multiplier,
11474
+ alpha
11475
+ );
11476
+ region.computeWorldVertices(slot, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
11477
+ let vertices = this.vertices;
11478
+ let uvs = region.uvs;
11479
+ vertices[RegionAttachment.C1R] = color.r;
11480
+ vertices[RegionAttachment.C1G] = color.g;
11481
+ vertices[RegionAttachment.C1B] = color.b;
11482
+ vertices[RegionAttachment.C1A] = color.a;
11483
+ vertices[RegionAttachment.U1] = uvs[0];
11484
+ vertices[RegionAttachment.V1] = uvs[1];
11485
+ vertices[RegionAttachment.C2R] = color.r;
11486
+ vertices[RegionAttachment.C2G] = color.g;
11487
+ vertices[RegionAttachment.C2B] = color.b;
11488
+ vertices[RegionAttachment.C2A] = color.a;
11489
+ vertices[RegionAttachment.U2] = uvs[2];
11490
+ vertices[RegionAttachment.V2] = uvs[3];
11491
+ vertices[RegionAttachment.C3R] = color.r;
11492
+ vertices[RegionAttachment.C3G] = color.g;
11493
+ vertices[RegionAttachment.C3B] = color.b;
11494
+ vertices[RegionAttachment.C3A] = color.a;
11495
+ vertices[RegionAttachment.U3] = uvs[4];
11496
+ vertices[RegionAttachment.V3] = uvs[5];
11497
+ vertices[RegionAttachment.C4R] = color.r;
11498
+ vertices[RegionAttachment.C4G] = color.g;
11499
+ vertices[RegionAttachment.C4B] = color.b;
11500
+ vertices[RegionAttachment.C4A] = color.a;
11501
+ vertices[RegionAttachment.U4] = uvs[6];
11502
+ vertices[RegionAttachment.V4] = uvs[7];
11503
+ return vertices;
11504
+ }
11505
+ computeMeshVertices(slot, mesh, pma) {
11506
+ let skeletonColor = slot.bone.skeleton.color;
11507
+ let slotColor = slot.color;
11508
+ let regionColor = mesh.color;
11509
+ let alpha = skeletonColor.a * slotColor.a * regionColor.a;
11510
+ let multiplier = pma ? alpha : 1;
11511
+ let color = this.tempColor;
11512
+ color.set(
11513
+ skeletonColor.r * slotColor.r * regionColor.r * multiplier,
11514
+ skeletonColor.g * slotColor.g * regionColor.g * multiplier,
11515
+ skeletonColor.b * slotColor.b * regionColor.b * multiplier,
11516
+ alpha
11517
+ );
11518
+ let vertexCount = mesh.worldVerticesLength / 2;
11519
+ let vertices = this.vertices;
11520
+ if (vertices.length < mesh.worldVerticesLength) this.vertices = vertices = Utils.newFloatArray(mesh.worldVerticesLength);
11521
+ mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
11522
+ let uvs = mesh.uvs;
11523
+ for (let i = 0, u = 0, v = 2; i < vertexCount; i++) {
11524
+ vertices[v++] = color.r;
11525
+ vertices[v++] = color.g;
11526
+ vertices[v++] = color.b;
11527
+ vertices[v++] = color.a;
11528
+ vertices[v++] = uvs[u++];
11529
+ vertices[v++] = uvs[u++];
11530
+ v += 2;
11531
+ }
11532
+ return vertices;
11533
+ }
11534
+ };
11535
+
11302
11536
  // spine-webgl/src/WebGL.ts
11303
11537
  var ManagedWebGLRenderingContext = class {
11304
11538
  canvas;
@@ -13137,7 +13371,7 @@ var Renderable = class {
13137
13371
  this.numFloats = numFloats;
13138
13372
  }
13139
13373
  };
13140
- var SkeletonRenderer = class _SkeletonRenderer {
13374
+ var SkeletonRenderer2 = class _SkeletonRenderer {
13141
13375
  static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
13142
13376
  premultipliedAlpha = false;
13143
13377
  tempColor = new Color();
@@ -13355,7 +13589,7 @@ var SceneRenderer = class {
13355
13589
  this.batcher = new PolygonBatcher(this.context, twoColorTint);
13356
13590
  this.shapesShader = Shader.newColored(this.context);
13357
13591
  this.shapes = new ShapeRenderer(this.context);
13358
- this.skeletonRenderer = new SkeletonRenderer(this.context, twoColorTint);
13592
+ this.skeletonRenderer = new SkeletonRenderer2(this.context, twoColorTint);
13359
13593
  this.skeletonDebugRenderer = new SkeletonDebugRenderer(this.context);
13360
13594
  }
13361
13595
  dispose() {
@@ -13955,6 +14189,16 @@ var SpineCanvas = class {
13955
14189
  }
13956
14190
  };
13957
14191
 
14192
+ // spine-phaser-v3/src/SpinePlugin.ts
14193
+ import * as Phaser2 from "Phaser";
14194
+
14195
+ // spine-phaser-v3/src/keys.ts
14196
+ var SPINE_SKELETON_FILE_CACHE_KEY = "esotericsoftware.spine.skeletonFile.cache";
14197
+ var SPINE_ATLAS_CACHE_KEY = "esotericsoftware.spine.atlas.cache";
14198
+ var SPINE_SKELETON_DATA_FILE_TYPE = "spineSkeletonData";
14199
+ var SPINE_ATLAS_FILE_TYPE = "spineAtlasData";
14200
+ var SPINE_GAME_OBJECT_TYPE = "spine";
14201
+
13958
14202
  // spine-phaser-v3/src/mixins.ts
13959
14203
  var components = Phaser.GameObjects.Components;
13960
14204
  var ComputedSize = components.ComputedSize;
@@ -14239,251 +14483,8 @@ var SpineGameObject = class extends DepthMixin(
14239
14483
  }
14240
14484
  };
14241
14485
 
14242
- // spine-canvas/src/CanvasTexture.ts
14243
- var CanvasTexture = class extends Texture {
14244
- constructor(image) {
14245
- super(image);
14246
- }
14247
- setFilters(minFilter, magFilter) {
14248
- }
14249
- setWraps(uWrap, vWrap) {
14250
- }
14251
- dispose() {
14252
- }
14253
- };
14254
-
14255
- // spine-canvas/src/SkeletonRenderer.ts
14256
- var worldVertices = Utils.newFloatArray(8);
14257
- var SkeletonRenderer2 = class _SkeletonRenderer {
14258
- static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
14259
- static VERTEX_SIZE = 2 + 2 + 4;
14260
- ctx;
14261
- triangleRendering = false;
14262
- debugRendering = false;
14263
- vertices = Utils.newFloatArray(8 * 1024);
14264
- tempColor = new Color();
14265
- constructor(context) {
14266
- this.ctx = context;
14267
- }
14268
- draw(skeleton) {
14269
- if (this.triangleRendering) this.drawTriangles(skeleton);
14270
- else this.drawImages(skeleton);
14271
- }
14272
- drawImages(skeleton) {
14273
- let ctx = this.ctx;
14274
- let color = this.tempColor;
14275
- let skeletonColor = skeleton.color;
14276
- let drawOrder = skeleton.drawOrder;
14277
- if (this.debugRendering) ctx.strokeStyle = "green";
14278
- for (let i = 0, n = drawOrder.length; i < n; i++) {
14279
- let slot = drawOrder[i];
14280
- let bone = slot.bone;
14281
- if (!bone.active) continue;
14282
- let attachment = slot.getAttachment();
14283
- if (!(attachment instanceof RegionAttachment)) continue;
14284
- attachment.computeWorldVertices(slot, worldVertices, 0, 2);
14285
- let region = attachment.region;
14286
- let image = region.texture.getImage();
14287
- let slotColor = slot.color;
14288
- let regionColor = attachment.color;
14289
- color.set(
14290
- skeletonColor.r * slotColor.r * regionColor.r,
14291
- skeletonColor.g * slotColor.g * regionColor.g,
14292
- skeletonColor.b * slotColor.b * regionColor.b,
14293
- skeletonColor.a * slotColor.a * regionColor.a
14294
- );
14295
- ctx.save();
14296
- ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
14297
- ctx.translate(attachment.offset[0], attachment.offset[1]);
14298
- ctx.rotate(attachment.rotation * Math.PI / 180);
14299
- let atlasScale = attachment.width / region.originalWidth;
14300
- ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
14301
- let w = region.width, h = region.height;
14302
- ctx.translate(w / 2, h / 2);
14303
- if (attachment.region.degrees == 90) {
14304
- let t = w;
14305
- w = h;
14306
- h = t;
14307
- ctx.rotate(-Math.PI / 2);
14308
- }
14309
- ctx.scale(1, -1);
14310
- ctx.translate(-w / 2, -h / 2);
14311
- ctx.globalAlpha = color.a;
14312
- ctx.drawImage(image, image.width * region.u, image.height * region.v, w, h, 0, 0, w, h);
14313
- if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
14314
- ctx.restore();
14315
- }
14316
- }
14317
- drawTriangles(skeleton) {
14318
- let ctx = this.ctx;
14319
- let color = this.tempColor;
14320
- let skeletonColor = skeleton.color;
14321
- let drawOrder = skeleton.drawOrder;
14322
- let blendMode = null;
14323
- let vertices = this.vertices;
14324
- let triangles = null;
14325
- for (let i = 0, n = drawOrder.length; i < n; i++) {
14326
- let slot = drawOrder[i];
14327
- let attachment = slot.getAttachment();
14328
- let texture;
14329
- let region;
14330
- if (attachment instanceof RegionAttachment) {
14331
- let regionAttachment = attachment;
14332
- vertices = this.computeRegionVertices(slot, regionAttachment, false);
14333
- triangles = _SkeletonRenderer.QUAD_TRIANGLES;
14334
- texture = regionAttachment.region.texture.getImage();
14335
- } else if (attachment instanceof MeshAttachment) {
14336
- let mesh = attachment;
14337
- vertices = this.computeMeshVertices(slot, mesh, false);
14338
- triangles = mesh.triangles;
14339
- texture = mesh.region.texture.getImage();
14340
- } else
14341
- continue;
14342
- if (texture) {
14343
- if (slot.data.blendMode != blendMode) blendMode = slot.data.blendMode;
14344
- let slotColor = slot.color;
14345
- let attachmentColor = attachment.color;
14346
- color.set(
14347
- skeletonColor.r * slotColor.r * attachmentColor.r,
14348
- skeletonColor.g * slotColor.g * attachmentColor.g,
14349
- skeletonColor.b * slotColor.b * attachmentColor.b,
14350
- skeletonColor.a * slotColor.a * attachmentColor.a
14351
- );
14352
- ctx.globalAlpha = color.a;
14353
- for (var j = 0; j < triangles.length; j += 3) {
14354
- let t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
14355
- let x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
14356
- let x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
14357
- let x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
14358
- this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
14359
- if (this.debugRendering) {
14360
- ctx.strokeStyle = "green";
14361
- ctx.beginPath();
14362
- ctx.moveTo(x0, y0);
14363
- ctx.lineTo(x1, y1);
14364
- ctx.lineTo(x2, y2);
14365
- ctx.lineTo(x0, y0);
14366
- ctx.stroke();
14367
- }
14368
- }
14369
- }
14370
- }
14371
- this.ctx.globalAlpha = 1;
14372
- }
14373
- // Adapted from http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
14374
- // Apache 2 licensed
14375
- drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
14376
- let ctx = this.ctx;
14377
- const width = img.width - 1;
14378
- const height = img.height - 1;
14379
- u0 *= width;
14380
- v0 *= height;
14381
- u1 *= width;
14382
- v1 *= height;
14383
- u2 *= width;
14384
- v2 *= height;
14385
- ctx.beginPath();
14386
- ctx.moveTo(x0, y0);
14387
- ctx.lineTo(x1, y1);
14388
- ctx.lineTo(x2, y2);
14389
- ctx.closePath();
14390
- x1 -= x0;
14391
- y1 -= y0;
14392
- x2 -= x0;
14393
- y2 -= y0;
14394
- u1 -= u0;
14395
- v1 -= v0;
14396
- u2 -= u0;
14397
- v2 -= v0;
14398
- let det = u1 * v2 - u2 * v1;
14399
- if (det == 0) return;
14400
- det = 1 / det;
14401
- const a = (v2 * x1 - v1 * x2) * det;
14402
- const b = (v2 * y1 - v1 * y2) * det;
14403
- const c = (u1 * x2 - u2 * x1) * det;
14404
- const d = (u1 * y2 - u2 * y1) * det;
14405
- const e = x0 - a * u0 - c * v0;
14406
- const f = y0 - b * u0 - d * v0;
14407
- ctx.save();
14408
- ctx.transform(a, b, c, d, e, f);
14409
- ctx.clip();
14410
- ctx.drawImage(img, 0, 0);
14411
- ctx.restore();
14412
- }
14413
- computeRegionVertices(slot, region, pma) {
14414
- let skeletonColor = slot.bone.skeleton.color;
14415
- let slotColor = slot.color;
14416
- let regionColor = region.color;
14417
- let alpha = skeletonColor.a * slotColor.a * regionColor.a;
14418
- let multiplier = pma ? alpha : 1;
14419
- let color = this.tempColor;
14420
- color.set(
14421
- skeletonColor.r * slotColor.r * regionColor.r * multiplier,
14422
- skeletonColor.g * slotColor.g * regionColor.g * multiplier,
14423
- skeletonColor.b * slotColor.b * regionColor.b * multiplier,
14424
- alpha
14425
- );
14426
- region.computeWorldVertices(slot, this.vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
14427
- let vertices = this.vertices;
14428
- let uvs = region.uvs;
14429
- vertices[RegionAttachment.C1R] = color.r;
14430
- vertices[RegionAttachment.C1G] = color.g;
14431
- vertices[RegionAttachment.C1B] = color.b;
14432
- vertices[RegionAttachment.C1A] = color.a;
14433
- vertices[RegionAttachment.U1] = uvs[0];
14434
- vertices[RegionAttachment.V1] = uvs[1];
14435
- vertices[RegionAttachment.C2R] = color.r;
14436
- vertices[RegionAttachment.C2G] = color.g;
14437
- vertices[RegionAttachment.C2B] = color.b;
14438
- vertices[RegionAttachment.C2A] = color.a;
14439
- vertices[RegionAttachment.U2] = uvs[2];
14440
- vertices[RegionAttachment.V2] = uvs[3];
14441
- vertices[RegionAttachment.C3R] = color.r;
14442
- vertices[RegionAttachment.C3G] = color.g;
14443
- vertices[RegionAttachment.C3B] = color.b;
14444
- vertices[RegionAttachment.C3A] = color.a;
14445
- vertices[RegionAttachment.U3] = uvs[4];
14446
- vertices[RegionAttachment.V3] = uvs[5];
14447
- vertices[RegionAttachment.C4R] = color.r;
14448
- vertices[RegionAttachment.C4G] = color.g;
14449
- vertices[RegionAttachment.C4B] = color.b;
14450
- vertices[RegionAttachment.C4A] = color.a;
14451
- vertices[RegionAttachment.U4] = uvs[6];
14452
- vertices[RegionAttachment.V4] = uvs[7];
14453
- return vertices;
14454
- }
14455
- computeMeshVertices(slot, mesh, pma) {
14456
- let skeletonColor = slot.bone.skeleton.color;
14457
- let slotColor = slot.color;
14458
- let regionColor = mesh.color;
14459
- let alpha = skeletonColor.a * slotColor.a * regionColor.a;
14460
- let multiplier = pma ? alpha : 1;
14461
- let color = this.tempColor;
14462
- color.set(
14463
- skeletonColor.r * slotColor.r * regionColor.r * multiplier,
14464
- skeletonColor.g * slotColor.g * regionColor.g * multiplier,
14465
- skeletonColor.b * slotColor.b * regionColor.b * multiplier,
14466
- alpha
14467
- );
14468
- let vertexCount = mesh.worldVerticesLength / 2;
14469
- let vertices = this.vertices;
14470
- if (vertices.length < mesh.worldVerticesLength) this.vertices = vertices = Utils.newFloatArray(mesh.worldVerticesLength);
14471
- mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, _SkeletonRenderer.VERTEX_SIZE);
14472
- let uvs = mesh.uvs;
14473
- for (let i = 0, u = 0, v = 2; i < vertexCount; i++) {
14474
- vertices[v++] = color.r;
14475
- vertices[v++] = color.g;
14476
- vertices[v++] = color.b;
14477
- vertices[v++] = color.a;
14478
- vertices[v++] = uvs[u++];
14479
- vertices[v++] = uvs[u++];
14480
- v += 2;
14481
- }
14482
- return vertices;
14483
- }
14484
- };
14485
-
14486
14486
  // spine-phaser-v3/src/SpinePlugin.ts
14487
+ Skeleton.yDown = true;
14487
14488
  var SpinePlugin = class _SpinePlugin extends Phaser2.Plugins.ScenePlugin {
14488
14489
  game;
14489
14490
  isWebGL;
@@ -14557,29 +14558,25 @@ var SpinePlugin = class _SpinePlugin extends Phaser2.Plugins.ScenePlugin {
14557
14558
  }
14558
14559
  static rendererId = 0;
14559
14560
  boot() {
14560
- Skeleton.yDown = true;
14561
- if (this.isWebGL) {
14562
- if (!_SpinePlugin.gameWebGLRenderer) {
14563
- _SpinePlugin.gameWebGLRenderer = new SceneRenderer(this.game.renderer.canvas, this.gl, true);
14564
- }
14565
- this.onResize();
14566
- this.game.scale.on(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14567
- } else {
14568
- if (!this.canvasRenderer) {
14569
- this.canvasRenderer = new SkeletonRenderer2(this.scene.sys.context);
14570
- }
14561
+ if (this.isWebGL && this.gl) {
14562
+ _SpinePlugin.gameWebGLRenderer ||= new SceneRenderer(this.game.renderer.canvas, this.gl, true);
14563
+ } else if (this.scene) {
14564
+ this.canvasRenderer ||= new SkeletonRenderer(this.scene.sys.context);
14565
+ }
14566
+ this.onResize();
14567
+ if (this.systems) {
14568
+ this.systems.events.once("destroy", this.destroy, this);
14569
+ this.systems.events.on("start", this.onStart, this);
14570
+ this.systems.events.on("shutdown", this.shutdown, this);
14571
14571
  }
14572
- var eventEmitter = this.systems.events;
14573
- eventEmitter.once("shutdown", this.shutdown, this);
14574
- eventEmitter.once("destroy", this.destroy, this);
14575
14572
  this.game.events.once("destroy", this.gameDestroy, this);
14576
14573
  }
14577
14574
  onResize() {
14578
- var phaserRenderer = this.game.renderer;
14579
- var sceneRenderer = this.webGLRenderer;
14575
+ const phaserRenderer = this.game.renderer;
14576
+ const sceneRenderer = this.webGLRenderer;
14580
14577
  if (phaserRenderer && sceneRenderer) {
14581
- var viewportWidth = phaserRenderer.width;
14582
- var viewportHeight = phaserRenderer.height;
14578
+ const viewportWidth = phaserRenderer.width;
14579
+ const viewportHeight = phaserRenderer.height;
14583
14580
  sceneRenderer.camera.position.x = viewportWidth / 2;
14584
14581
  sceneRenderer.camera.position.y = viewportHeight / 2;
14585
14582
  sceneRenderer.camera.up.y = -1;
@@ -14587,14 +14584,18 @@ var SpinePlugin = class _SpinePlugin extends Phaser2.Plugins.ScenePlugin {
14587
14584
  sceneRenderer.camera.setViewport(viewportWidth, viewportHeight);
14588
14585
  }
14589
14586
  }
14587
+ onStart() {
14588
+ this.game.scale.on(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14589
+ }
14590
14590
  shutdown() {
14591
- this.systems.events.off("shutdown", this.shutdown, this);
14592
14591
  if (this.isWebGL) {
14593
14592
  this.game.scale.off(Phaser2.Scale.Events.RESIZE, this.onResize, this);
14594
14593
  }
14595
14594
  }
14596
14595
  destroy() {
14597
14596
  this.shutdown();
14597
+ this.systems?.events.off("start", this.onStart, this);
14598
+ this.systems?.events.off("shutdown", this.shutdown, this);
14598
14599
  }
14599
14600
  gameDestroy() {
14600
14601
  this.pluginManager.removeGameObject(window.SPINE_GAME_OBJECT_TYPE ? window.SPINE_GAME_OBJECT_TYPE : SPINE_GAME_OBJECT_TYPE, true, true);
@@ -14907,7 +14908,7 @@ export {
14907
14908
  SkeletonData,
14908
14909
  SkeletonDebugRenderer,
14909
14910
  SkeletonJson,
14910
- SkeletonRenderer,
14911
+ SkeletonRenderer2 as SkeletonRenderer,
14911
14912
  Skin,
14912
14913
  SkinEntry,
14913
14914
  SkinsAndAnimationBoundsProvider,