viewer: expose depth snapshot channel - #646
Open
thomas-yanxin wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'toSnapshotPipeline.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
packages/viewer, runbun run build.packages/viewer, runbun run testand confirm all 102 tests pass.bunx biome check packages/viewer/src/lib/snapshot-pipeline.ts packages/viewer/src/lib/snapshot-pipeline.test.ts packages/viewer/src/index.tsfrom the repository root.Screenshots / screen recording
Not applicable: this adds a capture API channel and does not change the live viewer UI.
Checklist
mainbranchNote
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 toSnapshotPipeline.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.snapshotCameraDepthNodepicks raw depth for orthographic cameras and linear depth for perspective, avoiding Three’s perspective-onlygetLinearDepthNode()on ortho shots. The publicSnapshotCaptureChanneltype documents the encoding;snapshotCameraDepthNodeis 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.