Passed in color to material constructor
This commit is contained in:
parent
2837909a17
commit
c2f4f1741b
|
@ -2,25 +2,22 @@ import * as THREE from 'three';
|
||||||
|
|
||||||
import Config from '../../data/config';
|
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 {
|
export default class Material {
|
||||||
constructor() {
|
constructor(color) {
|
||||||
this.emissive = new THREE.MeshBasicMaterial({
|
this.basic = new THREE.MeshBasicMaterial({
|
||||||
color: 0xeeeeee,
|
color,
|
||||||
side: THREE.DoubleSide
|
side: THREE.DoubleSide
|
||||||
});
|
});
|
||||||
|
|
||||||
this.standard = new THREE.MeshStandardMaterial({
|
this.standard = new THREE.MeshStandardMaterial({
|
||||||
|
color,
|
||||||
shading: THREE.FlatShading,
|
shading: THREE.FlatShading,
|
||||||
roughness: 1,
|
roughness: 1,
|
||||||
metalness: 0,
|
metalness: 0,
|
||||||
side: THREE.DoubleSide
|
side: THREE.DoubleSide
|
||||||
});
|
});
|
||||||
|
|
||||||
this.phong = new THREE.MeshPhongMaterial({
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
this.wire = new THREE.MeshBasicMaterial({wireframe: true});
|
this.wire = new THREE.MeshBasicMaterial({wireframe: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ export default class Model {
|
||||||
this.loader.load(Config.model.path, obj => {
|
this.loader.load(Config.model.path, obj => {
|
||||||
obj.traverse(child => {
|
obj.traverse(child => {
|
||||||
if(child instanceof THREE.Mesh) {
|
if(child instanceof THREE.Mesh) {
|
||||||
// Create material for mesh and grab texture by name from preloaded textures
|
// Create material for mesh and set its map to texture by name from preloaded textures
|
||||||
const material = new Material().standard;
|
const material = new Material(0xffffff).standard;
|
||||||
material.map = this.textures.UV;
|
material.map = this.textures.UV;
|
||||||
child.material = material;
|
child.material = material;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue