@@ -22,20 +22,22 @@ THREE.MTLLoader.prototype = {
2222 * @param {Function } [onProgress] - Callback for download progress.
2323 * @param {Function } [onError] - Callback for download errors.
2424 *
25- * @see setPath setTexturePath
25+ * @see setPath setResourcePath
2626 *
2727 * @note In order for relative texture references to resolve correctly
28- * you must call setPath and/or setTexturePath explicitly prior to load.
28+ * you must call setResourcePath() explicitly prior to load.
2929 */
3030 load : function ( url , onLoad , onProgress , onError ) {
3131
3232 var scope = this ;
3333
34+ var path = ( this . path === undefined ) ? THREE . LoaderUtils . extractUrlBase ( url ) : this . path ;
35+
3436 var loader = new THREE . FileLoader ( this . manager ) ;
3537 loader . setPath ( this . path ) ;
3638 loader . load ( url , function ( text ) {
3739
38- onLoad ( scope . parse ( text ) ) ;
40+ onLoad ( scope . parse ( text , path ) ) ;
3941
4042 } , onProgress , onError ) ;
4143
@@ -45,7 +47,7 @@ THREE.MTLLoader.prototype = {
4547 * Set base path for resolving references.
4648 * If set this path will be prepended to each loaded and found reference.
4749 *
48- * @see setTexturePath
50+ * @see setResourcePath
4951 * @param {String } path
5052 * @return {THREE.MTLLoader }
5153 *
@@ -61,31 +63,28 @@ THREE.MTLLoader.prototype = {
6163 } ,
6264
6365 /**
64- * Set base path for resolving texture references.
65- * If set this path will be prepended found texture reference.
66- * If not set and setPath is, it will be used as texture base path.
66+ * Set base path for additional resources like textures.
6767 *
6868 * @see setPath
6969 * @param {String } path
7070 * @return {THREE.MTLLoader }
7171 *
7272 * @example
7373 * mtlLoader.setPath( 'assets/obj/' );
74- * mtlLoader.setTexturePath ( 'assets/textures/' );
74+ * mtlLoader.setResourcePath ( 'assets/textures/' );
7575 * mtlLoader.load( 'my.mtl', ... );
7676 */
77- setTexturePath : function ( path ) {
77+ setResourcePath : function ( path ) {
7878
79- this . texturePath = path ;
79+ this . resourcePath = path ;
8080 return this ;
8181
8282 } ,
8383
84- setBaseUrl : function ( path ) {
85-
86- console . warn ( 'THREE.MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead.' ) ;
84+ setTexturePath : function ( path ) {
8785
88- return this . setTexturePath ( path ) ;
86+ console . warn ( 'THREE.MTLLoader: .setTexturePath() has been renamed to .setResourcePath().' ) ;
87+ return this . setResourcePath ( path ) ;
8988
9089 } ,
9190
@@ -109,12 +108,12 @@ THREE.MTLLoader.prototype = {
109108 * @param {String } text - Content of MTL file
110109 * @return {THREE.MTLLoader.MaterialCreator }
111110 *
112- * @see setPath setTexturePath
111+ * @see setPath setResourcePath
113112 *
114113 * @note In order for relative texture references to resolve correctly
115- * you must call setPath and/or setTexturePath explicitly prior to parse.
114+ * you must call setResourcePath() explicitly prior to parse.
116115 */
117- parse : function ( text ) {
116+ parse : function ( text , path ) {
118117
119118 var lines = text . split ( '\n' ) ;
120119 var info = { } ;
@@ -165,7 +164,7 @@ THREE.MTLLoader.prototype = {
165164
166165 }
167166
168- var materialCreator = new THREE . MTLLoader . MaterialCreator ( this . texturePath || this . path , this . materialOptions ) ;
167+ var materialCreator = new THREE . MTLLoader . MaterialCreator ( this . resourcePath || path , this . materialOptions ) ;
169168 materialCreator . setCrossOrigin ( this . crossOrigin ) ;
170169 materialCreator . setManager ( this . manager ) ;
171170 materialCreator . setMaterials ( materialsInfo ) ;
0 commit comments