Browse Source

MaterialLoader: Add roughness/metalness support.

Mr.doob 9 years ago
parent
commit
e1427735dd
2 changed files with 6 additions and 0 deletions
  1. 2 0
      src/loaders/MaterialLoader.js
  2. 4 0
      src/materials/Material.js

+ 2 - 0
src/loaders/MaterialLoader.js

@@ -60,6 +60,8 @@ THREE.MaterialLoader.prototype = {
 
 		if ( json.name !== undefined ) material.name = json.name;
 		if ( json.color !== undefined ) material.color.setHex( json.color );
+		if ( json.roughness !== undefined ) material.roughness = json.roughness;
+		if ( json.metalness !== undefined ) material.metalness = json.metalness;
 		if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive );
 		if ( json.specular !== undefined ) material.specular.setHex( json.specular );
 		if ( json.shininess !== undefined ) material.shininess = json.shininess;

+ 4 - 0
src/materials/Material.js

@@ -140,6 +140,10 @@ THREE.Material.prototype = {
 		if ( this.name !== '' ) data.name = this.name;
 
 		if ( this.color instanceof THREE.Color ) data.color = this.color.getHex();
+
+		if ( this.roughness !== 0.5 ) data.roughness = this.roughness;
+		if ( this.metalness > 0 ) data.metalness = this.metalness;
+
 		if ( this.emissive instanceof THREE.Color ) data.emissive = this.emissive.getHex();
 		if ( this.specular instanceof THREE.Color ) data.specular = this.specular.getHex();
 		if ( this.shininess !== undefined ) data.shininess = this.shininess;