diff --git a/src/Spine.ts b/src/Spine.ts index 809f269..0573215 100644 --- a/src/Spine.ts +++ b/src/Spine.ts @@ -101,6 +101,7 @@ export interface AttachmentCacheData uvs: Float32Array; indices: number[]; color: Color; + skipRender: boolean; clippedData?: { vertices: Float32Array; uvs: Float32Array; @@ -431,7 +432,7 @@ export class Spine extends Container implements View skeletonColor.a * slotColor.a * attachmentColor.a, ); - cacheData.clipped = false; + cacheData.skipRender = cacheData.clipped = false; if (clipper.isClipping()) { @@ -489,7 +490,9 @@ export class Spine extends Container implements View const sizeChange = clippedData.vertexCount !== verticesCount || indicesCount !== clippedData.indicesCount; - if (sizeChange) + cacheData.skipRender = verticesCount === 0; + + if (sizeChange && !cacheData.skipRender) { this.spineAttachmentsDirty = true; @@ -583,6 +586,7 @@ export class Spine extends Container implements View indices: [0, 1, 2, 0, 2, 3], uvs: attachment.uvs as Float32Array, color: new Color(1, 1, 1, 1), + skipRender: false, }; } else @@ -596,6 +600,7 @@ export class Spine extends Container implements View indices: attachment.triangles, uvs: attachment.uvs as Float32Array, color: new Color(1, 1, 1, 1), + skipRender: false, }; } diff --git a/src/SpinePipe.ts b/src/SpinePipe.ts index d72825f..b9c4e6f 100644 --- a/src/SpinePipe.ts +++ b/src/SpinePipe.ts @@ -101,16 +101,16 @@ export class SpinePipe implements RenderPipe const cacheData = spine._getCachedData(slot, attachment); const batchableSpineSlot = gpuSpine.slotBatches[cacheData.id] ||= new BatchableSpineSlot(); - if (!cacheData.clipped || (cacheData.clipped && cacheData.clippedData.vertices.length > 0)) + batchableSpineSlot.setData( + spine, + cacheData, + (attachment.region?.texture.texture) || Texture.EMPTY, + blendMode, + roundPixels + ); + + if (!cacheData.skipRender) { - batchableSpineSlot.setData( - spine, - cacheData, - (attachment.region?.texture.texture) || Texture.EMPTY, - blendMode, - roundPixels - ); - batcher.addToBatch(batchableSpineSlot); } } @@ -146,9 +146,14 @@ export class SpinePipe implements RenderPipe if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) { - const batchableSpineSlot = gpuSpine.slotBatches[spine._getCachedData(slot, attachment).id]; + const cacheData = spine._getCachedData(slot, attachment); - batchableSpineSlot.batcher?.updateElement(batchableSpineSlot); + if (!cacheData.skipRender) + { + const batchableSpineSlot = gpuSpine.slotBatches[spine._getCachedData(slot, attachment).id]; + + batchableSpineSlot.batcher?.updateElement(batchableSpineSlot); + } } } }