|
@@ -41,30 +41,30 @@ THREE.FBXLoader = ( function () {
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
- var resourceDirectory = THREE.LoaderUtils.extractUrlBase( url );
|
|
|
+ var path = ( self.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : self.path;
|
|
|
|
|
|
var loader = new THREE.FileLoader( this.manager );
|
|
|
loader.setResponseType( 'arraybuffer' );
|
|
|
+
|
|
|
loader.load( url, function ( buffer ) {
|
|
|
|
|
|
- try {
|
|
|
+ onLoad( self.parse( buffer, path ) );
|
|
|
|
|
|
- var scene = self.parse( buffer, resourceDirectory );
|
|
|
- onLoad( scene );
|
|
|
+ }, onProgress, onError );
|
|
|
|
|
|
- } catch ( error ) {
|
|
|
+ },
|
|
|
|
|
|
- setTimeout( function () {
|
|
|
+ setPath: function ( value ) {
|
|
|
|
|
|
- if ( onError ) onError( error );
|
|
|
+ this.path = value;
|
|
|
+ return this;
|
|
|
|
|
|
- self.manager.itemError( url );
|
|
|
+ },
|
|
|
|
|
|
- }, 0 );
|
|
|
+ setResourcePath: function ( value ) {
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- }, onProgress, onError );
|
|
|
+ this.resourcePath = value;
|
|
|
+ return this;
|
|
|
|
|
|
},
|
|
|
|
|
@@ -75,7 +75,7 @@ THREE.FBXLoader = ( function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
- parse: function ( FBXBuffer, resourceDirectory ) {
|
|
|
+ parse: function ( FBXBuffer, path ) {
|
|
|
|
|
|
if ( isFbxFormatBinary( FBXBuffer ) ) {
|
|
|
|
|
@@ -103,7 +103,7 @@ THREE.FBXLoader = ( function () {
|
|
|
|
|
|
// console.log( fbxTree );
|
|
|
|
|
|
- var textureLoader = new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ).setCrossOrigin( this.crossOrigin );
|
|
|
+ var textureLoader = new THREE.TextureLoader( this.manager ).setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
|
|
|
|
|
|
return new FBXTreeParser( textureLoader ).parse( fbxTree );
|
|
|
|
|
@@ -282,7 +282,10 @@ THREE.FBXLoader = ( function () {
|
|
|
|
|
|
if ( THREE.Loader.Handlers.get( '.tga' ) === null ) {
|
|
|
|
|
|
- THREE.Loader.Handlers.add( /\.tga$/i, new THREE.TGALoader() );
|
|
|
+ var tgaLoader = new THREE.TGALoader();
|
|
|
+ tgaLoader.setPath( this.textureLoader.path );
|
|
|
+
|
|
|
+ THREE.Loader.Handlers.add( /\.tga$/i, tgaLoader );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -298,6 +301,8 @@ THREE.FBXLoader = ( function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ console.log();
|
|
|
+
|
|
|
if ( typeof content === 'string' ) { // ASCII format
|
|
|
|
|
|
return 'data:' + type + ';base64,' + content;
|