Hello,
There are many similar issues for using multiple atlas or attachments files.
But i couldn't find my problem.
I'm using 2 packs for body and weapons.
It means 6 files; body.atlas, body.png, body.json, weapons.atlas, weapons.png, weapons.json
Problem is that it shows only one png for first skeletonData.
here's some code.
It shows body.png not weapons.png
What am i wrong with it?
function load (name, scale) {
if (assetManager.isLoadingComplete()) {
var skeletonData = loadSkeleton("body");
var skeletonData2 = loadSkeleton("weapons");
// Create a SkeletonMesh from the data and attach it to the scene
skeletonMesh = new spine.threejs.SkeletonMesh(skeletonData);
var skeleton = skeletonMesh.skeleton;
// skeleton.setSkinByName("// preview");
// set new skin
var newSkin = new spine.Skin('mix');
var slotLen = skeleton.slots.length;
appendSkin(skeletonData.findSkin('eyes:tall'), newSkin, slotLen);
appendSkin(skeletonData2.findSkin('sword:orange'), newSkin, slotLen);
//
skeleton.setSkin(newSkin);
skeleton.setSlotsToSetupPose();
requestAnimationFrame(render);
} else requestAnimationFrame(load);
}
function appendSkin(source, newSkin, slotLength) {
for (var slot = 0; slot < slotLength; slot++) {
var attachments = source.attachments[slot];
for (var attachmentName in attachments) {
newSkin.addAttachment(slot, attachmentName, attachments[attachmentName]);
}
}
}
function loadSkeleton (name, scale = 1.0) {
// Load the texture atlas using name.atlas and name.png from the AssetManager.
// The function passed to TextureAtlas is used to resolve relative paths.
let atlas = new spine.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path) {
// going something wrong here...
return assetManager.get("assets/" + path);
});
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
let atlasLoader = new spine.AtlasAttachmentLoader(atlas);
// Create a SkeletonJson instance for parsing the .json file.
let skeletonJson = new spine.SkeletonJson(atlasLoader);
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
skeletonJson.scale = scale;
var skeletonData = skeletonJson.readSkeletonData(assetManager.get("assets/" + name + ".json"));
return skeletonData;
}
Thanks