@@ -25,7 +25,21 @@ THREE.GLTFLoader = ( function () {
2525
2626 var scope = this ;
2727
28- var path = this . path !== undefined ? this . path : THREE . LoaderUtils . extractUrlBase ( url ) ;
28+ var resourcePath ;
29+
30+ if ( this . resourcePath !== undefined ) {
31+
32+ resourcePath = this . resourcePath ;
33+
34+ } else if ( this . path !== undefined ) {
35+
36+ resourcePath = this . path ;
37+
38+ } else {
39+
40+ resourcePath = THREE . LoaderUtils . extractUrlBase ( url ) ;
41+
42+ }
2943
3044 // Tells the LoadingManager to track an extra item, which resolves after
3145 // the model is fully loaded. This means the count of items loaded will
@@ -51,13 +65,14 @@ THREE.GLTFLoader = ( function () {
5165
5266 var loader = new THREE . FileLoader ( scope . manager ) ;
5367
68+ loader . setPath ( this . path ) ;
5469 loader . setResponseType ( 'arraybuffer' ) ;
5570
5671 loader . load ( url , function ( data ) {
5772
5873 try {
5974
60- scope . parse ( data , path , function ( gltf ) {
75+ scope . parse ( data , resourcePath , function ( gltf ) {
6176
6277 onLoad ( gltf ) ;
6378
@@ -89,6 +104,13 @@ THREE.GLTFLoader = ( function () {
89104
90105 } ,
91106
107+ setResourcePath : function ( value ) {
108+
109+ this . resourcePath = value ;
110+ return this ;
111+
112+ } ,
113+
92114 setDRACOLoader : function ( dracoLoader ) {
93115
94116 this . dracoLoader = dracoLoader ;
@@ -186,7 +208,7 @@ THREE.GLTFLoader = ( function () {
186208
187209 var parser = new GLTFParser ( json , extensions , {
188210
189- path : path || this . path || '' ,
211+ path : path || this . resourcePath || '' ,
190212 crossOrigin : this . crossOrigin ,
191213 manager : this . manager
192214
0 commit comments