You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
[HTML5] Preloader fetch, streaming instantiation.
This commit is contained in:
@@ -227,10 +227,10 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||
/**
|
||||
* @ignore
|
||||
* @param {string} loadPath
|
||||
* @param {Promise} loadPromise
|
||||
* @param {Response} response
|
||||
*/
|
||||
Config.prototype.getModuleConfig = function (loadPath, loadPromise) {
|
||||
let loader = loadPromise;
|
||||
Config.prototype.getModuleConfig = function (loadPath, response) {
|
||||
let r = response;
|
||||
return {
|
||||
'print': this.onPrint,
|
||||
'printErr': this.onPrintError,
|
||||
@@ -238,12 +238,17 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||
'noExitRuntime': true,
|
||||
'dynamicLibraries': [`${loadPath}.side.wasm`],
|
||||
'instantiateWasm': function (imports, onSuccess) {
|
||||
loader.then(function (xhr) {
|
||||
WebAssembly.instantiate(xhr.response, imports).then(function (result) {
|
||||
onSuccess(result['instance'], result['module']);
|
||||
function done(result) {
|
||||
onSuccess(result['instance'], result['module']);
|
||||
}
|
||||
if (typeof (WebAssembly.instantiateStreaming) !== 'undefined') {
|
||||
WebAssembly.instantiateStreaming(Promise.resolve(r), imports).then(done);
|
||||
} else {
|
||||
r.arrayBuffer().then(function (buffer) {
|
||||
WebAssembly.instantiate(buffer, imports).then(done);
|
||||
});
|
||||
});
|
||||
loader = null;
|
||||
}
|
||||
r = null;
|
||||
return {};
|
||||
},
|
||||
'locateFile': function (path) {
|
||||
|
||||
Reference in New Issue
Block a user