Files, URLs and asset IDs
Connect project files to the names used by game code.
The manifest lists the game’s assets. Each has an id, a type and a URL. Code uses a stable identifier; Vite produces the file’s address in the build.
In assets.manifest.ts, import.meta.glob collects file URLs and AssetManifestBuilder turns them into asset bundles. Here is that fragment with the result type specified through glob<string>:
const images = import.meta.glob<string>(
'@game/assets/images/**/*.{png,jpg,jpeg,webp,avif}',
{ eager: true, query: '?url', import: 'default' },
);
Here, eager: true retrieves the URLs immediately. It does not load image content through AssetManager: those requests run when the corresponding bundle is loaded.
A small bundle can be assembled manually:
const bundles = [{
name: 'images',
assets: [{ id: 'images/block.png', type: 'image', importedUrl: blockUrl }],
}] satisfies BundleDescriptor[];
blockUrl is the image URL imported with ?url. Import the BundleDescriptor type from @gamedevland/engine/assets. For larger collections, AssetManifestBuilder assembles bundles without listing every file manually.
BundleBuildPolicy determines grouping. The game separates music and effects into audio-music and audio-sfx. The asset type selects the loader: image, audio, json or font. The SDK prepares the loaded image for a node; components do not need to create the texture individually.