From 9183cabf6a29eab51739abf1aba079b6b16bc2aa Mon Sep 17 00:00:00 2001 From: Sander Moolin Date: Fri, 12 Mar 2021 15:11:23 -0500 Subject: [PATCH] Recreate material if vert/frag shaders change --- src/materials/ShaderMaterial.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/materials/ShaderMaterial.js b/src/materials/ShaderMaterial.js index 4627cf0..8c2b2de 100644 --- a/src/materials/ShaderMaterial.js +++ b/src/materials/ShaderMaterial.js @@ -25,6 +25,12 @@ export default { ['uniforms', 'vertexShader', 'fragmentShader'].forEach(p => { watch(() => this[p], (value) => { this.material[p] = value; + + if (p === 'vertexShader' || p === 'fragmentShader') { + // recreate material if we change either shader + this.material.dispose(); + this.createMaterial(); + } }, // only watch deep on uniforms { deep: p === 'uniforms' }