Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible fix #318 for mesh attachments #384

Merged
merged 2 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -576,7 +578,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