FG-13915: Fix scale-invariant label picking#455
Closed
niels-foxglove wants to merge 1 commit into
Closed
Conversation
Merged
Move the sizeAttenuation=false vertex offset from clip space to view space so that setViewOffset (used by the Picker) works correctly. Multiply by camera distance to maintain constant pixel size. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
niels-foxglove
force-pushed
the
nn4/fg-13915
branch
from
February 13, 2026 19:45
b7705f3 to
13bb97f
Compare
Author
|
I will come back to this. This has been a low priority bug that nobody has reported yet and this PR is a draft because its only an AI generated first attempt. I will create a real PR when I've done a review of the code myself to get a better understanding of what is going on. |
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.
Changelog
Fixed scale-invariant billboard text labels not being pickable in the 3D panel.
Docs
None
Description
Fixes: FG-13915
Problem: Billboard text labels with
scale_invariant=true(sizeAttenuation=falsein three-text) were not clickable in the 3D panel's select mode. The Picker renders objects into a small offscreen target usingcamera.setViewOffset()to zoom into the area around the cursor, then reads back pixel colors to determine what was clicked. ThesizeAttenuation=falsevertex shader path added offsets in clip space (after projection), which produces incorrect positions whensetViewOffsetmodifies the projection matrix.Solution: Move the
sizeAttenuation=falseoffset calculation from clip space to view space (before projection). Multiply by camera distance (-mvPosition.z) to compensate for perspective divide, maintaining constant pixel size. This approach is compatible withsetViewOffsetbecause the projection matrix is applied after the offset.Before (clip-space offset, broken with setViewOffset):
three-text/src/LabelMaterial.ts
Lines 55 to 57 in 59edb17
After (view-space offset, works with setViewOffset):
three-text/src/LabelMaterial.ts
Lines 55 to 60 in b7705f3
Also renamed
uCanvasSizeuniform toresolution(Three.js convention) and changed its type from[0, 0]array toTHREE.Vector2(1, 1)to use.copy()inonBeforeRender.Testing: Verified with a test data server that publishes a 3D scene with both
scale_invariant=trueandscale_invariant=falselabels. Confirmed:Note: This PR should be merged after #448 (WebGPU support) lands, then the app's Picker.ts resolution override (lines 297-302) should also be removed in a follow-up.