Skip to content

Commit 042bd73

Browse files
authored
Merge pull request #14030 from takahirox/GLTFLoaderSetResourcePath
GLTFLoader: Rename .setPath with .setResourcePath
2 parents 869e8b3 + 9554b81 commit 042bd73

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

docs/examples/loaders/GLTFLoader.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Func
160160
Begin loading from url and call the callback function with the parsed response content.
161161
</p>
162162

163-
<h3>[method:null setPath]( [param:String path] )</h3>
163+
<h3>[method:GLTFLoader setPath]( [param:String path] )</h3>
164+
<p>
165+
[page:String path] — Base path.
166+
</p>
167+
<p>
168+
Set the base path for the .gltf/.glb file.
169+
</p>
170+
171+
<h3>[method:GLTFLoader setResourcePath]( [param:String path] )</h3>
164172
<p>
165173
[page:String path] — Base path for loading additional resources e.g. textures and .bin data.
166174
</p>

examples/js/loaders/GLTFLoader.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)