mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 20:32:02 +08:00
29 lines
712 B
JavaScript
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',
|
|
};
|