@esotericsoftware/spine-webgl 4.2.18 → 4.2.19

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.
@@ -10843,6 +10843,34 @@ var spine = (() => {
10843
10843
  throw new Error("Unknown blend mode: " + blendMode);
10844
10844
  }
10845
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
+ }
10846
10874
  static getSourceColorGLBlendMode(blendMode, premultipliedAlpha = false) {
10847
10875
  switch (blendMode) {
10848
10876
  case 0 /* Normal */:
@@ -10852,21 +10880,21 @@ var spine = (() => {
10852
10880
  case 2 /* Multiply */:
10853
10881
  return DST_COLOR;
10854
10882
  case 3 /* Screen */:
10855
- return ONE;
10883
+ return premultipliedAlpha ? ONE : SRC_ALPHA;
10856
10884
  default:
10857
10885
  throw new Error("Unknown blend mode: " + blendMode);
10858
10886
  }
10859
10887
  }
10860
- static getSourceAlphaGLBlendMode(blendMode) {
10888
+ static getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha = false) {
10861
10889
  switch (blendMode) {
10862
10890
  case 0 /* Normal */:
10863
- return ONE;
10891
+ return premultipliedAlpha ? SRC_ALPHA : ONE;
10864
10892
  case 1 /* Additive */:
10865
- return ONE;
10893
+ return premultipliedAlpha ? SRC_ALPHA : ONE;
10866
10894
  case 2 /* Multiply */:
10867
- return ONE_MINUS_SRC_ALPHA;
10895
+ return ONE;
10868
10896
  case 3 /* Screen */:
10869
- return ONE_MINUS_SRC_COLOR;
10897
+ return ONE;
10870
10898
  default:
10871
10899
  throw new Error("Unknown blend mode: " + blendMode);
10872
10900
  }
@@ -12091,7 +12119,8 @@ void main () {
12091
12119
  let gl = this.context.gl;
12092
12120
  this.srcColorBlend = gl.SRC_ALPHA;
12093
12121
  this.srcAlphaBlend = gl.ONE;
12094
- this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12122
+ this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12123
+ this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12095
12124
  }
12096
12125
  begin(shader) {
12097
12126
  if (this.isDrawing)
@@ -12102,23 +12131,24 @@ void main () {
12102
12131
  this.isDrawing = true;
12103
12132
  let gl = this.context.gl;
12104
12133
  gl.enable(gl.BLEND);
12105
- gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12134
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12106
12135
  if (_PolygonBatcher.disableCulling) {
12107
12136
  this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
12108
12137
  if (this.cullWasEnabled)
12109
12138
  gl.disable(gl.CULL_FACE);
12110
12139
  }
12111
12140
  }
12112
- setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12113
- if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
12141
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12142
+ if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstColorBlend == dstColorBlend && this.dstAlphaBlend == dstAlphaBlend)
12114
12143
  return;
12115
12144
  this.srcColorBlend = srcColorBlend;
12116
12145
  this.srcAlphaBlend = srcAlphaBlend;
12117
- this.dstBlend = dstBlend;
12146
+ this.dstColorBlend = dstColorBlend;
12147
+ this.dstAlphaBlend = dstAlphaBlend;
12118
12148
  if (this.isDrawing) {
12119
12149
  this.flush();
12120
12150
  let gl = this.context.gl;
12121
- gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12151
+ gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12122
12152
  }
12123
12153
  }
12124
12154
  draw(texture, vertices, indices) {
@@ -12201,7 +12231,8 @@ void main () {
12201
12231
  let gl = this.context.gl;
12202
12232
  this.srcColorBlend = gl.SRC_ALPHA;
12203
12233
  this.srcAlphaBlend = gl.ONE;
12204
- this.dstBlend = gl.ONE_MINUS_SRC_ALPHA;
12234
+ this.dstColorBlend = gl.ONE_MINUS_SRC_ALPHA;
12235
+ this.dstAlphaBlend = gl.ONE_MINUS_SRC_ALPHA;
12205
12236
  }
12206
12237
  begin(shader) {
12207
12238
  if (this.isDrawing)
@@ -12211,16 +12242,17 @@ void main () {
12211
12242
  this.isDrawing = true;
12212
12243
  let gl = this.context.gl;
12213
12244
  gl.enable(gl.BLEND);
12214
- gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
12245
+ gl.blendFuncSeparate(this.srcColorBlend, this.dstColorBlend, this.srcAlphaBlend, this.dstAlphaBlend);
12215
12246
  }
12216
- setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
12247
+ setBlendMode(srcColorBlend, srcAlphaBlend, dstColorBlend, dstAlphaBlend) {
12217
12248
  this.srcColorBlend = srcColorBlend;
12218
12249
  this.srcAlphaBlend = srcAlphaBlend;
12219
- this.dstBlend = dstBlend;
12250
+ this.dstColorBlend = dstColorBlend;
12251
+ this.dstAlphaBlend = dstAlphaBlend;
12220
12252
  if (this.isDrawing) {
12221
12253
  this.flush();
12222
12254
  let gl = this.context.gl;
12223
- gl.blendFuncSeparate(srcColorBlend, dstBlend, srcAlphaBlend, dstBlend);
12255
+ gl.blendFuncSeparate(srcColorBlend, dstColorBlend, srcAlphaBlend, dstAlphaBlend);
12224
12256
  }
12225
12257
  }
12226
12258
  setColor(color) {
@@ -12519,7 +12551,7 @@ void main () {
12519
12551
  let skeletonY = skeleton.y;
12520
12552
  let gl = this.context.gl;
12521
12553
  let srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
12522
- shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
12554
+ shapes.setBlendMode(srcFunc, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
12523
12555
  let bones = skeleton.bones;
12524
12556
  if (this.drawBones) {
12525
12557
  shapes.setColor(this.boneLineColor);
@@ -12816,8 +12848,9 @@ void main () {
12816
12848
  blendMode = slotBlendMode;
12817
12849
  batcher.setBlendMode(
12818
12850
  WebGLBlendModeConverter.getSourceColorGLBlendMode(blendMode, premultipliedAlpha),
12819
- WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode),
12820
- WebGLBlendModeConverter.getDestGLBlendMode(blendMode)
12851
+ WebGLBlendModeConverter.getSourceAlphaGLBlendMode(blendMode, premultipliedAlpha),
12852
+ WebGLBlendModeConverter.getDestColorGLBlendMode(blendMode),
12853
+ WebGLBlendModeConverter.getDestAlphaGLBlendMode(blendMode, premultipliedAlpha)
12821
12854
  );
12822
12855
  }
12823
12856
  if (clipper.isClipping()) {
@@ -13382,7 +13415,7 @@ void main () {
13382
13415
  let gl = renderer.context.gl;
13383
13416
  renderer.resize(1 /* Expand */);
13384
13417
  renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
13385
- renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
13418
+ renderer.batcher.setBlendMode(gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
13386
13419
  if (complete) {
13387
13420
  this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
13388
13421
  if (this.fadeOut > FADE_OUT)