Skip to content

Fix close-camera line rendering for drei-based lines under reversed depth#748

Open
brentyi wants to merge 1 commit into
mainfrom
claude/line-segment-close-camera-kuwyde
Open

Fix close-camera line rendering for drei-based lines under reversed depth#748
brentyi wants to merge 1 commit into
mainfrom
claude/line-segment-close-camera-kuwyde

Conversation

@brentyi

@brentyi brentyi commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Generated by Claude Code

…epth

three-stdlib LineMaterial's trimSegment near-plane estimate assumes a
standard depth projection; under the reversed depth buffer we enable in
App.tsx it evaluates to -far/2 instead of -near, so line segments crossing
the camera plane get extrapolated hundreds of units away and the part of
the line near the camera disappears.

Our own <Line> carried a per-material onBeforeCompile patch for this
(#720), but drei's <Line> -- used by camera frustums, Catmull-Rom / cubic
Bezier splines, and internally by PivotControls -- constructs its own
LineMaterial instances that never got patched.

Replace the per-material patch with a vertexShader accessor on
LineMaterial.prototype that rewrites the near-plane estimate at
construction time for every instance, drei's included. This also stops us
from overwriting three-stdlib's own onBeforeCompile, which manages the
USE_LINE_COLOR_ALPHA define for transparent materials.

Also fixes a PLW0108 lint error (newly stabilized in ruff 0.15) in
test_get_render.py.
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