maplibre-gl 3.1.0 → 3.2.0-pre.2
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 +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-struct-arrays.ts +9 -12
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3303 -3398
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3899 -3531
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +28 -25
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +36 -26
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +61 -44
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +34 -27
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +12 -11
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/value.ts +1 -1
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +8 -14
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +12 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +85 -65
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +18 -16
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +5 -4
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +7 -1
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/shaders.ts +1 -3
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +75 -59
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +23 -10
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +17 -38
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +34 -24
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +11 -23
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +21 -28
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +39 -33
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +23 -48
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +392 -361
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +21 -26
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +181 -194
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +46 -42
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +14 -18
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +570 -1281
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +97 -8
- package/src/ui/map.ts +856 -702
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +220 -141
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +179 -147
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +2 -6
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +6 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +6 -0
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +2 -4
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
package/src/render/painter.ts
CHANGED
|
@@ -1,66 +1,52 @@
|
|
|
1
|
-
import browser from '../util/browser';
|
|
1
|
+
import {browser} from '../util/browser';
|
|
2
2
|
import {mat4, vec3} from 'gl-matrix';
|
|
3
|
-
import SourceCache from '../source/source_cache';
|
|
4
|
-
import EXTENT from '../data/extent';
|
|
5
|
-
import pixelsToTileUnits from '../source/pixels_to_tile_units';
|
|
6
|
-
import SegmentVector from '../data/segment';
|
|
3
|
+
import {SourceCache} from '../source/source_cache';
|
|
4
|
+
import {EXTENT} from '../data/extent';
|
|
5
|
+
import {pixelsToTileUnits} from '../source/pixels_to_tile_units';
|
|
6
|
+
import {SegmentVector} from '../data/segment';
|
|
7
7
|
import {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types.g';
|
|
8
8
|
import rasterBoundsAttributes from '../data/raster_bounds_attributes';
|
|
9
9
|
import posAttributes from '../data/pos_attributes';
|
|
10
|
-
import ProgramConfiguration from '../data/program_configuration';
|
|
11
|
-
import CrossTileSymbolIndex from '../symbol/cross_tile_symbol_index';
|
|
12
|
-
import shaders from '../shaders/shaders';
|
|
13
|
-
import Program from './program';
|
|
10
|
+
import {ProgramConfiguration} from '../data/program_configuration';
|
|
11
|
+
import {CrossTileSymbolIndex} from '../symbol/cross_tile_symbol_index';
|
|
12
|
+
import {shaders} from '../shaders/shaders';
|
|
13
|
+
import {Program} from './program';
|
|
14
14
|
import {programUniforms} from './program/program_uniforms';
|
|
15
|
-
import Context from '../gl/context';
|
|
16
|
-
import DepthMode from '../gl/depth_mode';
|
|
17
|
-
import StencilMode from '../gl/stencil_mode';
|
|
18
|
-
import ColorMode from '../gl/color_mode';
|
|
19
|
-
import CullFaceMode from '../gl/cull_face_mode';
|
|
20
|
-
import Texture from './texture';
|
|
15
|
+
import {Context} from '../gl/context';
|
|
16
|
+
import {DepthMode} from '../gl/depth_mode';
|
|
17
|
+
import {StencilMode} from '../gl/stencil_mode';
|
|
18
|
+
import {ColorMode} from '../gl/color_mode';
|
|
19
|
+
import {CullFaceMode} from '../gl/cull_face_mode';
|
|
20
|
+
import {Texture} from './texture';
|
|
21
21
|
import {clippingMaskUniformValues} from './program/clipping_mask_program';
|
|
22
22
|
import {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
23
|
+
import {drawSymbols} from './draw_symbol';
|
|
24
|
+
import {drawCircles} from './draw_circle';
|
|
25
|
+
import {drawHeatmap} from './draw_heatmap';
|
|
26
|
+
import {drawLine} from './draw_line';
|
|
27
|
+
import {drawFill} from './draw_fill';
|
|
28
|
+
import {drawFillExtrusion} from './draw_fill_extrusion';
|
|
29
|
+
import {drawHillshade} from './draw_hillshade';
|
|
30
|
+
import {drawRaster} from './draw_raster';
|
|
31
|
+
import {drawBackground} from './draw_background';
|
|
32
|
+
import {drawDebug, drawDebugPadding, selectDebugSource} from './draw_debug';
|
|
33
|
+
import {drawCustom} from './draw_custom';
|
|
34
34
|
import {drawDepth, drawCoords} from './draw_terrain';
|
|
35
35
|
import {OverscaledTileID} from '../source/tile_id';
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
line,
|
|
42
|
-
fill,
|
|
43
|
-
'fill-extrusion': fillExtrusion,
|
|
44
|
-
hillshade,
|
|
45
|
-
raster,
|
|
46
|
-
background,
|
|
47
|
-
debug,
|
|
48
|
-
custom
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
import type Transform from '../geo/transform';
|
|
52
|
-
import type Tile from '../source/tile';
|
|
53
|
-
import type Style from '../style/style';
|
|
54
|
-
import type StyleLayer from '../style/style_layer';
|
|
37
|
+
import type {Transform} from '../geo/transform';
|
|
38
|
+
import type {Tile} from '../source/tile';
|
|
39
|
+
import type {Style} from '../style/style';
|
|
40
|
+
import type {StyleLayer} from '../style/style_layer';
|
|
55
41
|
import type {CrossFaded} from '../style/properties';
|
|
56
|
-
import type LineAtlas from './line_atlas';
|
|
57
|
-
import type ImageManager from './image_manager';
|
|
58
|
-
import type GlyphManager from './glyph_manager';
|
|
59
|
-
import type VertexBuffer from '../gl/vertex_buffer';
|
|
60
|
-
import type IndexBuffer from '../gl/index_buffer';
|
|
42
|
+
import type {LineAtlas} from './line_atlas';
|
|
43
|
+
import type {ImageManager} from './image_manager';
|
|
44
|
+
import type {GlyphManager} from './glyph_manager';
|
|
45
|
+
import type {VertexBuffer} from '../gl/vertex_buffer';
|
|
46
|
+
import type {IndexBuffer} from '../gl/index_buffer';
|
|
61
47
|
import type {DepthRangeType, DepthMaskType, DepthFuncType} from '../gl/types';
|
|
62
48
|
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
63
|
-
import RenderToTexture from './render_to_texture';
|
|
49
|
+
import {RenderToTexture} from './render_to_texture';
|
|
64
50
|
|
|
65
51
|
export type RenderPass = 'offscreen' | 'opaque' | 'translucent';
|
|
66
52
|
|
|
@@ -76,11 +62,8 @@ type PainterOptions = {
|
|
|
76
62
|
|
|
77
63
|
/**
|
|
78
64
|
* Initialize a new painter object.
|
|
79
|
-
*
|
|
80
|
-
* @param {Canvas} gl a webgl drawing context
|
|
81
|
-
* @private
|
|
82
65
|
*/
|
|
83
|
-
class Painter {
|
|
66
|
+
export class Painter {
|
|
84
67
|
context: Context;
|
|
85
68
|
transform: Transform;
|
|
86
69
|
renderToTexture: RenderToTexture;
|
|
@@ -149,8 +132,8 @@ class Painter {
|
|
|
149
132
|
* for a new width and height value.
|
|
150
133
|
*/
|
|
151
134
|
resize(width: number, height: number, pixelRatio: number) {
|
|
152
|
-
this.width = width * pixelRatio;
|
|
153
|
-
this.height = height * pixelRatio;
|
|
135
|
+
this.width = Math.floor(width * pixelRatio);
|
|
136
|
+
this.height = Math.floor(height * pixelRatio);
|
|
154
137
|
this.pixelRatio = pixelRatio;
|
|
155
138
|
this.context.viewport.set([0, 0, this.width, this.height]);
|
|
156
139
|
|
|
@@ -471,7 +454,7 @@ class Painter {
|
|
|
471
454
|
if (this.options.showTileBoundaries) {
|
|
472
455
|
const selectedSource = selectDebugSource(this.style, this.transform.zoom);
|
|
473
456
|
if (selectedSource) {
|
|
474
|
-
|
|
457
|
+
drawDebug(this, selectedSource, selectedSource.getVisibleCoordinates());
|
|
475
458
|
}
|
|
476
459
|
}
|
|
477
460
|
|
|
@@ -489,16 +472,46 @@ class Painter {
|
|
|
489
472
|
if (layer.type !== 'background' && layer.type !== 'custom' && !(coords || []).length) return;
|
|
490
473
|
this.id = layer.id;
|
|
491
474
|
|
|
492
|
-
|
|
475
|
+
switch (layer.type) {
|
|
476
|
+
case 'symbol':
|
|
477
|
+
drawSymbols(painter, sourceCache, layer as any, coords, this.style.placement.variableOffsets);
|
|
478
|
+
break;
|
|
479
|
+
case 'circle':
|
|
480
|
+
drawCircles(painter, sourceCache, layer as any, coords);
|
|
481
|
+
break;
|
|
482
|
+
case 'heatmap':
|
|
483
|
+
drawHeatmap(painter, sourceCache, layer as any, coords);
|
|
484
|
+
break;
|
|
485
|
+
case 'line':
|
|
486
|
+
drawLine(painter, sourceCache, layer as any, coords);
|
|
487
|
+
break;
|
|
488
|
+
case 'fill':
|
|
489
|
+
drawFill(painter, sourceCache, layer as any, coords);
|
|
490
|
+
break;
|
|
491
|
+
case 'fill-extrusion':
|
|
492
|
+
drawFillExtrusion(painter, sourceCache, layer as any, coords);
|
|
493
|
+
break;
|
|
494
|
+
case 'hillshade':
|
|
495
|
+
drawHillshade(painter, sourceCache, layer as any, coords);
|
|
496
|
+
break;
|
|
497
|
+
case 'raster':
|
|
498
|
+
drawRaster(painter, sourceCache, layer as any, coords);
|
|
499
|
+
break;
|
|
500
|
+
case 'background':
|
|
501
|
+
drawBackground(painter, sourceCache, layer as any, coords);
|
|
502
|
+
break;
|
|
503
|
+
case 'custom':
|
|
504
|
+
drawCustom(painter, sourceCache, layer as any);
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
493
507
|
}
|
|
494
508
|
|
|
495
509
|
/**
|
|
496
510
|
* Transform a matrix to incorporate the *-translate and *-translate-anchor properties into it.
|
|
497
|
-
* @param inViewportPixelUnitsUnits True when the units accepted by the matrix are in viewport pixels instead of tile units.
|
|
498
|
-
* @returns
|
|
499
|
-
* @private
|
|
511
|
+
* @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units.
|
|
512
|
+
* @returns matrix
|
|
500
513
|
*/
|
|
501
|
-
translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean) {
|
|
514
|
+
translatePosMatrix(matrix: mat4, tile: Tile, translate: [number, number], translateAnchor: 'map' | 'viewport', inViewportPixelUnitsUnits?: boolean): mat4 {
|
|
502
515
|
if (!translate[0] && !translate[1]) return matrix;
|
|
503
516
|
|
|
504
517
|
const angle = inViewportPixelUnitsUnits ?
|
|
@@ -543,7 +556,6 @@ class Painter {
|
|
|
543
556
|
* Checks whether a pattern image is needed, and if it is, whether it is not loaded.
|
|
544
557
|
*
|
|
545
558
|
* @returns true if a needed image is missing and rendering needs to be skipped.
|
|
546
|
-
* @private
|
|
547
559
|
*/
|
|
548
560
|
isPatternMissing(image?: CrossFaded<ResolvedImage> | null): boolean {
|
|
549
561
|
if (!image) return false;
|
|
@@ -617,6 +629,14 @@ class Painter {
|
|
|
617
629
|
this.debugOverlayTexture.destroy();
|
|
618
630
|
}
|
|
619
631
|
}
|
|
620
|
-
}
|
|
621
632
|
|
|
622
|
-
|
|
633
|
+
/*
|
|
634
|
+
* Return true if drawing buffer size is != from requested size.
|
|
635
|
+
* That means that we've reached GL limits somehow.
|
|
636
|
+
* Note: drawing buffer size changes only when canvas size changes
|
|
637
|
+
*/
|
|
638
|
+
overLimit() {
|
|
639
|
+
const {drawingBufferWidth, drawingBufferHeight} = this.context.gl;
|
|
640
|
+
return this.width !== drawingBufferWidth || this.height !== drawingBufferHeight;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
} from '../uniform_binding';
|
|
9
9
|
import {extend} from '../../util/util';
|
|
10
10
|
|
|
11
|
-
import type Painter from '../painter';
|
|
11
|
+
import type {Painter} from '../painter';
|
|
12
12
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
13
|
-
import type Context from '../../gl/context';
|
|
13
|
+
import type {Context} from '../../gl/context';
|
|
14
14
|
import type {Color, ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
15
15
|
import type {CrossFaded} from '../../style/properties';
|
|
16
16
|
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';
|
|
2
|
-
import pixelsToTileUnits from '../../source/pixels_to_tile_units';
|
|
2
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
3
3
|
|
|
4
|
-
import type Context from '../../gl/context';
|
|
4
|
+
import type {Context} from '../../gl/context';
|
|
5
5
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
6
6
|
import type {OverscaledTileID} from '../../source/tile_id';
|
|
7
|
-
import type Tile from '../../source/tile';
|
|
8
|
-
import type CircleStyleLayer from '../../style/style_layer/circle_style_layer';
|
|
9
|
-
import type Painter from '../painter';
|
|
7
|
+
import type {Tile} from '../../source/tile';
|
|
8
|
+
import type {CircleStyleLayer} from '../../style/style_layer/circle_style_layer';
|
|
9
|
+
import type {Painter} from '../painter';
|
|
10
10
|
|
|
11
11
|
export type CircleUniformsType = {
|
|
12
12
|
'u_camera_to_center_distance': Uniform1f;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';
|
|
2
|
-
import pixelsToTileUnits from '../../source/pixels_to_tile_units';
|
|
2
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
3
3
|
|
|
4
|
-
import type Context from '../../gl/context';
|
|
4
|
+
import type {Context} from '../../gl/context';
|
|
5
5
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
6
|
-
import type Transform from '../../geo/transform';
|
|
7
|
-
import type Tile from '../../source/tile';
|
|
6
|
+
import type {Transform} from '../../geo/transform';
|
|
7
|
+
import type {Tile} from '../../source/tile';
|
|
8
8
|
import {mat4} from 'gl-matrix';
|
|
9
9
|
|
|
10
10
|
export type CollisionUniformsType = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {UniformColor, UniformMatrix4f, Uniform1i, Uniform1f} from '../uniform_binding';
|
|
2
2
|
|
|
3
|
-
import type Context from '../../gl/context';
|
|
3
|
+
import type {Context} from '../../gl/context';
|
|
4
4
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
5
5
|
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
6
6
|
import {mat4} from 'gl-matrix';
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
import {mat3, mat4, vec3} from 'gl-matrix';
|
|
11
11
|
import {extend} from '../../util/util';
|
|
12
12
|
|
|
13
|
-
import type Context from '../../gl/context';
|
|
14
|
-
import type Painter from '../painter';
|
|
13
|
+
import type {Context} from '../../gl/context';
|
|
14
|
+
import type {Painter} from '../painter';
|
|
15
15
|
import type {OverscaledTileID} from '../../source/tile_id';
|
|
16
16
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
17
17
|
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
18
|
-
import type Tile from '../../source/tile';
|
|
18
|
+
import type {Tile} from '../../source/tile';
|
|
19
19
|
|
|
20
20
|
export type FillExtrusionUniformsType = {
|
|
21
21
|
'u_matrix': UniformMatrix4f;
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
} from '../uniform_binding';
|
|
9
9
|
import {extend} from '../../util/util';
|
|
10
10
|
|
|
11
|
-
import type Painter from '../painter';
|
|
11
|
+
import type {Painter} from '../painter';
|
|
12
12
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
13
|
-
import type Context from '../../gl/context';
|
|
13
|
+
import type {Context} from '../../gl/context';
|
|
14
14
|
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
15
|
-
import type Tile from '../../source/tile';
|
|
15
|
+
import type {Tile} from '../../source/tile';
|
|
16
16
|
import {mat4} from 'gl-matrix';
|
|
17
17
|
|
|
18
18
|
export type FillUniformsType = {
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
Uniform2f,
|
|
7
7
|
UniformMatrix4f
|
|
8
8
|
} from '../uniform_binding';
|
|
9
|
-
import pixelsToTileUnits from '../../source/pixels_to_tile_units';
|
|
9
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
10
10
|
|
|
11
|
-
import type Context from '../../gl/context';
|
|
12
|
-
import type Tile from '../../source/tile';
|
|
11
|
+
import type {Context} from '../../gl/context';
|
|
12
|
+
import type {Tile} from '../../source/tile';
|
|
13
13
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
14
|
-
import type Painter from '../painter';
|
|
15
|
-
import type HeatmapStyleLayer from '../../style/style_layer/heatmap_style_layer';
|
|
14
|
+
import type {Painter} from '../painter';
|
|
15
|
+
import type {HeatmapStyleLayer} from '../../style/style_layer/heatmap_style_layer';
|
|
16
16
|
|
|
17
17
|
export type HeatmapUniformsType = {
|
|
18
18
|
'u_extrude_scale': Uniform1f;
|
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
UniformMatrix4f,
|
|
9
9
|
Uniform4f
|
|
10
10
|
} from '../uniform_binding';
|
|
11
|
-
import EXTENT from '../../data/extent';
|
|
12
|
-
import MercatorCoordinate from '../../geo/mercator_coordinate';
|
|
11
|
+
import {EXTENT} from '../../data/extent';
|
|
12
|
+
import {MercatorCoordinate} from '../../geo/mercator_coordinate';
|
|
13
13
|
|
|
14
|
-
import type Context from '../../gl/context';
|
|
14
|
+
import type {Context} from '../../gl/context';
|
|
15
15
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
16
|
-
import type Tile from '../../source/tile';
|
|
17
|
-
import type Painter from '../painter';
|
|
18
|
-
import type HillshadeStyleLayer from '../../style/style_layer/hillshade_style_layer';
|
|
19
|
-
import type DEMData from '../../data/dem_data';
|
|
16
|
+
import type {Tile} from '../../source/tile';
|
|
17
|
+
import type {Painter} from '../painter';
|
|
18
|
+
import type {HillshadeStyleLayer} from '../../style/style_layer/hillshade_style_layer';
|
|
19
|
+
import type {DEMData} from '../../data/dem_data';
|
|
20
20
|
import type {OverscaledTileID} from '../../source/tile_id';
|
|
21
21
|
|
|
22
22
|
export type HillshadeUniformsType = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';
|
|
2
|
-
import pixelsToTileUnits from '../../source/pixels_to_tile_units';
|
|
2
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
3
3
|
import {extend} from '../../util/util';
|
|
4
4
|
|
|
5
|
-
import type Context from '../../gl/context';
|
|
5
|
+
import type {Context} from '../../gl/context';
|
|
6
6
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
7
|
-
import type Transform from '../../geo/transform';
|
|
8
|
-
import type Tile from '../../source/tile';
|
|
7
|
+
import type {Transform} from '../../geo/transform';
|
|
8
|
+
import type {Tile} from '../../source/tile';
|
|
9
9
|
import type {CrossFaded} from '../../style/properties';
|
|
10
|
-
import type LineStyleLayer from '../../style/style_layer/line_style_layer';
|
|
11
|
-
import type Painter from '../painter';
|
|
10
|
+
import type {LineStyleLayer} from '../../style/style_layer/line_style_layer';
|
|
11
|
+
import type {Painter} from '../painter';
|
|
12
12
|
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
13
13
|
import {OverscaledTileID} from '../../source/tile_id';
|
|
14
14
|
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
Uniform2f,
|
|
5
5
|
Uniform3f
|
|
6
6
|
} from '../uniform_binding';
|
|
7
|
-
import pixelsToTileUnits from '../../source/pixels_to_tile_units';
|
|
7
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
8
8
|
|
|
9
|
-
import type Painter from '../painter';
|
|
9
|
+
import type {Painter} from '../painter';
|
|
10
10
|
import type {OverscaledTileID} from '../../source/tile_id';
|
|
11
11
|
import type {CrossFaded} from '../../style/properties';
|
|
12
12
|
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
13
13
|
import type {UniformValues} from '../uniform_binding';
|
|
14
|
-
import type Tile from '../../source/tile';
|
|
14
|
+
import type {Tile} from '../../source/tile';
|
|
15
15
|
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
16
16
|
|
|
17
17
|
type BackgroundPatternUniformsType = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';
|
|
2
2
|
|
|
3
|
-
import type Context from '../../gl/context';
|
|
3
|
+
import type {Context} from '../../gl/context';
|
|
4
4
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
5
|
-
import type RasterStyleLayer from '../../style/style_layer/raster_style_layer';
|
|
5
|
+
import type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer';
|
|
6
6
|
import {mat4} from 'gl-matrix';
|
|
7
7
|
|
|
8
8
|
export type RasterUniformsType = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f} from '../uniform_binding';
|
|
2
2
|
import {extend} from '../../util/util';
|
|
3
3
|
|
|
4
|
-
import type Context from '../../gl/context';
|
|
5
|
-
import type Painter from '../painter';
|
|
4
|
+
import type {Context} from '../../gl/context';
|
|
5
|
+
import type {Painter} from '../painter';
|
|
6
6
|
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
7
7
|
import {mat4} from 'gl-matrix';
|
|
8
8
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Uniform4f,
|
|
5
5
|
UniformMatrix4f
|
|
6
6
|
} from '../uniform_binding';
|
|
7
|
-
import type Context from '../../gl/context';
|
|
7
|
+
import type {Context} from '../../gl/context';
|
|
8
8
|
import type {UniformValues, UniformLocations} from '../../render/uniform_binding';
|
|
9
9
|
import {mat4} from 'gl-matrix';
|
|
10
10
|
|
package/src/render/program.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import shaders from '../shaders/shaders';
|
|
2
|
-
import ProgramConfiguration from '../data/program_configuration';
|
|
3
|
-
import VertexArrayObject from './vertex_array_object';
|
|
4
|
-
import Context from '../gl/context';
|
|
5
|
-
|
|
6
|
-
import type SegmentVector from '../data/segment';
|
|
7
|
-
import type VertexBuffer from '../gl/vertex_buffer';
|
|
8
|
-
import type IndexBuffer from '../gl/index_buffer';
|
|
9
|
-
import type DepthMode from '../gl/depth_mode';
|
|
10
|
-
import type StencilMode from '../gl/stencil_mode';
|
|
11
|
-
import type ColorMode from '../gl/color_mode';
|
|
12
|
-
import type CullFaceMode from '../gl/cull_face_mode';
|
|
1
|
+
import {shaders} from '../shaders/shaders';
|
|
2
|
+
import {ProgramConfiguration} from '../data/program_configuration';
|
|
3
|
+
import {VertexArrayObject} from './vertex_array_object';
|
|
4
|
+
import {Context} from '../gl/context';
|
|
5
|
+
|
|
6
|
+
import type {SegmentVector} from '../data/segment';
|
|
7
|
+
import type {VertexBuffer} from '../gl/vertex_buffer';
|
|
8
|
+
import type {IndexBuffer} from '../gl/index_buffer';
|
|
9
|
+
import type {DepthMode} from '../gl/depth_mode';
|
|
10
|
+
import type {StencilMode} from '../gl/stencil_mode';
|
|
11
|
+
import type {ColorMode} from '../gl/color_mode';
|
|
12
|
+
import type {CullFaceMode} from '../gl/cull_face_mode';
|
|
13
13
|
import type {UniformBindings, UniformValues, UniformLocations} from './uniform_binding';
|
|
14
14
|
import type {BinderUniform} from '../data/program_configuration';
|
|
15
15
|
import {terrainPreludeUniforms, TerrainPreludeUniformsType} from './program/terrain_program';
|
|
16
16
|
import type {TerrainData} from '../render/terrain';
|
|
17
|
-
import Terrain from '../render/terrain';
|
|
17
|
+
import {Terrain} from '../render/terrain';
|
|
18
18
|
|
|
19
19
|
export type DrawMode = WebGLRenderingContextBase['LINES'] | WebGLRenderingContextBase['TRIANGLES'] | WebGL2RenderingContext['LINE_STRIP'];
|
|
20
20
|
|
|
@@ -28,7 +28,11 @@ function getTokenizedAttributesAndUniforms(array: Array<string>): Array<string>
|
|
|
28
28
|
}
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A webgl program to execute in the GPU space
|
|
34
|
+
*/
|
|
35
|
+
export class Program<Us extends UniformBindings> {
|
|
32
36
|
program: WebGLProgram;
|
|
33
37
|
attributes: {[_: string]: number};
|
|
34
38
|
numAttributes: number;
|
|
@@ -212,5 +216,3 @@ class Program<Us extends UniformBindings> {
|
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
218
|
}
|
|
215
|
-
|
|
216
|
-
export default Program;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import RenderToTexture from './render_to_texture';
|
|
2
|
-
import type Painter from './painter';
|
|
3
|
-
import type LineStyleLayer from '../style/style_layer/line_style_layer';
|
|
4
|
-
import type SymbolStyleLayer from '../style/style_layer/symbol_style_layer';
|
|
5
|
-
import Context from '../gl/context';
|
|
1
|
+
import {RenderToTexture} from './render_to_texture';
|
|
2
|
+
import type {Painter} from './painter';
|
|
3
|
+
import type {LineStyleLayer} from '../style/style_layer/line_style_layer';
|
|
4
|
+
import type {SymbolStyleLayer} from '../style/style_layer/symbol_style_layer';
|
|
5
|
+
import {Context} from '../gl/context';
|
|
6
6
|
import gl from 'gl';
|
|
7
|
-
import ColorMode from '../gl/color_mode';
|
|
8
|
-
import Terrain from './terrain';
|
|
9
|
-
import Style from '../style/style';
|
|
10
|
-
import Tile from '../source/tile';
|
|
11
|
-
import Map from '../ui/map';
|
|
7
|
+
import {ColorMode} from '../gl/color_mode';
|
|
8
|
+
import {Terrain} from './terrain';
|
|
9
|
+
import {Style} from '../style/style';
|
|
10
|
+
import {Tile} from '../source/tile';
|
|
11
|
+
import {Map} from '../ui/map';
|
|
12
12
|
import {OverscaledTileID} from '../source/tile_id';
|
|
13
|
-
import SourceCache from '../source/source_cache';
|
|
13
|
+
import {SourceCache} from '../source/source_cache';
|
|
14
14
|
import {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
15
|
-
import FillStyleLayer from '../style/style_layer/fill_style_layer';
|
|
16
|
-
import RasterStyleLayer from '../style/style_layer/raster_style_layer';
|
|
17
|
-
import HillshadeStyleLayer from '../style/style_layer/hillshade_style_layer';
|
|
18
|
-
import BackgroundStyleLayer from '../style/style_layer/background_style_layer';
|
|
15
|
+
import {FillStyleLayer} from '../style/style_layer/fill_style_layer';
|
|
16
|
+
import {RasterStyleLayer} from '../style/style_layer/raster_style_layer';
|
|
17
|
+
import {HillshadeStyleLayer} from '../style/style_layer/hillshade_style_layer';
|
|
18
|
+
import {BackgroundStyleLayer} from '../style/style_layer/background_style_layer';
|
|
19
19
|
|
|
20
20
|
describe('render to texture', () => {
|
|
21
21
|
const backgroundLayer = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Painter from './painter';
|
|
2
|
-
import Tile from '../source/tile';
|
|
1
|
+
import {Painter} from './painter';
|
|
2
|
+
import {Tile} from '../source/tile';
|
|
3
3
|
import {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
4
4
|
import {OverscaledTileID} from '../source/tile_id';
|
|
5
5
|
import {drawTerrain} from './draw_terrain';
|
|
6
|
-
import Style from '../style/style';
|
|
7
|
-
import Terrain from './terrain';
|
|
8
|
-
import RenderPool from '../gl/render_pool';
|
|
9
|
-
import Texture from './texture';
|
|
10
|
-
import type StyleLayer from '../style/style_layer';
|
|
6
|
+
import {Style} from '../style/style';
|
|
7
|
+
import {Terrain} from './terrain';
|
|
8
|
+
import {RenderPool} from '../gl/render_pool';
|
|
9
|
+
import {Texture} from './texture';
|
|
10
|
+
import type {StyleLayer} from '../style/style_layer';
|
|
11
11
|
|
|
12
12
|
// lookup table which layers should rendered to texture
|
|
13
13
|
const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {
|
|
@@ -21,7 +21,7 @@ const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = {
|
|
|
21
21
|
/**
|
|
22
22
|
* RenderToTexture
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export class RenderToTexture {
|
|
25
25
|
painter: Painter;
|
|
26
26
|
terrain: Terrain;
|
|
27
27
|
pool: RenderPool;
|
|
@@ -108,8 +108,8 @@ export default class RenderToTexture {
|
|
|
108
108
|
* Because of the stylesheet possibility to mixing render-to-texture layers
|
|
109
109
|
* and 'live'-layers (f.e. symbols) it is necessary to create more stacks. For example
|
|
110
110
|
* a symbol-layer is in between of fill-layers.
|
|
111
|
-
* @param
|
|
112
|
-
* @returns
|
|
111
|
+
* @param layer - the layer to render
|
|
112
|
+
* @returns if true layer is rendered to texture, otherwise false
|
|
113
113
|
*/
|
|
114
114
|
renderLayer(layer: StyleLayer): boolean {
|
|
115
115
|
if (layer.isHidden(this.painter.transform.zoom)) return false;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import Point from '@mapbox/point-geometry';
|
|
2
|
-
import Terrain from './terrain';
|
|
2
|
+
import {Terrain} from './terrain';
|
|
3
3
|
import gl from 'gl';
|
|
4
|
-
import Context from '../gl/context';
|
|
4
|
+
import {Context} from '../gl/context';
|
|
5
5
|
import {RGBAImage} from '../util/image';
|
|
6
|
-
import Texture from './texture';
|
|
7
|
-
import type SourceCache from '../source/source_cache';
|
|
6
|
+
import {Texture} from './texture';
|
|
7
|
+
import type {SourceCache} from '../source/source_cache';
|
|
8
8
|
import {OverscaledTileID} from '../source/tile_id';
|
|
9
9
|
import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
10
|
-
import type DEMData from '../data/dem_data';
|
|
11
|
-
import Tile from '../source/tile';
|
|
12
|
-
import Painter from './painter';
|
|
10
|
+
import type {DEMData} from '../data/dem_data';
|
|
11
|
+
import {Tile} from '../source/tile';
|
|
12
|
+
import {Painter} from './painter';
|
|
13
|
+
import {mat4} from 'gl-matrix';
|
|
13
14
|
|
|
14
15
|
describe('Terrain', () => {
|
|
15
16
|
test('pointCoordiate should not return null', () => {
|
|
@@ -162,4 +163,34 @@ describe('Terrain', () => {
|
|
|
162
163
|
expect(actualIndexArray).toStrictEqual([0, 5, 6, 0, 6, 1, 1, 6, 7, 1, 7, 2, 2, 7, 8, 2, 8, 3, 3, 8, 9, 3, 9, 4, 5, 10, 11, 5, 11, 6, 6, 11, 12, 6, 12, 7, 7, 12, 13, 7, 13, 8, 8, 13, 14, 8, 14, 9, 10, 15, 16, 10, 16, 11, 11, 16, 17, 11, 17, 12, 12, 17, 18, 12, 18, 13, 13, 18, 19, 13, 19, 14, 15, 20, 21, 15, 21, 16, 16, 21, 22, 16, 22, 17, 17, 22, 23, 17, 23, 18, 18, 23, 24, 18, 24, 19, 35, 36, 38, 35, 38, 37, 25, 28, 26, 25, 27, 28, 37, 38, 40, 37, 40, 39, 27, 30, 28, 27, 29, 30, 39, 40, 42, 39, 42, 41, 29, 32, 30, 29, 31, 32, 41, 42, 44, 41, 44, 43, 31, 34, 32, 31, 33, 34, 45, 46, 48, 45, 48, 47, 55, 58, 56, 55, 57, 58, 47, 48, 50, 47, 50, 49, 57, 60, 58, 57, 59, 60, 49, 50, 52, 49, 52, 51, 59, 62, 60, 59, 61, 62, 51, 52, 54, 51, 54, 53, 61, 64, 62, 61, 63, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
163
164
|
expect(actualVertexArray).toStrictEqual([0, 0, 0, 2048, 0, 0, 4096, 0, 0, 6144, 0, 0, 8192, 0, 0, 0, 2048, 0, 2048, 2048, 0, 4096, 2048, 0, 6144, 2048, 0, 8192, 2048, 0, 0, 4096, 0, 2048, 4096, 0, 4096, 4096, 0, 6144, 4096, 0, 8192, 4096, 0, 0, 6144, 0, 2048, 6144, 0, 4096, 6144, 0, 6144, 6144, 0, 8192, 6144, 0, 0, 8192, 0, 2048, 8192, 0, 4096, 8192, 0, 6144, 8192, 0, 8192, 8192, 0, 0, 0, 0, 0, 0, 1, 2048, 0, 0, 2048, 0, 1, 4096, 0, 0, 4096, 0, 1, 6144, 0, 0, 6144, 0, 1, 8192, 0, 0, 8192, 0, 1, 0, 8192, 0, 0, 8192, 1, 2048, 8192, 0, 2048, 8192, 1, 4096, 8192, 0, 4096, 8192, 1, 6144, 8192, 0, 6144, 8192, 1, 8192, 8192, 0, 8192, 8192, 1, 0, 0, 0, 0, 0, 1, 0, 2048, 0, 0, 2048, 1, 0, 4096, 0, 0, 4096, 1, 0, 6144, 0, 0, 6144, 1, 0, 8192, 0, 0, 8192, 1, 8192, 0, 0, 8192, 0, 1, 8192, 2048, 0, 8192, 2048, 1, 8192, 4096, 0, 8192, 4096, 1, 8192, 6144, 0, 8192, 6144, 1, 8192, 8192, 0, 8192, 8192, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
164
165
|
});
|
|
166
|
+
|
|
167
|
+
test('interpolation works', () => {
|
|
168
|
+
const mockTerrain = {
|
|
169
|
+
getDEMElevation: Terrain.prototype.getDEMElevation,
|
|
170
|
+
getTerrainData() {
|
|
171
|
+
return {
|
|
172
|
+
// eslint-disable-next-line camelcase
|
|
173
|
+
u_terrain_matrix: mat4.create(),
|
|
174
|
+
tile: {
|
|
175
|
+
dem: {
|
|
176
|
+
dim: 1,
|
|
177
|
+
get(x:number, y:number) {
|
|
178
|
+
expect(x % 1).toBe(0);
|
|
179
|
+
expect(y % 1).toBe(0);
|
|
180
|
+
return 100 * x + 10 * y;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
expect(mockTerrain.getDEMElevation(null, 0, 0)).toBeCloseTo(0);
|
|
188
|
+
expect(mockTerrain.getDEMElevation(null, 1, 1)).toBeCloseTo(110);
|
|
189
|
+
expect(mockTerrain.getDEMElevation(null, 0, 0.5)).toBeCloseTo(5);
|
|
190
|
+
expect(mockTerrain.getDEMElevation(null, 1, 0.5)).toBeCloseTo(105);
|
|
191
|
+
expect(mockTerrain.getDEMElevation(null, 0.5, 0)).toBeCloseTo(50);
|
|
192
|
+
expect(mockTerrain.getDEMElevation(null, 0.5, 1)).toBeCloseTo(60);
|
|
193
|
+
expect(mockTerrain.getDEMElevation(null, 0.4, 0.2)).toBeCloseTo(42);
|
|
194
|
+
});
|
|
195
|
+
|
|
165
196
|
});
|