-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLTFLoader: Set request header on FileLoader #18662
Conversation
I'm not sure we should start to expose this method, see #10609 (comment). |
If the method is not exposed there is not possibility to set authorization headers. Moreover, |
Instead of changing I think this is the more generic solution since this approach could be used in other loaders, too. |
That looks nice now 😊. Let's see how @mrdoob thinks about this solution. Reminder: It's also necessary to update the documentation (shifting the existing docs from |
After this PR is merged, I will have to adjust the rest of loaders to support a request header as well. |
Looks good to me. I'll merge it after releasing |
Any thoughts on putting this on the manager object? It seems in family with the url manipulation the manager handles and that way it can applied to all loaders that are using it: const manager = new LoadingManager();
manager.setRequestHeaders( { ... } );
new GLTFLoader( manager ).load( ... );
new PLYLoader( manager ).load( ... );
new VTKLoader( manager ).load( ... ); |
One could do this but there is also |
Right -- I actually feel like |
@gkjohnson how would the user code look like? |
Something like so: const manager = new LoadingManager();
manager.setCrossOrigin( true );
manager.setRequestHeader( {
'X-Hello': 'World'
} );
const loader = new GLTFLoader( manager );
loader.load( '../path/to/file.gtlf', model => {
} ); It just seems like if you need to add headers in order to load your models (credentials, etc) you're going to want it on every request and it would convenient to reuse the settings on a manager that can be shared. |
@donmccurdy Do you have any thought on this? |
I can't think of a preference between putting the method on Loader vs. LoadingManager. However, I would suggest pluralizing the method name: |
I agree, however, since the name ( |
In my opinion it should go on How would this work otherwise? |
In the same way three.js/examples/js/loaders/GLTFLoader.js Line 1411 in ed29076
|
This PR is a simple and backwards compatible change. I don't think it should be blocked by the question if |
I didn't mean to block it just make a suggestion for a use case that didn't seem considered. I forgot that the |
Edit: I'ver realized right now that Since the PR calls |
Thanks! |
GLTFLoader
class uses internallyFileLoader
however does not expose the method to set request headers, for instance the authorization header cannot be set. This PR fixes this problem by wrapping the methodsetRequestHeader()
.Edit:
Additionally,
GLTFParser
uses a new instance ofFileLoader
internally. This prevents to download any assets using request headers.