diff --git a/src/components/liquid/LiquidEffect.js b/src/components/liquid/LiquidEffect.js index 10d08df..244ad5e 100644 --- a/src/components/liquid/LiquidEffect.js +++ b/src/components/liquid/LiquidEffect.js @@ -10,6 +10,7 @@ import { WebGLRenderTarget, } from 'three'; +// shaders from https://github.com/evanw/webgl-water function LiquidEffect(renderer) { this.renderer = renderer; this.width = 512; diff --git a/src/components/liquid/LiquidPlane.js b/src/components/liquid/LiquidPlane.js index 881d8b1..dcfd14d 100644 --- a/src/components/liquid/LiquidPlane.js +++ b/src/components/liquid/LiquidPlane.js @@ -19,9 +19,7 @@ export default { this.liquidEffect = new LiquidEffect(this.three.renderer); this.rendererComponent.onMounted(() => { this.liquidEffect.renderer = this.rendererComponent.renderer; - this.three.onBeforeRender(() => { - this.liquidEffect.update(); - }); + this.three.onBeforeRender(this.liquidEffect.update); }); this.material = new MeshStandardMaterial({ color: this.color, side: DoubleSide, metalness: this.metalness, roughness: this.roughness, @@ -45,10 +43,7 @@ export default { this.mesh = new Mesh(this.geometry, this.material); this.initObject3D(this.mesh); }, - // mounted() { - // }, - // unmounted() { - // }, - methods: { + unmounted() { + this.three.offBeforeRender(this.liquidEffect.update); }, };