isard 1.16.0 → 2.1.0
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.
- package/CHANGELOG.md +80 -0
- package/README.md +5 -5
- package/dist/basemap/vectortiles/placed.js +7 -4
- package/dist/basemap/vectortiles/placed.js.map +1 -1
- package/dist/basemap/vectortiles/tiles.d.ts +1 -1
- package/dist/basemap/vectortiles/tiles.js.map +1 -1
- package/dist/basemap/vectortiles/vectors.d.ts +3 -1
- package/dist/basemap/vectortiles/vectors.js +2 -0
- package/dist/basemap/vectortiles/vectors.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +1 -3
- package/dist/basemap/vectortiles.js +1 -3
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/workerpool.d.ts +1 -1
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/bind/layers.js +2 -2
- package/dist/bind/layers.js.map +1 -1
- package/dist/decoder.worker.js +4 -5
- package/dist/decoder.worker.js.map +6 -6
- package/dist/decoding/decoders.d.ts +1 -1
- package/dist/decoding/decoders.js.map +1 -1
- package/dist/decoding/loader.d.ts +6 -3
- package/dist/decoding/loader.js +7 -5
- package/dist/decoding/loader.js.map +1 -1
- package/dist/decoding/protocol.d.ts +3 -2
- package/dist/decoding/protocol.js.map +1 -1
- package/dist/engine-loader.d.ts +20 -18
- package/dist/engine-loader.js +45 -42
- package/dist/engine-loader.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/isard_tiles3d_bg.wasm +0 -0
- package/dist/isard_webgl2_bg.wasm +0 -0
- package/dist/isard_webgpu_bg.wasm +0 -0
- package/dist/layers/custom.d.ts +35 -29
- package/dist/layers/custom.js +60 -46
- package/dist/layers/custom.js.map +1 -1
- package/dist/layers/extrusions.d.ts +6 -1
- package/dist/layers/extrusions.js +15 -4
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/flow.js.map +1 -1
- package/dist/layers/glyphs.d.ts +1 -1
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/ground.d.ts +21 -14
- package/dist/layers/ground.js +30 -9
- package/dist/layers/ground.js.map +1 -1
- package/dist/layers/icons.d.ts +1 -1
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +1 -2
- package/dist/layers/layers.js +3 -12
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/models.d.ts +7 -1
- package/dist/layers/models.js +19 -5
- package/dist/layers/models.js.map +1 -1
- package/dist/layers/network.d.ts +1 -1
- package/dist/layers/network.js.map +1 -1
- package/dist/layers/panoramas.d.ts +1 -0
- package/dist/layers/panoramas.js +3 -2
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -3
- package/dist/layers/pointclouds.js +3 -7
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/raster.js +5 -0
- package/dist/layers/raster.js.map +1 -1
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/tiles3d.d.ts +5 -7
- package/dist/layers/tiles3d.js +9 -18
- package/dist/layers/tiles3d.js.map +1 -1
- package/dist/layers/vectors.d.ts +10 -5
- package/dist/layers/vectors.js +25 -16
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/engine-settings.d.ts +5 -2
- package/dist/map/engine-settings.js +13 -2
- package/dist/map/engine-settings.js.map +1 -1
- package/dist/map/engines.d.ts +11 -26
- package/dist/map/engines.js +10 -48
- package/dist/map/engines.js.map +1 -1
- package/dist/map/frame-loop.d.ts +1 -3
- package/dist/map/frame-loop.js +3 -3
- package/dist/map/frame-loop.js.map +1 -1
- package/dist/map/hover-pick.d.ts +9 -3
- package/dist/map/hover-pick.js +29 -6
- package/dist/map/hover-pick.js.map +1 -1
- package/dist/map/layer-stack.d.ts +7 -8
- package/dist/map/layer-stack.js +6 -9
- package/dist/map/layer-stack.js.map +1 -1
- package/dist/map/symbol-atlases.d.ts +5 -4
- package/dist/map/symbol-atlases.js +8 -13
- package/dist/map/symbol-atlases.js.map +1 -1
- package/dist/map/viewshed.d.ts +1 -1
- package/dist/map/viewshed.js.map +1 -1
- package/dist/map.d.ts +45 -26
- package/dist/map.js +141 -90
- package/dist/map.js.map +1 -1
- package/dist/react/IsardMap.d.ts +1 -1
- package/dist/react/IsardMap.js.map +1 -1
- package/dist/react/VectorGeometry.d.ts +4 -1
- package/dist/react/VectorGeometry.js +5 -1
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/settings.d.ts +2 -0
- package/dist/settings.js +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +52 -22
- package/dist/types.js.map +1 -1
- package/dist/ui/interaction.d.ts +1 -1
- package/dist/ui/interaction.js.map +1 -1
- package/dist/util/animation.d.ts +1 -1
- package/dist/util/animation.js.map +1 -1
- package/dist/wasm/isard_tiles3d.d.ts +181 -0
- package/dist/wasm/isard_tiles3d.js +387 -0
- package/dist/wasm/{isard_core.d.ts → isard_webgl2.d.ts} +387 -182
- package/dist/wasm/{isard_core.js → isard_webgl2.js} +2087 -324
- package/dist/wasm/{isard.d.ts → isard_webgpu.d.ts} +195 -358
- package/dist/wasm/{isard.js → isard_webgpu.js} +1320 -1042
- package/package.json +4 -3
- package/vite.js +5 -4
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,86 @@ versions [Semantic Versioning](https://semver.org) (before 1.0.0, a minor versio
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [2.1.0] - 2026-10-31
|
|
9
|
+
|
|
10
|
+
With `isard-react-native` and `isard-map` (Python) 2.1.0.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Rasters draped on extrusions and on a vector basemap's buildings: `drape: { raster, faces, opacity }` in
|
|
15
|
+
`addExtrusions`, `vectorTiles().vectors()` and `vectorTiles().extrusions()` (or `setDrape`) lays a raster layer on
|
|
16
|
+
the roofs, or every face, as on 3D Tiles: an ortho on the city, a solar potential on the roofs. In React,
|
|
17
|
+
`<Geometry drape>` and `<Layer type="extrusions" drape>`. The An ortho on the city's roofs example (TypeScript,
|
|
18
|
+
React, Python, React Native).
|
|
19
|
+
- Rasters draped on glTF models: `drape` in `addModels` (or `setDrape`), on the faces looking up or every face, read
|
|
20
|
+
over the instances' footprint; in React, `<Layer type="models" drape>`. The A BIM building example drapes the
|
|
21
|
+
orthophotos on its building by buttons (TypeScript, React, Python, React Native).
|
|
22
|
+
- A GPU memory budget for the map: `memory` (megabytes; `'auto'`, the default, 256 on a touch screen and 1024
|
|
23
|
+
elsewhere) shared by the 3D Tiles' meshes, the point clouds' nodes and the rasters' pools; past it the tiles drawn
|
|
24
|
+
least recently are unloaded, whichever their layer. `map.memory()` says what each layer holds.
|
|
25
|
+
- `bun run port` loads isard from the local build where a page loads it from jsDelivr (the React Native examples), as
|
|
26
|
+
the visual tests do.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `Tiles3dDrape` is `Drape`: the same raster draped on 3D Tiles, extrusions, a basemap's buildings and models.
|
|
31
|
+
- A 3D Tiles layer no longer keeps 512 MB of meshes of its own, nor a point cloud twice its point budget's vertices:
|
|
32
|
+
they share the map's `memory`, as the rasters' pools do.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- The map is made again when its WebGPU device is lost (a phone taking its memory back, a driver reset, the GPU process
|
|
37
|
+
gone), as it was on a WebGL2 context lost: a new device asked for at once, its layers in their order with the same
|
|
38
|
+
handles, custom layers' `onAdd` again. A lost device left the map still.
|
|
39
|
+
|
|
40
|
+
## [2.0.0] - 2026-10-30
|
|
41
|
+
|
|
42
|
+
With `isard-react-native` and `isard-map` (Python) 2.0.0: the three now share their version.
|
|
43
|
+
|
|
44
|
+
The engine on WebGPU (#146), with breaking changes. From 1.x:
|
|
45
|
+
|
|
46
|
+
- `await` the answers of `map.pick` and `map.pickFeature` (a Promise now).
|
|
47
|
+
- Remove the options `tiles3d`, `wasmUrl` and `coreWasmUrl`; give the engine's files, if you serve them yourself, with
|
|
48
|
+
`webgpuWasmUrl` and `webgl2WasmUrl`.
|
|
49
|
+
- Serve the new files (`isard_webgpu_bg.wasm`, `isard_webgl2_bg.wasm`, `isard_tiles3d_bg.wasm`) in place of
|
|
50
|
+
`isard_bg.wasm` and `isard_core_bg.wasm` (`isard/vite` copies them).
|
|
51
|
+
- Rewrite custom layers for WebGPU: `onAdd(device, map)`, `render(device, frame)`, `onRemove(device, map)`, drawing
|
|
52
|
+
into `frame.color` (and `frame.depth`); see the guide's Custom layers page.
|
|
53
|
+
- `map.surfaceAt` may answer undefined at first: the height is measured a frame or two later.
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
|
|
57
|
+
- Profiling: `bun run profile` plays camera moves on a page (an example, or any page using isard) and gives per move the
|
|
58
|
+
frames, the draw calls and state changes a frame, the engine's CPU time and its GPU time, in all and by layer.
|
|
59
|
+
`map.setGpuTiming(true)` and `map.gpuTimings()` time a frame's parts on the GPU with an engine built to profile
|
|
60
|
+
(`PROFILE=1 bun run build`: timer queries, the functions' names kept); the engines published are unchanged.
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
|
|
64
|
+
- The engine on wgpu (#146): the map draws through WebGPU, or through wgpu's WebGL2 fallback where a browser has no
|
|
65
|
+
WebGPU (`isard_webgpu_bg.wasm`, `isard_webgl2_bg.wasm`, the 3D Tiles module `isard_tiles3d_bg.wasm` for the workers),
|
|
66
|
+
in place of the WebGL2 engine (`isard_bg.wasm`, `isard_core_bg.wasm` gone, from the package's files and exports and
|
|
67
|
+
from `isard/vite` too). Its shaders in WGSL; the same layers, passes and picking. Measured on a Mac: as fast or
|
|
68
|
+
faster on every example (a region's network zooming out at 59 fps where the WebGL2 engine did 36).
|
|
69
|
+
- `map.pick` and `map.pickFeature` answer with a Promise, a frame or two later: the picking pass's pixels are read back
|
|
70
|
+
once the GPU is done (WebGPU reads nothing back at once), the main thread no longer waiting for it (#146).
|
|
71
|
+
- One engine, 3D Tiles, models, point clouds and panoramas included from the start, through WebGPU or its WebGL2
|
|
72
|
+
fallback (#146): the map no longer moves onto an engine with 3D Tiles for its first 3D layer. The options
|
|
73
|
+
`tiles3d`, `wasmUrl` and `coreWasmUrl` are gone (`webgpuWasmUrl` and `webgl2WasmUrl` for the engine's files).
|
|
74
|
+
- Custom layers draw with WebGPU (#146): `onAdd(device, map)`, `render(device, frame)` and `onRemove(device, map)` get the
|
|
75
|
+
map's `GPUDevice`; `render` draws into the layer's targets (`frame.color`, and `frame.depth` in the '3d' mode, the
|
|
76
|
+
scene's depth to test against), laid over the frame at the layer's place; `frame.matrixAt` is in WebGPU's clip depth.
|
|
77
|
+
On the WebGL2 fallback, custom layers are not drawn. The three.js example on three's WebGPU renderer.
|
|
78
|
+
- `map.surfaceAt` answers undefined until the position is measured: the scene is drawn looking down at it after a
|
|
79
|
+
frame and read back a frame or two later, the answer kept and measured again every 250 ms at most (#146).
|
|
80
|
+
`map.pickSurface` answers at once from the last copy of the scene's depth, a frame or two old, without waiting for the
|
|
81
|
+
GPU.
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
|
|
85
|
+
- The trees and street furniture placed over a vector basemap are the same whether the relief under the view's center
|
|
86
|
+
came before or after them (chosen from the camera's scale, not the ground's).
|
|
87
|
+
|
|
8
88
|
## [1.16.0] - 2026-10-29
|
|
9
89
|
|
|
10
90
|
With `isard-react-native` 0.5.0 and `isard-map` 0.5.0 (Python).
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
**Maps that recolor at every mouse move.**
|
|
8
8
|
|
|
9
|
-
A
|
|
9
|
+
A WebGPU map engine (WebGL2 where a browser has no WebGPU) for large, interactive data layers, labels and 3D Tiles.<br />
|
|
10
10
|
Rust core in WebAssembly, a small TypeScript API.
|
|
11
11
|
|
|
12
12
|
[](https://www.npmjs.com/package/isard)
|
|
@@ -51,7 +51,7 @@ General-purpose map libraries spend their time on things these maps do not need.
|
|
|
51
51
|
models in 3D Tiles (Draco, meshopt, KTX2).
|
|
52
52
|
- ☁️ **Point clouds.** LiDAR in COPC read by range requests (the IGN's LiDAR HD, reprojected from Lambert-93 onto the
|
|
53
53
|
relief), 3D Tiles points; colored by RGB, class, altitude or intensity, Eye-Dome Lighting, a point budget, picked.
|
|
54
|
-
- 🧊 **Your own 3D.** glTF models at positions, instanced and picked; custom layers for your
|
|
54
|
+
- 🧊 **Your own 3D.** glTF models at positions, instanced and picked; custom layers for your WebGPU code or a three.js
|
|
55
55
|
scene, in the map's frame and depth, with camera-relative matrices exact at any zoom.
|
|
56
56
|
- 🦀 **Small and exact.** 278 KB of WebAssembly gzipped (452 KB once a 3D Tiles layer, a model or a point cloud is added), f64 on the CPU and f32 relative to the camera on the GPU
|
|
57
57
|
(centimetres at any zoom), frames on demand only, strict TypeScript types end to end.
|
|
@@ -126,7 +126,7 @@ Live in the [documentation](https://ideal-adventure-zqn6y6p.pages.github.io/exam
|
|
|
126
126
|
| [glTF models](https://ideal-adventure-zqn6y6p.pages.github.io/layers/models) | `addModels` | a glTF model at many positions, instanced, on the relief, picked |
|
|
127
127
|
| [Point clouds](https://ideal-adventure-zqn6y6p.pages.github.io/layers/pointclouds) | `addPointCloud` | COPC (LiDAR HD) by range requests, pnts and glTF points; by class, altitude, intensity, EDL |
|
|
128
128
|
| [Flows](https://ideal-adventure-zqn6y6p.pages.github.io/layers/flows) | `addFlow`, `readGrids` | particles carried by a wind or a current, a model's hours along a clock, its GRIB2 and NetCDF files read in workers, the wind through a city's streets (`streetWind`) |
|
|
129
|
-
| [Custom layers](https://ideal-adventure-zqn6y6p.pages.github.io/layers/custom) | `addCustomLayer` | your
|
|
129
|
+
| [Custom layers](https://ideal-adventure-zqn6y6p.pages.github.io/layers/custom) | `addCustomLayer` | your WebGPU code or a three.js scene in the map's frame, tested against its depth |
|
|
130
130
|
|
|
131
131
|
Plus markers, popups, controls, picking within a radius, `easeTo`, `flyTo`, a sky and fog for tilted views. All in
|
|
132
132
|
the [API reference](https://ideal-adventure-zqn6y6p.pages.github.io/api).
|
|
@@ -167,7 +167,7 @@ drives both. Each crate has its README; [crates/README.md](crates/README.md) gui
|
|
|
167
167
|
crates/geo/ camera, projections, geodesy and geoid, tile selection, label placement, polygons tested natively
|
|
168
168
|
crates/tiles3d/ 3D Tiles tree, traversal and decoding tested natively
|
|
169
169
|
crates/pointcloud/ COPC point clouds: header, octree hierarchy, traversal, LAZ chunks tested natively
|
|
170
|
-
crates/engine/
|
|
170
|
+
crates/engine-wgpu/ the WebAssembly engine on wgpu (WebGPU, or its WebGL2 fallback): the ground, the layers, picking
|
|
171
171
|
crates/tess/ the tessellation module: vector tiles made ready for the GPU in the basemap workers
|
|
172
172
|
crates/grid/ the grid module: GRIB2 and NetCDF files read into grids, the wind through the streets tested natively
|
|
173
173
|
packages/isard/ the npm package isard: GeoMap, layer handles, overlays, workers
|
|
@@ -186,7 +186,7 @@ More in [Develop and release](https://ideal-adventure-zqn6y6p.pages.github.io/gu
|
|
|
186
186
|
|
|
187
187
|
By priority:
|
|
188
188
|
|
|
189
|
-
- **P1**, next:
|
|
189
|
+
- **P1**, next: the memory budget measured on a phone (a phone closes a page past about a gigabyte).
|
|
190
190
|
- **P2**, then: rasters draped within an area; a clipping volume; a performance report.
|
|
191
191
|
- **P3**, later: objects moving along paths; video in the scene.
|
|
192
192
|
- **P4**, when time allows: the whole MapLibre style drawn as vectors, a 3D vector map to walk through, Panoramax's
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* each kind one instanced model layer: all of them near the ground under the camera, fewer and fewer past it (a
|
|
4
4
|
* simplified model there when the kind has one), the tiles following the view.
|
|
5
5
|
*/
|
|
6
|
-
import { METRES_PER_DEGREE, RAD } from "../../util/geo.js";
|
|
6
|
+
import { EARTH_METRES, METRES_PER_DEGREE, RAD } from "../../util/geo.js";
|
|
7
7
|
import { PLACED_KIND, PLACED_NUMBERS, PLACED_RANK } from "../placed.js";
|
|
8
8
|
import { TileRequests } from "./requests.js";
|
|
9
9
|
import { nearPriority, tileKey, tilesAround } from "./tiles.js";
|
|
@@ -13,10 +13,13 @@ const FOV = 0.6435011087932844;
|
|
|
13
13
|
* zoomed as much): going through the tiles' things at every frame of a drag would hold the main thread */
|
|
14
14
|
const RESEND_SHARE = 0.05;
|
|
15
15
|
/** The ground under the camera: east and north metres from the view's center, and its distance from it (the camera
|
|
16
|
-
* stands behind the center of a tilted view, `FOV` its field of view)
|
|
16
|
+
* stands behind the center of a tilted view, `FOV` its field of view). The camera's own scale at the center (512
|
|
17
|
+
* pixels a tile), not the ground's under it (`metersPerPixel`): the things chosen the same before and after the relief
|
|
18
|
+
* there has come */
|
|
17
19
|
const groundUnderCamera = (map) => {
|
|
18
|
-
const { pitch, bearing } = map.getCamera();
|
|
19
|
-
const
|
|
20
|
+
const { center, zoom, pitch, bearing } = map.getCamera();
|
|
21
|
+
const metresPerPixel = (EARTH_METRES * Math.cos(center[1] * RAD)) / (512 * 2 ** zoom);
|
|
22
|
+
const back = ((0.5 * map.getCanvas().clientHeight) / Math.tan(FOV / 2)) * Math.sin(pitch * RAD) * metresPerPixel;
|
|
20
23
|
return [-back * Math.sin(bearing * RAD), -back * Math.cos(bearing * RAD), back];
|
|
21
24
|
};
|
|
22
25
|
/** What follows the camera as it moves: `send` called again once it has gone `RESEND_SHARE` of `radius` metres (or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placed.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/placed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAA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C,CAAC,EAAE,EAAE;YACb,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QACL,8BAA8B;QAC9B,IAAI,EAAE,CAAC;QACP,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAC/B,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAE3B,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,OAAO;YAC5B,QAAQ,CAAC,GAAG,CACV,CAAC,EACD,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EACnG,CAAC,CAAC,EAAE,EAAE;gBACJ,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAE/B,IAAI,CAAC,MAAM;oBAAE,OAAO;gBACpB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;gBACrB,IAAI,EAAE,CAAC;YACT,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,+GAA+G;IAC/G,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Things placed by the workers in a vector basemap's tiles around the view (trees, street lamps, street furniture),\n * each kind one instanced model layer: all of them near the ground under the camera, fewer and fewer past it (a\n * simplified model there when the kind has one), the tiles following the view.\n */\n\nimport type { Layer } from '../../layers/layers.ts';\nimport type { ModelLayer, ModelOptions } from '../../layers/models.ts';\nimport type { GeoMap } from '../../map.ts';\nimport { METRES_PER_DEGREE, RAD } from '../../util/geo.ts';\nimport type { BasemapResponse, BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { PLACED_KIND, PLACED_NUMBERS, PLACED_RANK } from '../placed.ts';\nimport type { StyleLayer } from '../vectorstyle.ts';\nimport type { VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, tileKey, tilesAround } from './tiles.ts';\n\n/** The engine's vertical field of view (radians, `camera::FOV`): where the camera stands behind the view's center */\nconst FOV = 0.6435011087932844;\n\n/** While the camera moves, the things chosen again once it has gone this share of the near radius (or turned or\n * zoomed as much): going through the tiles' things at every frame of a drag would hold the main thread */\nconst RESEND_SHARE = 0.05;\n\n/** A model: a glTF binary's URL or bytes */\ntype Model = Pick<ModelOptions, 'url' | 'data'>;\n\ninterface PlacedOptions {\n /** A model per kind (`PLACED_KIND`); a kind past them drawn with the first */\n models: [Model, ...Model[]];\n /** Past `near`, the kinds' simplified models (as many), drawn `density` times as densely as the full ones would\n * be, at most `instances` times `maxInstances` */\n far?: { models: Model[]; density: number; instances: number };\n /** The style layers the renderer sends the workers (the tiles' source and its levels) */\n layers: (layer: StyleLayer) => boolean;\n /** The work asked of the worker of a tile (`layers`: the renderer's), and the things in its answer */\n work: (key: string, z: number, x: number, y: number, priority: Priority, layers: StyleLayer[]) => BasemapWork;\n read: (response: BasemapResponse) => Float64Array | undefined;\n /** Metres around the ground under the camera where every one is drawn at a zoom (twice as far a zoom level out) */\n near: [metres: number, zoom: number];\n minZoom: number;\n maxTiles: number;\n /** Things drawn at most, all kinds together (and `far.instances` times as many simplified) */\n maxInstances: number;\n before?: Layer;\n}\n\n/** The ground under the camera: east and north metres from the view's center, and its distance from it (the camera\n * stands behind the center of a tilted view, `FOV` its field of view) */\nconst groundUnderCamera = (map: GeoMap): [east: number, north: number, distance: number] => {\n const { pitch, bearing } = map.getCamera();\n const back =\n ((0.5 * map.getCanvas().clientHeight) / Math.tan(FOV / 2)) * Math.sin(pitch * RAD) * (map.metersPerPixel() ?? 0);\n\n return [-back * Math.sin(bearing * RAD), -back * Math.cos(bearing * RAD), back];\n};\n\n/** What follows the camera as it moves: `send` called again once it has gone `RESEND_SHARE` of `radius` metres (or\n * turned or zoomed as much), not at every frame of a drag */\nconst followWhenMoved = (map: GeoMap, radius: (zoom: number) => number, send: () => void): (() => void) => {\n /** The view of the last call: center (metres), zoom, bearing, pitch */\n let sent: [number, number, number, number, number] | undefined;\n\n return () => {\n const { center, zoom, bearing, pitch } = map.getCamera();\n const [x, y] = [center[0] * METRES_PER_DEGREE * Math.cos(center[1] * RAD), center[1] * METRES_PER_DEGREE];\n\n if (\n sent &&\n Math.hypot(x - sent[0], y - sent[1]) < RESEND_SHARE * radius(zoom) &&\n Math.abs(zoom - sent[2]) < RESEND_SHARE &&\n Math.abs(bearing - sent[3]) < 45 * RESEND_SHARE &&\n Math.abs(pitch - sent[4]) < 45 * RESEND_SHARE\n )\n return;\n sent = [x, y, zoom, bearing, pitch];\n send();\n };\n};\n\n/** The layers of the things placed: one per kind, then one per kind's simplified model; the first holds the others\n * (`Layer.companions`) */\nexport const placed = (context: VectorTilesContext, options: PlacedOptions): [ModelLayer, ...ModelLayer[]] => {\n const { map } = context;\n const { models, far, minZoom, maxTiles, maxInstances } = options;\n const add = (model: Model) =>\n map.addModels({ ...model, instances: [], ...(options.before ? { before: options.before } : {}) });\n const [model, ...more] = models;\n const layers: [ModelLayer, ...ModelLayer[]] = [add(model), ...more.map(add), ...(far?.models ?? []).map(add)];\n const renderer = context.renderer(options.layers, []);\n const radius = (zoom: number) => options.near[0] * 2 ** (options.near[1] - zoom);\n\n renderer.catch(() => undefined);\n layers[0].companions.push(...layers.slice(1));\n context.layers.push(...layers);\n\n const requests = new TileRequests();\n const found = new Map<string, Float64Array>();\n /** The things drawn: all of them near the ground under the camera; past it those of a rank under `density` (near /\n * distance)², simplified; at most `maxInstances` near, `far.instances` times as many past (beyond, the rank kept\n * lowered in proportion: no sort) */\n const send = () => {\n const { center, zoom } = map.getCamera();\n const cos = Math.cos(center[1] * RAD);\n const [ex, ey, back] = groundUnderCamera(map);\n const near = radius(zoom) + back;\n const density = far?.density ?? 1;\n /** Each thing that may be drawn: in full (near, or every one without simplified models) or simplified, with its\n * score (the lowest kept first) */\n const visit = (each: (t: Float64Array, at: number, full: boolean, score: number) => void) => {\n found.forEach((t) => {\n for (let at = 0; at < t.length; at += PLACED_NUMBERS) {\n const dx = ((t[at] ?? 0) - center[0]) * METRES_PER_DEGREE * cos - ex;\n const dy = ((t[at + 1] ?? 0) - center[1]) * METRES_PER_DEGREE - ey;\n const distance = (dx * dx + dy * dy) / (near * near);\n const rank = t[at + PLACED_RANK] ?? 0;\n\n if (distance <= 1) each(t, at, true, rank);\n else if (rank * (distance / density) < 1) each(t, at, !far, rank * (distance / density));\n }\n });\n };\n let [fullCount, farCount] = [0, 0];\n\n visit((_, __, full) => {\n if (full) fullCount += 1;\n else farCount += 1;\n });\n\n const limits = [\n Math.min(1, maxInstances / Math.max(fullCount, 1)),\n Math.min(1, (maxInstances * (far?.instances ?? 1)) / Math.max(farCount, 1)),\n ];\n // The engine's numbers: longitude, latitude, altitude, heading, pitch, roll, scale\n const out: number[][] = layers.map(() => []);\n\n visit((t, at, full, score) => {\n if (score >= (limits[full ? 0 : 1] ?? 1)) return;\n\n const kind = t[at + PLACED_KIND] ?? 0;\n const k = (full ? 0 : models.length) + (kind < models.length ? kind : 0);\n\n out[k]?.push(t[at] ?? 0, t[at + 1] ?? 0, 0, t[at + 3] ?? 0, 0, 0, t[at + 2] ?? 1);\n });\n layers.forEach((layer, k) => {\n layer.setInstanceNumbers(Float64Array.from(out[k] ?? []));\n });\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const { key, maxzoom: z, layers: list } = await renderer;\n const camera = map.getCamera();\n const wanted = camera.zoom < minZoom ? [] : tilesAround(map, camera, z, maxTiles);\n const keys = new Set(wanted.map(([x, y]) => tileKey(z, x, y)));\n\n // Out of view: dropped, or no longer asked for\n requests\n .keys()\n .filter((k) => !keys.has(k))\n .forEach((k) => {\n requests.drop(k);\n found.delete(k);\n });\n // Dense around the new center\n send();\n wanted.forEach(([x, y], index) => {\n const k = tileKey(z, x, y);\n\n if (requests.has(k)) return;\n requests.ask(\n k,\n (signal) => context.request(z, x, y, options.work(key, z, x, y, nearPriority(index), list), signal),\n (r) => {\n const things = options.read(r);\n\n if (!things) return;\n found.set(k, things);\n send();\n },\n );\n });\n };\n\n // While the camera moves, the things drawn follow it (dense near it), chosen again once it has gone far enough\n context.followView(layers[0], update, requests, followWhenMoved(map, radius, send));\n\n return layers;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"placed.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/placed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,qHAAqH;AACrH,MAAM,GAAG,GAAG,kBAAkB,CAAC;AAE/B;0GAC0G;AAC1G,MAAM,YAAY,GAAG,IAAI,CAAC;AAyB1B;;;oBAGoB;AACpB,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAmD,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;IACzD,MAAM,cAAc,GA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AE,CAAC,CAAC,CAAC;YAE3B,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,OAAO;YAC5B,QAAQ,CAAC,GAAG,CACV,CAAC,EACD,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EACnG,CAAC,CAAC,EAAE,EAAE;gBACJ,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAE/B,IAAI,CAAC,MAAM;oBAAE,OAAO;gBACpB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;gBACrB,IAAI,EAAE,CAAC;YACT,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,+GAA+G;IAC/G,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Things placed by the workers in a vector basemap's tiles around the view (trees, street lamps, street furniture),\n * each kind one instanced model layer: all of them near the ground under the camera, fewer and fewer past it (a\n * simplified model there when the kind has one), the tiles following the view.\n */\n\nimport type { Layer } from '../../layers/layers.ts';\nimport type { ModelLayer, ModelOptions } from '../../layers/models.ts';\nimport type { GeoMap } from '../../map.ts';\nimport { EARTH_METRES, METRES_PER_DEGREE, RAD } from '../../util/geo.ts';\nimport type { BasemapResponse, BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { PLACED_KIND, PLACED_NUMBERS, PLACED_RANK } from '../placed.ts';\nimport type { StyleLayer } from '../vectorstyle.ts';\nimport type { VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, tileKey, tilesAround } from './tiles.ts';\n\n/** The engine's vertical field of view (radians, `camera::FOV`): where the camera stands behind the view's center */\nconst FOV = 0.6435011087932844;\n\n/** While the camera moves, the things chosen again once it has gone this share of the near radius (or turned or\n * zoomed as much): going through the tiles' things at every frame of a drag would hold the main thread */\nconst RESEND_SHARE = 0.05;\n\n/** A model: a glTF binary's URL or bytes */\ntype Model = Pick<ModelOptions, 'url' | 'data'>;\n\ninterface PlacedOptions {\n /** A model per kind (`PLACED_KIND`); a kind past them drawn with the first */\n models: [Model, ...Model[]];\n /** Past `near`, the kinds' simplified models (as many), drawn `density` times as densely as the full ones would\n * be, at most `instances` times `maxInstances` */\n far?: { models: Model[]; density: number; instances: number };\n /** The style layers the renderer sends the workers (the tiles' source and its levels) */\n layers: (layer: StyleLayer) => boolean;\n /** The work asked of the worker of a tile (`layers`: the renderer's), and the things in its answer */\n work: (key: string, z: number, x: number, y: number, priority: Priority, layers: StyleLayer[]) => BasemapWork;\n read: (response: BasemapResponse) => Float64Array | undefined;\n /** Metres around the ground under the camera where every one is drawn at a zoom (twice as far a zoom level out) */\n near: [metres: number, zoom: number];\n minZoom: number;\n maxTiles: number;\n /** Things drawn at most, all kinds together (and `far.instances` times as many simplified) */\n maxInstances: number;\n before?: Layer;\n}\n\n/** The ground under the camera: east and north metres from the view's center, and its distance from it (the camera\n * stands behind the center of a tilted view, `FOV` its field of view). The camera's own scale at the center (512\n * pixels a tile), not the ground's under it (`metersPerPixel`): the things chosen the same before and after the relief\n * there has come */\nconst groundUnderCamera = (map: GeoMap): [east: number, north: number, distance: number] => {\n const { center, zoom, pitch, bearing } = map.getCamera();\n const metresPerPixel = (EARTH_METRES * Math.cos(center[1] * RAD)) / (512 * 2 ** zoom);\n const back = ((0.5 * map.getCanvas().clientHeight) / Math.tan(FOV / 2)) * Math.sin(pitch * RAD) * metresPerPixel;\n\n return [-back * Math.sin(bearing * RAD), -back * Math.cos(bearing * RAD), back];\n};\n\n/** What follows the camera as it moves: `send` called again once it has gone `RESEND_SHARE` of `radius` metres (or\n * turned or zoomed as much), not at every frame of a drag */\nconst followWhenMoved = (map: GeoMap, radius: (zoom: number) => number, send: () => void): (() => void) => {\n /** The view of the last call: center (metres), zoom, bearing, pitch */\n let sent: [number, number, number, number, number] | undefined;\n\n return () => {\n const { center, zoom, bearing, pitch } = map.getCamera();\n const [x, y] = [center[0] * METRES_PER_DEGREE * Math.cos(center[1] * RAD), center[1] * METRES_PER_DEGREE];\n\n if (\n sent &&\n Math.hypot(x - sent[0], y - sent[1]) < RESEND_SHARE * radius(zoom) &&\n Math.abs(zoom - sent[2]) < RESEND_SHARE &&\n Math.abs(bearing - sent[3]) < 45 * RESEND_SHARE &&\n Math.abs(pitch - sent[4]) < 45 * RESEND_SHARE\n )\n return;\n sent = [x, y, zoom, bearing, pitch];\n send();\n };\n};\n\n/** The layers of the things placed: one per kind, then one per kind's simplified model; the first holds the others\n * (`Layer.companions`) */\nexport const placed = (context: VectorTilesContext, options: PlacedOptions): [ModelLayer, ...ModelLayer[]] => {\n const { map } = context;\n const { models, far, minZoom, maxTiles, maxInstances } = options;\n const add = (model: Model) =>\n map.addModels({ ...model, instances: [], ...(options.before ? { before: options.before } : {}) });\n const [model, ...more] = models;\n const layers: [ModelLayer, ...ModelLayer[]] = [add(model), ...more.map(add), ...(far?.models ?? []).map(add)];\n const renderer = context.renderer(options.layers, []);\n const radius = (zoom: number) => options.near[0] * 2 ** (options.near[1] - zoom);\n\n renderer.catch(() => undefined);\n layers[0].companions.push(...layers.slice(1));\n context.layers.push(...layers);\n\n const requests = new TileRequests();\n const found = new Map<string, Float64Array>();\n /** The things drawn: all of them near the ground under the camera; past it those of a rank under `density` (near /\n * distance)², simplified; at most `maxInstances` near, `far.instances` times as many past (beyond, the rank kept\n * lowered in proportion: no sort) */\n const send = () => {\n const { center, zoom } = map.getCamera();\n const cos = Math.cos(center[1] * RAD);\n const [ex, ey, back] = groundUnderCamera(map);\n const near = radius(zoom) + back;\n const density = far?.density ?? 1;\n /** Each thing that may be drawn: in full (near, or every one without simplified models) or simplified, with its\n * score (the lowest kept first) */\n const visit = (each: (t: Float64Array, at: number, full: boolean, score: number) => void) => {\n found.forEach((t) => {\n for (let at = 0; at < t.length; at += PLACED_NUMBERS) {\n const dx = ((t[at] ?? 0) - center[0]) * METRES_PER_DEGREE * cos - ex;\n const dy = ((t[at + 1] ?? 0) - center[1]) * METRES_PER_DEGREE - ey;\n const distance = (dx * dx + dy * dy) / (near * near);\n const rank = t[at + PLACED_RANK] ?? 0;\n\n if (distance <= 1) each(t, at, true, rank);\n else if (rank * (distance / density) < 1) each(t, at, !far, rank * (distance / density));\n }\n });\n };\n let [fullCount, farCount] = [0, 0];\n\n visit((_, __, full) => {\n if (full) fullCount += 1;\n else farCount += 1;\n });\n\n const limits = [\n Math.min(1, maxInstances / Math.max(fullCount, 1)),\n Math.min(1, (maxInstances * (far?.instances ?? 1)) / Math.max(farCount, 1)),\n ];\n // The engine's numbers: longitude, latitude, altitude, heading, pitch, roll, scale\n const out: number[][] = layers.map(() => []);\n\n visit((t, at, full, score) => {\n if (score >= (limits[full ? 0 : 1] ?? 1)) return;\n\n const kind = t[at + PLACED_KIND] ?? 0;\n const k = (full ? 0 : models.length) + (kind < models.length ? kind : 0);\n\n out[k]?.push(t[at] ?? 0, t[at + 1] ?? 0, 0, t[at + 3] ?? 0, 0, 0, t[at + 2] ?? 1);\n });\n layers.forEach((layer, k) => {\n layer.setInstanceNumbers(Float64Array.from(out[k] ?? []));\n });\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const { key, maxzoom: z, layers: list } = await renderer;\n const camera = map.getCamera();\n const wanted = camera.zoom < minZoom ? [] : tilesAround(map, camera, z, maxTiles);\n const keys = new Set(wanted.map(([x, y]) => tileKey(z, x, y)));\n\n // Out of view: dropped, or no longer asked for\n requests\n .keys()\n .filter((k) => !keys.has(k))\n .forEach((k) => {\n requests.drop(k);\n found.delete(k);\n });\n // Dense around the new center\n send();\n wanted.forEach(([x, y], index) => {\n const k = tileKey(z, x, y);\n\n if (requests.has(k)) return;\n requests.ask(\n k,\n (signal) => context.request(z, x, y, options.work(key, z, x, y, nearPriority(index), list), signal),\n (r) => {\n const things = options.read(r);\n\n if (!things) return;\n found.set(k, things);\n send();\n },\n );\n });\n };\n\n // While the camera moves, the things drawn follow it (dense near it), chosen again once it has gone far enough\n context.followView(layers[0], update, requests, followWhenMoved(map, radius, send));\n\n return layers;\n};\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* for in, and the defaults the layers share.
|
|
4
4
|
*/
|
|
5
5
|
import type { GeoMap } from '../../map.ts';
|
|
6
|
-
import type { Camera } from '../../wasm/
|
|
6
|
+
import type { Camera } from '../../wasm/isard_webgpu.js';
|
|
7
7
|
import type { Priority } from '../../workers/basemap/protocol.ts';
|
|
8
8
|
/** A tile: its level and its column and row at that level */
|
|
9
9
|
export type TileTriple = [z: number, x: number, y: number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/tiles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOzD,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,wFAAwF;AACxF,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAE5B,wGAAwG;AACxG,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,sFAAsF;AACtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,4BAA4B;AAC5B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI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C,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IAEnH,2EAA2E;IAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxD,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACjB,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEZ,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACxB,CAAC,CAAC","sourcesContent":["/**\n * The tiles of the vector layers (`VectorTiles`): the tiles around the view, their keys, the order they are asked\n * for in, and the defaults the layers share.\n */\n\nimport type { GeoMap } from '../../map.ts';\nimport { mercatorX, mercatorY } from '../../util/geo.ts';\nimport type { Camera } from '../../wasm/
|
|
1
|
+
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/tiles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOzD,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,wFAAwF;AACxF,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAE5B,wGAAwG;AACxG,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,sFAAsF;AACtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,4BAA4B;A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,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IAEnH,2EAA2E;IAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxD,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACjB,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEZ,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACxB,CAAC,CAAC","sourcesContent":["/**\n * The tiles of the vector layers (`VectorTiles`): the tiles around the view, their keys, the order they are asked\n * for in, and the defaults the layers share.\n */\n\nimport type { GeoMap } from '../../map.ts';\nimport { mercatorX, mercatorY } from '../../util/geo.ts';\nimport type { Camera } from '../../wasm/isard_webgpu.js';\nimport type { Priority } from '../../workers/basemap/protocol.ts';\n\n/** A tile: its level and its column and row at that level */\nexport type TileTriple = [z: number, x: number, y: number];\n\n/** Street level: the zoom the extrusions, the streets' wind and the trees start at by default */\nexport const STREET_ZOOM = 15;\n\n/** Tiles of a layer that follows the view, by default (the extrusions', the labels') */\nexport const MAX_TILES = 36;\n\n/** Tiles nearest to the center asked for first: the others wait (for the raster tiles, for instance) */\nconst NEAR_TILES = 4;\n\n/** Milliseconds between two updates of the tiles of a layer while the camera moves */\nexport const VECTOR_MOVE_REFRESH_MS = 250;\n\n/** A tile's key, `z/x/y` */\nexport const tileKey = (z: number, x: number, y: number): string => `${z}/${x}/${y}`;\n\n/** The tile of a key `z/x/y` (zeros for the numbers it lacks) */\nexport const parseTileKey = (key: string): TileTriple => {\n const [z = 0, x = 0, y = 0] = key.split('/').map(Number);\n\n return [z, x, y];\n};\n\n/** The tiles of the engine's flat list of z, x, y triples */\nexport const tileTriples = (list: Uint32Array): TileTriple[] =>\n Array.from(\n { length: Math.floor(list.length / 3) },\n (_, i): TileTriple => [list[i * 3] ?? 0, list[i * 3 + 1] ?? 0, list[i * 3 + 2] ?? 0],\n );\n\n/** The priority of the `index`th tile asked for, the nearest first: `near` for the first `NEAR_TILES`, `far` after */\nexport const nearPriority = (index: number, near: Priority = 'auto', far: Priority = 'low'): Priority =>\n index < NEAR_TILES ? near : far;\n\n/** A tile's column at level `z` brought back into the world (the columns past the antimeridian are those of its other\n * side) */\nexport const wrapColumn = (x: number, z: number): number => {\n const n = 2 ** z;\n\n return ((x % n) + n) % n;\n};\n\n/**\n * The tiles of level `z` in view, within a window around the center (a tilted view's bounds reach far), the\n * `maxTiles` nearest to the center first. Across the antimeridian, the window's columns go on round the world (the\n * view's bounds, which stop at ±180°, no longer limit them)\n */\nexport const tilesAround = (map: GeoMap, camera: Camera, z: number, maxTiles: number): [x: number, y: number][] => {\n const n = 2 ** z;\n const [west, south, east, north] = map.getBounds();\n const tx = (lon: number) => Math.floor(mercatorX(lon) * n);\n const ty = (lat: number) => Math.floor(mercatorY(lat) * n);\n const [cx, cy] = [mercatorX(camera.center[0]) * n, mercatorY(camera.center[1]) * n];\n const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;\n const [left, right] = [Math.floor(cx) - reach, Math.floor(cx) + reach];\n const across = left < 0 || right > n - 1;\n const [x0, x1] = across ? [left, right] : [Math.max(left, tx(west)), Math.min(right, tx(east))];\n const [y0, y1] = [Math.max(0, ty(north), Math.floor(cy) - reach), Math.min(n - 1, ty(south), Math.floor(cy) + reach)];\n const wanted = Array.from({ length: Math.max(0, y1 - y0 + 1) }, (_, j) => y0 + j).flatMap((y) =>\n Array.from({ length: Math.max(0, x1 - x0 + 1) }, (_, i): [number, number] => [x0 + i, y]),\n );\n\n wanted.sort((a, b) => Math.hypot(a[0] + 0.5 - cx, a[1] + 0.5 - cy) - Math.hypot(b[0] + 0.5 - cx, b[1] + 0.5 - cy));\n\n // Each tile once (at a low level, the window can go round the whole world)\n const seen = new Set<string>();\n\n return wanted\n .map(([x, y]): [number, number] => [wrapColumn(x, z), y])\n .filter(([x, y]) => {\n const k = `${x}/${y}`;\n\n if (seen.has(k)) return false;\n seen.add(k);\n\n return true;\n })\n .slice(0, maxTiles);\n};\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Icons } from '../../layers/icons.ts';
|
|
6
6
|
import type { VectorLayer } from '../../layers/vectors.ts';
|
|
7
|
-
import type { Placement, Tiles3dOptions } from '../../types.ts';
|
|
7
|
+
import type { Drape, Placement, Tiles3dOptions } from '../../types.ts';
|
|
8
8
|
import type { RoofMode } from '../../util/roofs.ts';
|
|
9
9
|
import { type Json, type StyleLayer } from '../vectorstyle.ts';
|
|
10
10
|
import type { VectorTilesContext } from './context.ts';
|
|
@@ -31,6 +31,8 @@ export interface VectorsOptions extends Placement {
|
|
|
31
31
|
roofs?: RoofMode;
|
|
32
32
|
/** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */
|
|
33
33
|
facades?: boolean;
|
|
34
|
+
/** A raster layer draped on the buildings' roofs (`setDrape`): an ortho on the city; on the 3D buildings too */
|
|
35
|
+
drape?: Drape | undefined;
|
|
34
36
|
/**
|
|
35
37
|
* 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the
|
|
36
38
|
* IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's
|
|
@@ -91,6 +91,8 @@ export const vectors = (context, options = {}) => {
|
|
|
91
91
|
vector.companions.push(buildings);
|
|
92
92
|
vector.buildings3d = buildings;
|
|
93
93
|
vector.setFacades(facades);
|
|
94
|
+
if (options.drape)
|
|
95
|
+
vector.setDrape(options.drape);
|
|
94
96
|
const state = { renderer: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };
|
|
95
97
|
state.renderer.catch(() => undefined);
|
|
96
98
|
/** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/vectors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAA8B,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/F;;wEAEwE;AACxE,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,6FAA6F;AAC7F,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEpF,wFAAwF;AACxF,MAAM,MAAM,GAAG,CAAC,KAAuB,EAAE,IAAY,EAAW,EAAE,CAChE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,E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AAC;IACF,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;QACvD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,kCAAkC;IAClC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAErC,kHAAkH;IAClH,mBAAmB;IACnB,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * The vector layer of a vector basemap (`VectorTiles.vectors`): its fills, lines and buildings cut by the workers\n * into geometry the engine draws, the tiles following the view, and how its style layers are read for the engine.\n */\n\nimport { tilesetCoverage } from '../../data/tileset.ts';\nimport type { Icons } from '../../layers/icons.ts';\nimport type { VectorLayer, VectorSublayer } from '../../layers/vectors.ts';\nimport type { Placement, Tiles3dOptions } from '../../types.ts';\nimport { latitude, longitude } from '../../util/geo.ts';\nimport type { RoofMode } from '../../util/roofs.ts';\nimport { FLOATS, STYLE } from '../../util/style-floats.ts';\nimport type { BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { evaluate, isExpression, type Json, type StyleLayer, vectorKind, zoomOnly } from '../vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, parseTileKey, type TileTriple, tileKey, tileTriples } from './tiles.ts';\n\n/** The deepest level `vectors()` cuts its tiles at: past the source's deepest level, its tiles cut again into deeper\n * ones (overzoom, as MapLibre does) down to level 18, their styles those of their level, smaller tiles\n * drawn in a closer view; past it, the tiles of that level stretched */\nconst OVERZOOM_LEVEL = 18;\n\n/** The deepest level of the tiles of `vectors()` over a source whose deepest is `maxzoom` */\nconst deepestLevel = (maxzoom: number): number => Math.max(maxzoom, OVERZOOM_LEVEL);\n\n/** A layout or paint value at a zoom, whatever the feature (an expression evaluated) */\nconst atZoom = (value: Json | undefined, zoom: number): unknown =>\n isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\n\n/**\n * A `line-dasharray` as the engine takes it: two dashes and gaps in line widths (an odd count repeated, as the\n * canvas's `setLineDash`; past four, the first four), zeros for a solid line\n */\nexport const dashes = (value: Json | undefined, zoom: number): [number, number, number, number] => {\n const v = atZoom(value, zoom);\n const list = Array.isArray(v) ? v.map(Number).filter((d) => Number.isFinite(d) && d >= 0) : [];\n const even = list.length % 2 === 1 ? [...list, ...list] : list;\n const [a = 0, b = 0, c = 0, d = 0] = even.length >= 2 && even.some((x) => x > 0) ? even : [];\n\n return [a, b, c, d];\n};\n\n/** Whether a style layer draws streets, which glow at night: its id names a road (OpenMapTiles' styles, PLAN IGN's),\n * not its casing, a railway, a path or a tunnel */\nexport const isStreet = (layer: StyleLayer): boolean =>\n /road|highway|street|motorway|trunk|primary|secondary|tertiary|minor|routier/i.test(layer.id) &&\n !/casing|outline|rail|path|track|ferry|tunnel|pier|area|pattern|label/i.test(layer.id);\n\n/** A `line-cap` as the engine draws it, at the camera's zoom (MapLibre's default: butt) */\nconst lineCap = (value: Json | undefined, zoom: number): 'butt' | 'round' | 'square' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'square' ? v : 'butt';\n};\n\n/** A `line-join` as the engine draws it, at the camera's zoom (MapLibre's default: miter) */\nconst lineJoin = (value: Json | undefined, zoom: number): 'miter' | 'bevel' | 'round' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'bevel' ? v : 'miter';\n};\n\n/** A `line-miter-limit` at the camera's zoom (MapLibre's default: 2) */\nconst miterLimit = (value: Json | undefined, zoom: number): number => {\n const v = Number(atZoom(value, zoom) ?? 2);\n\n return Number.isFinite(v) ? v : 2;\n};\n\n/** A tile's styles with their patterns placed: each feature's pattern, as its index past one into `names`\n * (`STYLE.fillPattern`, `STYLE.linePattern`), replaced by its image's place in the icon atlas (texels) and pixel\n * ratio; none if the atlas has no such image; the atlas uploaded */\nexport const placePatterns = (\n styles: Float32Array,\n names: readonly string[] | undefined,\n icons: Icons,\n prefix: string,\n): Float32Array => {\n if (!names?.length) return styles;\n // Thousands of features a tile: a loop\n for (let f = 0; f + FLOATS <= styles.length; f += FLOATS) {\n const fill = styles[f + STYLE.fillPattern] ?? 0;\n const line = styles[f + STYLE.linePattern] ?? 0;\n const index = fill > 0 ? fill : line;\n\n if (index <= 0) continue;\n\n const icon = icons.get(prefix + (names[index - 1] ?? ''));\n const place = icon ? [icon.x, icon.y, icon.width, icon.height] : [0, 0, 0, 0];\n const ratio = icon?.pixelRatio ?? 0;\n\n if (fill > 0) styles.set([...place, ratio], f + STYLE.size + 4);\n else {\n styles.set(place, f + STYLE.second);\n styles[f + STYLE.patternRatio] = ratio;\n }\n }\n icons.flush();\n\n return styles;\n};\n\n/** The paint properties of the patterns `vectors()` draws, whose images come from the style's sprite */\nconst PATTERNS = ['fill-pattern', 'background-pattern', 'line-pattern', 'fill-extrusion-pattern'];\n\n/** A `fill-translate` or `line-translate` at the camera's zoom (CSS pixels; none if it is not two numbers) */\nexport const translation = (value: Json | undefined, zoom: number): [number, number] => {\n const v = atZoom(value, zoom);\n const [x, y] = Array.isArray(v) ? v.map(Number) : [];\n\n return Number.isFinite(x) && Number.isFinite(y) ? [x ?? 0, y ?? 0] : [0, 0];\n};\n\n/** The options of `VectorTiles.vectors` */\nexport interface VectorsOptions extends Placement {\n layers?: (layer: StyleLayer) => boolean;\n streets?: (layer: StyleLayer) => boolean;\n /** The buildings' roofs: from their data (`roof:shape`, `roof:height`; flat without, the default), generated from\n * their outline where they have none (hipped, gabled or mansard by size and shape), or all flat */\n roofs?: RoofMode;\n /** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades?: boolean;\n /**\n * 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the\n * IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's\n * buildings left out where the tileset's children cover (their boxes, read from its `tileset.json`, a child that is\n * a tileset of its own read when a tile meets it), kept elsewhere; their walls' windows with `facades`\n */\n buildings3d?: Tiles3dOptions;\n}\n\nexport const vectors = (context: VectorTilesContext, options: VectorsOptions = {}): VectorLayer => {\n const { map } = context;\n const { layers = () => true, streets = isStreet, before, roofs = 'data', facades = false } = options;\n const vector = map.addVectorLayer(before);\n // The 3D buildings over the layer's ground, and where they stand\n const buildings = options.buildings3d && map.addTiles3d({ ...options.buildings3d, ...(before && { before }) });\n const coverage = options.buildings3d && tilesetCoverage(options.buildings3d.url);\n\n if (buildings) vector.companions.push(buildings);\n vector.buildings3d = buildings;\n vector.setFacades(facades);\n const state: {\n renderer: Promise<Renderer>;\n /** The style layers as the application changed them (`setPaintProperty`…): a copy, its style left as it is */\n own?: StyleLayer[];\n /** Bumped by each update: only the last one drops the tiles out of its view */\n update: number;\n /** Bumped by each restyle: a tile cut under an older style is restyled once it is there */\n style: number;\n } = { renderer: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };\n\n state.renderer.catch(() => undefined);\n\n /** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */\n const sprites = context.ready\n .then(({ style }) =>\n style.layers.some((l) => layers(l) && PATTERNS.some((k) => l.paint?.[k] !== undefined))\n ? context.addSprites()\n : undefined,\n )\n .catch(() => undefined);\n const placed = (styles: Float32Array, names: readonly string[] | undefined) =>\n placePatterns(styles, names, map.icons, context.iconPrefix);\n context.layers.push(vector);\n\n const sublayers = (list: StyleLayer[]): VectorSublayer[] => {\n const zoom = map.getCamera().zoom;\n\n return list.map((l) => ({\n id: l.id,\n sourceLayer: l['source-layer'],\n kind: vectorKind(l) ?? 'fill',\n minZoom: l.minzoom ?? 0,\n maxZoom: l.maxzoom ?? 24,\n visible: l.layout?.visibility !== 'none',\n opacity: zoomOnly(l.paint?.[`${l.type}-opacity`], 1) ?? 1,\n cap: lineCap(l.layout?.['line-cap'], zoom),\n join: lineJoin(l.layout?.['line-join'], zoom),\n miterLimit: miterLimit(l.layout?.['line-miter-limit'], zoom),\n translate: translation(l.paint?.[`${l.type}-translate`], zoom),\n translateAnchor: l.paint?.[`${l.type}-translate-anchor`] === 'viewport' ? 'viewport' : 'map',\n patterned: l.paint?.['fill-pattern'] !== undefined || l.paint?.['background-pattern'] !== undefined,\n lit: l.type === 'line' && streets(l),\n dash: l.type === 'line' ? dashes(l.paint?.['line-dasharray'], zoom) : [0, 0, 0, 0],\n }));\n };\n\n /** The tiles held or asked for, by `z/x/y` */\n const requests = new TileRequests();\n /** A tile's geometry, or its styles alone, asked of the worker of its tile of the source's level (which keeps the\n * decoded tile its deeper tiles are cut from) */\n const ask = async (\n { key, maxzoom }: { key: string; maxzoom: number },\n [z, x, y]: TileTriple,\n styles: boolean,\n priority: Priority,\n signal?: AbortSignal,\n ) => {\n const d = Math.max(0, z - maxzoom);\n // Where the 3D buildings stand over the source's tile the worker cuts (none known: the style's buildings kept)\n const n = 2 ** (z - d);\n const [tx, ty] = [Math.floor(x / 2 ** d), Math.floor(y / 2 ** d)];\n const covered = await coverage\n ?.within([longitude(tx / n), latitude((ty + 1) / n), longitude((tx + 1) / n), latitude(ty / n)])\n .catch(() => undefined);\n const work: BasemapWork = {\n type: 'vectors',\n key,\n z,\n x,\n y,\n deepest: deepestLevel(maxzoom),\n roofs,\n ...(covered?.length ? { covered } : {}),\n priority,\n };\n\n // The geometry made ready for the GPU in the workers, with the prisms the relief needs\n return context.request(\n z - d,\n Math.floor(x / 2 ** d),\n Math.floor(y / 2 ** d),\n styles ? { ...work, styles } : { ...work, prism: map.hasRelief },\n signal,\n );\n };\n\n // The workers tessellate the tiles (the main thread only uploads them), once they know the module\n context.broadcast({ type: 'tess', url: map.tessUrl });\n /** Asks the workers again for the styles of a tile held, under the current style; the tile's geometry stays as it\n * is */\n const restyleTile = async (renderer: { key: string; maxzoom: number }, k: string) => {\n const r = await ask(renderer, parseTileKey(k), true, 'auto').catch(() => undefined);\n\n if (r && 'styles' in r) vector.setTileStyles(k, placed(r.styles, r.patterns));\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const generation = ++state.update;\n // The style the tiles are cut under: that of the renderer awaited, a restyle meanwhile (a paint property set as the\n // style loads) asking their styles again once they are there\n const style = state.style;\n const { key, maxzoom, layers: list } = await state.renderer;\n\n await sprites;\n\n vector.setSublayers(sublayers(state.own ?? list));\n\n const wanted = tileTriples(map.engine.vectorTilesInView(0, deepestLevel(maxzoom), map.quality.reach));\n const keys = new Set(wanted.map((t) => tileKey(...t)));\n const loads = wanted.flatMap((t, index) => {\n const k = tileKey(...t);\n\n if (requests.has(k)) return [];\n\n return [\n requests.ask(\n k,\n (signal) => ask({ key, maxzoom }, t, false, nearPriority(index, 'high', 'auto'), signal),\n async (r) => {\n if (!('vectors' in r)) return;\n await vector.setTile(k, { ...r.vectors, styles: placed(r.vectors.styles, r.vectors.patterns) });\n // Cut under a style changed since: its styles asked for again\n if (style !== state.style) await restyleTile(await state.renderer, k);\n },\n ),\n ];\n });\n // Out of view: those still asked for go at once, those drawn once their replacements are there (no hole). The\n // drawn ones are those the engine shows, held or not (a recut forgets what it held, not what is drawn)\n const drop = (drawn: boolean) => {\n const shown = new Set(vector.tileKeys);\n const known = new Set([...requests.keys(), ...(drawn ? shown : [])]);\n\n known.forEach((k) => {\n if (keys.has(k) || shown.has(k) !== drawn) return;\n requests.drop(k);\n vector.removeTile(k);\n });\n };\n\n drop(false);\n // Every tile of the view, those an earlier update asked for too: a tile out of view stays drawn until all of them\n // are there\n await Promise.all([...loads, requests.answered(keys)]);\n // A later update (the view moved again meanwhile) drops for its own view: these keys are no longer the view\n if (!context.destroyed() && generation === state.update) drop(true);\n };\n const refresh = () => {\n update().catch(() => undefined);\n };\n /** The style layers changed: the workers' copy, then the styles of the tiles held */\n const restyle = async (list: StyleLayer[]) => {\n state.own = list;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => context.renderer(() => false, list, key));\n\n const renderer = await state.renderer;\n\n vector.setSublayers(sublayers(list));\n await Promise.all(vector.tileKeys.map((k) => restyleTile(renderer, k)));\n };\n\n vector.restyle = (id, group, name, value) => {\n state.renderer\n .then(({ layers: list }) => {\n const next = (state.own ?? list).map((l) =>\n l.id === id ? { ...l, [group]: { ...l[group], [name]: value } } : l,\n );\n\n // Visibility and dashes are the engine's: the tiles stay as they are\n if ((group === 'layout' && name === 'visibility') || name === 'line-dasharray') {\n state.own = next;\n vector.setSublayers(sublayers(next));\n\n return undefined;\n }\n // An outline added or taken away: a feature more or less in each tile, cut again\n if (name === 'fill-outline-color' || name === 'fill-antialias') {\n state.own = next;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => context.renderer(() => false, next, key));\n vector.setSublayers(sublayers(next));\n vector.recut?.();\n\n return undefined;\n }\n\n return restyle(next);\n })\n .catch(() => undefined);\n };\n vector.recut = () => {\n requests.abortAll();\n refresh();\n };\n vector.refresh = refresh;\n vector.styled = state.renderer.then(({ layers: list }) => {\n if (!context.destroyed()) vector.setSublayers(sublayers(state.own ?? list));\n });\n // Reported by the style's `ready`\n vector.styled.catch(() => undefined);\n\n // While the camera moves, the tiles follow it (as the labels do: a long drag or flight does not leave the view of\n // its start drawn)\n context.followView(vector, update, requests, update);\n\n return vector;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/vectors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,MAAM,E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,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * The vector layer of a vector basemap (`VectorTiles.vectors`): its fills, lines and buildings cut by the workers\n * into geometry the engine draws, the tiles following the view, and how its style layers are read for the engine.\n */\n\nimport { tilesetCoverage } from '../../data/tileset.ts';\nimport type { Icons } from '../../layers/icons.ts';\nimport type { VectorLayer, VectorSublayer } from '../../layers/vectors.ts';\nimport type { Drape, Placement, Tiles3dOptions } from '../../types.ts';\nimport { latitude, longitude } from '../../util/geo.ts';\nimport type { RoofMode } from '../../util/roofs.ts';\nimport { FLOATS, STYLE } from '../../util/style-floats.ts';\nimport type { BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { evaluate, isExpression, type Json, type StyleLayer, vectorKind, zoomOnly } from '../vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, parseTileKey, type TileTriple, tileKey, tileTriples } from './tiles.ts';\n\n/** The deepest level `vectors()` cuts its tiles at: past the source's deepest level, its tiles cut again into deeper\n * ones (overzoom, as MapLibre does) down to level 18, their styles those of their level, smaller tiles\n * drawn in a closer view; past it, the tiles of that level stretched */\nconst OVERZOOM_LEVEL = 18;\n\n/** The deepest level of the tiles of `vectors()` over a source whose deepest is `maxzoom` */\nconst deepestLevel = (maxzoom: number): number => Math.max(maxzoom, OVERZOOM_LEVEL);\n\n/** A layout or paint value at a zoom, whatever the feature (an expression evaluated) */\nconst atZoom = (value: Json | undefined, zoom: number): unknown =>\n isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\n\n/**\n * A `line-dasharray` as the engine takes it: two dashes and gaps in line widths (an odd count repeated, as the\n * canvas's `setLineDash`; past four, the first four), zeros for a solid line\n */\nexport const dashes = (value: Json | undefined, zoom: number): [number, number, number, number] => {\n const v = atZoom(value, zoom);\n const list = Array.isArray(v) ? v.map(Number).filter((d) => Number.isFinite(d) && d >= 0) : [];\n const even = list.length % 2 === 1 ? [...list, ...list] : list;\n const [a = 0, b = 0, c = 0, d = 0] = even.length >= 2 && even.some((x) => x > 0) ? even : [];\n\n return [a, b, c, d];\n};\n\n/** Whether a style layer draws streets, which glow at night: its id names a road (OpenMapTiles' styles, PLAN IGN's),\n * not its casing, a railway, a path or a tunnel */\nexport const isStreet = (layer: StyleLayer): boolean =>\n /road|highway|street|motorway|trunk|primary|secondary|tertiary|minor|routier/i.test(layer.id) &&\n !/casing|outline|rail|path|track|ferry|tunnel|pier|area|pattern|label/i.test(layer.id);\n\n/** A `line-cap` as the engine draws it, at the camera's zoom (MapLibre's default: butt) */\nconst lineCap = (value: Json | undefined, zoom: number): 'butt' | 'round' | 'square' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'square' ? v : 'butt';\n};\n\n/** A `line-join` as the engine draws it, at the camera's zoom (MapLibre's default: miter) */\nconst lineJoin = (value: Json | undefined, zoom: number): 'miter' | 'bevel' | 'round' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'bevel' ? v : 'miter';\n};\n\n/** A `line-miter-limit` at the camera's zoom (MapLibre's default: 2) */\nconst miterLimit = (value: Json | undefined, zoom: number): number => {\n const v = Number(atZoom(value, zoom) ?? 2);\n\n return Number.isFinite(v) ? v : 2;\n};\n\n/** A tile's styles with their patterns placed: each feature's pattern, as its index past one into `names`\n * (`STYLE.fillPattern`, `STYLE.linePattern`), replaced by its image's place in the icon atlas (texels) and pixel\n * ratio; none if the atlas has no such image; the atlas uploaded */\nexport const placePatterns = (\n styles: Float32Array,\n names: readonly string[] | undefined,\n icons: Icons,\n prefix: string,\n): Float32Array => {\n if (!names?.length) return styles;\n // Thousands of features a tile: a loop\n for (let f = 0; f + FLOATS <= styles.length; f += FLOATS) {\n const fill = styles[f + STYLE.fillPattern] ?? 0;\n const line = styles[f + STYLE.linePattern] ?? 0;\n const index = fill > 0 ? fill : line;\n\n if (index <= 0) continue;\n\n const icon = icons.get(prefix + (names[index - 1] ?? ''));\n const place = icon ? [icon.x, icon.y, icon.width, icon.height] : [0, 0, 0, 0];\n const ratio = icon?.pixelRatio ?? 0;\n\n if (fill > 0) styles.set([...place, ratio], f + STYLE.size + 4);\n else {\n styles.set(place, f + STYLE.second);\n styles[f + STYLE.patternRatio] = ratio;\n }\n }\n icons.flush();\n\n return styles;\n};\n\n/** The paint properties of the patterns `vectors()` draws, whose images come from the style's sprite */\nconst PATTERNS = ['fill-pattern', 'background-pattern', 'line-pattern', 'fill-extrusion-pattern'];\n\n/** A `fill-translate` or `line-translate` at the camera's zoom (CSS pixels; none if it is not two numbers) */\nexport const translation = (value: Json | undefined, zoom: number): [number, number] => {\n const v = atZoom(value, zoom);\n const [x, y] = Array.isArray(v) ? v.map(Number) : [];\n\n return Number.isFinite(x) && Number.isFinite(y) ? [x ?? 0, y ?? 0] : [0, 0];\n};\n\n/** The options of `VectorTiles.vectors` */\nexport interface VectorsOptions extends Placement {\n layers?: (layer: StyleLayer) => boolean;\n streets?: (layer: StyleLayer) => boolean;\n /** The buildings' roofs: from their data (`roof:shape`, `roof:height`; flat without, the default), generated from\n * their outline where they have none (hipped, gabled or mansard by size and shape), or all flat */\n roofs?: RoofMode;\n /** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades?: boolean;\n /** A raster layer draped on the buildings' roofs (`setDrape`): an ortho on the city; on the 3D buildings too */\n drape?: Drape | undefined;\n /**\n * 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the\n * IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's\n * buildings left out where the tileset's children cover (their boxes, read from its `tileset.json`, a child that is\n * a tileset of its own read when a tile meets it), kept elsewhere; their walls' windows with `facades`\n */\n buildings3d?: Tiles3dOptions;\n}\n\nexport const vectors = (context: VectorTilesContext, options: VectorsOptions = {}): VectorLayer => {\n const { map } = context;\n const { layers = () => true, streets = isStreet, before, roofs = 'data', facades = false } = options;\n const vector = map.addVectorLayer(before);\n // The 3D buildings over the layer's ground, and where they stand\n const buildings = options.buildings3d && map.addTiles3d({ ...options.buildings3d, ...(before && { before }) });\n const coverage = options.buildings3d && tilesetCoverage(options.buildings3d.url);\n\n if (buildings) vector.companions.push(buildings);\n vector.buildings3d = buildings;\n vector.setFacades(facades);\n if (options.drape) vector.setDrape(options.drape);\n const state: {\n renderer: Promise<Renderer>;\n /** The style layers as the application changed them (`setPaintProperty`…): a copy, its style left as it is */\n own?: StyleLayer[];\n /** Bumped by each update: only the last one drops the tiles out of its view */\n update: number;\n /** Bumped by each restyle: a tile cut under an older style is restyled once it is there */\n style: number;\n } = { renderer: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };\n\n state.renderer.catch(() => undefined);\n\n /** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */\n const sprites = context.ready\n .then(({ style }) =>\n style.layers.some((l) => layers(l) && PATTERNS.some((k) => l.paint?.[k] !== undefined))\n ? context.addSprites()\n : undefined,\n )\n .catch(() => undefined);\n const placed = (styles: Float32Array, names: readonly string[] | undefined) =>\n placePatterns(styles, names, map.icons, context.iconPrefix);\n context.layers.push(vector);\n\n const sublayers = (list: StyleLayer[]): VectorSublayer[] => {\n const zoom = map.getCamera().zoom;\n\n return list.map((l) => ({\n id: l.id,\n sourceLayer: l['source-layer'],\n kind: vectorKind(l) ?? 'fill',\n minZoom: l.minzoom ?? 0,\n maxZoom: l.maxzoom ?? 24,\n visible: l.layout?.visibility !== 'none',\n opacity: zoomOnly(l.paint?.[`${l.type}-opacity`], 1) ?? 1,\n cap: lineCap(l.layout?.['line-cap'], zoom),\n join: lineJoin(l.layout?.['line-join'], zoom),\n miterLimit: miterLimit(l.layout?.['line-miter-limit'], zoom),\n translate: translation(l.paint?.[`${l.type}-translate`], zoom),\n translateAnchor: l.paint?.[`${l.type}-translate-anchor`] === 'viewport' ? 'viewport' : 'map',\n patterned: l.paint?.['fill-pattern'] !== undefined || l.paint?.['background-pattern'] !== undefined,\n lit: l.type === 'line' && streets(l),\n dash: l.type === 'line' ? dashes(l.paint?.['line-dasharray'], zoom) : [0, 0, 0, 0],\n }));\n };\n\n /** The tiles held or asked for, by `z/x/y` */\n const requests = new TileRequests();\n /** A tile's geometry, or its styles alone, asked of the worker of its tile of the source's level (which keeps the\n * decoded tile its deeper tiles are cut from) */\n const ask = async (\n { key, maxzoom }: { key: string; maxzoom: number },\n [z, x, y]: TileTriple,\n styles: boolean,\n priority: Priority,\n signal?: AbortSignal,\n ) => {\n const d = Math.max(0, z - maxzoom);\n // Where the 3D buildings stand over the source's tile the worker cuts (none known: the style's buildings kept)\n const n = 2 ** (z - d);\n const [tx, ty] = [Math.floor(x / 2 ** d), Math.floor(y / 2 ** d)];\n const covered = await coverage\n ?.within([longitude(tx / n), latitude((ty + 1) / n), longitude((tx + 1) / n), latitude(ty / n)])\n .catch(() => undefined);\n const work: BasemapWork = {\n type: 'vectors',\n key,\n z,\n x,\n y,\n deepest: deepestLevel(maxzoom),\n roofs,\n ...(covered?.length ? { covered } : {}),\n priority,\n };\n\n // The geometry made ready for the GPU in the workers, with the prisms the relief needs\n return context.request(\n z - d,\n Math.floor(x / 2 ** d),\n Math.floor(y / 2 ** d),\n styles ? { ...work, styles } : { ...work, prism: map.hasRelief },\n signal,\n );\n };\n\n // The workers tessellate the tiles (the main thread only uploads them), once they know the module\n context.broadcast({ type: 'tess', url: map.tessUrl });\n /** Asks the workers again for the styles of a tile held, under the current style; the tile's geometry stays as it\n * is */\n const restyleTile = async (renderer: { key: string; maxzoom: number }, k: string) => {\n const r = await ask(renderer, parseTileKey(k), true, 'auto').catch(() => undefined);\n\n if (r && 'styles' in r) vector.setTileStyles(k, placed(r.styles, r.patterns));\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const generation = ++state.update;\n // The style the tiles are cut under: that of the renderer awaited, a restyle meanwhile (a paint property set as the\n // style loads) asking their styles again once they are there\n const style = state.style;\n const { key, maxzoom, layers: list } = await state.renderer;\n\n await sprites;\n\n vector.setSublayers(sublayers(state.own ?? list));\n\n const wanted = tileTriples(map.engine.vectorTilesInView(0, deepestLevel(maxzoom), map.quality.reach));\n const keys = new Set(wanted.map((t) => tileKey(...t)));\n const loads = wanted.flatMap((t, index) => {\n const k = tileKey(...t);\n\n if (requests.has(k)) return [];\n\n return [\n requests.ask(\n k,\n (signal) => ask({ key, maxzoom }, t, false, nearPriority(index, 'high', 'auto'), signal),\n async (r) => {\n if (!('vectors' in r)) return;\n await vector.setTile(k, { ...r.vectors, styles: placed(r.vectors.styles, r.vectors.patterns) });\n // Cut under a style changed since: its styles asked for again\n if (style !== state.style) await restyleTile(await state.renderer, k);\n },\n ),\n ];\n });\n // Out of view: those still asked for go at once, those drawn once their replacements are there (no hole). The\n // drawn ones are those the engine shows, held or not (a recut forgets what it held, not what is drawn)\n const drop = (drawn: boolean) => {\n const shown = new Set(vector.tileKeys);\n const known = new Set([...requests.keys(), ...(drawn ? shown : [])]);\n\n known.forEach((k) => {\n if (keys.has(k) || shown.has(k) !== drawn) return;\n requests.drop(k);\n vector.removeTile(k);\n });\n };\n\n drop(false);\n // Every tile of the view, those an earlier update asked for too: a tile out of view stays drawn until all of them\n // are there\n await Promise.all([...loads, requests.answered(keys)]);\n // A later update (the view moved again meanwhile) drops for its own view: these keys are no longer the view\n if (!context.destroyed() && generation === state.update) drop(true);\n };\n const refresh = () => {\n update().catch(() => undefined);\n };\n /** The style layers changed: the workers' copy, then the styles of the tiles held */\n const restyle = async (list: StyleLayer[]) => {\n state.own = list;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => context.renderer(() => false, list, key));\n\n const renderer = await state.renderer;\n\n vector.setSublayers(sublayers(list));\n await Promise.all(vector.tileKeys.map((k) => restyleTile(renderer, k)));\n };\n\n vector.restyle = (id, group, name, value) => {\n state.renderer\n .then(({ layers: list }) => {\n const next = (state.own ?? list).map((l) =>\n l.id === id ? { ...l, [group]: { ...l[group], [name]: value } } : l,\n );\n\n // Visibility and dashes are the engine's: the tiles stay as they are\n if ((group === 'layout' && name === 'visibility') || name === 'line-dasharray') {\n state.own = next;\n vector.setSublayers(sublayers(next));\n\n return undefined;\n }\n // An outline added or taken away: a feature more or less in each tile, cut again\n if (name === 'fill-outline-color' || name === 'fill-antialias') {\n state.own = next;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => context.renderer(() => false, next, key));\n vector.setSublayers(sublayers(next));\n vector.recut?.();\n\n return undefined;\n }\n\n return restyle(next);\n })\n .catch(() => undefined);\n };\n vector.recut = () => {\n requests.abortAll();\n refresh();\n };\n vector.refresh = refresh;\n vector.styled = state.renderer.then(({ layers: list }) => {\n if (!context.destroyed()) vector.setSublayers(sublayers(state.own ?? list));\n });\n // Reported by the style's `ready`\n vector.styled.catch(() => undefined);\n\n // While the camera moves, the tiles follow it (as the labels do: a long drag or flight does not leave the view of\n // its start drawn)\n context.followView(vector, update, requests, update);\n\n return vector;\n};\n"]}
|
|
@@ -127,8 +127,7 @@ export declare class VectorTiles {
|
|
|
127
127
|
* tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its
|
|
128
128
|
* `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the
|
|
129
129
|
* view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default
|
|
130
|
-
* 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
|
|
131
|
-
* engine with 3D Tiles.
|
|
130
|
+
* 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
|
|
132
131
|
*/
|
|
133
132
|
trees(options?: TreesOptions): ModelLayer;
|
|
134
133
|
/**
|
|
@@ -136,7 +135,6 @@ export declare class VectorTiles {
|
|
|
136
135
|
* level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every
|
|
137
136
|
* other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of
|
|
138
137
|
* them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).
|
|
139
|
-
* The models load the engine with 3D Tiles.
|
|
140
138
|
*/
|
|
141
139
|
lamps(options?: LampsOptions): ModelLayer;
|
|
142
140
|
/**
|
|
@@ -220,8 +220,7 @@ export class VectorTiles {
|
|
|
220
220
|
* tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its
|
|
221
221
|
* `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the
|
|
222
222
|
* view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default
|
|
223
|
-
* 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
|
|
224
|
-
* engine with 3D Tiles.
|
|
223
|
+
* 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
|
|
225
224
|
*/
|
|
226
225
|
trees(options = {}) {
|
|
227
226
|
return trees(this.context, options);
|
|
@@ -231,7 +230,6 @@ export class VectorTiles {
|
|
|
231
230
|
* level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every
|
|
232
231
|
* other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of
|
|
233
232
|
* them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).
|
|
234
|
-
* The models load the engine with 3D Tiles.
|
|
235
233
|
*/
|
|
236
234
|
lamps(options = {}) {
|
|
237
235
|
return lamps(this.context, options);
|