Переглянути джерело

Added support for blender exporter material colors

Lewy Blue 7 роки тому
батько
коміт
6de4d78e8b
1 змінених файлів з 17 додано та 1 видалено
  1. 17 1
      examples/js/loaders/FBXLoader.js

+ 17 - 1
examples/js/loaders/FBXLoader.js

@@ -97,7 +97,7 @@
 
 			}
 
-			// console.log( FBXTree );
+			console.log( FBXTree );
 
 			var connections = parseConnections( FBXTree );
 			var images = parseImages( FBXTree );
@@ -424,6 +424,7 @@
 	// Also parse the texture map and return any textures associated with the material
 	function parseParameters( FBXTree, properties, textureMap, ID, connections ) {
 
+		console.log( properties)
 		var parameters = {};
 
 		if ( properties.BumpFactor ) {
@@ -435,6 +436,11 @@
 
 			parameters.color = new THREE.Color().fromArray( properties.Diffuse.value );
 
+		} else if ( properties.DiffuseColor && properties.DiffuseColor.type === 'Color' ) {
+
+			// The blender exporter exports diffuse here instead of in properties.Diffuse
+			parameters.color = new THREE.Color().fromArray( properties.DiffuseColor.value );
+
 		}
 		if ( properties.DisplacementFactor ) {
 
@@ -450,6 +456,11 @@
 
 			parameters.specular = new THREE.Color().fromArray( properties.Specular.value );
 
+		} else if ( properties.SpecularColor && properties.SpecularColor.type === 'Color' ) {
+
+			// The blender exporter exports specular color here instead of in properties.Specular
+			parameters.emissive = new THREE.Color().fromArray( properties.SpecularColor.value );
+
 		}
 		if ( properties.Shininess ) {
 
@@ -460,6 +471,11 @@
 
 			parameters.emissive = new THREE.Color().fromArray( properties.Emissive.value );
 
+		} else if ( properties.EmissiveColor && properties.EmissiveColor.type === 'Color' ) {
+
+			// The blender exporter exports emissive color here instead of in properties.Emissive
+			parameters.emissive = new THREE.Color().fromArray( properties.EmissiveColor.value );
+
 		}
 		if ( properties.EmissiveFactor ) {