瀏覽代碼

hide existing meshes when attachments are removed

when empty keyframes are set on attachments, we shouldn't see the mesh as it should have technically been removed (hidden)
Gordon Cummings 1 年之前
父節點
當前提交
c6614d7db7
共有 1 個文件被更改,包括 13 次插入2 次删除
  1. 13 2
      spine-ts/spine-pixi/src/Spine.ts

+ 13 - 2
spine-ts/spine-pixi/src/Spine.ts

@@ -227,8 +227,15 @@ export class Spine extends Container {
 	/**
 	 * If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
 	 */
-	protected getMeshForSlot (slot: Slot): ISlotMesh {
-		if (!this.meshesCache.has(slot)) {
+	protected hasMeshForSlot(slot: Slot) {
+		return this.meshesCache.has(slot);
+	}
+
+	/**
+	 * If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
+	 */
+	protected getMeshForSlot(slot: Slot): ISlotMesh {
+		if (!this.hasMeshForSlot(slot)) {
 			let mesh = this.slotMeshFactory();
 			this.addChild(mesh);
 			this.meshesCache.set(slot, mesh);
@@ -410,6 +417,9 @@ export class Spine extends Container {
 				pixiMaskSource = { slot, computed: false };
 				continue;
 			} else {
+				if (this.hasMeshForSlot(slot)) {
+					this.getMeshForSlot(slot).renderable = false;
+				}
 				Spine.clipper.clipEndWithSlot(slot);
 				this.pixiMaskCleanup(slot);
 				continue;
@@ -481,6 +491,7 @@ export class Spine extends Container {
 				}
 
 				const mesh = this.getMeshForSlot(slot);
+                mesh.renderable = true;
 				mesh.zIndex = zIndex;
 				mesh.updateFromSpineData(texture, slot.data.blendMode, slot.data.name, finalVertices, finalVerticesLength, finalIndices, finalIndicesLength, useDarkColor);
 			}