maplibre-rs
maplibre-rs copied to clipboard
Expression support
🤔 Expected Behavior
We want some kind of expression support. Though we first need to find out how expressions are used and whether we can find a simpler model.
@kimpham54 is working on getting some numbers.
😯 Current Behavior
Expressions are not supported.
💁 Possible Solution
How does it work in maplibre?
Expressions are always evaluated on the CPU. With evaluation I mean a function of fn evaluate(expression: JSON) -> number | fn interpolate(min: number, max: number: zoom: number) -> number
.
The trick maplibre uses to make expression dependent on the zoom is that they evaluate the returned function on the GPU. That function is only interpolating linearly between two values though.
maplibre does not translate expressions to shader code in any way.
🔦 Context
Here maplibre-gl-js sends the current zoom to the GPU: https://github.com/maplibre/maplibre-gl-js/blob/9d107a5f5651b6adfa49a87419dc7648a57249da/src/data/program_configuration.ts#L313
💻 Examples
None