Loading...
Loading...
Use this skill when loading and managing resources in PixiJS v8. Covers Assets.init, Assets.load/add/unload, bundles, manifests, background loading, onProgress, caching, spritesheets, video textures, web fonts, bitmap fonts, animated GIFs, compressed textures, SVG as texture or Graphics, resolution detection, per-asset data options, and forcing a specific loader with the parser field (for extension-less URLs). Triggers on: Assets, Assets.load, Assets.init, loadBundle, manifest, backgroundLoad, Spritesheet, Cache, LoadOptions, unload, parser, loadParser, loadWebFont, loadBitmapFont, loadVideoTextures, GifSource, VideoSourceOptions.
npx skill4agent add pixijs/pixijs-skills pixijs-assetsAssetsawait Assets.init({ basePath: "/static/" });
const texture = await Assets.load("bunny.png");
const sprite = new Sprite(texture);
app.stage.addChild(sprite);
const [hero, enemy] = await Assets.load(["hero.png", "enemy.png"]);
await Assets.load({
alias: "logo",
src: "logo.webp",
});
const logo = new Sprite(Assets.get("logo"));Assets.init()basePathtexturePreferenceAssets.load()UnresolvedAssetAssets.get()| Type | Extensions | Parser ID | Loader |
|---|---|---|---|
| Textures | | | |
| SVG | | | |
| Video textures | | | |
| Sprite sheets | | | |
| Bitmap fonts | | | |
| Web fonts | | | |
| JSON | | | |
| Text | | | |
| Compressed textures | | | See |
| Animated GIFs | | | Requires |
parserparserparser// Signed CDN URL with no extension
const texture = await Assets.load({
src: "https://cdn.example.com/signed/abc123?token=xyz",
parser: "texture",
});
// API endpoint that returns JSON
const data = await Assets.load({
alias: "config",
src: "https://api.example.com/v1/config",
parser: "json",
});
// Extension-less font URL with explicit family
await Assets.load({
src: "https://cdn.example.com/fonts/hero-v2",
parser: "web-font",
data: { family: "Hero", weights: ["400", "700"] },
});
// Video stream without a file extension
const clipTexture = await Assets.load({
src: "https://cdn.example.com/stream/xyz",
parser: "video",
data: { mime: "video/mp4", muted: true, playsinline: true },
});parsersrcdatadata'texture''svg''video''json''text''web-font''bitmap-font''spritesheet''gif''pixi.js/gif''basis''dds''ktx''ktx2'https://cdn.example.com/get?id=abc123URL.createObjectURL(blob)blob:.../api/assets/hero-v2/static/abc123def/static/abc123def.pngparserparserloadParserloadParserparser// Old (deprecated)
await Assets.load({ src: "...", loadParser: "loadTextures" });
// New
await Assets.load({ src: "...", parser: "texture" });| Topic | Reference | When |
|---|---|---|
| Texture atlases and animations | references/spritesheet.md | Loading sprite sheets with |
| Video textures | references/video.md | |
| Web and bitmap fonts | references/fonts.md | |
| Animated GIFs | references/gif.md | |
| Grouping assets by feature | references/bundles.md | |
| Declaring everything upfront | references/manifests.md | |
| Cache lookups and cleanup | references/caching.md | |
| Priming future assets | references/background.md | |
| Loading screens | references/progress.md | |
| GPU-compressed formats | references/compressed-textures.md | |
| Vector vs raster SVG | references/svg.md | |
| Retina + format detection | references/resolution.md | |
Assets.load(url)references/bundles.mdAssets.initreferences/manifests.mdAssets.loadreferences/progress.mdreferences/background.mdAssets.unloadreferences/compressed-textures.mdreferences/caching.mdreferences/svg.mdtexturePreferencereferences/resolution.mdLoadOptionsAssets.loadloadBundledataawait Assets.load(["hero.png", "enemy.png"], {
onProgress: (p) => updateBar(p),
onError: (err, url) => {
const src = typeof url === "string" ? url : url.src;
console.warn("failed:", src, err);
},
strategy: "retry",
retryCount: 3,
retryDelay: 250,
});onProgress(progress)[0, 1]onError(error, url)urlstring | ResolvedAsset.srcurl.srcstrategy: 'throw' | 'skip' | 'retry''throw''skip''retry'retryCount3strategy'retry'retryDelay250Loader.defaultOptionsloadOptionsAssets.init()datadata| Asset type | | Key options | Reference |
|---|---|---|---|
| Texture (image) | | | |
| SVG | | | |
| Video | | | |
| Web font | | | |
| Bitmap font | (none; auto-configured) | Distance-field detection sets scale mode and mipmaps | |
| Spritesheet | | | |
| GIF | | | |
| Compressed texture | | | |
| JSON / Text | (none) | Returned as-is | — |
LoadOptionsdataawait Assets.load(
{
alias: "hero",
src: "hero.png",
data: { scaleMode: "nearest", resolution: 2 },
},
{ strategy: "retry", retryCount: 3 },
);dataawait Assets.init({
manifest: {
bundles: [
{
name: "level1",
assets: [
{ alias: "tiles", src: "tiles.png", data: { scaleMode: "nearest" } },
{ alias: "font", src: "hero.woff2", data: { family: "Hero" } },
{
alias: "clip",
src: "intro.mp4",
data: { autoPlay: false, muted: true },
},
],
},
],
},
});Assets.init(options)basePathmanifestdefaultSearchParamsRecord<string, any>skipDetections: booleantexturePreference.formatbundleIdentifier: BundleIdentifierOptionsloadOptions: Partial<LoadOptions>strategyretryCountretryDelayAssets.loadpreferences: Partial<AssetsPreferences>crossOriginpreferWorkerspreferCreateImageBitmapparseAsGraphicsContextAssets.setPreferences({
crossOrigin: "anonymous",
preferCreateImageBitmap: false,
});
for (const detection of Assets.detections) {
console.log(detection.extension);
}
Assets.reset();Assets.setPreferences(preferences)Assets.detectionsFormatDetectionParserAssets.reset()Assets.initTexture.from(url)const texture = Texture.from("https://example.com/image.png");const texture = await Assets.load("https://example.com/image.png");Texture.from()Assets.load()Assets.addAssets.add("bunny", "bunny.png");Assets.add({ alias: "bunny", src: "bunny.png" });Assets.add(key, url)aliassrcAssets.load()Assets.unloadBundle()