mirror of
https://github.com/godotengine/godot.git
synced 2025-10-24 02:13:36 +00:00
[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).
This commit is contained in:
parent
272e491f52
commit
cb1b89dac5
4 changed files with 47 additions and 26 deletions
|
|
@ -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]);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue