Implementation for BENTLEY_materials_line_style#8856
Implementation for BENTLEY_materials_line_style#8856danielzhong wants to merge 30 commits intomasterfrom
Conversation
|
This pull request is now in conflicts. Could you fix it @danielzhong? 🙏 |
There was a problem hiding this comment.
Pull request overview
This PR implements support for the proposed BENTLEY_materials_line_style glTF extension, enabling iTwin.js to render line primitives with custom widths and patterns from glTF materials. The implementation introduces a dynamic line code texture system that can expand beyond the original 10 predefined patterns to accommodate custom patterns defined in glTF files.
Key changes:
- Added glTF schema and parser support for the
BENTLEY_materials_line_styleextension withwidthandpatternproperties - Refactored the line code system from static 10-pattern texture to dynamic pattern registration supporting up to 256 patterns
- Implemented automatic texture reloading when new patterns are registered at runtime
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
core/frontend/src/tile/GltfReader.ts |
Adds parsing logic for the line style extension, mapping glTF patterns to LinePixels codes and applying them to DisplayParams |
core/frontend/src/test/render/webgl/LineCode.test.ts |
Updates test expectation to reflect dynamic pattern assignment instead of fallback to solid |
core/frontend/src/internal/render/webgl/glsl/Polyline.ts |
Updates shader code to use dynamic capacity constant instead of hardcoded texture height |
core/frontend/src/internal/render/webgl/Texture.ts |
Exports Texture2DCreateParams class to enable texture reloading from System |
core/frontend/src/internal/render/webgl/System.ts |
Implements texture reload mechanism with event listener for dynamic pattern updates |
core/frontend/src/internal/render/webgl/LineCode.ts |
Replaces static pattern data with dynamic texture generation using shared pattern registry |
core/frontend/src/common/internal/render/LineCode.ts |
Implements core pattern registration system with Map-based lookup and event notification |
core/frontend/src/common/gltf/GltfSchema.ts |
Defines TypeScript interface for the BENTLEY_materials_line_style extension |
|
Do you intend to simultaneously enhance the tileset publisher to output this extension, so you can test both sets of changes against one another? Or will you do that later and submit a new PR for any decoding/rendering issues discovered afterward? |
| } | ||
|
|
||
| const textureSize = 32; | ||
| const maxLineCodeSlots = 256; |
There was a problem hiding this comment.
It's just a random number. Do you have any suggestions for what a reasonable value would be?
There was a problem hiding this comment.
Well the maximum number of possible unique patterns is 65,536, right? And the maximum height of the texture is given by System.maxTextureSize. It will be less than 65,536, but far more than 256 (typically, 16k). So, no more than the max texture size. (You could of course put more than one pattern on each row of the texture to get around that, but realistically you will never need that many).
I prefer to do that later and follow up with a separate PR if any decoding or rendering issues come up. |
|
This pull request is now in conflicts. Could you fix it @danielzhong? 🙏 |
3ab04c3 to
2fc076a
Compare
common/changes/@itwin/core-frontend/daniel-BENTLEY_materials_line_style_2025-12-12-00-01.json
Show resolved
Hide resolved
Seems to mostly work.
First segments look correct, some others are wrong/inconsistent. No creepy-crawly when panning, but when zooming yes.
|
Added a fix for |
|
This pull request is now in conflicts. Could you fix it @danielzhong? 🙏 |
common/changes/@itwin/core-frontend/daniel-BENTLEY_materials_line_style_2025-12-12-00-01.json
Show resolved
Hide resolved
|
|

Fixes #8836
This PR adds support for the proposed
BENTLEY_materials_line_styleglTF extension. The proposed specification can be found here.This PR introduces support for the
BENTLEY_materials_line_style extensionin glTF. iTwin.js can now interpret and render line primitives with their specifiedwidthandpatternproperties when loading glTF files. glTF materials can now specify a line width plus a 16‑bit dash bitfield, and we’ll map it either to one of the legacyLinePixelscodes or dynamically append a fresh pattern to the shared line-code texture (which now auto-expands beyond the original 10 entries and reloads on demand)To test this branch:
dta gltfFind the following section in the material definition:
Then, modify the
widthandpatternvalues as you like.iTwin default line pattern values:
0xFFFF655350x8080328960xF8F8636080xFFE0655040xFE10650400xE0E0575680xF888636240xFF18653040xCCCC524280x00011More customize example:
0x0F0F385511110000111100000x00FF25511111111000000000xC0034915511000000000000110xF0FE6169411111110000011110xAA554360510101010010101010xAAAA)Display.Test.App.2025-12-11.15-48-20.mp4