@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,127 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import Geo from '../../utils/geo';
|
|
6
|
+
import {GLOBE_PROJECTION_WGSL, GLOBE_NORMAL_WGSL, TERRAIN_DRAPING_WGSL, TERRAIN_GLOBE_ATTRIBUTES_WGSL} from '../../scene/projection_shaders';
|
|
7
|
+
import {buildLightingWGSL} from '../../lights/lighting-wgsl';
|
|
8
|
+
|
|
9
|
+
const LAYER_DELTA = 1 / (1 << 14);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Build the portable polygon shader used by the luma.gl WebGPU renderer.
|
|
13
|
+
*
|
|
14
|
+
* Tangram's existing GLSL shader composer remains authoritative for WebGL.
|
|
15
|
+
* This deliberately small WGSL program establishes the native-device path for
|
|
16
|
+
* flat polygons and raster tiles before the remaining style features are ported.
|
|
17
|
+
*/
|
|
18
|
+
export function buildPolygonsWGSL({ raster = false, lighting, lightCount, cpuProjection = false, terrain = false, selection = false }: {
|
|
19
|
+
/** Physical ground displacement and slope normals from worker attributes. */
|
|
20
|
+
terrain?: boolean;
|
|
21
|
+
/** Emit the worker selection key without lighting or color blending. */
|
|
22
|
+
selection?: boolean;
|
|
23
|
+
/** Include raster color sampling. */
|
|
24
|
+
raster?: boolean;
|
|
25
|
+
/** Opt into configured lights; undefined retains historical portable wall shading. */
|
|
26
|
+
lighting?: 'vertex' | 'fragment' | false;
|
|
27
|
+
/** Active scene light count, used to specialize shader compilation. */
|
|
28
|
+
lightCount?: number;
|
|
29
|
+
/** Use worker-projected common positions while retaining tile-local UVs. */
|
|
30
|
+
cpuProjection?: boolean;
|
|
31
|
+
} = {}) {
|
|
32
|
+
const raster_declarations = raster ? `
|
|
33
|
+
@group(0) @binding(3) var u_rasters: texture_2d<f32>;
|
|
34
|
+
@group(0) @binding(4) var u_rastersSampler: sampler;
|
|
35
|
+
` : '';
|
|
36
|
+
const raster_fragment = raster ? `
|
|
37
|
+
// Tangram's raster images are uploaded without a WebGL Y flip on WebGPU,
|
|
38
|
+
// so use top-left texture coordinates for the tile-local geometry.
|
|
39
|
+
let raster_color = textureSample(u_rasters, u_rastersSampler, input.raster_uv);
|
|
40
|
+
var color = input.color * raster_color;
|
|
41
|
+
` : ' var color = input.color;\n';
|
|
42
|
+
const configured = lighting === 'vertex' || lighting === 'fragment';
|
|
43
|
+
const shade = lighting === 'fragment' ? 'color = tangramCalculateLighting(input.eye_position, normalize(input.normal), color);' :
|
|
44
|
+
lighting === 'vertex' ? 'color *= input.lighting;' : '';
|
|
45
|
+
|
|
46
|
+
return `
|
|
47
|
+
${raster_declarations}
|
|
48
|
+
${GLOBE_PROJECTION_WGSL}
|
|
49
|
+
${GLOBE_NORMAL_WGSL}
|
|
50
|
+
${terrain ? TERRAIN_DRAPING_WGSL : ''}
|
|
51
|
+
${configured ? buildLightingWGSL(lightCount) : ''}
|
|
52
|
+
struct PolygonAttributes {
|
|
53
|
+
${terrain ? TERRAIN_GLOBE_ATTRIBUTES_WGSL : ''}
|
|
54
|
+
${terrain ? '@location(14) a_terrain: vec4<f32>, @location(15) a_terrain_previous: vec4<f32>,' : ''}
|
|
55
|
+
@location(0) a_position: vec4<${terrain ? 'f32' : 'i32'}>,
|
|
56
|
+
@location(1) a_normal: vec4<f32>,
|
|
57
|
+
@location(2) a_color: vec4<f32>,
|
|
58
|
+
${selection ? '@location(5) a_selection_color: vec4<f32>,' : ''}
|
|
59
|
+
${cpuProjection ? '@location(3) a_projected_position: vec3<f32>, @location(4) a_projected_normal: vec3<f32>,' : ''}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
struct PolygonVaryings {
|
|
63
|
+
@builtin(position) position: vec4<f32>,
|
|
64
|
+
@location(0) color: vec4<f32>,
|
|
65
|
+
@location(1) raster_uv: vec2<f32>,
|
|
66
|
+
@location(2) normal: vec3<f32>,
|
|
67
|
+
@location(3) eye_position: vec3<f32>,
|
|
68
|
+
@location(4) lighting: vec4<f32>,
|
|
69
|
+
@location(5) tile_position: vec2<f32>,
|
|
70
|
+
${selection ? '@location(6) @interpolate(flat) selection_color: vec4<f32>,' : ''}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
@vertex
|
|
74
|
+
fn vertexMain(attributes: PolygonAttributes) -> PolygonVaryings {
|
|
75
|
+
var output: PolygonVaryings;
|
|
76
|
+
${selection ? 'output.selection_color = attributes.a_selection_color;' : ''}
|
|
77
|
+
let local_position = vec4<f32>(
|
|
78
|
+
f32(attributes.a_position.x),
|
|
79
|
+
f32(attributes.a_position.y),
|
|
80
|
+
f32(attributes.a_position.z) / ${Geo.height_scale}.0 ${terrain ? '+ tangramTerrainHeight(attributes.a_terrain, attributes.a_terrain_previous)' : ''},
|
|
81
|
+
1.0
|
|
82
|
+
);
|
|
83
|
+
let eye_position = ${cpuProjection ? 'vec4<f32>(attributes.a_projected_position, 1.0)' : terrain ? 'tangramTerrainModelView(local_position, attributes.a_terrain, attributes.a_terrain_previous, attributes.a_terrain_globe_base, attributes.a_terrain_globe_relief, attributes.a_terrain_globe_base_previous, attributes.a_terrain_globe_relief_previous)' : 'tangramModelView(local_position)'};
|
|
84
|
+
var clip_position = TangramCamera.u_projection * eye_position;
|
|
85
|
+
${cpuProjection ? '// deck orthographic matrices use WebGL [-w, w] depth; WebGPU requires [0, w].\n clip_position.z = (clip_position.z + clip_position.w) * 0.5;' : ''}
|
|
86
|
+
let layer = f32(attributes.a_position.w) +
|
|
87
|
+
TangramTile.u_tile_proxy_order_offset + 1.0;
|
|
88
|
+
clip_position.z -= layer * ${cpuProjection ? LAYER_DELTA * 0.5 : LAYER_DELTA} * clip_position.w;
|
|
89
|
+
|
|
90
|
+
var surface_normal = normalize(attributes.a_normal.xyz);
|
|
91
|
+
${terrain ? 'surface_normal = tangramTerrainNormal(surface_normal, attributes.a_terrain, attributes.a_terrain_previous, vec2<f32>(attributes.a_position.xy));' : ''}
|
|
92
|
+
if (TangramView.u_projection_mode == 1) {
|
|
93
|
+
let world_position = TangramTile.u_model * local_position;
|
|
94
|
+
surface_normal = tangramGlobeNormal(world_position.xyz, surface_normal);
|
|
95
|
+
}
|
|
96
|
+
${configured ? `else { surface_normal = normalize(TangramTile.u_normalMatrix * surface_normal); }` : ''}
|
|
97
|
+
${cpuProjection ? 'surface_normal = normalize(attributes.a_projected_normal);' : ''}
|
|
98
|
+
let light_direction = normalize(vec3<f32>(0.35, -0.45, 0.82));
|
|
99
|
+
let diffuse = max(dot(surface_normal, light_direction), 0.0);
|
|
100
|
+
// Roof/wall classification stays local; geographic north is not surface up.
|
|
101
|
+
let side_amount = 1.0 - smoothstep(0.8, 0.98, abs(normalize(attributes.a_normal.xyz).z));
|
|
102
|
+
let light = mix(1.0, 0.58 + 0.52 * diffuse, side_amount);
|
|
103
|
+
|
|
104
|
+
output.position = clip_position;
|
|
105
|
+
output.tile_position = local_position.xy;
|
|
106
|
+
output.normal = surface_normal;
|
|
107
|
+
output.eye_position = eye_position.xyz - TangramCamera.u_eye;
|
|
108
|
+
output.lighting = ${lighting === 'vertex' ? 'tangramCalculateLighting(output.eye_position, surface_normal, vec4<f32>(1.0))' : 'vec4<f32>(1.0)'};
|
|
109
|
+
output.color = ${lighting === undefined ? 'vec4<f32>(attributes.a_color.rgb * light, attributes.a_color.a)' : 'attributes.a_color'};
|
|
110
|
+
output.raster_uv = vec2<f32>(
|
|
111
|
+
f32(attributes.a_position.x) / ${Geo.tile_scale}.0,
|
|
112
|
+
-f32(attributes.a_position.y) / ${Geo.tile_scale}.0
|
|
113
|
+
);
|
|
114
|
+
return output;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@fragment
|
|
118
|
+
fn fragmentMain(input: PolygonVaryings) -> @location(0) vec4<f32> {
|
|
119
|
+
if (TangramTile.u_tile_clip_bounds.z > TangramTile.u_tile_clip_bounds.x &&
|
|
120
|
+
(any(input.tile_position < TangramTile.u_tile_clip_bounds.xy) ||
|
|
121
|
+
any(input.tile_position >= TangramTile.u_tile_clip_bounds.zw))) { discard; }
|
|
122
|
+
${raster_fragment}
|
|
123
|
+
${shade}
|
|
124
|
+
return ${selection ? 'input.selection_color' : 'color'};
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Feature data available to dynamic scene expressions. */
|
|
6
|
+
export interface StyleFeature {
|
|
7
|
+
id?: string | number;
|
|
8
|
+
geometry: {type: string};
|
|
9
|
+
properties: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Tile conversions used when constructing a feature evaluation context. */
|
|
13
|
+
export interface StyleParseTile {
|
|
14
|
+
style_z: number;
|
|
15
|
+
meters_per_pixel: number;
|
|
16
|
+
meters_per_pixel_sq: number;
|
|
17
|
+
units_per_meter_overzoom: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Context may be partial for static expressions; feature evaluation supplies all required fields. */
|
|
21
|
+
export interface PropertyContext {
|
|
22
|
+
zoom?: number;
|
|
23
|
+
feature?: StyleFeature;
|
|
24
|
+
layers?: string[];
|
|
25
|
+
global?: unknown;
|
|
26
|
+
[name: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Dynamic values are intentionally unknown until the owning property parser normalizes them. */
|
|
30
|
+
export type PropertyFunction = ((context: PropertyContext) => unknown) & {source?: string};
|
|
31
|
+
|
|
32
|
+
/** Mutable cache shared by static, dynamic, and zoom-interpolated scene properties. */
|
|
33
|
+
export interface PropertyCache {
|
|
34
|
+
/** Original or once-normalized property; dynamic results are not stored here. */
|
|
35
|
+
value: unknown;
|
|
36
|
+
/** Legacy cache category, populated during construction. */
|
|
37
|
+
type?: number;
|
|
38
|
+
/** Lazily evaluated static value (including falsy values). */
|
|
39
|
+
static?: unknown;
|
|
40
|
+
/** Lazily interpolated results keyed by style zoom. */
|
|
41
|
+
zoom?: Record<number, unknown> | null;
|
|
42
|
+
/** Compiled per-feature evaluator, installed on first evaluation. */
|
|
43
|
+
dynamic?: PropertyFunction;
|
|
44
|
+
/** Optional post-evaluation normalization for dynamic values. */
|
|
45
|
+
dynamic_transform?: ((value: unknown) => unknown) | null;
|
|
46
|
+
/** Whether authored string colors have been normalized within zoom stops. */
|
|
47
|
+
zoom_preprocessed?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Coordinate/value stop consumed by the legacy interpolation procedure. */
|
|
51
|
+
export type PropertyStop = [number, unknown];
|
|
52
|
+
|
|
53
|
+
/** Unit value normalized before distance interpolation. */
|
|
54
|
+
export interface UnitValue {
|
|
55
|
+
value: number | number[];
|
|
56
|
+
units?: 'px';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Texture/sprite metadata used for percent and aspect-ratio sizing. */
|
|
60
|
+
export interface PointSizeImage {
|
|
61
|
+
sprite?: string;
|
|
62
|
+
css_size: number[];
|
|
63
|
+
aspect: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Per-stop flags retain the legacy scalar/array representation. */
|
|
67
|
+
export type PointSizeFlags = (boolean | boolean[])[];
|
|
68
|
+
|
|
69
|
+
/** Point sizes using image-relative percentages or an automatic dimension. */
|
|
70
|
+
export interface PointSizeCache extends PropertyCache {
|
|
71
|
+
/** Percentage flags matching the original scalar/vector stop shape. */
|
|
72
|
+
has_pct?: PointSizeFlags | null;
|
|
73
|
+
/** Aspect-ratio flags matching the original scalar/vector stop shape. */
|
|
74
|
+
has_ratio?: PointSizeFlags | null;
|
|
75
|
+
/** Independent evaluated caches keyed by sprite name. */
|
|
76
|
+
sprites?: Record<string, PropertyCache | undefined>;
|
|
77
|
+
/** Evaluated cache for an entire texture rather than a named sprite. */
|
|
78
|
+
texture?: PropertyCache;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** A one-time property normalization, with its zoom-stop index. */
|
|
82
|
+
export type PropertyTransform = (value: unknown, index: number) => unknown;
|
|
83
|
+
|
|
84
|
+
/** Checked callable surface of the incrementally initialized legacy parser object. */
|
|
85
|
+
export interface StyleParserRuntime {
|
|
86
|
+
/** Retains Math.max coercion, including array results from legacy nested inputs. */
|
|
87
|
+
clampPositive(value: unknown): number;
|
|
88
|
+
noNaN(value: number): number;
|
|
89
|
+
parseNumber(value: unknown[]): number[];
|
|
90
|
+
parseNumber(value: string | number | boolean | null | undefined): number;
|
|
91
|
+
parseNumber(value: unknown): number | number[];
|
|
92
|
+
parsePositiveNumber(value: unknown[]): number[];
|
|
93
|
+
parsePositiveNumber(value: string | number | boolean | null | undefined): number;
|
|
94
|
+
parsePositiveNumber(value: unknown): number | number[];
|
|
95
|
+
/** Preserve NaN only for properties that validate their own numeric contract. */
|
|
96
|
+
wrapFunction(source: string | (() => number[]), preserveNaN?: boolean): string;
|
|
97
|
+
zeroPair: readonly [number, number];
|
|
98
|
+
defaults: {
|
|
99
|
+
color: number[]; width: number; size: number; extrude: boolean;
|
|
100
|
+
height: number; min_height: number; order: number; z: number;
|
|
101
|
+
outline: {color: number[]; width: number}; material: {ambient: number; diffuse: number};
|
|
102
|
+
};
|
|
103
|
+
macros: Record<string, () => number[]>;
|
|
104
|
+
CACHE_TYPE: {STATIC: number; DYNAMIC: number; ZOOM: number};
|
|
105
|
+
getFeatureParseContext(feature: StyleFeature, tile: StyleParseTile, global: unknown): PropertyContext & {feature: StyleFeature; zoom: number};
|
|
106
|
+
createPropertyCache(value: unknown, transform?: PropertyTransform | null, dynamicTransform?: ((value: unknown) => unknown) | null): PropertyCache | undefined;
|
|
107
|
+
createColorPropertyCache(value: unknown): PropertyCache | undefined;
|
|
108
|
+
createPointSizePropertyCache(value: unknown, texture?: unknown): PointSizeCache | undefined;
|
|
109
|
+
evalCachedPointSizeProperty(value: PointSizeCache | null | undefined, sprite: PointSizeImage | null | undefined, texture: PointSizeImage | null | undefined, context: PropertyContext): unknown;
|
|
110
|
+
evalCachedProperty(value: PropertyCache | null | undefined, context: PropertyContext): unknown;
|
|
111
|
+
convertUnits(value: unknown, context: PropertyContext): unknown;
|
|
112
|
+
parseUnits(value: unknown): UnitValue;
|
|
113
|
+
/** Cache projected annotation heights without legacy NaN-to-zero coercion. */
|
|
114
|
+
createProjectedHeightPropertyCache(value: unknown): PropertyCache | undefined;
|
|
115
|
+
/** Evaluate projected heights without swallowing dynamic expression errors. */
|
|
116
|
+
evalProjectedHeightProperty(value: PropertyCache | undefined, context: PropertyContext): unknown;
|
|
117
|
+
evalCachedDistanceProperty(value: PropertyCache | null | undefined, context: PropertyContext): unknown;
|
|
118
|
+
string_colors: Record<string, number[]>;
|
|
119
|
+
colorForString(value: string): number[];
|
|
120
|
+
evalCachedColorProperty(value: PropertyCache | null | undefined, context?: PropertyContext): number[] | undefined;
|
|
121
|
+
evalCachedColorPropertyWithAlpha(value: PropertyCache | null | undefined, alpha: PropertyCache | null | undefined, context: PropertyContext): unknown[] | undefined;
|
|
122
|
+
parseColor(value: unknown, context?: PropertyContext): number[];
|
|
123
|
+
calculateOrder(value: unknown, context: PropertyContext): unknown;
|
|
124
|
+
evalProperty(value: unknown, context: PropertyContext): unknown;
|
|
125
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
// Raster tile rendering style
|
|
7
|
+
|
|
8
|
+
import StyleParser from '../style_parser';
|
|
9
|
+
import {Polygons} from '../polygons/polygons';
|
|
10
|
+
|
|
11
|
+
export let RasterStyle: any = Object.create(Polygons);
|
|
12
|
+
|
|
13
|
+
Object.assign(RasterStyle, {
|
|
14
|
+
name: 'raster',
|
|
15
|
+
super: Polygons,
|
|
16
|
+
built_in: true,
|
|
17
|
+
|
|
18
|
+
init (this: any): void {
|
|
19
|
+
// Required for raster tiles
|
|
20
|
+
this.raster = this.raster || 'color';
|
|
21
|
+
|
|
22
|
+
this.super.init.apply(this, arguments);
|
|
23
|
+
|
|
24
|
+
this.selection = false; // raster styles can't support feature selection
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
_preprocess (this: any, draw: any): any {
|
|
28
|
+
// Raster tiles default to white vertex color, as this color will tint the underlying texture
|
|
29
|
+
draw.color = draw.color || (StyleParser as any).defaults.color;
|
|
30
|
+
return this.super._preprocess.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Tangram
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) 2013-2016 Brett Camper and Mapzen
|
|
4
|
+
|
|
5
|
+
// Uniforms defining raster textures and macros for accessing them
|
|
6
|
+
|
|
7
|
+
#ifdef TANGRAM_FRAGMENT_SHADER
|
|
8
|
+
uniform sampler2D u_rasters[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture samplers
|
|
9
|
+
uniform vec2 u_raster_sizes[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture sizes (width/height in pixels)
|
|
10
|
+
uniform vec3 u_raster_offsets[TANGRAM_NUM_RASTER_SOURCES]; // raster tile texture UV starting offset for tile
|
|
11
|
+
|
|
12
|
+
// Raster sources can optionally mask by the alpha channel (render with only full or no alpha, based on a threshold),
|
|
13
|
+
// which is used for handling transparency outside the raster image when rendering with opaque blending
|
|
14
|
+
#if defined(TANGRAM_HAS_MASKED_RASTERS) && !defined(TANGRAM_ALL_MASKED_RASTERS) // only add uniform if we need it
|
|
15
|
+
uniform bool u_raster_mask_alpha;
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Note: the raster accessors below are #defines rather than functions to
|
|
19
|
+
// avoid issues with constant integer expressions for array indices
|
|
20
|
+
|
|
21
|
+
// Adjusts UVs in model space to account for raster tile texture overzooming
|
|
22
|
+
// (applies scale and offset adjustments)
|
|
23
|
+
#define adjustRasterUV(raster_index, uv) \
|
|
24
|
+
((uv) * u_raster_offsets[raster_index].z + u_raster_offsets[raster_index].xy)
|
|
25
|
+
|
|
26
|
+
// Returns the UVs of the current model position for a raster sampler
|
|
27
|
+
#define currentRasterUV(raster_index) \
|
|
28
|
+
(adjustRasterUV(raster_index, v_modelpos_base_zoom.xy))
|
|
29
|
+
|
|
30
|
+
// Returns pixel location in raster tile texture at current model position
|
|
31
|
+
#define currentRasterPixel(raster_index) \
|
|
32
|
+
(currentRasterUV(raster_index) * rasterPixelSize(raster_index))
|
|
33
|
+
|
|
34
|
+
// Samples a raster tile texture for the current model position
|
|
35
|
+
#define sampleRaster(raster_index) \
|
|
36
|
+
(texture2D(u_rasters[raster_index], currentRasterUV(raster_index)))
|
|
37
|
+
|
|
38
|
+
// Samples a raster tile texture for a given pixel
|
|
39
|
+
#define sampleRasterAtPixel(raster_index, pixel) \
|
|
40
|
+
(texture2D(u_rasters[raster_index], (pixel) / rasterPixelSize(raster_index)))
|
|
41
|
+
|
|
42
|
+
// Returns size of raster sampler in pixels
|
|
43
|
+
#define rasterPixelSize(raster_index) \
|
|
44
|
+
(u_raster_sizes[raster_index])
|
|
45
|
+
|
|
46
|
+
#endif
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TileBuildStyle} from '../tile/tile-build-types';
|
|
6
|
+
import type {StyleGLOptions} from './style-runtime-types';
|
|
7
|
+
import type UniformBuffer from '../gl/uniform_buffer';
|
|
8
|
+
import type ShaderProgram from '../gl/shader_program';
|
|
9
|
+
import type VBOMesh from '../gl/vbo_mesh';
|
|
10
|
+
import type {MeshRenderOptions} from '../gl/mesh-types';
|
|
11
|
+
|
|
12
|
+
/** Extensible shader customization before and after mixin evaluation. */
|
|
13
|
+
export interface StyleShaderDefinition {
|
|
14
|
+
defines?: Record<string, unknown>;
|
|
15
|
+
attributes?: Record<string, unknown>;
|
|
16
|
+
uniforms?: Record<string, unknown>;
|
|
17
|
+
_uniforms?: Record<string, unknown>;
|
|
18
|
+
_uniform_scopes?: Record<string, string>;
|
|
19
|
+
extensions?: string | string[];
|
|
20
|
+
blocks?: Record<string, string | string[]>;
|
|
21
|
+
block_scopes?: Record<string, string | string[]>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Authored/intermediate style configuration; abstract styles need no GPU lifecycle. */
|
|
25
|
+
export interface StyleDefinition {
|
|
26
|
+
name?: string;
|
|
27
|
+
mix?: string | string[];
|
|
28
|
+
mixed?: Record<string, boolean>;
|
|
29
|
+
base?: string | null;
|
|
30
|
+
animated?: boolean;
|
|
31
|
+
texcoords?: boolean;
|
|
32
|
+
lighting?: string | boolean;
|
|
33
|
+
texture?: string;
|
|
34
|
+
raster?: string | boolean;
|
|
35
|
+
dash?: unknown;
|
|
36
|
+
dash_background_color?: unknown;
|
|
37
|
+
blend?: string | false;
|
|
38
|
+
blend_order?: number;
|
|
39
|
+
defines?: Record<string, unknown>;
|
|
40
|
+
material?: Record<string, unknown>;
|
|
41
|
+
draw?: Record<string, unknown>;
|
|
42
|
+
shaders?: StyleShaderDefinition;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Instantiated base/custom style surface consumed by the style manager. */
|
|
46
|
+
export interface ManagedStyle extends StyleDefinition, TileBuildStyle {
|
|
47
|
+
/** Abstract styles with null bases are not admitted to this initialized registry. */
|
|
48
|
+
base?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
main_thread_target: string;
|
|
51
|
+
resource_context?: unknown;
|
|
52
|
+
gl?: unknown;
|
|
53
|
+
init(scene?: import('./style-runtime-types').StyleInitOptions): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
reset(): void;
|
|
56
|
+
/** Effective initialized blend mode; abstract styles never enter the draw registry. */
|
|
57
|
+
blend: 'opaque' | 'translucent' | 'add' | 'multiply' | 'inlay' | 'overlay';
|
|
58
|
+
/** Underlying built-in geometry implementation after mixins are resolved. */
|
|
59
|
+
baseStyle(): string;
|
|
60
|
+
/** Replace worker generation without reallocating style resources. */
|
|
61
|
+
setGeneration(generation: number): void;
|
|
62
|
+
/** Install host resource factories and the caller-owned drawing context. */
|
|
63
|
+
setGL(context: WebGLRenderingContext | null, blocks: Record<string, UniformBuffer>, options: StyleGLOptions): void;
|
|
64
|
+
/** Lazily compile the color or feature-selection program. */
|
|
65
|
+
getProgram(key: 'program' | 'selection_program'): ShaderProgram | undefined;
|
|
66
|
+
/** Optional feature-ID program is owned only by the style that created it. */
|
|
67
|
+
selection_program?: ShaderProgram | null;
|
|
68
|
+
/** Optional std140 material owner, retired with its style generation. */
|
|
69
|
+
portable_material_buffer?: UniformBuffer | null;
|
|
70
|
+
/** Bind style material and shader values for the currently active program. */
|
|
71
|
+
setup(): void;
|
|
72
|
+
/** Submit a retained mesh through the active classic or portable backend. */
|
|
73
|
+
render(mesh: VBOMesh, options: MeshRenderOptions): boolean;
|
|
74
|
+
/** Snapshot captured during worker initialization, absent for ordinary flat scenes. */
|
|
75
|
+
terrain?: import('../procedures/terrain-draping').TerrainDrapingSnapshot;
|
|
76
|
+
/** View-dependent worker ribbon target, separate from physical DEM identity. */
|
|
77
|
+
terrainRibbonZoom?: number;
|
|
78
|
+
/** Initialized shader owner and proxy stencil policy used by main scene passes. */
|
|
79
|
+
program?: ShaderProgram | null;
|
|
80
|
+
stencil_proxy_tiles?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Shader mix state populated in stages without changing the original object shape. */
|
|
84
|
+
export interface MixedStyleShaders extends StyleShaderDefinition {
|
|
85
|
+
defines: Record<string, unknown>;
|
|
86
|
+
attributes: Record<string, unknown>;
|
|
87
|
+
uniforms: Record<string, unknown>;
|
|
88
|
+
_uniforms: Record<string, unknown>;
|
|
89
|
+
_uniform_scopes: Record<string, string>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Tile mesh metadata used for active styles and ascending blend passes. */
|
|
93
|
+
export interface StyleManagerTile {
|
|
94
|
+
meshes: Record<string, {variant: {blend_order?: number}}[]>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Styles sharing one mesh blend-order pass. */
|
|
98
|
+
export interface ActiveStyleBlendOrder {
|
|
99
|
+
blend_order?: number;
|
|
100
|
+
styles: string[];
|
|
101
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// tangram-layers
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type DataSource from '../sources/data_source';
|
|
6
|
+
import type Material from '../lights/material';
|
|
7
|
+
import type ShaderProgram from '../gl/shader_program';
|
|
8
|
+
import type VertexLayout from '../gl/vertex_layout';
|
|
9
|
+
import type VertexData from '../gl/vertex_data';
|
|
10
|
+
import type UniformBuffer from '../gl/uniform_buffer';
|
|
11
|
+
import type {UniformBufferOptions} from '../gl/uniform_buffer';
|
|
12
|
+
import type {MeshOptions, MeshElementData} from '../gl/mesh-types';
|
|
13
|
+
import type {TangramGPUSceneOptions} from '../gpu/tangram_gpu_backend';
|
|
14
|
+
import type {TileMeshVariant, TileMeshPayload, LayerDebugCounts, WorkerBuildTile} from '../tile/tile-build-types';
|
|
15
|
+
import type {PropertyCache, PropertyContext, StyleFeature} from './property-types';
|
|
16
|
+
import type {GeometryMeshVariant} from './geometry-style-types';
|
|
17
|
+
import type {SceneDefinition} from '../scene/scene-resource-types';
|
|
18
|
+
import type {TerrainDrapingSnapshot} from '../procedures/terrain-draping';
|
|
19
|
+
import type {ProjectedBasemapOptions} from '../procedures/mesh-projector';
|
|
20
|
+
import type VBOMesh from '../gl/vbo_mesh';
|
|
21
|
+
import type {MeshRenderOptions} from '../gl/mesh-types';
|
|
22
|
+
import type {VertexAttribute} from '../gl/vertex-types';
|
|
23
|
+
|
|
24
|
+
/** Worker geometry channels used by the base dispatcher and concrete styles. */
|
|
25
|
+
export type BuildGeometry = import('./text/text-types').TextGeometry;
|
|
26
|
+
/** Source-normalized feature with geometry available to the style dispatcher. */
|
|
27
|
+
export interface BuildFeature extends StyleFeature {geometry: BuildGeometry;}
|
|
28
|
+
/** Evaluator state includes tile ownership and matching authored layers. */
|
|
29
|
+
export interface BuildContext extends PropertyContext {tile: StyleFinalizeTile & Pick<WorkerBuildTile, 'generation'> & {debug?: WorkerBuildTile['debug']}; layers?: string[];}
|
|
30
|
+
/** Finalization requires tile address only when a projection or raster consumes it. */
|
|
31
|
+
export type StyleFinalizeTile = Pick<WorkerBuildTile, 'id'> & Partial<Pick<WorkerBuildTile, 'coords' | 'min' | 'max' | 'style_z' | 'overzoom2' | 'rasters' | 'source' | 'key' | 'canceled'>>;
|
|
32
|
+
/** Mutable draw group at the cache boundary; extension values remain unresolved. */
|
|
33
|
+
export interface BuildDraw {
|
|
34
|
+
layers?: string[];
|
|
35
|
+
group?: string;
|
|
36
|
+
order?: unknown;
|
|
37
|
+
blend_order?: number;
|
|
38
|
+
preprocessed?: boolean;
|
|
39
|
+
interactive?: unknown;
|
|
40
|
+
attributes?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** Shared scratch values populated incrementally by concrete feature parsers. */
|
|
43
|
+
export interface BuildFeatureStyle {
|
|
44
|
+
order?: unknown;
|
|
45
|
+
interactive?: unknown;
|
|
46
|
+
selection_color?: number[];
|
|
47
|
+
attributes?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/** Authored material channels before the base lifecycle creates a Material owner. */
|
|
50
|
+
export interface AuthoredStyleMaterial {
|
|
51
|
+
emission?: unknown;
|
|
52
|
+
ambient?: unknown;
|
|
53
|
+
diffuse?: unknown;
|
|
54
|
+
specular?: number | number[] | {amount?: number | number[]};
|
|
55
|
+
normal?: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** A mesh is mutable while accumulating geometry, then owns transferable bytes. */
|
|
58
|
+
export interface BuildMesh<Buffer extends VertexData | Uint8Array = VertexData> extends Omit<TileMeshPayload, 'vertex_data' | 'variant'> {
|
|
59
|
+
vertex_data: Buffer;
|
|
60
|
+
variant: GeometryMeshVariant & TileMeshVariant;
|
|
61
|
+
}
|
|
62
|
+
/** Per-tile style output shared by collision, raster loading, and serialization. */
|
|
63
|
+
export interface BuildTileData<Buffer extends VertexData | Uint8Array = VertexData> extends MeshOptions {
|
|
64
|
+
meshes: Record<string, BuildMesh<Buffer>>;
|
|
65
|
+
uniforms: Record<string, unknown>;
|
|
66
|
+
textures: string[];
|
|
67
|
+
}
|
|
68
|
+
/** Configuration provided to inherited style initialization in either thread. */
|
|
69
|
+
export interface StyleInitOptions {
|
|
70
|
+
generation?: number;
|
|
71
|
+
styles?: Record<string, import('./style-mixing-types').ManagedStyle> | null;
|
|
72
|
+
sources?: Record<string, DataSource>;
|
|
73
|
+
introspection?: boolean;
|
|
74
|
+
shader_language?: 'glsl' | 'wgsl';
|
|
75
|
+
config?: SceneDefinition | null;
|
|
76
|
+
projection_target?: string;
|
|
77
|
+
terrain?: TerrainDrapingSnapshot;
|
|
78
|
+
/** Host view zoom for canonical road geometry; independent of immutable DEM ownership. */
|
|
79
|
+
terrainRibbonZoom?: number;
|
|
80
|
+
}
|
|
81
|
+
/** Renderer hooks passed to the base resource lifecycle. */
|
|
82
|
+
export interface StyleGLOptions extends Omit<Partial<TangramGPUSceneOptions>, 'enableUniformBuffers' | 'deviceShaderCompilation'> {
|
|
83
|
+
enableUniformBuffers?: boolean;
|
|
84
|
+
deviceShaderCompilation?: boolean;
|
|
85
|
+
resourceContext?: object;
|
|
86
|
+
uniformBlockFactory?: (options: UniformBufferOptions) => UniformBuffer;
|
|
87
|
+
deferUniformBlocks?: boolean;
|
|
88
|
+
deferTextureBindings?: boolean;
|
|
89
|
+
deferUniformUpdates?: boolean;
|
|
90
|
+
portableLightCount?: number;
|
|
91
|
+
portableLighting?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** Shader customization after style-manager mixin normalization. */
|
|
94
|
+
export interface RuntimeStyleShaders {
|
|
95
|
+
defines?: Record<string, unknown>;
|
|
96
|
+
uniforms?: Record<string, unknown>;
|
|
97
|
+
attributes?: Record<string, {type?: string; varying?: boolean}>;
|
|
98
|
+
blocks?: Record<string, string[] | null>;
|
|
99
|
+
block_scopes?: Record<string, (string | null)[] | null>;
|
|
100
|
+
extensions?: string | string[];
|
|
101
|
+
}
|
|
102
|
+
/** State written by initialization and released by the inherited lifecycle. */
|
|
103
|
+
export interface StyleState {
|
|
104
|
+
name: string;
|
|
105
|
+
base?: string;
|
|
106
|
+
generation: number | undefined;
|
|
107
|
+
styles: Record<string, import('./style-mixing-types').ManagedStyle> | null | undefined;
|
|
108
|
+
sources: Record<string, DataSource>;
|
|
109
|
+
shader_language: 'glsl' | 'wgsl';
|
|
110
|
+
projection_target?: string;
|
|
111
|
+
terrain?: TerrainDrapingSnapshot;
|
|
112
|
+
/** Host view zoom for canonical road width/offset refinement. */
|
|
113
|
+
terrainRibbonZoom?: number;
|
|
114
|
+
cpu_projection?: ProjectedBasemapOptions;
|
|
115
|
+
screen_space_labels: boolean;
|
|
116
|
+
defines: Record<string, unknown>;
|
|
117
|
+
shaders: RuntimeStyleShaders;
|
|
118
|
+
introspection: boolean;
|
|
119
|
+
selection: boolean;
|
|
120
|
+
compile_setup: boolean;
|
|
121
|
+
program: ShaderProgram | null;
|
|
122
|
+
selection_program: ShaderProgram | null;
|
|
123
|
+
feature_style: BuildFeatureStyle;
|
|
124
|
+
vertex_template: number[];
|
|
125
|
+
tile_data: Record<string | number, BuildTileData | null>;
|
|
126
|
+
stencil_proxy_tiles: boolean;
|
|
127
|
+
variants: Record<string | number, GeometryMeshVariant & TileMeshVariant>;
|
|
128
|
+
vertex_layouts: Record<string | number, VertexLayout>;
|
|
129
|
+
blend: 'opaque' | 'translucent' | 'add' | 'multiply' | 'inlay' | 'overlay';
|
|
130
|
+
blend_order?: number;
|
|
131
|
+
material: Material | AuthoredStyleMaterial;
|
|
132
|
+
lighting?: string | boolean;
|
|
133
|
+
raster?: string | boolean;
|
|
134
|
+
draw?: Record<string, unknown>;
|
|
135
|
+
initialized: boolean;
|
|
136
|
+
main_thread_target: string;
|
|
137
|
+
gl: WebGLRenderingContext | null;
|
|
138
|
+
resource_context: object | null;
|
|
139
|
+
uniform_blocks: Record<string, UniformBuffer> | null;
|
|
140
|
+
uniform_block_factory: StyleGLOptions['uniformBlockFactory'] | null;
|
|
141
|
+
shader_factory?: TangramGPUSceneOptions['shaderFactory'];
|
|
142
|
+
shader_program_validator?: TangramGPUSceneOptions['shaderProgramValidator'];
|
|
143
|
+
mesh_buffer_factory?: TangramGPUSceneOptions['meshBufferFactory'];
|
|
144
|
+
texture_factory?: TangramGPUSceneOptions['textureFactory'];
|
|
145
|
+
device_shader_compilation: boolean;
|
|
146
|
+
defer_uniform_blocks: boolean;
|
|
147
|
+
defer_texture_bindings: boolean;
|
|
148
|
+
defer_uniform_updates: boolean;
|
|
149
|
+
max_texture_size: number;
|
|
150
|
+
portable_material_buffer: UniformBuffer | null;
|
|
151
|
+
portable_lighting_mode?: 'vertex' | 'fragment' | false;
|
|
152
|
+
portable_light_count?: number;
|
|
153
|
+
vertex_shader_src: string;
|
|
154
|
+
fragment_shader_src: string;
|
|
155
|
+
getWGSLShaderSource?(selection?: boolean): string;
|
|
156
|
+
}
|
|
157
|
+
/** Concrete styles inherit these checked methods, retaining prototype ownership. */
|
|
158
|
+
export type StyleRuntime = StyleState & StyleMethods;
|
|
159
|
+
/** Checked inherited operations; concrete geometry hooks may return no value on the abstract base. */
|
|
160
|
+
export interface StyleMethods {
|
|
161
|
+
init(options?: StyleInitOptions): void;
|
|
162
|
+
destroy(): void;
|
|
163
|
+
reset(): void;
|
|
164
|
+
baseStyle(): string;
|
|
165
|
+
setGeneration(generation: number | undefined): void;
|
|
166
|
+
startData(tile: Pick<WorkerBuildTile, 'id'>): void;
|
|
167
|
+
endData(tile: StyleFinalizeTile): Promise<BuildTileData<Uint8Array> | null>;
|
|
168
|
+
hasDataForTile(tile: Pick<WorkerBuildTile, 'id'>): boolean;
|
|
169
|
+
getTileMesh(tile: Pick<WorkerBuildTile, 'id'>, variant: GeometryMeshVariant & TileMeshVariant): BuildMesh;
|
|
170
|
+
vertexLayoutForMeshVariant(variant: TileMeshVariant | undefined): VertexLayout | undefined;
|
|
171
|
+
meshVariantTypeForDraw(draw: BuildDraw): (GeometryMeshVariant & TileMeshVariant) | undefined;
|
|
172
|
+
addFeature(feature: BuildFeature, draw: BuildDraw, context: BuildContext): void;
|
|
173
|
+
buildGeometry(geometry: BuildGeometry, style: BuildFeatureStyle, context: BuildContext): number | undefined;
|
|
174
|
+
parseFeature(feature: BuildFeature, draw: BuildDraw, context: BuildContext): BuildFeatureStyle | undefined;
|
|
175
|
+
_parseFeature(feature: BuildFeature, draw: BuildDraw, context: BuildContext): BuildFeatureStyle | undefined;
|
|
176
|
+
preprocess(draw: BuildDraw): BuildDraw | undefined;
|
|
177
|
+
_preprocess(draw: BuildDraw): BuildDraw | undefined;
|
|
178
|
+
parseOrder(order: unknown, context: PropertyContext): unknown;
|
|
179
|
+
scaleOrder(order: number): number;
|
|
180
|
+
parseColor(color: PropertyCache | null | undefined, context: PropertyContext): number[] | undefined;
|
|
181
|
+
buildPolygons(polygons: Extract<BuildGeometry, {type: 'MultiPolygon'}>['coordinates'], style: BuildFeatureStyle, context: BuildContext): number;
|
|
182
|
+
buildLines(lines: number[][][], style: BuildFeatureStyle, context: BuildContext): number;
|
|
183
|
+
buildPoints(points: number[][], style: BuildFeatureStyle, context: BuildContext): number;
|
|
184
|
+
setGL(context: WebGLRenderingContext | null, blocks?: Record<string, UniformBuffer>, options?: StyleGLOptions): void;
|
|
185
|
+
makeMesh(vertices: Uint8Array, elements: MeshElementData, options?: Partial<import('../tile/tile-build-types').TileStylePayload>): VBOMesh;
|
|
186
|
+
render(mesh: VBOMesh, options: MeshRenderOptions): boolean;
|
|
187
|
+
getProgram(key?: 'program' | 'selection_program'): ShaderProgram | undefined;
|
|
188
|
+
compileSetup(): void;
|
|
189
|
+
addShaderBlock(key: string, block: string, scope?: string | null): void;
|
|
190
|
+
removeShaderBlock(key: string): void;
|
|
191
|
+
replaceShaderBlock(key: string, block: string, scope?: string | null): void;
|
|
192
|
+
buildDefineList(): Record<string, unknown>;
|
|
193
|
+
hasRasters(): boolean;
|
|
194
|
+
setupRasters(): void;
|
|
195
|
+
buildRasterTextures(tile: StyleFinalizeTile, data: BuildTileData<Uint8Array>): Promise<BuildTileData<Uint8Array> | null>;
|
|
196
|
+
loadTextures(tile: RasterTextureTile): Promise<RasterTextureInfo[]>;
|
|
197
|
+
setupCustomAttributes(): void;
|
|
198
|
+
addCustomAttributesToAttributeList(attributes: VertexAttribute[]): VertexAttribute[];
|
|
199
|
+
addCustomAttributesToVertexTemplate(style: BuildFeatureStyle, offset: number): void;
|
|
200
|
+
setup(): void;
|
|
201
|
+
setUniforms(): void;
|
|
202
|
+
render_states: Record<StyleState['blend'], {depth_test: boolean; depth_write: boolean}>;
|
|
203
|
+
default_blend_orders: Record<StyleState['blend'], number>;
|
|
204
|
+
getBlendOrderForDraw(draw: {blend_order?: number}): number | undefined;
|
|
205
|
+
}
|
|
206
|
+
/** Serializable loaded raster metadata; no GPU object crosses the worker boundary. */
|
|
207
|
+
export interface RasterTextureInfo {
|
|
208
|
+
name: string;
|
|
209
|
+
width: number;
|
|
210
|
+
height: number;
|
|
211
|
+
loaded: boolean;
|
|
212
|
+
index: number;
|
|
213
|
+
coords: {x: number; y: number; z: number};
|
|
214
|
+
}
|
|
215
|
+
/** Main-thread raster request carries geometry metadata, not a complete worker build. */
|
|
216
|
+
export type RasterTextureTile = Pick<WorkerBuildTile, 'coords' | 'source' | 'min' | 'max'> & {rasters: string[]};
|
|
217
|
+
/** Nested feature counters, with no GPU or tile ownership. */
|
|
218
|
+
export type LayerDebugTree = Record<string, LayerDebugCounts>;
|
|
219
|
+
/** Feature-local tree records which nodes have already contributed counters. */
|
|
220
|
+
export interface CountedLayerTree {[name: string]: CountedLayerTree;}
|