@tileflow/core 0.1.0-alpha.42 → 0.1.0-alpha.44

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 (50) hide show
  1. package/README.md +56 -69
  2. package/THIRD_PARTY_NOTICES.md +3 -3
  3. package/dist/{3d-CzLTD0RK.d.ts → 3d-CW5Ls0An.d.ts} +32 -2
  4. package/dist/3d.d.ts +1 -1
  5. package/dist/3d.js +425 -50
  6. package/dist/browser.d.ts +95 -5
  7. package/dist/browser.js +866 -101
  8. package/dist/build.d.ts +8 -4
  9. package/dist/build.js +250 -3
  10. package/dist/config-reference.json +3395 -2140
  11. package/dist/{icon-composition-B1A2udKb.d.ts → icon-composition-Bbw9umUA.d.ts} +37 -2
  12. package/dist/index.d.ts +13 -4
  13. package/dist/index.js +193 -3
  14. package/dist/{manifest-types-B0lQjabX.d.ts → manifest-types-CwjHd4qc.d.ts} +8 -0
  15. package/dist/manifest.d.ts +2 -2
  16. package/dist/native-profile.d.ts +4 -0
  17. package/dist/native-profile.js +2 -0
  18. package/dist/native.js +789 -462
  19. package/dist/runtime.d.ts +1 -1
  20. package/dist/worker/camera-tile-worker.global.js +2 -2
  21. package/package.json +5 -6
  22. package/docs/application-tile-reading.md +0 -86
  23. package/docs/authoring-model.md +0 -269
  24. package/docs/boundary-areas-and-choropleths.md +0 -230
  25. package/docs/buildings-3d.md +0 -624
  26. package/docs/camera-moves-and-tile-cache.md +0 -112
  27. package/docs/capture-scenes.md +0 -40
  28. package/docs/capture-shots.md +0 -173
  29. package/docs/cartographic-defaults.md +0 -214
  30. package/docs/compiled-style-performance.md +0 -286
  31. package/docs/data-is-separate-from-design.md +0 -610
  32. package/docs/depth-markers.md +0 -65
  33. package/docs/dynamic-style-images.md +0 -100
  34. package/docs/globe-atmosphere.md +0 -113
  35. package/docs/hosted-session-authorization.md +0 -106
  36. package/docs/map-and-terrain-examples.md +0 -156
  37. package/docs/map-emphasis.md +0 -89
  38. package/docs/native-artifact-profile.md +0 -152
  39. package/docs/native-resource-urls.md +0 -369
  40. package/docs/nautical-marks.md +0 -308
  41. package/docs/public-api-and-browser-subpath.md +0 -101
  42. package/docs/route-drawing.md +0 -191
  43. package/docs/shared-visual-primitives.md +0 -101
  44. package/docs/street-lights.md +0 -127
  45. package/docs/street-sky.md +0 -156
  46. package/docs/style-states.md +0 -73
  47. package/docs/sun-and-light.md +0 -167
  48. package/docs/theme-transitions-and-blends.md +0 -317
  49. package/docs/themes-and-module-styles.md +0 -156
  50. package/docs/trees-3d.md +0 -295
package/docs/trees-3d.md DELETED
@@ -1,295 +0,0 @@
1
- # 3D trees
2
-
3
- `createTileflowTrees3D` stands the trees of a Tileflow map's vector tiles round the camera as 3D
4
- trees, lit by the theme controller's sun. Each tree takes the form and the size its data gives:
5
- palms, conifers, columns and three broadleaf forms, at their mapped height and crown where the data
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
- and take the buildings' shadows; nearer buildings hide them.
8
-
9
- The map describes how its trees look; the renderer only stands them. A map that declares
10
- `vegetation({mode: '3d'})`, as Streets does, publishes its tree colours, scales and forms in the
11
- style it compiles, for every theme, and the renderer follows theme changes and blends.
12
-
13
- It is a custom WebGL2 layer for MapLibre GL JS, drawn above the map's buildings and below its
14
- labels. It needs WebGL2 and the Mercator projection, and the trees stand from zoom 15 by default.
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`.
19
-
20
- ## Visibility and representation
21
-
22
- Use `createTileflowVegetation` for application controls. React, Vue and Svelte mount it automatically
23
- in interactive maps, as part of the map's [3D scene](buildings-3d.md#the-maps-3d-scene). The map
24
- chooses `vegetation.mode` independently of visibility:
25
-
26
- | Mode | 2D view | 3D view |
27
- | -------------- | ------------------- | ------------------- |
28
- | `3d` (default) | Model trees | Model trees |
29
- | `flat` | Flat crowns/circles | Flat crowns/circles |
30
- | `auto` | Flat crowns/circles | Model trees |
31
-
32
- `viewMode` is explicit application state, not a pitch threshold: `2d` by default for
33
- `createTileflowVegetation`, and `3d` by default in the framework components and `createTileflowMap3D`. Tilting the camera
34
- does not change representation. Visibility defaults to `vegetation.visible ?? true`; OFF hides every
35
- representation. Turning trees off releases model buffers and tile readers. Controls apply immediately,
36
- without a grow/sink animation, and do not change building appearance or lighting.
37
-
38
- <!-- docs:check -->
39
-
40
- ```ts
41
- import {createTileflowVegetation, type TileflowVegetationOptions} from '@tileflow/core/browser';
42
-
43
- export function mountVegetation(options: TileflowVegetationOptions) {
44
- const trees = createTileflowVegetation({...options, viewMode: '2d'});
45
- trees.setVisible(false); // Hide all vegetation, including flat artwork.
46
- trees.setVisible(undefined); // Restore the map's authored visibility.
47
- trees.setViewMode('3d'); // Only auto maps change representation.
48
- return trees; // Call dispose() before removing the map, or let its remove event clean up.
49
- }
50
- ```
51
-
52
- Pass the application's HTTP tile `transformRequest` when it supplies credentials or request headers;
53
- asynchronous transforms are supported. Use one vegetation controller per map and do not mount a second
54
- low-level tree renderer alongside it. Style replacement and theme changes retain visibility and view mode.
55
-
56
- To change an inherited map's policy while preserving its artwork:
57
-
58
- <!-- docs:check -->
59
-
60
- ```ts
61
- import {defineMap, refine} from '@tileflow/core';
62
- import {streets} from '@tileflow/maps';
63
-
64
- export default defineMap({
65
- id: 'adaptive-trees',
66
- version: 1,
67
- extends: streets,
68
- modules: {vegetation: refine({mode: 'auto', fallback: 'flat'})},
69
- });
70
- ```
71
-
72
- Use `refine({visible: false})` for initially hidden vegetation that can be enabled at runtime.
73
- Use `vegetation: disable()` to remove the module entirely; a runtime toggle cannot restore a module
74
- that is absent from the compiled map. Browser framework components accept `vegetation={false}` and
75
- `viewMode="2d"` (Vue: `:vegetation="false"`, `view-mode="2d"`). Image mode uses the compiled static
76
- fallback and does not apply these interactive controls.
77
-
78
- ## Animate trees with the low-level renderer
79
-
80
- This example assumes an existing MapLibre map showing a Tileflow map whose vector source is called
81
- `tileflow`, as Tileflow's maps call World, and a theme controller for it:
82
-
83
- <!-- docs:check -->
84
-
85
- ```ts
86
- import {
87
- createTileflowTrees3D,
88
- type TileflowThemeController,
89
- type TileflowTrees3DMap,
90
- } from '@tileflow/core/browser';
91
-
92
- export function standTheTrees(map: TileflowTrees3DMap, controller: TileflowThemeController) {
93
- const trees = createTileflowTrees3D({map, controller});
94
- // The trees grow out of the ground over a second.
95
- void trees.show({transition: {duration: 1000}});
96
- return trees;
97
- }
98
- ```
99
-
100
- `show()` grows the trees, `hide()` sinks them back into the ground, and `grow(scale)` eases them to
101
- a share of their size, from 0 to 1. Each returns a promise that resolves once the motion ends; a
102
- newer call takes over from where the trees stand. A browser preference for reduced motion changes at
103
- once. `dispose()` takes the layer off the map.
104
-
105
- This low-level API retains its flat-layer restoration behavior; use the vegetation controller for
106
- a visibility toggle. While they stand, the 3D trees stand in for the map's flat trees: the layers the vegetation module
107
- draws them with are hidden when the trees are shown, and come back as they were once the trees have
108
- sunk or the layer leaves the map.
109
-
110
- `stats.declared` tells whether the map's style describes 3D trees. When it is false the layer draws
111
- nothing: declare `vegetation({mode: '3d'})` in the map. `stats` also counts the tiles, the trees
112
- placed, the pieces of hedge placed and the trees drawn in the last frame.
113
-
114
- ## What the trees come from
115
-
116
- The renderer reads the source's z15 tiles round the camera:
117
-
118
- - World's `tree` layer: the trees OpenStreetMap maps one by one, as points, and its rows of trees,
119
- as lines, along which a tree stands every 8 metres. A tree's `leaf_type`, `genus`, `species` and
120
- `taxon` choose its form; its `height` and `diameter_crown` its size, and a trunk's
121
- `circumference` sizes a tree with neither. A row's attributes apply to each of its trees.
122
- - World's `canopy` layer, where the data has it: decorative points in urban parks and gardens, each
123
- standing one to three trees by its canopy cover, inside the room it leaves before a path, a
124
- building or the park's edge. They stand for measured canopy, not for mapped trees.
125
- - World's `traffic_control` layer: its hedges (`subclass` `hedge`), the lines OpenStreetMap maps and
126
- the hedges it maps as areas. A hedge stands as pieces 1.2 metres apart along each line and round
127
- each area, 0.8 metres thick, at its `height` or 1.3 metres, a metre higher where `hedge` says
128
- `hedge_bank`. The style still draws the hedge flat underneath, and fences and walls stay flat.
129
-
130
- | Form | From the data |
131
- | ---------- | ---------------------------------------------------------------------------- |
132
- | `palm` | `leaf_type` `palm`, `taxon` `Arecaceae`, or a palm genus such as `Roystonea` |
133
- | `columnar` | the cypress genera `Cupressus`, `Calocedrus` and `Thuja` |
134
- | `conifer` | `leaf_type` `needleleaved`, or a conifer genus such as `Pinus` or `Cedrus` |
135
- | `open` | spreading genera such as `Quercus`, `Olea`, `Ficus` or `Jacaranda` |
136
- | `tall` | upright genera such as `Platanus`, `Populus`, `Ulmus` or `Ginkgo` |
137
- | `round` | rounded genera such as `Acer`, `Tilia`, `Aesculus` or `Prunus` |
138
-
139
- A tree whose data gives no form, and every canopy tree, takes one of the three broadleaf forms; a
140
- tree the data calls broadleaved keeps to them. Each tree's form, size, turn and shade come from a
141
- stable hash of where it stands, so it looks the same at every zoom and on every device. Points in a
142
- tile's buffer belong to the neighbouring tile, so no tree stands twice.
143
-
144
- ## Design the trees in the map
145
-
146
- Colours come from the theme: `vegetation.tree.bark`, `vegetation.tree.broadleaf.a` to `.d`,
147
- `vegetation.tree.conifer.a` to `.c` and `vegetation.tree.palm.a` to `.c`, sunlit, from darkest to
148
- lightest. Hedges take `hedgeColors`, the two darkest broadleaf colours unless the map gives its own;
149
- Streets gives its flat hedge's colours, so a hedge keeps its colour as it rises. `hedges: false`
150
- leaves hedges flat. A crown facing a sunlit sky takes its colour; shade takes the sky's light, as on 3D
151
- buildings. At night a neutral lift keeps crown tops visible; grey materials stay grey under neutral
152
- lighting, while coloured scene lighting can tint them. The vegetation module's `threeDimensional`
153
- options refine them for one map:
154
-
155
- <!-- docs:check -->
156
-
157
- ```ts
158
- import {defineMap, token, vegetation} from '@tileflow/core';
159
- import {streets} from '@tileflow/maps';
160
-
161
- export default defineMap({
162
- id: 'subtropical-city',
163
- name: 'Subtropical city',
164
- version: 1,
165
- extends: streets,
166
- modules: {
167
- vegetation: vegetation({
168
- mode: '3d',
169
- threeDimensional: {
170
- barkColor: token.color('vegetation.tree.bark'),
171
- heightScale: 1.1,
172
- finish: 'toon',
173
- edges: 1,
174
- // Along this coast most trees the data does not describe are palms.
175
- regions: [{bounds: [-81.0, 24.4, -79.8, 26.9], unknownForms: {palm: 3, round: 1, open: 1}}],
176
- },
177
- }),
178
- },
179
- });
180
- ```
181
-
182
- `finish` sets how trees take the light: `faceted` (the default), low-poly facets softened towards a
183
- round crown; `smooth`, round crowns; or `toon`, three bands of light and a crisp shadow, as a drawn
184
- tree has them. `edges` rings each tree with an outline a constant width on screen, from 0 (none,
185
- the default) to 1, in `edgeColor` or the crown's darkest colour deepened; buildings use the same
186
- two words for their outlines.
187
-
188
- `heightScale` and `crownScale` stretch every tree, and `forms` each form on top of them, such as
189
- `forms: {palm: {heightScale: 1.2}}` for taller palms. `unknownForms` sets, as relative weights, the
190
- forms of trees whose data gives none, and `regions` sets them inside `[west, south, east, north]`
191
- bounds in degrees, the first region holding a tree applying. They are a choice of look, not data:
192
- they never change a tree whose data gives its form, and as mapping improves they apply to fewer
193
- trees.
194
-
195
- `minimumHeight` optionally sets a visual height floor in metres (0–20, default 0). It applies after
196
- scaling, enlarging only smaller trees and their crowns proportionally; source measurements stay
197
- unchanged. Hedges retain their measured height and segment length. Color, shadow and outline
198
- passes use the same size. `materialVariation` (0–1, default 0)
199
- adds stable brightness variation between trunks and uses authored lobe shades to vary foliage
200
- within the theme palette. It does not add colors outside that palette.
201
-
202
- ## Your own trees
203
-
204
- A map can draw a form with its own models. Put glTF binaries (`.glb`) in a directory, declare it in
205
- the map's `models`, and name the models a form draws by their file names:
206
-
207
- <!-- docs:check -->
208
-
209
- ```ts
210
- import {defineMap, vegetation} from '@tileflow/core';
211
- import {streets} from '@tileflow/maps';
212
-
213
- export default defineMap({
214
- id: 'palm-coast',
215
- name: 'Palm coast',
216
- version: 1,
217
- extends: streets,
218
- // ./models holds sabal-palm.glb and royal-palm.glb, and sabal-palm.far.glb for far trees.
219
- models: ['./models'],
220
- modules: {
221
- vegetation: vegetation({
222
- mode: '3d',
223
- threeDimensional: {
224
- forms: {palm: {models: ['sabal-palm', 'royal-palm'], heightScale: 1.1}},
225
- },
226
- }),
227
- },
228
- });
229
- ```
230
-
231
- Each tree of the form draws one of its models, one to four, by its stable hash, so a palm keeps its
232
- model wherever it is read. The data still chooses each tree's form and size: a model replaces how a
233
- form looks, not which trees take it.
234
-
235
- How to prepare a model:
236
-
237
- - **Materials name the parts.** Name each material `bark`, `leaves`, `fronds` or `stem` (an
238
- exporter's `.001` suffix is ignored). Each part takes its theme colours, as Core's trees do; the
239
- material's colour and any vertex colours set how light or dark each part of the model is within
240
- them, so the model follows the theme from day to night.
241
- - **The origin is where the trunk meets the ground**, with the tree above it. Tileflow stands the
242
- model as a unit tree: its top is the tree's height, and its widest leaf half its crown.
243
- - **Budgets.** A model has at most 1,000 triangles and 4,096 vertices; `<id>.far.glb`, drawn
244
- beyond the nearest tiles, at most 120 triangles. Without a far model, the form's own far tree
245
- stands in. A map draws at most 16 models.
246
- - **What is read.** Triangles of the default scene with their node transforms; textures,
247
- animations and compressed geometry (Draco or meshopt) are not. Export without compression.
248
-
249
- `tileflow preview` and every build read the models, report a problem with the file and what to
250
- change, and watch the directories. The models travel inside the compiled style, so they need no
251
- files of their own when the map is deployed. A later directory's model replaces an earlier one of
252
- the same name; omitting `models` inherits them, and `[]` declares none.
253
-
254
- ## Light and shadows
255
-
256
- The light comes from `controller.getSun()`: the theme's sun, mixed during a blend, or the sun an
257
- application places by direction or by date and place (see
258
- [sun and light](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/sun-and-light.md)).
259
- Without a controller, trees read the compiled style's sun and light direction, falling back to
260
- SDK daylight, just as 3D buildings do. This cached light refreshes when the style changes.
261
- Leaves take light round their edges and glow a little against a low sun; the underside and the
262
- inside of a crown stay darker.
263
-
264
- Trees and 3D buildings on one map share one shadow map: trees cast shadows on the ground and on the
265
- buildings, and stand in the buildings' shade. The flat map darkens under both. Without 3D buildings
266
- the trees darken the map themselves. The depth pass uses the same visible tree ranks, near/far
267
- models and distance fade as the colour pass, so hidden trees do not leave full shadows behind.
268
- Shadow direction stops lowering at 15° above the horizon; the actual scene light keeps its angle.
269
-
270
- ## Options
271
-
272
- `minzoom` (15 by default, fading to full coverage at 15.25) and `maxTiles` (25 by default, at most 64) bound where and how far trees
273
- stand; trees thin out and fade with distance from the map's centre, and near trees take more detail
274
- than far ones. `canopySource` names a vector source with canopy points when they are not in the
275
- map's World source. `beforeId` places the layer before another one; `transformRequest` applies the
276
- map's request rules to the tiles the layer reads. Layers that read the same source share each
277
- tile's download.
278
-
279
- ## Cost
280
-
281
- A near tree has 60 to 120 triangles and a far one about 20, and each form is one instanced draw per
282
- tile. Trees are placed in the worker the page's 3D layers share, which decodes each tile once for
283
- all of them, nearest tiles first. The shared shadow map concentrates resolution on the view when its public camera methods
284
- provide a safe planar fit. It is drawn again when that focused area, the light, visible tree
285
- selection, fading or geometry changes. Unchanged views reuse it. While the camera moves, the trees'
286
- shadows follow their selection and fading in steps of a sixteenth of a tile, and exactly again once
287
- it stops. Over the Champ de Mars in Paris,
288
- where OpenStreetMap maps every tree, about 13,000 trees stand in a pitched view at zoom 16.6.
289
-
290
- ## Limits
291
-
292
- - Mercator only; the layer draws nothing below its `minzoom`.
293
- - No terrain: trees stand on flat ground.
294
- - No wind or seasons; one form per tree.
295
- - Models replace a form's look; a model per genus or species is not available.