Skip to content

viewer: expose depth snapshot channel - #646

Open
thomas-yanxin wants to merge 1 commit into
pascalorg:mainfrom
thomas-yanxin:codex/expose-depth-snapshot-channel
Open

viewer: expose depth snapshot channel#646
thomas-yanxin wants to merge 1 commit into
pascalorg:mainfrom
thomas-yanxin:codex/expose-depth-snapshot-channel

Conversation

@thomas-yanxin

@thomas-yanxin thomas-yanxin commented Aug 14, 2026

Copy link
Copy Markdown

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

  1. From packages/viewer, run bun run build.
  2. From packages/viewer, run bun run test and confirm all 102 tests pass.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant