isard 1.4.0 → 1.6.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 +220 -2
- package/README.md +23 -7
- package/dist/basemap/furniture.d.ts +8 -0
- package/dist/basemap/furniture.js +26 -0
- package/dist/basemap/furniture.js.map +1 -0
- package/dist/basemap/trees.d.ts +35 -8
- package/dist/basemap/trees.js +105 -52
- package/dist/basemap/trees.js.map +1 -1
- package/dist/basemap/vectorstyle.d.ts +9 -3
- package/dist/basemap/vectorstyle.js +5 -6
- package/dist/basemap/vectorstyle.js.map +1 -1
- package/dist/basemap/vectortiles/context.d.ts +46 -0
- package/dist/basemap/vectortiles/context.js +6 -0
- package/dist/basemap/vectortiles/context.js.map +1 -0
- package/dist/basemap/vectortiles/extrusions.d.ts +15 -0
- package/dist/basemap/vectortiles/extrusions.js +61 -0
- package/dist/basemap/vectortiles/extrusions.js.map +1 -0
- package/dist/basemap/vectortiles/labels.d.ts +25 -0
- package/dist/basemap/vectortiles/labels.js +250 -0
- package/dist/basemap/vectortiles/labels.js.map +1 -0
- package/dist/basemap/vectortiles/lamps.d.ts +23 -0
- package/dist/basemap/vectortiles/lamps.js +90 -0
- package/dist/basemap/vectortiles/lamps.js.map +1 -0
- package/dist/basemap/vectortiles/requests.d.ts +28 -0
- package/dist/basemap/vectortiles/requests.js +74 -0
- package/dist/basemap/vectortiles/requests.js.map +1 -0
- package/dist/basemap/vectortiles/street-wind.d.ts +19 -0
- package/dist/basemap/vectortiles/street-wind.js +133 -0
- package/dist/basemap/vectortiles/street-wind.js.map +1 -0
- package/dist/basemap/vectortiles/style.d.ts +47 -0
- package/dist/basemap/vectortiles/style.js +141 -0
- package/dist/basemap/vectortiles/style.js.map +1 -0
- package/dist/basemap/vectortiles/tiles.d.ts +34 -0
- package/dist/basemap/vectortiles/tiles.js +62 -0
- package/dist/basemap/vectortiles/tiles.js.map +1 -0
- package/dist/basemap/vectortiles/trees.d.ts +28 -0
- package/dist/basemap/vectortiles/trees.js +178 -0
- package/dist/basemap/vectortiles/trees.js.map +1 -0
- package/dist/basemap/vectortiles/vectors.d.ts +37 -0
- package/dist/basemap/vectortiles/vectors.js +231 -0
- package/dist/basemap/vectortiles/vectors.js.map +1 -0
- package/dist/basemap/vectortiles.d.ts +49 -96
- package/dist/basemap/vectortiles.js +99 -774
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/workerpool.js +25 -6
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +14 -12
- package/dist/bind/layers.js +1 -0
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/collada.d.ts +19 -0
- package/dist/data/collada.js +319 -0
- package/dist/data/collada.js.map +1 -0
- package/dist/data/ifc.d.ts +100 -0
- package/dist/data/ifc.js +372 -0
- package/dist/data/ifc.js.map +1 -0
- package/dist/decoder.worker.js +5 -4
- package/dist/decoder.worker.js.map +8 -6
- package/dist/engine/decoders.d.ts +4 -8
- package/dist/engine/decoders.js +29 -2
- package/dist/engine/decoders.js.map +1 -1
- package/dist/formats.d.ts +7 -2
- package/dist/formats.js +7 -2
- package/dist/formats.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/extrusions.d.ts +10 -0
- package/dist/layers/extrusions.js +28 -2
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/flow.d.ts +9 -2
- package/dist/layers/flow.js +51 -10
- package/dist/layers/flow.js.map +1 -1
- package/dist/layers/layers.d.ts +12 -0
- package/dist/layers/layers.js +44 -1
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +2 -0
- package/dist/layers/panoramas.js +27 -6
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/photos.d.ts +48 -0
- package/dist/layers/photos.js +140 -0
- package/dist/layers/photos.js.map +1 -0
- package/dist/layers/symbols.d.ts +5 -1
- package/dist/layers/symbols.js +111 -32
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/trees.d.ts +28 -0
- package/dist/layers/trees.js +51 -0
- package/dist/layers/trees.js.map +1 -0
- package/dist/layers/vectors.d.ts +28 -2
- package/dist/layers/vectors.js +81 -7
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/layer-spec.d.ts +3 -0
- package/dist/map/layer-spec.js +2 -0
- package/dist/map/layer-spec.js.map +1 -1
- package/dist/map/workers.js +3 -0
- package/dist/map/workers.js.map +1 -1
- package/dist/map.d.ts +8 -0
- package/dist/map.js +15 -2
- package/dist/map.js.map +1 -1
- package/dist/panoramax.d.ts +49 -0
- package/dist/panoramax.js +71 -0
- package/dist/panoramax.js.map +1 -0
- package/dist/react/Layer.d.ts +1 -0
- package/dist/react/Layer.js.map +1 -1
- package/dist/react/VectorGeometry.d.ts +5 -0
- package/dist/react/VectorGeometry.js +12 -4
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/util/gltf.d.ts +9 -0
- package/dist/util/gltf.js +27 -0
- package/dist/util/gltf.js.map +1 -0
- package/dist/util/read.d.ts +4 -0
- package/dist/util/read.js +28 -0
- package/dist/util/read.js.map +1 -0
- package/dist/util/roofs.d.ts +10 -0
- package/dist/util/roofs.js +30 -0
- package/dist/util/roofs.js.map +1 -0
- package/dist/wasm/isard.d.ts +74 -22
- package/dist/wasm/isard.js +153 -22
- package/dist/wasm/isard_core.d.ts +62 -22
- package/dist/wasm/isard_core.js +129 -22
- package/dist/wasm/isard_tess.d.ts +6 -3
- package/dist/wasm/isard_tess.js +27 -4
- package/dist/workers/basemap/geometry.d.ts +38 -22
- package/dist/workers/basemap/labels.d.ts +14 -1
- package/dist/workers/basemap/lamps.d.ts +10 -0
- package/dist/workers/basemap/street.d.ts +1 -1
- package/dist/workers/basemap/trees.d.ts +3 -1
- package/dist/workers/basemap.worker.d.ts +43 -3
- package/dist/workers/basemap.worker.js +14 -2
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/layers/vectors.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface VectorSublayer {
|
|
|
13
13
|
id: string;
|
|
14
14
|
/** Its source layer, if any (not for a background) */
|
|
15
15
|
sourceLayer: string | undefined;
|
|
16
|
-
kind: 'fill' | 'line' | 'extrusion';
|
|
16
|
+
kind: 'fill' | 'line' | 'extrusion' | 'circle';
|
|
17
17
|
minZoom: number;
|
|
18
18
|
maxZoom: number;
|
|
19
19
|
visible: boolean;
|
|
@@ -21,8 +21,19 @@ export interface VectorSublayer {
|
|
|
21
21
|
* it) */
|
|
22
22
|
opacity: Size;
|
|
23
23
|
dash: [number, number, number, number];
|
|
24
|
-
/** The caps of its lines' ends (`line-cap
|
|
24
|
+
/** The caps of its lines' ends (`line-cap`) */
|
|
25
25
|
cap: 'butt' | 'round' | 'square';
|
|
26
|
+
/** The joins of its lines' pieces (`line-join`), a miter longer than `miterLimit` line widths bevelled
|
|
27
|
+
* (`line-miter-limit`); round and 2 if left out */
|
|
28
|
+
join?: 'miter' | 'bevel' | 'round';
|
|
29
|
+
miterLimit?: number;
|
|
30
|
+
/** How far its fills or lines move on screen (`fill-translate`, `line-translate`: CSS pixels, x right, y down),
|
|
31
|
+
* turning with the map or staying on the screen (`*-translate-anchor`); none and `map` if left out */
|
|
32
|
+
translate?: [number, number];
|
|
33
|
+
translateAnchor?: 'map' | 'viewport';
|
|
34
|
+
/** Its fills have patterns (`fill-pattern`, `background-pattern`): over the relief, the engine finds the ground under
|
|
35
|
+
* them */
|
|
36
|
+
patterned?: boolean;
|
|
26
37
|
/** Its lines glow at night (the streets: its id names a road, not its casing; `setSun`) */
|
|
27
38
|
lit: boolean;
|
|
28
39
|
}
|
|
@@ -33,10 +44,16 @@ export type VectorFeature = Feature<Record<string, unknown>> & {
|
|
|
33
44
|
};
|
|
34
45
|
export declare class VectorLayer extends Layer {
|
|
35
46
|
private readonly tiles;
|
|
47
|
+
/** The tiles waiting for their upload (`UPLOAD_MS` a frame), each with what resolves its `setTile`; `sent`: in the
|
|
48
|
+
* engine already, its blocks still uploading */
|
|
49
|
+
private readonly queue;
|
|
50
|
+
private flushing;
|
|
36
51
|
private sublayers;
|
|
37
52
|
private nextKey;
|
|
38
53
|
/** The whole layer shown (`setVisible`), over each style layer's visibility */
|
|
39
54
|
private shown;
|
|
55
|
+
/** Its buildings' walls show their windows (`setFacades`) */
|
|
56
|
+
private facades;
|
|
40
57
|
/** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected
|
|
41
58
|
* if the style fails */
|
|
42
59
|
get ready(): Promise<void>;
|
|
@@ -44,6 +61,13 @@ export declare class VectorLayer extends Layer {
|
|
|
44
61
|
get layers(): readonly VectorSublayer[];
|
|
45
62
|
/** Keys of the tiles held (`z/x/y`) */
|
|
46
63
|
get tileKeys(): string[];
|
|
64
|
+
/** Uploads the waiting tiles on the next frame */
|
|
65
|
+
private flushSoon;
|
|
66
|
+
/** Uploads waiting tiles for `UPLOAD_MS` at most (one at least, or a part of its blocks), the rest on the next
|
|
67
|
+
* frames; a tile's `setTile` resolves once its blocks are all there */
|
|
68
|
+
private flush;
|
|
69
|
+
/** Sends a tile to the engine (its blocks' first part); its key */
|
|
70
|
+
private upload;
|
|
47
71
|
/** The feature of a picked index (no geometry: the tiles hold it cut), its properties and style layer. Tiles are
|
|
48
72
|
* numbered one after the other, in the order they were first added */
|
|
49
73
|
featureAt(index: number): VectorFeature | undefined;
|
|
@@ -53,6 +77,8 @@ export declare class VectorLayer extends Layer {
|
|
|
53
77
|
/** Changes a layout property of a style layer drawn (`visibility`: shown or hidden at once), as MapLibre's
|
|
54
78
|
* `setLayoutProperty` */
|
|
55
79
|
setLayoutProperty(layer: string, name: string, value: unknown): void;
|
|
80
|
+
/** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */
|
|
81
|
+
setFacades(facades: boolean): void;
|
|
56
82
|
setVisible(visible: boolean): void;
|
|
57
83
|
private sendSublayers;
|
|
58
84
|
/** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */
|
package/dist/layers/vectors.js
CHANGED
|
@@ -6,12 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { FLOATS, stops } from "./features.js";
|
|
8
8
|
import { Layer } from "./layers.js";
|
|
9
|
+
/** The main thread's time a frame gives to uploading tiles (ms): tiles arriving together are uploaded over several
|
|
10
|
+
* frames, not all in the one (copying a tile's buffers to the GPU takes milliseconds) */
|
|
11
|
+
const UPLOAD_MS = 4;
|
|
9
12
|
export class VectorLayer extends Layer {
|
|
10
13
|
tiles = new Map();
|
|
14
|
+
/** The tiles waiting for their upload (`UPLOAD_MS` a frame), each with what resolves its `setTile`; `sent`: in the
|
|
15
|
+
* engine already, its blocks still uploading */
|
|
16
|
+
queue = new Map();
|
|
17
|
+
flushing = false;
|
|
11
18
|
sublayers = [];
|
|
12
19
|
nextKey = 0;
|
|
13
20
|
/** The whole layer shown (`setVisible`), over each style layer's visibility */
|
|
14
21
|
shown = true;
|
|
22
|
+
/** Its buildings' walls show their windows (`setFacades`) */
|
|
23
|
+
facades = false;
|
|
15
24
|
/** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */
|
|
16
25
|
styled = Promise.resolve();
|
|
17
26
|
/** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */
|
|
@@ -41,16 +50,65 @@ export class VectorLayer extends Layer {
|
|
|
41
50
|
this.sendSublayers(this.map.engine, this.id);
|
|
42
51
|
this.map.requestRender();
|
|
43
52
|
}
|
|
44
|
-
/** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh)
|
|
53
|
+
/** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh): uploaded
|
|
54
|
+
* on a coming frame, within its share of the frame (`UPLOAD_MS`); resolves once it is (or once dropped meanwhile) */
|
|
45
55
|
setTile(tile, vectors) {
|
|
56
|
+
return new Promise((uploaded) => {
|
|
57
|
+
// A newer cut of a tile still waiting takes its place
|
|
58
|
+
this.queue.get(tile)?.uploaded();
|
|
59
|
+
this.queue.set(tile, { vectors, uploaded });
|
|
60
|
+
this.flushSoon();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Uploads the waiting tiles on the next frame */
|
|
64
|
+
flushSoon() {
|
|
65
|
+
if (this.flushing)
|
|
66
|
+
return;
|
|
67
|
+
this.flushing = true;
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
this.flushing = false;
|
|
70
|
+
this.flush();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** Uploads waiting tiles for `UPLOAD_MS` at most (one at least, or a part of its blocks), the rest on the next
|
|
74
|
+
* frames; a tile's `setTile` resolves once its blocks are all there */
|
|
75
|
+
flush() {
|
|
76
|
+
const start = performance.now();
|
|
77
|
+
const within = () => performance.now() - start <= UPLOAD_MS;
|
|
78
|
+
for (const [tile, waiting] of this.queue) {
|
|
79
|
+
waiting.sent ??= this.upload(tile, waiting.vectors);
|
|
80
|
+
// A large tile's blocks (a pitched view's far tiles of a city: 10 MB and more), a part at a time
|
|
81
|
+
let left = this.map.engine.uploadVectorTile(this.id, waiting.sent);
|
|
82
|
+
while (left && within())
|
|
83
|
+
left = this.map.engine.uploadVectorTile(this.id, waiting.sent);
|
|
84
|
+
if (left)
|
|
85
|
+
break;
|
|
86
|
+
this.queue.delete(tile);
|
|
87
|
+
waiting.uploaded();
|
|
88
|
+
if (!within())
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
if (this.queue.size > 0)
|
|
92
|
+
this.flushSoon();
|
|
93
|
+
this.map.requestRender();
|
|
94
|
+
}
|
|
95
|
+
/** Sends a tile to the engine (its blocks' first part); its key */
|
|
96
|
+
upload(tile, vectors) {
|
|
46
97
|
const key = this.tiles.get(tile)?.key ?? this.nextKey++;
|
|
47
98
|
const { properties, sublayer } = vectors;
|
|
48
99
|
this.tiles.set(tile, { key, vectors: { properties, sublayer } });
|
|
49
100
|
this.sendTile(this.map.engine, this.id, key, vectors);
|
|
50
|
-
|
|
101
|
+
return key;
|
|
51
102
|
}
|
|
52
103
|
/** @internal New styles of a tile's features, as the workers evaluated them (the same features) */
|
|
53
104
|
setTileStyles(tile, styles) {
|
|
105
|
+
const waiting = this.queue.get(tile);
|
|
106
|
+
// Not uploaded yet: uploaded with them
|
|
107
|
+
if (waiting && waiting.sent === undefined) {
|
|
108
|
+
if (styles.length === waiting.vectors.properties.length * FLOATS)
|
|
109
|
+
waiting.vectors.styles = styles;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
54
112
|
const t = this.tiles.get(tile);
|
|
55
113
|
if (!t || styles.length !== t.vectors.properties.length * FLOATS)
|
|
56
114
|
return;
|
|
@@ -59,6 +117,8 @@ export class VectorLayer extends Layer {
|
|
|
59
117
|
}
|
|
60
118
|
/** @internal */
|
|
61
119
|
removeTile(tile) {
|
|
120
|
+
this.queue.get(tile)?.uploaded();
|
|
121
|
+
this.queue.delete(tile);
|
|
62
122
|
const t = this.tiles.get(tile);
|
|
63
123
|
if (!t)
|
|
64
124
|
return;
|
|
@@ -96,6 +156,12 @@ export class VectorLayer extends Layer {
|
|
|
96
156
|
setLayoutProperty(layer, name, value) {
|
|
97
157
|
this.restyle?.(layer, 'layout', name, value);
|
|
98
158
|
}
|
|
159
|
+
/** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */
|
|
160
|
+
setFacades(facades) {
|
|
161
|
+
this.facades = facades;
|
|
162
|
+
this.map.engine.setFacades(this.id, facades);
|
|
163
|
+
this.map.requestRender();
|
|
164
|
+
}
|
|
99
165
|
setVisible(visible) {
|
|
100
166
|
this.shown = visible;
|
|
101
167
|
this.sendSublayers(this.map.engine, this.id);
|
|
@@ -103,26 +169,34 @@ export class VectorLayer extends Layer {
|
|
|
103
169
|
}
|
|
104
170
|
sendSublayers(engine, id) {
|
|
105
171
|
const s = this.sublayers;
|
|
106
|
-
engine.setVectorSublayers(id, Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2 })[l.kind]), Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])), Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)), Float32Array.from(s.flatMap((l) => l.dash)), Float32Array.from(s.flatMap((l) => stops(l.opacity))), Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]), Uint8Array.from(s, (l) => (l.lit ? 1 : 0)));
|
|
172
|
+
engine.setVectorSublayers(id, Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2, circle: 3 })[l.kind]), Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])), Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)), Float32Array.from(s.flatMap((l) => l.dash)), Float32Array.from(s.flatMap((l) => stops(l.opacity))), Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]), Uint8Array.from(s, (l) => (l.lit ? 1 : 0)), Float32Array.from(s.flatMap((l) => [{ round: 0, miter: 1, bevel: 2 }[l.join ?? 'round'], l.miterLimit ?? 2])), Float32Array.from(s.flatMap((l) => [...(l.translate ?? [0, 0]), l.translateAnchor === 'viewport' ? 1 : 0])), Uint8Array.from(s, (l) => (l.patterned ? 1 : 0)));
|
|
107
173
|
}
|
|
108
174
|
/** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */
|
|
109
175
|
sendTile(engine, id, key, vectors) {
|
|
110
|
-
const { fills, lines, styles, properties, mesh } = vectors;
|
|
176
|
+
const { fills, lines, circles, styles, properties, mesh } = vectors;
|
|
111
177
|
if (mesh) {
|
|
112
178
|
engine.setVectorTileMesh(id, key, fills.points, fills.ringStart, fills.polygonStart, fills.feature, fills.fillStart, mesh.vertices, mesh.indices, mesh.fillRanges, mesh.prism, mesh.pieces, mesh.lineTable, mesh.lineRanges, mesh.blocks, mesh.blockIndices, mesh.blockRanges, mesh.bounds, properties.length);
|
|
113
|
-
engine.setFeatureStyle(id, styles, key);
|
|
114
|
-
return;
|
|
115
179
|
}
|
|
116
|
-
|
|
180
|
+
else {
|
|
181
|
+
engine.setVectorTile(id, key, fills.points, fills.ringStart, fills.polygonStart, fills.feature, fills.fillStart, lines.points, lines.start, lines.feature, lines.lineStart, properties.length, vectors.tile ?? new Float64Array(), fills.roofs ?? new Uint8Array(), fills.roofHeights ?? new Float32Array(), fills.roofOutlines ?? new Float64Array(), fills.roofOutlineStart ?? new Uint32Array(), fills.roofMetres ?? 0);
|
|
182
|
+
}
|
|
183
|
+
// The circles' points, once the tile is there
|
|
184
|
+
if (circles)
|
|
185
|
+
engine.setVectorTilePoints(id, key, circles.points, circles.feature, circles.circleStart);
|
|
117
186
|
engine.setFeatureStyle(id, styles, key);
|
|
118
187
|
}
|
|
119
188
|
/** @internal */
|
|
120
189
|
create(engine) {
|
|
121
190
|
const id = engine.addVectorTiles();
|
|
122
191
|
this.sendSublayers(engine, id);
|
|
192
|
+
engine.setFacades(id, this.facades);
|
|
123
193
|
// An engine made anew (after a context loss, or the one with 3D Tiles): its tiles cut again by the workers, once
|
|
124
194
|
// the layer has its id there. Keeping their geometry here would double the memory they take
|
|
125
195
|
this.tiles.clear();
|
|
196
|
+
this.queue.forEach(({ uploaded }) => {
|
|
197
|
+
uploaded();
|
|
198
|
+
});
|
|
199
|
+
this.queue.clear();
|
|
126
200
|
queueMicrotask(() => this.recut?.());
|
|
127
201
|
return id;
|
|
128
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../src/layers/vectors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAgB,MAAM,EAAa,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAiCpC,MAAM,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AAC;YAExC,OAAO;QACT,CAAC;QACD,MAAM,CAAC,aAAa,CAClB,EAAE,EACF,GAAG,EACH,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,EACf,UAAU,CAAC,MAAM,EACjB,OAAO,CAAC,IAAI,IAAI,IAAI,YAAY,EAAE,CACnC,CAAC;QACF,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;QAEnC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/B,iHAAiH;QACjH,4FAA4F;QAC5F,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErC,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * The fills and lines of a MapLibre style drawn as geometry, tile by tile (`VectorTiles.vectors`), instead of into the\n * images of a raster layer: sharp at any zoom and pitch, on the relief, picked by feature, restyled without cutting the\n * tiles again. The workers cut each vector tile into polygons and lines and style its features; the engine draws the\n * style's layers in their order, each over its zoom range.\n */\n\nimport type { LayerHost } from '../types.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport type { TileVectors } from '../workers/basemap.worker.ts';\nimport { type Feature, FLOATS, type Size, stops } from './features.ts';\nimport { Layer } from './layers.ts';\n\n/** A style layer as the engine draws it: its kind, zoom range, visibility and dashes (dash, gap, dash, gap, in line\n * widths; zeros: solid) */\nexport interface VectorSublayer {\n /** The style layer's id */\n id: string;\n /** Its source layer, if any (not for a background) */\n sourceLayer: string | undefined;\n kind: 'fill' | 'line' | 'extrusion';\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Its opacity when it depends on the zoom only, evaluated at the camera's zoom (else 1: the features' colors hold\n * it) */\n opacity: Size;\n dash: [number, number, number, number];\n /** The caps of its lines' ends (`line-cap`; the joins between their pieces are round) */\n cap: 'butt' | 'round' | 'square';\n /** Its lines glow at night (the streets: its id names a road, not its casing; `setSun`) */\n lit: boolean;\n}\n\n/** The properties of a picked feature, with the style layer that drew it */\nexport type VectorFeature = Feature<Record<string, unknown>> & { layer: string; sourceLayer: string | undefined };\n\ninterface Tile {\n /** Its number in the engine: tiles are numbered for picking in this order */\n key: number;\n /** What picking needs (its geometry and styles are the engine's only: an engine made anew asks the tiles again) */\n vectors: Pick<TileVectors, 'properties' | 'sublayer'>;\n}\n\nexport class VectorLayer extends Layer {\n private readonly tiles = new Map<string, Tile>();\n private sublayers: VectorSublayer[] = [];\n private nextKey = 0;\n /** The whole layer shown (`setVisible`), over each style layer's visibility */\n private shown = true;\n /** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */\n styled: Promise<void> = Promise.resolve();\n /** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */\n restyle: ((layer: string, group: 'paint' | 'layout', name: string, value: unknown) => void) | undefined;\n /** @internal Asks the workers for the tiles in view again (set by its `VectorTiles`): an engine made anew has none */\n recut: (() => void) | undefined;\n\n /** @internal */\n constructor(map: LayerHost) {\n super(map);\n }\n\n /** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected\n * if the style fails */\n override get ready(): Promise<void> {\n return this.styled.then(() => super.ready);\n }\n\n /** The style layers drawn, in order */\n get layers(): readonly VectorSublayer[] {\n return this.sublayers;\n }\n\n /** Keys of the tiles held (`z/x/y`) */\n get tileKeys(): string[] {\n return [...this.tiles.keys()];\n }\n\n /** @internal Sets the style layers drawn, in order (the tiles' sublayers) */\n setSublayers(sublayers: VectorSublayer[]): void {\n this.sublayers = sublayers;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh) */\n setTile(tile: string, vectors: TileVectors): void {\n const key = this.tiles.get(tile)?.key ?? this.nextKey++;\n const { properties, sublayer } = vectors;\n\n this.tiles.set(tile, { key, vectors: { properties, sublayer } });\n this.sendTile(this.map.engine, this.id, key, vectors);\n this.map.requestRender();\n }\n\n /** @internal New styles of a tile's features, as the workers evaluated them (the same features) */\n setTileStyles(tile: string, styles: Float32Array): void {\n const t = this.tiles.get(tile);\n\n if (!t || styles.length !== t.vectors.properties.length * FLOATS) return;\n this.map.engine.setFeatureStyle(this.id, styles, t.key);\n this.map.requestRender();\n }\n\n /** @internal */\n removeTile(tile: string): void {\n const t = this.tiles.get(tile);\n\n if (!t) return;\n this.tiles.delete(tile);\n this.map.engine.removeVectorTile(this.id, t.key);\n this.map.requestRender();\n }\n\n /** The feature of a picked index (no geometry: the tiles hold it cut), its properties and style layer. Tiles are\n * numbered one after the other, in the order they were first added */\n featureAt(index: number): VectorFeature | undefined {\n const tiles = [...this.tiles.values()].sort((a, b) => a.key - b.key);\n // The tile holding the index, and the index among its features (one pass, the features of the tiles before\n // taken off)\n const { tile, rest } = tiles.reduce<{ tile?: Tile; rest: number }>(\n (found, t) => {\n if (found.tile) return found;\n\n const count = t.vectors.properties.length;\n\n return found.rest < count ? { tile: t, rest: found.rest } : { rest: found.rest - count };\n },\n { rest: index },\n );\n\n if (!tile) return undefined;\n\n const properties = tile.vectors.properties[rest];\n const sublayer = this.sublayers[tile.vectors.sublayer[rest] ?? -1];\n\n if (properties === undefined || !sublayer) return undefined;\n\n return { type: 'Feature', properties, geometry: null, layer: sublayer.id, sourceLayer: sublayer.sourceLayer };\n }\n\n /** Changes a paint property of a style layer drawn, as MapLibre's `setPaintProperty`: the tiles are restyled, not cut\n * again */\n setPaintProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'paint', name, value);\n }\n\n /** Changes a layout property of a style layer drawn (`visibility`: shown or hidden at once), as MapLibre's\n * `setLayoutProperty` */\n setLayoutProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'layout', name, value);\n }\n\n setVisible(visible: boolean): void {\n this.shown = visible;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendSublayers(engine: Engine, id: number): void {\n const s = this.sublayers;\n\n engine.setVectorSublayers(\n id,\n Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2 })[l.kind]),\n Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])),\n Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => l.dash)),\n Float32Array.from(s.flatMap((l) => stops(l.opacity))),\n Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]),\n Uint8Array.from(s, (l) => (l.lit ? 1 : 0)),\n );\n }\n\n /** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */\n private sendTile(engine: Engine, id: number, key: number, vectors: TileVectors): void {\n const { fills, lines, styles, properties, mesh } = vectors;\n\n if (mesh) {\n engine.setVectorTileMesh(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.prism,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n properties.length,\n );\n engine.setFeatureStyle(id, styles, key);\n\n return;\n }\n engine.setVectorTile(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n lines.points,\n lines.start,\n lines.feature,\n lines.lineStart,\n properties.length,\n vectors.tile ?? new Float64Array(),\n );\n engine.setFeatureStyle(id, styles, key);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addVectorTiles();\n\n this.sendSublayers(engine, id);\n // An engine made anew (after a context loss, or the one with 3D Tiles): its tiles cut again by the workers, once\n // the layer has its id there. Keeping their geometry here would double the memory they take\n this.tiles.clear();\n queueMicrotask(() => this.recut?.());\n\n return id;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../src/layers/vectors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAgB,MAAM,EAAa,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAqCpC;yFACyF;AACzF,MAAM,SAAS,GAAG,CAAC,CAAC;AASpB,MAAM,OAAO,WAAY,SAAQ,KAAK;IACnB,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IACjD;oDACgD;IAC/B,KAAK,GAAG,IAAI,GAAG,EAAyE,CAAC;IAClG,QAAQ,GAAG,KAAK,CAAC;IACjB,SAAS,GAAqB,EAAE,CAAC;IACjC,OAAO,GAAG,CAAC,CAAC;IACpB,+EAA+E;IACvE,KAAK,GAAG,IAAI,CAAC;IACrB,6DAA6D;IACrD,OAAO,GAAG,KAAK,CAAC;IACxB,wGAAwG;IACxG,MAAM,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1C,qFAAqF;IACrF,OAAO,CAAiG;IACxG,sHAAsH;IACtH,KAAK,CAA2B;IAEhC,gBAAgB;IAChB,YAAY,GAAc;QACxB,KAAK,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IAED;4BACwB;IACxB,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,uCAAuC;IACvC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,uCAAuC;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c,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErC,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * The fills and lines of a MapLibre style drawn as geometry, tile by tile (`VectorTiles.vectors`), instead of into the\n * images of a raster layer: sharp at any zoom and pitch, on the relief, picked by feature, restyled without cutting the\n * tiles again. The workers cut each vector tile into polygons and lines and style its features; the engine draws the\n * style's layers in their order, each over its zoom range.\n */\n\nimport type { LayerHost } from '../types.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport type { TileVectors } from '../workers/basemap.worker.ts';\nimport { type Feature, FLOATS, type Size, stops } from './features.ts';\nimport { Layer } from './layers.ts';\n\n/** A style layer as the engine draws it: its kind, zoom range, visibility and dashes (dash, gap, dash, gap, in line\n * widths; zeros: solid) */\nexport interface VectorSublayer {\n /** The style layer's id */\n id: string;\n /** Its source layer, if any (not for a background) */\n sourceLayer: string | undefined;\n kind: 'fill' | 'line' | 'extrusion' | 'circle';\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Its opacity when it depends on the zoom only, evaluated at the camera's zoom (else 1: the features' colors hold\n * it) */\n opacity: Size;\n dash: [number, number, number, number];\n /** The caps of its lines' ends (`line-cap`) */\n cap: 'butt' | 'round' | 'square';\n /** The joins of its lines' pieces (`line-join`), a miter longer than `miterLimit` line widths bevelled\n * (`line-miter-limit`); round and 2 if left out */\n join?: 'miter' | 'bevel' | 'round';\n miterLimit?: number;\n /** How far its fills or lines move on screen (`fill-translate`, `line-translate`: CSS pixels, x right, y down),\n * turning with the map or staying on the screen (`*-translate-anchor`); none and `map` if left out */\n translate?: [number, number];\n translateAnchor?: 'map' | 'viewport';\n /** Its fills have patterns (`fill-pattern`, `background-pattern`): over the relief, the engine finds the ground under\n * them */\n patterned?: boolean;\n /** Its lines glow at night (the streets: its id names a road, not its casing; `setSun`) */\n lit: boolean;\n}\n\n/** The properties of a picked feature, with the style layer that drew it */\nexport type VectorFeature = Feature<Record<string, unknown>> & { layer: string; sourceLayer: string | undefined };\n\n/** The main thread's time a frame gives to uploading tiles (ms): tiles arriving together are uploaded over several\n * frames, not all in the one (copying a tile's buffers to the GPU takes milliseconds) */\nconst UPLOAD_MS = 4;\n\ninterface Tile {\n /** Its number in the engine: tiles are numbered for picking in this order */\n key: number;\n /** What picking needs (its geometry and styles are the engine's only: an engine made anew asks the tiles again) */\n vectors: Pick<TileVectors, 'properties' | 'sublayer'>;\n}\n\nexport class VectorLayer extends Layer {\n private readonly tiles = new Map<string, Tile>();\n /** The tiles waiting for their upload (`UPLOAD_MS` a frame), each with what resolves its `setTile`; `sent`: in the\n * engine already, its blocks still uploading */\n private readonly queue = new Map<string, { vectors: TileVectors; uploaded: () => void; sent?: number }>();\n private flushing = false;\n private sublayers: VectorSublayer[] = [];\n private nextKey = 0;\n /** The whole layer shown (`setVisible`), over each style layer's visibility */\n private shown = true;\n /** Its buildings' walls show their windows (`setFacades`) */\n private facades = false;\n /** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */\n styled: Promise<void> = Promise.resolve();\n /** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */\n restyle: ((layer: string, group: 'paint' | 'layout', name: string, value: unknown) => void) | undefined;\n /** @internal Asks the workers for the tiles in view again (set by its `VectorTiles`): an engine made anew has none */\n recut: (() => void) | undefined;\n\n /** @internal */\n constructor(map: LayerHost) {\n super(map);\n }\n\n /** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected\n * if the style fails */\n override get ready(): Promise<void> {\n return this.styled.then(() => super.ready);\n }\n\n /** The style layers drawn, in order */\n get layers(): readonly VectorSublayer[] {\n return this.sublayers;\n }\n\n /** Keys of the tiles held (`z/x/y`) */\n get tileKeys(): string[] {\n return [...this.tiles.keys()];\n }\n\n /** @internal Sets the style layers drawn, in order (the tiles' sublayers) */\n setSublayers(sublayers: VectorSublayer[]): void {\n this.sublayers = sublayers;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh): uploaded\n * on a coming frame, within its share of the frame (`UPLOAD_MS`); resolves once it is (or once dropped meanwhile) */\n setTile(tile: string, vectors: TileVectors): Promise<void> {\n return new Promise((uploaded) => {\n // A newer cut of a tile still waiting takes its place\n this.queue.get(tile)?.uploaded();\n this.queue.set(tile, { vectors, uploaded });\n this.flushSoon();\n });\n }\n\n /** Uploads the waiting tiles on the next frame */\n private flushSoon(): void {\n if (this.flushing) return;\n this.flushing = true;\n requestAnimationFrame(() => {\n this.flushing = false;\n this.flush();\n });\n }\n\n /** Uploads waiting tiles for `UPLOAD_MS` at most (one at least, or a part of its blocks), the rest on the next\n * frames; a tile's `setTile` resolves once its blocks are all there */\n private flush(): void {\n const start = performance.now();\n const within = () => performance.now() - start <= UPLOAD_MS;\n\n for (const [tile, waiting] of this.queue) {\n waiting.sent ??= this.upload(tile, waiting.vectors);\n\n // A large tile's blocks (a pitched view's far tiles of a city: 10 MB and more), a part at a time\n let left = this.map.engine.uploadVectorTile(this.id, waiting.sent);\n\n while (left && within()) left = this.map.engine.uploadVectorTile(this.id, waiting.sent);\n if (left) break;\n this.queue.delete(tile);\n waiting.uploaded();\n if (!within()) break;\n }\n if (this.queue.size > 0) this.flushSoon();\n this.map.requestRender();\n }\n\n /** Sends a tile to the engine (its blocks' first part); its key */\n private upload(tile: string, vectors: TileVectors): number {\n const key = this.tiles.get(tile)?.key ?? this.nextKey++;\n const { properties, sublayer } = vectors;\n\n this.tiles.set(tile, { key, vectors: { properties, sublayer } });\n this.sendTile(this.map.engine, this.id, key, vectors);\n\n return key;\n }\n\n /** @internal New styles of a tile's features, as the workers evaluated them (the same features) */\n setTileStyles(tile: string, styles: Float32Array): void {\n const waiting = this.queue.get(tile);\n\n // Not uploaded yet: uploaded with them\n if (waiting && waiting.sent === undefined) {\n if (styles.length === waiting.vectors.properties.length * FLOATS) waiting.vectors.styles = styles;\n\n return;\n }\n\n const t = this.tiles.get(tile);\n\n if (!t || styles.length !== t.vectors.properties.length * FLOATS) return;\n this.map.engine.setFeatureStyle(this.id, styles, t.key);\n this.map.requestRender();\n }\n\n /** @internal */\n removeTile(tile: string): void {\n this.queue.get(tile)?.uploaded();\n this.queue.delete(tile);\n\n const t = this.tiles.get(tile);\n\n if (!t) return;\n this.tiles.delete(tile);\n this.map.engine.removeVectorTile(this.id, t.key);\n this.map.requestRender();\n }\n\n /** The feature of a picked index (no geometry: the tiles hold it cut), its properties and style layer. Tiles are\n * numbered one after the other, in the order they were first added */\n featureAt(index: number): VectorFeature | undefined {\n const tiles = [...this.tiles.values()].sort((a, b) => a.key - b.key);\n // The tile holding the index, and the index among its features (one pass, the features of the tiles before\n // taken off)\n const { tile, rest } = tiles.reduce<{ tile?: Tile; rest: number }>(\n (found, t) => {\n if (found.tile) return found;\n\n const count = t.vectors.properties.length;\n\n return found.rest < count ? { tile: t, rest: found.rest } : { rest: found.rest - count };\n },\n { rest: index },\n );\n\n if (!tile) return undefined;\n\n const properties = tile.vectors.properties[rest];\n const sublayer = this.sublayers[tile.vectors.sublayer[rest] ?? -1];\n\n if (properties === undefined || !sublayer) return undefined;\n\n return { type: 'Feature', properties, geometry: null, layer: sublayer.id, sourceLayer: sublayer.sourceLayer };\n }\n\n /** Changes a paint property of a style layer drawn, as MapLibre's `setPaintProperty`: the tiles are restyled, not cut\n * again */\n setPaintProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'paint', name, value);\n }\n\n /** Changes a layout property of a style layer drawn (`visibility`: shown or hidden at once), as MapLibre's\n * `setLayoutProperty` */\n setLayoutProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'layout', name, value);\n }\n\n /** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */\n setFacades(facades: boolean): void {\n this.facades = facades;\n this.map.engine.setFacades(this.id, facades);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.shown = visible;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendSublayers(engine: Engine, id: number): void {\n const s = this.sublayers;\n\n engine.setVectorSublayers(\n id,\n Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2, circle: 3 })[l.kind]),\n Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])),\n Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => l.dash)),\n Float32Array.from(s.flatMap((l) => stops(l.opacity))),\n Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]),\n Uint8Array.from(s, (l) => (l.lit ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => [{ round: 0, miter: 1, bevel: 2 }[l.join ?? 'round'], l.miterLimit ?? 2])),\n Float32Array.from(s.flatMap((l) => [...(l.translate ?? [0, 0]), l.translateAnchor === 'viewport' ? 1 : 0])),\n Uint8Array.from(s, (l) => (l.patterned ? 1 : 0)),\n );\n }\n\n /** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */\n private sendTile(engine: Engine, id: number, key: number, vectors: TileVectors): void {\n const { fills, lines, circles, styles, properties, mesh } = vectors;\n\n if (mesh) {\n engine.setVectorTileMesh(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.prism,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n properties.length,\n );\n } else {\n engine.setVectorTile(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n lines.points,\n lines.start,\n lines.feature,\n lines.lineStart,\n properties.length,\n vectors.tile ?? new Float64Array(),\n fills.roofs ?? new Uint8Array(),\n fills.roofHeights ?? new Float32Array(),\n fills.roofOutlines ?? new Float64Array(),\n fills.roofOutlineStart ?? new Uint32Array(),\n fills.roofMetres ?? 0,\n );\n }\n // The circles' points, once the tile is there\n if (circles) engine.setVectorTilePoints(id, key, circles.points, circles.feature, circles.circleStart);\n engine.setFeatureStyle(id, styles, key);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addVectorTiles();\n\n this.sendSublayers(engine, id);\n engine.setFacades(id, this.facades);\n // An engine made anew (after a context loss, or the one with 3D Tiles): its tiles cut again by the workers, once\n // the layer has its id there. Keeping their geometry here would double the memory they take\n this.tiles.clear();\n this.queue.forEach(({ uploaded }) => {\n uploaded();\n });\n this.queue.clear();\n queueMicrotask(() => this.recut?.());\n\n return id;\n }\n}\n"]}
|
package/dist/map/layer-spec.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { FlowOptions } from '../layers/flow.ts';
|
|
|
5
5
|
import type { GroundOptions, Layer, ModelOptions } from '../layers/layers.ts';
|
|
6
6
|
import type { PointCloudOptions } from '../layers/pointclouds.ts';
|
|
7
7
|
import type { SymbolOptions } from '../layers/symbols.ts';
|
|
8
|
+
import type { TreeOptions } from '../layers/trees.ts';
|
|
8
9
|
import type { GeoMap } from '../map.ts';
|
|
9
10
|
import type { NetworkOptions, RasterOptions, Tiles3dOptions } from '../types.ts';
|
|
10
11
|
/** A layer by its type and the options of its `add…` method (`GeoMap.add`) */
|
|
@@ -39,6 +40,8 @@ export type LayerSpec<P = Record<string, unknown>> = ({
|
|
|
39
40
|
} & ModelOptions & {
|
|
40
41
|
before?: Layer;
|
|
41
42
|
}) | ({
|
|
43
|
+
type: 'trees';
|
|
44
|
+
} & TreeOptions<P>) | ({
|
|
42
45
|
type: 'flow';
|
|
43
46
|
} & FlowOptions);
|
|
44
47
|
/** Adds the layer a description gives with the `add…` method of its type; an unknown type throws */
|
package/dist/map/layer-spec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-spec.js","sourceRoot":"","sources":["../../src/map/layer-spec.ts"],"names":[],"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R,sFAAsF;YACtF,MAAM,EAAE,IAAI,EAAE,GAAuB,IAAI,CAAC;YAE1C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["/** A layer described by its type and options, as an application's configuration gives it, and the map adding it. */\n\nimport type { ExtrusionOptions } from '../layers/extrusions.ts';\nimport type { CircleOptions, FillOptions, LineOptions } from '../layers/features.ts';\nimport type { FlowOptions } from '../layers/flow.ts';\nimport type { GroundOptions, Layer, ModelOptions } from '../layers/layers.ts';\nimport type { PointCloudOptions } from '../layers/pointclouds.ts';\nimport type { SymbolOptions } from '../layers/symbols.ts';\nimport type { TreeOptions } from '../layers/trees.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { NetworkOptions, RasterOptions, Tiles3dOptions } from '../types.ts';\n\n/** A layer by its type and the options of its `add…` method (`GeoMap.add`) */\nexport type LayerSpec<P = Record<string, unknown>> =\n | ({ type: 'lines' } & LineOptions<P>)\n | ({ type: 'circles' } & CircleOptions<P>)\n | ({ type: 'fills' } & FillOptions<P>)\n | ({ type: 'symbols' } & SymbolOptions<P>)\n | ({ type: 'extrusions' } & ExtrusionOptions<P>)\n | ({ type: 'raster' } & RasterOptions & { before?: Layer })\n | ({ type: 'ground' } & GroundOptions & { before?: Layer })\n | ({ type: 'network' } & NetworkOptions)\n | ({ type: 'tiles3d' } & Tiles3dOptions)\n | ({ type: 'pointcloud' } & PointCloudOptions & { before?: Layer })\n | ({ type: 'models' } & ModelOptions & { before?: Layer })\n | ({ type: 'trees' } & TreeOptions<P>)\n | ({ type: 'flow' } & FlowOptions);\n\n/** Adds the layer a description gives with the `add…` method of its type; an unknown type throws */\nexport const addSpec = <P = Record<string, unknown>>(map: GeoMap, spec: LayerSpec<P>): Layer => {\n switch (spec.type) {\n case 'lines':\n return map.addLines<P>(spec);\n case 'circles':\n return map.addCircles<P>(spec);\n case 'fills':\n return map.addFills<P>(spec);\n case 'symbols':\n return map.addSymbols<P>(spec);\n case 'extrusions':\n return map.addExtrusions<P>(spec);\n case 'raster':\n return map.addRaster(spec);\n case 'ground':\n return map.addGround(spec);\n case 'network':\n return map.addNetwork(spec);\n case 'tiles3d':\n return map.addTiles3d(spec);\n case 'pointcloud':\n return map.addPointCloud(spec);\n case 'models':\n return map.addModels(spec);\n case 'trees':\n return map.addTrees<P>(spec);\n case 'flow':\n return map.addFlow(spec);\n default: {\n // Only from an application's configuration, untyped: the cases above cover every type\n const { type }: { type?: unknown } = spec;\n\n throw new Error(`isard: no layer of type ${String(type)}`);\n }\n }\n};\n"]}
|
package/dist/map/workers.js
CHANGED
|
@@ -33,6 +33,9 @@ export class MapWorkers {
|
|
|
33
33
|
* another count or URL
|
|
34
34
|
*/
|
|
35
35
|
pool(count, url) {
|
|
36
|
+
// Workers started after the map went would never be stopped
|
|
37
|
+
if (this.gone())
|
|
38
|
+
throw new Error('isard: the map was destroyed');
|
|
36
39
|
const shared = defaultWorkerCount();
|
|
37
40
|
const workers = Math.max(1, count ?? shared);
|
|
38
41
|
const workerUrl = url ?? this.url;
|
package/dist/map/workers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/map/workers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAwC,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAa,MAAM,EAAE,MAAM,aAAa,CAAC;AAIhD,iDAAiD;AACjD,MAAM,OAAO,UAAU;IACrB,iCAAiC;IACxB,GAAG,CAAe;IACV,OAAO,CAA2B;IACnD,gEAAgE;IAC/C,IAAI,CA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AC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;iBACxG,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACxB,0GAA0G;gBAC1G,qCAAqC;gBACrC,IAAI,MAAM,EAAE,OAAO,IAAI,KAAK,EAAE,UAAU,KAAK,CAAC;oBAAE,MAAM,KAAK,CAAC;gBAE5D,OAAO,MAAM,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QAEvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACK,YAAY;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAClG,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,eAAe,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAE9F,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and\n * reprojects rasters off the page; and the loaders of the relief, one per tile source.\n */\n\nimport type { RemoteReprojection } from '../basemap/grid.ts';\nimport { encodedTerrainLoader, type PngEncoding, type RemoteHeights } from '../basemap/terrain.ts';\nimport { BasemapWorkers, defaultWorkerCount } from '../basemap/workerpool.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport { decodeGrids } from '../grid-module.ts';\nimport { type Grid, gridOf } from '../grids.ts';\nimport type { TerrainLoader } from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\n\n/** The workers of a map, created on first use */\nexport class MapWorkers {\n /** URL of the workers' script */\n readonly url: string | URL;\n private readonly workers: GeoMapOptions['workers'];\n /** The map is destroyed: nothing more is sent to the workers */\n private readonly gone: () => boolean;\n /** Whose requests the workers' answer (cancelled together) */\n private readonly owner: object;\n /** The shared pool, created on first use */\n private shared: BasemapWorkers | undefined;\n /** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its\n * tiles when only the exaggeration changes) */\n private readonly terrainLoaders = new Map<string, TerrainLoader>();\n\n /** `workers`: the map's option (false or 0, no worker); `owner`: the map */\n constructor(url: string | URL, workers: GeoMapOptions['workers'], gone: () => boolean, owner: object) {\n this.url = url;\n this.workers = workers;\n this.gone = gone;\n this.owner = owner;\n }\n\n /**\n * The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for\n * another count or URL\n */\n pool(count?: number, url?: string | URL): { pool: BasemapWorkers; own: boolean } {\n const shared = defaultWorkerCount();\n const workers = Math.max(1, count ?? shared);\n const workerUrl = url ?? this.url;\n\n if (workers === shared && String(workerUrl) === String(this.url)) {\n this.shared ??= new BasemapWorkers(shared, this.url);\n\n return { pool: this.shared, own: false };\n }\n\n return { pool: new BasemapWorkers(workers, workerUrl), own: true };\n }\n\n /** Stops the shared pool */\n terminate(): void {\n this.shared?.terminate();\n this.shared = undefined;\n }\n\n /** Rasters reprojected by the workers (in the page without them) */\n readonly remoteReprojection: RemoteReprojection = (job, tile, signal) =>\n this.decodingPool()?.reproject(job, tile, signal, this.owner);\n\n /** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */\n readonly terrainLoader = (url: string, encoding: PngEncoding, floor?: number): TerrainLoader => {\n const key = `${encoding} ${floor ?? ''} ${url}`;\n const cached = this.terrainLoaders.get(key);\n\n if (cached) return cached;\n\n const loader = encodedTerrainLoader(url, encoding, floor, this.remoteHeights);\n\n this.terrainLoaders.set(key, loader);\n\n return loader;\n };\n\n private readonly remoteHeights: RemoteHeights = (url, encoding, floor, tile, signal) =>\n this.decodingPool()?.heights(url, encoding, floor, tile, signal, this.owner);\n\n /** A GRIB2 or NetCDF file read into grids by the grid module (`module`), in a worker (in the page without them, or if\n * the worker fails) */\n async readGrids(\n source: string | URL | ArrayBuffer | Uint8Array,\n module: string,\n signal?: AbortSignal,\n ): Promise<Grid[]> {\n const pool = this.decodingPool();\n const url = typeof source === 'string' || source instanceof URL ? String(source) : undefined;\n const copy = source instanceof Uint8Array ? source.slice().buffer : undefined;\n const bytes = copy ?? (source instanceof ArrayBuffer ? source : undefined);\n // Against the page: the workers fetch it, and a relative URL would be theirs\n const absolute = url && typeof document !== 'undefined' ? new URL(url, document.baseURI).href : url;\n const fetchFile = async (at: string) => {\n const response = await fetch(at, withHeaders(at, signal ? { signal } : {}));\n\n if (!response.ok) throw new Error(`isard: ${at}: ${response.status}`);\n\n return response.arrayBuffer();\n };\n const inPage = async () => decodeGrids(new Uint8Array(bytes ?? (await fetchFile(absolute ?? ''))), module);\n const read = async () => {\n if (!pool) return inPage();\n\n return pool\n .grids(absolute ? { url: absolute } : { bytes: bytes ?? new ArrayBuffer(0) }, module, signal, this.owner)\n .catch((error: unknown) => {\n // A worker's failure (the module not fetched, a worker of an older build): read again in the page, unless\n // cancelled or its bytes handed over\n if (signal?.aborted || bytes?.byteLength === 0) throw error;\n\n return inPage();\n });\n };\n const { grids, values } = await read();\n\n return grids.map((g, i) => gridOf(g, values[i] ?? new Float32Array()));\n }\n\n /**\n * The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers\n * (`workers: false` or 0, or none in this browser): that is done in the page then\n */\n private decodingPool(): BasemapWorkers | undefined {\n const workers = this.workers;\n\n if (this.gone() || workers === false || (workers !== undefined && workers <= 0)) return undefined;\n if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') return undefined;\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AO,CAAC;QAE7B,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAClG,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,eAAe,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAE9F,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and\n * reprojects rasters off the page; and the loaders of the relief, one per tile source.\n */\n\nimport type { RemoteReprojection } from '../basemap/grid.ts';\nimport { encodedTerrainLoader, type PngEncoding, type RemoteHeights } from '../basemap/terrain.ts';\nimport { BasemapWorkers, defaultWorkerCount } from '../basemap/workerpool.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport { decodeGrids } from '../grid-module.ts';\nimport { type Grid, gridOf } from '../grids.ts';\nimport type { TerrainLoader } from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\n\n/** The workers of a map, created on first use */\nexport class MapWorkers {\n /** URL of the workers' script */\n readonly url: string | URL;\n private readonly workers: GeoMapOptions['workers'];\n /** The map is destroyed: nothing more is sent to the workers */\n private readonly gone: () => boolean;\n /** Whose requests the workers' answer (cancelled together) */\n private readonly owner: object;\n /** The shared pool, created on first use */\n private shared: BasemapWorkers | undefined;\n /** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its\n * tiles when only the exaggeration changes) */\n private readonly terrainLoaders = new Map<string, TerrainLoader>();\n\n /** `workers`: the map's option (false or 0, no worker); `owner`: the map */\n constructor(url: string | URL, workers: GeoMapOptions['workers'], gone: () => boolean, owner: object) {\n this.url = url;\n this.workers = workers;\n this.gone = gone;\n this.owner = owner;\n }\n\n /**\n * The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for\n * another count or URL\n */\n pool(count?: number, url?: string | URL): { pool: BasemapWorkers; own: boolean } {\n // Workers started after the map went would never be stopped\n if (this.gone()) throw new Error('isard: the map was destroyed');\n\n const shared = defaultWorkerCount();\n const workers = Math.max(1, count ?? shared);\n const workerUrl = url ?? this.url;\n\n if (workers === shared && String(workerUrl) === String(this.url)) {\n this.shared ??= new BasemapWorkers(shared, this.url);\n\n return { pool: this.shared, own: false };\n }\n\n return { pool: new BasemapWorkers(workers, workerUrl), own: true };\n }\n\n /** Stops the shared pool */\n terminate(): void {\n this.shared?.terminate();\n this.shared = undefined;\n }\n\n /** Rasters reprojected by the workers (in the page without them) */\n readonly remoteReprojection: RemoteReprojection = (job, tile, signal) =>\n this.decodingPool()?.reproject(job, tile, signal, this.owner);\n\n /** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */\n readonly terrainLoader = (url: string, encoding: PngEncoding, floor?: number): TerrainLoader => {\n const key = `${encoding} ${floor ?? ''} ${url}`;\n const cached = this.terrainLoaders.get(key);\n\n if (cached) return cached;\n\n const loader = encodedTerrainLoader(url, encoding, floor, this.remoteHeights);\n\n this.terrainLoaders.set(key, loader);\n\n return loader;\n };\n\n private readonly remoteHeights: RemoteHeights = (url, encoding, floor, tile, signal) =>\n this.decodingPool()?.heights(url, encoding, floor, tile, signal, this.owner);\n\n /** A GRIB2 or NetCDF file read into grids by the grid module (`module`), in a worker (in the page without them, or if\n * the worker fails) */\n async readGrids(\n source: string | URL | ArrayBuffer | Uint8Array,\n module: string,\n signal?: AbortSignal,\n ): Promise<Grid[]> {\n const pool = this.decodingPool();\n const url = typeof source === 'string' || source instanceof URL ? String(source) : undefined;\n const copy = source instanceof Uint8Array ? source.slice().buffer : undefined;\n const bytes = copy ?? (source instanceof ArrayBuffer ? source : undefined);\n // Against the page: the workers fetch it, and a relative URL would be theirs\n const absolute = url && typeof document !== 'undefined' ? new URL(url, document.baseURI).href : url;\n const fetchFile = async (at: string) => {\n const response = await fetch(at, withHeaders(at, signal ? { signal } : {}));\n\n if (!response.ok) throw new Error(`isard: ${at}: ${response.status}`);\n\n return response.arrayBuffer();\n };\n const inPage = async () => decodeGrids(new Uint8Array(bytes ?? (await fetchFile(absolute ?? ''))), module);\n const read = async () => {\n if (!pool) return inPage();\n\n return pool\n .grids(absolute ? { url: absolute } : { bytes: bytes ?? new ArrayBuffer(0) }, module, signal, this.owner)\n .catch((error: unknown) => {\n // A worker's failure (the module not fetched, a worker of an older build): read again in the page, unless\n // cancelled or its bytes handed over\n if (signal?.aborted || bytes?.byteLength === 0) throw error;\n\n return inPage();\n });\n };\n const { grids, values } = await read();\n\n return grids.map((g, i) => gridOf(g, values[i] ?? new Float32Array()));\n }\n\n /**\n * The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers\n * (`workers: false` or 0, or none in this browser): that is done in the page then\n */\n private decodingPool(): BasemapWorkers | undefined {\n const workers = this.workers;\n\n if (this.gone() || workers === false || (workers !== undefined && workers <= 0)) return undefined;\n if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') return undefined;\n\n return this.pool().pool;\n }\n}\n"]}
|
package/dist/map.d.ts
CHANGED
|
@@ -14,8 +14,10 @@ import { FlowLayer, type FlowOptions } from './layers/flow.ts';
|
|
|
14
14
|
import type { ImageOptions, Pixels } from './layers/icons.ts';
|
|
15
15
|
import { CustomLayer, type CustomLayerInterface, GroundLayer, type GroundOptions, type Layer, ModelLayer, type ModelOptions, NetworkLayer, RasterLayer, Tiles3dLayer } from './layers/layers.ts';
|
|
16
16
|
import { type PanoramaOptions, type Panoramas } from './layers/panoramas.ts';
|
|
17
|
+
import { type PhotoOptions } from './layers/photos.ts';
|
|
17
18
|
import { PointCloudLayer, type PointCloudOptions } from './layers/pointclouds.ts';
|
|
18
19
|
import { SymbolLayer, type SymbolOptions } from './layers/symbols.ts';
|
|
20
|
+
import { type TreeOptions } from './layers/trees.ts';
|
|
19
21
|
import { type HoverPicking } from './map/hover-pick.ts';
|
|
20
22
|
import { type LayerSpec } from './map/layer-spec.ts';
|
|
21
23
|
import type { AnimationOptions, AtmosphereOptions, Basemap, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, NetworkOptions, Point, Projection, RasterOptions, SunOptions, SwipeOptions, TerrainModel, TerrainOptions, Tiles3dOptions, ViewshedOptions } from './types.ts';
|
|
@@ -327,6 +329,12 @@ export declare class GeoMap {
|
|
|
327
329
|
addModels(options: ModelOptions & {
|
|
328
330
|
before?: Layer;
|
|
329
331
|
}): ModelLayer;
|
|
332
|
+
/** Trees at the points of a source that has them (a city's street trees), broadleaved or conifers by their data,
|
|
333
|
+
* scaled to their height (see `TreeOptions`); the conifers on a layer that goes with the one returned */
|
|
334
|
+
addTrees<P = Record<string, unknown>>(options: TreeOptions<P>): ModelLayer;
|
|
335
|
+
/** A photo standing where it was taken, facing its way (see `PhotoOptions`): flat on a frame across its field of
|
|
336
|
+
* view, a 360° one on a band round its camera; resolves once its image is read */
|
|
337
|
+
addPhoto(options: PhotoOptions): Promise<ModelLayer>;
|
|
330
338
|
/**
|
|
331
339
|
* The page's own WebGL drawing at its place among the layers, in every frame (see `CustomLayerInterface`): raw
|
|
332
340
|
* WebGL, three.js… with the matrices of the frame (`frame.matrixAt`); under `before` if given
|
package/dist/map.js
CHANGED
|
@@ -17,8 +17,10 @@ import { CircleLayer, circleStyle, FillLayer, fillStyle, LineLayer, lineStyle, }
|
|
|
17
17
|
import { FlowLayer } from "./layers/flow.js";
|
|
18
18
|
import { CustomLayer, GroundLayer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from "./layers/layers.js";
|
|
19
19
|
import { loadPanoramas } from "./layers/panoramas.js";
|
|
20
|
+
import { addPhoto } from "./layers/photos.js";
|
|
20
21
|
import { PointCloudLayer } from "./layers/pointclouds.js";
|
|
21
22
|
import { SymbolLayer, symbolStyle } from "./layers/symbols.js";
|
|
23
|
+
import { addTrees } from "./layers/trees.js";
|
|
22
24
|
import { VectorLayer } from "./layers/vectors.js";
|
|
23
25
|
import { BasemapLayers } from "./map/basemap-layers.js";
|
|
24
26
|
import { createCanvas, labelCanvas, watchContext, watchPixelRatio } from "./map/canvas.js";
|
|
@@ -679,10 +681,11 @@ export class GeoMap {
|
|
|
679
681
|
/** @internal A layer made anew from its description, in the place of `old` in the drawing order (old removed) */
|
|
680
682
|
rebuildLayer(old, spec) {
|
|
681
683
|
const index = this.layers.indexOf(old);
|
|
682
|
-
|
|
684
|
+
// The first layer above that goes not with it: its companions are removed with it
|
|
685
|
+
const above = index >= 0 ? this.layers.slice(index + 1).find((l) => !old.companions.includes(l)) : undefined;
|
|
683
686
|
const layer = this.add(spec);
|
|
684
687
|
if (!('before' in spec && spec.before) && index >= 0)
|
|
685
|
-
|
|
688
|
+
layer.moveBefore(above);
|
|
686
689
|
old.remove();
|
|
687
690
|
return layer;
|
|
688
691
|
}
|
|
@@ -816,6 +819,16 @@ export class GeoMap {
|
|
|
816
819
|
addModels(options) {
|
|
817
820
|
return this.place(new ModelLayer(this, options), options.before);
|
|
818
821
|
}
|
|
822
|
+
/** Trees at the points of a source that has them (a city's street trees), broadleaved or conifers by their data,
|
|
823
|
+
* scaled to their height (see `TreeOptions`); the conifers on a layer that goes with the one returned */
|
|
824
|
+
addTrees(options) {
|
|
825
|
+
return addTrees((o) => this.addModels(o), options);
|
|
826
|
+
}
|
|
827
|
+
/** A photo standing where it was taken, facing its way (see `PhotoOptions`): flat on a frame across its field of
|
|
828
|
+
* view, a 360° one on a band round its camera; resolves once its image is read */
|
|
829
|
+
addPhoto(options) {
|
|
830
|
+
return addPhoto((o) => this.addModels(o), options);
|
|
831
|
+
}
|
|
819
832
|
/**
|
|
820
833
|
* The page's own WebGL drawing at its place among the layers, in every frame (see `CustomLayerInterface`): raw
|
|
821
834
|
* WebGL, three.js… with the matrices of the frame (`frame.matrixAt`); under `before` if given
|