@esotericsoftware/spine-webgl 4.1.40 → 4.1.41

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.
@@ -168,7 +168,6 @@ var spine = (() => {
168
168
  VertexAttachment: () => VertexAttachment,
169
169
  VertexAttribute: () => VertexAttribute,
170
170
  VertexAttributeType: () => VertexAttributeType,
171
- WebGLBlendModeConverter: () => WebGLBlendModeConverter,
172
171
  WindowedMean: () => WindowedMean
173
172
  });
174
173
 
@@ -10779,83 +10778,6 @@ var spine = (() => {
10779
10778
  this.restorables.splice(index, 1);
10780
10779
  }
10781
10780
  };
10782
- var ONE = 1;
10783
- var ONE_MINUS_SRC_COLOR = 769;
10784
- var SRC_ALPHA = 770;
10785
- var ONE_MINUS_SRC_ALPHA = 771;
10786
- var DST_COLOR = 774;
10787
- var WebGLBlendModeConverter = class {
10788
- static getDestGLBlendMode(blendMode) {
10789
- switch (blendMode) {
10790
- case 0 /* Normal */:
10791
- return ONE_MINUS_SRC_ALPHA;
10792
- case 1 /* Additive */:
10793
- return ONE;
10794
- case 2 /* Multiply */:
10795
- return ONE_MINUS_SRC_ALPHA;
10796
- case 3 /* Screen */:
10797
- return ONE_MINUS_SRC_ALPHA;
10798
- default:
10799
- throw new Error("Unknown blend mode: " + blendMode);
10800
- }
10801
- }
10802
- static getDestColorGLBlendMode(blendMode) {
10803
- switch (blendMode) {
10804
- case 0 /* Normal */:
10805
- return ONE_MINUS_SRC_ALPHA;
10806
- case 1 /* Additive */:
10807
- return ONE;
10808
- case 2 /* Multiply */:
10809
- return ONE_MINUS_SRC_ALPHA;
10810
- case 3 /* Screen */:
10811
- return ONE_MINUS_SRC_COLOR;
10812
- default:
10813
- throw new Error("Unknown blend mode: " + blendMode);
10814
- }
10815
- }
10816
- static getDestAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10817
- switch (blendMode) {
10818
- case 0 /* Normal */:
10819
- return ONE_MINUS_SRC_ALPHA;
10820
- case 1 /* Additive */:
10821
- return premultipliedAlpha ? ONE_MINUS_SRC_ALPHA : ONE;
10822
- case 2 /* Multiply */:
10823
- return ONE_MINUS_SRC_ALPHA;
10824
- case 3 /* Screen */:
10825
- return ONE_MINUS_SRC_ALPHA;
10826
- default:
10827
- throw new Error("Unknown blend mode: " + blendMode);
10828
- }
10829
- }
10830
- static getSourceColorGLBlendMode(blendMode, premultipliedAlpha = false) {
10831
- switch (blendMode) {
10832
- case 0 /* Normal */:
10833
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10834
- case 1 /* Additive */:
10835
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10836
- case 2 /* Multiply */:
10837
- return DST_COLOR;
10838
- case 3 /* Screen */:
10839
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10840
- default:
10841
- throw new Error("Unknown blend mode: " + blendMode);
10842
- }
10843
- }
10844
- static getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10845
- switch (blendMode) {
10846
- case 0 /* Normal */:
10847
- return premultipliedAlpha ? SRC_ALPHA : ONE;
10848
- case 1 /* Additive */:
10849
- return premultipliedAlpha ? SRC_ALPHA : ONE;
10850
- case 2 /* Multiply */:
10851
- return ONE;
10852
- case 3 /* Screen */:
10853
- return ONE;
10854
- default:
10855
- throw new Error("Unknown blend mode: " + blendMode);
10856
- }
10857
- }
10858
- };
10859
10781
 
10860
10782
  // spine-webgl/src/GLTexture.ts
10861
10783
  var _GLTexture = class extends Texture {
@@ -12060,6 +11982,11 @@ void main () {
12060
11982
  })(VertexAttributeType || {});
12061
11983
 
12062
11984
  // spine-webgl/src/PolygonBatcher.ts
11985
+ var GL_ONE = 1;
11986
+ var GL_ONE_MINUS_SRC_COLOR = 769;
11987
+ var GL_SRC_ALPHA = 770;
11988
+ var GL_ONE_MINUS_SRC_ALPHA = 771;
11989
+ var GL_DST_COLOR = 774;
12063
11990
  var _PolygonBatcher = class {
12064
11991
  constructor(context, twoColorTint = true, maxVertices = 10920) {
12065
11992
  this.drawCalls = 0;
@@ -12077,8 +12004,7 @@ void main () {
12077
12004
  let gl = this.context.gl;
12078
12005
  this.srcColorBlend = gl.SRC_ALPHA;
12079
12006
  this.srcAlphaBlend = gl.ONE;
12080
- this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12081
- this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12007
+ this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12082
12008
  }
12083
12009
  begin(shader) {
12084
12010
  if (this.isDrawing)
@@ -12089,25 +12015,28 @@ void main () {
12089
12015
  this.isDrawing = true;
12090
12016
  let gl = this.context.gl;
12091
12017
  gl.enable(gl.BLEND);
12092
- gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12018
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12093
12019
  if (_PolygonBatcher.disableCulling) {
12094
12020
  this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
12095
12021
  if (this.cullWasEnabled)
12096
12022
  gl.disable(gl.CULL_FACE);
12097
12023
  }
12098
12024
  }
12099
- setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12100
- if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstColorBlend == dstColorBlend && this.dstAlphaBlend == dstAlphaBlend)
12025
+ setBlendMode(blendMode, premultipliedAlpha) {
12026
+ const blendModeGL = _PolygonBatcher.blendModesGL[blendMode];
12027
+ const srcColorBlend = premultipliedAlpha ? blendModeGL.srcRgbPma : blendModeGL.srcRgb;
12028
+ const srcAlphaBlend = blendModeGL.srcAlpha;
12029
+ const dstBlend = blendModeGL.dstRgb;
12030
+ if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
12101
12031
  return;
12102
12032
  this.srcColorBlend = srcColorBlend;
12103
12033
  this.srcAlphaBlend = srcAlphaBlend;
12104
- this.dstColorBlend = dstColorBlend;
12105
- this.dstAlphaBlend = dstAlphaBlend;
12034
+ this.dstBlend = dstBlend;
12106
12035
  if (this.isDrawing) {
12107
12036
  this.flush();
12108
- let gl = this.context.gl;
12109
- gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12110
12037
  }
12038
+ let gl = this.context.gl;
12039
+ gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12111
12040
  }
12112
12041
  draw(texture, vertices, indices) {
12113
12042
  if (texture != this.lastTexture) {
@@ -12172,6 +12101,12 @@ void main () {
12172
12101
  var PolygonBatcher = _PolygonBatcher;
12173
12102
  PolygonBatcher.disableCulling = false;
12174
12103
  PolygonBatcher.globalDrawCalls = 0;
12104
+ PolygonBatcher.blendModesGL = [
12105
+ { srcRgb: GL_SRC_ALPHA, srcRgbPma: GL_ONE, dstRgb: GL_ONE_MINUS_SRC_ALPHA, srcAlpha: GL_ONE },
12106
+ { srcRgb: GL_SRC_ALPHA, srcRgbPma: GL_ONE, dstRgb: GL_ONE, srcAlpha: GL_ONE },
12107
+ { srcRgb: GL_DST_COLOR, srcRgbPma: GL_DST_COLOR, dstRgb: GL_ONE_MINUS_SRC_ALPHA, srcAlpha: GL_ONE },
12108
+ { srcRgb: GL_ONE, srcRgbPma: GL_ONE, dstRgb: GL_ONE_MINUS_SRC_COLOR, srcAlpha: GL_ONE }
12109
+ ];
12175
12110
 
12176
12111
  // spine-webgl/src/ShapeRenderer.ts
12177
12112
  var ShapeRenderer = class {
@@ -12189,8 +12124,7 @@ void main () {
12189
12124
  let gl = this.context.gl;
12190
12125
  this.srcColorBlend = gl.SRC_ALPHA;
12191
12126
  this.srcAlphaBlend = gl.ONE;
12192
- this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12193
- this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12127
+ this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12194
12128
  }
12195
12129
  begin(shader) {
12196
12130
  if (this.isDrawing)
@@ -12200,17 +12134,16 @@ void main () {
12200
12134
  this.isDrawing = true;
12201
12135
  let gl = this.context.gl;
12202
12136
  gl.enable(gl.BLEND);
12203
- gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12137
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12204
12138
  }
12205
- setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12139
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12206
12140
  this.srcColorBlend = srcColorBlend;
12207
12141
  this.srcAlphaBlend = srcAlphaBlend;
12208
- this.dstColorBlend = dstColorBlend;
12209
- this.dstAlphaBlend = dstAlphaBlend;
12142
+ this.dstBlend = dstBlend;
12210
12143
  if (this.isDrawing) {
12211
12144
  this.flush();
12212
12145
  let gl = this.context.gl;
12213
- gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12146
+ gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12214
12147
  }
12215
12148
  }
12216
12149
  setColor(color) {
@@ -12509,7 +12442,7 @@ void main () {
12509
12442
  let skeletonY = skeleton.y;
12510
12443
  let gl = this.context.gl;
12511
12444
  let srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
12512
- shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
12445
+ shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
12513
12446
  let bones = skeleton.bones;
12514
12447
  if (this.drawBones) {
12515
12448
  shapes.setColor(this.boneLineColor);
@@ -12712,10 +12645,6 @@ void main () {
12712
12645
  let premultipliedAlpha = this.premultipliedAlpha;
12713
12646
  let twoColorTint = this.twoColorTint;
12714
12647
  let blendMode = null;
12715
- let tempPos = this.temp;
12716
- let tempUv = this.temp2;
12717
- let tempLight = this.temp3;
12718
- let tempDark = this.temp4;
12719
12648
  let renderable = this.renderable;
12720
12649
  let uvs;
12721
12650
  let triangles;
@@ -12804,12 +12733,7 @@ void main () {
12804
12733
  let slotBlendMode = slot.data.blendMode;
12805
12734
  if (slotBlendMode != blendMode) {
12806
12735
  blendMode = slotBlendMode;
12807
- batcher.setBlendMode(
12808
- WebGLBlendModeConverter.getSourceColorGLBlendMode(blendMode, premultipliedAlpha),
12809
- WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha),
12810
- WebGLBlendModeConverter.getDestColorGLBlendMode(blendMode),
12811
- WebGLBlendModeConverter.getDestAlphaGLBlendMode(blendMode, premultipliedAlpha)
12812
- );
12736
+ batcher.setBlendMode(blendMode, premultipliedAlpha);
12813
12737
  }
12814
12738
  if (clipper.isClipping()) {
12815
12739
  clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
@@ -13373,7 +13297,7 @@ void main () {
13373
13297
  let gl = renderer.context.gl;
13374
13298
  renderer.resize(1 /* Expand */);
13375
13299
  renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
13376
- renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
13300
+ renderer.batcher.setBlendMode(0 /* Normal */, true);
13377
13301
  if (complete) {
13378
13302
  this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
13379
13303
  if (this.fadeOut > FADE_OUT)