From 5e42c9dcd6bc43be573a8ad54abb9b1cdccd7f13 Mon Sep 17 00:00:00 2001 From: Oscar Lorentzon Date: Sun, 13 Sep 2026 18:56:30 -0700 Subject: [PATCH] Allocate all four SH textures for paged ext splats With extSplats SH3 spans two textures, so an sh3 asset needs four while the pager created three. Every page with SH3 data threw RangeError, and the rest of that frame's loading was skipped. Lower SH degrees and the packed path are unaffected. --- src/SplatPager.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/SplatPager.ts b/src/SplatPager.ts index baa2869e..c1426685 100644 --- a/src/SplatPager.ts +++ b/src/SplatPager.ts @@ -871,13 +871,11 @@ export class SplatPager { } } - private ensureShTextures(numSh: number) { - this.curSh = Math.max(this.curSh, numSh); - + private ensureShTextures(numTextures: number) { const emptyShTextures = this.extSplats ? SplatPager.emptyExtShTextures : SplatPager.emptyShTextures; - for (let i = 0; i < this.curSh; i++) { + for (let i = 0; i < numTextures; i++) { if (this.shTextures[i].value === emptyShTextures[i]) { const elementsPerSplat = this.shTextures[i].value === SplatPager.emptyUint32x2 ? 2 : 4; @@ -996,9 +994,9 @@ export class SplatPager { uploadTextureLayer(this.extTexture, page, pageBase * 4, extArray); } - // In case of extSplats there can be 4 shArrays for 3 sh degrees - const numSh = Math.min(shArrays.length, 3); - this.ensureShTextures(numSh); + // With extSplats SH3 spans two textures: four arrays, three degrees. + this.curSh = Math.max(this.curSh, Math.min(shArrays.length, 3)); + this.ensureShTextures(shArrays.length); for (let i = 0; i < shArrays.length; i++) { const array = shArrays[i];