Hi everyone,
I'm working on integrating a Spine animation in PixiJS, and everything works perfectly when I load the files normally like this:
PIXI.Assets.add({ alias: "spineboyData", src: "chibi-stickers.txt" });
PIXI.Assets.add({ alias: "spineboyAtlas", src: "chibi-stickers-pro.atlas" });
await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]);
const spineboy = spine.Spine.from({
skeleton: "spineboyData",
atlas: "spineboyAtlas",
scale: 0.5,
});
However, I need to embed the .skel and .atlas files as Base64 instead of loading them from external files. I tried converting the .skel binary file to Base64 and decoding it back to a Uint8Array, but it doesn't seem to work.
I also embedded the .atlas as a Base64 string inside a Blob and created an object URL, but Spine cannot find the region textures.
However, I need to embed the .skel, .atlas, and .png files in Base64 instead of loading them as external files.
For the .skel binary file, I tried converting it to Base64 and then decoding it back into a Uint8Array, but it doesn’t seem to work properly.
For the .atlas file, I embedded it as a Base64 string inside a Blob and created a URL object, but Spine can’t find the texture regions when loading the skeleton.
For the .png file, I know it must be converted into Base64, but I’m not sure how to correctly reference it inside the .atlas file.
My Questions:
How should I embed the .skel binary file in Base64? Do I need to change the way I load it in PixiJS?
How should I embed the .atlas file correctly? Does anything need to be modified to keep the texture references valid?
How do I reference a .png in Base64 inside the .atlas file? Should I replace the image name with the Base64 string directly, or is there another way?
If anyone has successfully done this, I’d really appreciate some guidance. Thanks in advance!
What I Have Done
The Problem
My Current Code
Load all assets
const { atlasTxt: loadedAtlasTxt, skeleton } = await PIXI.Assets.load(['atlasTxt', 'skeleton', 'spineImage']);
//
Debugging logs
console.log("Checking if assets are loaded:");
console.log("Skeleton:", skeleton);
console.log("Atlas Text:", loadedAtlasTxt);
if (!skeleton) {
console.error("
Error: Skeleton asset is missing.");
return;
}
if (!loadedAtlasTxt || loadedAtlasTxt.length === 0) {
console.error("
Looking for texture: ${path}`);
return PIXI.Assets.get("spineImage")?.baseTexture || null;
});
PIXI.Assets.cache.set('atlas', textureAtlas);
//
Set animations
spineboy.skeleton.setSkinByName("soeren");
spineboy.skeleton.setSlotsToSetupPose();
spineboy.state.setAnimation(0, "wave", true);
// 