@sakuzu/maplibre-gl-draw 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/LICENSE +661 -0
- package/README.ja.md +248 -0
- package/README.md +255 -0
- package/THIRD_PARTY_NOTICES.md +275 -0
- package/dist/api/api.d.ts +1259 -0
- package/dist/api/api.js +86 -0
- package/dist/api/context.d.ts +173 -0
- package/dist/api/context.js +193 -0
- package/dist/api/display-api.d.ts +1 -0
- package/dist/api/display-api.js +23 -0
- package/dist/api/event-api.d.ts +13 -0
- package/dist/api/event-api.js +17 -0
- package/dist/api/extension-api.d.ts +46 -0
- package/dist/api/extension-api.js +85 -0
- package/dist/api/feature-api.d.ts +11 -0
- package/dist/api/feature-api.js +101 -0
- package/dist/api/geometry/apply.d.ts +51 -0
- package/dist/api/geometry/apply.js +114 -0
- package/dist/api/geometry/boolean.d.ts +28 -0
- package/dist/api/geometry/boolean.js +65 -0
- package/dist/api/geometry/buffer.d.ts +11 -0
- package/dist/api/geometry/buffer.js +105 -0
- package/dist/api/geometry/split.d.ts +16 -0
- package/dist/api/geometry/split.js +75 -0
- package/dist/api/geometry/targets.d.ts +76 -0
- package/dist/api/geometry/targets.js +158 -0
- package/dist/api/geometry/types.d.ts +31 -0
- package/dist/api/geometry/types.js +3 -0
- package/dist/api/geometry-operations.d.ts +162 -0
- package/dist/api/geometry-operations.js +94 -0
- package/dist/api/group-api.d.ts +10 -0
- package/dist/api/group-api.js +78 -0
- package/dist/api/import-export/constants.d.ts +29 -0
- package/dist/api/import-export/constants.js +40 -0
- package/dist/api/import-export/embedded-file.d.ts +13 -0
- package/dist/api/import-export/embedded-file.js +31 -0
- package/dist/api/import-export/file-name.d.ts +10 -0
- package/dist/api/import-export/file-name.js +20 -0
- package/dist/api/import-export/format-detection.d.ts +12 -0
- package/dist/api/import-export/format-detection.js +29 -0
- package/dist/api/import-export/geojson-export.d.ts +19 -0
- package/dist/api/import-export/geojson-export.js +262 -0
- package/dist/api/import-export/geojson-import.d.ts +34 -0
- package/dist/api/import-export/geojson-import.js +538 -0
- package/dist/api/import-export/geometry-validation.d.ts +20 -0
- package/dist/api/import-export/geometry-validation.js +107 -0
- package/dist/api/import-export/image-import.d.ts +12 -0
- package/dist/api/import-export/image-import.js +53 -0
- package/dist/api/import-export/index.d.ts +9 -0
- package/dist/api/import-export/index.js +107 -0
- package/dist/api/import-export/native-format.d.ts +15 -0
- package/dist/api/import-export/native-format.js +126 -0
- package/dist/api/import-export/native-validation.d.ts +28 -0
- package/dist/api/import-export/native-validation.js +212 -0
- package/dist/api/import-export/own-property.d.ts +10 -0
- package/dist/api/import-export/own-property.js +19 -0
- package/dist/api/import-export/style-validation.d.ts +27 -0
- package/dist/api/import-export/style-validation.js +49 -0
- package/dist/api/import-export/types.d.ts +26 -0
- package/dist/api/import-export/types.js +3 -0
- package/dist/api/index.d.ts +15 -0
- package/dist/api/index.js +3 -0
- package/dist/api/input-api.d.ts +158 -0
- package/dist/api/input-api.js +144 -0
- package/dist/api/instance-api.d.ts +38 -0
- package/dist/api/instance-api.js +136 -0
- package/dist/api/layer-api.d.ts +12 -0
- package/dist/api/layer-api.js +62 -0
- package/dist/api/selection-api.d.ts +7 -0
- package/dist/api/selection-api.js +78 -0
- package/dist/api/snapping-api.d.ts +125 -0
- package/dist/api/snapping-api.js +50 -0
- package/dist/api/topology-api.d.ts +30 -0
- package/dist/api/topology-api.js +16 -0
- package/dist/api/tracing-api.d.ts +31 -0
- package/dist/api/tracing-api.js +16 -0
- package/dist/dispatcher/hit-test/box-strategies.d.ts +19 -0
- package/dist/dispatcher/hit-test/box-strategies.js +275 -0
- package/dist/dispatcher/hit-test/box-strategy.d.ts +59 -0
- package/dist/dispatcher/hit-test/box-strategy.js +37 -0
- package/dist/dispatcher/hit-test/globe-shape.d.ts +46 -0
- package/dist/dispatcher/hit-test/globe-shape.js +70 -0
- package/dist/dispatcher/hit-test/index.d.ts +14 -0
- package/dist/dispatcher/hit-test/index.js +9 -0
- package/dist/dispatcher/hit-test/local-frame.d.ts +77 -0
- package/dist/dispatcher/hit-test/local-frame.js +112 -0
- package/dist/dispatcher/hit-test/segment-grid.d.ts +32 -0
- package/dist/dispatcher/hit-test/segment-grid.js +79 -0
- package/dist/dispatcher/hit-test/service.d.ts +120 -0
- package/dist/dispatcher/hit-test/service.js +333 -0
- package/dist/dispatcher/hit-test/strategies/base.d.ts +136 -0
- package/dist/dispatcher/hit-test/strategies/base.js +66 -0
- package/dist/dispatcher/hit-test/strategies/circle.d.ts +10 -0
- package/dist/dispatcher/hit-test/strategies/circle.js +56 -0
- package/dist/dispatcher/hit-test/strategies/image.d.ts +22 -0
- package/dist/dispatcher/hit-test/strategies/image.js +115 -0
- package/dist/dispatcher/hit-test/strategies/index.d.ts +11 -0
- package/dist/dispatcher/hit-test/strategies/index.js +10 -0
- package/dist/dispatcher/hit-test/strategies/line.d.ts +17 -0
- package/dist/dispatcher/hit-test/strategies/line.js +30 -0
- package/dist/dispatcher/hit-test/strategies/multi.d.ts +44 -0
- package/dist/dispatcher/hit-test/strategies/multi.js +141 -0
- package/dist/dispatcher/hit-test/strategies/point.d.ts +20 -0
- package/dist/dispatcher/hit-test/strategies/point.js +29 -0
- package/dist/dispatcher/hit-test/strategies/polygon.d.ts +52 -0
- package/dist/dispatcher/hit-test/strategies/polygon.js +138 -0
- package/dist/dispatcher/hit-test/topmost.d.ts +48 -0
- package/dist/dispatcher/hit-test/topmost.js +157 -0
- package/dist/dispatcher/hit-test/visibility-lookup.d.ts +23 -0
- package/dist/dispatcher/hit-test/visibility-lookup.js +40 -0
- package/dist/dispatcher/index.d.ts +15 -0
- package/dist/dispatcher/index.js +3 -0
- package/dist/dispatcher/input-router.d.ts +1 -0
- package/dist/dispatcher/input-router.js +288 -0
- package/dist/dispatcher/normalizer.d.ts +1 -0
- package/dist/dispatcher/normalizer.js +513 -0
- package/dist/dispatcher/types.d.ts +144 -0
- package/dist/dispatcher/types.js +15 -0
- package/dist/display/chunk-set.d.ts +24 -0
- package/dist/display/chunk-set.js +533 -0
- package/dist/display/chunk.d.ts +1 -0
- package/dist/display/chunk.js +104 -0
- package/dist/display/columnar/index.d.ts +12 -0
- package/dist/display/columnar/index.js +13 -0
- package/dist/display/columnar/prepare.d.ts +42 -0
- package/dist/display/columnar/prepare.js +116 -0
- package/dist/display/columnar/source.d.ts +1 -0
- package/dist/display/columnar/source.js +531 -0
- package/dist/display/columnar/table.d.ts +1 -0
- package/dist/display/columnar/table.js +471 -0
- package/dist/display/columnar/types.d.ts +223 -0
- package/dist/display/columnar/types.js +3 -0
- package/dist/display/dataset.d.ts +2 -0
- package/dist/display/dataset.js +891 -0
- package/dist/display/index.d.ts +13 -0
- package/dist/display/index.js +3 -0
- package/dist/display/interaction.d.ts +1 -0
- package/dist/display/interaction.js +90 -0
- package/dist/display/manager.d.ts +1 -0
- package/dist/display/manager.js +440 -0
- package/dist/display/packed-rtree.d.ts +1 -0
- package/dist/display/packed-rtree.js +244 -0
- package/dist/display/partition.d.ts +1 -0
- package/dist/display/partition.js +226 -0
- package/dist/display/provider.d.ts +1 -0
- package/dist/display/provider.js +342 -0
- package/dist/display/retained.d.ts +40 -0
- package/dist/display/retained.js +898 -0
- package/dist/display/selection.d.ts +13 -0
- package/dist/display/selection.js +226 -0
- package/dist/display/source.d.ts +1 -0
- package/dist/display/source.js +119 -0
- package/dist/display/spatial.d.ts +1 -0
- package/dist/display/spatial.js +71 -0
- package/dist/display/style.d.ts +1 -0
- package/dist/display/style.js +126 -0
- package/dist/display/thinning.d.ts +65 -0
- package/dist/display/thinning.js +910 -0
- package/dist/display/triangulation.d.ts +1 -0
- package/dist/display/triangulation.js +0 -0
- package/dist/display/types.d.ts +561 -0
- package/dist/display/types.js +43 -0
- package/dist/extension/feature-handler.d.ts +182 -0
- package/dist/extension/feature-handler.js +3 -0
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +3 -0
- package/dist/extension/renderers.d.ts +208 -0
- package/dist/extension/renderers.js +3 -0
- package/dist/geometry/angle.d.ts +47 -0
- package/dist/geometry/angle.js +44 -0
- package/dist/geometry/bbox.d.ts +48 -0
- package/dist/geometry/bbox.js +83 -0
- package/dist/geometry/boolean.d.ts +162 -0
- package/dist/geometry/boolean.js +331 -0
- package/dist/geometry/buffer.d.ts +72 -0
- package/dist/geometry/buffer.js +218 -0
- package/dist/geometry/circle.d.ts +55 -0
- package/dist/geometry/circle.js +107 -0
- package/dist/geometry/coords.d.ts +97 -0
- package/dist/geometry/coords.js +149 -0
- package/dist/geometry/distance.d.ts +79 -0
- package/dist/geometry/distance.js +111 -0
- package/dist/geometry/errors.d.ts +74 -0
- package/dist/geometry/errors.js +104 -0
- package/dist/geometry/index.d.ts +28 -0
- package/dist/geometry/index.js +38 -0
- package/dist/geometry/measure.d.ts +81 -0
- package/dist/geometry/measure.js +236 -0
- package/dist/geometry/predicates.d.ts +62 -0
- package/dist/geometry/predicates.js +132 -0
- package/dist/geometry/simplify.d.ts +74 -0
- package/dist/geometry/simplify.js +159 -0
- package/dist/geometry/split.d.ts +68 -0
- package/dist/geometry/split.js +430 -0
- package/dist/geometry/types.d.ts +95 -0
- package/dist/geometry/types.js +3 -0
- package/dist/geometry/units.d.ts +35 -0
- package/dist/geometry/units.js +41 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +20 -0
- package/dist/maplibre-gl-draw.d.ts +47 -0
- package/dist/maplibre-gl-draw.js +407 -0
- package/dist/messages.d.ts +64 -0
- package/dist/messages.js +36 -0
- package/dist/modes/cursor.d.ts +1 -0
- package/dist/modes/cursor.js +72 -0
- package/dist/modes/draw/circle.d.ts +1 -0
- package/dist/modes/draw/circle.js +222 -0
- package/dist/modes/draw/commit-layer.d.ts +26 -0
- package/dist/modes/draw/commit-layer.js +31 -0
- package/dist/modes/draw/freehand.d.ts +1 -0
- package/dist/modes/draw/freehand.js +264 -0
- package/dist/modes/draw/image.d.ts +1 -0
- package/dist/modes/draw/image.js +60 -0
- package/dist/modes/draw/index.d.ts +9 -0
- package/dist/modes/draw/index.js +11 -0
- package/dist/modes/draw/line.d.ts +1 -0
- package/dist/modes/draw/line.js +363 -0
- package/dist/modes/draw/point.d.ts +1 -0
- package/dist/modes/draw/point.js +87 -0
- package/dist/modes/draw/polygon.d.ts +1 -0
- package/dist/modes/draw/polygon.js +378 -0
- package/dist/modes/draw/trace-support.d.ts +79 -0
- package/dist/modes/draw/trace-support.js +161 -0
- package/dist/modes/handler.d.ts +285 -0
- package/dist/modes/handler.js +3 -0
- package/dist/modes/index.d.ts +7 -0
- package/dist/modes/index.js +3 -0
- package/dist/modes/manager.d.ts +15 -0
- package/dist/modes/manager.js +196 -0
- package/dist/modes/select/box-selection.d.ts +52 -0
- package/dist/modes/select/box-selection.js +140 -0
- package/dist/modes/select/click-handler.d.ts +32 -0
- package/dist/modes/select/click-handler.js +166 -0
- package/dist/modes/select/cursor-handler.d.ts +15 -0
- package/dist/modes/select/cursor-handler.js +59 -0
- package/dist/modes/select/drag/auxiliary.d.ts +26 -0
- package/dist/modes/select/drag/auxiliary.js +56 -0
- package/dist/modes/select/drag/intermediate-writes.d.ts +1 -0
- package/dist/modes/select/drag/intermediate-writes.js +171 -0
- package/dist/modes/select/drag/move.d.ts +24 -0
- package/dist/modes/select/drag/move.js +59 -0
- package/dist/modes/select/drag/operation.d.ts +30 -0
- package/dist/modes/select/drag/operation.js +18 -0
- package/dist/modes/select/drag/radius.d.ts +15 -0
- package/dist/modes/select/drag/radius.js +49 -0
- package/dist/modes/select/drag/transform.d.ts +17 -0
- package/dist/modes/select/drag/transform.js +155 -0
- package/dist/modes/select/drag/vertex.d.ts +17 -0
- package/dist/modes/select/drag/vertex.js +163 -0
- package/dist/modes/select/drag-handler.d.ts +1 -0
- package/dist/modes/select/drag-handler.js +254 -0
- package/dist/modes/select/hit-helpers.d.ts +40 -0
- package/dist/modes/select/hit-helpers.js +51 -0
- package/dist/modes/select/mode.d.ts +1 -0
- package/dist/modes/select/mode.js +397 -0
- package/dist/modes/select/shortcut-handler.d.ts +40 -0
- package/dist/modes/select/shortcut-handler.js +128 -0
- package/dist/operations/index.d.ts +9 -0
- package/dist/operations/index.js +3 -0
- package/dist/operations/layer-operations.d.ts +1 -0
- package/dist/operations/layer-operations.js +350 -0
- package/dist/operations/resize.d.ts +71 -0
- package/dist/operations/resize.js +252 -0
- package/dist/operations/rotate.d.ts +17 -0
- package/dist/operations/rotate.js +166 -0
- package/dist/operations/selection-operations.d.ts +20 -0
- package/dist/operations/selection-operations.js +159 -0
- package/dist/operations/shared-vertex.d.ts +1 -0
- package/dist/operations/shared-vertex.js +210 -0
- package/dist/operations/trace-graph.d.ts +96 -0
- package/dist/operations/trace-graph.js +283 -0
- package/dist/operations/vertex.d.ts +1 -0
- package/dist/operations/vertex.js +538 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/mutation-hooks.d.ts +28 -0
- package/dist/plugins/mutation-hooks.js +84 -0
- package/dist/plugins/plugin-context.d.ts +1 -0
- package/dist/plugins/plugin-context.js +367 -0
- package/dist/plugins/plugin-manager.d.ts +103 -0
- package/dist/plugins/plugin-manager.js +316 -0
- package/dist/plugins/plugin.d.ts +529 -0
- package/dist/plugins/plugin.js +3 -0
- package/dist/shared/config/constants.d.ts +66 -0
- package/dist/shared/config/constants.js +60 -0
- package/dist/shared/config/feature-style.d.ts +155 -0
- package/dist/shared/config/feature-style.js +154 -0
- package/dist/shared/config/index.d.ts +17 -0
- package/dist/shared/config/index.js +8 -0
- package/dist/shared/config/rendering.d.ts +107 -0
- package/dist/shared/config/rendering.js +33 -0
- package/dist/shared/config/selection-highlight.d.ts +29 -0
- package/dist/shared/config/selection-highlight.js +35 -0
- package/dist/shared/config/selection.d.ts +273 -0
- package/dist/shared/config/selection.js +266 -0
- package/dist/shared/config/topology.d.ts +33 -0
- package/dist/shared/config/topology.js +17 -0
- package/dist/shared/config/trace.d.ts +40 -0
- package/dist/shared/config/trace.js +17 -0
- package/dist/shared/math/angle.d.ts +21 -0
- package/dist/shared/math/angle.js +34 -0
- package/dist/shared/math/circle.d.ts +6 -0
- package/dist/shared/math/circle.js +10 -0
- package/dist/shared/math/constants.d.ts +48 -0
- package/dist/shared/math/constants.js +59 -0
- package/dist/shared/math/distance.d.ts +78 -0
- package/dist/shared/math/distance.js +147 -0
- package/dist/shared/math/globe-subdivision.d.ts +62 -0
- package/dist/shared/math/globe-subdivision.js +99 -0
- package/dist/shared/math/index.d.ts +17 -0
- package/dist/shared/math/index.js +21 -0
- package/dist/shared/math/intersection.d.ts +63 -0
- package/dist/shared/math/intersection.js +236 -0
- package/dist/shared/math/longitude.d.ts +20 -0
- package/dist/shared/math/longitude.js +31 -0
- package/dist/shared/math/mercator-plane.d.ts +27 -0
- package/dist/shared/math/mercator-plane.js +26 -0
- package/dist/shared/math/obb.d.ts +65 -0
- package/dist/shared/math/obb.js +107 -0
- package/dist/shared/math/rotation.d.ts +93 -0
- package/dist/shared/math/rotation.js +186 -0
- package/dist/shared/math/segment-grid.d.ts +69 -0
- package/dist/shared/math/segment-grid.js +159 -0
- package/dist/shared/math/transform.d.ts +140 -0
- package/dist/shared/math/transform.js +189 -0
- package/dist/shared/types/events.d.ts +128 -0
- package/dist/shared/types/events.js +3 -0
- package/dist/shared/types/model.d.ts +950 -0
- package/dist/shared/types/model.js +3 -0
- package/dist/shared/types/selection-box.d.ts +23 -0
- package/dist/shared/types/selection-box.js +3 -0
- package/dist/shared/types/style.d.ts +68 -0
- package/dist/shared/types/style.js +3 -0
- package/dist/shared/utils/color.d.ts +49 -0
- package/dist/shared/utils/color.js +180 -0
- package/dist/shared/utils/coordinates.d.ts +52 -0
- package/dist/shared/utils/coordinates.js +75 -0
- package/dist/shared/utils/embedded-image.d.ts +34 -0
- package/dist/shared/utils/embedded-image.js +161 -0
- package/dist/shared/utils/event-emitter.d.ts +262 -0
- package/dist/shared/utils/event-emitter.js +44 -0
- package/dist/shared/utils/feature-bbox.d.ts +8 -0
- package/dist/shared/utils/feature-bbox.js +207 -0
- package/dist/shared/utils/feature-segments.d.ts +23 -0
- package/dist/shared/utils/feature-segments.js +179 -0
- package/dist/shared/utils/id.d.ts +1 -0
- package/dist/shared/utils/id.js +35 -0
- package/dist/shared/utils/image.d.ts +34 -0
- package/dist/shared/utils/image.js +106 -0
- package/dist/shared/utils/index.d.ts +15 -0
- package/dist/shared/utils/index.js +24 -0
- package/dist/shared/utils/map.d.ts +26 -0
- package/dist/shared/utils/map.js +35 -0
- package/dist/shared/utils/name-generator.d.ts +197 -0
- package/dist/shared/utils/name-generator.js +337 -0
- package/dist/shared/utils/pixel-ratio.d.ts +111 -0
- package/dist/shared/utils/pixel-ratio.js +85 -0
- package/dist/shared/utils/property.d.ts +88 -0
- package/dist/shared/utils/property.js +140 -0
- package/dist/shared/utils/vertex-ref.d.ts +23 -0
- package/dist/shared/utils/vertex-ref.js +20 -0
- package/dist/snapping/custom-targets.d.ts +1 -0
- package/dist/snapping/custom-targets.js +21 -0
- package/dist/snapping/geometry.d.ts +1 -0
- package/dist/snapping/geometry.js +61 -0
- package/dist/snapping/index.d.ts +14 -0
- package/dist/snapping/index.js +4 -0
- package/dist/snapping/indicator.d.ts +19 -0
- package/dist/snapping/indicator.js +145 -0
- package/dist/snapping/providers/display.d.ts +72 -0
- package/dist/snapping/providers/display.js +268 -0
- package/dist/snapping/providers/guide.d.ts +69 -0
- package/dist/snapping/providers/guide.js +187 -0
- package/dist/snapping/providers/intersection.d.ts +1 -0
- package/dist/snapping/providers/intersection.js +92 -0
- package/dist/snapping/providers/shared.d.ts +39 -0
- package/dist/snapping/providers/shared.js +146 -0
- package/dist/snapping/providers/store.d.ts +1 -0
- package/dist/snapping/providers/store.js +132 -0
- package/dist/snapping/service.d.ts +1 -0
- package/dist/snapping/service.js +272 -0
- package/dist/snapping/types.d.ts +267 -0
- package/dist/snapping/types.js +66 -0
- package/dist/store/change-merger.d.ts +1 -0
- package/dist/store/change-merger.js +102 -0
- package/dist/store/draw-store.d.ts +1 -0
- package/dist/store/draw-store.js +396 -0
- package/dist/store/event-bridge.d.ts +1 -0
- package/dist/store/event-bridge.js +161 -0
- package/dist/store/index.d.ts +12 -0
- package/dist/store/index.js +4 -0
- package/dist/store/local-visibility.d.ts +21 -0
- package/dist/store/local-visibility.js +27 -0
- package/dist/store/lock.d.ts +67 -0
- package/dist/store/lock.js +54 -0
- package/dist/store/memory/change-bus.d.ts +60 -0
- package/dist/store/memory/change-bus.js +232 -0
- package/dist/store/memory/file-store.d.ts +15 -0
- package/dist/store/memory/file-store.js +33 -0
- package/dist/store/memory/frozen.d.ts +21 -0
- package/dist/store/memory/frozen.js +51 -0
- package/dist/store/memory/ui-state.d.ts +51 -0
- package/dist/store/memory/ui-state.js +223 -0
- package/dist/store/memory.d.ts +26 -0
- package/dist/store/memory.js +708 -0
- package/dist/store/spatial/index.d.ts +6 -0
- package/dist/store/spatial/index.js +4 -0
- package/dist/store/spatial/spatial-index.d.ts +90 -0
- package/dist/store/spatial/spatial-index.js +148 -0
- package/dist/store/spatial/store-spatial-index.d.ts +60 -0
- package/dist/store/spatial/store-spatial-index.js +125 -0
- package/dist/store/store.d.ts +417 -0
- package/dist/store/store.js +3 -0
- package/dist/store/types.d.ts +8 -0
- package/dist/store/types.js +3 -0
- package/dist/store/writable-layer.d.ts +35 -0
- package/dist/store/writable-layer.js +20 -0
- package/dist/view/cache/buffer.d.ts +28 -0
- package/dist/view/cache/buffer.js +176 -0
- package/dist/view/cache/earcut.d.ts +1 -0
- package/dist/view/cache/earcut.js +122 -0
- package/dist/view/cache/style-rule.d.ts +1 -0
- package/dist/view/cache/style-rule.js +97 -0
- package/dist/view/cache/terrain-fill.d.ts +30 -0
- package/dist/view/cache/terrain-fill.js +60 -0
- package/dist/view/cache/texture.d.ts +14 -0
- package/dist/view/cache/texture.js +292 -0
- package/dist/view/coordinator.d.ts +27 -0
- package/dist/view/coordinator.js +72 -0
- package/dist/view/feature-companion.d.ts +173 -0
- package/dist/view/feature-companion.js +108 -0
- package/dist/view/globe-subdivision.d.ts +78 -0
- package/dist/view/globe-subdivision.js +128 -0
- package/dist/view/index.d.ts +47 -0
- package/dist/view/index.js +20 -0
- package/dist/view/layer/attach.d.ts +20 -0
- package/dist/view/layer/attach.js +47 -0
- package/dist/view/layer/blend.d.ts +57 -0
- package/dist/view/layer/blend.js +14 -0
- package/dist/view/layer/custom-layer.d.ts +1 -0
- package/dist/view/layer/custom-layer.js +509 -0
- package/dist/view/layer/depth-state.d.ts +14 -0
- package/dist/view/layer/depth-state.js +44 -0
- package/dist/view/layer/display-list.d.ts +1 -0
- package/dist/view/layer/display-list.js +111 -0
- package/dist/view/layer/drape-planner.d.ts +139 -0
- package/dist/view/layer/drape-planner.js +726 -0
- package/dist/view/layer/frame-render.d.ts +57 -0
- package/dist/view/layer/frame-render.js +209 -0
- package/dist/view/layer/frame-state.d.ts +147 -0
- package/dist/view/layer/frame-state.js +484 -0
- package/dist/view/layer/gl-state.d.ts +77 -0
- package/dist/view/layer/gl-state.js +132 -0
- package/dist/view/layer/index.d.ts +6 -0
- package/dist/view/layer/index.js +5 -0
- package/dist/view/layer/render-scope.d.ts +30 -0
- package/dist/view/layer/render-scope.js +28 -0
- package/dist/view/layer/render.d.ts +87 -0
- package/dist/view/layer/render.js +187 -0
- package/dist/view/layer/renderers.d.ts +81 -0
- package/dist/view/layer/renderers.js +142 -0
- package/dist/view/layer/slot-manager.d.ts +26 -0
- package/dist/view/layer/slot-manager.js +133 -0
- package/dist/view/layer/slots.d.ts +33 -0
- package/dist/view/layer/slots.js +50 -0
- package/dist/view/layer/store-retained-bbox.d.ts +36 -0
- package/dist/view/layer/store-retained-bbox.js +188 -0
- package/dist/view/layer/store-retained-chunk.d.ts +97 -0
- package/dist/view/layer/store-retained-chunk.js +94 -0
- package/dist/view/layer/store-retained-classify.d.ts +34 -0
- package/dist/view/layer/store-retained-classify.js +88 -0
- package/dist/view/layer/store-retained-collect.d.ts +24 -0
- package/dist/view/layer/store-retained-collect.js +121 -0
- package/dist/view/layer/store-retained-coord-patch.d.ts +119 -0
- package/dist/view/layer/store-retained-coord-patch.js +168 -0
- package/dist/view/layer/store-retained-immediate.d.ts +63 -0
- package/dist/view/layer/store-retained-immediate.js +49 -0
- package/dist/view/layer/store-retained-invalidation.d.ts +96 -0
- package/dist/view/layer/store-retained-invalidation.js +192 -0
- package/dist/view/layer/store-retained.d.ts +198 -0
- package/dist/view/layer/store-retained.js +430 -0
- package/dist/view/layer/terrain-resolver.d.ts +1 -0
- package/dist/view/layer/terrain-resolver.js +174 -0
- package/dist/view/renderers/batch-manager.d.ts +61 -0
- package/dist/view/renderers/batch-manager.js +718 -0
- package/dist/view/renderers/draw-factors.d.ts +60 -0
- package/dist/view/renderers/draw-factors.js +35 -0
- package/dist/view/renderers/drawer.d.ts +1 -0
- package/dist/view/renderers/drawer.js +346 -0
- package/dist/view/renderers/image.d.ts +1 -0
- package/dist/view/renderers/image.js +255 -0
- package/dist/view/renderers/line/dash.d.ts +31 -0
- package/dist/view/renderers/line/dash.js +152 -0
- package/dist/view/renderers/line/line-geometry.d.ts +39 -0
- package/dist/view/renderers/line/line-geometry.js +460 -0
- package/dist/view/renderers/line/line-gl.d.ts +1 -0
- package/dist/view/renderers/line/line-gl.js +236 -0
- package/dist/view/renderers/line/line-shader.d.ts +1 -0
- package/dist/view/renderers/line/line-shader.js +364 -0
- package/dist/view/renderers/line/line-types.d.ts +43 -0
- package/dist/view/renderers/line/line-types.js +3 -0
- package/dist/view/renderers/line/line-uniforms.d.ts +1 -0
- package/dist/view/renderers/line/line-uniforms.js +390 -0
- package/dist/view/renderers/line/sdf-line.d.ts +92 -0
- package/dist/view/renderers/line/sdf-line.js +567 -0
- package/dist/view/renderers/point/billboard-depth.d.ts +10 -0
- package/dist/view/renderers/point/billboard-depth.js +56 -0
- package/dist/view/renderers/point/point-instance.d.ts +124 -0
- package/dist/view/renderers/point/point-instance.js +738 -0
- package/dist/view/renderers/point/point-sdf.d.ts +58 -0
- package/dist/view/renderers/point/point-sdf.js +170 -0
- package/dist/view/renderers/point/point-shape.d.ts +99 -0
- package/dist/view/renderers/point/point-shape.js +504 -0
- package/dist/view/renderers/point/point-style.d.ts +1 -0
- package/dist/view/renderers/point/point-style.js +46 -0
- package/dist/view/renderers/polygon/batch.d.ts +26 -0
- package/dist/view/renderers/polygon/batch.js +336 -0
- package/dist/view/renderers/polygon/earcut-input.d.ts +37 -0
- package/dist/view/renderers/polygon/earcut-input.js +55 -0
- package/dist/view/renderers/polygon/earcut-sliced.d.ts +69 -0
- package/dist/view/renderers/polygon/earcut-sliced.js +960 -0
- package/dist/view/renderers/polygon/fill.d.ts +74 -0
- package/dist/view/renderers/polygon/fill.js +251 -0
- package/dist/view/renderers/polygon/sdf-polygon.d.ts +62 -0
- package/dist/view/renderers/polygon/sdf-polygon.js +919 -0
- package/dist/view/renderers/polygon/terrain-cull.d.ts +3 -0
- package/dist/view/renderers/polygon/terrain-cull.js +14 -0
- package/dist/view/renderers/polygon/triangulator.d.ts +41 -0
- package/dist/view/renderers/polygon/triangulator.js +3 -0
- package/dist/view/renderers/retained.d.ts +43 -0
- package/dist/view/renderers/retained.js +3 -0
- package/dist/view/renderers/stroke.d.ts +121 -0
- package/dist/view/renderers/stroke.js +621 -0
- package/dist/view/shaders/frame.d.ts +8 -0
- package/dist/view/shaders/frame.js +37 -0
- package/dist/view/shaders/helpers.d.ts +238 -0
- package/dist/view/shaders/helpers.js +611 -0
- package/dist/view/shaders/initializer.d.ts +27 -0
- package/dist/view/shaders/initializer.js +125 -0
- package/dist/view/shaders/projection.d.ts +123 -0
- package/dist/view/shaders/projection.js +299 -0
- package/dist/view/shaders/quad-grid.d.ts +77 -0
- package/dist/view/shaders/quad-grid.js +128 -0
- package/dist/view/shaders/quad.d.ts +189 -0
- package/dist/view/shaders/quad.js +582 -0
- package/dist/view/shaders/retained-origin.d.ts +50 -0
- package/dist/view/shaders/retained-origin.js +67 -0
- package/dist/view/shaders/terrain-shade.d.ts +23 -0
- package/dist/view/shaders/terrain-shade.js +93 -0
- package/dist/view/style-rule.d.ts +166 -0
- package/dist/view/style-rule.js +300 -0
- package/dist/view/terrain/anchor.d.ts +135 -0
- package/dist/view/terrain/anchor.js +226 -0
- package/dist/view/terrain/context.d.ts +132 -0
- package/dist/view/terrain/context.js +437 -0
- package/dist/view/terrain/dem-atlas.d.ts +97 -0
- package/dist/view/terrain/dem-atlas.js +534 -0
- package/dist/view/terrain/detect.d.ts +126 -0
- package/dist/view/terrain/detect.js +198 -0
- package/dist/view/terrain/drape/bin-store.d.ts +179 -0
- package/dist/view/terrain/drape/bin-store.js +529 -0
- package/dist/view/terrain/drape/binning.d.ts +259 -0
- package/dist/view/terrain/drape/binning.js +604 -0
- package/dist/view/terrain/drape/edge-constrain.d.ts +37 -0
- package/dist/view/terrain/drape/edge-constrain.js +175 -0
- package/dist/view/terrain/drape/geometry.d.ts +95 -0
- package/dist/view/terrain/drape/geometry.js +260 -0
- package/dist/view/terrain/drape/mesh.d.ts +50 -0
- package/dist/view/terrain/drape/mesh.js +86 -0
- package/dist/view/terrain/drape/pass.d.ts +122 -0
- package/dist/view/terrain/drape/pass.js +379 -0
- package/dist/view/terrain/drape/quad-glyphs.d.ts +64 -0
- package/dist/view/terrain/drape/quad-glyphs.js +117 -0
- package/dist/view/terrain/drape/quad.d.ts +249 -0
- package/dist/view/terrain/drape/quad.js +835 -0
- package/dist/view/terrain/drape/renderer.d.ts +184 -0
- package/dist/view/terrain/drape/renderer.js +706 -0
- package/dist/view/terrain/drape/shared.d.ts +80 -0
- package/dist/view/terrain/drape/shared.js +173 -0
- package/dist/view/terrain/drape/stitch.d.ts +155 -0
- package/dist/view/terrain/drape/stitch.js +228 -0
- package/dist/view/terrain/ground.d.ts +72 -0
- package/dist/view/terrain/ground.js +151 -0
- package/dist/view/terrain/metrics.d.ts +180 -0
- package/dist/view/terrain/metrics.js +231 -0
- package/dist/view/terrain/occlusion.d.ts +11 -0
- package/dist/view/terrain/occlusion.js +129 -0
- package/dist/view/terrain/polygon.d.ts +86 -0
- package/dist/view/terrain/polygon.js +301 -0
- package/dist/view/terrain/shade.d.ts +48 -0
- package/dist/view/terrain/shade.js +45 -0
- package/dist/view/terrain/state.d.ts +99 -0
- package/dist/view/terrain/state.js +186 -0
- package/dist/view/terrain/tessellation.d.ts +265 -0
- package/dist/view/terrain/tessellation.js +924 -0
- package/dist/view/terrain/tiling.d.ts +56 -0
- package/dist/view/terrain/tiling.js +155 -0
- package/dist/view/terrain/upstream-terrain.d.ts +82 -0
- package/dist/view/terrain/upstream-terrain.js +116 -0
- package/dist/view/ui/auxiliary-handles.d.ts +151 -0
- package/dist/view/ui/auxiliary-handles.js +22 -0
- package/dist/view/ui/bounds.d.ts +53 -0
- package/dist/view/ui/bounds.js +149 -0
- package/dist/view/ui/box-selection.d.ts +1 -0
- package/dist/view/ui/box-selection.js +83 -0
- package/dist/view/ui/handle-test.d.ts +1 -0
- package/dist/view/ui/handle-test.js +437 -0
- package/dist/view/ui/handle-thinning.d.ts +122 -0
- package/dist/view/ui/handle-thinning.js +430 -0
- package/dist/view/ui/handles.d.ts +25 -0
- package/dist/view/ui/handles.js +673 -0
- package/dist/view/ui/helper.d.ts +19 -0
- package/dist/view/ui/helper.js +76 -0
- package/dist/view/ui/index.d.ts +15 -0
- package/dist/view/ui/index.js +15 -0
- package/dist/view/ui/selection-scope.d.ts +25 -0
- package/dist/view/ui/selection-scope.js +34 -0
- package/dist/view/ui/selection-ui/bounding-box.d.ts +44 -0
- package/dist/view/ui/selection-ui/bounding-box.js +240 -0
- package/dist/view/ui/selection-ui/extension-registry.d.ts +76 -0
- package/dist/view/ui/selection-ui/extension-registry.js +78 -0
- package/dist/view/ui/selection-ui/index.d.ts +12 -0
- package/dist/view/ui/selection-ui/index.js +12 -0
- package/dist/view/ui/selection-ui/renderer.d.ts +29 -0
- package/dist/view/ui/selection-ui/renderer.js +227 -0
- package/dist/view/ui/selection-ui/types.d.ts +55 -0
- package/dist/view/ui/selection-ui/types.js +3 -0
- package/dist/view/ui/selection-ui-drawer.d.ts +52 -0
- package/dist/view/ui/selection-ui-drawer.js +329 -0
- package/dist/view/ui/tentative.d.ts +1 -0
- package/dist/view/ui/tentative.js +320 -0
- package/dist/view/viewport.d.ts +119 -0
- package/dist/view/viewport.js +254 -0
- package/package.json +113 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessors of the frame state of terrain rendering
|
|
3
|
+
*
|
|
4
|
+
* This is state during rendering that is set only while the terrain (MapLibre's terrain) is
|
|
5
|
+
* enabled. The owner of the values is the `TerrainContext` of each draw instance
|
|
6
|
+
* (`context.ts`; how a shared global broke with several instances is written there). Every
|
|
7
|
+
* accessor takes that context explicitly: the renderers of a CustomLayer receive their
|
|
8
|
+
* instance's context at construction, and extension renderers receive it in the draw context
|
|
9
|
+
* (`CustomRendererDrawContext.terrain`). Nothing here reads "the instance drawn last".
|
|
10
|
+
*
|
|
11
|
+
* When the terrain is disabled, `INACTIVE_TERRAIN_STATE` is held and the shader's
|
|
12
|
+
* `u_terrain_on` becomes 0. The vertex computation when it is 0 is exactly identical to
|
|
13
|
+
* the former one (this guarantees zero regression).
|
|
14
|
+
*/
|
|
15
|
+
import { INACTIVE_TERRAIN_STATE, type TerrainContext, type TerrainDrapeDebug, type TerrainRenderState } from './context.js';
|
|
16
|
+
import type { QuadDrapeFrame } from './drape/quad.js';
|
|
17
|
+
import type { TerrainShadeLight } from './shade.js';
|
|
18
|
+
export type { TerrainDrapeDebug, TerrainRenderState };
|
|
19
|
+
export { INACTIVE_TERRAIN_STATE };
|
|
20
|
+
/**
|
|
21
|
+
* Replaces the terrain state of the frame (custom-layer calls this every frame)
|
|
22
|
+
*/
|
|
23
|
+
export declare function setTerrainRenderState(context: TerrainContext, state: TerrainRenderState): void;
|
|
24
|
+
/**
|
|
25
|
+
* Whether giving elevation to the vertices is suppressed
|
|
26
|
+
*
|
|
27
|
+
* UI drawn as a rectangle on the screen (the rubber band of a rectangular selection) stops
|
|
28
|
+
* being a rectangle once it is pasted onto the ground surface. Elevation is stopped only
|
|
29
|
+
* for such drawing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isTerrainElevationSuppressed(context: TerrainContext): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether this is a frame that draws polygons and lines flat (a band that cannot be made
|
|
34
|
+
* to follow the ground surface)
|
|
35
|
+
*
|
|
36
|
+
* The reason is written at `surfacesFlattened` in `context.ts`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isTerrainSurfacesFlattened(context: TerrainContext): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Sets whether polygons and lines are drawn flat in this frame (custom-layer calls this
|
|
41
|
+
* every frame)
|
|
42
|
+
*/
|
|
43
|
+
export declare function setTerrainSurfacesFlattened(context: TerrainContext, flattened: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the shading light source of this frame (custom-layer calls this for each frame)
|
|
46
|
+
*
|
|
47
|
+
* null is set for frames where the terrain is disabled. While it is null, fills on the
|
|
48
|
+
* vertex displacement path are drawn with a shading factor of 1.0 (the same pixels as
|
|
49
|
+
* before the terrain was introduced).
|
|
50
|
+
*/
|
|
51
|
+
export declare function setTerrainShadeLight(context: TerrainContext, light: TerrainShadeLight | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* The shading light source of this frame (null when the terrain is disabled)
|
|
54
|
+
*/
|
|
55
|
+
export declare function getTerrainShadeLight(context: TerrainContext): TerrainShadeLight | null;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the datasets whose polygons and lines are painted by the analytic drape in this
|
|
58
|
+
* frame
|
|
59
|
+
*
|
|
60
|
+
* The reason is written at `drapePaintedDatasets` in `context.ts`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function setDrapePaintedDatasets(context: TerrainContext, ids: ReadonlySet<string> | null): void;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the polygons and lines of this dataset are painted by the analytic drape in
|
|
65
|
+
* this frame
|
|
66
|
+
*/
|
|
67
|
+
export declare function isDrapePaintedDataset(context: TerrainContext, id: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the camera is in the middle of moving (used to decide to defer rebaking the
|
|
70
|
+
* retained batches)
|
|
71
|
+
*/
|
|
72
|
+
export declare function isTerrainCameraMoving(context: TerrainContext): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Records the movement of the camera (custom-layer calls this every frame)
|
|
75
|
+
*/
|
|
76
|
+
export declare function setTerrainCameraMoving(context: TerrainContext, moving: boolean): void;
|
|
77
|
+
/**
|
|
78
|
+
* Reports the coarseness of the step that was used (the polygon renderer calls this when
|
|
79
|
+
* building a batch)
|
|
80
|
+
*
|
|
81
|
+
* The coarsest value within the generation is kept. Only one depth bias can be set for the
|
|
82
|
+
* whole frame, so it is matched to a value at which the coarsest polygon does not sink.
|
|
83
|
+
*/
|
|
84
|
+
export declare function reportTerrainCoarsening(context: TerrainContext, factor: number): void;
|
|
85
|
+
/**
|
|
86
|
+
* The coarsest step multiplier used in this generation
|
|
87
|
+
*/
|
|
88
|
+
export declare function getTerrainCoarsening(context: TerrainContext): number;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the handle of the quad analytic drape for this frame (null when the terrain is
|
|
91
|
+
* disabled)
|
|
92
|
+
*
|
|
93
|
+
* QuadShader (Image, and the fill of text quads) reads it.
|
|
94
|
+
*/
|
|
95
|
+
export declare function getQuadDrapeFrame(context: TerrainContext): QuadDrapeFrame | null;
|
|
96
|
+
/** Sets the handle of the quad analytic drape (custom-layer calls this every frame) */
|
|
97
|
+
export declare function setQuadDrapeFrame(context: TerrainContext, frame: QuadDrapeFrame | null): void;
|
|
98
|
+
/** Sets the diagnostic values (custom-layer calls this) */
|
|
99
|
+
export declare function setTerrainDrapeDebug(context: TerrainContext, value: TerrainDrapeDebug): void;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
/**
|
|
4
|
+
* Accessors of the frame state of terrain rendering
|
|
5
|
+
*
|
|
6
|
+
* This is state during rendering that is set only while the terrain (MapLibre's terrain) is
|
|
7
|
+
* enabled. The owner of the values is the `TerrainContext` of each draw instance
|
|
8
|
+
* (`context.ts`; how a shared global broke with several instances is written there). Every
|
|
9
|
+
* accessor takes that context explicitly: the renderers of a CustomLayer receive their
|
|
10
|
+
* instance's context at construction, and extension renderers receive it in the draw context
|
|
11
|
+
* (`CustomRendererDrawContext.terrain`). Nothing here reads "the instance drawn last".
|
|
12
|
+
*
|
|
13
|
+
* When the terrain is disabled, `INACTIVE_TERRAIN_STATE` is held and the shader's
|
|
14
|
+
* `u_terrain_on` becomes 0. The vertex computation when it is 0 is exactly identical to
|
|
15
|
+
* the former one (this guarantees zero regression).
|
|
16
|
+
*/
|
|
17
|
+
import { INACTIVE_TERRAIN_STATE, } from './context.js';
|
|
18
|
+
export { INACTIVE_TERRAIN_STATE };
|
|
19
|
+
/**
|
|
20
|
+
* Texture unit that binds the DEM atlas (unit 0 is used by the coordinate texture)
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const TERRAIN_ATLAS_TEXTURE_UNIT = 6;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the terrain state of the current frame
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export function getTerrainRenderState(context) {
|
|
31
|
+
return context.renderState;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Replaces the terrain state of the frame (custom-layer calls this every frame)
|
|
35
|
+
*/
|
|
36
|
+
export function setTerrainRenderState(context, state) {
|
|
37
|
+
context.renderState = state;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether giving elevation to the vertices is suppressed
|
|
41
|
+
*
|
|
42
|
+
* UI drawn as a rectangle on the screen (the rubber band of a rectangular selection) stops
|
|
43
|
+
* being a rectangle once it is pasted onto the ground surface. Elevation is stopped only
|
|
44
|
+
* for such drawing.
|
|
45
|
+
*/
|
|
46
|
+
export function isTerrainElevationSuppressed(context) {
|
|
47
|
+
return context.elevationSuppressed;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Draws with the elevation turned off
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export function withoutTerrainElevation(context, draw) {
|
|
55
|
+
const previous = context.elevationSuppressed;
|
|
56
|
+
context.elevationSuppressed = true;
|
|
57
|
+
try {
|
|
58
|
+
return draw();
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
context.elevationSuppressed = previous;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether this is a frame that draws polygons and lines flat (a band that cannot be made
|
|
66
|
+
* to follow the ground surface)
|
|
67
|
+
*
|
|
68
|
+
* The reason is written at `surfacesFlattened` in `context.ts`.
|
|
69
|
+
*/
|
|
70
|
+
export function isTerrainSurfacesFlattened(context) {
|
|
71
|
+
return context.surfacesFlattened;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Sets whether polygons and lines are drawn flat in this frame (custom-layer calls this
|
|
75
|
+
* every frame)
|
|
76
|
+
*/
|
|
77
|
+
export function setTerrainSurfacesFlattened(context, flattened) {
|
|
78
|
+
context.surfacesFlattened = flattened;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sets the shading light source of this frame (custom-layer calls this for each frame)
|
|
82
|
+
*
|
|
83
|
+
* null is set for frames where the terrain is disabled. While it is null, fills on the
|
|
84
|
+
* vertex displacement path are drawn with a shading factor of 1.0 (the same pixels as
|
|
85
|
+
* before the terrain was introduced).
|
|
86
|
+
*/
|
|
87
|
+
export function setTerrainShadeLight(context, light) {
|
|
88
|
+
context.shadeLight = light;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The shading light source of this frame (null when the terrain is disabled)
|
|
92
|
+
*/
|
|
93
|
+
export function getTerrainShadeLight(context) {
|
|
94
|
+
return context.shadeLight;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Sets the datasets whose polygons and lines are painted by the analytic drape in this
|
|
98
|
+
* frame
|
|
99
|
+
*
|
|
100
|
+
* The reason is written at `drapePaintedDatasets` in `context.ts`.
|
|
101
|
+
*/
|
|
102
|
+
export function setDrapePaintedDatasets(context, ids) {
|
|
103
|
+
context.drapePaintedDatasets = ids;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Whether the polygons and lines of this dataset are painted by the analytic drape in
|
|
107
|
+
* this frame
|
|
108
|
+
*/
|
|
109
|
+
export function isDrapePaintedDataset(context, id) {
|
|
110
|
+
return context.drapePaintedDatasets?.has(id) === true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the vertex shader adds the elevation (the state combined with the suppression)
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export function isTerrainElevationActive(context) {
|
|
118
|
+
return context.renderState.active && !context.elevationSuppressed;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Whether the subdivision on the CPU side is enabled
|
|
122
|
+
*
|
|
123
|
+
* This is independent of the suppression (`withoutTerrainElevation`), because subdivision
|
|
124
|
+
* is a matter of building the vertex data while suppression is a matter of drawing.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
export function isTerrainTessellationActive(context) {
|
|
129
|
+
const state = context.renderState;
|
|
130
|
+
return state.active && state.stepMeters > 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Whether the camera is in the middle of moving (used to decide to defer rebaking the
|
|
134
|
+
* retained batches)
|
|
135
|
+
*/
|
|
136
|
+
export function isTerrainCameraMoving(context) {
|
|
137
|
+
return context.cameraMoving;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Records the movement of the camera (custom-layer calls this every frame)
|
|
141
|
+
*/
|
|
142
|
+
export function setTerrainCameraMoving(context, moving) {
|
|
143
|
+
context.cameraMoving = moving;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Reports the coarseness of the step that was used (the polygon renderer calls this when
|
|
147
|
+
* building a batch)
|
|
148
|
+
*
|
|
149
|
+
* The coarsest value within the generation is kept. Only one depth bias can be set for the
|
|
150
|
+
* whole frame, so it is matched to a value at which the coarsest polygon does not sink.
|
|
151
|
+
*/
|
|
152
|
+
export function reportTerrainCoarsening(context, factor) {
|
|
153
|
+
if (factor > context.tessellationCoarsening)
|
|
154
|
+
context.tessellationCoarsening = factor;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The coarsest step multiplier used in this generation
|
|
158
|
+
*/
|
|
159
|
+
export function getTerrainCoarsening(context) {
|
|
160
|
+
return context.tessellationCoarsening;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets the handle of the quad analytic drape for this frame (null when the terrain is
|
|
164
|
+
* disabled)
|
|
165
|
+
*
|
|
166
|
+
* QuadShader (Image, and the fill of text quads) reads it.
|
|
167
|
+
*/
|
|
168
|
+
export function getQuadDrapeFrame(context) {
|
|
169
|
+
return context.quadDrapeFrame;
|
|
170
|
+
}
|
|
171
|
+
/** Sets the handle of the quad analytic drape (custom-layer calls this every frame) */
|
|
172
|
+
export function setQuadDrapeFrame(context, frame) {
|
|
173
|
+
context.quadDrapeFrame = frame;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets the diagnostic values
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
export function getTerrainDrapeDebug(context) {
|
|
181
|
+
return context.drapeDebug;
|
|
182
|
+
}
|
|
183
|
+
/** Sets the diagnostic values (custom-layer calls this) */
|
|
184
|
+
export function setTerrainDrapeDebug(context, value) {
|
|
185
|
+
context.drapeDebug = value;
|
|
186
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tessellation for terrain
|
|
3
|
+
*
|
|
4
|
+
* On terrain, a long segment sinks into the ground where it crosses a valley and floats
|
|
5
|
+
* above a ridge. Since elevation can only be given to vertices, the only option is to cut
|
|
6
|
+
* segments and triangles finely and give elevation to the split points as well.
|
|
7
|
+
*
|
|
8
|
+
* ## Why we align with "the lattice of MapLibre's terrain mesh"
|
|
9
|
+
*
|
|
10
|
+
* If the step were an arbitrary interval, we would be sampling the same DEM with "two
|
|
11
|
+
* triangulations that know nothing about each other". Neither the vertex positions nor the
|
|
12
|
+
* directions of the triangle diagonals would agree, so the two surfaces would never agree
|
|
13
|
+
* exactly anywhere, and the discrepancy is largest where the twist inside a DEM cell is
|
|
14
|
+
* largest -- at the creases of a slope. Making the tessellation finer only makes the
|
|
15
|
+
* discrepancy asymptotically smaller, never zero, and a constant lift cannot cover it.
|
|
16
|
+
*
|
|
17
|
+
* So we place the split points on the lattice nodes of MapLibre's terrain mesh themselves.
|
|
18
|
+
* MapLibre draws terrain on a regular lattice that divides one tile into `terrain.meshSize`
|
|
19
|
+
* (128 by default) parts, so the nodes line up at multiples of 1/(2^z * meshSize) in
|
|
20
|
+
* Mercator coordinates. On a node both elevations become the same interpolated value of the
|
|
21
|
+
* same DEM, so the surfaces agree. We also match the direction of the cell diagonal to
|
|
22
|
+
* MapLibre (getTerrainMesh splits along the main diagonal (x, y) -> (x+1, y+1)), so they
|
|
23
|
+
* agree inside a cell as well. All that remains is floating point rounding, and that can be
|
|
24
|
+
* covered with a depth bias.
|
|
25
|
+
*
|
|
26
|
+
* The lattice is defined in Mercator space, so the tessellation is done in Mercator space
|
|
27
|
+
* too. A lattice with equal intervals in longitude and latitude does not sit on the Mercator
|
|
28
|
+
* lattice (the latitude direction is non-linear). Input and output stay in longitude and
|
|
29
|
+
* latitude; only the internals move to Mercator.
|
|
30
|
+
*
|
|
31
|
+
* This code is only reached when terrain is enabled. When it is disabled the caller passes
|
|
32
|
+
* straight through, so the result is byte-for-byte identical to the conventional rendering.
|
|
33
|
+
*/
|
|
34
|
+
import type { Coordinate } from '../../store/types.js';
|
|
35
|
+
/**
|
|
36
|
+
* A rectangle in Web Mercator coordinates (0..1 across the world, y growing southward).
|
|
37
|
+
*/
|
|
38
|
+
export interface MercatorRect {
|
|
39
|
+
/** The west edge */
|
|
40
|
+
readonly x0: number;
|
|
41
|
+
/** The north edge */
|
|
42
|
+
readonly y0: number;
|
|
43
|
+
/** The east edge */
|
|
44
|
+
readonly x1: number;
|
|
45
|
+
/** The south edge */
|
|
46
|
+
readonly y1: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* How finely a line or a fill is subdivided to follow the terrain mesh, as
|
|
50
|
+
* {@link getTerrainTessellationStep} returns it.
|
|
51
|
+
*/
|
|
52
|
+
export interface TessellationStep {
|
|
53
|
+
/**
|
|
54
|
+
* Lattice interval (in Mercator units)
|
|
55
|
+
*
|
|
56
|
+
* The node interval of MapLibre's terrain mesh, 1/(2^z * meshSize), or that value
|
|
57
|
+
* coarsened by a power of two. Even when coarsened it still sits on a subset of the nodes.
|
|
58
|
+
*/
|
|
59
|
+
readonly grid: number;
|
|
60
|
+
/** Upper limit on the number of vertices that may be generated */
|
|
61
|
+
readonly maxPoints: number;
|
|
62
|
+
/**
|
|
63
|
+
* The area that may be tessellated (in Mercator; null means no area = split anywhere)
|
|
64
|
+
*
|
|
65
|
+
* Elevation is read from the DEM atlas, but the atlas only covers the neighbourhood of
|
|
66
|
+
* the view, and outside it the value saturates at the edge value (`dem_elevation_meters`
|
|
67
|
+
* in `shaders/helpers.ts` clamps the uv). In other words, splitting finely outside the
|
|
68
|
+
* atlas only splits a flat surface finely while it stays flat, and the elevation does not
|
|
69
|
+
* change by a single metre.
|
|
70
|
+
*
|
|
71
|
+
* Splitting there anyway was the root of the slowness. With a dataset
|
|
72
|
+
* (8,172 administrative boundaries, all of Japan), the cost of splitting even the features
|
|
73
|
+
* that never appear on screen ate up the batch's tessellation budget, and the uniform
|
|
74
|
+
* coarsening applied to stay within the budget (up to 64x) reached even the features on
|
|
75
|
+
* screen. The chord of a coarse triangle dives below a hill, gets cut away by the depth
|
|
76
|
+
* test, and a hole opens in the fill.
|
|
77
|
+
*
|
|
78
|
+
* So we limit the area we split to the atlas (plus a margin). The cost is decided by how
|
|
79
|
+
* wide the view is and no longer depends on the number of records, so what is on screen
|
|
80
|
+
* can always be split at the finest step.
|
|
81
|
+
*/
|
|
82
|
+
readonly region?: MercatorRect | null;
|
|
83
|
+
/**
|
|
84
|
+
* The actual mesh step of each terrain tile (if null, `grid` is used everywhere)
|
|
85
|
+
*
|
|
86
|
+
* MapLibre's terrain is drawn with a fixed lattice per tile, and in a pitched view the
|
|
87
|
+
* more distant the view is, the coarser the zoom of the tiles used. Matching the step to
|
|
88
|
+
* the tile's actual mesh makes our own surface agree with MapLibre's both on the nodes and
|
|
89
|
+
* inside the cells. If it is not matched, too fine a step sinks along the valley bottoms
|
|
90
|
+
* and too coarse a step dives under the ridges, and both are cut away by depth.
|
|
91
|
+
*/
|
|
92
|
+
readonly tiling?: TessellationTiling | null;
|
|
93
|
+
/**
|
|
94
|
+
* The coarsening factor applied to the tile step (a power of two; 1 = the actual mesh)
|
|
95
|
+
*
|
|
96
|
+
* Splitting at the actual mesh itself is ideal, but in a wide view the amount to split
|
|
97
|
+
* jumps. As long as we coarsen by a power of two, the split points keep sitting on a
|
|
98
|
+
* subset of the actual mesh nodes, so the problem of sinking along the valley bottoms does
|
|
99
|
+
* not occur (sinking happens when we leave the nodes). What remains is only that the chord
|
|
100
|
+
* dives slightly under a ridge, and that can be covered with a depth bias proportional to
|
|
101
|
+
* the step. Keep the factor small (TERRAIN_MAX_TILED_COARSEN).
|
|
102
|
+
*/
|
|
103
|
+
readonly coarsen?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The subdivision step of each terrain tile, indexed by a grid of cells.
|
|
107
|
+
*
|
|
108
|
+
* The set of tiles is indexed by cells the size of the finest tile. A coarse tile spans
|
|
109
|
+
* several cells, but a cell boundary always lies on one of that tile's mesh lines (the side
|
|
110
|
+
* length of the finest tile is an integer multiple of the mesh interval), so cutting along
|
|
111
|
+
* the cells does not create a seam.
|
|
112
|
+
*/
|
|
113
|
+
export interface TessellationTiling {
|
|
114
|
+
/** The area the index covers (in Mercator) */
|
|
115
|
+
readonly rect: MercatorRect;
|
|
116
|
+
/** The side length of an index cell (= the side length of the finest tile) */
|
|
117
|
+
readonly cell: number;
|
|
118
|
+
/** The number of cell columns */
|
|
119
|
+
readonly cols: number;
|
|
120
|
+
/** The number of cell rows */
|
|
121
|
+
readonly rows: number;
|
|
122
|
+
/** The step of each cell (0 = there is no tile = do not split) */
|
|
123
|
+
readonly grids: Float64Array;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Whether the rectangles intersect
|
|
127
|
+
*/
|
|
128
|
+
export declare function rectsIntersect(minX: number, minY: number, maxX: number, maxY: number, region: MercatorRect): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Whether the rectangle `outer` wholly contains the rectangle `inner`
|
|
131
|
+
*/
|
|
132
|
+
export declare function containsRect(outer: MercatorRect, inner: MercatorRect): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Expand a rectangle outwards by `margin` as a ratio of its side lengths
|
|
135
|
+
*/
|
|
136
|
+
export declare function expandRect(rect: MercatorRect, margin: number): MercatorRect;
|
|
137
|
+
/**
|
|
138
|
+
* The intersection of two rectangles (null if they do not intersect)
|
|
139
|
+
*/
|
|
140
|
+
export declare function intersectRect(a: MercatorRect, b: MercatorRect): MercatorRect | null;
|
|
141
|
+
/**
|
|
142
|
+
* Convert the DEM atlas uniform representation [x0, y0, 1/width, 1/height] into a rectangle
|
|
143
|
+
*/
|
|
144
|
+
export declare function atlasCoverage(rect: readonly [number, number, number, number]): MercatorRect;
|
|
145
|
+
/**
|
|
146
|
+
* The number of lattice cells a bounding box touches within the area (an estimate)
|
|
147
|
+
*
|
|
148
|
+
* We do not split outside the area, so it is left out of the cost estimate too.
|
|
149
|
+
*/
|
|
150
|
+
export declare function cellsInRegion(minX: number, minY: number, maxX: number, maxY: number, grid: number, region: MercatorRect | null | undefined): number;
|
|
151
|
+
/** The result of the triangulation */
|
|
152
|
+
export interface TessellatedFill {
|
|
153
|
+
flatCoords: number[];
|
|
154
|
+
indices: number[];
|
|
155
|
+
/**
|
|
156
|
+
* Whether the step was too fine to split through
|
|
157
|
+
*
|
|
158
|
+
* When true, the result contains triangles that are "left as they were (flat triangles
|
|
159
|
+
* that do not follow the terrain)". Either the vertex budget ran out, or one triangle
|
|
160
|
+
* covered too many cells. A flat triangle is visible as a wedge piercing the terrain, so
|
|
161
|
+
* the caller must coarsen the step and split again (tessellatePolygonFill in
|
|
162
|
+
* terrain/polygon.ts). It is exactly this mixture of "fine in places, flat in the rest"
|
|
163
|
+
* that is the real cause of the visual breakdown.
|
|
164
|
+
*/
|
|
165
|
+
overflowed: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* By what factor the step has to be coarsened to split through (1 = it split through as
|
|
168
|
+
* it was)
|
|
169
|
+
*
|
|
170
|
+
* Repeating "it did not split through, so double it and try again" means that for a huge
|
|
171
|
+
* feature (a municipal boundary with 130,000 vertices, for example) the work is redone
|
|
172
|
+
* every time up to the limit of 6 rounds, spending hundreds of milliseconds on a single
|
|
173
|
+
* feature. The factor we need follows directly from the amount that overflowed, so we
|
|
174
|
+
* return it and get it right in one go.
|
|
175
|
+
*/
|
|
176
|
+
overflowFactor: number;
|
|
177
|
+
}
|
|
178
|
+
/** Longitude -> Mercator x */
|
|
179
|
+
export declare function mercatorX(lng: number): number;
|
|
180
|
+
/** Latitude -> Mercator y */
|
|
181
|
+
export declare function mercatorY(lat: number): number;
|
|
182
|
+
/** Mercator x -> longitude */
|
|
183
|
+
export declare function lngFromMercatorX(x: number): number;
|
|
184
|
+
/** Mercator y -> latitude */
|
|
185
|
+
export declare function latFromMercatorY(y: number): number;
|
|
186
|
+
/**
|
|
187
|
+
* Inserts vertices where a line crosses the lattice of the terrain mesh, so that it follows
|
|
188
|
+
* the terrain when each vertex is lifted.
|
|
189
|
+
*
|
|
190
|
+
* The original vertices are always kept, and only the intersections with the lattice lines
|
|
191
|
+
* are inserted. The intersections are found by linear interpolation in Mercator space
|
|
192
|
+
* (rendering also draws a straight line after projection, so an inserted point always lies
|
|
193
|
+
* on the original line).
|
|
194
|
+
*
|
|
195
|
+
* @param path The vertices `[lng, lat]` in degrees
|
|
196
|
+
* @param step The step from {@link getTerrainTessellationStep}
|
|
197
|
+
* @returns The densified vertices. The input itself for fewer than 2 positions or a step of
|
|
198
|
+
* 0; insertion stops when `step.maxPoints` is reached
|
|
199
|
+
*/
|
|
200
|
+
export declare function densifyPath(path: readonly Coordinate[], step: TessellationStep): Coordinate[];
|
|
201
|
+
/**
|
|
202
|
+
* Emit a triangle with its winding order aligned
|
|
203
|
+
*
|
|
204
|
+
* The terrain-following fill culls the far side of a ridge with back-face culling (the cure
|
|
205
|
+
* for the silhouette bleed-through in which a fill laid on the far slope shows through the
|
|
206
|
+
* ridge in front). For the culling to hold, the winding order of every triangle must be
|
|
207
|
+
* uniform, but the orientation of the input ring (clockwise / counter-clockwise) differs
|
|
208
|
+
* from feature to feature. So here we normalise to the orientation in which the cross
|
|
209
|
+
* product in Mercator (x right, y down) is positive. In a y-down coordinate system a
|
|
210
|
+
* positive cross product = clockwise on screen = counter-clockwise in GL window coordinates
|
|
211
|
+
* (y up) = the front face of the default frontFace(CCW).
|
|
212
|
+
*/
|
|
213
|
+
export declare function pushOriented(out: number[], pool: VertexPool, a: number, b: number, c: number): void;
|
|
214
|
+
/**
|
|
215
|
+
* The vertex pool (held in Mercator coordinates, with duplicates merged)
|
|
216
|
+
*
|
|
217
|
+
* By assigning the same number to the same coordinate, neighbouring triangles share their
|
|
218
|
+
* split points. If they are shared, their elevations necessarily agree too, so no crack
|
|
219
|
+
* appears in the fill.
|
|
220
|
+
*
|
|
221
|
+
* The longitude and latitude of the vertices that were there from the start are emitted as
|
|
222
|
+
* they are, without a round trip through the conversion.
|
|
223
|
+
*/
|
|
224
|
+
declare class VertexPool {
|
|
225
|
+
private readonly mx;
|
|
226
|
+
private readonly my;
|
|
227
|
+
private readonly lng;
|
|
228
|
+
private readonly lat;
|
|
229
|
+
/** A two-stage lookup, x -> (y -> number) (the keys are numbers; no strings are made) */
|
|
230
|
+
private readonly lookup;
|
|
231
|
+
private readonly limit;
|
|
232
|
+
private overflow;
|
|
233
|
+
constructor(source: readonly number[], maxPoints: number);
|
|
234
|
+
exhausted(): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* How many times the budget's worth of vertices we tried to create (usable as a step
|
|
237
|
+
* factor)
|
|
238
|
+
*
|
|
239
|
+
* The vertex count is inversely proportional to the square of the step, so the square root
|
|
240
|
+
* gives the step factor.
|
|
241
|
+
*/
|
|
242
|
+
overflowRatio(): number;
|
|
243
|
+
/**
|
|
244
|
+
* Register a Mercator coordinate and return its number
|
|
245
|
+
*
|
|
246
|
+
* The matching is exact. It is tempting to round before matching, but it must not be
|
|
247
|
+
* done. The intersection of a lattice line and an edge can come arbitrarily close to a
|
|
248
|
+
* lattice node, so with even the slightest rounding "a nearby but different point" is
|
|
249
|
+
* treated as the same one, that cell's fragment degenerates and drops out, and a hole one
|
|
250
|
+
* cell wide opens in the surface (measured). With exact matching, what remains instead is
|
|
251
|
+
* that vertices that are "the same point but differ in the last bit" occasionally survive.
|
|
252
|
+
* That becomes a crack 1e-16 degrees wide (1e-11 m on the ground), but it does not show on
|
|
253
|
+
* screen. Unlike a hole, the coverage of the surface is not lost.
|
|
254
|
+
*
|
|
255
|
+
* The key is a two-stage numeric lookup. A Map's numeric keys use SameValueZero
|
|
256
|
+
* comparison, so the matching is just as exact as it was back when we turned them into the
|
|
257
|
+
* string `${x},${y}`, while the per-point string creation disappears.
|
|
258
|
+
*/
|
|
259
|
+
intern(x: number, y: number): number;
|
|
260
|
+
x(index: number): number;
|
|
261
|
+
y(index: number): number;
|
|
262
|
+
/** Build the flattened coordinate array of longitudes and latitudes */
|
|
263
|
+
output(): number[];
|
|
264
|
+
}
|
|
265
|
+
export {};
|