1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 12:22:03 +08:00
trois/src/materials/ShaderMaterial.js

26 lines
545 B
JavaScript
Raw Normal View History

2020-09-17 16:16:02 +08:00
export default {
2020-10-03 18:34:14 +08:00
inject: ['three', 'mesh'],
2020-09-17 16:16:02 +08:00
props: {
id: String,
uniforms: Object,
vertexShader: String,
fragmentShader: String,
},
2020-10-03 18:34:14 +08:00
beforeMount() {
this.createMaterial();
if (this.id) this.three.materials[this.id] = this.material;
this.mesh.setMaterial(this.material);
},
2020-09-17 16:16:02 +08:00
mounted() {
2020-10-03 18:34:14 +08:00
if (this.addWatchers) this.addWatchers();
2020-09-17 16:16:02 +08:00
},
unmounted() {
this.material.dispose();
2020-10-03 18:34:14 +08:00
if (this.id) delete this.three.materials[this.id];
2020-09-17 16:16:02 +08:00
},
render() {
return [];
},
2020-09-19 23:00:29 +08:00
__hmrId: 'ShaderMaterial',
2020-09-17 16:16:02 +08:00
};