Skip to content

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

Merged
brentyi merged 1 commit into
mainfrom
line-close-camera-fix
Jul 29, 2026
Merged

Fix close-camera line rendering for drei-based lines under reversed depth#750
brentyi merged 1 commit into
mainfrom
line-close-camera-fix

Conversation

@brentyi

@brentyi brentyi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Extends the reversed-depth trimSegment fix from #720 to all three-stdlib LineMaterial instances, including the ones drei creates for camera frustums, splines, and gizmos, so lines no longer vanish or smear when they pass close to the camera.

…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.
@brentyi
brentyi merged commit 88e68cd into main Jul 29, 2026
23 checks passed
@brentyi
brentyi deleted the line-close-camera-fix branch July 29, 2026 02:52
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