@esotericsoftware/spine-webgl 4.2.20 → 4.2.22

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
 
@@ -10823,83 +10822,6 @@ var spine = (() => {
10823
10822
  this.restorables.splice(index, 1);
10824
10823
  }
10825
10824
  };
10826
- var ONE = 1;
10827
- var ONE_MINUS_SRC_COLOR = 769;
10828
- var SRC_ALPHA = 770;
10829
- var ONE_MINUS_SRC_ALPHA = 771;
10830
- var DST_COLOR = 774;
10831
- var WebGLBlendModeConverter = class {
10832
- static getDestGLBlendMode(blendMode) {
10833
- switch (blendMode) {
10834
- case 0 /* Normal */:
10835
- return ONE_MINUS_SRC_ALPHA;
10836
- case 1 /* Additive */:
10837
- return ONE;
10838
- case 2 /* Multiply */:
10839
- return ONE_MINUS_SRC_ALPHA;
10840
- case 3 /* Screen */:
10841
- return ONE_MINUS_SRC_ALPHA;
10842
- default:
10843
- throw new Error("Unknown blend mode: " + blendMode);
10844
- }
10845
- }
10846
- static getDestColorGLBlendMode(blendMode) {
10847
- switch (blendMode) {
10848
- case 0 /* Normal */:
10849
- return ONE_MINUS_SRC_ALPHA;
10850
- case 1 /* Additive */:
10851
- return ONE;
10852
- case 2 /* Multiply */:
10853
- return ONE_MINUS_SRC_ALPHA;
10854
- case 3 /* Screen */:
10855
- return ONE_MINUS_SRC_COLOR;
10856
- default:
10857
- throw new Error("Unknown blend mode: " + blendMode);
10858
- }
10859
- }
10860
- static getDestAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10861
- switch (blendMode) {
10862
- case 0 /* Normal */:
10863
- return ONE_MINUS_SRC_ALPHA;
10864
- case 1 /* Additive */:
10865
- return premultipliedAlpha ? ONE_MINUS_SRC_ALPHA : ONE;
10866
- case 2 /* Multiply */:
10867
- return ONE_MINUS_SRC_ALPHA;
10868
- case 3 /* Screen */:
10869
- return ONE_MINUS_SRC_ALPHA;
10870
- default:
10871
- throw new Error("Unknown blend mode: " + blendMode);
10872
- }
10873
- }
10874
- static getSourceColorGLBlendMode(blendMode, premultipliedAlpha = false) {
10875
- switch (blendMode) {
10876
- case 0 /* Normal */:
10877
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10878
- case 1 /* Additive */:
10879
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10880
- case 2 /* Multiply */:
10881
- return DST_COLOR;
10882
- case 3 /* Screen */:
10883
- return premultipliedAlpha ? ONE : SRC_ALPHA;
10884
- default:
10885
- throw new Error("Unknown blend mode: " + blendMode);
10886
- }
10887
- }
10888
- static getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10889
- switch (blendMode) {
10890
- case 0 /* Normal */:
10891
- return premultipliedAlpha ? SRC_ALPHA : ONE;
10892
- case 1 /* Additive */:
10893
- return premultipliedAlpha ? SRC_ALPHA : ONE;
10894
- case 2 /* Multiply */:
10895
- return ONE;
10896
- case 3 /* Screen */:
10897
- return ONE;
10898
- default:
10899
- throw new Error("Unknown blend mode: " + blendMode);
10900
- }
10901
- }
10902
- };
10903
10825
 
10904
10826
  // spine-webgl/src/GLTexture.ts
10905
10827
  var _GLTexture = class extends Texture {
@@ -12102,6 +12024,11 @@ void main () {
12102
12024
  })(VertexAttributeType || {});
12103
12025
 
12104
12026
  // spine-webgl/src/PolygonBatcher.ts
12027
+ var GL_ONE = 1;
12028
+ var GL_ONE_MINUS_SRC_COLOR = 769;
12029
+ var GL_SRC_ALPHA = 770;
12030
+ var GL_ONE_MINUS_SRC_ALPHA = 771;
12031
+ var GL_DST_COLOR = 774;
12105
12032
  var _PolygonBatcher = class {
12106
12033
  constructor(context, twoColorTint = true, maxVertices = 10920) {
12107
12034
  this.drawCalls = 0;
@@ -12119,8 +12046,7 @@ void main () {
12119
12046
  let gl = this.context.gl;
12120
12047
  this.srcColorBlend = gl.SRC_ALPHA;
12121
12048
  this.srcAlphaBlend = gl.ONE;
12122
- this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12123
- this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12049
+ this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12124
12050
  }
12125
12051
  begin(shader) {
12126
12052
  if (this.isDrawing)
@@ -12131,25 +12057,28 @@ void main () {
12131
12057
  this.isDrawing = true;
12132
12058
  let gl = this.context.gl;
12133
12059
  gl.enable(gl.BLEND);
12134
- gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12060
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12135
12061
  if (_PolygonBatcher.disableCulling) {
12136
12062
  this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
12137
12063
  if (this.cullWasEnabled)
12138
12064
  gl.disable(gl.CULL_FACE);
12139
12065
  }
12140
12066
  }
12141
- setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12142
- if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstColorBlend == dstColorBlend && this.dstAlphaBlend == dstAlphaBlend)
12067
+ setBlendMode(blendMode, premultipliedAlpha) {
12068
+ const blendModeGL = _PolygonBatcher.blendModesGL[blendMode];
12069
+ const srcColorBlend = premultipliedAlpha ? blendModeGL.srcRgbPma : blendModeGL.srcRgb;
12070
+ const srcAlphaBlend = blendModeGL.srcAlpha;
12071
+ const dstBlend = blendModeGL.dstRgb;
12072
+ if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
12143
12073
  return;
12144
12074
  this.srcColorBlend = srcColorBlend;
12145
12075
  this.srcAlphaBlend = srcAlphaBlend;
12146
- this.dstColorBlend = dstColorBlend;
12147
- this.dstAlphaBlend = dstAlphaBlend;
12076
+ this.dstBlend = dstBlend;
12148
12077
  if (this.isDrawing) {
12149
12078
  this.flush();
12150
- let gl = this.context.gl;
12151
- gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12152
12079
  }
12080
+ let gl = this.context.gl;
12081
+ gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12153
12082
  }
12154
12083
  draw(texture, vertices, indices) {
12155
12084
  if (texture != this.lastTexture) {
@@ -12214,6 +12143,12 @@ void main () {
12214
12143
  var PolygonBatcher = _PolygonBatcher;
12215
12144
  PolygonBatcher.disableCulling = false;
12216
12145
  PolygonBatcher.globalDrawCalls = 0;
12146
+ PolygonBatcher.blendModesGL = [
12147
+ { srcRgb: GL_SRC_ALPHA, srcRgbPma: GL_ONE, dstRgb: GL_ONE_MINUS_SRC_ALPHA, srcAlpha: GL_ONE },
12148
+ { srcRgb: GL_SRC_ALPHA, srcRgbPma: GL_ONE, dstRgb: GL_ONE, srcAlpha: GL_ONE },
12149
+ { srcRgb: GL_DST_COLOR, srcRgbPma: GL_DST_COLOR, dstRgb: GL_ONE_MINUS_SRC_ALPHA, srcAlpha: GL_ONE },
12150
+ { srcRgb: GL_ONE, srcRgbPma: GL_ONE, dstRgb: GL_ONE_MINUS_SRC_COLOR, srcAlpha: GL_ONE }
12151
+ ];
12217
12152
 
12218
12153
  // spine-webgl/src/ShapeRenderer.ts
12219
12154
  var ShapeRenderer = class {
@@ -12231,8 +12166,7 @@ void main () {
12231
12166
  let gl = this.context.gl;
12232
12167
  this.srcColorBlend = gl.SRC_ALPHA;
12233
12168
  this.srcAlphaBlend = gl.ONE;
12234
- this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12235
- this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12169
+ this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12236
12170
  }
12237
12171
  begin(shader) {
12238
12172
  if (this.isDrawing)
@@ -12242,17 +12176,16 @@ void main () {
12242
12176
  this.isDrawing = true;
12243
12177
  let gl = this.context.gl;
12244
12178
  gl.enable(gl.BLEND);
12245
- gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12179
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12246
12180
  }
12247
- setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12181
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12248
12182
  this.srcColorBlend = srcColorBlend;
12249
12183
  this.srcAlphaBlend = srcAlphaBlend;
12250
- this.dstColorBlend = dstColorBlend;
12251
- this.dstAlphaBlend = dstAlphaBlend;
12184
+ this.dstBlend = dstBlend;
12252
12185
  if (this.isDrawing) {
12253
12186
  this.flush();
12254
12187
  let gl = this.context.gl;
12255
- gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12188
+ gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12256
12189
  }
12257
12190
  }
12258
12191
  setColor(color) {
@@ -12551,7 +12484,7 @@ void main () {
12551
12484
  let skeletonY = skeleton.y;
12552
12485
  let gl = this.context.gl;
12553
12486
  let srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
12554
- shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
12487
+ shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
12555
12488
  let bones = skeleton.bones;
12556
12489
  if (this.drawBones) {
12557
12490
  shapes.setColor(this.boneLineColor);
@@ -12754,10 +12687,6 @@ void main () {
12754
12687
  let premultipliedAlpha = this.premultipliedAlpha;
12755
12688
  let twoColorTint = this.twoColorTint;
12756
12689
  let blendMode = null;
12757
- let tempPos = this.temp;
12758
- let tempUv = this.temp2;
12759
- let tempLight = this.temp3;
12760
- let tempDark = this.temp4;
12761
12690
  let renderable = this.renderable;
12762
12691
  let uvs;
12763
12692
  let triangles;
@@ -12846,12 +12775,7 @@ void main () {
12846
12775
  let slotBlendMode = slot.data.blendMode;
12847
12776
  if (slotBlendMode != blendMode) {
12848
12777
  blendMode = slotBlendMode;
12849
- batcher.setBlendMode(
12850
- WebGLBlendModeConverter.getSourceColorGLBlendMode(blendMode, premultipliedAlpha),
12851
- WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha),
12852
- WebGLBlendModeConverter.getDestColorGLBlendMode(blendMode),
12853
- WebGLBlendModeConverter.getDestAlphaGLBlendMode(blendMode, premultipliedAlpha)
12854
- );
12778
+ batcher.setBlendMode(blendMode, premultipliedAlpha);
12855
12779
  }
12856
12780
  if (clipper.isClipping()) {
12857
12781
  clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
@@ -13415,7 +13339,7 @@ void main () {
13415
13339
  let gl = renderer.context.gl;
13416
13340
  renderer.resize(1 /* Expand */);
13417
13341
  renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
13418
- renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
13342
+ renderer.batcher.setBlendMode(0 /* Normal */, true);
13419
13343
  if (complete) {
13420
13344
  this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
13421
13345
  if (this.fadeOut > FADE_OUT)