Browse Source

Merge pull request #7459 from tschw/SerNormalScale

Material: Fixed .normalScale serialization.
Mr.doob 9 years ago
parent
commit
399debde25

+ 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 ) {

+ 1 - 1
utils/exporters/blender/addons/io_three/exporter/api/material.py

@@ -199,7 +199,7 @@ def normal_scale(material):
     logger.debug("material.normal_scale(%s)", material)
     logger.debug("material.normal_scale(%s)", material)
     for texture in _valid_textures(material):
     for texture in _valid_textures(material):
         if texture.use_map_normal:
         if texture.use_map_normal:
-            return texture.normal_factor
+            return (texture.normal_factor, texture.normal_factor)
 
 
 
 
 @_material
 @_material