|
@@ -407,72 +407,50 @@ class FBXTreeParser {
|
|
// load a texture specified as a blob or data URI, or via an external URL using TextureLoader
|
|
// load a texture specified as a blob or data URI, or via an external URL using TextureLoader
|
|
loadTexture( textureNode, images ) {
|
|
loadTexture( textureNode, images ) {
|
|
|
|
|
|
- let fileName;
|
|
|
|
-
|
|
|
|
- const currentPath = this.textureLoader.path;
|
|
|
|
-
|
|
|
|
- const children = connections.get( textureNode.id ).children;
|
|
|
|
|
|
+ const nonNativeExtensions = new Set( [ 'tga', 'tif', 'tiff', 'exr', 'dds', 'hdr', 'ktx2' ] );
|
|
|
|
|
|
- if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) {
|
|
|
|
|
|
+ const extension = textureNode.FileName.split( '.' ).pop().toLowerCase();
|
|
|
|
|
|
- fileName = images[ children[ 0 ].ID ];
|
|
|
|
|
|
+ const loader = nonNativeExtensions.has( extension ) ? this.manager.getHandler( `.${extension}` ) : this.textureLoader;
|
|
|
|
|
|
- if ( fileName.indexOf( 'blob:' ) === 0 || fileName.indexOf( 'data:' ) === 0 ) {
|
|
|
|
|
|
+ if ( ! loader ) {
|
|
|
|
|
|
- this.textureLoader.setPath( undefined );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ console.warn(
|
|
|
|
+ `FBXLoader: ${extension.toUpperCase()} loader not found, creating placeholder texture for`,
|
|
|
|
+ textureNode.RelativeFilename
|
|
|
|
+ );
|
|
|
|
+ return new Texture();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- let texture;
|
|
|
|
-
|
|
|
|
- const extension = textureNode.FileName.slice( - 3 ).toLowerCase();
|
|
|
|
-
|
|
|
|
- if ( extension === 'tga' ) {
|
|
|
|
-
|
|
|
|
- const loader = this.manager.getHandler( '.tga' );
|
|
|
|
|
|
+ const loaderPath = loader.path;
|
|
|
|
|
|
- if ( loader === null ) {
|
|
|
|
-
|
|
|
|
- console.warn( 'FBXLoader: TGA loader not found, creating placeholder texture for', textureNode.RelativeFilename );
|
|
|
|
- texture = new Texture();
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
|
|
+ if ( ! loaderPath ) {
|
|
|
|
|
|
- loader.setPath( this.textureLoader.path );
|
|
|
|
- texture = loader.load( fileName );
|
|
|
|
|
|
+ loader.setPath( this.textureLoader.path );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- } else if ( extension === 'dds' ) {
|
|
|
|
|
|
+ const children = connections.get( textureNode.id ).children;
|
|
|
|
|
|
- const loader = this.manager.getHandler( '.dds' );
|
|
|
|
|
|
+ let fileName;
|
|
|
|
|
|
- if ( loader === null ) {
|
|
|
|
|
|
+ if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) {
|
|
|
|
|
|
- console.warn( 'FBXLoader: DDS loader not found, creating placeholder texture for', textureNode.RelativeFilename );
|
|
|
|
- texture = new Texture();
|
|
|
|
|
|
+ fileName = images[ children[ 0 ].ID ];
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
+ if ( fileName.indexOf( 'blob:' ) === 0 || fileName.indexOf( 'data:' ) === 0 ) {
|
|
|
|
|
|
- loader.setPath( this.textureLoader.path );
|
|
|
|
- texture = loader.load( fileName );
|
|
|
|
|
|
+ loader.setPath( undefined );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- } else if ( extension === 'psd' ) {
|
|
|
|
-
|
|
|
|
- console.warn( 'FBXLoader: PSD textures are not supported, creating placeholder texture for', textureNode.RelativeFilename );
|
|
|
|
- texture = new Texture();
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- texture = this.textureLoader.load( fileName );
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- this.textureLoader.setPath( currentPath );
|
|
|
|
|
|
+ const texture = loader.load( fileName );
|
|
|
|
+
|
|
|
|
+ // revert to initial path
|
|
|
|
+ loader.setPath( loaderPath );
|
|
|
|
|
|
return texture;
|
|
return texture;
|
|
|
|
|