@tileflow/core 0.1.0-alpha.34 → 0.1.0-alpha.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +24 -23
  2. package/THIRD_PARTY_NOTICES.md +100 -6
  3. package/dist/browser.d.ts +758 -388
  4. package/dist/browser.js +4598 -1169
  5. package/dist/build.d.ts +9 -5
  6. package/dist/build.js +2892 -1410
  7. package/dist/capture.js +1 -0
  8. package/dist/config-reference.json +3780 -2153
  9. package/dist/{icon-composition-DqoZWQuz.d.ts → icon-composition-sN3JkXdb.d.ts} +380 -96
  10. package/dist/index.d.ts +426 -13
  11. package/dist/index.js +4999 -1841
  12. package/dist/{manifest-types-hmzy2bBX.d.ts → manifest-types-jrBdBrES.d.ts} +71 -9
  13. package/dist/manifest.d.ts +2 -2
  14. package/dist/manifest.js +80 -2
  15. package/dist/native-profile.js +1 -0
  16. package/dist/native.d.ts +13 -3
  17. package/dist/native.js +714 -318
  18. package/dist/runtime.d.ts +1 -1
  19. package/dist/runtime.js +124 -6
  20. package/dist/worker/buildings-3d-worker.global.js +1 -0
  21. package/docs/authoring-model.md +12 -3
  22. package/docs/boundary-areas-and-choropleths.md +217 -0
  23. package/docs/buildings-3d.md +264 -34
  24. package/docs/cartographic-defaults.md +142 -0
  25. package/docs/compiled-style-performance.md +14 -3
  26. package/docs/data-is-separate-from-design.md +191 -7
  27. package/docs/hosted-session-authorization.md +2 -4
  28. package/docs/map-and-terrain-examples.md +10 -3
  29. package/docs/native-artifact-profile.md +5 -0
  30. package/docs/native-resource-urls.md +5 -3
  31. package/docs/street-lights.md +22 -6
  32. package/docs/sun-and-light.md +42 -2
  33. package/docs/theme-transitions-and-blends.md +50 -0
  34. package/docs/themes-and-module-styles.md +66 -0
  35. package/docs/trees-3d.md +85 -13
  36. package/package.json +5 -4
package/docs/trees-3d.md CHANGED
@@ -3,7 +3,7 @@
3
3
  `createTileflowTrees3D` stands the trees of a Tileflow map's vector tiles round the camera as 3D
4
4
  trees, lit by the theme controller's sun. Each tree takes the form and the size its data gives:
5
5
  palms, conifers, columns and three broadleaf forms, at their mapped height and crown where the data
6
- has them. Trees cast shadows on the ground and, with `createTileflowBuildings3D`, on the buildings,
6
+ has them. The data's hedges stand beside them as clipped green walls. Trees cast shadows on the ground and, with `createTileflowBuildings3D`, on the buildings,
7
7
  and take the buildings' shadows; nearer buildings hide them.
8
8
 
9
9
  The map describes how its trees look; the renderer only stands them. A map that declares
@@ -12,10 +12,68 @@ style it compiles, for every theme, and the renderer follows theme changes and b
12
12
 
13
13
  It is a custom WebGL2 layer for MapLibre GL JS, drawn above the map's buildings and below its
14
14
  labels. It needs WebGL2 and the Mercator projection, and the trees stand from zoom 15 by default.
15
- Elsewhere (Capture, Static Maps, Native, or a browser without WebGL2) the map draws the vegetation
16
- module's flat trees.
15
+ When model trees are requested, Capture, Static Maps, Native, and browsers without WebGL2 use
16
+ the module's `fallback`: `flat` by default, or `none` to omit trees. Static output uses the 2D view
17
+ for `auto` maps. Streets chooses `none`, so it never substitutes flat crowns
18
+ for its models unless an extension explicitly chooses `flat` or `auto`.
17
19
 
18
- ## Stand the trees
20
+ ## Visibility and representation
21
+
22
+ Use `createTileflowVegetation` for application controls. React, Vue and Svelte mount it automatically
23
+ in interactive maps. The map chooses `vegetation.mode` independently of visibility:
24
+
25
+ | Mode | 2D view | 3D view |
26
+ | -------------- | ------------------- | ------------------- |
27
+ | `3d` (default) | Model trees | Model trees |
28
+ | `flat` | Flat crowns/circles | Flat crowns/circles |
29
+ | `auto` | Flat crowns/circles | Model trees |
30
+
31
+ `viewMode` is explicit application state (`2d` by default), not a pitch threshold. Tilting the camera
32
+ does not change representation. Visibility defaults to `vegetation.visible ?? true`; OFF hides every
33
+ representation. Turning trees off releases model buffers and tile readers. Controls apply immediately,
34
+ without a grow/sink animation, and do not change building appearance or lighting.
35
+
36
+ <!-- docs:check -->
37
+
38
+ ```ts
39
+ import {createTileflowVegetation, type TileflowVegetationOptions} from '@tileflow/core/browser';
40
+
41
+ export function mountVegetation(options: TileflowVegetationOptions) {
42
+ const trees = createTileflowVegetation({...options, viewMode: '2d'});
43
+ trees.setVisible(false); // Hide all vegetation, including flat artwork.
44
+ trees.setVisible(undefined); // Restore the map's authored visibility.
45
+ trees.setViewMode('3d'); // Only auto maps change representation.
46
+ return trees; // Call dispose() before removing the map, or let its remove event clean up.
47
+ }
48
+ ```
49
+
50
+ Pass the application's HTTP tile `transformRequest` when it supplies credentials or request headers;
51
+ asynchronous transforms are supported. Use one vegetation controller per map and do not mount a second
52
+ low-level tree renderer alongside it. Style replacement and theme changes retain visibility and view mode.
53
+
54
+ To change an inherited map's policy while preserving its artwork:
55
+
56
+ <!-- docs:check -->
57
+
58
+ ```ts
59
+ import {defineMap, refine} from '@tileflow/core';
60
+ import {streets} from '@tileflow/maps';
61
+
62
+ export default defineMap({
63
+ id: 'adaptive-trees',
64
+ version: 1,
65
+ extends: streets,
66
+ modules: {vegetation: refine({mode: 'auto', fallback: 'flat'})},
67
+ });
68
+ ```
69
+
70
+ Use `refine({visible: false})` for initially hidden vegetation that can be enabled at runtime.
71
+ Use `vegetation: disable()` to remove the module entirely; a runtime toggle cannot restore a module
72
+ that is absent from the compiled map. Browser framework components accept `vegetation={false}` and
73
+ `viewMode="3d"` (Vue: `:vegetation="false"`, `view-mode="3d"`). Image mode uses the compiled static
74
+ fallback and does not apply these interactive controls.
75
+
76
+ ## Animate trees with the low-level renderer
19
77
 
20
78
  This example assumes an existing MapLibre map showing a Tileflow map whose vector source is called
21
79
  `tileflow`, as Tileflow's maps call World, and a theme controller for it:
@@ -42,13 +100,14 @@ a share of their size, from 0 to 1. Each returns a promise that resolves once th
42
100
  newer call takes over from where the trees stand. A browser preference for reduced motion changes at
43
101
  once. `dispose()` takes the layer off the map.
44
102
 
45
- While they stand, the 3D trees stand in for the map's flat trees: the layers the vegetation module
103
+ This low-level API retains its flat-layer restoration behavior; use the vegetation controller for
104
+ a visibility toggle. While they stand, the 3D trees stand in for the map's flat trees: the layers the vegetation module
46
105
  draws them with are hidden when the trees are shown, and come back as they were once the trees have
47
106
  sunk or the layer leaves the map.
48
107
 
49
108
  `stats.declared` tells whether the map's style describes 3D trees. When it is false the layer draws
50
109
  nothing: declare `vegetation({mode: '3d'})` in the map. `stats` also counts the tiles, the trees
51
- placed and the trees drawn in the last frame.
110
+ placed, the pieces of hedge placed and the trees drawn in the last frame.
52
111
 
53
112
  ## What the trees come from
54
113
 
@@ -61,6 +120,10 @@ The renderer reads the source's z15 tiles round the camera:
61
120
  - World's `canopy` layer, where the data has it: decorative points in urban parks and gardens, each
62
121
  standing one to three trees by its canopy cover, inside the room it leaves before a path, a
63
122
  building or the park's edge. They stand for measured canopy, not for mapped trees.
123
+ - World's `traffic_control` layer: its hedges (`subclass` `hedge`), the lines OpenStreetMap maps and
124
+ the hedges it maps as areas. A hedge stands as pieces 1.2 metres apart along each line and round
125
+ each area, 0.8 metres thick, at its `height` or 1.3 metres, a metre higher where `hedge` says
126
+ `hedge_bank`. The style still draws the hedge flat underneath, and fences and walls stay flat.
64
127
 
65
128
  | Form | From the data |
66
129
  | ---------- | ---------------------------------------------------------------------------- |
@@ -80,8 +143,12 @@ tile's buffer belong to the neighbouring tile, so no tree stands twice.
80
143
 
81
144
  Colours come from the theme: `vegetation.tree.bark`, `vegetation.tree.broadleaf.a` to `.d`,
82
145
  `vegetation.tree.conifer.a` to `.c` and `vegetation.tree.palm.a` to `.c`, sunlit, from darkest to
83
- lightest. A crown facing a sunlit sky takes its colour; shade takes the sky's light, as on 3D
84
- buildings. The vegetation module's `threeDimensional` options refine them for one map:
146
+ lightest. Hedges take `hedgeColors`, the two darkest broadleaf colours unless the map gives its own;
147
+ Streets gives its flat hedge's colours, so a hedge keeps its colour as it rises. `hedges: false`
148
+ leaves hedges flat. A crown facing a sunlit sky takes its colour; shade takes the sky's light, as on 3D
149
+ buildings. At night a neutral lift keeps crown tops visible; grey materials stay grey under neutral
150
+ lighting, while coloured scene lighting can tint them. The vegetation module's `threeDimensional`
151
+ options refine them for one map:
85
152
 
86
153
  <!-- docs:check -->
87
154
 
@@ -180,16 +247,20 @@ the same name; omitting `models` inherits them, and `[]` declares none.
180
247
  The light comes from `controller.getSun()`: the theme's sun, mixed during a blend, or the sun an
181
248
  application places by direction or by date and place (see
182
249
  [sun and light](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/sun-and-light.md)).
250
+ Without a controller, trees read the compiled style's sun and light direction, falling back to
251
+ SDK daylight, just as 3D buildings do. This cached light refreshes when the style changes.
183
252
  Leaves take light round their edges and glow a little against a low sun; the underside and the
184
253
  inside of a crown stay darker.
185
254
 
186
255
  Trees and 3D buildings on one map share one shadow map: trees cast shadows on the ground and on the
187
256
  buildings, and stand in the buildings' shade. The flat map darkens under both. Without 3D buildings
188
- the trees darken the map themselves.
257
+ the trees darken the map themselves. The depth pass uses the same visible tree ranks, near/far
258
+ models and distance fade as the colour pass, so hidden trees do not leave full shadows behind.
259
+ Shadow direction stops lowering at 15° above the horizon; the actual scene light keeps its angle.
189
260
 
190
261
  ## Options
191
262
 
192
- `minzoom` (15 by default) and `maxTiles` (25 by default, at most 64) bound where and how far trees
263
+ `minzoom` (15 by default, fading to full coverage at 15.25 like buildings) and `maxTiles` (25 by default, at most 64) bound where and how far trees
193
264
  stand; trees thin out and fade with distance from the map's centre, and near trees take more detail
194
265
  than far ones. `canopySource` names a vector source with canopy points when they are not in the
195
266
  map's World source. `beforeId` places the layer before another one; `transformRequest` applies the
@@ -199,9 +270,10 @@ tile's download.
199
270
  ## Cost
200
271
 
201
272
  A near tree has 60 to 120 triangles and a far one about 20, and each form is one instanced draw per
202
- tile. The shadow map is drawn again only when the sun, the trees on screen or their size change, not
203
- when the camera moves. Over the Champ de Mars in Paris, where OpenStreetMap maps every tree, about
204
- 13,000 trees stand in a pitched view at zoom 16.6.
273
+ tile. The shared shadow map concentrates resolution on the view when its public camera methods
274
+ provide a safe planar fit. It is drawn again when that focused area, the light, visible tree
275
+ selection, fading or geometry changes. Unchanged views reuse it. Over the Champ de Mars in Paris,
276
+ where OpenStreetMap maps every tree, about 13,000 trees stand in a pitched view at zoom 16.6.
205
277
 
206
278
  ## Limits
207
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/core",
3
- "version": "0.1.0-alpha.34",
3
+ "version": "0.1.0-alpha.36",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Typed Tileflow config and MapLibre style compiler.",
6
6
  "type": "module",
@@ -84,12 +84,13 @@
84
84
  "@mapbox/vector-tile": "3.0.0",
85
85
  "earcut": "3.2.4",
86
86
  "maplibre-contour": "0.1.0",
87
+ "meshoptimizer": "1.3.0",
87
88
  "pbf": "5.1.2",
88
- "pmtiles": "4.4.0",
89
- "whatwg-url": "15.1.0"
89
+ "pmtiles": "4.5.0",
90
+ "whatwg-url": "17.2.0"
90
91
  },
91
92
  "scripts": {
92
- "build": "tsup --config tsup.build.config.ts && tsup --config tsup.native-profile.config.ts && tsup src/browser.ts --format esm --dts --no-splitting --platform browser && tsup --config tsup.native.config.ts && cp ../../docs/modules-api-reference.json dist/config-reference.json",
93
+ "build": "tsup --config tsup.build.config.ts && tsup --config tsup.native-profile.config.ts && tsup --config tsup.browser.config.ts && tsup --config tsup.native.config.ts && cp ../../docs/modules-api-reference.json dist/config-reference.json",
93
94
  "reference:check": "tsx scripts/generate-config-reference.ts --check",
94
95
  "reference:generate": "tsx scripts/generate-config-reference.ts --write",
95
96
  "verify": "pnpm run build && tsx --test test/*.test.ts",