summaryrefslogtreecommitdiffstats
path: root/platform/javascript/js/engine/engine.js
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-03-01 17:53:56 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-03-05 20:15:38 +0100
commitcb1b89dac5b9a73612ccf8f61dfcc9d55c9ad598 (patch)
tree5f2dbfded768b587b5020226f75d6b315d8d7119 /platform/javascript/js/engine/engine.js
parent272e491f52d4277667c35021f5fdf60655ccc917 (diff)
downloadredot-engine-cb1b89dac5b9a73612ccf8f61dfcc9d55c9ad598.tar.gz
[HTML5] Export process writes sizes in template.
This allow the loading bar to be much more reliable, even in cases where realible stream loading status is not detectable (server-side compression, chunked encoding).
Diffstat (limited to 'platform/javascript/js/engine/engine.js')
-rw-r--r--platform/javascript/js/engine/engine.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/platform/javascript/js/engine/engine.js b/platform/javascript/js/engine/engine.js
index e2d27c4c02..19a0552c8c 100644
--- a/platform/javascript/js/engine/engine.js
+++ b/platform/javascript/js/engine/engine.js
@@ -35,14 +35,15 @@ const Engine = (function () {
* Load the engine from the specified base path.
*
* @param {string} basePath Base path of the engine to load.
+ * @param {number=} [size=0] The file size if known.
* @returns {Promise} A Promise that resolves once the engine is loaded.
*
* @function Engine.load
*/
- Engine.load = function (basePath) {
+ Engine.load = function (basePath, size) {
if (loadPromise == null) {
loadPath = basePath;
- loadPromise = preloader.loadPromise(`${loadPath}.wasm`, true);
+ loadPromise = preloader.loadPromise(`${loadPath}.wasm`, size, true);
requestAnimationFrame(preloader.animateProgress);
}
return loadPromise;
@@ -96,7 +97,7 @@ const Engine = (function () {
initPromise = Promise.reject(new Error('A base path must be provided when calling `init` and the engine is not loaded.'));
return initPromise;
}
- Engine.load(basePath);
+ Engine.load(basePath, this.config.fileSizes[`${basePath}.wasm`]);
}
const me = this;
function doInit(promise) {
@@ -137,7 +138,7 @@ const Engine = (function () {
* @returns {Promise} A Promise that resolves once the file is loaded.
*/
preloadFile: function (file, path) {
- return preloader.preload(file, path);
+ return preloader.preload(file, path, this.config.fileSizes[file]);
},
/**