Spaces:
Running
Running
File size: 1,733 Bytes
03b7287 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
var loadModules = function (modules, urlPrefix, doneCallback) { // eslint-disable-line no-unused-vars
if (typeof modules === "undefined" || modules.length === 0) {
// caller may depend on callback behaviour being async
setTimeout(doneCallback);
} else {
let remaining = modules.length;
const moduleLoaded = () => {
if (--remaining === 0) {
doneCallback();
}
};
modules.forEach(function (m) {
pc.WasmModule.setConfig(m.moduleName, {
glueUrl: urlPrefix + m.glueUrl,
wasmUrl: urlPrefix + m.wasmUrl,
fallbackUrl: urlPrefix + m.fallbackUrl
});
if (!m.hasOwnProperty('preload') || m.preload) {
if (m.moduleName === 'BASIS') {
// preload basis transcoder
pc.basisInitialize();
moduleLoaded();
} else if (m.moduleName === 'DracoDecoderModule') {
// preload draco decoder
if (pc.dracoInitialize) {
// 1.63 onwards
pc.dracoInitialize();
moduleLoaded();
} else {
// 1.62 and earlier
pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); });
}
} else {
// load remaining modules in global scope
pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); });
}
} else {
moduleLoaded();
}
});
}
};
window.loadModules = loadModules;
|