spine icon indicating copy to clipboard operation
spine copied to clipboard

preloading base textures in Pixi 7

Open gaming-vf opened this issue 2 years ago • 2 comments

Is pixi-spine still capable of using a preloaded base texture in Pixi 7? I'm using [email protected].

The following code throws an error

await Assets.load("spineAnim.png");
await Assets.load({ src: "spineAnim.json", 
		   data: {
			image: Assets.get("spineAnim.png").baseTexture 
		   }});

It works fine if I don't define an image, otherwise the error is TypeError: this.atlas.findRegion is not a function

gaming-vf avatar Mar 01 '23 16:03 gaming-vf

It seems that the image metadata is successful if used when loading the atlas file rather than the json file. This is a suitable workaround for me. For reference:

await Assets.load("spineAnim.png");
await Assets.load({ 
   src: "spineAnim.atlas", 
   data: { image: Assets.get("spineAnim.png")}
});
await Assets.load({ 
   src: "spineAnim.json", 
   data: { spineAtlas: false }
})

gaming-vf avatar Mar 01 '23 20:03 gaming-vf

Maybe similar problem, I have a suffix to the atlas name.

        assets: [
          {
            name: "Beaver_Guard_Warrior",
            srcs: "./assets/animation/units/Beaver_Guard_Warrior.json",
            loaderOptions: { metadata: { spineAtlasSuffix: "@sd.atlas" } },
          },
        ],

The above can be fixed by either:

            name: "Beaver_Guard_Warrior",
            srcs: "./assets/animation/units/Beaver_Guard_Warrior.json",
            data: {
              spineAtlasFile: "./assets/animation/units/[email protected]",
            },

or spineAtlasSuffix - but that one I can't get to work

Can i update https://github.com/pixijs/spine/tree/master/examples ?

FloodGames avatar Apr 02 '23 19:04 FloodGames