mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
fix #21 (flatshading)
This commit is contained in:
parent
ebe2e799ed
commit
e57a05de53
@ -8,6 +8,7 @@ export default {
|
||||
props: {
|
||||
src: String,
|
||||
name: String,
|
||||
flatShading: Boolean,
|
||||
},
|
||||
methods: {
|
||||
createMaterial() {
|
||||
@ -16,6 +17,9 @@ export default {
|
||||
opts.matcap = new TextureLoader().load(src);
|
||||
this.material = new MeshMatcapMaterial(opts);
|
||||
},
|
||||
addWatchers() {
|
||||
// TODO
|
||||
},
|
||||
},
|
||||
__hmrId: 'MatcapMaterial',
|
||||
};
|
||||
|
@ -7,7 +7,6 @@ export default {
|
||||
color: { type: [String, Number], default: '#ffffff' },
|
||||
depthTest: { type: Boolean, default: true },
|
||||
depthWrite: { type: Boolean, default: true },
|
||||
flatShading: Boolean,
|
||||
fog: { type: Boolean, default: true },
|
||||
opacity: { type: Number, default: 1 },
|
||||
side: { type: Number, default: FrontSide },
|
||||
@ -38,7 +37,6 @@ export default {
|
||||
this.setProp(key, texture, true);
|
||||
},
|
||||
_addWatchers() {
|
||||
// don't work for flatShading
|
||||
['color', 'depthTest', 'depthWrite', 'fog', 'opacity', 'side', 'transparent'].forEach(p => {
|
||||
watch(() => this[p], () => {
|
||||
if (p === 'color') {
|
||||
|
@ -11,12 +11,14 @@ export default {
|
||||
reflectivity: { type: Number, default: 1 },
|
||||
shininess: { type: Number, default: 30 },
|
||||
specular: { type: [String, Number], default: 0x111111 },
|
||||
flatShading: Boolean,
|
||||
},
|
||||
methods: {
|
||||
createMaterial() {
|
||||
this.material = new MeshPhongMaterial(propsValues(this.$props));
|
||||
},
|
||||
addWatchers() {
|
||||
// TODO : handle flatShading ?
|
||||
['emissive', 'emissiveIntensity', 'reflectivity', 'shininess', 'specular'].forEach(p => {
|
||||
watch(() => this[p], (value) => {
|
||||
if (p === 'emissive' || p === 'specular') {
|
||||
|
@ -4,10 +4,16 @@ import StandardMaterial from './StandardMaterial';
|
||||
|
||||
export default {
|
||||
extends: StandardMaterial,
|
||||
props: {
|
||||
flatShading: Boolean,
|
||||
},
|
||||
methods: {
|
||||
createMaterial() {
|
||||
this.material = new MeshPhysicalMaterial(propsValues(this.$props));
|
||||
},
|
||||
addWatchers() {
|
||||
// TODO
|
||||
},
|
||||
},
|
||||
__hmrId: 'PhysicalMaterial',
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ const props = {
|
||||
normalScale: { type: Object, default: { x: 1, y: 1 } },
|
||||
roughness: { type: Number, default: 1 },
|
||||
refractionRatio: { type: Number, default: 0.98 },
|
||||
flatShading: Boolean,
|
||||
wireframe: Boolean,
|
||||
};
|
||||
|
||||
@ -27,7 +28,7 @@ export default {
|
||||
this.material = new MeshStandardMaterial(propsValues(this.$props, ['normalScale']));
|
||||
},
|
||||
addWatchers() {
|
||||
// todo : use setProp ?
|
||||
// TODO : use setProp, handle flatShading ?
|
||||
Object.keys(props).forEach(p => {
|
||||
if (p === 'normalScale') return;
|
||||
watch(() => this[p], (value) => {
|
||||
|
Loading…
Reference in New Issue
Block a user