fix(element): cull screen-space text by content bounds#8934
Merged
Conversation
Screen-space elements are culled via isVisibleForCamera, which tested the element's anchored box. Wrapped text can overflow that box, so masked (or off-screen) text whose box fell outside the clip region was culled even when its glyphs were still on screen, rendering as nothing. Cull text against its rendered content bounds instead: expand the box by the horizontal/vertical overflow, distributed according to the text alignment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Build size reportThis PR changes the size of the minified bundles.
|
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.
Fixes #4615.
Screen-space UI elements are frustum-culled via
ElementComponent.isVisibleForCamera, which tested the element's anchored box. A text element's wrapped glyphs can overflow that box, so masked (or off-screen) text whose box fell outside the clip region was culled even though its glyphs were still on screen — the text rendered as nothing at runtime, while still showing in the Editor (edit-mode culling differs).This culls text against its rendered content bounds instead: the box is expanded by the horizontal/vertical overflow (
text.width/height−calculatedWidth/Height), distributed according to the text alignment. Over-estimation is the safe direction — worst case it renders an element that the stencil then clips; it never wrongly culls.The corner-building logic in
screenCornersis extracted into a shared_calcScreenCornershelper used by both paths.Testing
Masked text is not culled when its wrapped content overflows the element box) — fails onmain, passes here.🤖 Generated with Claude Code