40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$assets$BackgroundLoader = function(global, require, module, exports) {
|
|
class BackgroundLoader {
|
|
constructor(loader, verbose = !1) {
|
|
this._loader = loader;
|
|
this._assetList = [];
|
|
this._isLoading = !1;
|
|
this._maxConcurrent = 1;
|
|
this.verbose = verbose;
|
|
}
|
|
add(assetUrls) {
|
|
assetUrls.forEach(a => {
|
|
this._assetList.push(a);
|
|
});
|
|
this.verbose && console.log("[BackgroundLoader] assets: ", this._assetList);
|
|
this._isActive && !this._isLoading && this._next();
|
|
}
|
|
async _next() {
|
|
if (this._assetList.length && this._isActive) {
|
|
this._isLoading = !0;
|
|
const toLoad = [], toLoadAmount = Math.min(this._assetList.length, this._maxConcurrent);
|
|
for (let i = 0; i < toLoadAmount; i++) {
|
|
toLoad.push(this._assetList.pop());
|
|
}
|
|
await this._loader.load(toLoad);
|
|
this._isLoading = !1;
|
|
this._next();
|
|
}
|
|
}
|
|
get active() {
|
|
return this._isActive;
|
|
}
|
|
set active(value) {
|
|
this._isActive !== value && (this._isActive = value) && !this._isLoading && this._next();
|
|
}
|
|
}
|
|
exports.BackgroundLoader = BackgroundLoader;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$assets$BackgroundLoader.js.map
|