diff --git a/docs/api/en/loaders/ObjectLoader.html b/docs/api/en/loaders/ObjectLoader.html
index 95a7c0f2e4026259981a2349513346768367b134..2fe83f2f67e1698556d6b03f86b2c055adf05fdd 100644
--- a/docs/api/en/loaders/ObjectLoader.html
+++ b/docs/api/en/loaders/ObjectLoader.html
@@ -85,9 +85,9 @@
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
- [property:String texturePath]
+ [property:String resourcePath]
- The base path or URL from which textures will be loaded. See [page:.setTexturePath].
+ The base path or URL from which additional resources like textuures will be loaded. See [page:.setResourcePath].
Default is the empty string.
@@ -217,11 +217,14 @@
[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
- [method:ObjectLoader setTexturePath]( [param:String value] )
+ [method:ObjectLoader setPath]( [param:String value] )
- [page:String value] — The base path or URL from which textures will be loaded.
-
+ Set the base path for the original file.
+
+ [method:ObjectLoader setResourcePath]( [param:String value] )
+
+ Set the base path for dependent resources like textures.
Source
diff --git a/editor/js/Loader.js b/editor/js/Loader.js
index 1357e067ff13aae5a53f11637f65a6aad3320c52..30b7c4841e848f0cc3e1529e2470b1bec6b6ebba 100644
--- a/editor/js/Loader.js
+++ b/editor/js/Loader.js
@@ -626,7 +626,7 @@ var Loader = function ( editor ) {
case 'object':
var loader = new THREE.ObjectLoader();
- loader.setTexturePath( scope.texturePath );
+ loader.setResourcePath( scope.texturePath );
var result = loader.parse( data );
diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js
index bcf4da484af2c2bfc6cf116877cfb0c09623d02e..456d75b1254074d6419ecbb2c1027d72377e4369 100644
--- a/src/Three.Legacy.js
+++ b/src/Three.Legacy.js
@@ -45,6 +45,7 @@ import { AudioLoader } from './loaders/AudioLoader.js';
import { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
import { DataTextureLoader } from './loaders/DataTextureLoader.js';
import { JSONLoader } from './loaders/JSONLoader.js';
+import { ObjectLoader } from './loaders/ObjectLoader.js';
import { TextureLoader } from './loaders/TextureLoader.js';
import { Material } from './materials/Material.js';
import { LineBasicMaterial } from './materials/LineBasicMaterial.js';
@@ -447,6 +448,17 @@ Object.assign( JSONLoader.prototype, {
} );
+Object.assign( ObjectLoader.prototype, {
+
+ setTexturePath: function ( value ) {
+
+ console.warn( 'THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().' );
+ return this.setResourcePath( value );
+
+ }
+
+} );
+
//
Object.assign( Box2.prototype, {
diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js
index 2ff101e72c17ff6a310aa164495ab7bd21df649b..b951a645f67fac47a13f349b33bae0c42435147d 100644
--- a/src/loaders/ObjectLoader.js
+++ b/src/loaders/ObjectLoader.js
@@ -48,6 +48,7 @@ import { ImageLoader } from './ImageLoader.js';
import { LoadingManager, DefaultLoadingManager } from './LoadingManager.js';
import { AnimationClip } from '../animation/AnimationClip.js';
import { MaterialLoader } from './MaterialLoader.js';
+import { LoaderUtils } from './LoaderUtils.js';
import { BufferGeometryLoader } from './BufferGeometryLoader.js';
import { JSONLoader } from './JSONLoader.js';
import { FileLoader } from './FileLoader.js';
@@ -61,7 +62,7 @@ import * as Curves from '../extras/curves/Curves.js';
function ObjectLoader( manager ) {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
- this.texturePath = '';
+ this.resourcePath = '';
}
@@ -71,15 +72,13 @@ Object.assign( ObjectLoader.prototype, {
load: function ( url, onLoad, onProgress, onError ) {
- if ( this.texturePath === '' ) {
-
- this.texturePath = url.substring( 0, url.lastIndexOf( '/' ) + 1 );
-
- }
-
var scope = this;
+ var path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path;
+ this.resourcePath = this.resourcePath || path;
+
var loader = new FileLoader( scope.manager );
+ loader.setPath( this.path );
loader.load( url, function ( text ) {
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;
},
@@ -418,7 +424,7 @@ Object.assign( ObjectLoader.prototype, {
case 'Geometry':
- geometry = geometryLoader.parse( data, this.texturePath ).geometry;
+ geometry = geometryLoader.parse( data, this.resourcePath ).geometry;
break;
@@ -550,7 +556,7 @@ Object.assign( ObjectLoader.prototype, {
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 ) );
@@ -560,7 +566,7 @@ Object.assign( ObjectLoader.prototype, {
// 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 );