Skip to content

Commit

Permalink
Fix mrdoob#20705 Ability to cancel ongoing HTTP requests in loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Dec 22, 2021
1 parent 95b5a61 commit eb77f9e
Show file tree
Hide file tree
Showing 24 changed files with 74 additions and 62 deletions.
7 changes: 4 additions & 3 deletions docs/api/en/loaders/AnimationLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:AnimationClip animation clips].<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called if load errors.<br /><br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called if load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br /><br />

Begin loading from url and pass the loaded animation to onLoad.
</p>
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/AudioLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and pass the loaded [page:String AudioBuffer] to onLoad.
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/BufferGeometryLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].d<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:BufferGeometry].<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and call onLoad with the parsed response content.
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/CompressedTextureLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:CompressedTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:CompressedTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and pass the loaded texture to onLoad.
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/CubeTextureLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:CubeTexture load]( [param:String urls], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:CubeTexture load]( [param:String urls], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String urls] — array of 6 urls to images, one for each side of the CubeTexture.
The urls should be specified in the following order: pos-x, neg-x, pos-y, neg-y, pos-z, neg-z.
Expand All @@ -64,8 +64,9 @@ <h3>[method:CubeTexture load]( [param:String urls], [param:Function onLoad], [pa
when looking up the positive-z axis -- in other words, using a left-handed coordinate system.
Since three.js uses a right-handed coordinate system, environment maps used in three.js will have pos-x and neg-x swapped.<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — This callback function is currently not supported.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and pass the loaded [page:CubeTexture texture] to onLoad.
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/DataTextureLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — Will be called while load progresses.The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and pass the loaded texture to onLoad.
Expand Down
10 changes: 5 additions & 5 deletions docs/api/en/loaders/FileLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1>[name]</h1>

<p class="desc">
A low level class for loading resources with XMLHttpRequest, used internaly by most loaders.
A low level class for loading resources with Fetch, used internaly by most loaders.
It can also be used directly to load any file type that does not have a loader.
</p>

Expand Down Expand Up @@ -74,14 +74,14 @@ <h3>[property:String responseType]</h3>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] (optional) — Will be called when loading completes. The argument will be the loaded response.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the XMLHttpRequest instance,
which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called if an error occurs.<br /><br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called if an error occurs.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br /><br />

Load the URL and pass the response to the onLoad function.
</p>
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/ImageBitmapLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ <h3>[property:String options]</h3>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
[page:Function onProgress] — This callback function is currently not supported.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — This callback function is currently not supported.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and return the [page:ImageBitmap image] object that will contain the data.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/en/loaders/ImageLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ <h3>[method:HTMLImageElement load]( [param:String url], [param:Function onLoad],
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
[page:Function onProgress] — This callback function is currently not supported.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — This callback function is currently not supported.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
</p>
<p>
Begin loading from url and return the [page:Image image] object that will contain the data.
Expand Down
5 changes: 3 additions & 2 deletions docs/api/en/loaders/Loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ <h3>[method:undefined load]()</h3>
This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.
</p>

<h3>[method:Promise loadAsync]( [param:String url], [param:Function onProgress] )</h3>
<h3>[method:Promise loadAsync]( [param:String url], [param:Function onProgress], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — A string containing the path/URL of the file to be loaded.<br />
[page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onProgress] (optional) — A function to be called while the loading is in progress. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
This method is equivalent to [page:.load], but returns a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promise].
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/MaterialLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ <h3>[property:Object textures]</h3>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Material].<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br /><br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br /><br />

Begin loading from url.
</p>
Expand Down
7 changes: 4 additions & 3 deletions docs/api/en/loaders/ObjectLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ <h2>Properties</h2>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:AbortSignal abortSignal] )</h3>
<p>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Object3D object].<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] — Will be called when load errors.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the ProgressEvent instance, which contains .[page:Boolean lengthComputable], .[page:Integer total] and .[page:Integer loaded]. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
[page:Function onError] (optional) — Will be called when load errors.<br />
[page:AbortSignal abortSignal] (optional) — the signal of an AbortController used to cancel the request.<br />
</p>
<p>
Begin loading from url and call onLoad with the parsed response content.
Expand Down
Loading

0 comments on commit eb77f9e

Please sign in to comment.