isard 1.15.0 → 2.0.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 +70 -0
- package/README.md +4 -4
- 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/workerpool.d.ts +1 -1
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/bind/layers.js +3 -1
- 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_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.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 +20 -13
- package/dist/layers/ground.js +29 -8
- 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 +2 -11
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/models.js +0 -4
- 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 +1 -1
- package/dist/layers/pointclouds.js +0 -4
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/raster.js +2 -2
- package/dist/layers/raster.js.map +1 -1
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/tiles3d.d.ts +6 -2
- package/dist/layers/tiles3d.js +23 -5
- package/dist/layers/tiles3d.js.map +1 -1
- package/dist/layers/vectors.d.ts +4 -5
- package/dist/layers/vectors.js +7 -15
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/engine-settings.d.ts +1 -1
- 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 +2 -2
- package/dist/map/layer-stack.js +1 -3
- 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 +26 -20
- package/dist/map.js +97 -82
- 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/index.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +49 -18
- 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} +375 -184
- package/dist/wasm/{isard_core.js → isard_webgl2.js} +2167 -415
- package/dist/wasm/{isard.d.ts → isard_webgpu.d.ts} +183 -355
- package/dist/wasm/{isard.js → isard_webgpu.js} +1374 -1097
- 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/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAiB5E,OAAO,EAAE,QAAQ,EAAuB,MAAM,kCAAkC,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAsB,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OA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AmC,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAsB,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,aAAa,EAGb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAuCxB,OAAO,EACL,kBAAkB,EAIlB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAEL,MAAM,EAIN,KAAK,EAEL,KAAK,GAGN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/models/trees.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport { isStreet, type VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorRasterOptions, VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './decoding/decoders.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { CustomFrame, CustomLayerInterface } from './layers/custom.ts';\nexport { CustomLayer } from './layers/custom.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { GroundOptions, GroundTexture, GroundUniform } from './layers/ground.ts';\nexport { GroundLayer } from './layers/ground.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport { Layer } from './layers/layers.ts';\nexport type { ModelInstance, ModelOptions } from './layers/models.ts';\nexport { ModelLayer } from './layers/models.ts';\nexport { NetworkLayer } from './layers/network.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport { RasterLayer } from './layers/raster.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { Tiles3dLayer } from './layers/tiles3d.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n type PanoramaxSequenceOptions,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureColor,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapGpuTimings,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n PickOptions,\n Placement,\n Point,\n Projection,\n Quality,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dDrape,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { setRequestHeaders } from './util/requests.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard_webgpu.js';\n"]}
|
package/dist/isard_tess_bg.wasm
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/layers/custom.d.ts
CHANGED
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
/** The page's own
|
|
1
|
+
/** The page's own WebGPU drawing as a layer, called in every frame with the map's matrices and targets */
|
|
2
2
|
import type { GeoMap } from '../map.ts';
|
|
3
3
|
import type { LonLat } from '../types.ts';
|
|
4
|
-
import type { Camera } from '../wasm/
|
|
4
|
+
import type { Camera } from '../wasm/isard_webgpu.js';
|
|
5
5
|
import { Layer } from './layers.ts';
|
|
6
6
|
/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */
|
|
7
7
|
export interface CustomFrame {
|
|
8
8
|
/**
|
|
9
9
|
* The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the
|
|
10
|
-
* relief is drawn: times its exaggeration), column-major
|
|
11
|
-
* north, z up, in metres. Made in double precision relative to the camera, so that what is
|
|
12
|
-
* any zoom; draw within a few kilometres of the position (or take one matrix per object far
|
|
13
|
-
* `render`.
|
|
10
|
+
* relief is drawn: times its exaggeration), column-major, WebGPU's clip depth (0 to 1, as three.js's WebGPU renderer
|
|
11
|
+
* takes it): x east, y north, z up, in metres. Made in double precision relative to the camera, so that what is
|
|
12
|
+
* drawn stays exact at any zoom; draw within a few kilometres of the position (or take one matrix per object far
|
|
13
|
+
* apart). Only during `render`.
|
|
14
14
|
*/
|
|
15
15
|
matrixAt(lonLat: LonLat, altitude?: number): Float32Array;
|
|
16
16
|
/** The camera of the frame */
|
|
17
17
|
readonly camera: Camera;
|
|
18
|
+
/** Where to draw: a texture at the canvas's size (`width` × `height` device pixels), cleared, laid over the frame at
|
|
19
|
+
* the layer's place, its alpha premultiplied */
|
|
20
|
+
readonly color: GPUTexture;
|
|
21
|
+
readonly format: 'rgba8unorm';
|
|
22
|
+
/** In the `'3d'` mode, the depth of the solid scene (the relief, the buildings, the 3D Tiles) to test against
|
|
23
|
+
* (`depthLoadOp: 'load'`): what it hides of what is drawn is hidden. Copyable into a library's own depth target */
|
|
24
|
+
readonly depth: GPUTexture | undefined;
|
|
25
|
+
readonly depthFormat: 'depth32float';
|
|
26
|
+
readonly width: number;
|
|
27
|
+
readonly height: number;
|
|
18
28
|
}
|
|
19
29
|
/**
|
|
20
|
-
* A layer drawn by the page with its own
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).
|
|
30
|
+
* A layer drawn by the page with its own WebGPU code, on the map's `GPUDevice`: before every frame's pass, `render`
|
|
31
|
+
* encodes and submits its passes into the layer's color texture (and tests against the scene's depth in the `'3d'`
|
|
32
|
+
* mode); what it draws is laid over the frame at the layer's place. The map is busy drawing meanwhile: `render` reads
|
|
33
|
+
* the frame, not the map (`getCamera` excepted); it may call `requestRender` for an animation.
|
|
25
34
|
*
|
|
26
|
-
*
|
|
27
|
-
* `requestRender` for an animation.
|
|
35
|
+
* On a browser without WebGPU (the map on its WebGL2 fallback) custom layers are not drawn: the console says so once.
|
|
28
36
|
*/
|
|
29
37
|
export interface CustomLayerInterface {
|
|
30
38
|
/** A name for the application (the map numbers its layers) */
|
|
31
39
|
id?: string;
|
|
32
|
-
/** `'2d'` (the default): drawn over what is under it; `'3d'`:
|
|
40
|
+
/** `'2d'` (the default): drawn over what is under it; `'3d'`: tested against the depth of the solid scene */
|
|
33
41
|
renderingMode?: '2d' | '3d';
|
|
34
|
-
/** Creates the
|
|
35
|
-
onAdd?(
|
|
36
|
-
render(
|
|
37
|
-
/** Frees the
|
|
38
|
-
onRemove?(
|
|
42
|
+
/** Creates the GPU objects: once added, and again on the device of a new engine (the GPU lost and given back) */
|
|
43
|
+
onAdd?(device: GPUDevice, map: GeoMap): void;
|
|
44
|
+
render(device: GPUDevice, frame: CustomFrame): void;
|
|
45
|
+
/** Frees the GPU objects: the layer is removed, or the map destroyed */
|
|
46
|
+
onRemove?(device: GPUDevice, map: GeoMap): void;
|
|
39
47
|
}
|
|
40
|
-
/** A layer drawn by the page's
|
|
48
|
+
/** A layer drawn by the page's WebGPU code (see `CustomLayerInterface`) */
|
|
41
49
|
export declare class CustomLayer extends Layer {
|
|
42
50
|
/** The application's object */
|
|
43
51
|
readonly implementation: CustomLayerInterface;
|
|
44
|
-
private readonly canvas;
|
|
45
52
|
private readonly owner;
|
|
46
|
-
/** The
|
|
47
|
-
private
|
|
48
|
-
private
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */
|
|
53
|
+
/** The device `onAdd` made the layer's objects on (until `onRemove`), and whether it was lost since */
|
|
54
|
+
private device;
|
|
55
|
+
private lost;
|
|
56
|
+
private readonly matrix;
|
|
57
|
+
private readonly camera;
|
|
58
|
+
/** Called by the engine before the frame's pass with the layer's targets; the page's errors are reported, the frame
|
|
59
|
+
* goes on */
|
|
54
60
|
private readonly draw;
|
|
55
61
|
remove(): void;
|
|
56
62
|
}
|
package/dist/layers/custom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The page's own
|
|
1
|
+
/** The page's own WebGPU drawing as a layer, called in every frame with the map's matrices and targets */
|
|
2
2
|
import { Layer } from "./layers.js";
|
|
3
3
|
// ── The page's own 3D content: custom layers, glTF models ──
|
|
4
4
|
/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */
|
|
@@ -10,61 +10,75 @@ const report = (error) => {
|
|
|
10
10
|
throw error;
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
13
|
+
/** The page warned once that custom layers need WebGPU */
|
|
14
|
+
let warned = false;
|
|
15
|
+
/** A layer drawn by the page's WebGPU code (see `CustomLayerInterface`) */
|
|
14
16
|
export class CustomLayer extends Layer {
|
|
15
17
|
implementation;
|
|
16
|
-
canvas;
|
|
17
18
|
owner;
|
|
18
|
-
/** The
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
lost = () => {
|
|
24
|
-
this.stale = true;
|
|
25
|
-
};
|
|
26
|
-
frame;
|
|
19
|
+
/** The device `onAdd` made the layer's objects on (until `onRemove`), and whether it was lost since */
|
|
20
|
+
device;
|
|
21
|
+
lost = false;
|
|
22
|
+
matrix;
|
|
23
|
+
camera;
|
|
27
24
|
/** @internal */
|
|
28
25
|
constructor(map,
|
|
29
26
|
/** The application's object */
|
|
30
|
-
implementation,
|
|
27
|
+
implementation, owner, matrix, camera) {
|
|
31
28
|
super(map);
|
|
32
29
|
this.implementation = implementation;
|
|
33
|
-
this.canvas = canvas;
|
|
34
30
|
this.owner = owner;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!gl)
|
|
38
|
-
throw new Error('isard: a custom layer needs the WebGL2 context of the map');
|
|
39
|
-
this.gl = gl;
|
|
40
|
-
this.frame = {
|
|
41
|
-
matrixAt: ([lon, lat], altitude = 0) => {
|
|
42
|
-
const m = matrix(lon, lat, altitude);
|
|
43
|
-
if (!m)
|
|
44
|
-
throw new Error('isard: frame.matrixAt is only available during render');
|
|
45
|
-
return m;
|
|
46
|
-
},
|
|
47
|
-
get camera() {
|
|
48
|
-
return camera();
|
|
49
|
-
},
|
|
50
|
-
};
|
|
31
|
+
this.matrix = matrix;
|
|
32
|
+
this.camera = camera;
|
|
51
33
|
}
|
|
52
34
|
/** @internal */
|
|
53
35
|
create(engine) {
|
|
54
|
-
|
|
55
|
-
if (!
|
|
56
|
-
if (!
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
const device = engine.gpuDevice();
|
|
37
|
+
if (!device) {
|
|
38
|
+
if (!warned)
|
|
39
|
+
console.warn('isard: custom layers need WebGPU; on its WebGL2 fallback, the map does not draw them');
|
|
40
|
+
warned = true;
|
|
41
|
+
}
|
|
42
|
+
else if (device !== this.device) {
|
|
43
|
+
// Once, and again on the device of a new engine (its objects gone with the old one)
|
|
44
|
+
this.device = device;
|
|
45
|
+
this.lost = false;
|
|
46
|
+
device.lost.then(() => {
|
|
47
|
+
if (this.device === device)
|
|
48
|
+
this.lost = true;
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
this.implementation.onAdd?.(device, this.owner);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
report(error);
|
|
55
|
+
}
|
|
61
56
|
}
|
|
62
57
|
return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');
|
|
63
58
|
}
|
|
64
|
-
/** Called by the engine
|
|
65
|
-
|
|
59
|
+
/** Called by the engine before the frame's pass with the layer's targets; the page's errors are reported, the frame
|
|
60
|
+
* goes on */
|
|
61
|
+
draw = (target) => {
|
|
62
|
+
const { matrix } = this;
|
|
63
|
+
const camera = this.camera;
|
|
66
64
|
try {
|
|
67
|
-
this.implementation.render(
|
|
65
|
+
this.implementation.render(target.device, {
|
|
66
|
+
matrixAt: ([lon, lat], altitude = 0) => {
|
|
67
|
+
const m = matrix(lon, lat, altitude);
|
|
68
|
+
if (!m)
|
|
69
|
+
throw new Error('isard: frame.matrixAt is only available during render');
|
|
70
|
+
return m;
|
|
71
|
+
},
|
|
72
|
+
get camera() {
|
|
73
|
+
return camera();
|
|
74
|
+
},
|
|
75
|
+
color: target.color,
|
|
76
|
+
format: target.format,
|
|
77
|
+
depth: target.depth,
|
|
78
|
+
depthFormat: target.depthFormat,
|
|
79
|
+
width: target.width,
|
|
80
|
+
height: target.height,
|
|
81
|
+
});
|
|
68
82
|
}
|
|
69
83
|
catch (error) {
|
|
70
84
|
report(error);
|
|
@@ -74,16 +88,16 @@ export class CustomLayer extends Layer {
|
|
|
74
88
|
super.remove();
|
|
75
89
|
this.dispose();
|
|
76
90
|
}
|
|
77
|
-
/** @internal The layer is removed or the map destroyed: `onRemove`, unless
|
|
91
|
+
/** @internal The layer is removed or the map destroyed: `onRemove`, unless its device is lost */
|
|
78
92
|
dispose() {
|
|
79
|
-
|
|
93
|
+
const device = this.device;
|
|
94
|
+
if (!device)
|
|
80
95
|
return;
|
|
81
|
-
this.
|
|
82
|
-
|
|
83
|
-
if (this.stale)
|
|
96
|
+
this.device = undefined;
|
|
97
|
+
if (this.lost)
|
|
84
98
|
return;
|
|
85
99
|
try {
|
|
86
|
-
this.implementation.onRemove?.(
|
|
100
|
+
this.implementation.onRemove?.(device, this.owner);
|
|
87
101
|
}
|
|
88
102
|
catch (error) {
|
|
89
103
|
report(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/layers/custom.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/layers/custom.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAK1G,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,8DAA8D;AAE9D,sGAAsG;AACtG,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IACtC,IAAI,OAAO,WAAW,KAAK,UAAU;QAAE,WAAW,CAAC,KAAK,CAAC,CAAC;;QAExD,cAAc,CAAC,GAAG,EAAE;YAClB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAkDF,0DAA0D;AAC1D,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,2EAA2E;AAC3E,MAAM,OAAO,WAAY,SAAQ,KAAK;IAWzB;IACQ;IAXnB,uGAAuG;IAC/F,MAAM,CAAwB;IAC9B,IAAI,GAAG,KAAK,CAAC;IACJ,MAAM,CAAe;IACrB,MAAM,CAAe;IAEtC,gBAAgB;IAChB,YACE,GAA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IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;CACF","sourcesContent":["/** The page's own WebGPU drawing as a layer, called in every frame with the map's matrices and targets */\n\nimport type { GeoMap } from '../map.ts';\nimport type { LayerHost, LonLat } from '../types.ts';\nimport type { Camera, CustomTarget, Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\n\n// ── The page's own 3D content: custom layers, glTF models ──\n\n/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */\nconst report = (error: unknown): void => {\n if (typeof reportError === 'function') reportError(error);\n else\n queueMicrotask(() => {\n throw error;\n });\n};\n\n/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */\nexport interface CustomFrame {\n /**\n * The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the\n * relief is drawn: times its exaggeration), column-major, WebGPU's clip depth (0 to 1, as three.js's WebGPU renderer\n * takes it): x east, y north, z up, in metres. Made in double precision relative to the camera, so that what is\n * drawn stays exact at any zoom; draw within a few kilometres of the position (or take one matrix per object far\n * apart). Only during `render`.\n */\n matrixAt(lonLat: LonLat, altitude?: number): Float32Array;\n /** The camera of the frame */\n readonly camera: Camera;\n /** Where to draw: a texture at the canvas's size (`width` × `height` device pixels), cleared, laid over the frame at\n * the layer's place, its alpha premultiplied */\n readonly color: GPUTexture;\n readonly format: 'rgba8unorm';\n /** In the `'3d'` mode, the depth of the solid scene (the relief, the buildings, the 3D Tiles) to test against\n * (`depthLoadOp: 'load'`): what it hides of what is drawn is hidden. Copyable into a library's own depth target */\n readonly depth: GPUTexture | undefined;\n readonly depthFormat: 'depth32float';\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * A layer drawn by the page with its own WebGPU code, on the map's `GPUDevice`: before every frame's pass, `render`\n * encodes and submits its passes into the layer's color texture (and tests against the scene's depth in the `'3d'`\n * mode); what it draws is laid over the frame at the layer's place. The map is busy drawing meanwhile: `render` reads\n * the frame, not the map (`getCamera` excepted); it may call `requestRender` for an animation.\n *\n * On a browser without WebGPU (the map on its WebGL2 fallback) custom layers are not drawn: the console says so once.\n */\nexport interface CustomLayerInterface {\n /** A name for the application (the map numbers its layers) */\n id?: string;\n /** `'2d'` (the default): drawn over what is under it; `'3d'`: tested against the depth of the solid scene */\n renderingMode?: '2d' | '3d';\n /** Creates the GPU objects: once added, and again on the device of a new engine (the GPU lost and given back) */\n onAdd?(device: GPUDevice, map: GeoMap): void;\n render(device: GPUDevice, frame: CustomFrame): void;\n /** Frees the GPU objects: the layer is removed, or the map destroyed */\n onRemove?(device: GPUDevice, map: GeoMap): void;\n}\n\n/** The model-view-projection of a local frame in the engine running the map (`Engine.customMatrix`) */\n/** @internal */\nexport type CustomMatrix = (lon: number, lat: number, altitude: number) => Float32Array | undefined;\n\n/** The page warned once that custom layers need WebGPU */\nlet warned = false;\n\n/** A layer drawn by the page's WebGPU code (see `CustomLayerInterface`) */\nexport class CustomLayer extends Layer {\n /** The device `onAdd` made the layer's objects on (until `onRemove`), and whether it was lost since */\n private device: GPUDevice | undefined;\n private lost = false;\n private readonly matrix: CustomMatrix;\n private readonly camera: () => Camera;\n\n /** @internal */\n constructor(\n map: LayerHost,\n /** The application's object */\n readonly implementation: CustomLayerInterface,\n private readonly owner: GeoMap,\n matrix: CustomMatrix,\n camera: () => Camera,\n ) {\n super(map);\n this.matrix = matrix;\n this.camera = camera;\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const device = engine.gpuDevice();\n\n if (!device) {\n if (!warned) console.warn('isard: custom layers need WebGPU; on its WebGL2 fallback, the map does not draw them');\n warned = true;\n } else if (device !== this.device) {\n // Once, and again on the device of a new engine (its objects gone with the old one)\n this.device = device;\n this.lost = false;\n device.lost.then(() => {\n if (this.device === device) this.lost = true;\n });\n try {\n this.implementation.onAdd?.(device, this.owner);\n } catch (error) {\n report(error);\n }\n }\n\n return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');\n }\n\n /** Called by the engine before the frame's pass with the layer's targets; the page's errors are reported, the frame\n * goes on */\n private readonly draw = (target: CustomTarget): void => {\n const { matrix } = this;\n const camera = this.camera;\n\n try {\n this.implementation.render(target.device, {\n matrixAt: ([lon, lat], altitude = 0) => {\n const m = matrix(lon, lat, altitude);\n\n if (!m) throw new Error('isard: frame.matrixAt is only available during render');\n\n return m;\n },\n get camera() {\n return camera();\n },\n color: target.color,\n format: target.format,\n depth: target.depth,\n depthFormat: target.depthFormat,\n width: target.width,\n height: target.height,\n });\n } catch (error) {\n report(error);\n }\n };\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The layer is removed or the map destroyed: `onRemove`, unless its device is lost */\n override dispose(): void {\n const device = this.device;\n\n if (!device) return;\n this.device = undefined;\n if (this.lost) return;\n try {\n this.implementation.onRemove?.(device, this.owner);\n } catch (error) {\n report(error);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,QAAQ,EAIR,UAAU,EAEV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAmDpC,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IARO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAA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AC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost, Placement } from '../types.ts';\nimport { metresAt } from '../util/geo.ts';\nimport { roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { NetworkLayer } from './network.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C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AI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE3E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sGAAsG;IAC7F,MAAM,CAAC,MAAc;QAC5B,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,OAA4B,EAAqB,EAAE;IACnF,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost, Placement } from '../types.ts';\nimport { metresAt } from '../util/geo.ts';\nimport { roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { NetworkLayer } from './network.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
|