From 4ada68250159a7bc5ba28448556ec53d2b4da6fc Mon Sep 17 00:00:00 2001 From: xiamidaxia Date: Thu, 1 Jul 2021 14:06:27 +0800 Subject: [PATCH] Fix all scene share the same spine renderer. --- plugins/spine/src/SpinePlugin.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/spine/src/SpinePlugin.js b/plugins/spine/src/SpinePlugin.js index fb8ca5c6d..dc6ba07b0 100644 --- a/plugins/spine/src/SpinePlugin.js +++ b/plugins/spine/src/SpinePlugin.js @@ -461,11 +461,15 @@ var SpinePlugin = new Class({ } }; - var sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true); - sceneRenderer.batcher.setBlendMode = setBlendMode; - sceneRenderer.shapes.setBlendMode = setBlendMode; + var sceneRenderer = this.renderer.spineSceneRenderer; + if (!sceneRenderer) { + sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true); + sceneRenderer.batcher.setBlendMode = setBlendMode; + sceneRenderer.shapes.setBlendMode = setBlendMode; + this.renderer.spineSceneRenderer = sceneRenderer; + } - // All share the same instance + // All scene share the same instance this.sceneRenderer = sceneRenderer; this.skeletonRenderer = sceneRenderer.skeletonRenderer; this.skeletonDebugRenderer = sceneRenderer.skeletonDebugRenderer; @@ -1131,11 +1135,14 @@ var SpinePlugin = new Class({ this.pluginManager = null; - if (this.sceneRenderer) + var sceneRenderer = this.renderer.spineSceneRenderer; + + if (sceneRenderer) { - this.sceneRenderer.dispose(); - this.sceneRenderer = null; + sceneRenderer.dispose(); } + this.renderer.spineSceneRenderer = null; + this.sceneRenderer = null; } });