Skip to content

Commit bccb629

Browse files
authored
Add missing load onProgress behaviour (#22990)
Load's onProgress function has an undocumented behaviour. If a server does not set the Content-Length header, the onProgress function sets total to 0. This change documents that behaviour.
1 parent a88d0ec commit bccb629

25 files changed

+25
-25
lines changed

docs/api/en/loaders/AnimationLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
6464
[page:String url] — the path or URL to the file. This can also be a
6565
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
6666
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:AnimationClip animation clips].<br />
67-
[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.<br />
67+
[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 />
6868
[page:Function onError] — Will be called if load errors.<br /><br />
6969

7070
Begin loading from url and pass the loaded animation to onLoad.

docs/api/en/loaders/AudioLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
8181
[page:String url] — the path or URL to the file. This can also be a
8282
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
8383
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<br />
84-
[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.<br />
84+
[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 />
8585
[page:Function onError] — Will be called when load errors.<br />
8686
</p>
8787
<p>

docs/api/en/loaders/BufferGeometryLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
7373
[page:String url] — the path or URL to the file. This can also be a
7474
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].d<br />
7575
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:BufferGeometry].<br />
76-
[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.<br />
76+
[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 />
7777
[page:Function onError] — Will be called when load errors.<br />
7878
</p>
7979
<p>

docs/api/en/loaders/CompressedTextureLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h3>[method:CompressedTexture load]( [param:String url], [param:Function onLoad]
4545
[page:String url] — the path or URL to the file. This can also be a
4646
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
4747
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
48-
[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.<br />
48+
[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 />
4949
[page:Function onError] — Will be called when load errors.<br />
5050
</p>
5151
<p>

docs/api/en/loaders/CubeTextureLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h3>[method:CubeTexture load]( [param:String urls], [param:Function onLoad], [pa
6464
when looking up the positive-z axis -- in other words, using a left-handed coordinate system.
6565
Since three.js uses a right-handed coordinate system, environment maps used in three.js will have pos-x and neg-x swapped.<br />
6666
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
67-
[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.<br />
67+
[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 />
6868
[page:Function onError] — Will be called when load errors.<br />
6969
</p>
7070
<p>

docs/api/en/loaders/DataTextureLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [par
4545
[page:String url] — the path or URL to the file. This can also be a
4646
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
4747
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
48-
[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.<br />
48+
[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 />
4949
[page:Function onError] — Will be called when load errors.<br />
5050
</p>
5151
<p>

docs/api/en/loaders/FileLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
8080
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
8181
[page:Function onLoad] (optional) — Will be called when loading completes. The argument will be the loaded response.<br />
8282
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the XMLHttpRequest instance,
83-
which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
83+
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 />
8484
[page:Function onError] (optional) — Will be called if an error occurs.<br /><br />
8585

8686
Load the URL and pass the response to the onLoad function.

docs/api/en/loaders/Loader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h3>[method:undefined load]()</h3>
7070
<h3>[method:Promise loadAsync]( [param:String url], [param:Function onProgress] )</h3>
7171
<p>
7272
[page:String url] — A string containing the path/URL of the file to be loaded.<br />
73-
[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.<br />
73+
[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 />
7474
</p>
7575
<p>
7676
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].

docs/api/en/loaders/MaterialLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
6767
[page:String url] — the path or URL to the file. This can also be a
6868
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
6969
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Material].<br />
70-
[page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
70+
[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 />
7171
[page:Function onError] — Will be called when load errors.<br /><br />
7272

7373
Begin loading from url.

docs/api/en/loaders/ObjectLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param
7777
[page:String url] — the path or URL to the file. This can also be a
7878
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
7979
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Object3D object].<br />
80-
[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.<br />
80+
[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 />
8181
[page:Function onError] — Will be called when load errors.<br />
8282
</p>
8383
<p>

0 commit comments

Comments
 (0)