mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
Uniforms working correctly
This commit is contained in:
parent
5bd7bcc70f
commit
e9e2ac7bce
@ -1,10 +1,11 @@
|
||||
import { ShaderMaterial } from 'three'
|
||||
import { watch } from 'vue';
|
||||
import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools.js';
|
||||
|
||||
export default {
|
||||
inject: ['three', 'mesh'],
|
||||
props: {
|
||||
uniforms: Object,
|
||||
uniforms: { type: Object, default: () => { } },
|
||||
vertexShader: { type: String, default: defaultVertexShader },
|
||||
fragmentShader: { type: String, default: defaultFragmentShader },
|
||||
},
|
||||
@ -20,6 +21,16 @@ export default {
|
||||
createMaterial() {
|
||||
this.material = new ShaderMaterial(propsValues(this.$props));
|
||||
},
|
||||
addWatchers() {
|
||||
['uniforms', 'vertexShader', 'fragmentShader'].forEach(p => {
|
||||
watch(() => this[p], (value) => {
|
||||
this.material[p] = value;
|
||||
},
|
||||
// only watch deep on uniforms
|
||||
{ deep: p === 'uniforms' }
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
render() {
|
||||
return [];
|
||||
|
Loading…
Reference in New Issue
Block a user