Adds an optional channel: 'rgb' | 'depth' to SnapshotPipeline.capture, defaulting to the existing RGB behavior.
The depth channel reuses the snapshot pipeline's existing scene pass, render target, crop, GPU readback, and encoder. It emits near geometry as white and far/background pixels as black. Orthographic cameras use the hardware depth attachment directly because Three's current getLinearDepthNode() always applies perspective conversion.
This makes aligned RGB/depth evidence available to viewer consumers without maintaining a second capture implementation.
How to test
From packages/viewer, run bun run build.
From packages/viewer, run bun run test and confirm all 102 tests pass.
Run bunx biome check packages/viewer/src/lib/snapshot-pipeline.ts packages/viewer/src/lib/snapshot-pipeline.test.ts packages/viewer/src/index.ts from the repository root.
Screenshots / screen recording
Not applicable: this adds a capture API channel and does not change the live viewer UI.
Checklist
I've tested this locally with the viewer build and full viewer test suite
My code follows the existing code style
I've documented the depth encoding on the public capture-channel type
This PR targets the main branch
Note
Low Risk
Additive API with default RGB behavior unchanged; depth path is isolated but touches the shared snapshot render/dispose flow.
Overview
Adds an optional channel: 'rgb' | 'depth' argument to SnapshotPipeline.capture (default 'rgb'), so consumers can request aligned depth evidence through the same render target, crop modes, and WebP readback path as existing snapshots.
For 'depth', a dedicated TSL pipeline outputs inverted depth (near white, far/background black) with color transforms disabled. snapshotCameraDepthNode picks raw depth for orthographic cameras and linear depth for perspective, avoiding Three’s perspective-only getLinearDepthNode() on ortho shots. The public SnapshotCaptureChannel type documents the encoding; snapshotCameraDepthNode is covered by a small unit test.
Reviewed by Cursor Bugbot for commit 3671362. Bugbot is set up for automated code reviews on this repo. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds an optional channel: 'rgb' | 'depth' to SnapshotPipeline.capture, defaulting to the existing RGB behavior.
The depth channel reuses the snapshot pipeline's existing scene pass, render target, crop, GPU readback, and encoder. It emits near geometry as white and far/background pixels as black. Orthographic cameras use the hardware depth attachment directly because Three's current getLinearDepthNode() always applies perspective conversion.
This makes aligned RGB/depth evidence available to viewer consumers without maintaining a second capture implementation.
How to test
Screenshots / screen recording
Not applicable: this adds a capture API channel and does not change the live viewer UI.
Checklist
Note
Low Risk
Additive API with default RGB behavior unchanged; depth path is isolated but touches the shared snapshot render/dispose flow.
Overview
Adds an optional channel: 'rgb' | 'depth' argument to SnapshotPipeline.capture (default 'rgb'), so consumers can request aligned depth evidence through the same render target, crop modes, and WebP readback path as existing snapshots.
For 'depth', a dedicated TSL pipeline outputs inverted depth (near white, far/background black) with color transforms disabled. snapshotCameraDepthNode picks raw depth for orthographic cameras and linear depth for perspective, avoiding Three’s perspective-only getLinearDepthNode() on ortho shots. The public SnapshotCaptureChannel type documents the encoding; snapshotCameraDepthNode is covered by a small unit test.
Reviewed by Cursor Bugbot for commit 3671362. Bugbot is set up for automated code reviews on this repo. Configure here.