Skip to content

Feat/ogc3dtiles style pre sky#2722

Open
ymoisan wants to merge 3 commits intoiTowns:masterfrom
ymoisan:feat/ogc3dtiles-style-pre-sky
Open

Feat/ogc3dtiles style pre sky#2722
ymoisan wants to merge 3 commits intoiTowns:masterfrom
ymoisan:feat/ogc3dtiles-style-pre-sky

Conversation

@ymoisan
Copy link
Copy Markdown

@ymoisan ymoisan commented Mar 18, 2026

Note: This branch is based on master prior to the sky/atmosphere rendering merge (66a44d4), which introduced a camera/zoom regression I encountered. The changes in this PR are independent of that feature and should rebase cleanly once the regression is addressed.

Also, you will see in commit messages that code is generated by AI. however, I have made sure I understand the code and I have deliberately kept the code edits limited in scope to ease the work of reviewers.

PR message generated by AI; lightly modified by me

Description

Add per-feature styling capability to OGC3DTilesLayer, enabling color assignment by feature type (e.g. Building, SolitaryVegetationObject). The original intent was to provide interactive visual rendering for 3DTiles 1.1 but 3D Tiles 1.0 behavior should be preserved.

New functionality in OGC3DTilesLayer:

  • Detect feature IDs from _FEATURE_ID_0 (3D Tiles 1.1) with _batchid (1.0) fallback
  • Handle both indexed and non-indexed geometries when building feature groups
  • Populate per-feature metadata from EXT_structural_metadata property tables into C3DTFeature.userData
  • Support dynamic style application and removal via layer.style setter, with material caching
  • Cache and restore original materials when style is toggled off
  • Clean up tile features on dispose-model events

Bug fix in optimizeGeometryGroups (ThreeUtils.js):

  • Only merge geometry groups that are contiguous in vertex space. Previously, groups sharing a materialIndex were merged unconditionally, which produced wrong vertex ranges when features of the same type interleave in the buffer (e.g. Building, Vegetation, Building).

Tests:

  • 7 new unit tests covering feature init (1.1 + 1.0 fallback), indexed geometry, style apply, style restore, cleanup, and picking

Examples:

  • New 3DTiles-11-styling.html: interactive per-type color picker for any tileset URL
  • Updated OGC3DTilesHelper.js

Motivation and Context

There was no built-in way to style individual features in OGC3DTilesLayer by semantic type. Users working with CityGML-derived 3D Tiles (Buildings, Vegetation, etc.) had no API to assign colors per feature category.

This change brings OGC3DTilesLayer closer to the per-feature styling capabilities already present in the vector layer pipeline, and makes the 3D Tiles 1.1 EXT_structural_metadata / EXT_mesh_features extensions usable for styling.

Tested on Chrome 134 / Windows 11 (WSL2) with 3D Tiles 1.1 tilesets containing EXT_structural_metadata.

Screenshots

screenshot of 3DTiles-11-styling.html showing color pickers and styled features.
pr-screenshot

ymoisan and others added 3 commits March 17, 2026 13:24
Add per-feature styling capability to OGC3DTilesLayer, enabling color
assignment by feature type (e.g. Building, SolitaryVegetationObject).

- Detect feature IDs from _FEATURE_ID_0 (3D Tiles 1.1) with _batchid
  (1.0) fallback
- Handle both indexed and non-indexed geometries when building feature
  groups
- Support dynamic style application and removal via layer.style setter
- Cache and restore original materials when style is toggled
- Clean up tile features on dispose-model events
- Add unit tests for feature init, styling, restore, cleanup, and picking
- Add 3DTiles-11-styling.html example for interactive feature color picking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix optimizeGeometryGroups to only merge contiguous groups, preventing
  wrong vertex ranges when features of the same type interleave
- Remove incorrect eslint-disable on used Style import
- Use separator in material cache key to avoid ambiguous concatenation
- Early return in style setter when clearing style (null)
- Hoist rebuildTimer to module scope and clear on layer removal
- Replace silent catch blocks with console.warn in example
- Add indexed-geometry unit test for _initFeatures
- Update 3dtiles_loader and OGC3DTilesHelper examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jailln jailln requested a review from Desplandis March 24, 2026 09:45
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