Jump to content

Migrating from 'pixi.js' to '@pixi/...' - Any documentation around this?


pesper
 Share

Recommended Posts

I recently tried to switch from importing everything from the 'pixijs' package to importing from the individual '@pixi/...' packages referenced in the documentation here: https://pixijs.io/guides/basics/architecture-overview.html

I assumed the usage would be the same across these packages but making this change caused a whole range of bugs and broken behavior. Is there any kind of documentation for differences between the two, or gotchas while attempting this kind of migration? And more broadly, what is the distinction between these packages? Is it safe to assume that the '@pixi/' modular packages are "recommended" going forward?

The specific issue I'm currently stuck on is loading Spritesheets from a JSON file- code that works perfectly fine with the 'pixijs' import, with the '@pixi/loaders' import is now giving exceptions where the 'spritesheet' property is missing from the loaded resource (similar to this: https://github.com/pixijs/pixijs/issues/5965, though I am running the site on a cloud host, not locally).

For example this code:

import { Loader } from 'pixi.js'
Loader.shared.add("https://MY_FILE_SERVER/sheet.json").load((loader, resources) => {
	console.log(resources)
})

...logs an object with 'spritesheet' and 'textures' attributes, and you can see that the PNG is retrieved via the network tab. But this code:

import { Loader } from '@pixi/loaders'
Loader.shared.add("https://MY_FILE_SERVER/sheet.json").load((loader, resources) => {
	console.log(resources)
})

...just logs an object with 'data' and 'metadata' but no loaded spritesheet and the PNG is never loaded (nor attempted to load).

Edited by pesper
Added an example.
Link to comment
Share on other sites

https://pixijs.io/customize/ , switch to bundler mode. The thing is, you need a bundle. Whether its yours or the one from npm 'pixi.js' or 'pixi.js-legacy', you need a file that imports everything and links it between.

If you have it, even if its just default pixi.js bundle, then you can import stuff from submodules like '@pixi/display'.

Just using submodules without registering loaders, renderer plugins and application plugins wont work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...