@scoova/mgl 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/LICENSE.txt +116 -0
- package/README.md +174 -0
- package/build/banner.ts +12 -0
- package/build/bump-version-changelog.js +26 -0
- package/build/check-bundle-size.js +77 -0
- package/build/generate-dist-package.js +26 -0
- package/build/generate-doc-images.ts +78 -0
- package/build/generate-docs.ts +190 -0
- package/build/generate-shaders.ts +68 -0
- package/build/generate-struct-arrays.ts +438 -0
- package/build/generate-style-code.ts +283 -0
- package/build/readme.md +56 -0
- package/build/release-notes.js +45 -0
- package/build/rollup/bundle_prelude.js +29 -0
- package/build/rollup/maplibregl.js +22 -0
- package/build/rollup_plugins.ts +58 -0
- package/dist/LICENSE.txt +116 -0
- package/dist/maplibre-gl.css +1 -0
- package/dist/maplibre-gl.d.ts +13304 -0
- package/dist/maplibre-gl.js +59 -0
- package/dist/maplibre-gl.js.map +1 -0
- package/dist/package.json +1 -0
- package/package.json +192 -0
- package/src/css/maplibre-gl.css +854 -0
- package/src/css/svg/maplibregl-ctrl-attrib.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-compass.svg +4 -0
- package/src/css/svg/maplibregl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-geolocate.svg +5 -0
- package/src/css/svg/maplibregl-ctrl-logo.svg +11 -0
- package/src/css/svg/maplibregl-ctrl-shrink.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-terrain.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.g.ts +1130 -0
- package/src/data/bucket/circle_attributes.ts +8 -0
- package/src/data/bucket/circle_bucket.ts +197 -0
- package/src/data/bucket/fill_attributes.ts +8 -0
- package/src/data/bucket/fill_bucket.test.ts +95 -0
- package/src/data/bucket/fill_bucket.ts +228 -0
- package/src/data/bucket/fill_extrusion_attributes.ts +13 -0
- package/src/data/bucket/fill_extrusion_bucket.ts +305 -0
- package/src/data/bucket/heatmap_bucket.ts +12 -0
- package/src/data/bucket/line_attributes.ts +8 -0
- package/src/data/bucket/line_attributes_ext.ts +8 -0
- package/src/data/bucket/line_bucket.test.ts +142 -0
- package/src/data/bucket/line_bucket.ts +592 -0
- package/src/data/bucket/pattern_attributes.ts +9 -0
- package/src/data/bucket/pattern_bucket_features.ts +57 -0
- package/src/data/bucket/symbol_attributes.ts +122 -0
- package/src/data/bucket/symbol_bucket.test.ts +243 -0
- package/src/data/bucket/symbol_bucket.ts +975 -0
- package/src/data/bucket.ts +123 -0
- package/src/data/dem_data.test.ts +237 -0
- package/src/data/dem_data.ts +171 -0
- package/src/data/evaluation_feature.ts +18 -0
- package/src/data/extent.ts +13 -0
- package/src/data/feature_index.ts +337 -0
- package/src/data/feature_position_map.test.ts +33 -0
- package/src/data/feature_position_map.ts +126 -0
- package/src/data/index_array_type.ts +9 -0
- package/src/data/load_geometry.test.ts +49 -0
- package/src/data/load_geometry.ts +44 -0
- package/src/data/pos3d_attributes.ts +5 -0
- package/src/data/pos_attributes.ts +5 -0
- package/src/data/program_configuration.ts +735 -0
- package/src/data/raster_bounds_attributes.ts +6 -0
- package/src/data/segment.ts +89 -0
- package/src/geo/edge_insets.test.ts +83 -0
- package/src/geo/edge_insets.ts +146 -0
- package/src/geo/lng_lat.test.ts +65 -0
- package/src/geo/lng_lat.ts +169 -0
- package/src/geo/lng_lat_bounds.test.ts +357 -0
- package/src/geo/lng_lat_bounds.ts +356 -0
- package/src/geo/mercator_coordinate.test.ts +34 -0
- package/src/geo/mercator_coordinate.ts +157 -0
- package/src/geo/projection/projection.ts +72 -0
- package/src/geo/transform.test.ts +509 -0
- package/src/geo/transform.ts +1072 -0
- package/src/gl/color_mode.ts +31 -0
- package/src/gl/context.ts +321 -0
- package/src/gl/cull_face_mode.ts +22 -0
- package/src/gl/depth_mode.ts +26 -0
- package/src/gl/framebuffer.ts +48 -0
- package/src/gl/index_buffer.ts +55 -0
- package/src/gl/render_pool.test.ts +69 -0
- package/src/gl/render_pool.ts +93 -0
- package/src/gl/state.test.ts +125 -0
- package/src/gl/stencil_mode.ts +27 -0
- package/src/gl/types.ts +59 -0
- package/src/gl/value.ts +534 -0
- package/src/gl/vertex_buffer.test.ts +57 -0
- package/src/gl/vertex_buffer.ts +111 -0
- package/src/gl/webgl2.ts +12 -0
- package/src/index.test.ts +121 -0
- package/src/index.ts +250 -0
- package/src/render/draw_background.ts +53 -0
- package/src/render/draw_circle.ts +113 -0
- package/src/render/draw_collision_debug.ts +168 -0
- package/src/render/draw_custom.test.ts +73 -0
- package/src/render/draw_custom.ts +45 -0
- package/src/render/draw_debug.test.ts +122 -0
- package/src/render/draw_debug.ts +148 -0
- package/src/render/draw_fill.test.ts +137 -0
- package/src/render/draw_fill.ts +128 -0
- package/src/render/draw_fill_extrusion.ts +97 -0
- package/src/render/draw_heatmap.ts +228 -0
- package/src/render/draw_hillshade.ts +119 -0
- package/src/render/draw_line.ts +125 -0
- package/src/render/draw_raster.ts +133 -0
- package/src/render/draw_sky.ts +44 -0
- package/src/render/draw_symbol.test.ts +223 -0
- package/src/render/draw_symbol.ts +499 -0
- package/src/render/draw_terrain.ts +99 -0
- package/src/render/glyph_atlas.ts +83 -0
- package/src/render/glyph_manager.test.ts +147 -0
- package/src/render/glyph_manager.ts +198 -0
- package/src/render/image_atlas.ts +159 -0
- package/src/render/image_manager.ts +337 -0
- package/src/render/line_atlas.test.ts +38 -0
- package/src/render/line_atlas.ts +214 -0
- package/src/render/mesh.ts +25 -0
- package/src/render/painter.test.ts +51 -0
- package/src/render/painter.ts +666 -0
- package/src/render/program/background_program.ts +100 -0
- package/src/render/program/circle_program.ts +61 -0
- package/src/render/program/clipping_mask_program.ts +19 -0
- package/src/render/program/collision_program.ts +47 -0
- package/src/render/program/debug_program.ts +29 -0
- package/src/render/program/fill_extrusion_program.ts +120 -0
- package/src/render/program/fill_program.ts +121 -0
- package/src/render/program/heatmap_program.ts +76 -0
- package/src/render/program/hillshade_program.ts +116 -0
- package/src/render/program/line_program.ts +207 -0
- package/src/render/program/pattern.ts +102 -0
- package/src/render/program/program_uniforms.ts +46 -0
- package/src/render/program/raster_program.ts +88 -0
- package/src/render/program/sky_program.ts +28 -0
- package/src/render/program/symbol_program.ts +266 -0
- package/src/render/program/terrain_program.ts +116 -0
- package/src/render/program.ts +233 -0
- package/src/render/render_to_texture.test.ts +151 -0
- package/src/render/render_to_texture.ts +197 -0
- package/src/render/terrain.test.ts +322 -0
- package/src/render/terrain.ts +464 -0
- package/src/render/texture.ts +114 -0
- package/src/render/uniform_binding.test.ts +122 -0
- package/src/render/uniform_binding.ts +157 -0
- package/src/render/update_pattern_positions_in_program.test.ts +74 -0
- package/src/render/update_pattern_positions_in_program.ts +50 -0
- package/src/render/vertex_array_object.ts +163 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +19 -0
- package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
- package/src/shaders/_prelude.vertex.glsl +148 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.fragment.glsl.g.ts +2 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background.vertex.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.vertex.glsl +19 -0
- package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/circle.fragment.glsl +34 -0
- package/src/shaders/circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/circle.vertex.glsl +68 -0
- package/src/shaders/circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_box.fragment.glsl +20 -0
- package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_box.vertex.glsl +27 -0
- package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.fragment.glsl +17 -0
- package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.vertex.glsl +59 -0
- package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/debug.fragment.glsl +9 -0
- package/src/shaders/debug.fragment.glsl.g.ts +2 -0
- package/src/shaders/debug.vertex.glsl +12 -0
- package/src/shaders/debug.vertex.glsl.g.ts +2 -0
- package/src/shaders/encode_attribute.test.ts +11 -0
- package/src/shaders/encode_attribute.ts +13 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.fragment.glsl +9 -0
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.vertex.glsl +84 -0
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +47 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +96 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.fragment.glsl +39 -0
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.vertex.glsl +39 -0
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap.fragment.glsl +22 -0
- package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap.vertex.glsl +54 -0
- package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.fragment.glsl +15 -0
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +77 -0
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
- package/src/shaders/line.fragment.glsl +30 -0
- package/src/shaders/line.fragment.glsl.g.ts +2 -0
- package/src/shaders/line.vertex.glsl +89 -0
- package/src/shaders/line.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.vertex.glsl +92 -0
- package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.fragment.glsl +77 -0
- package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.vertex.glsl +103 -0
- package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.fragment.glsl +45 -0
- package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.vertex.glsl +101 -0
- package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/raster.fragment.glsl +53 -0
- package/src/shaders/raster.fragment.glsl.g.ts +2 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/raster.vertex.glsl.g.ts +2 -0
- package/src/shaders/shaders.ts +197 -0
- package/src/shaders/sky.fragment.glsl +17 -0
- package/src/shaders/sky.fragment.glsl.g.ts +2 -0
- package/src/shaders/sky.vertex.glsl +5 -0
- package/src/shaders/sky.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.vertex.glsl +117 -0
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.fragment.glsl +58 -0
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.vertex.glsl +142 -0
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl +140 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain.fragment.glsl +32 -0
- package/src/shaders/terrain.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain.vertex.glsl +17 -0
- package/src/shaders/terrain.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain_coords.fragment.glsl +11 -0
- package/src/shaders/terrain_coords.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain_coords.vertex.glsl +13 -0
- package/src/shaders/terrain_coords.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain_depth.fragment.glsl +15 -0
- package/src/shaders/terrain_depth.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain_depth.vertex.glsl +13 -0
- package/src/shaders/terrain_depth.vertex.glsl.g.ts +2 -0
- package/src/source/canvas_source.test.ts +210 -0
- package/src/source/canvas_source.ts +227 -0
- package/src/source/geojson_source.test.ts +492 -0
- package/src/source/geojson_source.ts +431 -0
- package/src/source/geojson_source_diff.test.ts +364 -0
- package/src/source/geojson_source_diff.ts +172 -0
- package/src/source/geojson_worker_source.test.ts +399 -0
- package/src/source/geojson_worker_source.ts +303 -0
- package/src/source/geojson_wrapper.test.ts +32 -0
- package/src/source/geojson_wrapper.ts +81 -0
- package/src/source/image_source.test.ts +235 -0
- package/src/source/image_source.ts +338 -0
- package/src/source/load_tilejson.ts +47 -0
- package/src/source/pixels_to_tile_units.ts +25 -0
- package/src/source/protocol_crud.ts +48 -0
- package/src/source/query_features.test.ts +31 -0
- package/src/source/query_features.ts +252 -0
- package/src/source/raster_dem_tile_source.test.ts +158 -0
- package/src/source/raster_dem_tile_source.ts +166 -0
- package/src/source/raster_dem_tile_worker_source.test.ts +36 -0
- package/src/source/raster_dem_tile_worker_source.ts +38 -0
- package/src/source/raster_tile_source.test.ts +206 -0
- package/src/source/raster_tile_source.ts +227 -0
- package/src/source/rtl_text_plugin_main_thread.test.ts +170 -0
- package/src/source/rtl_text_plugin_main_thread.ts +89 -0
- package/src/source/rtl_text_plugin_status.ts +33 -0
- package/src/source/rtl_text_plugin_worker.ts +49 -0
- package/src/source/source.test.ts +41 -0
- package/src/source/source.ts +186 -0
- package/src/source/source_cache.test.ts +2069 -0
- package/src/source/source_cache.ts +1102 -0
- package/src/source/source_state.ts +157 -0
- package/src/source/terrain_source_cache.test.ts +105 -0
- package/src/source/terrain_source_cache.ts +204 -0
- package/src/source/tile.test.ts +290 -0
- package/src/source/tile.ts +478 -0
- package/src/source/tile_bounds.ts +34 -0
- package/src/source/tile_cache.test.ts +130 -0
- package/src/source/tile_cache.ts +208 -0
- package/src/source/tile_id.test.ts +112 -0
- package/src/source/tile_id.ts +221 -0
- package/src/source/vector_tile_source.test.ts +401 -0
- package/src/source/vector_tile_source.ts +283 -0
- package/src/source/vector_tile_worker_source.test.ts +396 -0
- package/src/source/vector_tile_worker_source.ts +199 -0
- package/src/source/video_source.test.ts +124 -0
- package/src/source/video_source.ts +204 -0
- package/src/source/worker.test.ts +233 -0
- package/src/source/worker.ts +301 -0
- package/src/source/worker_source.ts +117 -0
- package/src/source/worker_tile.test.ts +226 -0
- package/src/source/worker_tile.ts +208 -0
- package/src/style/create_style_layer.ts +39 -0
- package/src/style/evaluation_parameters.ts +62 -0
- package/src/style/format_section_override.test.ts +62 -0
- package/src/style/format_section_override.ts +50 -0
- package/src/style/light.test.ts +86 -0
- package/src/style/light.ts +135 -0
- package/src/style/load_glyph_range.test.ts +40 -0
- package/src/style/load_glyph_range.ts +32 -0
- package/src/style/load_sprite.test.ts +227 -0
- package/src/style/load_sprite.ts +71 -0
- package/src/style/parse_glyph_pbf.ts +42 -0
- package/src/style/pauseable_placement.ts +138 -0
- package/src/style/properties.ts +726 -0
- package/src/style/query_utils.test.ts +107 -0
- package/src/style/query_utils.ts +70 -0
- package/src/style/sky.ts +127 -0
- package/src/style/style.test.ts +2654 -0
- package/src/style/style.ts +1814 -0
- package/src/style/style_glyph.ts +25 -0
- package/src/style/style_image.ts +188 -0
- package/src/style/style_layer/background_style_layer.ts +17 -0
- package/src/style/style_layer/background_style_layer_properties.g.ts +40 -0
- package/src/style/style_layer/circle_style_layer.ts +98 -0
- package/src/style/style_layer/circle_style_layer_properties.g.ts +76 -0
- package/src/style/style_layer/custom_style_layer.ts +233 -0
- package/src/style/style_layer/fill_extrusion_style_layer.ts +224 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +55 -0
- package/src/style/style_layer/fill_style_layer.test.ts +37 -0
- package/src/style/style_layer/fill_style_layer.ts +65 -0
- package/src/style/style_layer/fill_style_layer_properties.g.ts +64 -0
- package/src/style/style_layer/heatmap_style_layer.ts +74 -0
- package/src/style/style_layer/heatmap_style_layer_properties.g.ts +46 -0
- package/src/style/style_layer/hillshade_style_layer.ts +21 -0
- package/src/style/style_layer/hillshade_style_layer_properties.g.ts +49 -0
- package/src/style/style_layer/line_style_layer.test.ts +50 -0
- package/src/style/style_layer/line_style_layer.ts +131 -0
- package/src/style/style_layer/line_style_layer_properties.g.ts +88 -0
- package/src/style/style_layer/overlap_mode.test.ts +57 -0
- package/src/style/style_layer/overlap_mode.ts +25 -0
- package/src/style/style_layer/raster_style_layer.ts +17 -0
- package/src/style/style_layer/raster_style_layer_properties.g.ts +55 -0
- package/src/style/style_layer/symbol_style_layer.ts +195 -0
- package/src/style/style_layer/symbol_style_layer_properties.g.ts +218 -0
- package/src/style/style_layer/typed_style_layer.ts +9 -0
- package/src/style/style_layer/variable_text_anchor.test.ts +117 -0
- package/src/style/style_layer/variable_text_anchor.ts +163 -0
- package/src/style/style_layer.test.ts +372 -0
- package/src/style/style_layer.ts +287 -0
- package/src/style/style_layer_index.test.ts +99 -0
- package/src/style/style_layer_index.ts +78 -0
- package/src/style/validate_style.ts +53 -0
- package/src/style/zoom_history.ts +40 -0
- package/src/symbol/anchor.test.ts +14 -0
- package/src/symbol/anchor.ts +22 -0
- package/src/symbol/check_max_angle.test.ts +54 -0
- package/src/symbol/check_max_angle.ts +76 -0
- package/src/symbol/clip_line.test.ts +154 -0
- package/src/symbol/clip_line.ts +66 -0
- package/src/symbol/collision_feature.test.ts +98 -0
- package/src/symbol/collision_feature.ts +114 -0
- package/src/symbol/collision_index.test.ts +19 -0
- package/src/symbol/collision_index.ts +618 -0
- package/src/symbol/cross_tile_symbol_index.test.ts +260 -0
- package/src/symbol/cross_tile_symbol_index.ts +367 -0
- package/src/symbol/get_anchors.test.ts +113 -0
- package/src/symbol/get_anchors.ts +167 -0
- package/src/symbol/grid_index.test.ts +75 -0
- package/src/symbol/grid_index.ts +414 -0
- package/src/symbol/merge_lines.test.ts +30 -0
- package/src/symbol/merge_lines.ts +80 -0
- package/src/symbol/one_em.ts +3 -0
- package/src/symbol/opacity_state.ts +23 -0
- package/src/symbol/path_interpolator.test.ts +134 -0
- package/src/symbol/path_interpolator.ts +55 -0
- package/src/symbol/placement.ts +1371 -0
- package/src/symbol/projection.test.ts +171 -0
- package/src/symbol/projection.ts +833 -0
- package/src/symbol/quads.test.ts +157 -0
- package/src/symbol/quads.ts +349 -0
- package/src/symbol/shaping.test.ts +360 -0
- package/src/symbol/shaping.ts +911 -0
- package/src/symbol/symbol_layout.ts +739 -0
- package/src/symbol/symbol_size.ts +129 -0
- package/src/symbol/symbol_style_layer.test.ts +103 -0
- package/src/symbol/transform_text.ts +27 -0
- package/src/ui/anchor.ts +27 -0
- package/src/ui/camera.test.ts +2301 -0
- package/src/ui/camera.ts +1520 -0
- package/src/ui/control/attribution_control.test.ts +543 -0
- package/src/ui/control/attribution_control.ts +209 -0
- package/src/ui/control/control.ts +67 -0
- package/src/ui/control/fullscreen_control.test.ts +114 -0
- package/src/ui/control/fullscreen_control.ts +189 -0
- package/src/ui/control/geolocate_control.test.ts +619 -0
- package/src/ui/control/geolocate_control.ts +725 -0
- package/src/ui/control/logo_control.test.ts +88 -0
- package/src/ui/control/logo_control.ts +86 -0
- package/src/ui/control/navigation_control.test.ts +238 -0
- package/src/ui/control/navigation_control.ts +294 -0
- package/src/ui/control/scale_control.test.ts +52 -0
- package/src/ui/control/scale_control.ts +152 -0
- package/src/ui/control/terrain_control.test.ts +58 -0
- package/src/ui/control/terrain_control.ts +74 -0
- package/src/ui/default_locale.ts +25 -0
- package/src/ui/events.ts +758 -0
- package/src/ui/handler/box_zoom.test.ts +163 -0
- package/src/ui/handler/box_zoom.ts +171 -0
- package/src/ui/handler/click_zoom.ts +55 -0
- package/src/ui/handler/cooperative_gestures.test.ts +338 -0
- package/src/ui/handler/cooperative_gestures.ts +111 -0
- package/src/ui/handler/dblclick_zoom.test.ts +151 -0
- package/src/ui/handler/drag_handler.ts +174 -0
- package/src/ui/handler/drag_move_state_manager.ts +115 -0
- package/src/ui/handler/drag_pan.test.ts +487 -0
- package/src/ui/handler/drag_rotate.test.ts +859 -0
- package/src/ui/handler/handler_util.ts +10 -0
- package/src/ui/handler/keyboard.test.ts +235 -0
- package/src/ui/handler/keyboard.ts +212 -0
- package/src/ui/handler/map_event.test.ts +158 -0
- package/src/ui/handler/map_event.ts +161 -0
- package/src/ui/handler/mouse.ts +92 -0
- package/src/ui/handler/mouse_handler_interface.test.ts +111 -0
- package/src/ui/handler/mouse_rotate.test.ts +62 -0
- package/src/ui/handler/one_finger_touch_drag.ts +45 -0
- package/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts +77 -0
- package/src/ui/handler/scroll_zoom.test.ts +382 -0
- package/src/ui/handler/scroll_zoom.ts +379 -0
- package/src/ui/handler/shim/dblclick_zoom.ts +64 -0
- package/src/ui/handler/shim/drag_pan.ts +104 -0
- package/src/ui/handler/shim/drag_rotate.ts +76 -0
- package/src/ui/handler/shim/two_fingers_touch.ts +112 -0
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +112 -0
- package/src/ui/handler/tap_recognizer.ts +138 -0
- package/src/ui/handler/tap_zoom.ts +98 -0
- package/src/ui/handler/touch_pan.ts +115 -0
- package/src/ui/handler/transform-provider.ts +44 -0
- package/src/ui/handler/two_fingers_touch.test.ts +283 -0
- package/src/ui/handler/two_fingers_touch.ts +336 -0
- package/src/ui/handler_inertia.ts +157 -0
- package/src/ui/handler_manager.ts +637 -0
- package/src/ui/hash.test.ts +404 -0
- package/src/ui/hash.ts +153 -0
- package/src/ui/map.ts +3393 -0
- package/src/ui/map_tests/map_animation.test.ts +61 -0
- package/src/ui/map_tests/map_basic.test.ts +223 -0
- package/src/ui/map_tests/map_bounds.test.ts +123 -0
- package/src/ui/map_tests/map_calculate_camera_options.test.ts +113 -0
- package/src/ui/map_tests/map_canvas.test.ts +59 -0
- package/src/ui/map_tests/map_control.test.ts +61 -0
- package/src/ui/map_tests/map_disable_handlers.test.ts +38 -0
- package/src/ui/map_tests/map_events.test.ts +1001 -0
- package/src/ui/map_tests/map_feature_state.test.ts +421 -0
- package/src/ui/map_tests/map_images.test.ts +175 -0
- package/src/ui/map_tests/map_is_moving.test.ts +164 -0
- package/src/ui/map_tests/map_is_rotating.test.ts +62 -0
- package/src/ui/map_tests/map_is_zooming.test.ts +86 -0
- package/src/ui/map_tests/map_layer.test.ts +457 -0
- package/src/ui/map_tests/map_options.test.ts +64 -0
- package/src/ui/map_tests/map_pitch.test.ts +90 -0
- package/src/ui/map_tests/map_pixel_ratio.test.ts +75 -0
- package/src/ui/map_tests/map_query_rendered_features.test.ts +93 -0
- package/src/ui/map_tests/map_render.test.ts +90 -0
- package/src/ui/map_tests/map_request_render_frame.test.ts +51 -0
- package/src/ui/map_tests/map_resize.test.ts +120 -0
- package/src/ui/map_tests/map_style.test.ts +541 -0
- package/src/ui/map_tests/map_terrian.test.ts +104 -0
- package/src/ui/map_tests/map_webgl.test.ts +72 -0
- package/src/ui/map_tests/map_world_copies.test.ts +103 -0
- package/src/ui/map_tests/map_zoom.test.ts +95 -0
- package/src/ui/marker.test.ts +1149 -0
- package/src/ui/marker.ts +880 -0
- package/src/ui/popup.test.ts +827 -0
- package/src/ui/popup.ts +717 -0
- package/src/util/abort_error.ts +21 -0
- package/src/util/actor.test.ts +218 -0
- package/src/util/actor.ts +241 -0
- package/src/util/actor_messages.ts +149 -0
- package/src/util/ajax.test.ts +237 -0
- package/src/util/ajax.ts +297 -0
- package/src/util/browser.test.ts +23 -0
- package/src/util/browser.ts +63 -0
- package/src/util/color_ramp.test.ts +105 -0
- package/src/util/color_ramp.ts +56 -0
- package/src/util/config.ts +29 -0
- package/src/util/dictionary_coder.ts +23 -0
- package/src/util/dispatcher.test.ts +76 -0
- package/src/util/dispatcher.ts +78 -0
- package/src/util/dom.ts +135 -0
- package/src/util/evented.test.ts +231 -0
- package/src/util/evented.ts +178 -0
- package/src/util/find_pole_of_inaccessibility.test.ts +21 -0
- package/src/util/find_pole_of_inaccessibility.ts +130 -0
- package/src/util/geolocation_support.test.ts +43 -0
- package/src/util/geolocation_support.ts +23 -0
- package/src/util/global_worker_pool.ts +65 -0
- package/src/util/image.ts +150 -0
- package/src/util/image_request.test.ts +408 -0
- package/src/util/image_request.ts +246 -0
- package/src/util/intersection_tests.ts +206 -0
- package/src/util/is_char_in_unicode_block.test.ts +15 -0
- package/src/util/is_char_in_unicode_block.ts +345 -0
- package/src/util/offscreen_canvas_distorted.test.ts +13 -0
- package/src/util/offscreen_canvas_distorted.ts +39 -0
- package/src/util/offscreen_canvas_supported.ts +11 -0
- package/src/util/performance.ts +117 -0
- package/src/util/primitives.test.ts +140 -0
- package/src/util/primitives.ts +143 -0
- package/src/util/request_manager.ts +42 -0
- package/src/util/resolve_tokens.test.ts +45 -0
- package/src/util/resolve_tokens.ts +17 -0
- package/src/util/script_detection.test.ts +138 -0
- package/src/util/script_detection.ts +376 -0
- package/src/util/smart_wrap.test.ts +97 -0
- package/src/util/smart_wrap.ts +58 -0
- package/src/util/struct_array.test.ts +101 -0
- package/src/util/struct_array.ts +246 -0
- package/src/util/style.test.ts +34 -0
- package/src/util/style.ts +28 -0
- package/src/util/task_queue.test.ts +114 -0
- package/src/util/task_queue.ts +64 -0
- package/src/util/test/util.ts +185 -0
- package/src/util/throttle.test.ts +42 -0
- package/src/util/throttle.ts +28 -0
- package/src/util/throttled_invoker.ts +41 -0
- package/src/util/transferable_grid_index.test.ts +56 -0
- package/src/util/transferable_grid_index.ts +214 -0
- package/src/util/util.test.ts +414 -0
- package/src/util/util.ts +724 -0
- package/src/util/vectortile_to_geojson.ts +72 -0
- package/src/util/verticalize_punctuation.ts +110 -0
- package/src/util/web_worker.ts +16 -0
- package/src/util/web_worker_transfer.test.ts +153 -0
- package/src/util/web_worker_transfer.ts +254 -0
- package/src/util/webp_supported.ts +63 -0
- package/src/util/worker_pool.test.ts +43 -0
- package/src/util/worker_pool.ts +58 -0
- package/src/util/world_bounds.test.ts +59 -0
- package/src/util/world_bounds.ts +46 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {mat4} from 'gl-matrix';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Uniform1i,
|
|
5
|
+
Uniform1f,
|
|
6
|
+
Uniform2f,
|
|
7
|
+
UniformColor,
|
|
8
|
+
UniformMatrix4f,
|
|
9
|
+
Uniform4f
|
|
10
|
+
} from '../uniform_binding';
|
|
11
|
+
import {EXTENT} from '../../data/extent';
|
|
12
|
+
import {MercatorCoordinate} from '../../geo/mercator_coordinate';
|
|
13
|
+
|
|
14
|
+
import type {Context} from '../../gl/context';
|
|
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';
|
|
20
|
+
import type {OverscaledTileID} from '../../source/tile_id';
|
|
21
|
+
|
|
22
|
+
export type HillshadeUniformsType = {
|
|
23
|
+
'u_matrix': UniformMatrix4f;
|
|
24
|
+
'u_image': Uniform1i;
|
|
25
|
+
'u_latrange': Uniform2f;
|
|
26
|
+
'u_light': Uniform2f;
|
|
27
|
+
'u_shadow': UniformColor;
|
|
28
|
+
'u_highlight': UniformColor;
|
|
29
|
+
'u_accent': UniformColor;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type HillshadePrepareUniformsType = {
|
|
33
|
+
'u_matrix': UniformMatrix4f;
|
|
34
|
+
'u_image': Uniform1i;
|
|
35
|
+
'u_dimension': Uniform2f;
|
|
36
|
+
'u_zoom': Uniform1f;
|
|
37
|
+
'u_unpack': Uniform4f;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const hillshadeUniforms = (context: Context, locations: UniformLocations): HillshadeUniformsType => ({
|
|
41
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
42
|
+
'u_image': new Uniform1i(context, locations.u_image),
|
|
43
|
+
'u_latrange': new Uniform2f(context, locations.u_latrange),
|
|
44
|
+
'u_light': new Uniform2f(context, locations.u_light),
|
|
45
|
+
'u_shadow': new UniformColor(context, locations.u_shadow),
|
|
46
|
+
'u_highlight': new UniformColor(context, locations.u_highlight),
|
|
47
|
+
'u_accent': new UniformColor(context, locations.u_accent)
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const hillshadePrepareUniforms = (context: Context, locations: UniformLocations): HillshadePrepareUniformsType => ({
|
|
51
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
52
|
+
'u_image': new Uniform1i(context, locations.u_image),
|
|
53
|
+
'u_dimension': new Uniform2f(context, locations.u_dimension),
|
|
54
|
+
'u_zoom': new Uniform1f(context, locations.u_zoom),
|
|
55
|
+
'u_unpack': new Uniform4f(context, locations.u_unpack)
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const hillshadeUniformValues = (
|
|
59
|
+
painter: Painter,
|
|
60
|
+
tile: Tile,
|
|
61
|
+
layer: HillshadeStyleLayer,
|
|
62
|
+
coord: OverscaledTileID
|
|
63
|
+
): UniformValues<HillshadeUniformsType> => {
|
|
64
|
+
const shadow = layer.paint.get('hillshade-shadow-color');
|
|
65
|
+
const highlight = layer.paint.get('hillshade-highlight-color');
|
|
66
|
+
const accent = layer.paint.get('hillshade-accent-color');
|
|
67
|
+
|
|
68
|
+
let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180);
|
|
69
|
+
// modify azimuthal angle by map rotation if light is anchored at the viewport
|
|
70
|
+
if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {
|
|
71
|
+
azimuthal -= painter.transform.angle;
|
|
72
|
+
}
|
|
73
|
+
const align = !painter.options.moving;
|
|
74
|
+
return {
|
|
75
|
+
'u_matrix': coord ? coord.posMatrix : painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),
|
|
76
|
+
'u_image': 0,
|
|
77
|
+
'u_latrange': getTileLatRange(painter, tile.tileID),
|
|
78
|
+
'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal],
|
|
79
|
+
'u_shadow': shadow,
|
|
80
|
+
'u_highlight': highlight,
|
|
81
|
+
'u_accent': accent
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const hillshadeUniformPrepareValues = (tileID: OverscaledTileID, dem: DEMData): UniformValues<HillshadePrepareUniformsType> => {
|
|
86
|
+
|
|
87
|
+
const stride = dem.stride;
|
|
88
|
+
const matrix = mat4.create();
|
|
89
|
+
// Flip rendering at y axis.
|
|
90
|
+
mat4.ortho(matrix, 0, EXTENT, -EXTENT, 0, 0, 1);
|
|
91
|
+
mat4.translate(matrix, matrix, [0, -EXTENT, 0]);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
'u_matrix': matrix,
|
|
95
|
+
'u_image': 1,
|
|
96
|
+
'u_dimension': [stride, stride],
|
|
97
|
+
'u_zoom': tileID.overscaledZ,
|
|
98
|
+
'u_unpack': dem.getUnpackVector()
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function getTileLatRange(painter: Painter, tileID: OverscaledTileID) {
|
|
103
|
+
// for scaling the magnitude of a points slope by its latitude
|
|
104
|
+
const tilesAtZoom = Math.pow(2, tileID.canonical.z);
|
|
105
|
+
const y = tileID.canonical.y;
|
|
106
|
+
return [
|
|
107
|
+
new MercatorCoordinate(0, y / tilesAtZoom).toLngLat().lat,
|
|
108
|
+
new MercatorCoordinate(0, (y + 1) / tilesAtZoom).toLngLat().lat];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
hillshadeUniforms,
|
|
113
|
+
hillshadePrepareUniforms,
|
|
114
|
+
hillshadeUniformValues,
|
|
115
|
+
hillshadeUniformPrepareValues
|
|
116
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';
|
|
2
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
3
|
+
import {extend} from '../../util/util';
|
|
4
|
+
|
|
5
|
+
import type {Context} from '../../gl/context';
|
|
6
|
+
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
7
|
+
import type {Transform} from '../../geo/transform';
|
|
8
|
+
import type {Tile} from '../../source/tile';
|
|
9
|
+
import type {CrossFaded} from '../../style/properties';
|
|
10
|
+
import type {LineStyleLayer} from '../../style/style_layer/line_style_layer';
|
|
11
|
+
import type {Painter} from '../painter';
|
|
12
|
+
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
13
|
+
import {OverscaledTileID} from '../../source/tile_id';
|
|
14
|
+
|
|
15
|
+
export type LineUniformsType = {
|
|
16
|
+
'u_matrix': UniformMatrix4f;
|
|
17
|
+
'u_ratio': Uniform1f;
|
|
18
|
+
'u_device_pixel_ratio': Uniform1f;
|
|
19
|
+
'u_units_to_pixels': Uniform2f;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type LineGradientUniformsType = {
|
|
23
|
+
'u_matrix': UniformMatrix4f;
|
|
24
|
+
'u_ratio': Uniform1f;
|
|
25
|
+
'u_device_pixel_ratio': Uniform1f;
|
|
26
|
+
'u_units_to_pixels': Uniform2f;
|
|
27
|
+
'u_image': Uniform1i;
|
|
28
|
+
'u_image_height': Uniform1f;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type LinePatternUniformsType = {
|
|
32
|
+
'u_matrix': UniformMatrix4f;
|
|
33
|
+
'u_texsize': Uniform2f;
|
|
34
|
+
'u_ratio': Uniform1f;
|
|
35
|
+
'u_device_pixel_ratio': Uniform1f;
|
|
36
|
+
'u_units_to_pixels': Uniform2f;
|
|
37
|
+
'u_image': Uniform1i;
|
|
38
|
+
'u_scale': Uniform3f;
|
|
39
|
+
'u_fade': Uniform1f;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type LineSDFUniformsType = {
|
|
43
|
+
'u_matrix': UniformMatrix4f;
|
|
44
|
+
'u_ratio': Uniform1f;
|
|
45
|
+
'u_device_pixel_ratio': Uniform1f;
|
|
46
|
+
'u_units_to_pixels': Uniform2f;
|
|
47
|
+
'u_patternscale_a': Uniform2f;
|
|
48
|
+
'u_patternscale_b': Uniform2f;
|
|
49
|
+
'u_sdfgamma': Uniform1f;
|
|
50
|
+
'u_image': Uniform1i;
|
|
51
|
+
'u_tex_y_a': Uniform1f;
|
|
52
|
+
'u_tex_y_b': Uniform1f;
|
|
53
|
+
'u_mix': Uniform1f;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const lineUniforms = (context: Context, locations: UniformLocations): LineUniformsType => ({
|
|
57
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
58
|
+
'u_ratio': new Uniform1f(context, locations.u_ratio),
|
|
59
|
+
'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),
|
|
60
|
+
'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels)
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const lineGradientUniforms = (context: Context, locations: UniformLocations): LineGradientUniformsType => ({
|
|
64
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
65
|
+
'u_ratio': new Uniform1f(context, locations.u_ratio),
|
|
66
|
+
'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),
|
|
67
|
+
'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),
|
|
68
|
+
'u_image': new Uniform1i(context, locations.u_image),
|
|
69
|
+
'u_image_height': new Uniform1f(context, locations.u_image_height)
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const linePatternUniforms = (context: Context, locations: UniformLocations): LinePatternUniformsType => ({
|
|
73
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
74
|
+
'u_texsize': new Uniform2f(context, locations.u_texsize),
|
|
75
|
+
'u_ratio': new Uniform1f(context, locations.u_ratio),
|
|
76
|
+
'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),
|
|
77
|
+
'u_image': new Uniform1i(context, locations.u_image),
|
|
78
|
+
'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),
|
|
79
|
+
'u_scale': new Uniform3f(context, locations.u_scale),
|
|
80
|
+
'u_fade': new Uniform1f(context, locations.u_fade)
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const lineSDFUniforms = (context: Context, locations: UniformLocations): LineSDFUniformsType => ({
|
|
84
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
85
|
+
'u_ratio': new Uniform1f(context, locations.u_ratio),
|
|
86
|
+
'u_device_pixel_ratio': new Uniform1f(context, locations.u_device_pixel_ratio),
|
|
87
|
+
'u_units_to_pixels': new Uniform2f(context, locations.u_units_to_pixels),
|
|
88
|
+
'u_patternscale_a': new Uniform2f(context, locations.u_patternscale_a),
|
|
89
|
+
'u_patternscale_b': new Uniform2f(context, locations.u_patternscale_b),
|
|
90
|
+
'u_sdfgamma': new Uniform1f(context, locations.u_sdfgamma),
|
|
91
|
+
'u_image': new Uniform1i(context, locations.u_image),
|
|
92
|
+
'u_tex_y_a': new Uniform1f(context, locations.u_tex_y_a),
|
|
93
|
+
'u_tex_y_b': new Uniform1f(context, locations.u_tex_y_b),
|
|
94
|
+
'u_mix': new Uniform1f(context, locations.u_mix)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const lineUniformValues = (
|
|
98
|
+
painter: Painter,
|
|
99
|
+
tile: Tile,
|
|
100
|
+
layer: LineStyleLayer,
|
|
101
|
+
coord: OverscaledTileID
|
|
102
|
+
): UniformValues<LineUniformsType> => {
|
|
103
|
+
const transform = painter.transform;
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
'u_matrix': calculateMatrix(painter, tile, layer, coord),
|
|
107
|
+
'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),
|
|
108
|
+
'u_device_pixel_ratio': painter.pixelRatio,
|
|
109
|
+
'u_units_to_pixels': [
|
|
110
|
+
1 / transform.pixelsToGLUnits[0],
|
|
111
|
+
1 / transform.pixelsToGLUnits[1]
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const lineGradientUniformValues = (
|
|
117
|
+
painter: Painter,
|
|
118
|
+
tile: Tile,
|
|
119
|
+
layer: LineStyleLayer,
|
|
120
|
+
imageHeight: number,
|
|
121
|
+
coord: OverscaledTileID
|
|
122
|
+
): UniformValues<LineGradientUniformsType> => {
|
|
123
|
+
return extend(lineUniformValues(painter, tile, layer, coord), {
|
|
124
|
+
'u_image': 0,
|
|
125
|
+
'u_image_height': imageHeight,
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const linePatternUniformValues = (
|
|
130
|
+
painter: Painter,
|
|
131
|
+
tile: Tile,
|
|
132
|
+
layer: LineStyleLayer,
|
|
133
|
+
crossfade: CrossfadeParameters,
|
|
134
|
+
coord: OverscaledTileID
|
|
135
|
+
): UniformValues<LinePatternUniformsType> => {
|
|
136
|
+
const transform = painter.transform;
|
|
137
|
+
const tileZoomRatio = calculateTileRatio(tile, transform);
|
|
138
|
+
return {
|
|
139
|
+
'u_matrix': calculateMatrix(painter, tile, layer, coord),
|
|
140
|
+
'u_texsize': tile.imageAtlasTexture.size,
|
|
141
|
+
// camera zoom ratio
|
|
142
|
+
'u_ratio': 1 / pixelsToTileUnits(tile, 1, transform.zoom),
|
|
143
|
+
'u_device_pixel_ratio': painter.pixelRatio,
|
|
144
|
+
'u_image': 0,
|
|
145
|
+
'u_scale': [tileZoomRatio, crossfade.fromScale, crossfade.toScale],
|
|
146
|
+
'u_fade': crossfade.t,
|
|
147
|
+
'u_units_to_pixels': [
|
|
148
|
+
1 / transform.pixelsToGLUnits[0],
|
|
149
|
+
1 / transform.pixelsToGLUnits[1]
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const lineSDFUniformValues = (
|
|
155
|
+
painter: Painter,
|
|
156
|
+
tile: Tile,
|
|
157
|
+
layer: LineStyleLayer,
|
|
158
|
+
dasharray: CrossFaded<Array<number>>,
|
|
159
|
+
crossfade: CrossfadeParameters,
|
|
160
|
+
coord: OverscaledTileID
|
|
161
|
+
): UniformValues<LineSDFUniformsType> => {
|
|
162
|
+
const transform = painter.transform;
|
|
163
|
+
const lineAtlas = painter.lineAtlas;
|
|
164
|
+
const tileRatio = calculateTileRatio(tile, transform);
|
|
165
|
+
|
|
166
|
+
const round = layer.layout.get('line-cap') === 'round';
|
|
167
|
+
|
|
168
|
+
const posA = lineAtlas.getDash(dasharray.from, round);
|
|
169
|
+
const posB = lineAtlas.getDash(dasharray.to, round);
|
|
170
|
+
|
|
171
|
+
const widthA = posA.width * crossfade.fromScale;
|
|
172
|
+
const widthB = posB.width * crossfade.toScale;
|
|
173
|
+
|
|
174
|
+
return extend(lineUniformValues(painter, tile, layer, coord), {
|
|
175
|
+
'u_patternscale_a': [tileRatio / widthA, -posA.height / 2],
|
|
176
|
+
'u_patternscale_b': [tileRatio / widthB, -posB.height / 2],
|
|
177
|
+
'u_sdfgamma': lineAtlas.width / (Math.min(widthA, widthB) * 256 * painter.pixelRatio) / 2,
|
|
178
|
+
'u_image': 0,
|
|
179
|
+
'u_tex_y_a': posA.y,
|
|
180
|
+
'u_tex_y_b': posB.y,
|
|
181
|
+
'u_mix': crossfade.t
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
function calculateTileRatio(tile: Tile, transform: Transform) {
|
|
186
|
+
return 1 / pixelsToTileUnits(tile, 1, transform.tileZoom);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function calculateMatrix(painter: Painter, tile: Tile, layer: LineStyleLayer, coord: OverscaledTileID) {
|
|
190
|
+
return painter.translatePosMatrix(
|
|
191
|
+
coord ? coord.posMatrix : tile.tileID.posMatrix,
|
|
192
|
+
tile,
|
|
193
|
+
layer.paint.get('line-translate'),
|
|
194
|
+
layer.paint.get('line-translate-anchor')
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export {
|
|
199
|
+
lineUniforms,
|
|
200
|
+
lineGradientUniforms,
|
|
201
|
+
linePatternUniforms,
|
|
202
|
+
lineSDFUniforms,
|
|
203
|
+
lineUniformValues,
|
|
204
|
+
lineGradientUniformValues,
|
|
205
|
+
linePatternUniformValues,
|
|
206
|
+
lineSDFUniformValues
|
|
207
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Uniform1i,
|
|
3
|
+
Uniform1f,
|
|
4
|
+
Uniform2f,
|
|
5
|
+
Uniform3f
|
|
6
|
+
} from '../uniform_binding';
|
|
7
|
+
import {pixelsToTileUnits} from '../../source/pixels_to_tile_units';
|
|
8
|
+
|
|
9
|
+
import type {Painter} from '../painter';
|
|
10
|
+
import type {OverscaledTileID} from '../../source/tile_id';
|
|
11
|
+
import type {CrossFaded} from '../../style/properties';
|
|
12
|
+
import type {CrossfadeParameters} from '../../style/evaluation_parameters';
|
|
13
|
+
import type {UniformValues} from '../uniform_binding';
|
|
14
|
+
import type {Tile} from '../../source/tile';
|
|
15
|
+
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
16
|
+
|
|
17
|
+
type BackgroundPatternUniformsType = {
|
|
18
|
+
'u_image': Uniform1i;
|
|
19
|
+
'u_pattern_tl_a': Uniform2f;
|
|
20
|
+
'u_pattern_br_a': Uniform2f;
|
|
21
|
+
'u_pattern_tl_b': Uniform2f;
|
|
22
|
+
'u_pattern_br_b': Uniform2f;
|
|
23
|
+
'u_texsize': Uniform2f;
|
|
24
|
+
'u_mix': Uniform1f;
|
|
25
|
+
'u_pattern_size_a': Uniform2f;
|
|
26
|
+
'u_pattern_size_b': Uniform2f;
|
|
27
|
+
'u_scale_a': Uniform1f;
|
|
28
|
+
'u_scale_b': Uniform1f;
|
|
29
|
+
'u_pixel_coord_upper': Uniform2f;
|
|
30
|
+
'u_pixel_coord_lower': Uniform2f;
|
|
31
|
+
'u_tile_units_to_pixels': Uniform1f;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type PatternUniformsType = {
|
|
35
|
+
// pattern uniforms:
|
|
36
|
+
'u_image': Uniform1i;
|
|
37
|
+
'u_texsize': Uniform2f;
|
|
38
|
+
'u_scale': Uniform3f;
|
|
39
|
+
'u_fade': Uniform1f;
|
|
40
|
+
'u_pixel_coord_upper': Uniform2f;
|
|
41
|
+
'u_pixel_coord_lower': Uniform2f;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function patternUniformValues(crossfade: CrossfadeParameters, painter: Painter, tile: Tile): UniformValues<PatternUniformsType> {
|
|
45
|
+
|
|
46
|
+
const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom);
|
|
47
|
+
|
|
48
|
+
const numTiles = Math.pow(2, tile.tileID.overscaledZ);
|
|
49
|
+
const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;
|
|
50
|
+
|
|
51
|
+
const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);
|
|
52
|
+
const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
'u_image': 0,
|
|
56
|
+
'u_texsize': tile.imageAtlasTexture.size,
|
|
57
|
+
'u_scale': [tileRatio, crossfade.fromScale, crossfade.toScale],
|
|
58
|
+
'u_fade': crossfade.t,
|
|
59
|
+
// split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.
|
|
60
|
+
'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],
|
|
61
|
+
'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function bgPatternUniformValues(
|
|
66
|
+
image: CrossFaded<ResolvedImage>,
|
|
67
|
+
crossfade: CrossfadeParameters,
|
|
68
|
+
painter: Painter,
|
|
69
|
+
tile: {
|
|
70
|
+
tileID: OverscaledTileID;
|
|
71
|
+
tileSize: number;
|
|
72
|
+
}
|
|
73
|
+
): UniformValues<BackgroundPatternUniformsType> {
|
|
74
|
+
const imagePosA = painter.imageManager.getPattern(image.from.toString());
|
|
75
|
+
const imagePosB = painter.imageManager.getPattern(image.to.toString());
|
|
76
|
+
const {width, height} = painter.imageManager.getPixelSize();
|
|
77
|
+
|
|
78
|
+
const numTiles = Math.pow(2, tile.tileID.overscaledZ);
|
|
79
|
+
const tileSizeAtNearestZoom = tile.tileSize * Math.pow(2, painter.transform.tileZoom) / numTiles;
|
|
80
|
+
|
|
81
|
+
const pixelX = tileSizeAtNearestZoom * (tile.tileID.canonical.x + tile.tileID.wrap * numTiles);
|
|
82
|
+
const pixelY = tileSizeAtNearestZoom * tile.tileID.canonical.y;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
'u_image': 0,
|
|
86
|
+
'u_pattern_tl_a': (imagePosA as any).tl,
|
|
87
|
+
'u_pattern_br_a': (imagePosA as any).br,
|
|
88
|
+
'u_pattern_tl_b': (imagePosB as any).tl,
|
|
89
|
+
'u_pattern_br_b': (imagePosB as any).br,
|
|
90
|
+
'u_texsize': [width, height],
|
|
91
|
+
'u_mix': crossfade.t,
|
|
92
|
+
'u_pattern_size_a': (imagePosA as any).displaySize,
|
|
93
|
+
'u_pattern_size_b': (imagePosB as any).displaySize,
|
|
94
|
+
'u_scale_a': crossfade.fromScale,
|
|
95
|
+
'u_scale_b': crossfade.toScale,
|
|
96
|
+
'u_tile_units_to_pixels': 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom),
|
|
97
|
+
// split the pixel coord into two pairs of 16 bit numbers. The glsl spec only guarantees 16 bits of precision.
|
|
98
|
+
'u_pixel_coord_upper': [pixelX >> 16, pixelY >> 16],
|
|
99
|
+
'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {bgPatternUniformValues, patternUniformValues};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program';
|
|
2
|
+
import {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program';
|
|
3
|
+
import {circleUniforms} from './circle_program';
|
|
4
|
+
import {collisionUniforms, collisionCircleUniforms} from './collision_program';
|
|
5
|
+
import {debugUniforms} from './debug_program';
|
|
6
|
+
import {clippingMaskUniforms} from './clipping_mask_program';
|
|
7
|
+
import {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program';
|
|
8
|
+
import {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program';
|
|
9
|
+
import {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program';
|
|
10
|
+
import {rasterUniforms} from './raster_program';
|
|
11
|
+
import {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program';
|
|
12
|
+
import {backgroundUniforms, backgroundPatternUniforms} from './background_program';
|
|
13
|
+
import {terrainUniforms, terrainDepthUniforms, terrainCoordsUniforms} from './terrain_program';
|
|
14
|
+
import {skyUniforms} from './sky_program';
|
|
15
|
+
|
|
16
|
+
export const programUniforms = {
|
|
17
|
+
fillExtrusion: fillExtrusionUniforms,
|
|
18
|
+
fillExtrusionPattern: fillExtrusionPatternUniforms,
|
|
19
|
+
fill: fillUniforms,
|
|
20
|
+
fillPattern: fillPatternUniforms,
|
|
21
|
+
fillOutline: fillOutlineUniforms,
|
|
22
|
+
fillOutlinePattern: fillOutlinePatternUniforms,
|
|
23
|
+
circle: circleUniforms,
|
|
24
|
+
collisionBox: collisionUniforms,
|
|
25
|
+
collisionCircle: collisionCircleUniforms,
|
|
26
|
+
debug: debugUniforms,
|
|
27
|
+
clippingMask: clippingMaskUniforms,
|
|
28
|
+
heatmap: heatmapUniforms,
|
|
29
|
+
heatmapTexture: heatmapTextureUniforms,
|
|
30
|
+
hillshade: hillshadeUniforms,
|
|
31
|
+
hillshadePrepare: hillshadePrepareUniforms,
|
|
32
|
+
line: lineUniforms,
|
|
33
|
+
lineGradient: lineGradientUniforms,
|
|
34
|
+
linePattern: linePatternUniforms,
|
|
35
|
+
lineSDF: lineSDFUniforms,
|
|
36
|
+
raster: rasterUniforms,
|
|
37
|
+
symbolIcon: symbolIconUniforms,
|
|
38
|
+
symbolSDF: symbolSDFUniforms,
|
|
39
|
+
symbolTextAndIcon: symbolTextAndIconUniforms,
|
|
40
|
+
background: backgroundUniforms,
|
|
41
|
+
backgroundPattern: backgroundPatternUniforms,
|
|
42
|
+
terrain: terrainUniforms,
|
|
43
|
+
terrainDepth: terrainDepthUniforms,
|
|
44
|
+
terrainCoords: terrainCoordsUniforms,
|
|
45
|
+
sky: skyUniforms
|
|
46
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f} from '../uniform_binding';
|
|
2
|
+
|
|
3
|
+
import type {Context} from '../../gl/context';
|
|
4
|
+
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
5
|
+
import type {RasterStyleLayer} from '../../style/style_layer/raster_style_layer';
|
|
6
|
+
import {mat4} from 'gl-matrix';
|
|
7
|
+
|
|
8
|
+
export type RasterUniformsType = {
|
|
9
|
+
'u_matrix': UniformMatrix4f;
|
|
10
|
+
'u_tl_parent': Uniform2f;
|
|
11
|
+
'u_scale_parent': Uniform1f;
|
|
12
|
+
'u_buffer_scale': Uniform1f;
|
|
13
|
+
'u_fade_t': Uniform1f;
|
|
14
|
+
'u_opacity': Uniform1f;
|
|
15
|
+
'u_image0': Uniform1i;
|
|
16
|
+
'u_image1': Uniform1i;
|
|
17
|
+
'u_brightness_low': Uniform1f;
|
|
18
|
+
'u_brightness_high': Uniform1f;
|
|
19
|
+
'u_saturation_factor': Uniform1f;
|
|
20
|
+
'u_contrast_factor': Uniform1f;
|
|
21
|
+
'u_spin_weights': Uniform3f;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const rasterUniforms = (context: Context, locations: UniformLocations): RasterUniformsType => ({
|
|
25
|
+
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
|
|
26
|
+
'u_tl_parent': new Uniform2f(context, locations.u_tl_parent),
|
|
27
|
+
'u_scale_parent': new Uniform1f(context, locations.u_scale_parent),
|
|
28
|
+
'u_buffer_scale': new Uniform1f(context, locations.u_buffer_scale),
|
|
29
|
+
'u_fade_t': new Uniform1f(context, locations.u_fade_t),
|
|
30
|
+
'u_opacity': new Uniform1f(context, locations.u_opacity),
|
|
31
|
+
'u_image0': new Uniform1i(context, locations.u_image0),
|
|
32
|
+
'u_image1': new Uniform1i(context, locations.u_image1),
|
|
33
|
+
'u_brightness_low': new Uniform1f(context, locations.u_brightness_low),
|
|
34
|
+
'u_brightness_high': new Uniform1f(context, locations.u_brightness_high),
|
|
35
|
+
'u_saturation_factor': new Uniform1f(context, locations.u_saturation_factor),
|
|
36
|
+
'u_contrast_factor': new Uniform1f(context, locations.u_contrast_factor),
|
|
37
|
+
'u_spin_weights': new Uniform3f(context, locations.u_spin_weights)
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const rasterUniformValues = (
|
|
41
|
+
matrix: mat4,
|
|
42
|
+
parentTL: [number, number],
|
|
43
|
+
parentScaleBy: number,
|
|
44
|
+
fade: {
|
|
45
|
+
mix: number;
|
|
46
|
+
opacity: number;
|
|
47
|
+
},
|
|
48
|
+
layer: RasterStyleLayer
|
|
49
|
+
): UniformValues<RasterUniformsType> => ({
|
|
50
|
+
'u_matrix': matrix,
|
|
51
|
+
'u_tl_parent': parentTL,
|
|
52
|
+
'u_scale_parent': parentScaleBy,
|
|
53
|
+
'u_buffer_scale': 1,
|
|
54
|
+
'u_fade_t': fade.mix,
|
|
55
|
+
'u_opacity': fade.opacity * layer.paint.get('raster-opacity'),
|
|
56
|
+
'u_image0': 0,
|
|
57
|
+
'u_image1': 1,
|
|
58
|
+
'u_brightness_low': layer.paint.get('raster-brightness-min'),
|
|
59
|
+
'u_brightness_high': layer.paint.get('raster-brightness-max'),
|
|
60
|
+
'u_saturation_factor': saturationFactor(layer.paint.get('raster-saturation')),
|
|
61
|
+
'u_contrast_factor': contrastFactor(layer.paint.get('raster-contrast')),
|
|
62
|
+
'u_spin_weights': spinWeights(layer.paint.get('raster-hue-rotate'))
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
function spinWeights(angle) {
|
|
66
|
+
angle *= Math.PI / 180;
|
|
67
|
+
const s = Math.sin(angle);
|
|
68
|
+
const c = Math.cos(angle);
|
|
69
|
+
return [
|
|
70
|
+
(2 * c + 1) / 3,
|
|
71
|
+
(-Math.sqrt(3) * s - c + 1) / 3,
|
|
72
|
+
(Math.sqrt(3) * s - c + 1) / 3
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function contrastFactor(contrast) {
|
|
77
|
+
return contrast > 0 ?
|
|
78
|
+
1 / (1 - contrast) :
|
|
79
|
+
1 + contrast;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function saturationFactor(saturation) {
|
|
83
|
+
return saturation > 0 ?
|
|
84
|
+
1 - 1 / (1.001 - saturation) :
|
|
85
|
+
-saturation;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {rasterUniforms, rasterUniformValues};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {UniformColor, Uniform1f} from '../uniform_binding';
|
|
2
|
+
import type {Context} from '../../gl/context';
|
|
3
|
+
import type {UniformValues, UniformLocations} from '../uniform_binding';
|
|
4
|
+
import {Transform} from '../../geo/transform';
|
|
5
|
+
import {Sky} from '../../style/sky';
|
|
6
|
+
|
|
7
|
+
export type SkyUniformsType = {
|
|
8
|
+
'u_sky_color': UniformColor;
|
|
9
|
+
'u_horizon_color': UniformColor;
|
|
10
|
+
'u_horizon': Uniform1f;
|
|
11
|
+
'u_sky_horizon_blend': Uniform1f;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const skyUniforms = (context: Context, locations: UniformLocations): SkyUniformsType => ({
|
|
15
|
+
'u_sky_color': new UniformColor(context, locations.u_sky_color),
|
|
16
|
+
'u_horizon_color': new UniformColor(context, locations.u_horizon_color),
|
|
17
|
+
'u_horizon': new Uniform1f(context, locations.u_horizon),
|
|
18
|
+
'u_sky_horizon_blend': new Uniform1f(context, locations.u_sky_horizon_blend),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const skyUniformValues = (sky: Sky, transform: Transform, pixelRatio: number): UniformValues<SkyUniformsType> => ({
|
|
22
|
+
'u_sky_color': sky.properties.get('sky-color'),
|
|
23
|
+
'u_horizon_color': sky.properties.get('horizon-color'),
|
|
24
|
+
'u_horizon': (transform.height / 2 + transform.getHorizon()) * pixelRatio,
|
|
25
|
+
'u_sky_horizon_blend': (sky.properties.get('sky-horizon-blend') * transform.height / 2) * pixelRatio,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export {skyUniforms, skyUniformValues};
|