1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/materials/ShaderMaterial.js
2021-03-12 09:29:10 -05:00

29 lines
712 B
JavaScript

import { ShaderMaterial } from 'three'
import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools.js';
export default {
inject: ['three', 'mesh'],
props: {
uniforms: Object,
vertexShader: { type: String, default: defaultVertexShader },
fragmentShader: { type: String, default: defaultFragmentShader },
},
created() {
this.createMaterial();
this.mesh.setMaterial(this.material);
if (this.addWatchers) this.addWatchers();
},
unmounted() {
this.material.dispose();
},
methods: {
createMaterial() {
this.material = new ShaderMaterial(propsValues(this.$props));
},
},
render() {
return [];
},
__hmrId: 'ShaderMaterial',
};