@tangram.gl/tangram-renderer 0.0.0-stage → 0.0.1
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/README.md +60 -2
- package/dist/core.js +36923 -0
- package/dist/core.js.map +6 -0
- package/dist/index.js +32 -0
- package/dist/loaders-gl-worker.js +82 -0
- package/dist/loaders-gl-worker.js.map +6 -0
- package/dist/map-logic.js +2 -0
- package/dist/map-logic.js.map +6 -0
- package/dist/projected-basemaps-worker.js +3 -0
- package/dist/projected-basemaps-worker.js.map +6 -0
- package/dist/shader-modules.js +141 -0
- package/dist/shader-modules.js.map +6 -0
- package/dist/style-schema.js +126 -0
- package/dist/style-schema.js.map +6 -0
- package/dist/tangram-style.schema.json +882 -0
- package/dist/tangram.debug.mjs +37139 -0
- package/dist/tangram.debug.mjs.map +6 -0
- package/dist/tangram.min.mjs +4950 -0
- package/dist/types/builders/earcut.d.ts +15 -0
- package/dist/types/core.d.ts +29 -0
- package/dist/types/gl/constants.d.ts +2 -0
- package/dist/types/gl/globe_mesh.d.ts +48 -0
- package/dist/types/gl/glsl.d.ts +17 -0
- package/dist/types/gl/vertex-constants.d.ts +4 -0
- package/dist/types/gl/vertex-types.d.ts +34 -0
- package/dist/types/gl/vertex_data.d.ts +32 -0
- package/dist/types/gl/vertex_elements.d.ts +8 -0
- package/dist/types/gl/vertex_layout.d.ts +32 -0
- package/dist/types/glsl.d.ts +14 -0
- package/dist/types/gpu/luma_device_renderer.d.ts +66 -0
- package/dist/types/gpu/resource_lifecycle.d.ts +4 -0
- package/dist/types/gpu/tangram_gpu_backend.d.ts +151 -0
- package/dist/types/index.d.ts +155 -0
- package/dist/types/lights/light-definitions.d.ts +121 -0
- package/dist/types/map-logic/draped-terrain-bounds.d.ts +41 -0
- package/dist/types/map-logic/globe-terrain-preparation.d.ts +85 -0
- package/dist/types/map-logic/globe-terrain.d.ts +54 -0
- package/dist/types/map-logic/index.d.ts +33 -0
- package/dist/types/map-logic/label-identity.d.ts +22 -0
- package/dist/types/map-logic/label-placement.d.ts +32 -0
- package/dist/types/map-logic/screen-bounds.d.ts +15 -0
- package/dist/types/map-logic/terrain-data.d.ts +55 -0
- package/dist/types/map-logic/terrain-error.d.ts +51 -0
- package/dist/types/map-logic/terrain-ground-topology.d.ts +26 -0
- package/dist/types/map-logic/terrain-height-field.d.ts +59 -0
- package/dist/types/map-logic/terrain-navigation.d.ts +27 -0
- package/dist/types/map-logic/terrain-neighborhood.d.ts +5 -0
- package/dist/types/map-logic/terrain-query.d.ts +33 -0
- package/dist/types/map-logic/terrain-resource-budget.d.ts +51 -0
- package/dist/types/map-logic/terrain-transition-topology.d.ts +23 -0
- package/dist/types/map-logic/tile-build-queue.d.ts +51 -0
- package/dist/types/map-logic/tile-cache-policy.d.ts +46 -0
- package/dist/types/map-logic/tile-residency.d.ts +17 -0
- package/dist/types/map-logic/triangle-query-index.d.ts +87 -0
- package/dist/types/procedures/js-yaml.d.ts +15 -0
- package/dist/types/procedures/mesh-projector.d.ts +107 -0
- package/dist/types/procedures/mvt-dependencies.d.ts +20 -0
- package/dist/types/procedures/projected-coordinate-transform.d.ts +27 -0
- package/dist/types/procedures/projection-batch-executor.d.ts +53 -0
- package/dist/types/procedures/scene-yaml-legacy.d.ts +6 -0
- package/dist/types/procedures/terrain-draping.d.ts +165 -0
- package/dist/types/procedures/terrain-globe.d.ts +6 -0
- package/dist/types/procedures/terrain-styled-topology.d.ts +34 -0
- package/dist/types/procedures/web-mercator-legacy.d.ts +4 -0
- package/dist/types/procedures/web-mercator-math.d.ts +4 -0
- package/dist/types/scene/globals.d.ts +11 -0
- package/dist/types/scene/ground_footprint.d.ts +16 -0
- package/dist/types/scene/host_frame.d.ts +54 -0
- package/dist/types/scene/projection_math.d.ts +52 -0
- package/dist/types/scene/scene-resource-types.d.ts +177 -0
- package/dist/types/scene/scene_bundle.d.ts +69 -0
- package/dist/types/scene/visibility_adapter.d.ts +106 -0
- package/dist/types/selection/draped-terrain-surface.d.ts +78 -0
- package/dist/types/selection/terrain_surface.d.ts +149 -0
- package/dist/types/shader-modules/globe-horizon.d.ts +15 -0
- package/dist/types/shader-modules/height-decode.d.ts +13 -0
- package/dist/types/shader-modules/hillshade.d.ts +13 -0
- package/dist/types/shader-modules/index.d.ts +6 -0
- package/dist/types/shader-modules/planar.d.ts +12 -0
- package/dist/types/shader-modules/sphere-map.d.ts +13 -0
- package/dist/types/shader-modules/triplanar.d.ts +15 -0
- package/dist/types/sources/decoded_tile_store.d.ts +95 -0
- package/dist/types/sources/tile_source_metadata.d.ts +32 -0
- package/dist/types/styles/text/fontfaceobserver.d.ts +10 -0
- package/dist/types/tile/tile_id.d.ts +37 -0
- package/dist/types/tile/tile_traversal_adapter.d.ts +63 -0
- package/dist/types/types.d.ts +293 -0
- package/dist/types/utils/geo.d.ts +57 -0
- package/dist/types/utils/hash.d.ts +1 -0
- package/dist/types/utils/log.d.ts +27 -0
- package/dist/types/utils/props.d.ts +6 -0
- package/dist/types/utils/subscribe.d.ts +10 -0
- package/dist/types/utils/thread.d.ts +6 -0
- package/dist/types/utils/urls.d.ts +26 -0
- package/dist/types/utils/utils.d.ts +26 -0
- package/dist/types/utils/version.d.ts +2 -0
- package/dist/types/utils/worker-types.d.ts +68 -0
- package/dist/types/utils/worker_broker.d.ts +3 -0
- package/package.json +103 -3
- package/src/builders/common.ts +41 -0
- package/src/builders/earcut.d.ts +15 -0
- package/src/builders/geometry-types.ts +60 -0
- package/src/builders/points.ts +115 -0
- package/src/builders/polygons.ts +225 -0
- package/src/builders/polylines.ts +682 -0
- package/src/builders/wireframe.ts +31 -0
- package/src/core.d.ts +29 -0
- package/src/core.ts +33 -0
- package/src/experimental/loaders-gl-worker.ts +19 -0
- package/src/experimental/projected-basemaps-worker.ts +13 -0
- package/src/experimental/projected-mesh-cache.ts +137 -0
- package/src/experimental/projected-mesh-domain.ts +110 -0
- package/src/experimental/projected-mesh-refinement.ts +193 -0
- package/src/experimental/projected-mesh.ts +399 -0
- package/src/experimental/projected-normal.ts +26 -0
- package/src/experimental/projected-symbol-mesh.ts +74 -0
- package/src/gl/constants.ts +18 -0
- package/src/gl/context.ts +103 -0
- package/src/gl/extensions.ts +30 -0
- package/src/gl/globe_mesh.ts +285 -0
- package/src/gl/glsl.ts +257 -0
- package/src/gl/mesh-types.ts +56 -0
- package/src/gl/render_state.ts +111 -0
- package/src/gl/shader_program.ts +1310 -0
- package/src/gl/texture.ts +814 -0
- package/src/gl/uniform_buffer.ts +340 -0
- package/src/gl/vao.ts +154 -0
- package/src/gl/vbo_mesh.ts +349 -0
- package/src/gl/vertex-constants.ts +19 -0
- package/src/gl/vertex-types.ts +35 -0
- package/src/gl/vertex_data.ts +126 -0
- package/src/gl/vertex_elements.ts +54 -0
- package/src/gl/vertex_layout.ts +241 -0
- package/src/glsl.d.ts +14 -0
- package/src/gpu/luma_device_renderer.ts +579 -0
- package/src/gpu/pixel_readback.ts +51 -0
- package/src/gpu/resource_lifecycle.ts +32 -0
- package/src/gpu/tangram_gpu_backend.ts +195 -0
- package/src/index.d.ts +155 -0
- package/src/index.ts +105 -0
- package/src/labels/collision-types.ts +94 -0
- package/src/labels/collision.ts +273 -0
- package/src/labels/collision_grid.ts +61 -0
- package/src/labels/intersect.ts +30 -0
- package/src/labels/label-types.ts +91 -0
- package/src/labels/label.ts +207 -0
- package/src/labels/label_line.ts +801 -0
- package/src/labels/label_point.ts +131 -0
- package/src/labels/main-pass-types.ts +73 -0
- package/src/labels/main_pass.ts +221 -0
- package/src/labels/point_anchor.ts +100 -0
- package/src/labels/point_placement.ts +150 -0
- package/src/labels/projected-pass.ts +259 -0
- package/src/labels/repeat_group.ts +72 -0
- package/src/lights/ambient_light.glsl +18 -0
- package/src/lights/directional_light.glsl +39 -0
- package/src/lights/geographic-lights.ts +21 -0
- package/src/lights/light-definitions.ts +285 -0
- package/src/lights/light.ts +590 -0
- package/src/lights/lighting-uniforms.ts +80 -0
- package/src/lights/lighting-wgsl.ts +116 -0
- package/src/lights/material.glsl +237 -0
- package/src/lights/material.ts +145 -0
- package/src/lights/native-falloff.ts +37 -0
- package/src/lights/point_light.glsl +96 -0
- package/src/lights/spot_light.glsl +111 -0
- package/src/map-logic/draped-terrain-bounds.ts +71 -0
- package/src/map-logic/globe-terrain-preparation.ts +217 -0
- package/src/map-logic/globe-terrain.ts +296 -0
- package/src/map-logic/index.ts +37 -0
- package/src/map-logic/label-identity.ts +36 -0
- package/src/map-logic/label-placement.ts +117 -0
- package/src/map-logic/screen-bounds.ts +34 -0
- package/src/map-logic/terrain-data.ts +107 -0
- package/src/map-logic/terrain-error.ts +134 -0
- package/src/map-logic/terrain-ground-topology.ts +164 -0
- package/src/map-logic/terrain-height-field.ts +254 -0
- package/src/map-logic/terrain-navigation.ts +50 -0
- package/src/map-logic/terrain-neighborhood.ts +43 -0
- package/src/map-logic/terrain-query.ts +51 -0
- package/src/map-logic/terrain-resource-budget.ts +124 -0
- package/src/map-logic/terrain-transition-topology.ts +164 -0
- package/src/map-logic/tile-build-queue.ts +110 -0
- package/src/map-logic/tile-cache-policy.ts +89 -0
- package/src/map-logic/tile-residency.ts +50 -0
- package/src/map-logic/triangle-query-index.ts +265 -0
- package/src/procedures/js-yaml.d.ts +15 -0
- package/src/procedures/mesh-projector.ts +191 -0
- package/src/procedures/mlt-loaders.ts +55 -0
- package/src/procedures/mvt-dependencies.d.ts +20 -0
- package/src/procedures/mvt-legacy.ts +150 -0
- package/src/procedures/mvt-loaders.ts +53 -0
- package/src/procedures/mvt-parser.ts +48 -0
- package/src/procedures/mvt-properties.ts +36 -0
- package/src/procedures/mvt-tile-provider.ts +72 -0
- package/src/procedures/pmtiles-loader.ts +75 -0
- package/src/procedures/projected-coordinate-transform.ts +79 -0
- package/src/procedures/projection-batch-executor.ts +140 -0
- package/src/procedures/scene-yaml-legacy.ts +16 -0
- package/src/procedures/scene-yaml-loaders.ts +10 -0
- package/src/procedures/terrain-draping.ts +713 -0
- package/src/procedures/terrain-globe.ts +32 -0
- package/src/procedures/terrain-styled-topology.ts +184 -0
- package/src/procedures/web-mercator-legacy.ts +24 -0
- package/src/procedures/web-mercator-math.ts +50 -0
- package/src/scene/camera.ts +298 -0
- package/src/scene/camera_base.ts +116 -0
- package/src/scene/classic_scene.ts +20 -0
- package/src/scene/external_camera.ts +101 -0
- package/src/scene/globals.ts +120 -0
- package/src/scene/ground_footprint.ts +139 -0
- package/src/scene/host_frame.ts +326 -0
- package/src/scene/projected_tile_lod.ts +125 -0
- package/src/scene/projection_math.ts +142 -0
- package/src/scene/projection_shaders.ts +183 -0
- package/src/scene/renderer.ts +516 -0
- package/src/scene/scene-resource-types.ts +174 -0
- package/src/scene/scene.ts +2378 -0
- package/src/scene/scene_bundle.ts +304 -0
- package/src/scene/scene_debug.ts +129 -0
- package/src/scene/scene_loader.ts +402 -0
- package/src/scene/scene_worker.ts +528 -0
- package/src/scene/view.ts +683 -0
- package/src/scene/visibility_adapter.ts +319 -0
- package/src/scene/worker_url.ts +15 -0
- package/src/selection/draped-terrain-surface.ts +377 -0
- package/src/selection/selection-types.ts +79 -0
- package/src/selection/selection.ts +542 -0
- package/src/selection/selection_fragment.glsl +18 -0
- package/src/selection/selection_globals.glsl +9 -0
- package/src/selection/selection_pixels.ts +59 -0
- package/src/selection/selection_vertex.glsl +15 -0
- package/src/selection/terrain_surface.ts +298 -0
- package/src/shader-modules/globe-horizon.ts +52 -0
- package/src/shader-modules/height-decode.ts +41 -0
- package/src/shader-modules/hillshade.ts +70 -0
- package/src/shader-modules/index.ts +10 -0
- package/src/shader-modules/planar.ts +24 -0
- package/src/shader-modules/sphere-map.ts +38 -0
- package/src/shader-modules/triplanar.ts +45 -0
- package/src/sources/aligned_tile_source.ts +122 -0
- package/src/sources/data_source.ts +655 -0
- package/src/sources/decoded_tile_store.ts +245 -0
- package/src/sources/geojson.ts +300 -0
- package/src/sources/mvt.ts +247 -0
- package/src/sources/raster.ts +341 -0
- package/src/sources/shared_tile_source_adapter.ts +117 -0
- package/src/sources/sources.ts +10 -0
- package/src/sources/tile_source_adapter.ts +84 -0
- package/src/sources/tile_source_metadata.ts +65 -0
- package/src/sources/tile_source_state.ts +112 -0
- package/src/sources/topojson.ts +90 -0
- package/src/styles/feature_annotations.ts +16 -0
- package/src/styles/filter.ts +190 -0
- package/src/styles/geometry-style-types.ts +209 -0
- package/src/styles/globe_visibility_wgsl.ts +22 -0
- package/src/styles/layer-types.ts +45 -0
- package/src/styles/layer.ts +586 -0
- package/src/styles/lines/dasharray.ts +49 -0
- package/src/styles/lines/lines.ts +707 -0
- package/src/styles/lines/lines_wgsl.ts +224 -0
- package/src/styles/points/point-runtime-types.ts +125 -0
- package/src/styles/points/points.ts +1079 -0
- package/src/styles/points/points_fragment.glsl +126 -0
- package/src/styles/points/points_vertex.glsl +230 -0
- package/src/styles/points/points_wgsl.ts +189 -0
- package/src/styles/polygons/polygons.ts +268 -0
- package/src/styles/polygons/polygons_fragment.glsl +173 -0
- package/src/styles/polygons/polygons_vertex.glsl +213 -0
- package/src/styles/polygons/polygons_wgsl.ts +127 -0
- package/src/styles/property-types.ts +125 -0
- package/src/styles/raster/raster.ts +33 -0
- package/src/styles/raster/raster_globals.glsl +46 -0
- package/src/styles/style-mixing-types.ts +101 -0
- package/src/styles/style-runtime-types.ts +220 -0
- package/src/styles/style-schema.ts +133 -0
- package/src/styles/style.ts +1033 -0
- package/src/styles/style_globals.glsl +69 -0
- package/src/styles/style_manager.ts +464 -0
- package/src/styles/style_parser.ts +620 -0
- package/src/styles/text/font_manager.ts +180 -0
- package/src/styles/text/fontfaceobserver.d.ts +10 -0
- package/src/styles/text/text-types.ts +220 -0
- package/src/styles/text/text.ts +378 -0
- package/src/styles/text/text_canvas.ts +773 -0
- package/src/styles/text/text_labels.ts +436 -0
- package/src/styles/text/text_segments.ts +142 -0
- package/src/styles/text/text_settings.ts +228 -0
- package/src/styles/text/text_wgsl.ts +159 -0
- package/src/styles/text/text_wrap.ts +194 -0
- package/src/tile/globe_tile_preload.ts +40 -0
- package/src/tile/tangram_tileset_2d.ts +108 -0
- package/src/tile/tile-build-types.ts +155 -0
- package/src/tile/tile.ts +807 -0
- package/src/tile/tile_id.ts +172 -0
- package/src/tile/tile_manager.ts +889 -0
- package/src/tile/tile_pyramid.ts +119 -0
- package/src/tile/tile_resource_cache.ts +91 -0
- package/src/tile/tile_traversal_adapter.ts +132 -0
- package/src/types.ts +332 -0
- package/src/utils/debounce.ts +17 -0
- package/src/utils/debug_settings.ts +43 -0
- package/src/utils/errors.ts +12 -0
- package/src/utils/functions.ts +95 -0
- package/src/utils/geo.ts +364 -0
- package/src/utils/hash.ts +14 -0
- package/src/utils/log.ts +108 -0
- package/src/utils/media_capture.ts +193 -0
- package/src/utils/merge.ts +44 -0
- package/src/utils/obb.ts +134 -0
- package/src/utils/props.ts +43 -0
- package/src/utils/slice.ts +14 -0
- package/src/utils/subscribe.ts +58 -0
- package/src/utils/task.ts +154 -0
- package/src/utils/thread.ts +26 -0
- package/src/utils/urls.ts +223 -0
- package/src/utils/utils.ts +310 -0
- package/src/utils/vector.ts +197 -0
- package/src/utils/version.ts +8 -0
- package/src/utils/worker-types.ts +79 -0
- package/src/utils/worker_broker.ts +523 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Tangram
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) 2013-2016 Brett Camper and Mapzen
|
|
4
|
+
// Copyright (c) 2026 vis.gl contributors
|
|
5
|
+
|
|
6
|
+
import {TileID, type TileReference} from './tile_id';
|
|
7
|
+
|
|
8
|
+
/** Resident proxy metadata; traversal references never acquire a live tile's methods. */
|
|
9
|
+
type PyramidTile = TileReference & {key: string; loaded: boolean};
|
|
10
|
+
/** Resident owner and count of retained descendants. */
|
|
11
|
+
type PyramidEntry<Tile extends PyramidTile> = {tile?: Tile; descendants: number};
|
|
12
|
+
|
|
13
|
+
export default class TilePyramid<Tile extends PyramidTile = PyramidTile> {
|
|
14
|
+
tiles: Record<string, PyramidEntry<Tile>>;
|
|
15
|
+
max_proxy_descendant_depth: number;
|
|
16
|
+
max_proxy_ancestor_depth: number;
|
|
17
|
+
children_cache: Record<string, Record<string, TileReference[]>>;
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.tiles = {};
|
|
21
|
+
this.max_proxy_descendant_depth = 6; // # of levels to search up/down for proxy tiles
|
|
22
|
+
this.max_proxy_ancestor_depth = 7;
|
|
23
|
+
this.children_cache = {}; // cache for children of coordinates
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
addTile(tile: Tile): void {
|
|
27
|
+
// Add target tile
|
|
28
|
+
this.tiles[tile.key] = this.tiles[tile.key] || { descendants: 0 };
|
|
29
|
+
this.tiles[tile.key].tile = tile;
|
|
30
|
+
|
|
31
|
+
// Add to parents
|
|
32
|
+
let reference: TileReference = tile;
|
|
33
|
+
while (reference.style_z >= 0) {
|
|
34
|
+
const parent = TileID.parent(reference);
|
|
35
|
+
if (!parent?.key) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
reference = parent;
|
|
40
|
+
if (!this.tiles[parent.key]) {
|
|
41
|
+
this.tiles[parent.key] = { descendants: 0 };
|
|
42
|
+
}
|
|
43
|
+
this.tiles[parent.key].descendants++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
removeTile(tile: Tile): void {
|
|
48
|
+
// Remove target tile
|
|
49
|
+
if (this.tiles[tile.key]) {
|
|
50
|
+
delete this.tiles[tile.key].tile;
|
|
51
|
+
|
|
52
|
+
if (this.tiles[tile.key].descendants === 0) {
|
|
53
|
+
delete this.tiles[tile.key]; // remove whole tile in tree
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Decrement reference count up the tile pyramid
|
|
58
|
+
let reference: TileReference = tile;
|
|
59
|
+
while (reference.style_z >= 0) {
|
|
60
|
+
const parent = TileID.parent(reference);
|
|
61
|
+
if (!parent?.key) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
reference = parent;
|
|
66
|
+
if (this.tiles[parent.key] && this.tiles[parent.key].descendants > 0) {
|
|
67
|
+
this.tiles[parent.key].descendants--;
|
|
68
|
+
if (this.tiles[parent.key].descendants === 0 && !this.tiles[parent.key].tile) {
|
|
69
|
+
delete this.tiles[parent.key]; // remove whole tile in tree
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Find the parent tile for a given tile and style zoom level
|
|
76
|
+
getAncestor (tile: TileReference): Tile | undefined {
|
|
77
|
+
let level = 0;
|
|
78
|
+
while (level < this.max_proxy_ancestor_depth) {
|
|
79
|
+
const parent = TileID.parent(tile);
|
|
80
|
+
if (!parent?.key) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
tile = parent;
|
|
85
|
+
const owner = this.tiles[parent.key]?.tile;
|
|
86
|
+
if (owner?.loaded) {
|
|
87
|
+
return owner;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
level++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Find the descendant tiles for a given tile and style zoom level
|
|
95
|
+
getDescendants (tile: TileReference, level = 0): Tile[] {
|
|
96
|
+
const descendants: Tile[] = [];
|
|
97
|
+
if (level < this.max_proxy_descendant_depth) {
|
|
98
|
+
const tiles = TileID.children(tile, this.children_cache);
|
|
99
|
+
if (!tiles) {
|
|
100
|
+
return descendants;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
tiles.forEach(t => {
|
|
104
|
+
if (t.key && this.tiles[t.key]) {
|
|
105
|
+
const owner = this.tiles[t.key].tile;
|
|
106
|
+
if (owner?.loaded) {
|
|
107
|
+
descendants.push(owner);
|
|
108
|
+
}
|
|
109
|
+
else if (this.tiles[t.key].descendants > 0) { // didn't find any children, try next level
|
|
110
|
+
descendants.push(...(this.getDescendants(t, level + 1) || []));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return descendants;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {HostTileResourceOptions, TileResourceStatistics} from '../types';
|
|
6
|
+
import {TileCachePolicy} from '../map-logic/tile-cache-policy';
|
|
7
|
+
|
|
8
|
+
/** The byte-accounting surface shared by planar, globe, and pending-label meshes. */
|
|
9
|
+
interface ResourceMesh {
|
|
10
|
+
/** Vertex and index allocation size, excluding textures and driver overhead. */
|
|
11
|
+
buffer_size?: number;
|
|
12
|
+
/** Independently allocated projection-specific mesh. */
|
|
13
|
+
globe_mesh?: ResourceMesh | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Minimal lifecycle state used by the resource policy; no GPU or host dependency. */
|
|
17
|
+
export interface ResourceTile {
|
|
18
|
+
/** Source/style-normalized key. */
|
|
19
|
+
key: string;
|
|
20
|
+
/** Eye-union and fallback visibility. */
|
|
21
|
+
visible: boolean;
|
|
22
|
+
/** Worker processing is still incomplete. */
|
|
23
|
+
loading: boolean;
|
|
24
|
+
/** All mesh batches have arrived. */
|
|
25
|
+
built: boolean;
|
|
26
|
+
/** Current drawable meshes by style. */
|
|
27
|
+
meshes: Record<string, ResourceMesh[]>;
|
|
28
|
+
/** Label mesh batches waiting for collision layout. */
|
|
29
|
+
pending_label_meshes?: Record<string, ResourceMesh[]> | null;
|
|
30
|
+
/** Proxy tiles remain protected even if not explicitly visible. */
|
|
31
|
+
isProxy(): boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Mesh bytes currently owned by a tile, deduplicating shared mesh references. */
|
|
35
|
+
export function getTileMeshBytes(tile: ResourceTile): number {
|
|
36
|
+
const seen = new Set<ResourceMesh>();
|
|
37
|
+
let bytes = 0;
|
|
38
|
+
const addMesh = (mesh: ResourceMesh): void => {
|
|
39
|
+
if (seen.has(mesh)) return;
|
|
40
|
+
seen.add(mesh);
|
|
41
|
+
if (typeof mesh.buffer_size === 'number' && Number.isFinite(mesh.buffer_size) && mesh.buffer_size > 0) {
|
|
42
|
+
bytes += mesh.buffer_size;
|
|
43
|
+
}
|
|
44
|
+
if (mesh.globe_mesh) addMesh(mesh.globe_mesh);
|
|
45
|
+
};
|
|
46
|
+
for (const collection of [tile.meshes, tile.pending_label_meshes]) {
|
|
47
|
+
for (const meshes of Object.values(collection ?? {})) for (const mesh of meshes) addMesh(mesh);
|
|
48
|
+
}
|
|
49
|
+
return bytes;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** LRU limits apply only to completed, unneeded tiles, never visible/proxy/preload work. */
|
|
53
|
+
export default class TileResourceCache {
|
|
54
|
+
/** Neutral metadata policy; renderer mesh accounting stays in this adapter. */
|
|
55
|
+
private readonly policy = new TileCachePolicy();
|
|
56
|
+
|
|
57
|
+
/** Mark newly retained or currently protected tiles as recently used. */
|
|
58
|
+
touch(key: string): void { this.policy.touch(key); }
|
|
59
|
+
|
|
60
|
+
/** Remove metadata with the tile's worker and GPU resources. */
|
|
61
|
+
forget(key: string): void { this.policy.forget(key); }
|
|
62
|
+
|
|
63
|
+
/** Choose oldest completed cache entries until both opt-in limits are satisfied. */
|
|
64
|
+
selectEvictions(tiles: readonly ResourceTile[], options: HostTileResourceOptions | undefined,
|
|
65
|
+
isPreloaded: (key: string) => boolean): string[] {
|
|
66
|
+
if (options?.maxCachedTiles === undefined && options?.maxCachedMeshBytes === undefined) return [];
|
|
67
|
+
// As before, only walk mesh allocations for evictable tiles when a budget is enabled.
|
|
68
|
+
const records = tiles.filter(tile => !this.isProtected(tile, isPreloaded))
|
|
69
|
+
.map(tile => ({key: tile.key, bytes: getTileMeshBytes(tile), protected: false}));
|
|
70
|
+
return this.policy.selectEvictions(records, {maxCachedTiles: options?.maxCachedTiles,
|
|
71
|
+
maxCachedBytes: options?.maxCachedMeshBytes});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Detached accounting for protected residency and evictable cache separately. */
|
|
75
|
+
getStatistics(tiles: readonly ResourceTile[], isPreloaded: (key: string) => boolean,
|
|
76
|
+
builds: {activeBuilds: number; queuedBuilds: number}): TileResourceStatistics {
|
|
77
|
+
const statistics = this.policy.getStatistics(tiles.map(tile => ({key: tile.key,
|
|
78
|
+
protected: this.isProtected(tile, isPreloaded), bytes: getTileMeshBytes(tile)})));
|
|
79
|
+
return {...builds, residentTiles: statistics.residentTiles, cachedTiles: statistics.cachedTiles,
|
|
80
|
+
cachedMeshBytes: statistics.cachedBytes, protectedTiles: statistics.protectedTiles,
|
|
81
|
+
protectedMeshBytes: statistics.protectedBytes};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Visible union, loading work, proxy ancestors and pinned coarse tiles are never cache victims. */
|
|
85
|
+
isProtected(tile: ResourceTile, isPreloaded: (key: string) => boolean): boolean {
|
|
86
|
+
return tile.visible || tile.loading || !tile.built || tile.isProxy() || isPreloaded(tile.key);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Clear residency metadata on renderer teardown. */
|
|
90
|
+
clear(): void { this.policy.clear(); }
|
|
91
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Tangram
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) 2013-2016 Brett Camper and Mapzen
|
|
4
|
+
// Copyright (c) 2026 vis.gl contributors
|
|
5
|
+
|
|
6
|
+
import Geo from '../utils/geo';
|
|
7
|
+
import type {HostProjection} from '../types';
|
|
8
|
+
import type {TileCoordinate, TileCoordinates} from './tile_id';
|
|
9
|
+
import type {GlobeVisibilityLODAdapter, VisibilityLODAdapter, VisibilityViewState} from '../scene/visibility_adapter';
|
|
10
|
+
import {WebMercatorVisibilityAdapter} from '../scene/visibility_adapter';
|
|
11
|
+
|
|
12
|
+
/** Count a finite CPU-projected footprint at data detail 0–6 without allocating tile coordinates.
|
|
13
|
+
* Uses the same XYZ endpoint and single-world clamping rules as actual traversal.
|
|
14
|
+
* This is a per-source candidate count, not a total across multiple sources.
|
|
15
|
+
*/
|
|
16
|
+
export function countProjectedTileCoordinates(bounds: readonly [number, number, number, number], tileZoom: number): number {
|
|
17
|
+
if (!Array.isArray(bounds) || bounds.length !== 4 || !Array.from(bounds).every(Number.isFinite) || bounds[0] < -180 || bounds[2] > 180 ||
|
|
18
|
+
bounds[0] > bounds[2] || bounds[1] > bounds[3] || bounds[1] < -85.0511287798066 || bounds[3] > 85.0511287798066 ||
|
|
19
|
+
!Number.isSafeInteger(tileZoom) || tileZoom < 0 || tileZoom > 6) {
|
|
20
|
+
throw new Error('Projected tile count requires finite single-world bounds and integer detail 0–6');
|
|
21
|
+
}
|
|
22
|
+
const southwest = Geo.latLngToMeters([bounds[0], bounds[1]]);
|
|
23
|
+
const northeast = Geo.latLngToMeters([bounds[2], bounds[3]]);
|
|
24
|
+
return new WebMercatorVisibilityAdapter().countTileCoordinates({
|
|
25
|
+
center: {lng: 0, lat: 0}, zoom: tileZoom, tile_zoom: tileZoom,
|
|
26
|
+
size: {css: {width: 1, height: 1}}, buffer: 0, wrap: false,
|
|
27
|
+
bounds: {sw: {x: southwest[0], y: southwest[1]}, ne: {x: northeast[0], y: northeast[1]}}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Geographic XYZ tile bounds; an unwrapped world copy retains its longitude offset. */
|
|
32
|
+
export interface GeographicTileBounds {
|
|
33
|
+
/** Western longitude in degrees. */
|
|
34
|
+
west: number;
|
|
35
|
+
/** Southern latitude in degrees. */
|
|
36
|
+
south: number;
|
|
37
|
+
/** Eastern longitude in degrees. */
|
|
38
|
+
east: number;
|
|
39
|
+
/** Northern latitude in degrees. */
|
|
40
|
+
north: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** One host eye's traversal inputs, independent of deck.gl viewport classes. */
|
|
44
|
+
export interface TangramTraversalEye {
|
|
45
|
+
/** Geographic view state with style and data zoom kept distinct. */
|
|
46
|
+
readonly view: VisibilityViewState;
|
|
47
|
+
/** Projection and footprint policy. */
|
|
48
|
+
readonly projection: HostProjection;
|
|
49
|
+
/** Optional globe/common-space camera position. */
|
|
50
|
+
readonly position?: ArrayLike<number>;
|
|
51
|
+
/** Host eyes need independent bounds; classic views already have calculated bounds. */
|
|
52
|
+
readonly calculateBounds?: boolean;
|
|
53
|
+
/** Projected LOD overrides per-eye automatic detail, never style zoom. */
|
|
54
|
+
readonly dataZoom?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Shared logical traversal state; stereo consumers contribute an eye union. */
|
|
58
|
+
export interface TangramTraversalState {
|
|
59
|
+
/** Empty until the view is ready. */
|
|
60
|
+
readonly eyes: readonly TangramTraversalEye[];
|
|
61
|
+
/** Host render-view collections deduplicate even a single eye; classic ordering remains unchanged. */
|
|
62
|
+
readonly union?: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Structured geographic bounds suitable for both Tangram and loaders.gl adapters. */
|
|
66
|
+
export function getTileGeographicBounds(index: TileCoordinates): GeographicTileBounds {
|
|
67
|
+
const northwest = Geo.metersForTile(index);
|
|
68
|
+
const southeast = Geo.metersForTile({x: index.x + 1, y: index.y + 1, z: index.z});
|
|
69
|
+
const [west, north] = Geo.metersToLatLng([northwest.x, northwest.y]);
|
|
70
|
+
const [east, south] = Geo.metersToLatLng([southeast.x, southeast.y]);
|
|
71
|
+
return {west, south, east, north};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Traversal seam structurally compatible with loaders.gl Tileset2DAdapter.
|
|
76
|
+
* Tangram owns footprint/LOD inputs; source normalization and fallback pinning remain separate.
|
|
77
|
+
*/
|
|
78
|
+
export default class TangramTileTraversalAdapter {
|
|
79
|
+
/** Existing planar/FirstPerson visibility implementation. */
|
|
80
|
+
private readonly planar: VisibilityLODAdapter;
|
|
81
|
+
/** Existing curved globe/horizon visibility implementation. */
|
|
82
|
+
private readonly globe: GlobeVisibilityLODAdapter;
|
|
83
|
+
|
|
84
|
+
/** Bind the unchanged projection-specific selection procedures. */
|
|
85
|
+
constructor(planar: VisibilityLODAdapter, globe: GlobeVisibilityLODAdapter) {
|
|
86
|
+
this.planar = planar;
|
|
87
|
+
this.globe = globe;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Select the same logical data tiles before source sparse-zoom/overzoom normalization. */
|
|
91
|
+
getTileIndices({viewState}: {viewState: TangramTraversalState}): TileCoordinate[] {
|
|
92
|
+
if (viewState.eyes.length === 1 && !viewState.union) return this.selectEye(viewState.eyes[0]);
|
|
93
|
+
const coordinates = new Map<string, TileCoordinate>();
|
|
94
|
+
for (const eye of viewState.eyes) for (const coordinate of this.selectEye(eye)) {
|
|
95
|
+
coordinates.set(coordinate.key ?? `${coordinate.x}/${coordinate.y}/${coordinate.z}`, coordinate);
|
|
96
|
+
}
|
|
97
|
+
return Array.from(coordinates.values());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Geographic tile metadata, with XYZ's north-down Y convention preserved. */
|
|
101
|
+
getTileBoundingBox(_context: {viewState: TangramTraversalState}, index: TileCoordinates): GeographicTileBounds {
|
|
102
|
+
return getTileGeographicBounds(index);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Original per-eye projection dispatch and explicit footprint handling. */
|
|
106
|
+
private selectEye(eye: TangramTraversalEye): TileCoordinate[] {
|
|
107
|
+
let state = eye.view;
|
|
108
|
+
if (eye.calculateBounds) {
|
|
109
|
+
const bounds = this.planar.calculateBounds(state);
|
|
110
|
+
state = {...state, bounds: bounds.bounds, tile_zoom: eye.dataZoom ?? bounds.tileZoom};
|
|
111
|
+
}
|
|
112
|
+
const projection = eye.projection;
|
|
113
|
+
if (projection.type === 'globe') {
|
|
114
|
+
return this.globe.findVisibleTileCoordinates({tile_zoom: state.tile_zoom, buffer: state.buffer,
|
|
115
|
+
visibleBounds: projection.visibleBounds,
|
|
116
|
+
...(projection.maxElevation === undefined ? {} : {maxElevation: projection.maxElevation}),
|
|
117
|
+
cameraPosition: eye.position ? [eye.position[0], eye.position[1], eye.position[2]] : undefined});
|
|
118
|
+
}
|
|
119
|
+
if (projection.visibleBounds !== undefined) {
|
|
120
|
+
const bounds = projection.visibleBounds;
|
|
121
|
+
if (bounds === null) return [];
|
|
122
|
+
const southwest = Geo.latLngToMeters([bounds[0], bounds[1]]);
|
|
123
|
+
const northeast = Geo.latLngToMeters([bounds[2], bounds[3]]);
|
|
124
|
+
if (!southwest.every(Number.isFinite) || !northeast.every(Number.isFinite)) {
|
|
125
|
+
throw new Error('HostFrame planar visibleBounds must project to finite meters');
|
|
126
|
+
}
|
|
127
|
+
state = {...state, bounds: {sw: {x: southwest[0], y: southwest[1]}, ne: {x: northeast[0], y: northeast[1]}}};
|
|
128
|
+
}
|
|
129
|
+
// CPU-projected scenes represent one finite tile world, never wrapped copies.
|
|
130
|
+
return this.planar.findVisibleTileCoordinates(projection.type === 'projected' ? {...state, wrap: false} : state);
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Device, RenderPass} from '@luma.gl/core';
|
|
6
|
+
import type {DecodedTileStatistics} from './sources/decoded_tile_store';
|
|
7
|
+
import type {
|
|
8
|
+
GlobeVisibilityLODAdapter,
|
|
9
|
+
VisibilityLODAdapter
|
|
10
|
+
} from './scene/visibility_adapter.js';
|
|
11
|
+
|
|
12
|
+
export type Matrix4 = readonly number[] | Float32Array | Float64Array;
|
|
13
|
+
export type Vector3 = readonly [number, number, number];
|
|
14
|
+
export type SceneDefinition = string | Record<string, unknown> | readonly SceneDefinition[];
|
|
15
|
+
|
|
16
|
+
/** Minimal CRS options accepted by a caller-owned math.gl-compatible projection factory. */
|
|
17
|
+
export interface ProjectionEngineOptions {
|
|
18
|
+
/** Source CRS, supplied by Tangram as geographic degrees. */
|
|
19
|
+
from?: string;
|
|
20
|
+
/** Destination CRS, supplied by Tangram as north-positive projected meters. */
|
|
21
|
+
to?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Compiled projection surface used for packed worker mesh coordinates. */
|
|
25
|
+
export interface ProjectionEngineTransform {
|
|
26
|
+
/** Project packed coordinates in place, preserving their typed-array representation. */
|
|
27
|
+
projectFlatSync(coordinates: Float64Array, dimension?: number): Float64Array;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Structural subset of math.gl's factory; ordinary consumers need not install the optional peer. */
|
|
31
|
+
export interface ProjectionEngine {
|
|
32
|
+
/** Compile an independent transform synchronously. */
|
|
33
|
+
createProjection(options?: ProjectionEngineOptions): ProjectionEngineTransform;
|
|
34
|
+
/** Compile a transform after loading any registered lazy projection implementations. */
|
|
35
|
+
createProjectionAsync(options?: ProjectionEngineOptions): Promise<ProjectionEngineTransform>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Viewport = {
|
|
39
|
+
x?: number;
|
|
40
|
+
y?: number;
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type GeographicAnchor = {
|
|
46
|
+
longitude: number;
|
|
47
|
+
latitude: number;
|
|
48
|
+
altitude?: number;
|
|
49
|
+
zoom: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Geographic projection used by host-provided positions and camera matrices. */
|
|
53
|
+
export type HostProjection =
|
|
54
|
+
| {
|
|
55
|
+
/** Worker-projected flat common coordinates; requires an explicit geographic footprint. */
|
|
56
|
+
type: 'projected';
|
|
57
|
+
/** Ordered unwrapped footprint in degrees; tile selection remains Web Mercator XYZ. */
|
|
58
|
+
visibleBounds: readonly [number, number, number, number];
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
type: 'web-mercator';
|
|
62
|
+
/** Explicit unwrapped geographic footprint; null means no visible ground, omitted uses camera/legacy bounds. */
|
|
63
|
+
visibleBounds?: readonly [number, number, number, number] | null;
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
type: 'globe';
|
|
67
|
+
/** Conservative footprint enclosing ground and elevated content: west, south, east, north. */
|
|
68
|
+
visibleBounds: readonly [number, number, number, number];
|
|
69
|
+
/**
|
|
70
|
+
* Conservative maximum rendered elevation in geographic meters above the reference sphere.
|
|
71
|
+
* Zero declares a surface-only scene. Omitted means unknown and disables horizon rejection.
|
|
72
|
+
* Includes terrain, extrusion, offsets and shader displacement; never inferred from camera altitude.
|
|
73
|
+
*/
|
|
74
|
+
maxElevation?: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type HostCamera = {
|
|
78
|
+
view: Matrix4;
|
|
79
|
+
projection: Matrix4;
|
|
80
|
+
position: Vector3;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type HostRenderView = {
|
|
84
|
+
id?: string;
|
|
85
|
+
viewport?: Viewport;
|
|
86
|
+
camera: HostCamera;
|
|
87
|
+
/** Optional per-eye footprint anchor; scene/style state still uses the shared anchor. */
|
|
88
|
+
geographicAnchor?: GeographicAnchor;
|
|
89
|
+
/** Optional per-eye geographic bounds for union visibility. */
|
|
90
|
+
projection?: HostProjection;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** Opt-in uniform data LOD estimated from projected surface scale across all eyes. */
|
|
94
|
+
export type HostTileLODOptions = {
|
|
95
|
+
/** Target projected tile edge in device pixels; defaults to 512. */
|
|
96
|
+
targetTilePixels?: number;
|
|
97
|
+
/** Device pixels per viewport CSS pixel; defaults to 1. */
|
|
98
|
+
pixelRatio?: number;
|
|
99
|
+
/** Buffered candidate visits across eyes, before deduplication; defaults to 256. */
|
|
100
|
+
maxTiles?: number;
|
|
101
|
+
/** Zoom-level dead band around transitions; defaults to 0.2. */
|
|
102
|
+
hysteresis?: number;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Opt-in worker scheduling and completed off-screen mesh cache limits, shared by all eyes. */
|
|
106
|
+
export type HostTileResourceOptions = {
|
|
107
|
+
/** Maximum concurrently submitted tile builds across sources; positive integer, omitted is unlimited. */
|
|
108
|
+
maxConcurrentBuilds?: number;
|
|
109
|
+
/** Maximum completed off-screen cache entries; non-negative integer, omitted is unlimited. */
|
|
110
|
+
maxCachedTiles?: number;
|
|
111
|
+
/** Cached vertex/index bytes, including globe variants and pending labels; non-negative integer. */
|
|
112
|
+
maxCachedMeshBytes?: number;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** Detached renderer resource accounting; textures, CPU data and driver overhead are not included. */
|
|
116
|
+
export type TileResourceStatistics = {
|
|
117
|
+
/** Tile builds submitted to workers, not individual network requests. */
|
|
118
|
+
activeBuilds: number;
|
|
119
|
+
/** Source/style tile builds waiting for a scheduling slot. */
|
|
120
|
+
queuedBuilds: number;
|
|
121
|
+
/** All retained tiles, including visible/proxy/preload and incomplete builds. */
|
|
122
|
+
residentTiles: number;
|
|
123
|
+
/** Completed tiles eligible for cache eviction. */
|
|
124
|
+
cachedTiles: number;
|
|
125
|
+
/** Vertex/index bytes owned by evictable tiles. */
|
|
126
|
+
cachedMeshBytes: number;
|
|
127
|
+
/** Tiles protected from resource-policy eviction. */
|
|
128
|
+
protectedTiles: number;
|
|
129
|
+
/** Vertex/index bytes owned by protected tiles. */
|
|
130
|
+
protectedMeshBytes: number;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** Worker-local decoded acquisition accounting, separate from scene-wide mesh-build statistics. */
|
|
134
|
+
export type TileSourceStatistics = DecodedTileStatistics & {
|
|
135
|
+
/** Index of the worker in the scene's current worker pool. */
|
|
136
|
+
workerId: number;
|
|
137
|
+
/** False for workers with external source scripts; custom pipelines always bypass sharing. */
|
|
138
|
+
sharingEnabled: boolean;
|
|
139
|
+
/** Present only for the opt-in projected worker; separate from decoded-source and GPU residency. */
|
|
140
|
+
projectionPreparation?: import('./procedures/mesh-projector').MeshPreparationStatistics;
|
|
141
|
+
/** Optional cumulative CPU projection/refinement work, reset when the worker source lifecycle resets. */
|
|
142
|
+
projectionWork?: import('./procedures/mesh-projector').MeshProjectionStatistics;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** CSS-pixel query coordinates and view routing for asynchronous feature selection. */
|
|
146
|
+
export interface FeatureSelectionOptions {
|
|
147
|
+
/** Non-negative CSS-pixel search radius. */
|
|
148
|
+
radius?: number;
|
|
149
|
+
/** Explicit eye/view identity; omitted canvas queries choose the last overlapping view. */
|
|
150
|
+
renderViewId?: string;
|
|
151
|
+
/** Default view-local pixels, or full-target top-origin CSS pixels for stereo routing. */
|
|
152
|
+
coordinateSpace?: 'view' | 'canvas';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Asynchronous selection of a built-in worker feature or an application-defined payload. */
|
|
156
|
+
export type FeatureSelectionResult = {
|
|
157
|
+
/** Cloneable metadata from the worker; null/undefined means no hit. */
|
|
158
|
+
feature?: unknown;
|
|
159
|
+
/** Whether the selected feature differs from the previous completed query. */
|
|
160
|
+
changed?: boolean;
|
|
161
|
+
/** Caller-requested top-origin CSS pixel, in the selected coordinate space. */
|
|
162
|
+
pixel?: {x: number; y: number};
|
|
163
|
+
/** View/eye used for the query; pixel remains in the caller's requested coordinate space. */
|
|
164
|
+
renderViewId?: string;
|
|
165
|
+
/** Readback, cancellation or worker failure, preserving Scene's result contract. */
|
|
166
|
+
error?: unknown;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export type HostFrameOptions = {
|
|
170
|
+
viewport: Viewport;
|
|
171
|
+
geographicAnchor: GeographicAnchor;
|
|
172
|
+
projection?: HostProjection;
|
|
173
|
+
renderViews: readonly HostRenderView[];
|
|
174
|
+
activeRenderViewId?: string;
|
|
175
|
+
tileBuffer?: number;
|
|
176
|
+
/** Optional shared data-tile zoom (integer 0–22, no higher than the shared style zoom). */
|
|
177
|
+
tileZoom?: number;
|
|
178
|
+
/** Automatic shared data LOD; mutually exclusive with tileZoom. */
|
|
179
|
+
tileLOD?: HostTileLODOptions;
|
|
180
|
+
/** Opt-in scheduling/cache policy shared by every render view and source. */
|
|
181
|
+
tileResources?: HostTileResourceOptions;
|
|
182
|
+
/** Retain a global coarse level for globe loading gaps; integer 0–3, omitted disables preloading. */
|
|
183
|
+
globePreloadZoom?: number;
|
|
184
|
+
/** Shared elapsed scene animation time in seconds. */
|
|
185
|
+
animationTime?: number;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export type LegacyHostFrame = {
|
|
189
|
+
viewport: Viewport;
|
|
190
|
+
view: GeographicAnchor;
|
|
191
|
+
projection?: HostProjection;
|
|
192
|
+
camera: HostCamera;
|
|
193
|
+
tileBuffer?: number;
|
|
194
|
+
/** Optional shared data-tile zoom; omission preserves zoom-driven selection. */
|
|
195
|
+
tileZoom?: number;
|
|
196
|
+
/** Opt-in projected-scale data LOD. */
|
|
197
|
+
tileLOD?: HostTileLODOptions;
|
|
198
|
+
/** Opt-in scheduling/cache policy; omission restores unlimited scheduling/cache defaults. */
|
|
199
|
+
tileResources?: HostTileResourceOptions;
|
|
200
|
+
/** Optional bounded global globe fallback level, integer 0–3. */
|
|
201
|
+
globePreloadZoom?: number;
|
|
202
|
+
/** Shared elapsed scene animation time in seconds. */
|
|
203
|
+
animationTime?: number;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export type RendererOptions = {
|
|
207
|
+
/** Opt-in worker-side physical terrain displacement; provider loading remains host-owned. */
|
|
208
|
+
terrain?: import('./procedures/terrain-draping').TerrainDrapingOptions;
|
|
209
|
+
/** Optional application-owned admission pool shared with terrain source/preparation owners. Captured at creation; never sent to workers. */
|
|
210
|
+
terrainResourceBudget?: import('./map-logic/terrain-resource-budget').TerrainResourceBudget;
|
|
211
|
+
/** Optional caller-owned CRS factory for CPU-projected basemaps; ordinary Mercator/globe cameras are unchanged. */
|
|
212
|
+
projectionEngine?: ProjectionEngine;
|
|
213
|
+
/** Host kernel chunking policy; captured at renderer creation and independent of worker/build budgets. */
|
|
214
|
+
projectionEngineExecution?: import('./procedures/projection-batch-executor').ProjectionExecutionOptions;
|
|
215
|
+
device?: Device;
|
|
216
|
+
/** Optional worker script URL; otherwise the package uses its embedded worker. */
|
|
217
|
+
workerURL?: string;
|
|
218
|
+
/** Renderer-owned policy for viewport bounds and tile visibility/LOD. */
|
|
219
|
+
visibilityAdapter?: VisibilityLODAdapter;
|
|
220
|
+
/** Renderer-owned policy for selecting tiles for globe projection bounds. */
|
|
221
|
+
globeVisibilityAdapter?: GlobeVisibilityLODAdapter;
|
|
222
|
+
canvas?: HTMLCanvasElement | OffscreenCanvas;
|
|
223
|
+
requestRedraw?: () => void;
|
|
224
|
+
numWorkers?: number;
|
|
225
|
+
/** Positive safe integer limit for shared built-in tile loads in each worker; omitted is unlimited. */
|
|
226
|
+
maxConcurrentTileLoadsPerWorker?: number;
|
|
227
|
+
logLevel?: import('./utils/log').LogLevel;
|
|
228
|
+
highDensityDisplay?: boolean;
|
|
229
|
+
introspection?: boolean;
|
|
230
|
+
[option: string]: unknown;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export type SceneLoadOptions = {
|
|
234
|
+
base_path?: string;
|
|
235
|
+
file_type?: string;
|
|
236
|
+
blocking?: boolean;
|
|
237
|
+
[option: string]: unknown;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export type SceneUpdateOptions = {
|
|
241
|
+
loading?: boolean;
|
|
242
|
+
rebuild?: boolean | Record<string, unknown>;
|
|
243
|
+
serialize_funcs?: boolean;
|
|
244
|
+
texture_nodes?: import('./scene/scene-resource-types').SceneTextureNodes;
|
|
245
|
+
normalize?: boolean;
|
|
246
|
+
fade_in?: boolean;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export type SceneDataSource = {
|
|
250
|
+
type: string;
|
|
251
|
+
/** Required provider credit HTML for the host to display safely. */
|
|
252
|
+
attribution?: string;
|
|
253
|
+
url?: string;
|
|
254
|
+
tilejson?: string | Record<string, unknown>;
|
|
255
|
+
data?: unknown;
|
|
256
|
+
[property: string]: unknown;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export type SceneFeature = {
|
|
260
|
+
id?: string | number;
|
|
261
|
+
properties: Record<string, unknown>;
|
|
262
|
+
geometry?: Record<string, unknown>;
|
|
263
|
+
[property: string]: unknown;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export type SceneQueryOptions = {
|
|
267
|
+
filter?: unknown;
|
|
268
|
+
unique?: boolean | string | readonly string[];
|
|
269
|
+
group_by?: string | readonly string[] | null;
|
|
270
|
+
visible?: boolean | null;
|
|
271
|
+
geometry?: boolean;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export type SceneScreenshot = {
|
|
275
|
+
url: string;
|
|
276
|
+
blob: Blob;
|
|
277
|
+
type: 'png';
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export type RenderOptions = {
|
|
281
|
+
frame?: HostFrameOptions | LegacyHostFrame;
|
|
282
|
+
renderPass?: RenderPass | null;
|
|
283
|
+
renderViewId?: string;
|
|
284
|
+
force?: boolean;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export type SceneConfigEvent = {config: Record<string, unknown>};
|
|
288
|
+
export type SceneErrorEvent = {
|
|
289
|
+
type?: string;
|
|
290
|
+
message?: string;
|
|
291
|
+
error?: unknown;
|
|
292
|
+
[property: string]: unknown;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export type SceneEventMap = {
|
|
296
|
+
load: [event: SceneConfigEvent];
|
|
297
|
+
update: [event: SceneConfigEvent];
|
|
298
|
+
pre_update: [willRender: boolean];
|
|
299
|
+
post_update: [willRender: boolean];
|
|
300
|
+
view_complete: [event: {first: boolean}];
|
|
301
|
+
error: [event: SceneErrorEvent];
|
|
302
|
+
warning: [event: SceneErrorEvent];
|
|
303
|
+
move: [];
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export type SceneListener<EventName extends keyof SceneEventMap = keyof SceneEventMap> = (
|
|
307
|
+
...arguments_: SceneEventMap[EventName]
|
|
308
|
+
) => void;
|
|
309
|
+
|
|
310
|
+
export type SceneListeners = {
|
|
311
|
+
[EventName in keyof SceneEventMap]?: SceneListener<EventName>;
|
|
312
|
+
} & {
|
|
313
|
+
[event: string]: ((...arguments_: never[]) => void) | undefined;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export type WorkerRequest<Message = unknown> = {
|
|
317
|
+
type: 'main_send' | 'worker_send';
|
|
318
|
+
message_id: number;
|
|
319
|
+
method: string;
|
|
320
|
+
message: Message;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export type WorkerResponse<Message = unknown> = {
|
|
324
|
+
type: 'main_reply' | 'worker_reply';
|
|
325
|
+
message_id: number;
|
|
326
|
+
message?: Message;
|
|
327
|
+
error?: string;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export type WorkerBrokerMessage<Message = unknown> =
|
|
331
|
+
| WorkerRequest<Message>
|
|
332
|
+
| WorkerResponse<Message>;
|