Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/scene/gsplat-unified/gsplat-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,12 @@ class GSplatManager {
worldState.pendingReleases.length = 0;
}

// number of splats to render
this.renderer.setNumSplats(count);
}

// update order texture
this.workBuffer.setOrderData(orderData);

// number of splats to render
this.renderer.setNumSplats(count);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/scene/gsplat-unified/gsplat-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BLEND_NONE, BLEND_PREMULTIPLIED } from '../constants.js';
import { ShaderMaterial } from '../materials/shader-material.js';
import { GSplatResourceBase } from '../gsplat/gsplat-resource-base.js';
import { MeshInstance } from '../mesh-instance.js';
import { math } from '../../core/math/math.js';

/**
* @import { VertexBuffer } from '../../platform/graphics/vertex-buffer.js'
Expand Down Expand Up @@ -101,8 +102,11 @@ class GSplatRenderer {

setMaxNumSplats(numSplats) {

if (this.instanceIndicesCount < numSplats) {
this.instanceIndicesCount = numSplats;
// round up to the nearest multiple of instanceSize (same as createInstanceIndices does internally)
const roundedNumSplats = math.roundUp(numSplats, GSplatResourceBase.instanceSize);

if (this.instanceIndicesCount < roundedNumSplats) {
this.instanceIndicesCount = roundedNumSplats;

// destroy old instance indices
this.instanceIndices?.destroy();
Expand Down