Added Spine runtime setBlendMode monkey patch to avoid batch flushing

This commit is contained in:
Richard Davey 2019-07-25 13:26:58 +01:00
parent f36a0e5cac
commit 3b46296c07

View file

@ -139,6 +139,28 @@ var SpinePlugin = new Class({
bootWebGL: function () bootWebGL: function ()
{ {
this.sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true); this.sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true);
// Monkeypatch the Spine setBlendMode functions, or batching is destroyed
var setBlendMode = function (srcBlend, dstBlend)
{
if (srcBlend !== this.srcBlend || dstBlend !== this.dstBlend)
{
var gl = this.context.gl;
this.srcBlend = srcBlend;
this.dstBlend = dstBlend;
if (this.isDrawing)
{
this.flush();
gl.blendFunc(this.srcBlend, this.dstBlend);
}
}
};
this.sceneRenderer.batcher.setBlendMode = setBlendMode;
this.sceneRenderer.shapes.setBlendMode = setBlendMode;
}, },
getAtlasWebGL: function (key) getAtlasWebGL: function (key)