Route Graphics renders from aliases, not from raw URLs in the middle of a render call. The intended flow is:
createAssetBufferManager().app.loadAssets(...).circle-red or video-sample from elements[] and audio[].import createRouteGraphics, {
createAssetBufferManager,
spritePlugin,
videoPlugin,
soundPlugin,
} from "/RouteGraphics.js";
const assets = {
"hero-texture": { url: "/public/hero.png", type: "image/png" },
"intro-video": { url: "/public/intro.mp4", type: "video/mp4" },
"bgm-main": { url: "/public/bgm.mp3", type: "audio/mpeg" },
};
const assetBufferManager = createAssetBufferManager();
await assetBufferManager.load(assets);
const app = createRouteGraphics();
await app.init({
width: 1280,
height: 720,
plugins: {
elements: [spritePlugin, videoPlugin],
audio: [soundPlugin],
},
});
await app.loadAssets(assetBufferManager.getBufferMap());
Asset loading errors are safe to show in application UI. The thrown
error.message and error.userMessage use plain language and explain what the
user can act on:
Could not load image "hero-texture". Missing, inaccessible, or unsupported image file.
When several assets fail in the same load call, Route Graphics throws an
AggregateError with a short summary:
Could not load 2 assets: audio "bgm-main", image "hero-texture". Check that the files exist and are supported.
Use error.userMessage ?? error.message for alerts or toasts, and log the full
error object for debugging. The original low-level failure is preserved in
error.cause. Route Graphics also attaches structured diagnostics to
error.details:
try {
await assetBufferManager.load(assets);
await app.loadAssets(assetBufferManager.getBufferMap());
} catch (error) {
showToast(error.userMessage ?? error.message);
console.error("Failed to load route graphics assets", error);
}
For a single asset failure, error.details may include:
assetKey: alias that failedassetKind: user-facing kind, such as image, audio, video, or fontassetCategory: runtime category, such as texture, audio, video, or
fonttype: MIME typesource: url or bufferurl: source URL, truncated if very longbufferBytes: byte length for buffer-backed assetsphase: loader step that failedcause: original low-level error messageFor multi-asset failures, error.details.failures contains one diagnostic
object per failed asset. Use that for logs or a separate details view instead of
putting the full list in the alert.
Assets and can be used by sprite, slider, spritesheet-animation, text-revealing, and particle textures. When possible, images are loaded directly from their source URLs instead of being buffered into JS first.sound nodes or interaction props such as soundSrc. Audio remains buffer-backed because the runtime still needs decoded audio data.FontFace; use the alias key as textStyle.fontFamily or as an entry in its ordered fallback array.assetBufferManager.load() is cached, so calling it again with the same aliases does not refetch them.assetBufferManager.getBufferMap() may now contain a mix of URL-backed and buffer-backed entries. Images and videos prefer direct URLs when available; audio and fonts stay buffer-backed.render(...) does not fetch missing assets for you. Load before render.Try the built-in examples in the Playground, video demo, and sound demo.