Hello,
I need help with creating texture in Spine.
LIBRARY: I use @esotericsoftware/spine-pixi
GOAL: My main goal is to create a single html file with all assets.
So, I load all assets with base64 format.
In my atlas file, I create the first line as [IMG]
to switch to the loaded asset local URL
this URL has after bundling some hash URLs like fe9ea.png and localhost:3000/fe9ea.png display image
ERROR: When I run atlas.setTextures(assetManager),
It throws error with Texture. I assume that Pixi.Texture is not compatible with SpineTexture.
async loadSpine(img: HTMLImageElement) {
const atlasDecode = atob(atlas_base64).replace('[IMG]', img.src);
console.log(img.src); // http://localhost:3000/fe9ea6d84ce6ada8c62a385fc4ae8e13.png
const jsonDecode = atob(json_base64);
const atlas = new spine.TextureAtlas(atlasDecode);
const assetManager = new spine.AssetManagerBase((imagePath) => {
const pixiTexture = PIXI.Texture.from(imagePath);
return new SpineTexture(pixiTexture);
});
assetManager.loadTexture(img.src, (asset) => {
console.log(asset); // http://localhost:3000/fe9ea6d84ce6ada8c62a385fc4ae8e13.png
atlas.setTextures(assetManager); //Cannot read properties of undefined (reading 'setFilters')
const atlasAttachmentLoader = new spine.AtlasAttachmentLoader(atlas);
const skeletonJson = new spine.SkeletonJson(atlasAttachmentLoader).readSkeletonData(jsonDecode);
this.baseSpine = new spine.Spine(skeletonJson);
this.baseSpine.state.setAnimation(0, 'idle', true);
this.baseSpine.autoUpdate = true;
this.baseSpine.state.timeScale = 0.5;
this.baseContainer.addChild(this.baseSpine);
Game.addToLevel(this.baseContainer);
this.baseContainer.on('pointerdown', this.lipSync);
});
}
I had try with Asset.load base64 images and JSON works fine however atlas cant find img.
Please let me know how to solve it.