When loading a .rad file with paged: true, onLoad fires before any splat data is available. At that point:
splatMesh.numSplats === 0
splatMesh.packedSplats === undefined
splatMesh.isInitialized === true
splatMesh.forEachSplat() iterates 0 splats
This makes it impossible to compute a bounding box (or do any per-splat work) at load time for paged .rad files.
Additionally, SplatMesh.getBoundingBox() throws "Bounding box requires PackedSplats or ExtSplats" in this state, even though isInitialized is true.
const splat = new SplatMesh({
url: 'my-file.rad',
paged: true,
onLoad: () => {
console.log(splat.numSplats); // 0
console.log(splat.packedSplats); // undefined
console.log(splat.isInitialized); // true
splat.forEachSplat(() => {}); // iterates 0 times
splat.getBoundingBox(); // throws: "Bounding box requires PackedSplats or ExtSplats"
}
});
Either:
onLoad fires only after the first chunk of splat data is available (so numSplats > 0), or
A separate callback like onFirstChunkLoaded / onSplatsReady is provided for paged files, or
getBoundingBox() and forEachSplat() work correctly once isInitialized === true, regardless of paging mode
Currently working around this by polling numSplats in onFrame:
const splat = new SplatMesh({
url: 'my-file.rad',
paged: true,
onFrame: ({ mesh }) => {
if (mesh.numSplats > 0 && !boundingBoxComputed) {
// compute bounding box here
boundingBoxComputed = true;
}
}
});
@sparkjsdev/spark version: 2.0.0
File format: .rad with paged: true
THREE.js version: r180
When loading a .rad file with paged: true, onLoad fires before any splat data is available. At that point:
This makes it impossible to compute a bounding box (or do any per-splat work) at load time for paged .rad files.
Additionally, SplatMesh.getBoundingBox() throws "Bounding box requires PackedSplats or ExtSplats" in this state, even though isInitialized is true.
Either:
onLoad fires only after the first chunk of splat data is available (so numSplats > 0), or
A separate callback like onFirstChunkLoaded / onSplatsReady is provided for paged files, or
getBoundingBox() and forEachSplat() work correctly once isInitialized === true, regardless of paging mode
Currently working around this by polling numSplats in onFrame:
@sparkjsdev/spark version: 2.0.0
File format: .rad with paged: true
THREE.js version: r180