Skip to content

Commit

Permalink
Merge pull request #384 from unclearriw/skin_mesh_fix
Browse files Browse the repository at this point in the history
possible fix #318 for mesh attachments
  • Loading branch information
ivanpopelyshev authored Apr 7, 2021
2 parents 701f405 + d4bb2c6 commit 092c444
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -284,6 +284,7 @@ namespace pixi_spine {
if (slot.currentMesh) {
slot.currentMesh.visible = false;
slot.currentMesh = null;
slot.currentMeshId = undefined;
slot.currentMeshName = undefined;
}
let ar = region as core.TextureAtlasRegion;
Expand Down Expand Up @@ -337,24 +338,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) {
Expand Down Expand Up @@ -579,7 +581,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;
};

Expand Down
1 change: 1 addition & 0 deletions src/core/Slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace pixi_spine.core {
clippingContainer: any;

meshes: any;
currentMeshId: number;
currentMeshName: string;
sprites: any;
currentSpriteName: string;
Expand Down

0 comments on commit 092c444

Please sign in to comment.