Browse Source

Update ObjectLoader.js to load different maps

Simple extension to the PR submitted by @denzp https://github.com/mrdoob/three.js/pull/5502 to allow for other map types.  Tested here with map, bumpMap, and alphaMap: http://datable.net/WebGL/Test299/
Luis E. Fraguada 10 years ago
parent
commit
e5ae7d153b
1 changed files with 73 additions and 1 deletions
  1. 73 1
      src/loaders/ObjectLoader.js

+ 73 - 1
src/loaders/ObjectLoader.js

@@ -229,11 +229,83 @@ THREE.ObjectLoader.prototype = {
 
 						console.warn( 'THREE.ObjectLoader: Undefined texture', data.map );
 
-				}
+					}
 
 					material.map = textures[ data.map ];
 
 				}
+				
+				if ( data.bumpMap ) {	
+			
+					if ( !textures[data.bumpMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.bumpMap );
+					
+					}
+					
+					material.bumpMap = textures[data.bumpMap];
+					
+				}
+				
+				if ( data.alphaMap ) {
+					
+					if ( !textures[data.alphaMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.alphaMap );
+						
+					}
+					
+					material.alphaMap = textures[data.alphaMap];
+					
+				}
+				
+				if ( data.envMap ) {
+				
+					if ( !textures[data.envMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.envMap );
+						
+					}
+					
+					material.envMap = textures[data.envMap];
+					
+				}
+				
+				if ( data.normalMap ) {
+				
+					if ( !textures[data.normalMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.normalMap );
+						
+					}
+					
+					material.normalMap = textures[data.normalMap];
+					
+				}
+				
+				if ( data.lightMap ) {
+				
+					if ( !textures[data.lightMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.lightMap );
+						
+					}
+					
+					material.lightMap = textures[data.lightMap];
+					
+				}
+				
+				if ( data.specularMap ) {
+				
+					if ( !textures[data.specularMap] ) {
+						
+						console.warn( 'THREE.ObjectLoader: Undefined texture', data.specularMap );
+						
+					}
+					
+					material.specularMap = textures[data.specularMap];
+					
+				}
 
 				materials[ data.uuid ] = material;