pesper Posted May 15, 2022 Share Posted May 15, 2022 (edited) 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 May 15, 2022 by pesper Added an example. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 15, 2022 Share Posted May 15, 2022 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. Quote Link to comment Share on other sites More sharing options...
pesper Posted May 15, 2022 Author Share Posted May 15, 2022 Got it, thank you! I had a file to import everything but I hadn't registered "@pixi/spritesheets" as a Loader plugin. After registering the plugin I'm getting the correct functionality. ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.