浏览代码

parse attribute type Color correctly

Lewy Blue 7 年之前
父节点
当前提交
a637179e9f
共有 1 个文件被更改,包括 8 次插入19 次删除
  1. 8 19
      examples/js/loaders/FBXLoader.js

+ 8 - 19
examples/js/loaders/FBXLoader.js

@@ -433,7 +433,7 @@
 		}
 		}
 		if ( properties.Diffuse ) {
 		if ( properties.Diffuse ) {
 
 
-			parameters.color = parseColor( properties.Diffuse );
+			parameters.color = new THREE.Color().fromArray( properties.Diffuse.value );
 
 
 		}
 		}
 		if ( properties.DisplacementFactor ) {
 		if ( properties.DisplacementFactor ) {
@@ -448,7 +448,7 @@
 		}
 		}
 		if ( properties.Specular ) {
 		if ( properties.Specular ) {
 
 
-			parameters.specular = parseColor( properties.Specular );
+			parameters.specular = new THREE.Color().fromArray( properties.Specular.value );
 
 
 		}
 		}
 		if ( properties.Shininess ) {
 		if ( properties.Shininess ) {
@@ -458,7 +458,7 @@
 		}
 		}
 		if ( properties.Emissive ) {
 		if ( properties.Emissive ) {
 
 
-			parameters.emissive = parseColor( properties.Emissive );
+			parameters.emissive = new THREE.Color().fromArray( properties.Emissive.value );
 
 
 		}
 		}
 		if ( properties.EmissiveFactor ) {
 		if ( properties.EmissiveFactor ) {
@@ -1711,7 +1711,7 @@
 
 
 			if ( lightAttribute.Color !== undefined ) {
 			if ( lightAttribute.Color !== undefined ) {
 
 
-				color = parseColor( lightAttribute.Color );
+				color = new THREE.Color().fromArray( lightAttribute.Color.value );
 
 
 			}
 			}
 
 
@@ -2791,6 +2791,8 @@
 			var innerPropFlag = props[ 3 ];
 			var innerPropFlag = props[ 3 ];
 			var innerPropValue = props[ 4 ];
 			var innerPropValue = props[ 4 ];
 
 
+			console.log( innerPropType1 )
+
 			// cast values where needed, otherwise leave as strings
 			// cast values where needed, otherwise leave as strings
 			switch ( innerPropType1 ) {
 			switch ( innerPropType1 ) {
 
 
@@ -2804,6 +2806,7 @@
 					innerPropValue = parseFloat( innerPropValue );
 					innerPropValue = parseFloat( innerPropValue );
 					break;
 					break;
 
 
+				case 'Color':
 				case 'ColorRGB':
 				case 'ColorRGB':
 				case 'Vector3D':
 				case 'Vector3D':
 				case 'Lcl_Translation':
 				case 'Lcl_Translation':
@@ -2993,7 +2996,7 @@
 				if ( innerPropName.indexOf( 'Lcl ' ) === 0 ) innerPropName = innerPropName.replace( 'Lcl ', 'Lcl_' );
 				if ( innerPropName.indexOf( 'Lcl ' ) === 0 ) innerPropName = innerPropName.replace( 'Lcl ', 'Lcl_' );
 				if ( innerPropType1.indexOf( 'Lcl ' ) === 0 ) innerPropType1 = innerPropType1.replace( 'Lcl ', 'Lcl_' );
 				if ( innerPropType1.indexOf( 'Lcl ' ) === 0 ) innerPropType1 = innerPropType1.replace( 'Lcl ', 'Lcl_' );
 
 
-				if ( innerPropType1 === 'ColorRGB' || innerPropType1 === 'Vector' || innerPropType1 === 'Vector3D' || innerPropType1.indexOf( 'Lcl_' ) === 0 ) {
+				if ( innerPropType1 === 'Color' || innerPropType1 === 'ColorRGB' || innerPropType1 === 'Vector' || innerPropType1 === 'Vector3D' || innerPropType1.indexOf( 'Lcl_' ) === 0 ) {
 
 
 					innerPropValue = [
 					innerPropValue = [
 						subNode.propertyList[ 4 ],
 						subNode.propertyList[ 4 ],
@@ -3488,20 +3491,6 @@
 
 
 	}
 	}
 
 
-	function parseColor( property ) {
-
-		var color = new THREE.Color();
-
-		if ( property.type === 'Color' ) {
-
-			return color.setScalar( property.value );
-
-		}
-
-		return color.fromArray( property.value );
-
-	}
-
 	function convertArrayBufferToString( buffer, from, to ) {
 	function convertArrayBufferToString( buffer, from, to ) {
 
 
 		if ( from === undefined ) from = 0;
 		if ( from === undefined ) from = 0;