pixijs: Documentation insufficient for v6.x explaining that @pixi/assets is external, opt-in
Expected Behavior
The docs show how to use the assets loader:
import { Assets } from 'pixi.js';
Current Behavior
This doesn’t work:
At runtime: Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/pixi__js.js?v=25d6e02b' does not provide an export named 'Assets' (at plugin.ts:8:23)
This is on pixi 6.5.6 which as far as I know is the default.
Other attempt with @pixi/assets
Seeing that, I digged around and found this repo which seems to be in the process of converting to a monorepo (though I couldn’t find any docs about that). I then found the @pixi/assets package and added it to my project.
This worked up to a point: When creating animated sprites using textures from the Assets package I get a strange error:
This happens because this._texture in AnimatedSprite is undefined, which in turns is caused by the following:
The textures coming from the Assets loader are not instances of the same base texture class as the one being checked inside AnimatedSprite.
This leads me to believe the reason this doesn’t work is that using the @pixi/assets package on top of the normal pixi.js package probably ends up with two versions of the same files being imported, and thus two versions of the base texture class, maybe. Though when I looked at the monorepo, the Assets package seems to have no dependencies, so I don’t know.
Possible Solution
I don’t know, I just expected to be able to import Assets from pixi.js as said in the docs.
I wouldn’t mind using the monorepo package otherwise, but this is undocumented and I don’t know if it’s intended to be used.
Steps to Reproduce
- Try to import
Assetsfrompixi.js - It doesn’t exist
Environment
pixi.jsversion: 6.5.6- Browser & Version: Chrome Version 106.0.5249.119 (Official Build) (arm64)
- OS & Version: MacOS
- Note: I am running this using Vite. Though I don’t think that should matter as this is standard import behaviour.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (9 by maintainers)
@F8ER You are mixing different versions of
@pixi/assets(7.0.5) andpixi.js(6.5.8). You need to upgradepixi.jsto 7.0.5, or downgrade@pixi/assetsto 6.5.8.Document for v6.x is here: https://pixijs.download/v6.x/docs/PIXI.Assets.html
I think the document here should also be modified to illustrate
@pixi/assetsis not included inpixi.jsbundle as for v6.x.By the way, I think we need to add links for different version of API Docs (latest, v7.x, v6.x, dev, etc.) on the navbar of pixijs.com instead of just the latest release version, in order to avoid confusion.
https://pixijs.download/v6.x/docs/PIXI.Assets.html The updated document is here! Hope you enjoy it. 😃 I’ll add links for different versions of API Docs for pixijs.com in the near future.