Parcourir la source

Merge pull request #13841 from NicekDev/patch-1

TGA files support for FBXLoader
Mr.doob il y a 7 ans
Parent
commit
25446d6cfb
1 fichiers modifiés avec 32 ajouts et 2 suppressions
  1. 32 2
      examples/js/loaders/FBXLoader.js

+ 32 - 2
examples/js/loaders/FBXLoader.js

@@ -237,7 +237,27 @@
 
 				type = 'image/tiff';
 				break;
+				
+ 			case 'tga':
+			
+				if ( typeof THREE.TGALoader !== 'function' ) {
+					
+					console.warn( 'FBXLoader: THREE.TGALoader is required to load TGA textures' );
+					return;
 
+				} else {
+					
+					if ( THREE.Loader.Handlers.get( '.tga' ) === null ) {
+
+						THREE.Loader.Handlers.add( /\.tga$/i, new THREE.TGALoader() );
+
+					}
+					
+					type = 'image/tga';
+					break;
+
+				}
+				
 			default:
 
 				console.warn( 'FBXLoader: Image type "' + extension + '" is not supported.' );
@@ -336,8 +356,18 @@
 
 		}
 
-		var texture = loader.load( fileName );
-
+		var texture;
+	
+		if ( textureNode.FileName.slice( -3 ).toLowerCase() === 'tga' ) {
+			
+ 			texture = THREE.Loader.Handlers.get( '.tga' ).load( fileName );
+			
+ 		} else {
+			
+ 			texture = loader.load( fileName );
+			
+ 		}
+		
 		loader.setPath( currentPath );
 
 		return texture;