cesium-native icon indicating copy to clipboard operation
cesium-native copied to clipboard

Support for 3D Tiles Styling language

Open azrogers opened this issue 6 months ago • 3 comments

One issue we're running into with vector rasterization is that styling loaded GeoJSON documents is done by manipulating the style properties on the document itself. This works great from C++ and is just about as performant as can be, but really falters when it comes to Unreal - trying to run an Unreal Blueprint that iterates over thousands or tens of thousands or hundreds of thousands of GeoJSON objects results in a noticeable freeze when the document is loaded (on the order of several seconds for a modest dataset like the Philadelphia Streets dataset).

It would be nice if we could implement the 3D Tiles Styling language as used in CesiumJS for this purpose. The upside here would be that this is already a tested and capable solution for the problem we're facing, and would give users pretty much all the tools they need to style a GeoJSON document.

The downside is that it requires a JavaScript interpreter.

Now, the 3D Tiles Styling language only uses a very constrained set of JavaScript features, so we don't need to bring in the entire kitchen sink to implement it. And that's very good news, as v8 would add something like 35MB to our binary size for a feature most users wouldn't need. Implementing our own interpreter for the language isn't beyond the pale of possibility, but it would be a significant amount of work.

Luckily, there are plenty of projects out there trying to run JavaScript in very limited environments - particularly in embedded environments, where even 1MB would be considered a gigantic binary.

Some interesting possibilities I've found:

Both of these libraries are meant to run with less than 200KB of flash memory, and both seem to support regex which is necessary for 3D Tiles Styling language support.

azrogers avatar Jun 30 '25 20:06 azrogers

I think that there's a lot of potential for duktape in this role. Before I started at Cesium, I submitted an Ecosystems grant to implement the styling language in Cesium Native by embedding duktape to interpret the styling commands.

timoore avatar Jun 30 '25 21:06 timoore

I would also request this for regular geometry too (do we want to open a seperate issue or just use this one)?

I'm increasingly working with metadata from sources such as iTwin's, there are plenty of use cases where we want to highlight or hide certain aspects of a tileset based on metadata.

To some extent this can be done via CesiumFeaturesMetadata component but it is kind of clunky to use in comparison to styling in JS.

It also has a substantial limitation of only working with shader compatible data like floats. Metadata often features many strings or other data types, so it is not uncommon to setup styling with filters such as ${name} === 'Crown Entertainment Complex' as shown here

r-veenstra avatar Sep 09 '25 23:09 r-veenstra

@r-veenstra That's a good suggestion! I think it makes sense to just rename this issue instead of opening up a new one, which I've just done.

azrogers avatar Sep 10 '25 13:09 azrogers