Avoid crash if batchableSpineSlot is undefined (it shouldn't be undefined). See #2991.

This commit is contained in:
Davide Tantillo 2025-12-11 12:17:20 +01:00
parent bb228f9b64
commit 6c64b2fba3

View File

@ -46,7 +46,7 @@ const spineBlendModeMap: Record<number, BLEND_MODES> = {
3: 'screen' 3: 'screen'
}; };
type GpuSpineDataElement = { slotBatches: Record<string, BatchableSpineSlot> }; type GpuSpineDataElement = { slotBatches: Record<string, BatchableSpineSlot | undefined> };
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
export class SpinePipe implements RenderPipe<Spine> { export class SpinePipe implements RenderPipe<Spine> {
@ -93,8 +93,8 @@ export class SpinePipe implements RenderPipe<Spine> {
const texture = cacheData.texture; const texture = cacheData.texture;
if (texture !== batchableSpineSlot.texture) { if (texture !== batchableSpineSlot?.texture) {
if (!batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot, texture)) { if (!batchableSpineSlot?._batcher.checkAndUpdateTexture(batchableSpineSlot, texture)) {
return true; return true;
} }
} }
@ -176,9 +176,9 @@ export class SpinePipe implements RenderPipe<Spine> {
const cacheData = spine._getCachedData(slot, attachment); const cacheData = spine._getCachedData(slot, attachment);
if (!cacheData.skipRender) { if (!cacheData.skipRender) {
const batchableSpineSlot = gpuSpine.slotBatches[spine._getCachedData(slot, attachment).id]; const batchableSpineSlot = gpuSpine.slotBatches[cacheData.id];
// we didn't figure out why batchableSpineSlot might be undefined: https://github.com/EsotericSoftware/spine-runtimes/issues/2991
batchableSpineSlot._batcher?.updateElement(batchableSpineSlot); batchableSpineSlot?._batcher?.updateElement(batchableSpineSlot);
} }
} }
} }