1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

Recreate material if vert/frag shaders change

This commit is contained in:
Sander Moolin 2021-03-12 15:11:23 -05:00
parent e9e2ac7bce
commit 9183cabf6a

View File

@ -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' }