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