Creates a new AssetLoader instance with the specified configuration.
Configuration options for the asset loader
Gets the current loading status including active and queued loads. Useful for monitoring loading progress and debugging.
Object containing the number of active and queued loads
Loads multiple promises organized as an object with named keys. The result preserves the same structure with resolved values.
Object containing promises to be loaded
Promise that resolves to an object with the same keys but resolved values
const assets = await loader.load({
texture: loadTexture('path/to/texture.jpg'),
model: loadModel('path/to/model.gltf'),
audio: loadAudio('path/to/sound.mp3')
});
// Type-safe access to resolved values
console.log(assets.texture); // Texture
console.log(assets.model); // Model
console.log(assets.audio); // AudioBuffer
Loads multiple promises in bulk as an array. Supports both homogeneous arrays and heterogeneous tuples with type safety.
Array or tuple of promises to be loaded
Promise that resolves to an array or tuple of resolved values with preserved types
// Homogeneous array
const textures = await loader.loadArray([
loadTexture('texture1.jpg'),
loadTexture('texture2.jpg'),
loadTexture('texture3.jpg')
]);
// Heterogeneous tuple with type safety
const [texture, model, audio] = await loader.loadArray([
loadTexture('texture.jpg'),
loadModel('model.gltf'),
loadAudio('sound.mp3')
] as const);
Loads multiple promises with retry capabilities organized as an object.
Combines the structure of load()
with the retry functionality of loadWithRetryArray()
.
Object where each value is an array of factory functions
Promise that resolves to an object with the same keys but resolved values
const assets = await loader.loadWithRetry({
texture: [
() => loadTexture('high-res.jpg'),
() => loadTexture('low-res.jpg')
],
model: [
() => loadModel('detailed.gltf'),
() => loadModel('simple.gltf')
]
});
console.log(assets.texture); // Texture (from successful factory)
console.log(assets.model); // Model (from successful factory)
Loads multiple promises with retry capabilities for each one. Each promise has its own set of factory functions for retry attempts.
Array where each element is an array of factory functions for one promise
Promise that resolves to an array of resolved values
Loads a single promise with automatic retry using fallback factories. If the first promise fails, it will try the next factory in order.
Array of factory functions that create promises, ordered by priority
Promise that resolves to the value from the first successful factory
Type-safe asset loader class
Example