|
@@ -48,6 +48,7 @@ import { ImageLoader } from './ImageLoader.js';
|
|
import { LoadingManager, DefaultLoadingManager } from './LoadingManager.js';
|
|
import { LoadingManager, DefaultLoadingManager } from './LoadingManager.js';
|
|
import { AnimationClip } from '../animation/AnimationClip.js';
|
|
import { AnimationClip } from '../animation/AnimationClip.js';
|
|
import { MaterialLoader } from './MaterialLoader.js';
|
|
import { MaterialLoader } from './MaterialLoader.js';
|
|
|
|
+import { LoaderUtils } from './LoaderUtils.js';
|
|
import { BufferGeometryLoader } from './BufferGeometryLoader.js';
|
|
import { BufferGeometryLoader } from './BufferGeometryLoader.js';
|
|
import { JSONLoader } from './JSONLoader.js';
|
|
import { JSONLoader } from './JSONLoader.js';
|
|
import { FileLoader } from './FileLoader.js';
|
|
import { FileLoader } from './FileLoader.js';
|
|
@@ -61,7 +62,7 @@ import * as Curves from '../extras/curves/Curves.js';
|
|
function ObjectLoader( manager ) {
|
|
function ObjectLoader( manager ) {
|
|
|
|
|
|
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
|
|
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
|
|
- this.texturePath = '';
|
|
|
|
|
|
+ this.resourcePath = '';
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -71,15 +72,13 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
load: function ( url, onLoad, onProgress, onError ) {
|
|
load: function ( url, onLoad, onProgress, onError ) {
|
|
|
|
|
|
- if ( this.texturePath === '' ) {
|
|
|
|
-
|
|
|
|
- this.texturePath = url.substring( 0, url.lastIndexOf( '/' ) + 1 );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
var scope = this;
|
|
var scope = this;
|
|
|
|
|
|
|
|
+ var path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path;
|
|
|
|
+ this.resourcePath = this.resourcePath || path;
|
|
|
|
+
|
|
var loader = new FileLoader( scope.manager );
|
|
var loader = new FileLoader( scope.manager );
|
|
|
|
+ loader.setPath( this.path );
|
|
loader.load( url, function ( text ) {
|
|
loader.load( url, function ( text ) {
|
|
|
|
|
|
var json = null;
|
|
var json = null;
|
|
@@ -113,9 +112,16 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setTexturePath: function ( value ) {
|
|
|
|
|
|
+ setPath: function ( value ) {
|
|
|
|
+
|
|
|
|
+ this.path = value;
|
|
|
|
+ return this;
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ setResourcePath: function ( value ) {
|
|
|
|
|
|
- this.texturePath = value;
|
|
|
|
|
|
+ this.resourcePath = value;
|
|
return this;
|
|
return this;
|
|
|
|
|
|
},
|
|
},
|
|
@@ -418,7 +424,7 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
case 'Geometry':
|
|
case 'Geometry':
|
|
|
|
|
|
- geometry = geometryLoader.parse( data, this.texturePath ).geometry;
|
|
|
|
|
|
+ geometry = geometryLoader.parse( data, this.resourcePath ).geometry;
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -550,7 +556,7 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
var currentUrl = url[ j ];
|
|
var currentUrl = url[ j ];
|
|
|
|
|
|
- var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( currentUrl ) ? currentUrl : scope.texturePath + currentUrl;
|
|
|
|
|
|
+ var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( currentUrl ) ? currentUrl : scope.resourcePath + currentUrl;
|
|
|
|
|
|
images[ image.uuid ].push( loadImage( path ) );
|
|
images[ image.uuid ].push( loadImage( path ) );
|
|
|
|
|
|
@@ -560,7 +566,7 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
// load single image
|
|
// load single image
|
|
|
|
|
|
- var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( image.url ) ? image.url : scope.texturePath + image.url;
|
|
|
|
|
|
+ var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test( image.url ) ? image.url : scope.resourcePath + image.url;
|
|
|
|
|
|
images[ image.uuid ] = loadImage( path );
|
|
images[ image.uuid ] = loadImage( path );
|
|
|
|
|