diff --git a/src/materials/MatcapMaterial.js b/src/materials/MatcapMaterial.js index 5d5c384..6595aed 100644 --- a/src/materials/MatcapMaterial.js +++ b/src/materials/MatcapMaterial.js @@ -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', }; diff --git a/src/materials/Material.js b/src/materials/Material.js index 1ded368..f36d43d 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -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') { diff --git a/src/materials/PhongMaterial.js b/src/materials/PhongMaterial.js index e7c4a1a..77a7c43 100644 --- a/src/materials/PhongMaterial.js +++ b/src/materials/PhongMaterial.js @@ -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') { diff --git a/src/materials/PhysicalMaterial.js b/src/materials/PhysicalMaterial.js index 95ba19e..d8dca76 100644 --- a/src/materials/PhysicalMaterial.js +++ b/src/materials/PhysicalMaterial.js @@ -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', }; diff --git a/src/materials/StandardMaterial.js b/src/materials/StandardMaterial.js index 562a1da..062f6b1 100644 --- a/src/materials/StandardMaterial.js +++ b/src/materials/StandardMaterial.js @@ -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) => {