Add dashed line support to BufferPolylineMaterial - #1
Open
DanielLeone wants to merge 1 commit into
Open
Conversation
Four new material properties - gapColor, dashRepeat, dashOffset and dashPattern - packed into 12 more bytes of the material layout (gap colour as U32, repeat and offset as U8 each, the pattern as U16) and carried to the shaders in a new dashParams vec4 vertex attribute. The pattern is a 16-bit on/off bitmask sampled within each cycle: 1 draws colour, 0 draws gapColor, and the default 0xFFFF is fully solid, so existing polylines are unaffected. A transparent gapColor discards, so gaps read as empty space. Dashes are anchored to the geometry rather than to the screen: the fragment shader walks the pattern along texCoord (0..1 down the line) instead of gl_FragCoord, so bands stay put on the line as the camera pans and scale with it as it zooms. dashOffset phase-shifts the pattern within a cycle, stored in 256ths so a quarter turn round-trips exactly. FTP-16167. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Adds dashes to
BufferPolylineMaterial. Ticket:FTP-16167. Targets this fork's
main—not proposed upstream.
The API
gapColorColor.TRANSPARENTdashRepeat1dashOffset0dashPattern65535(0xFFFF)Defaults are fully solid, so existing polylines are untouched.
How it works
The material layout grows 12 bytes (
GAP_COLOR_U32,DASH_REPEAT_U8,DASH_OFFSET_U8,DASH_PATTERN_U16) with matchingpack/unpack, and the valuesreach the shaders through a new
dashParamsvec4 vertex attribute carrying(encodedGapColorRGB8, gapAlpha, dashRepeat + dashOffset, dashPattern). The integercycle count and the fractional phase share one float; the shader splits them with
floor()/fract().dashOffsetis stored in 256ths so a quarter turn round-tripsexactly.
The fragment shader walks the pattern along
texCoord(0..1 down the line) ratherthan
gl_FragCoord, so dashes are anchored to the geometry: bands stay put onthe line as the camera pans, and scale with the line as it zooms, instead of
crawling in screen space. That's the main design choice here and it's the opposite
of upstream's
PolylineDashMaterialProperty, which is sized in screen pixels.Checked
tsc(the material file is// @ts-check) via the repo hookswireless-manager-front-endbuilds and bundles clean with this branch linked in(
bun run build, exit 0, no new warnings)Not checked yet
worth measuring before this goes near a customer site
Note on consuming it
Only
mainpublishes to our registry, so the front-end can't pick this up as@ftpsolutions/cesium@…until it merges. Until then, usebun run cesium:linkinthe front-end against this branch.
🤖 Generated with Claude Code