Skip to content

Commit

Permalink
Limit output SH bands (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck authored Dec 9, 2024
1 parent b15d8fc commit 0dcc6be
Show file tree
Hide file tree
Showing 2 changed files with 268 additions and 332 deletions.
26 changes: 17 additions & 9 deletions src/file-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ const initFileHandler = (scene: Scene, events: Events, dropTarget: HTMLElement,
}
});

// get the array of visible splats
// get the list of visible splats containing gaussians
const getSplats = () => {
return (scene.getElementsByType(ElementType.splat) as Splat[]).filter(splat => splat.visible);
return (scene.getElementsByType(ElementType.splat) as Splat[])
.filter(splat => splat.visible)
.filter(splat => splat.numSplats - splat.numDeleted > 0);
};

events.function('scene.empty', () => {
Expand Down Expand Up @@ -359,20 +361,26 @@ const initFileHandler = (scene: Scene, events: Events, dropTarget: HTMLElement,

const writeScene = async (type: ExportType, writeFunc: WriteFunc) => {
const splats = getSplats();
const events = splats[0].scene.events;

const options = {
splats: splats,
maxSHBands: events.invoke('view.bands')
};

switch (type) {
case 'ply':
await serializePly(splats, writeFunc);
await serializePly(options, writeFunc);
break;
case 'compressed-ply':
await serializePlyCompressed(splats, writeFunc);
return;
await serializePlyCompressed(options, writeFunc);
break;
case 'splat':
await serializeSplat(splats, writeFunc);
return;
await serializeSplat(options, writeFunc);
break;
case 'viewer':
await serializeViewer(splats, writeFunc);

await serializeViewer(options, writeFunc);
break;
}
};

Expand Down
Loading

0 comments on commit 0dcc6be

Please sign in to comment.