Browse Source

improved texture checks

Lewy Blue 7 years ago
parent
commit
937ca1f640
1 changed files with 23 additions and 3 deletions
  1. 23 3
      examples/js/loaders/FBXLoader.js

+ 23 - 3
examples/js/loaders/FBXLoader.js

@@ -389,13 +389,33 @@ THREE.FBXLoader = ( function () {
 
 			var texture;
 
-			if ( textureNode.FileName.slice( - 3 ).toLowerCase() === 'tga' ) {
+			var extension = textureNode.FileName.slice( - 3 ).toLowerCase();
 
-				texture = THREE.Loader.Handlers.get( '.tga' ).load( fileName );
+			function onError() {
+
+				console.warn( 'FBXLoader: Creating empty placeholder texture for', fileName );
+				texture = new THREE.Texture();
+
+			}
+
+			if ( extension === 'tga' ) {
+
+				var loader = THREE.Loader.Handlers.get( '.tga' );
+				if ( loader === null ) {
+
+					console.warn( 'FBXLoader: TGALoader not found, creating empty placeholder texture for', fileName );
+					texture = new THREE.Texture();
+
+				} else texture = loader.load( fileName, undefined, undefined, onError );
+
+			} else if ( extension === 'psd' ) {
+
+				console.warn( 'FBXLoader: PSD textures are not supported, creating empty placeholder texture for', fileName );
+				texture = new THREE.Texture();
 
 			} else {
 
-				texture = this.textureLoader.load( fileName );
+				texture = this.textureLoader.load( fileName, undefined, undefined, onError );
 
 			}