Passed in color to material constructor

This commit is contained in:
Paul Graffam 2016-10-07 14:55:13 -04:00
parent 2837909a17
commit c2f4f1741b
2 changed files with 7 additions and 10 deletions

View File

@ -2,25 +2,22 @@ import * as THREE from 'three';
import Config from '../../data/config';
// USe this class as a Helper to set up some default materials
// USe this class as a helper to set up some default materials
export default class Material {
constructor() {
this.emissive = new THREE.MeshBasicMaterial({
color: 0xeeeeee,
constructor(color) {
this.basic = new THREE.MeshBasicMaterial({
color,
side: THREE.DoubleSide
});
this.standard = new THREE.MeshStandardMaterial({
color,
shading: THREE.FlatShading,
roughness: 1,
metalness: 0,
side: THREE.DoubleSide
});
this.phong = new THREE.MeshPhongMaterial({
});
this.wire = new THREE.MeshBasicMaterial({wireframe: true});
}
}

View File

@ -21,8 +21,8 @@ export default class Model {
this.loader.load(Config.model.path, obj => {
obj.traverse(child => {
if(child instanceof THREE.Mesh) {
// Create material for mesh and grab texture by name from preloaded textures
const material = new Material().standard;
// Create material for mesh and set its map to texture by name from preloaded textures
const material = new Material(0xffffff).standard;
material.map = this.textures.UV;
child.material = material;