Browse Source

Merge pull request #17206 from Mugen87/dev33

Material: Add clearCoatNormalMap/Scale to .toJSON() and loader.
Mr.doob 6 years ago
parent
commit
53b2bc386c
2 changed files with 10 additions and 0 deletions
  1. 3 0
      src/loaders/MaterialLoader.js
  2. 7 0
      src/materials/Material.js

+ 3 - 0
src/loaders/MaterialLoader.js

@@ -229,6 +229,9 @@ Object.assign( MaterialLoader.prototype, {
 
 		if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap );
 
+		if ( json.clearCoatNormalMap !== undefined ) material.clearCoatNormalMap = getTexture( json.clearCoatNormalMap );
+		if ( json.clearCoatNormalScale !== undefined ) material.clearCoatNormalScale = new Vector2().fromArray( json.clearCoatNormalScale );
+
 		return material;
 
 	},

+ 7 - 0
src/materials/Material.js

@@ -175,6 +175,13 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		if ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat;
 		if ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness;
 
+		if ( this.clearCoatNormalMap && this.clearCoatNormalMap.isTexture ) {
+
+			data.clearCoatNormalMap = this.clearCoatNormalMap.toJSON( meta ).uuid;
+			data.clearCoatNormalScale = this.clearCoatNormalScale.toArray();
+
+		}
+
 		if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
 		if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
 		if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;