@tangram.gl/tangram-renderer 0.0.0-stage → 0.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/README.md +59 -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,190 @@
|
|
|
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
|
+
type FilterValue = unknown;
|
|
7
|
+
/** Optional normalization for filter range bounds. */
|
|
8
|
+
export interface FilterOptions {
|
|
9
|
+
rangeTransform?: (value: unknown) => unknown;
|
|
10
|
+
}
|
|
11
|
+
/** Generated filter retains authored function results; matching applies truthiness. */
|
|
12
|
+
export type FilterFunction = (context: {
|
|
13
|
+
feature?: {properties: Record<string, unknown>};
|
|
14
|
+
[name: string]: unknown;
|
|
15
|
+
}) => unknown;
|
|
16
|
+
type FilterAst = string[];
|
|
17
|
+
|
|
18
|
+
function notNull (x: FilterValue): boolean { return x != null; }
|
|
19
|
+
function wrap (x: FilterValue): string { return '(' + x + ')';}
|
|
20
|
+
|
|
21
|
+
function maybeQuote (value: FilterValue): FilterValue {
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return '"' + value + '"';
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function lookUp (key: string): string {
|
|
29
|
+
if (key[0] === '$') {
|
|
30
|
+
// keys prefixed with $ are special properties in the context object (not feature properties)
|
|
31
|
+
return 'context[\'' + key.substring(1) + '\']';
|
|
32
|
+
}
|
|
33
|
+
else if (key.indexOf('.') > -1) {
|
|
34
|
+
if (key.indexOf('\\.') === -1) { // no escaped dot notation
|
|
35
|
+
// un-escaped dot notation indicates a nested feature property
|
|
36
|
+
return `context.feature.properties${key.split('.').map(k => '[\'' + k + '\']').join('')}`;
|
|
37
|
+
}
|
|
38
|
+
else { // mixed escaped/unescaped dot notation
|
|
39
|
+
// escaped dot notation will be interpreted as a single-level feature property with dots in the name
|
|
40
|
+
// this splits on unescaped dots, which requires a temporary swap of escaped and unescaped dots
|
|
41
|
+
let keys = key
|
|
42
|
+
.replace(/\\\./g, '__TANGRAM_DELIMITER__')
|
|
43
|
+
.split('.')
|
|
44
|
+
.map(s => s.replace(/__TANGRAM_DELIMITER__/g, '.'));
|
|
45
|
+
return `context.feature.properties${keys.map(k => '[\'' + k + '\']').join('')}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// single-level feature property
|
|
49
|
+
return 'context.feature.properties[\'' + key + '\']';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function nullValue (/*key, value*/ _key?: FilterValue, _value?: FilterValue): string {
|
|
53
|
+
return ' true ';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function propertyEqual (key: string, value: FilterValue): string {
|
|
57
|
+
return wrap(maybeQuote(value) + ' === ' + lookUp(key));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function propertyOr (key: string, values: FilterValue[]): string {
|
|
61
|
+
const arr = '[' + values.map(maybeQuote).join(',') + ']';
|
|
62
|
+
return wrap(`${arr}.indexOf(${lookUp(key)}) > -1`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function printNested (values: FilterAst[], joiner: string): string {
|
|
66
|
+
return wrap(values.filter(notNull).map(function (x: FilterAst) {
|
|
67
|
+
return wrap(x.join(' && '));
|
|
68
|
+
}).join(' ' + joiner + ' '));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function any (_: FilterValue, values: FilterValue[], options: FilterOptions | undefined): string {
|
|
72
|
+
return (values && values.length > 0) ? printNested(values.map(function (v: FilterValue) { return parseFilter(v, options); }), '||') : 'true';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function all (_: FilterValue, values: FilterValue[], options: FilterOptions | undefined): string {
|
|
76
|
+
return (values && values.length > 0) ? printNested(values.map(function (v: FilterValue) { return parseFilter(v, options); }), '&&') : 'true';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function not (key: FilterValue, value: FilterValue, options: FilterOptions | undefined): string {
|
|
80
|
+
return '!' + wrap(parseFilter(value, options).join(' && '));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function none (key: FilterValue, values: FilterValue[], options: FilterOptions | undefined): string {
|
|
84
|
+
return '!' + wrap(any(null, values, options));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function propertyMatchesBoolean (key: string, value: boolean): string {
|
|
88
|
+
return wrap(lookUp(key) + (value ? ' != ' : ' == ') + 'null');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function rangeMatch (key: string, value: Record<string, unknown>, options: FilterOptions | undefined): string {
|
|
92
|
+
var expressions = [];
|
|
93
|
+
var transform = options && (typeof options.rangeTransform === 'function') && options.rangeTransform;
|
|
94
|
+
|
|
95
|
+
if (value.max) {
|
|
96
|
+
var max = transform ? transform(value.max) : value.max;
|
|
97
|
+
expressions.push('' + lookUp(key) + ' < ' + max);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (value.min) {
|
|
101
|
+
var min: unknown = transform ? min = transform(value.min) : value.min;
|
|
102
|
+
expressions.push('' + lookUp(key) + ' >= ' + min);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return wrap(expressions.join(' && '));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function includesMatch (key: string, value: Record<string, unknown>, _options?: FilterOptions): string {
|
|
109
|
+
let expressions = [];
|
|
110
|
+
|
|
111
|
+
// the array includes ONE OE MORE of the provided values (a single value is converted to an array)
|
|
112
|
+
if (value.includes_any) {
|
|
113
|
+
const vals = Array.isArray(value.includes_any) ? value.includes_any : [value.includes_any];
|
|
114
|
+
const arr = '['+ vals.map(maybeQuote).join(',') + ']';
|
|
115
|
+
expressions.push(`${lookUp(key)} != null && ${arr}.some(function(v) { return ${lookUp(key)}.indexOf(v) > -1 })`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// the array includes ALL of the provided values (a single value is converted to an array)
|
|
119
|
+
if (value.includes_all) {
|
|
120
|
+
const vals = Array.isArray(value.includes_all) ? value.includes_all : [value.includes_all];
|
|
121
|
+
const arr = '[' + vals.map(maybeQuote).join(',') + ']';
|
|
122
|
+
expressions.push(`${lookUp(key)} != null && ${arr}.every(function(v) { return ${lookUp(key)}.indexOf(v) > -1 })`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return wrap(expressions.join(' && '));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function parseFilter (filter: FilterValue, options: FilterOptions | undefined): FilterAst {
|
|
129
|
+
var filterAST: FilterAst = [];
|
|
130
|
+
|
|
131
|
+
// Function filter
|
|
132
|
+
if (typeof filter === 'function') {
|
|
133
|
+
return [wrap(wrap(filter.toString()) + '(context)')];
|
|
134
|
+
}
|
|
135
|
+
// Array filter, implicit 'any'
|
|
136
|
+
else if (Array.isArray(filter)) {
|
|
137
|
+
return [any(null, filter, options)];
|
|
138
|
+
}
|
|
139
|
+
// Null filter object
|
|
140
|
+
else if (filter == null) {
|
|
141
|
+
return ['true'];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Object filter, e.g. implicit 'all'
|
|
145
|
+
var keys = Object.keys(filter as object);
|
|
146
|
+
for (var k=0; k < keys.length; k++) {
|
|
147
|
+
var key = keys[k];
|
|
148
|
+
|
|
149
|
+
var value = (filter as Record<string, unknown>)[key],
|
|
150
|
+
type = typeof value;
|
|
151
|
+
if (type === 'string' || type === 'number') {
|
|
152
|
+
filterAST.push(propertyEqual(key, value));
|
|
153
|
+
} else if (type === 'boolean') {
|
|
154
|
+
filterAST.push(propertyMatchesBoolean(key, value as boolean));
|
|
155
|
+
} else if (key === 'not') {
|
|
156
|
+
filterAST.push(not(key, value, options));
|
|
157
|
+
} else if (key === 'any') {
|
|
158
|
+
filterAST.push(any(key, value as FilterValue[], options));
|
|
159
|
+
} else if (key === 'all') {
|
|
160
|
+
filterAST.push(all(key, value as FilterValue[], options));
|
|
161
|
+
} else if (key === 'none') {
|
|
162
|
+
filterAST.push(none(key, value as FilterValue[], options));
|
|
163
|
+
} else if (Array.isArray(value)) {
|
|
164
|
+
filterAST.push(propertyOr(key, value));
|
|
165
|
+
} else if (type === 'object' && value != null) {
|
|
166
|
+
if ((value as Record<string, unknown>).max || (value as Record<string, unknown>).min) {
|
|
167
|
+
filterAST.push(rangeMatch(key, value as Record<string, unknown>, options));
|
|
168
|
+
}
|
|
169
|
+
else if ((value as Record<string, unknown>).includes_any || (value as Record<string, unknown>).includes_all) {
|
|
170
|
+
filterAST.push(includesMatch(key, value as Record<string, unknown>, options));
|
|
171
|
+
}
|
|
172
|
+
} else if (value == null) {
|
|
173
|
+
filterAST.push(nullValue(key, value));
|
|
174
|
+
} else {
|
|
175
|
+
throw new Error('Unknown Query syntax: ' + value);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return keys.length === 0 ? ['true'] : filterAST;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function filterToString (filterAST: FilterAst): string {
|
|
183
|
+
return wrap(filterAST.join(' && '));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function buildFilter (filter: FilterValue, options?: FilterOptions): FilterFunction {
|
|
187
|
+
if (filter == null) { return function () { return true; }; }
|
|
188
|
+
// jshint evil: true
|
|
189
|
+
return new Function('context', 'return ' + filterToString(parseFilter(filter, options)) + ';') as FilterFunction;
|
|
190
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type VertexData from '../gl/vertex_data';
|
|
6
|
+
import type VertexLayout from '../gl/vertex_layout';
|
|
7
|
+
import type UniformBuffer from '../gl/uniform_buffer';
|
|
8
|
+
import type {UniformBufferOptions} from '../gl/uniform_buffer';
|
|
9
|
+
import type {VertexAttribute} from '../gl/vertex-types';
|
|
10
|
+
import type {GeometryLine, GeometryPolygon, PolylineStyle} from '../builders/geometry-types';
|
|
11
|
+
import type {PropertyCache, PropertyContext, StyleFeature} from './property-types';
|
|
12
|
+
import type {ProjectedBasemapOptions} from '../procedures/mesh-projector';
|
|
13
|
+
|
|
14
|
+
/** Geometry feature properties normalized by the source and style expression boundary. */
|
|
15
|
+
export interface GeometryFeature extends StyleFeature {
|
|
16
|
+
properties: Record<string, unknown> & {height?: number; min_height?: number};
|
|
17
|
+
}
|
|
18
|
+
/** Tile state consumed by line width interpolation and edge clipping. */
|
|
19
|
+
export interface GeometryTile {
|
|
20
|
+
id: string | number;
|
|
21
|
+
pad_scale: number;
|
|
22
|
+
overzoom2: number;
|
|
23
|
+
}
|
|
24
|
+
/** Evaluation context with the tile conversions needed by geometry construction. */
|
|
25
|
+
export interface GeometryContext extends PropertyContext {
|
|
26
|
+
/** EPSG:3857 meters per CSS pixel at the style zoom. */
|
|
27
|
+
meters_per_pixel: number;
|
|
28
|
+
feature: GeometryFeature;
|
|
29
|
+
zoom: number;
|
|
30
|
+
units_per_meter_overzoom: number;
|
|
31
|
+
tile: GeometryTile;
|
|
32
|
+
winding?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Authored extrusion resolves to a flag, height, or [minimum height, height]. */
|
|
35
|
+
export type GeometryExtrusion = boolean | number | number[] | null | undefined;
|
|
36
|
+
/** Normalized mesh variant shared by outlines, polygons, and portable attributes. */
|
|
37
|
+
export interface GeometryMeshVariant {
|
|
38
|
+
key: string | number;
|
|
39
|
+
blend_order: number | undefined;
|
|
40
|
+
mesh_order: number;
|
|
41
|
+
selection: number;
|
|
42
|
+
normal?: number;
|
|
43
|
+
offset?: number;
|
|
44
|
+
z_or_offset?: number;
|
|
45
|
+
texcoords?: number | boolean;
|
|
46
|
+
texture?: string | null | false;
|
|
47
|
+
dash?: number[] | null | false;
|
|
48
|
+
dash_key?: string | null | false;
|
|
49
|
+
dash_background_color?: number[] | null | false;
|
|
50
|
+
}
|
|
51
|
+
/** Per-draw cache fields after property preprocessing, not evaluated feature values. */
|
|
52
|
+
export interface GeometryDraw {
|
|
53
|
+
/** Internal fixed-pixel stroke marker captured before distance preprocessing. */
|
|
54
|
+
projected_pixel_width?: boolean;
|
|
55
|
+
color?: PropertyCache | null;
|
|
56
|
+
alpha?: PropertyCache;
|
|
57
|
+
width?: PropertyCache;
|
|
58
|
+
next_width?: PropertyCache;
|
|
59
|
+
offset?: PropertyCache | null;
|
|
60
|
+
next_offset?: PropertyCache;
|
|
61
|
+
z?: PropertyCache;
|
|
62
|
+
extrude?: unknown;
|
|
63
|
+
interactive?: unknown;
|
|
64
|
+
cap?: PolylineStyle['cap'];
|
|
65
|
+
join?: PolylineStyle['join'];
|
|
66
|
+
miter_limit?: number;
|
|
67
|
+
variant: string | number;
|
|
68
|
+
tile_edges?: boolean;
|
|
69
|
+
texcoords?: number | boolean;
|
|
70
|
+
inline_texcoord_width?: number | null;
|
|
71
|
+
offset_precalc?: number;
|
|
72
|
+
offset_scale_precalc?: number;
|
|
73
|
+
dash?: number[] | null | false;
|
|
74
|
+
dash_key?: string | null | false;
|
|
75
|
+
dash_background_color?: number[] | null | false;
|
|
76
|
+
texture?: string | null;
|
|
77
|
+
texture_merged?: string | null | false;
|
|
78
|
+
is_outline?: boolean;
|
|
79
|
+
visible?: boolean;
|
|
80
|
+
order?: unknown;
|
|
81
|
+
blend_order?: number;
|
|
82
|
+
layers: string[];
|
|
83
|
+
style: string;
|
|
84
|
+
preprocessed?: boolean;
|
|
85
|
+
outline?: GeometryDraw | null;
|
|
86
|
+
}
|
|
87
|
+
/** Values may be authored scalars/functions before the cache wrappers are installed. */
|
|
88
|
+
export type RawGeometryDraw = Omit<GeometryDraw, 'variant' | 'color' | 'alpha' | 'width' | 'offset' | 'z' | 'dash_background_color' | 'outline'> & {
|
|
89
|
+
variant?: string | number;
|
|
90
|
+
color?: unknown;
|
|
91
|
+
alpha?: unknown;
|
|
92
|
+
width?: unknown;
|
|
93
|
+
offset?: unknown;
|
|
94
|
+
z?: unknown;
|
|
95
|
+
dash_background_color?: unknown;
|
|
96
|
+
outline?: RawGeometryDraw | null;
|
|
97
|
+
};
|
|
98
|
+
/** Reused feature record; the base style and parsing methods populate it before building. */
|
|
99
|
+
export interface PolygonFeatureStyle {
|
|
100
|
+
color: number[];
|
|
101
|
+
alpha?: number;
|
|
102
|
+
variant: string | number;
|
|
103
|
+
z: number;
|
|
104
|
+
height: number;
|
|
105
|
+
min_height: number;
|
|
106
|
+
extrude: GeometryExtrusion;
|
|
107
|
+
tile_edges?: boolean;
|
|
108
|
+
order: number;
|
|
109
|
+
selection_color: number[];
|
|
110
|
+
}
|
|
111
|
+
/** Computed line values, including interpolation and a reusable cached outline. */
|
|
112
|
+
export interface LineFeatureStyle extends Omit<PolygonFeatureStyle, 'min_height'>, PolylineStyle {
|
|
113
|
+
/** Packed extrusion units per CSS pixel, zero for meter-width strokes. */
|
|
114
|
+
projected_pixel_scale?: number;
|
|
115
|
+
width_unscaled: number;
|
|
116
|
+
next_width_unscaled: number;
|
|
117
|
+
width_scale: number;
|
|
118
|
+
offset_scale: number;
|
|
119
|
+
outline?: GeometryOutlineDraw;
|
|
120
|
+
}
|
|
121
|
+
/** The outline scratch record always owns width caches, populated before submission. */
|
|
122
|
+
export interface GeometryOutlineDraw extends GeometryDraw {
|
|
123
|
+
width: PropertyCache;
|
|
124
|
+
next_width: PropertyCache;
|
|
125
|
+
order: number;
|
|
126
|
+
}
|
|
127
|
+
/** Worker-side mesh records while packed geometry is still being accumulated. */
|
|
128
|
+
export interface GeometryBuildMesh {
|
|
129
|
+
vertex_data: VertexData;
|
|
130
|
+
variant: GeometryMeshVariant;
|
|
131
|
+
uniforms?: Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
/** Completed tile records used to assign dash/texture uniforms before submission. */
|
|
134
|
+
export interface GeometryTileData {
|
|
135
|
+
uniforms: Record<string, unknown>;
|
|
136
|
+
meshes: Record<string, {variant: GeometryMeshVariant; uniforms?: Record<string, unknown>}>;
|
|
137
|
+
}
|
|
138
|
+
/** Checked geometry style surface; inherited base lifecycle remains a separate tranche. */
|
|
139
|
+
export interface GeometryStyleRuntime<FeatureStyle extends Omit<PolygonFeatureStyle, 'min_height'> = PolygonFeatureStyle> {
|
|
140
|
+
/** Opt-in validated worker height field; absent preserves the original packed layout. */
|
|
141
|
+
terrain?: import('../procedures/terrain-draping').TerrainDrapingSnapshot;
|
|
142
|
+
name: string;
|
|
143
|
+
built_in: boolean;
|
|
144
|
+
vertex_shader_src: string;
|
|
145
|
+
fragment_shader_src: string;
|
|
146
|
+
selection: boolean;
|
|
147
|
+
animated?: boolean;
|
|
148
|
+
texcoords?: boolean;
|
|
149
|
+
raster?: string | boolean;
|
|
150
|
+
shader_language: 'glsl' | 'wgsl';
|
|
151
|
+
/** Optional scene-wide CPU projection of ground surfaces and fixed-meter line ribbons. */
|
|
152
|
+
cpu_projection?: ProjectedBasemapOptions;
|
|
153
|
+
/** Authored polygon lighting, disabled for initial CPU-projected ground. */
|
|
154
|
+
lighting?: 'vertex' | 'fragment' | boolean;
|
|
155
|
+
/** Position blocks and custom attributes are outside the initial contract. */
|
|
156
|
+
shaders?: {blocks?: {position?: unknown}; attributes?: unknown};
|
|
157
|
+
/** Underlying builtin style after inheritance and mixins. */
|
|
158
|
+
baseStyle(): string;
|
|
159
|
+
portable_lighting_mode?: 'vertex' | 'fragment' | false;
|
|
160
|
+
portable_light_count?: number;
|
|
161
|
+
defines: Record<string, boolean | number | string | undefined>;
|
|
162
|
+
feature_style: FeatureStyle;
|
|
163
|
+
vertex_template: number[];
|
|
164
|
+
variants: Record<string | number, GeometryMeshVariant>;
|
|
165
|
+
vertex_layouts: Record<string | number, VertexLayout>;
|
|
166
|
+
texture?: string;
|
|
167
|
+
dash?: number[] | null | false;
|
|
168
|
+
dash_background_color?: number[] | null | false;
|
|
169
|
+
init(options?: Record<string, unknown>): void;
|
|
170
|
+
destroy(): void;
|
|
171
|
+
setGL(context: unknown, blocks?: Record<string, UniformBuffer>, options?: Record<string, unknown>): void;
|
|
172
|
+
getWGSLShaderSource(selection?: boolean): string;
|
|
173
|
+
_parseFeature(feature: GeometryFeature, draw: GeometryDraw, context: GeometryContext): FeatureStyle | null | undefined;
|
|
174
|
+
_preprocess(draw: RawGeometryDraw): GeometryDraw;
|
|
175
|
+
computeVariant(draw: GeometryDraw | RawGeometryDraw): void;
|
|
176
|
+
getBlendOrderForDraw(draw: GeometryDraw | RawGeometryDraw): number;
|
|
177
|
+
vertexLayoutForMeshVariant(variant: GeometryMeshVariant): VertexLayout;
|
|
178
|
+
meshVariantTypeForDraw(draw: Pick<GeometryDraw, 'variant'>): GeometryMeshVariant;
|
|
179
|
+
makeVertexTemplate(style: FeatureStyle, mesh: GeometryBuildMesh): number[];
|
|
180
|
+
parseColor(property: PropertyCache | null | undefined, context: GeometryContext): number[];
|
|
181
|
+
parseOrder(value: unknown, context: GeometryContext): number;
|
|
182
|
+
scaleOrder(order: number): number;
|
|
183
|
+
addCustomAttributesToAttributeList(attributes: VertexAttribute[]): void;
|
|
184
|
+
addCustomAttributesToVertexTemplate(style: FeatureStyle, offset: number): void;
|
|
185
|
+
getTileMesh(tile: GeometryTile, variant: GeometryMeshVariant): GeometryBuildMesh;
|
|
186
|
+
startData(tile: GeometryTile): void;
|
|
187
|
+
addFeature(feature: GeometryFeature, draw: GeometryDraw, context: GeometryContext): void;
|
|
188
|
+
buildPolygons(polygons: GeometryPolygon[], style: FeatureStyle, context: GeometryContext): number;
|
|
189
|
+
endData(tile: GeometryTile): Promise<GeometryTileData | null>;
|
|
190
|
+
}
|
|
191
|
+
/** Additional lifecycle and interpolation owned only by line styles. */
|
|
192
|
+
export interface LineStyleRuntime extends GeometryStyleRuntime<LineFeatureStyle> {
|
|
193
|
+
inline_feature_style: LineFeatureStyle;
|
|
194
|
+
outline_feature_style: LineFeatureStyle;
|
|
195
|
+
styles: Record<string, GeometryStyleRuntime<LineFeatureStyle>>;
|
|
196
|
+
dash_textures: Record<string, boolean>;
|
|
197
|
+
main_thread_target: string;
|
|
198
|
+
resource_context: object | null;
|
|
199
|
+
line_uniform_buffer?: UniformBuffer | null;
|
|
200
|
+
uniform_blocks?: Record<string, UniformBuffer> | null;
|
|
201
|
+
uniform_block_factory?: ((options: UniformBufferOptions) => UniformBuffer) | null;
|
|
202
|
+
calcDistance(property: PropertyCache | null | undefined, context: GeometryContext): number;
|
|
203
|
+
calcDistanceNextZoom(property: PropertyCache | null | undefined, context: GeometryContext): number;
|
|
204
|
+
calcWidth(draw: GeometryDraw, style: LineFeatureStyle, context: GeometryContext): boolean | undefined;
|
|
205
|
+
calcOffset(draw: GeometryDraw, style: LineFeatureStyle, context: GeometryContext): void;
|
|
206
|
+
buildLines(lines: GeometryLine[], style: LineFeatureStyle, context: GeometryContext, options?: {closed_polygon?: boolean; remove_tile_edges?: boolean}): number;
|
|
207
|
+
dashTextureKey(dash: number[]): string;
|
|
208
|
+
getDashTexture(dash: number[]): void;
|
|
209
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {globeHorizon} from '../shader-modules/globe-horizon';
|
|
6
|
+
|
|
7
|
+
/** Shared GLSL horizon math with Tangram's radius-256, geographic-altitude contract. */
|
|
8
|
+
export const GLOBE_VISIBILITY_GLSL = `${globeHorizon.vs}
|
|
9
|
+
bool tangramGlobeOccluded(vec3 position, float altitude, vec3 eye) {
|
|
10
|
+
return globeHorizon_isOccluded(
|
|
11
|
+
globeHorizon_getAnchor(position, altitude, 256., 6370972.), eye, 256.);
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
/** Shared WGSL horizon math with the same common-space and altitude contract. */
|
|
16
|
+
export const GLOBE_VISIBILITY_WGSL = `
|
|
17
|
+
${globeHorizon.source}
|
|
18
|
+
fn tangramGlobeOccluded(position: vec3<f32>, altitude: f32, eye: vec3<f32>) -> bool {
|
|
19
|
+
return globeHorizon_isOccluded(
|
|
20
|
+
globeHorizon_getAnchor(position, altitude, 256.0, 6370972.0), eye, 256.0);
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {PropertyContext} from './property-types';
|
|
6
|
+
import type {LayerTree, LayerLeaf} from './layer';
|
|
7
|
+
|
|
8
|
+
/** Raw YAML members validated lazily during matching. */
|
|
9
|
+
export type SceneLayerDefinition = Record<string, unknown>;
|
|
10
|
+
/** Extensible evaluated draw properties for built-in and custom styles. */
|
|
11
|
+
export interface LayerDrawGroup extends Record<string, unknown> {
|
|
12
|
+
/** Resolved style registry name, when it differs from the draw-group name. */
|
|
13
|
+
style?: string;
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
key?: string;
|
|
16
|
+
layers?: string[];
|
|
17
|
+
group?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Named draw groups at one scene-tree depth. */
|
|
20
|
+
export type LayerDrawGroups = Record<string, LayerDrawGroup | null>;
|
|
21
|
+
/** Leaf/tree candidates sharing the legacy matching order. */
|
|
22
|
+
export type SceneLayer = LayerTree | LayerLeaf;
|
|
23
|
+
/** A lazy layer constructor's reserved properties. */
|
|
24
|
+
export interface LayerConfig {
|
|
25
|
+
layer: SceneLayerDefinition;
|
|
26
|
+
name: string;
|
|
27
|
+
parent?: LayerTree | null;
|
|
28
|
+
draw?: Record<string, unknown>;
|
|
29
|
+
visible?: boolean;
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
filter?: unknown;
|
|
32
|
+
exclusive?: boolean;
|
|
33
|
+
priority?: number;
|
|
34
|
+
styles?: Record<string, unknown>;
|
|
35
|
+
layers?: SceneLayer[];
|
|
36
|
+
}
|
|
37
|
+
/** Context used by feature, property, and zoom filters. */
|
|
38
|
+
export interface LayerMatchContext extends PropertyContext {
|
|
39
|
+
zoom: number;
|
|
40
|
+
feature: NonNullable<PropertyContext['feature']>;
|
|
41
|
+
}
|
|
42
|
+
/** Optimized match retaining the original comparison values. */
|
|
43
|
+
export type LayerPropertyMatch = [string, unknown[]];
|
|
44
|
+
/** Null means evaluated with no draw; undefined means not evaluated. */
|
|
45
|
+
export type LayerCombinationCache = Record<string, LayerDrawGroups | null | undefined>;
|