Reformat parameters

This commit is contained in:
Paul Graffam 2019-01-23 17:26:49 -05:00
parent 052e101e1c
commit 3018c6f5bd
1 changed files with 27 additions and 22 deletions

View File

@ -18,32 +18,37 @@ export default class Model {
load() { load() {
// Load model with ObjectLoader // Load model with ObjectLoader
this.loader.load(Config.model.path, obj => { this.loader.load(
obj.traverse(child => { Config.model.path,
if(child instanceof THREE.Mesh) { obj => {
// Create material for mesh and set its map to texture by name from preloaded textures obj.traverse(child => {
const material = new Material(0xffffff).standard; if(child instanceof THREE.Mesh) {
material.map = this.textures.UV; // Create material for mesh and set its map to texture by name from preloaded textures
child.material = material; const material = new Material(0xffffff).standard;
material.map = this.textures.UV;
child.material = material;
// Set to cast and receive shadow if enabled // Set to cast and receive shadow if enabled
if(Config.shadow.enabled) { if(Config.shadow.enabled) {
child.receiveShadow = true; child.receiveShadow = true;
child.castShadow = true; child.castShadow = true;
}
} }
});
// Add mesh helper if Dev
if(Config.isDev && Config.mesh.enableHelper) {
new MeshHelper(this.scene, obj);
} }
});
// Add mesh helper if Dev // Set prop to obj so it can be accessed from outside the class
if(Config.isDev && Config.mesh.enableHelper) { this.obj = obj;
new MeshHelper(this.scene, obj);
}
// Set prop to obj so it can be accessed from outside the class obj.scale.multiplyScalar(Config.model.scale);
this.obj = obj; this.scene.add(obj);
},
obj.scale.multiplyScalar(Config.model.scale); Helpers.logProgress(),
this.scene.add(obj); Helpers.logError()
}, Helpers.logProgress(), Helpers.logError()); );
} }
} }