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

26 lines
545 B
JavaScript

export default {
inject: ['three', 'mesh'],
props: {
id: String,
uniforms: Object,
vertexShader: String,
fragmentShader: String,
},
beforeMount() {
this.createMaterial();
if (this.id) this.three.materials[this.id] = this.material;
this.mesh.setMaterial(this.material);
},
mounted() {
if (this.addWatchers) this.addWatchers();
},
unmounted() {
this.material.dispose();
if (this.id) delete this.three.materials[this.id];
},
render() {
return [];
},
__hmrId: 'ShaderMaterial',
};