1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/materials/MatcapMaterial.js

26 lines
651 B
JavaScript
Raw Normal View History

2020-10-04 17:23:02 +08:00
import { MeshMatcapMaterial, TextureLoader } from 'three';
// import { watch } from 'vue';
import { propsValues, getMatcapUrl } from '../tools.js';
import Material from './Material';
export default {
extends: Material,
props: {
src: String,
name: String,
2021-03-13 06:54:55 +08:00
flatShading: Boolean,
2020-10-04 17:23:02 +08:00
},
methods: {
createMaterial() {
const src = this.name ? getMatcapUrl(this.name) : this.src;
2021-03-07 06:14:22 +08:00
const opts = propsValues(this.$props, ['src', 'name']);
2020-10-04 17:23:02 +08:00
opts.matcap = new TextureLoader().load(src);
this.material = new MeshMatcapMaterial(opts);
},
2021-03-13 06:54:55 +08:00
addWatchers() {
// TODO
},
2020-10-04 17:23:02 +08:00
},
__hmrId: 'MatcapMaterial',
};