@esotericsoftware/spine-webgl 4.1.37 → 4.1.38

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.
@@ -10799,6 +10799,34 @@ var spine = (() => {
10799
10799
  throw new Error("Unknown blend mode: " + blendMode);
10800
10800
  }
10801
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
+ }
10802
10830
  static getSourceColorGLBlendMode(blendMode, premultipliedAlpha = false) {
10803
10831
  switch (blendMode) {
10804
10832
  case 0 /* Normal */:
@@ -10808,21 +10836,21 @@ var spine = (() => {
10808
10836
  case 2 /* Multiply */:
10809
10837
  return DST_COLOR;
10810
10838
  case 3 /* Screen */:
10811
- return ONE;
10839
+ return premultipliedAlpha ? ONE : SRC_ALPHA;
10812
10840
  default:
10813
10841
  throw new Error("Unknown blend mode: " + blendMode);
10814
10842
  }
10815
10843
  }
10816
- static getSourceAlphaGLBlendMode(blendMode) {
10844
+ static getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10817
10845
  switch (blendMode) {
10818
10846
  case 0 /* Normal */:
10819
- return ONE;
10847
+ return premultipliedAlpha ? SRC_ALPHA : ONE;
10820
10848
  case 1 /* Additive */:
10821
- return ONE;
10849
+ return premultipliedAlpha ? SRC_ALPHA : ONE;
10822
10850
  case 2 /* Multiply */:
10823
- return ONE_MINUS_SRC_ALPHA;
10851
+ return ONE;
10824
10852
  case 3 /* Screen */:
10825
- return ONE_MINUS_SRC_COLOR;
10853
+ return ONE;
10826
10854
  default:
10827
10855
  throw new Error("Unknown blend mode: " + blendMode);
10828
10856
  }
@@ -12049,7 +12077,8 @@ void main () {
12049
12077
  let gl = this.context.gl;
12050
12078
  this.srcColorBlend = gl.SRC_ALPHA;
12051
12079
  this.srcAlphaBlend = gl.ONE;
12052
- this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12080
+ this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12081
+ this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12053
12082
  }
12054
12083
  begin(shader) {
12055
12084
  if (this.isDrawing)
@@ -12060,23 +12089,24 @@ void main () {
12060
12089
  this.isDrawing = true;
12061
12090
  let gl = this.context.gl;
12062
12091
  gl.enable(gl.BLEND);
12063
- gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12092
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12064
12093
  if (_PolygonBatcher.disableCulling) {
12065
12094
  this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
12066
12095
  if (this.cullWasEnabled)
12067
12096
  gl.disable(gl.CULL_FACE);
12068
12097
  }
12069
12098
  }
12070
- setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12071
- if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
12099
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12100
+ if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstColorBlend == dstColorBlend && this.dstAlphaBlend == dstAlphaBlend)
12072
12101
  return;
12073
12102
  this.srcColorBlend = srcColorBlend;
12074
12103
  this.srcAlphaBlend = srcAlphaBlend;
12075
- this.dstBlend = dstBlend;
12104
+ this.dstColorBlend = dstColorBlend;
12105
+ this.dstAlphaBlend = dstAlphaBlend;
12076
12106
  if (this.isDrawing) {
12077
12107
  this.flush();
12078
12108
  let gl = this.context.gl;
12079
- gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12109
+ gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12080
12110
  }
12081
12111
  }
12082
12112
  draw(texture, vertices, indices) {
@@ -12159,7 +12189,8 @@ void main () {
12159
12189
  let gl = this.context.gl;
12160
12190
  this.srcColorBlend = gl.SRC_ALPHA;
12161
12191
  this.srcAlphaBlend = gl.ONE;
12162
- this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12192
+ this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12193
+ this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12163
12194
  }
12164
12195
  begin(shader) {
12165
12196
  if (this.isDrawing)
@@ -12169,16 +12200,17 @@ void main () {
12169
12200
  this.isDrawing = true;
12170
12201
  let gl = this.context.gl;
12171
12202
  gl.enable(gl.BLEND);
12172
- gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12203
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12173
12204
  }
12174
- setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12205
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12175
12206
  this.srcColorBlend = srcColorBlend;
12176
12207
  this.srcAlphaBlend = srcAlphaBlend;
12177
- this.dstBlend = dstBlend;
12208
+ this.dstColorBlend = dstColorBlend;
12209
+ this.dstAlphaBlend = dstAlphaBlend;
12178
12210
  if (this.isDrawing) {
12179
12211
  this.flush();
12180
12212
  let gl = this.context.gl;
12181
- gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12213
+ gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12182
12214
  }
12183
12215
  }
12184
12216
  setColor(color) {
@@ -12477,7 +12509,7 @@ void main () {
12477
12509
  let skeletonY = skeleton.y;
12478
12510
  let gl = this.context.gl;
12479
12511
  let srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
12480
- shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
12512
+ shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
12481
12513
  let bones = skeleton.bones;
12482
12514
  if (this.drawBones) {
12483
12515
  shapes.setColor(this.boneLineColor);
@@ -12774,8 +12806,9 @@ void main () {
12774
12806
  blendMode = slotBlendMode;
12775
12807
  batcher.setBlendMode(
12776
12808
  WebGLBlendModeConverter.getSourceColorGLBlendMode(blendMode, premultipliedAlpha),
12777
- WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode),
12778
- WebGLBlendModeConverter.getDestGLBlendMode(blendMode)
12809
+ WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha),
12810
+ WebGLBlendModeConverter.getDestColorGLBlendMode(blendMode),
12811
+ WebGLBlendModeConverter.getDestAlphaGLBlendMode(blendMode, premultipliedAlpha)
12779
12812
  );
12780
12813
  }
12781
12814
  if (clipper.isClipping()) {
@@ -13340,7 +13373,7 @@ void main () {
13340
13373
  let gl = renderer.context.gl;
13341
13374
  renderer.resize(1 /* Expand */);
13342
13375
  renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
13343
- renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
13376
+ renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
13344
13377
  if (complete) {
13345
13378
  this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
13346
13379
  if (this.fadeOut > FADE_OUT)