Loader: Add "setFromFetchOptions" function #21286
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: --
Description
This is a suggestion to add a
setFromFetchOptions( fetchOptions )
function toLoader
.fetch
has become the predominant way to perform requests and it comes with a (in my opinion) more intuitive set of options for defining the request that is not supported by the three.js loaders. In my apps I carry around a common fetch options object that defines the "mode", "credentials", and necessary "headers" needed to make a request for a certain set of resources and it's not immediately clear how to map those options to the old XMLHttpRequest / three.js Loader model.setFromFetchOptions
makes it easy to map the more modernfetch
options to those needed by the loader ultimately callingsetWithCredentials
,setCrossOrigin
, andsetRequestHeader
with ( as far as I can tell) the equivalent values.