@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,165 @@
|
|
|
1
|
+
import type { TerrainHeightGrid } from "../map-logic/terrain-data.js";
|
|
2
|
+
import VertexLayout from "../gl/vertex_layout.js";
|
|
3
|
+
import type { DrapedTerrainQueryMesh } from "../selection/draped-terrain-surface.js";
|
|
4
|
+
/** Opt-in physical-height basemap displacement, independent of deck, providers and GPU ownership. */
|
|
5
|
+
export interface TerrainDrapingOptions {
|
|
6
|
+
/** Non-overlapping loaded EPSG:3857 height grids; missing coverage hides geometry. */
|
|
7
|
+
grids: readonly TerrainHeightGrid[];
|
|
8
|
+
/** Previous admitted grids, sampled at the new vertices for temporal height morphing. */
|
|
9
|
+
previousGrids?: readonly TerrainHeightGrid[];
|
|
10
|
+
/** Horizontal edge target in Mercator meters; default 250, constrained by per-tile detail and vertex budgets. */
|
|
11
|
+
maxSegmentLength?: number;
|
|
12
|
+
/** Maximum additional vertices in one worker mesh; default 131072. */
|
|
13
|
+
maxAdditionalVertices?: number;
|
|
14
|
+
/** Completed interleaved vertex/index bytes per mesh; default 16 MiB. */
|
|
15
|
+
maxMeshBytes?: number;
|
|
16
|
+
/** Owned current/previous grid arrays per scene/worker, default 32 MiB. */
|
|
17
|
+
maxGridBytes?: number;
|
|
18
|
+
/** Shared height/slope interpolation duration per admitted terrain field, default 200 ms. */
|
|
19
|
+
transitionDuration?: number;
|
|
20
|
+
/** Ground style names whose exact final triangles are retained for physical queries; default empty. */
|
|
21
|
+
querySurfaceStyles?: readonly string[];
|
|
22
|
+
/** Opt-in DEM-owned ground cells per tile axis (2, 4, 8, 16, 32, 64), also conforming polygons/roads; zero keeps legacy refinement. */
|
|
23
|
+
groundMeshResolution?: number;
|
|
24
|
+
/** Previous admitted ground resolution; Renderer supplies it automatically for field replacement. */
|
|
25
|
+
previousGroundMeshResolution?: number;
|
|
26
|
+
/** Opt-in common planar refinement against previous canonical ground triangles; default false preserves arbitrary legacy previous fields. */
|
|
27
|
+
conformTransitions?: boolean;
|
|
28
|
+
/** Retained query channels per mesh, default 8 MiB; separate from completed draw bytes. */
|
|
29
|
+
maxQueryMeshBytes?: number;
|
|
30
|
+
/** Additional staged draw/query buffers across a replacement generation; default 64 MiB, excluding GPU overhead. */
|
|
31
|
+
maxStagedMeshBytes?: number;
|
|
32
|
+
/** Peak retained draw/query arrays plus estimated GPU vertex/index copies, including incumbent and staged generations; default 256 MiB. Excludes textures, driver overhead and worker scratch. */
|
|
33
|
+
maxResidentMeshBytes?: number;
|
|
34
|
+
/** Aggregate acceleration reservation for the current draped query snapshot; default 16 MiB. */
|
|
35
|
+
maxQueryIndexBytes?: number;
|
|
36
|
+
/** Retained projected picking geometry per snapshot; default 32 MiB, with exact streaming fallback. */
|
|
37
|
+
maxProjectedQueryBytes?: number;
|
|
38
|
+
/** Cooperative query-index warming target per host frame in milliseconds; default 2. */
|
|
39
|
+
queryPreparationBudgetMs?: number;
|
|
40
|
+
/** Test annotation fragments against rendered terrain and omit fully blocked collision candidates; default false. */
|
|
41
|
+
occludeAnnotations?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Validated, detached physical input; typed-array contents are immutable by contract. */
|
|
44
|
+
export interface TerrainDrapingSnapshot extends Required<TerrainDrapingOptions> {
|
|
45
|
+
/** Renderer-owned field epoch; unrelated scene/source rebuilds preserve this identity. */
|
|
46
|
+
transitionGeneration: number;
|
|
47
|
+
/** Exact owned height/mask array bytes; excludes structured-clone and scratch allocations. */
|
|
48
|
+
byteLength: number;
|
|
49
|
+
/** Lowest valid current/previous height for safe spherical exaggeration. */
|
|
50
|
+
minimumHeight: number;
|
|
51
|
+
}
|
|
52
|
+
/** Completed worker preparation cost; does not claim a total GPU/transient memory budget. */
|
|
53
|
+
export interface TerrainMeshPreparation {
|
|
54
|
+
/** Original packed vertex count. */
|
|
55
|
+
inputVertices: number;
|
|
56
|
+
/** Prepared vertices, including retained originals. */
|
|
57
|
+
vertices: number;
|
|
58
|
+
/** Admitted triangle count. */
|
|
59
|
+
triangles: number;
|
|
60
|
+
/** Refined triangles conservatively removed for missing coverage. */
|
|
61
|
+
suppressedTriangles: number;
|
|
62
|
+
/** Completed interleaved vertex and index bytes. */
|
|
63
|
+
meshBytes: number;
|
|
64
|
+
/** Monotonic worker wall time for topology, sampling and mask admission. */
|
|
65
|
+
preparationMs: number;
|
|
66
|
+
/** Effective Mercator edge target; canonical ground reports its maximum admitted edge, not a certified error. */
|
|
67
|
+
edgeTarget: number;
|
|
68
|
+
/** The per-tile detail floor prevented the requested edge target. */
|
|
69
|
+
detailLimited: boolean;
|
|
70
|
+
/** Explicit source-independent ground resolution; absent on legacy polygons/ribbons/annotations. */
|
|
71
|
+
canonicalGroundResolution?: number;
|
|
72
|
+
/** Canonical cell resolution used to cut authored polygons or nominal expanded road faces. */
|
|
73
|
+
canonicalStyledResolution?: number;
|
|
74
|
+
/** Shared planar transition triangles after cutting against the previous generation's faces. */
|
|
75
|
+
transitionTriangles?: number;
|
|
76
|
+
/** View zoom whose built-in road width/offset was expanded and re-intersected in the worker. */
|
|
77
|
+
ribbonZoom?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Resident preparation counters useful to compare detail policies on a real host. */
|
|
80
|
+
export interface TerrainDrapingStatistics {
|
|
81
|
+
/** Whether displacement attributes were enabled at construction. */
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
/** Owned current/previous height-array bytes per scene/worker copy. */
|
|
84
|
+
gridBytes: number;
|
|
85
|
+
/** Resident completed draped meshes, including off-screen retained tiles. */
|
|
86
|
+
meshes: number;
|
|
87
|
+
/** Resident prepared vertex count. */
|
|
88
|
+
vertices: number;
|
|
89
|
+
/** Resident admitted triangles. */
|
|
90
|
+
triangles: number;
|
|
91
|
+
/** Resident rejected no-data triangles. */
|
|
92
|
+
suppressedTriangles: number;
|
|
93
|
+
/** Resident completed worker output bytes; excludes GPU copies and scratch. */
|
|
94
|
+
meshBytes: number;
|
|
95
|
+
/** Slowest resident worker mesh preparation. */
|
|
96
|
+
maximumPreparationMs: number;
|
|
97
|
+
/** Resident meshes constrained by the per-tile detail floor. */
|
|
98
|
+
detailLimitedMeshes: number;
|
|
99
|
+
/** Retained exact ground topology and height channels, excluding lazy projected query copies. */
|
|
100
|
+
queryBytes: number;
|
|
101
|
+
/** New draw/query buffers waiting for all worker batches to complete. */
|
|
102
|
+
stagedMeshBytes: number;
|
|
103
|
+
/** Draw/query arrays plus estimated GPU vertex/index copies in both admitted and staged generations. */
|
|
104
|
+
residentMeshBytes: number;
|
|
105
|
+
/** Peak mesh-domain admission limit; source, worker scratch and driver overhead remain separate. */
|
|
106
|
+
residentMeshByteLimit: number;
|
|
107
|
+
/** Snapshot-local annotation query costs; excludes separately retained host snapshots. */
|
|
108
|
+
annotationQueries?: import("../selection/draped-terrain-surface.js").DrapedTerrainQueryStatistics;
|
|
109
|
+
/** Resident canonical road meshes, whose corners are baked at their admitted worker view zoom. */
|
|
110
|
+
ribbonMeshes?: number;
|
|
111
|
+
/** Host-driven width replacement state; failed admission preserves the last complete geometry. */
|
|
112
|
+
ribbonRefinement?: {
|
|
113
|
+
requestedZoom?: number;
|
|
114
|
+
admittedZoom?: number;
|
|
115
|
+
pending: boolean;
|
|
116
|
+
error?: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Validate and snapshot terrain before changing a scene or rebuilding workers. */
|
|
120
|
+
export declare function normalizeTerrainDraping(options: TerrainDrapingOptions): TerrainDrapingSnapshot;
|
|
121
|
+
/**
|
|
122
|
+
* Retain the final draw's ground channels and topology, never another DEM mesh.
|
|
123
|
+
* @param canonicalPositions - Optional exact lattice XY, avoiding source-origin reconstruction ulps at terminal bounds.
|
|
124
|
+
*/
|
|
125
|
+
export declare function extractDrapedTerrainQueryMesh(vertices: Uint8Array, indices: Uint16Array | Uint32Array, layout: VertexLayout, origin: readonly [number, number], tileZoom: number, byteLimit: number, canonicalPositions?: Float64Array): DrapedTerrainQueryMesh;
|
|
126
|
+
/** Admit source work only where current physical heights can produce drawable geometry. */
|
|
127
|
+
export declare function hasTerrainTileCoverage(grids: readonly TerrainHeightGrid[], coordinates: {
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
z: number;
|
|
131
|
+
}): boolean;
|
|
132
|
+
/** Add terrain data only after the original packed mesh has been completed. */
|
|
133
|
+
export declare function getTerrainVertexLayout(original: VertexLayout): VertexLayout;
|
|
134
|
+
/** Worker-side topology and samples; retains original feature/label vertex identities. */
|
|
135
|
+
export declare function drapeTerrainMesh(options: {
|
|
136
|
+
/** Completed original packed vertices. */
|
|
137
|
+
vertices: Uint8Array;
|
|
138
|
+
/** Triangle topology, or an implicit non-indexed triangle list. */
|
|
139
|
+
indices: Uint16Array | Uint32Array | false;
|
|
140
|
+
/** Original layout before appending height/slope data. */
|
|
141
|
+
layout: VertexLayout;
|
|
142
|
+
/** Absolute Mercator origin of tile-local coordinates. */
|
|
143
|
+
origin: readonly [number, number];
|
|
144
|
+
/** Source tile zoom and its packed XY edge size. */
|
|
145
|
+
tileZoom: number;
|
|
146
|
+
/** Styling zoom, independent of source detail; bounds possible screen-space ribbon expansion. */
|
|
147
|
+
styleZoom?: number;
|
|
148
|
+
/** Actual host view zoom for canonical road width/offset re-intersection; defaults to style zoom. */
|
|
149
|
+
ribbonZoom?: number;
|
|
150
|
+
/** Do not refine screen-space annotation quads. */
|
|
151
|
+
annotations?: boolean;
|
|
152
|
+
/** Explicit full-tile raster ground owner; source clipping, not triangle cropping, partitions cells. */
|
|
153
|
+
ground?: boolean;
|
|
154
|
+
/** Cut polygon/line style faces against the canonical surface when groundMeshResolution is enabled. */
|
|
155
|
+
styled?: boolean;
|
|
156
|
+
/** Validated immutable current/previous heights and resource policy. */
|
|
157
|
+
terrain: TerrainDrapingSnapshot;
|
|
158
|
+
}): {
|
|
159
|
+
vertices: Uint8Array;
|
|
160
|
+
indices: Uint16Array | Uint32Array;
|
|
161
|
+
byteLength: number;
|
|
162
|
+
statistics: TerrainMeshPreparation;
|
|
163
|
+
groundClip?: boolean;
|
|
164
|
+
groundPositions?: Float64Array;
|
|
165
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Zero-relief globe point followed by the common-space displacement per unit exaggeration. */
|
|
2
|
+
export declare function createTerrainGlobePoint(coordinate: readonly [number, number], height: number, normalized?: readonly [number, number]): Float64Array;
|
|
3
|
+
/** Preserve a canonical face's affine globe plane rather than projecting a new cut back onto the sphere. */
|
|
4
|
+
export declare function interpolateTerrainGlobePoints(points: readonly Float64Array[], weights: ArrayLike<number>): Float64Array;
|
|
5
|
+
/** Evaluate the same current/previous affine surface as the shader, with independent authored physical altitude. */
|
|
6
|
+
export declare function projectTerrainGlobeVertex(channels: ArrayLike<number>, vertex: number, blend: number, exaggeration: number, coordinate: readonly [number, number, number]): [number, number, number];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type VertexLayout from "../gl/vertex_layout.js";
|
|
2
|
+
/** Styled geometry and its barycentric references to the shared physical surface. */
|
|
3
|
+
export interface TerrainStyledTopology {
|
|
4
|
+
/** Packed source channels interpolated only within each original feature face. */
|
|
5
|
+
vertices: Uint8Array;
|
|
6
|
+
/** Source winding/order retained; disconnected features never weld their attributes. */
|
|
7
|
+
indices: Uint32Array;
|
|
8
|
+
/** Three canonical vertex identities per output vertex. */
|
|
9
|
+
surfaceIndices: Uint32Array;
|
|
10
|
+
/** Three surface weights at the actual packed nominal XY per output vertex. */
|
|
11
|
+
surfaceWeights: Float64Array;
|
|
12
|
+
}
|
|
13
|
+
/** Intersect source faces with complete DEM triangles, preserving holes, walls and feature identity.
|
|
14
|
+
* Heights are interpolated from the terrain face, not resampled from a different bilinear surface.
|
|
15
|
+
* The caller owns DEM validation, physical sampling and final draw-byte admission.
|
|
16
|
+
*/
|
|
17
|
+
export declare function conformTerrainStyledMesh(options: {
|
|
18
|
+
/** Floating-position authored records before terrain channels are appended. */
|
|
19
|
+
vertices: Uint8Array;
|
|
20
|
+
/** Valid source triangles in authored draw order. */
|
|
21
|
+
indices: Uint16Array | Uint32Array;
|
|
22
|
+
/** Original packed attribute interpolation semantics. */
|
|
23
|
+
layout: VertexLayout;
|
|
24
|
+
/** Canonical terrain nodes in the same tile-local coordinate system. */
|
|
25
|
+
surfacePositions: Float64Array;
|
|
26
|
+
/** Counterclockwise canonical terrain triangles. */
|
|
27
|
+
surfaceIndices: Uint32Array;
|
|
28
|
+
/** Nominal expanded corner, including road width and offset. */
|
|
29
|
+
getPosition: (record: DataView) => [number, number];
|
|
30
|
+
/** Authored elevation, used to retain vertical walls rather than discarding XY degenerates. */
|
|
31
|
+
getElevation: (record: DataView) => number;
|
|
32
|
+
/** Maximum completed output vertices; a failed admission never returns partial geometry. */
|
|
33
|
+
maxVertices: number;
|
|
34
|
+
}): TerrainStyledTopology;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Project longitude/latitude degrees to Web Mercator meters using Tangram's established formula. */
|
|
2
|
+
export declare function projectLngLatToMetersLegacy(coordinates: readonly [number, number]): [number, number];
|
|
3
|
+
/** Unproject Web Mercator meters to longitude/latitude degrees using Tangram's established formula. */
|
|
4
|
+
export declare function unprojectMetersToLngLatLegacy(coordinates: readonly [number, number]): [number, number];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Project longitude/latitude degrees to Tangram Web Mercator meters using math.gl. */
|
|
2
|
+
export declare function projectLngLatToMetersWithMath(coordinates: readonly [number, number]): [number, number];
|
|
3
|
+
/** Unproject Tangram Web Mercator meters to longitude/latitude degrees using math.gl. */
|
|
4
|
+
export declare function unprojectMetersToLngLatWithMath(coordinates: readonly [number, number]): [number, number];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Authored globals may contain scalars, functions, arrays, or opaque application values. */
|
|
2
|
+
type GlobalObject = Record<string, unknown>;
|
|
3
|
+
/** Identify URL/global-reference strings while retaining omitted resource values. */
|
|
4
|
+
export declare function isGlobalReference(val: string | null | undefined): boolean;
|
|
5
|
+
/** Inspect substitution provenance for a named property or nested object/array path. */
|
|
6
|
+
export declare function isGlobalSubstitution(object: object, prop_or_path: string | (string | number)[]): boolean;
|
|
7
|
+
/** Flatten global records without discarding their original nested values. */
|
|
8
|
+
export declare function flattenGlobalProperties(obj: GlobalObject, prefix?: string | null, globals?: GlobalObject): GlobalObject;
|
|
9
|
+
/** Reapply globals using hidden provenance, retaining the input object's identity and type. */
|
|
10
|
+
export declare function applyGlobalProperties<Value>(globals: GlobalObject, obj: Value, target?: object, key?: string | number): Value;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HostCamera } from "../types.js";
|
|
2
|
+
import type { Bounds } from "../utils/geo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Intersects all twelve edges of a finite host frustum with EPSG:3857 ground.
|
|
5
|
+
* Optional meter-space limits clip the resulting convex polygon before bounds
|
|
6
|
+
* are calculated. Null means no ground area, not an unknown footprint.
|
|
7
|
+
* Matrices use column-major OpenGL clip coordinates, also on the WebGPU path.
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculatePlanarGroundBounds(camera: HostCamera, limits?: Bounds): Bounds | null;
|
|
10
|
+
/**
|
|
11
|
+
* Bounds the finite frustum intersected with a closed elevation slab. Heights
|
|
12
|
+
* are physical meters; XY uses EPSG:3857 meters. This conservative candidate
|
|
13
|
+
* footprint includes elevated-only geometry, not terrain surface intersections.
|
|
14
|
+
* Optional horizontal limits clip the convex footprint, not its bounding box.
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculatePlanarVolumeBounds(camera: HostCamera, elevationRange: readonly [number, number], limits?: Bounds): Bounds | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GeographicAnchor, HostCamera, HostFrameOptions, HostProjection, HostTileLODOptions, HostTileResourceOptions, Viewport, FeatureSelectionOptions } from "../types.js";
|
|
2
|
+
/** Validated per-eye state; optional visibility overrides never change scene/style state. */
|
|
3
|
+
export interface NormalizedRenderView {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly viewport: Required<Viewport>;
|
|
6
|
+
readonly camera: HostCamera;
|
|
7
|
+
readonly geographicAnchor?: Required<GeographicAnchor>;
|
|
8
|
+
readonly projection?: HostProjection;
|
|
9
|
+
}
|
|
10
|
+
/** Host-owned logical frame, shared tile visibility, and independently drawable eyes. */
|
|
11
|
+
export default class HostFrame {
|
|
12
|
+
/** Resolve a full-target or view-local CSS pixel without changing the active camera. */
|
|
13
|
+
resolveSelectionPoint(pixel: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}, options?: FeatureSelectionOptions, activeViewId?: string): {
|
|
17
|
+
view: NormalizedRenderView;
|
|
18
|
+
pixel: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
} | null;
|
|
23
|
+
/** Full target dimensions in CSS pixels; origins are top-left. */
|
|
24
|
+
readonly viewport: Required<Viewport>;
|
|
25
|
+
/** Shared geographic/style anchor in degrees, altitude meters, and Tangram zoom. */
|
|
26
|
+
readonly geographicAnchor: Required<GeographicAnchor>;
|
|
27
|
+
/** Shared geographic projection. */
|
|
28
|
+
readonly projection: HostProjection;
|
|
29
|
+
/** Per-eye camera and footprint state. */
|
|
30
|
+
readonly renderViews: readonly NormalizedRenderView[];
|
|
31
|
+
/** Default eye to draw. */
|
|
32
|
+
readonly activeRenderViewId: string;
|
|
33
|
+
/** Conservative neighboring tile buffer. */
|
|
34
|
+
readonly tileBuffer: number;
|
|
35
|
+
/** Shared data-tile level, independent of scene/style zoom, when supplied. */
|
|
36
|
+
readonly tileZoom?: number;
|
|
37
|
+
/** Validated projected-scale LOD settings, when enabled. */
|
|
38
|
+
readonly tileLOD?: Readonly<Required<HostTileLODOptions>>;
|
|
39
|
+
/** Shared opt-in worker and completed off-screen mesh cache limits. */
|
|
40
|
+
readonly tileResources?: Readonly<HostTileResourceOptions>;
|
|
41
|
+
/** Optional globally resident globe fallback level, capped at 64 coordinates per source. */
|
|
42
|
+
readonly globePreloadZoom?: number;
|
|
43
|
+
/** Shared elapsed scene animation time in seconds, when supplied. */
|
|
44
|
+
readonly animationTime?: number;
|
|
45
|
+
/** Copies and validates a host frame without retaining caller matrix arrays. */
|
|
46
|
+
constructor(options: HostFrameOptions);
|
|
47
|
+
/** Validates untrusted application input, including the original single-view shape. */
|
|
48
|
+
static from(frame: unknown): HostFrame;
|
|
49
|
+
/** Converts the original viewport/view/camera contract. */
|
|
50
|
+
static fromLegacy(frame: unknown): HostFrame;
|
|
51
|
+
/** Returns the selected eye or throws before any scene state is modified. */
|
|
52
|
+
getRenderView(id?: string): NormalizedRenderView;
|
|
53
|
+
private static createValidated;
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HostProjection } from "../types.js";
|
|
2
|
+
/** Neutral units shared by CPU geometry, lighting, shader generation and host adapters. */
|
|
3
|
+
export declare const PROJECTION_CONSTANTS: Readonly<{
|
|
4
|
+
/** EPSG:3857 spherical radius in meters; not the geographic altitude radius. */
|
|
5
|
+
mercatorRadius: 6378137;
|
|
6
|
+
/** Geographic altitude scale matching deck.gl's public GlobeViewport. */
|
|
7
|
+
earthRadius: 6370972;
|
|
8
|
+
/** Globe common-space radius; north is +Z and longitude zero is -Y. */
|
|
9
|
+
globeRadius: 256;
|
|
10
|
+
/** Tangram's reference tile size, distinct from deck's 512-unit world. */
|
|
11
|
+
tileSize: 256;
|
|
12
|
+
/** Mercator's finite square-world latitude cutoff in degrees. */
|
|
13
|
+
maxMercatorLatitude: 85.0511287798066;
|
|
14
|
+
}>;
|
|
15
|
+
/** Longitude/latitude in degrees and geographic altitude in meters. */
|
|
16
|
+
export type GeographicProjectionPosition = readonly [number, number, number];
|
|
17
|
+
/** Renderer-owned geographic boundary; cameras and tile-row conversion are separate. */
|
|
18
|
+
export interface GeographicProjectionProcedure {
|
|
19
|
+
/** Existing HostFrame projection discriminator; this is not a CRS identifier. */
|
|
20
|
+
readonly type: HostProjection['type'];
|
|
21
|
+
/** Absolute position units before the host's view/placement matrices. */
|
|
22
|
+
readonly positionUnits: 'meters' | 'globe-common-units';
|
|
23
|
+
/** Maximum represented latitude in degrees, after Mercator clamping. */
|
|
24
|
+
readonly latitudeLimit: number;
|
|
25
|
+
/** Whether longitude selects a nearest anchored world copy or repeats around a sphere. */
|
|
26
|
+
readonly longitudePolicy: 'nearest-anchor-or-unwrapped' | 'periodic';
|
|
27
|
+
/** Project finite degree/degree/meter positions; an anchor affects only Mercator longitude. */
|
|
28
|
+
readonly project: (position: GeographicProjectionPosition, anchorLongitude?: number) => [number, number, number];
|
|
29
|
+
/** Invert an absolute position; globe center is undefined and longitude becomes canonical. */
|
|
30
|
+
readonly unproject: (position: readonly [number, number, number]) => [number, number, number];
|
|
31
|
+
/** Rotate an ENU direction without converting its length to common-space units. */
|
|
32
|
+
readonly projectVector: (position: GeographicProjectionPosition, direction: readonly [number, number, number]) => [number, number, number];
|
|
33
|
+
}
|
|
34
|
+
/** Project geography to absolute Mercator meters or globe common coordinates, never eye space. */
|
|
35
|
+
export declare function projectGeographicPosition(position: GeographicProjectionPosition, projection: HostProjection['type'], anchorLongitude?: number): [number, number, number];
|
|
36
|
+
/** Rotate an ENU direction into globe axes without camera transforms or changing its length. */
|
|
37
|
+
export declare function projectGeographicVector(position: GeographicProjectionPosition, direction: readonly [number, number, number], projection: HostProjection['type']): [number, number, number];
|
|
38
|
+
/** Invert globe common coordinates for spatial picking, rejecting the undefined sphere center. */
|
|
39
|
+
export declare function unprojectGlobePosition(position: readonly [number, number, number]): [number, number, number];
|
|
40
|
+
/** Style pixels in the zoom-zero Mercator convention, not perspective screen-pixel error. */
|
|
41
|
+
export declare function getMercatorMetersPerPixel(zoom: number): number;
|
|
42
|
+
/** Surface differential per EPSG:3857 meter for projected LOD; elevation is intentionally zero. */
|
|
43
|
+
export declare function getProjectionSurface(x: number, y: number, projection: HostProjection['type']): {
|
|
44
|
+
/** Common-space ground position. */
|
|
45
|
+
position: number[];
|
|
46
|
+
/** Change in position per eastward Mercator meter. */
|
|
47
|
+
derivativeX: number[];
|
|
48
|
+
/** Change in position per northward Mercator meter. */
|
|
49
|
+
derivativeY: number[];
|
|
50
|
+
};
|
|
51
|
+
/** Select the existing renderer's CPU procedure and conventions for a supported HostFrame projection. */
|
|
52
|
+
export declare function getGeographicProjectionProcedure(projection: HostProjection['type']): GeographicProjectionProcedure;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type GLSL from "../gl/glsl.js";
|
|
2
|
+
import type { SceneBundle } from "./scene_bundle.js";
|
|
3
|
+
import type { SubscriptionMethods } from "../utils/subscribe.js";
|
|
4
|
+
/** URL-backed or in-memory scene input, including class-backed editor definitions. */
|
|
5
|
+
export type SceneInput = string | object;
|
|
6
|
+
/** A URL-bearing resource; omitted URLs remain omitted during normalization. */
|
|
7
|
+
export interface SceneResourceDefinition extends Record<string, unknown> {
|
|
8
|
+
/** Relative, absolute, blob, or global-reference URL. */
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Source fields whose paths are normalized by the scene loader. */
|
|
12
|
+
export interface SceneSourceDefinition extends SceneResourceDefinition {
|
|
13
|
+
/** Optional TileJSON metadata URL. */
|
|
14
|
+
tilejson?: string | Record<string, unknown>;
|
|
15
|
+
/** Legacy raster composite resources. */
|
|
16
|
+
composite?: SceneResourceDefinition[];
|
|
17
|
+
/** Named external scripts, or the legacy list form. */
|
|
18
|
+
scripts?: string[] | Record<string, string | undefined>;
|
|
19
|
+
}
|
|
20
|
+
/** A CSS-provided font, one URL face, or multiple URL faces. */
|
|
21
|
+
export type SceneFontDefinition = 'external' | SceneResourceDefinition | SceneResourceDefinition[];
|
|
22
|
+
/** Material channels may contain an inline texture URL or a named texture reference. */
|
|
23
|
+
export type SceneMaterialChannel = number | string | number[] | {
|
|
24
|
+
texture?: string;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
/** Style fields used by resource discovery, without restricting custom shader blocks. */
|
|
28
|
+
export interface SceneStyleDefinition extends Record<string, unknown> {
|
|
29
|
+
/** Named texture or inline texture URL. */
|
|
30
|
+
texture?: string;
|
|
31
|
+
/** Material channels understood by Tangram's texture collector. */
|
|
32
|
+
material?: Record<string, SceneMaterialChannel | null>;
|
|
33
|
+
/** Custom shader configuration; other shader block fields are retained. */
|
|
34
|
+
shaders?: {
|
|
35
|
+
uniforms?: Parameters<typeof GLSL.parseUniforms>[0];
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Draw-group fields relevant to texture discovery. */
|
|
40
|
+
export interface SceneDrawDefinition extends Record<string, unknown> {
|
|
41
|
+
/** Named texture or inline texture URL. */
|
|
42
|
+
texture?: string;
|
|
43
|
+
/** Optional outline texture. */
|
|
44
|
+
outline?: SceneDrawDefinition;
|
|
45
|
+
}
|
|
46
|
+
/** Recursive layers combine sublayers with reserved metadata and draw groups. */
|
|
47
|
+
export interface SceneLayerDefinition {
|
|
48
|
+
/** Style-named draw groups at this level. */
|
|
49
|
+
draw?: Record<string, SceneDrawDefinition>;
|
|
50
|
+
/** Sublayers and reserved fields are interpreted separately by the loader. */
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** Loader-owned fields of an authored scene; extensions stay explicitly unknown. */
|
|
54
|
+
export interface SceneDefinition extends Record<string, unknown> {
|
|
55
|
+
/** One import or an authored-order list of imports. */
|
|
56
|
+
import?: SceneInput | SceneInput[];
|
|
57
|
+
/** Data sources normalized relative to their declaring bundle. */
|
|
58
|
+
sources?: Record<string, SceneSourceDefinition>;
|
|
59
|
+
/** Fonts normalized relative to their declaring bundle. */
|
|
60
|
+
fonts?: Record<string, SceneFontDefinition>;
|
|
61
|
+
/** Named textures normalized relative to their declaring bundle. */
|
|
62
|
+
textures?: Record<string, SceneResourceDefinition>;
|
|
63
|
+
/** Custom and built-in style definitions. */
|
|
64
|
+
styles?: Record<string, SceneStyleDefinition>;
|
|
65
|
+
/** Hierarchical drawing rules. */
|
|
66
|
+
layers?: SceneLayerDefinition;
|
|
67
|
+
/** Authored globals; their values may include functions and opaque objects. */
|
|
68
|
+
global?: Record<string, unknown>;
|
|
69
|
+
/** Scene-wide settings, including explicit lighting mode. */
|
|
70
|
+
scene?: Record<string, unknown>;
|
|
71
|
+
/** Classic camera definitions; host-driven scenes retain but do not synthesize them. */
|
|
72
|
+
cameras?: Record<string, Record<string, unknown>>;
|
|
73
|
+
/** Legacy singular classic camera definition. */
|
|
74
|
+
camera?: Record<string, unknown>;
|
|
75
|
+
/** Legacy named or native luma.gl light definitions, normalized separately. */
|
|
76
|
+
lights?: SceneNamedLights | unknown[];
|
|
77
|
+
}
|
|
78
|
+
/** Light data stays unresolved until globals and the native-light adapter have run. */
|
|
79
|
+
export type SceneNamedLights = Record<string, {
|
|
80
|
+
visible?: boolean | string;
|
|
81
|
+
type?: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}>;
|
|
84
|
+
/** Settings guaranteed by scene-wide finalization, including empty native-light arrays. */
|
|
85
|
+
export interface FinalizedSceneDefinition extends SceneDefinition {
|
|
86
|
+
/** Always present global registry. */
|
|
87
|
+
global: Record<string, unknown>;
|
|
88
|
+
/** Always present scene-wide settings. */
|
|
89
|
+
scene: Record<string, unknown>;
|
|
90
|
+
/** Always present camera registry, possibly empty for host cameras. */
|
|
91
|
+
cameras: Record<string, Record<string, unknown>>;
|
|
92
|
+
/** Native arrays have become named wrappers; conversion remains deferred. */
|
|
93
|
+
lights: SceneNamedLights;
|
|
94
|
+
/** Always present style registry. */
|
|
95
|
+
styles: Record<string, SceneStyleDefinition>;
|
|
96
|
+
/** Always present layer hierarchy. */
|
|
97
|
+
layers: SceneLayerDefinition;
|
|
98
|
+
}
|
|
99
|
+
/** Input descriptor passed between recursive scene loads. */
|
|
100
|
+
export interface SceneResourceDescriptor {
|
|
101
|
+
/** Resource to load; missing archive members have no URL. */
|
|
102
|
+
url?: SceneInput;
|
|
103
|
+
/** Original resource directory, before archive URLs become blob URLs. */
|
|
104
|
+
path?: string | null;
|
|
105
|
+
/** Explicit or inferred bundle format. */
|
|
106
|
+
type?: string | null;
|
|
107
|
+
}
|
|
108
|
+
/** Texture provenance tracked before global substitution and hoisting. */
|
|
109
|
+
export type SceneTextureNodes = Record<string, {
|
|
110
|
+
path: (string | number)[];
|
|
111
|
+
bundle: SceneBundle;
|
|
112
|
+
}>;
|
|
113
|
+
/** Successful load with normalized local resources and authored texture provenance. */
|
|
114
|
+
export interface LoadedScene {
|
|
115
|
+
/** Merged scene data. */
|
|
116
|
+
config: SceneDefinition;
|
|
117
|
+
/** Root resource resolver. */
|
|
118
|
+
bundle: SceneBundle;
|
|
119
|
+
/** Original declaring bundle for every inline texture property. */
|
|
120
|
+
texture_nodes?: SceneTextureNodes;
|
|
121
|
+
}
|
|
122
|
+
/** A rejected subtree contributes no config, bundle, or texture provenance. */
|
|
123
|
+
export type SceneLoadResult = LoadedScene | {
|
|
124
|
+
config?: never;
|
|
125
|
+
bundle?: never;
|
|
126
|
+
texture_nodes?: never;
|
|
127
|
+
};
|
|
128
|
+
/** Scene import failure with its authored URL or object attached. */
|
|
129
|
+
export type SceneImportError = Error & {
|
|
130
|
+
url?: SceneInput;
|
|
131
|
+
};
|
|
132
|
+
/** Options shared by root loading and final camera normalization. */
|
|
133
|
+
export interface SceneLoadOptions {
|
|
134
|
+
/** Override the root resource directory, such as for an edited scene. */
|
|
135
|
+
path?: string | null;
|
|
136
|
+
/** Explicit root bundle format. */
|
|
137
|
+
type?: string | null;
|
|
138
|
+
/** Leave camera ownership to Tangram or its host. */
|
|
139
|
+
cameraMode?: 'scene' | 'external';
|
|
140
|
+
}
|
|
141
|
+
/** Typed loader operations shared by scene startup, editor reloads, and resource tests. */
|
|
142
|
+
export interface SceneLoaderAPI extends SubscriptionMethods {
|
|
143
|
+
/** Load a root scene, report failed imports, and return successful merged data. */
|
|
144
|
+
loadScene(url: SceneInput, options?: SceneLoadOptions): Promise<LoadedScene & {
|
|
145
|
+
texture_nodes: SceneTextureNodes;
|
|
146
|
+
}>;
|
|
147
|
+
/** Load an import subtree without rejecting valid sibling imports. */
|
|
148
|
+
loadSceneRecursive(resource: SceneResourceDescriptor, parent: SceneBundle | null, nodes?: SceneTextureNodes, errors?: SceneImportError[]): Promise<SceneLoadResult>;
|
|
149
|
+
/** Normalize one declaring scene before merging it with other scenes. */
|
|
150
|
+
normalize(config: SceneDefinition, bundle: SceneBundle, nodes?: SceneTextureNodes): LoadedScene;
|
|
151
|
+
/** Resolve source resource paths. */
|
|
152
|
+
normalizeDataSources(config: SceneDefinition, bundle: SceneBundle): SceneDefinition;
|
|
153
|
+
/** Resolve one source's data, metadata, composite, and script paths. */
|
|
154
|
+
normalizeDataSource(source: SceneSourceDefinition, bundle: SceneBundle): SceneSourceDefinition;
|
|
155
|
+
/** Resolve URL font faces, preserving CSS-provided fonts. */
|
|
156
|
+
normalizeFonts(config: SceneDefinition, bundle: SceneBundle): SceneDefinition;
|
|
157
|
+
/** Resolve named texture definitions. */
|
|
158
|
+
normalizeTextures(config: SceneDefinition, bundle: SceneBundle): void;
|
|
159
|
+
/** Collect inline texture provenance after named textures have been normalized. */
|
|
160
|
+
collectTextures(config: SceneDefinition, bundle: SceneBundle, nodes: SceneTextureNodes): void;
|
|
161
|
+
/** Record the declaring bundle for a nested texture property. */
|
|
162
|
+
addTextureNode(path: (string | number)[], bundle: SceneBundle, nodes: SceneTextureNodes): void;
|
|
163
|
+
/** Hoist inline texture URLs after global substitution; named textures must exist. */
|
|
164
|
+
hoistTextureNodes(config: SceneDefinition, bundle: SceneBundle, nodes?: SceneTextureNodes): void;
|
|
165
|
+
/** Substitute authored globals in merged scene data. */
|
|
166
|
+
applyGlobalProperties<Config extends SceneDefinition>(config: Config): Config;
|
|
167
|
+
/** Apply scene-wide defaults without synthesizing host-owned cameras. */
|
|
168
|
+
finalize<Bundle>(scene: {
|
|
169
|
+
config: SceneDefinition;
|
|
170
|
+
bundle: Bundle;
|
|
171
|
+
}, options?: SceneLoadOptions): {
|
|
172
|
+
config: FinalizedSceneDefinition;
|
|
173
|
+
bundle: Bundle;
|
|
174
|
+
};
|
|
175
|
+
/** Failed subtrees have no finalizable scene data. */
|
|
176
|
+
finalize(scene: SceneLoadResult, options?: SceneLoadOptions): SceneLoadResult;
|
|
177
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import JSZip from 'jszip';
|
|
2
|
+
import type { SceneDefinition, SceneInput, SceneResourceDescriptor } from "./scene-resource-types.js";
|
|
3
|
+
/** Extracted archive member and its lazily created browser URL. */
|
|
4
|
+
type SceneBundleFile = {
|
|
5
|
+
data: ArrayBuffer;
|
|
6
|
+
type: string | undefined;
|
|
7
|
+
depth: number;
|
|
8
|
+
url?: string;
|
|
9
|
+
};
|
|
10
|
+
type SceneBundleParent = SceneBundle | ZipSceneBundle | null;
|
|
11
|
+
/** Resolve resources relative to an authored scene, including nested archive imports. */
|
|
12
|
+
export declare class SceneBundle {
|
|
13
|
+
/** Scene URL or reusable in-memory definition. */
|
|
14
|
+
url: SceneInput;
|
|
15
|
+
/** Resource directory for this scene. */
|
|
16
|
+
path: string;
|
|
17
|
+
/** Authored directory used to resolve within an ancestor archive. */
|
|
18
|
+
path_for_parent: string;
|
|
19
|
+
/** Importing scene, if present. */
|
|
20
|
+
parent: SceneBundleParent;
|
|
21
|
+
/** Archive ancestor responsible for relative resources. */
|
|
22
|
+
container: SceneBundle | ZipSceneBundle | null;
|
|
23
|
+
/** Create a resource resolver without loading or validating its scene. */
|
|
24
|
+
constructor(url: SceneInput, path?: string | null, parent?: SceneBundleParent);
|
|
25
|
+
/** Load and parse URL data, or snapshot reusable object scene data. */
|
|
26
|
+
load(): Promise<SceneDefinition>;
|
|
27
|
+
/** Return the network/blob URL and authored directory/format for an import. */
|
|
28
|
+
resourceFor(url: string): SceneResourceDescriptor;
|
|
29
|
+
/** Resolve a resource URL, retaining globals and omitted URLs. */
|
|
30
|
+
urlFor(url: string | undefined): string | undefined;
|
|
31
|
+
/** Return the authored directory before archive resolution changes the URL. */
|
|
32
|
+
pathFor(url: string): string;
|
|
33
|
+
/** Infer the resource format from its authored extension. */
|
|
34
|
+
typeFor(url: string): string | undefined;
|
|
35
|
+
/** Ordinary scene files do not own an archive of resources. */
|
|
36
|
+
isContainer(): boolean;
|
|
37
|
+
}
|
|
38
|
+
/** ZIP scene with one root YAML member and lazy blob URLs for its resources. */
|
|
39
|
+
export declare class ZipSceneBundle extends SceneBundle {
|
|
40
|
+
/** Archive parser, initialized only when loading starts. */
|
|
41
|
+
zip: JSZip | null;
|
|
42
|
+
/** Non-directory members indexed by authored archive path. */
|
|
43
|
+
files: Record<string, SceneBundleFile>;
|
|
44
|
+
/** Root YAML path selected after archive inspection. */
|
|
45
|
+
root: string | null;
|
|
46
|
+
/** Create an archive resolver; loading remains explicit. */
|
|
47
|
+
constructor(url: SceneInput, path?: string | null, parent?: SceneBundleParent);
|
|
48
|
+
/** Archive scenes own their relative resources. */
|
|
49
|
+
isContainer(): boolean;
|
|
50
|
+
/** Extract an URL-backed archive, retaining the legacy object-input fallback. */
|
|
51
|
+
load(): Promise<SceneDefinition>;
|
|
52
|
+
/** Resolve relative resources within the archive, or delegate external URLs. */
|
|
53
|
+
urlFor(url: string | undefined): string | undefined;
|
|
54
|
+
/** Infer an archive member's format without opening its blob URL. */
|
|
55
|
+
typeFor(url: string): string | undefined;
|
|
56
|
+
/** Load the unique root YAML file selected by findRoot. */
|
|
57
|
+
loadRoot(): Promise<SceneDefinition>;
|
|
58
|
+
/** Select the unique root YAML file, rejecting missing or ambiguous roots. */
|
|
59
|
+
findRoot(): void;
|
|
60
|
+
/** Extract non-directory members while retaining depth and format metadata. */
|
|
61
|
+
parseZipFiles(): Promise<void>;
|
|
62
|
+
/** Create or reuse a member's blob URL; missing members return undefined. */
|
|
63
|
+
urlForZipFile(file: string): string | undefined;
|
|
64
|
+
/** Return a member's format, or undefined when the member is absent. */
|
|
65
|
+
typeForZipFile(file: string): string | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** Create a scene or zip bundle, inferring its path and parent when omitted. */
|
|
68
|
+
export declare function createSceneBundle(url: SceneInput, path?: string | null, parent?: SceneBundleParent, type?: string | null): SceneBundle | ZipSceneBundle;
|
|
69
|
+
export {};
|