How to use spine models which share an atlas?

It’s not too uncommon for spine models to share an atlas file. However, i cannot find any examples of its implementation.

Loading a spine file is done as so:

this.load.spine("jsonkey", "json-filename", "atlas-filename");

but when another spine model (but using the same atlas file) is loaded, you get an error from the TextureManager that the file already exists.

this.load.spine("jsonkey", "json-filename1", "atlas-filename");
this.load.spine("jsonkey", "json-filename2", "atlas-filename");

What am I supposed to do?

I dug into SpinePlugin.js and located where I can avoid the error inside the addToCache function. But this seems janky?

before:
this.loader.textureManager.addImage(key, file.data);

after:

if(!this.loader.textureManager.exists(key)){
  this.loader.textureManager.addImage(key, file.data);
}

I noticed that in the documentation for jsonURL there is an optional to send an array of strings. Doing this would solve the problem, however it can be inconvenient if two total separate pieces of logic need to share an atlas. This means that there has to be some separate logic which has to know all the json files it needs to load :frowning:

https://photonstorm.github.io/phaser3-docs/Phaser.Loader.FileTypes.SpineFile.html

Did you ever get this properly working? Looking at the source it looks like SpineFile only takes a single string jsonURL.

I never looked at the source directly, maybe it changed? I “solved” my problem by manually editing SpinePlugin.js as explained before. It’s not good since it will be overwritten everytime you update the phaser library