Optional
baseBase path prepended to all asset URLs. Useful for CDN hosting.
Optional
Advanced
bundleOverride how bundle IDs are generated and resolved.
This allows you to customize how assets are grouped and accessed via bundles and allow for multiple bundles to share the same asset keys.
const manifest = {
bundles: [
{
name: 'bunny1',
assets: [
{
alias: ['character', 'character2'],
src: 'textures/bunny.png',
},
],
},
{
name: 'bunny2',
assets: [
{
alias: ['character', 'character2'],
src: 'textures/bunny-2.png',
},
],
},
]
};
const bundleIdentifier: BundleIdentifierOptions = {
connector: ':',
};
await Assets.init({ manifest, basePath, bundleIdentifier });
const resources = await Assets.loadBundle('bunny1');
const resources2 = await Assets.loadBundle('bunny2');
console.log(resources.character === resources2.character); // false
Optional
Advanced
defaultURL parameters to append to all asset URLs. Useful for cache-busting or version control.
Optional
loadOptions for defining the loading behavior of assets.
await Assets.init({
loadOptions: {
onProgress: (progress) => console.log(`Loading: ${Math.round(progress * 100)}%`),
onError: (error, asset) => console.error(`Error loading ${asset.src}: ${error.message}`),
strategy: 'retry',
retryCount: 5,
retryDelay: 500,
}
});
onProgress
callback receives values from 0.0 to 1.0onError
callback is invoked for individual asset load failuresstrategy
can be 'throw' (default), 'retry', or 'skip'retryCount
sets how many times to retry failed assets (default 3)retryDelay
sets the delay between retries in milliseconds (default 250ms)LoadOptions For all available load options
Optional
manifestA manifest defining all your application's assets. Can be a URL to a JSON file or a manifest object.
// Using a manifest object
await Assets.init({
manifest: {
bundles: [{
name: 'game-screen',
assets: [
{
alias: 'hero',
src: 'hero.{png,webp}'
},
{
alias: 'map',
src: 'map.json'
}
]
}]
}
});
// Using a URL to manifest
await Assets.init({
manifest: 'assets/manifest.json'
});
// loading a bundle from the manifest
await Assets.loadBundle('game-screen');
// load individual assets from the manifest
const heroTexture = await Assets.load('hero');
Optional
preferencesOptional preferences for asset loading behavior.
Optional
Advanced
skipSkip browser format detection for faster initialization. Only use if you know exactly what formats your target browsers support.
Optional
textureConfigure texture loading preferences. Useful for optimizing asset delivery based on device capabilities.
Optional
format?: ArrayOr<string>Preferred texture formats in order of preference. Default: ['avif', 'webp', 'png', 'jpg', 'jpeg']
Optional
resolution?: number | number[]Preferred texture resolution(s). Can be a single number or array of resolutions in order of preference.
Options for initializing the Assets class. These options configure how assets are loaded, resolved, and managed in your PixiJS application.