Skip to content

Dynamic style update for feature meshes#2648

Open
Neptilo wants to merge 24 commits intoiTowns:masterfrom
Neptilo:dynamic-style-update
Open

Dynamic style update for feature meshes#2648
Neptilo wants to merge 24 commits intoiTowns:masterfrom
Neptilo:dynamic-style-update

Conversation

@Neptilo
Copy link
Contributor

@Neptilo Neptilo commented Dec 4, 2025

Addresses #2649

Description

Enables dynamic style updates for feature meshes. Refactors buffer logic into reusable functions and adds style versioning to track property changes.

Motivation and Context

Allows real-time style updates (colors, heights) without rebuilding meshes, improving performance for interactive applications.

@jailln jailln marked this pull request as draft December 9, 2025 09:06
@jailln jailln requested a review from ftoromanoff December 9, 2025 09:06
@Neptilo Neptilo force-pushed the dynamic-style-update branch from aa1cd66 to f0d148e Compare December 11, 2025 16:22
@Neptilo Neptilo marked this pull request as ready for review December 11, 2025 16:45
@ftoromanoff
Copy link
Contributor

Thanks for the PR !

Would it be possible to add unit tests for the new behavior that you add here ? (Mostly for Feature2Mesh.js)
image

And maybe an example where we can play with this ?

@mgermerie mgermerie self-requested a review January 5, 2026 10:47
@mgermerie mgermerie self-assigned this Jan 5, 2026
@Neptilo Neptilo force-pushed the dynamic-style-update branch from bf18706 to 3feb58c Compare January 16, 2026 09:00
@Neptilo
Copy link
Contributor Author

Neptilo commented Jan 16, 2026

@ftoromanoff @mgermerie PR ready again

@jailln
Copy link
Contributor

jailln commented Jan 29, 2026

ping @ftoromanoff @mgermerie

@ftoromanoff
Copy link
Contributor

I don't know if it's linked with that PR, but when I play with the Layer WFS Building' opacity and that I tilt the view I get some strange results:
image
(This doesn't seem to appear in ortho view)

Copy link
Contributor

@mgermerie mgermerie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and nice idea for the style properties versioning implementation!

A few comments on the code other than which there is an issue with line altitude: it seems you have an accidental increment somewhere, making each line appear higher than the previous one. You can see this behavior on this screenshot:

Image

Comment on lines 196 to 199
getGeometry() {
return this.#geometry;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a proper get geometry would be more alike what's done with properties getter. I know setters are not defined as so but we can try at least to have coherence in our getters.

* @param {number} buffers.indexPtr - Current write position in index buffer (incremented by function).
* @param {number} [id] - Batch id value to assign to written vertices when batchIds is provided.
*/
function updateLineBuffers(featureMesh, buffers, id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more code navigability and consistency with your other updates, can you either define this method right after featureToLine or define all other update{shape}Buffer methods here along side this one ?

up.set(0, 0, 1).multiply(inverseScale);

const pointMaterialSize = [];
context.setFeature(feature);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You re-call this inside the updatePointBuffer method. I get the need of it inside updatePointBuffer method (which can be called by updateStyle) but it thus should be removed from here. Same goes for context.setGeometry on line 205 and in other feature type methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. For context.setGeometry, I don't see the redundancy. All the update*Buffers seem to access context.geometry and therefore need the geometry to be defined before.

@mgermerie
Copy link
Contributor

I don't know if it's linked with that PR, but when I play with the Layer WFS Building' opacity and that I tilt the view I get some strange results: image (This doesn't seem to appear in ortho view)

From my personal testing, I did not have this issue, buildings opacity was correctly computed. I tried on the WFS to 3D objects example, with custom or identical color for each buildings, before and after toggling their extrusion height. Maybe you found this in another test condition @ftoromanoff ?

@Neptilo
Copy link
Contributor Author

Neptilo commented Feb 12, 2026

A few comments on the code other than which there is an issue with line altitude: it seems you have an accidental increment somewhere, making each line appear higher than the previous one.

Found it! I had oversimplified by getting base_altitude before the for loop, but actually, the call to setLocalCoordinatesFromArray inside the loop could modify the context, which was then used in base_altitude's getter.

@Neptilo
Copy link
Contributor Author

Neptilo commented Feb 13, 2026

I don't know if it's linked with that PR, but when I play with the Layer WFS Building' opacity and that I tilt the view I get some strange results

I can´t reproduce either. In the image it looks like the terrain also has transparency.

@Neptilo Neptilo requested a review from mgermerie February 13, 2026 10:32
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.

4 participants