diff --git a/src/materials/Material.ts b/src/materials/Material.ts index a7de924..3cf8a56 100644 --- a/src/materials/Material.ts +++ b/src/materials/Material.ts @@ -67,7 +67,7 @@ export default defineComponent({ this.setProp(key, texture, true) }, addWatchers() { - ['color', 'alphaTest', 'depthTest', 'depthWrite', 'fog', 'opacity', 'side', 'transparent'].forEach(p => { + ['color', 'alphaTest', 'blending', 'depthTest', 'depthWrite', 'fog', 'opacity', 'side', 'transparent'].forEach(p => { // @ts-ignore watch(() => this[p], (value) => { if (p === 'color') { diff --git a/src/materials/ShaderMaterial.ts b/src/materials/ShaderMaterial.ts index 25c79d5..88a3f4f 100644 --- a/src/materials/ShaderMaterial.ts +++ b/src/materials/ShaderMaterial.ts @@ -1,6 +1,7 @@ import { defineComponent, watch } from 'vue' import { ShaderMaterial } from 'three' import Material from './Material' +import { propsValues } from '../tools' const defaultVertexShader = ` varying vec2 vUv; @@ -26,23 +27,15 @@ export default defineComponent({ }, methods: { createMaterial() { - const material = new ShaderMaterial({ - uniforms: this.uniforms, - vertexShader: this.vertexShader, - fragmentShader: this.fragmentShader, - }) + const material = new ShaderMaterial(propsValues(this.$props, ['color'])); - const watchProps = ['vertexShader', 'fragmentShader'] - watchProps.forEach(p => { + ['vertexShader', 'fragmentShader'].forEach(p => { // @ts-ignore - watch(() => this[p], (value) => { - this.setProp(p, value, true) - }) + watch(() => this[p], (value) => { material[p] = value; material.needsUpdate = true }) }) return material }, - addWatchers() {}, }, __hmrId: 'ShaderMaterial', })