1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

update materials

This commit is contained in:
Kevin Levron 2020-09-16 21:11:23 +02:00
parent 9bb438dd97
commit 859d82e4e3
2 changed files with 59 additions and 4 deletions

View File

@ -1,11 +1,41 @@
import { FrontSide } from 'three';
export default { export default {
inject: ['three'], inject: ['three'],
props: { props: {
id: String, id: String,
color: { color: {
type: String, type: [String, Number],
default: '#ffffff', default: '#ffffff',
}, },
depthTest: {
type: Boolean,
default: true,
},
depthWrite: {
type: Boolean,
default: true,
},
fog: {
type: Boolean,
default: false,
},
opacity: {
type: Number,
default: 1,
},
side: {
type: Number,
default: FrontSide,
},
transparent: {
type: Boolean,
default: false,
},
vertexColors: {
type: Boolean,
default: false,
},
}, },
mounted() { mounted() {
this.three.materials[this.id] = this.material; this.three.materials[this.id] = this.material;
@ -13,6 +43,15 @@ export default {
unmounted() { unmounted() {
this.material.dispose(); this.material.dispose();
}, },
methods: {
propsValues() {
const props = {};
for (const [key, value] of Object.entries(this.$props)) {
if (key !== 'id') props[key] = value;
}
return props;
},
},
render() { render() {
return []; return [];
}, },

View File

@ -3,9 +3,25 @@ import Material from './Material';
export default { export default {
extends: Material, extends: Material,
props: {
emissive: {
type: [Number, String],
default: 0,
},
emissiveIntensity: {
type: Number,
default: 1,
},
metalness: {
type: Number,
default: 0,
},
roughness: {
type: Number,
default: 1,
},
},
created() { created() {
this.material = new MeshStandardMaterial({ this.material = new MeshStandardMaterial(this.propsValues());
color: this.color,
});
}, },
}; };