All asset loading functions in Fraxel returnDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/fraxel/llms.txt
Use this file to discover all available pages before exploring further.
symbol IDs. These symbols are opaque handles — you store them in constants and pass them to JSX props like textureId or soundId on nodes. The engine maps symbols back to their underlying ImageBitmap or AudioBuffer at render/playback time. For a full guide on preloading strategies and per-scene loading patterns, see the Assets guide.
loadTexture(url)
Loads an image fromurl, decodes it into a Texture, and returns a symbol ID. If the same URL has already been loaded, the existing symbol is returned immediately (automatic deduplication — no double-fetching).
Absolute or root-relative URL of the image file. Any format the browser’s
<img> element accepts works (PNG, WebP, JPEG, SVG, etc.).Promise<symbol> — resolves to a symbol ID once the image has fully loaded and decoded. Rejects if the network request fails or the image cannot be decoded.
loadSound(url)
Fetches an audio file fromurl, decodes the raw bytes using the Web Audio API (AudioContext.decodeAudioData()), and returns a symbol ID referencing the in-memory AudioBuffer.
Absolute or root-relative URL of the audio file. Any format supported by the browser’s
AudioContext works (MP3, OGG, WAV, etc.).Promise<symbol> — resolves to a symbol ID once the file has been fetched and the audio buffer has been decoded. Rejects on network errors or decode failures.
Unlike
loadTexture, loadSound does not deduplicate by URL — each call returns a new symbol. Load sounds once at module scope or in a preload step.loadBatch(loaders, options?)
Loads multiple assets in parallel with optional progress tracking. Eachloader is a zero-argument function that returns Promise<T> — wrap your loadTexture / loadSound calls in arrow functions. Results are returned in the same order as the input array, regardless of which asset resolves first.
An array of loader functions. All are invoked immediately and run concurrently via
Promise.all. Each function should return a Promise that resolves to the asset handle.Optional configuration object.
Called each time an individual asset finishes loading.
loaded is the count of assets resolved so far; total is the length of the loaders array. Use this to drive loading-screen progress bars.Promise<T[]> — resolves to an array of results in the same order as the input loaders. The generic T matches whatever your loader functions return (typically symbol).
loadBatchAsset(type, urls, options?)
A typed convenience wrapper aroundloadBatch for loading multiple assets of the same type from a URL list. Internally calls loadTexture or loadSound for each URL depending on type.
Asset type. Determines whether each URL is loaded with
loadTexture or loadSound.Array of URLs to load. All are fetched concurrently.
Optional configuration object.
Called each time an individual URL finishes loading.
Promise<symbol[]> — array of symbol IDs in the same order as the input urls.
unloadTexture(id)
Frees a previously loaded texture from memory by removing it from the internal texture store. After calling this, any node still referencing the symbol will render nothing (or fall back to a default).The symbol ID returned by
loadTexture. Passing an unknown symbol is a no-op.void.
unloadSound(id)
Frees a previously loadedAudioBuffer from memory. After calling this, any <audio-player> node referencing the symbol will no longer be able to play that sound.
The symbol ID returned by
loadSound. Passing an unknown symbol is a no-op.void.
Usage patterns
Individual loading at module scope
The simplest approach — await each asset at the top level of your scene module. Works well for small scenes:Preload screen with progress bar
Load everything before starting the game loop. Drive a loading bar withonProgress:
Per-scene loading with loadBatchAsset
Load only what a specific level needs, then unload when the player leaves:LoaderOptions reference
| Property | Type | Description |
|---|---|---|
onProgress | (loaded: number, total: number) => void | Called after each asset resolves. loaded increments from 1 to total. |
Related guides
- Assets guide — full pipeline, preloading strategies, and per-scene patterns
- Animation & Tweening API — using texture symbols with
animationFromSheet - Nodes 2D API —
<sprite>and<audio-player>node props that accept symbol IDs