Procházet zdrojové kódy

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 před 1 rokem
rodič
revize
c6614d7db7
1 změnil soubory, kde provedl 13 přidání a 2 odebrání
  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);
 			}