Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/SplatPager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ export class SplatPager {
readonly pageSplats: number;

readonly maxSh: number;
curSh: number;

autoDrive: boolean;
numFetchers: number;
Expand Down Expand Up @@ -619,7 +618,6 @@ export class SplatPager {
this.maxSplats = this.maxPages * PAGE_SPLATS;

this.maxSh = options.maxSh ?? 3;
this.curSh = 0;

this.autoDrive = options.autoDrive ?? true;
this.numFetchers = options.numFetchers ?? 3;
Expand Down Expand Up @@ -871,13 +869,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;
Expand Down Expand Up @@ -996,9 +992,8 @@ 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 is split across two textures: 3 degrees, 4 arrays.
this.ensureShTextures(shArrays.length);

for (let i = 0; i < shArrays.length; i++) {
const array = shArrays[i];
Expand Down
Loading