From 1585da7f80bfca45bf65730a42d19d444018288e Mon Sep 17 00:00:00 2001 From: "I.Rezantsev" Date: Fri, 2 Apr 2021 15:50:51 +0300 Subject: [PATCH 1/2] manage meshes by id, not name --- src/Spine.ts | 19 ++++++++++--------- src/core/Slot.ts | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Spine.ts b/src/Spine.ts index 67fa5ebd..d7011df9 100644 --- a/src/Spine.ts +++ b/src/Spine.ts @@ -134,7 +134,7 @@ namespace pixi_spine { else if (attachment instanceof core.MeshAttachment) { let mesh = this.createMesh(slot, attachment); slot.currentMesh = mesh; - slot.currentMeshName = attachment.name; + slot.currentMeshId = attachment.id; slotContainer.addChild(mesh); } else if (attachment instanceof core.ClippingAttachment) { @@ -284,7 +284,7 @@ namespace pixi_spine { if (slot.currentMesh) { slot.currentMesh.visible = false; slot.currentMesh = null; - slot.currentMeshName = undefined; + slot.currentMeshId = undefined; } let ar = region as core.TextureAtlasRegion; if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) { @@ -337,24 +337,25 @@ namespace pixi_spine { (transform as any)._worldID = (slotContainer.transform as any)._worldID; slotContainer.transform = transform; } - if (!slot.currentMeshName || slot.currentMeshName !== attachment.name) { - let meshName = attachment.name; + if (!slot.currentMeshId || slot.currentMeshId !== attachment.id) { + let meshId = attachment.id; if (slot.currentMesh) { slot.currentMesh.visible = false; } slot.meshes = slot.meshes || {}; - if (slot.meshes[meshName] !== undefined) { - slot.meshes[meshName].visible = true; + if (slot.meshes[meshId] !== undefined) { + slot.meshes[meshId].visible = true; } else { let mesh = this.createMesh(slot, attachment); slotContainer.addChild(mesh); } - slot.currentMesh = slot.meshes[meshName]; - slot.currentMeshName = meshName; + slot.currentMesh = slot.meshes[meshId]; + slot.currentMeshName = attachment.name; + slot.currentMeshId = meshId; } (attachment as core.VertexAttachment).computeWorldVerticesOld(slot, slot.currentMesh.vertices); if (slot.currentMesh.color) { @@ -576,7 +577,7 @@ namespace pixi_spine { this.setMeshRegion(attachment, strip, region); slot.meshes = slot.meshes || {}; - slot.meshes[attachment.name] = strip; + slot.meshes[attachment.id] = strip; return strip; }; diff --git a/src/core/Slot.ts b/src/core/Slot.ts index 94dd88a9..03d41b85 100644 --- a/src/core/Slot.ts +++ b/src/core/Slot.ts @@ -38,6 +38,7 @@ namespace pixi_spine.core { clippingContainer: any; meshes: any; + currentMeshId: number; currentMeshName: string; sprites: any; currentSpriteName: string; From d4bb2c62a06c37f8472b1eb4e80fc0c38c9ebf01 Mon Sep 17 00:00:00 2001 From: "I.Rezantsev" Date: Fri, 2 Apr 2021 15:58:56 +0300 Subject: [PATCH 2/2] return currentMeshName reset --- src/Spine.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Spine.ts b/src/Spine.ts index d7011df9..6abf5c43 100644 --- a/src/Spine.ts +++ b/src/Spine.ts @@ -285,6 +285,7 @@ namespace pixi_spine { slot.currentMesh.visible = false; slot.currentMesh = null; slot.currentMeshId = undefined; + slot.currentMeshName = undefined; } let ar = region as core.TextureAtlasRegion; if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) {