Browse Source

Material: Fixed .normalScale serialization.

tschw 9 years ago
parent
commit
a7e30374f4
2 changed files with 19 additions and 2 deletions
  1. 18 1
      src/loaders/MaterialLoader.js
  2. 1 1
      src/materials/Material.js

+ 18 - 1
src/loaders/MaterialLoader.js

@@ -97,7 +97,24 @@ THREE.MaterialLoader.prototype = {
 		if ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale;
 		if ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale;
 
 
 		if ( json.normalMap !== undefined ) material.normalMap = this.getTexture( json.normalMap );
 		if ( json.normalMap !== undefined ) material.normalMap = this.getTexture( json.normalMap );
-		if ( json.normalScale )	material.normalScale = new THREE.Vector2( json.normalScale, json.normalScale );
+		if ( json.normalScale )	{
+
+			var jsonValue = json.normalScale,
+				vector = new THREE.Vector2();
+
+			if ( Array.isArray( jsonValue ) ) {
+
+				vector.fromArray( jsonValue );
+
+			} else {
+
+				vector.set( jsonValue, jsonValue );
+
+			}
+
+			material.normalScale = vector;
+
+		}
 
 
 		if ( json.displacementMap !== undefined ) material.displacementMap = this.getTexture( json.displacementMap );
 		if ( json.displacementMap !== undefined ) material.displacementMap = this.getTexture( json.displacementMap );
 		if ( json.displacementScale !== undefined ) material.displacementScale = json.displacementScale;
 		if ( json.displacementScale !== undefined ) material.displacementScale = json.displacementScale;

+ 1 - 1
src/materials/Material.js

@@ -156,7 +156,7 @@ THREE.Material.prototype = {
 		if ( this.normalMap instanceof THREE.Texture ) {
 		if ( this.normalMap instanceof THREE.Texture ) {
 
 
 			data.normalMap = this.normalMap.toJSON( meta ).uuid;
 			data.normalMap = this.normalMap.toJSON( meta ).uuid;
-			data.normalScale = this.normalScale; // Removed for now, causes issue in editor ui.js
+			data.normalScale = this.normalScale.toArray();
 
 
 		}
 		}
 		if ( this.displacementMap instanceof THREE.Texture ) {
 		if ( this.displacementMap instanceof THREE.Texture ) {