interface HeroData extends SpritesheetData {
animations: { idle: string[]; walk: string[]; attack: string[] };
}
ecs.builder.withAssets(a => a
.add('hero', spritesheetLoader<HeroData>('/hero.json'))
);
// Later:
const sheet = ecs.assets.get('hero'); // Spritesheet<HeroData>
const set = animationSetFromSheet('hero', sheet); // names inferred
Build an asset-manager-compatible loader for a PixiJS spritesheet atlas (TexturePacker JSON, etc.). Returns the fully-parsed
Spritesheetobject with.animationsand.texturespopulated.The loader performs a runtime shape check on the resolved value —
Assets.load<T>is purely nominal in PixiJS, so pointing this at a non-atlas URL would otherwise surface as a misleading 'animation not found' error deep inclipFromSheet/animationSetFromSheet. The shape check turns that into a load-time error with a clear message.To get literal animation-name inference, declare
Sas aninterface ... extends SpritesheetData(atypealias re-widens viaSpritesheetData.animations'sDict<string[]>string index signature).