You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the best way to track the total loaded assets percentage using PIXI JS.
What I did is like this
/** Load assets bundles that have nott been loaded yet */exportasyncfunctionloadBundles(bundles: string|string[],onProgress?: ProgressCallback){if(typeofbundles==='string')bundles=[bundles];// Check bundles requested if they existsfor(constbundleofbundles){if(!checkBundleExists(bundle)){thrownewError(`[Assets] Invalid bundle: ${bundle}`);}}// Filter out bundles already loadedconstloadList=bundles.filter((bundle)=>!loadedBundles.includes(bundle));// Skip if there is no bundle left to be loadedif(!loadList.length)return;// Load bundlesconsole.log('[Assets] Load:',loadList.join(', '));awaitAssets.loadBundle(loadList,onProgress);// Append loaded bundles to the loaded listloadedBundles.push(...loadList);}
/** Initialise and start background loading of all assets */exportasyncfunctioninitAssets(onProgress: ProgressCallback){// Load assets manifestassetsManifest=awaitfetchAssetsManifest('assets/assets-manifest.json');// Init PixiJS assets with this asset manifestawaitAssets.init({manifest: assetsManifest,basePath: 'assets'});// Load assets for the load screenawaitloadBundles('preload',onProgress);// List all existing bundles namesconstallBundles=assetsManifest.bundles.map((item)=>item.name);// Start up background loading of all bundlesAssets.backgroundLoadBundle(allBundles);}
// Setup assets bundles (see assets.ts) and start up loading everything in backgroundawaitinitAssets((progress)=>{console.log(progress)});
Do you happen to have any suggestion how to do it, or this is okay. Thanks
The text was updated successfully, but these errors were encountered:
What's the best way to track the total loaded assets percentage using PIXI JS.
What I did is like this
Do you happen to have any suggestion how to do it, or this is okay. Thanks
The text was updated successfully, but these errors were encountered: