@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,52 @@
|
|
|
1
|
+
uniform sampler2D u_image;
|
|
2
|
+
in vec2 v_pos;
|
|
3
|
+
|
|
4
|
+
uniform vec2 u_latrange;
|
|
5
|
+
uniform vec2 u_light;
|
|
6
|
+
uniform vec4 u_shadow;
|
|
7
|
+
uniform vec4 u_highlight;
|
|
8
|
+
uniform vec4 u_accent;
|
|
9
|
+
|
|
10
|
+
#define PI 3.141592653589793
|
|
11
|
+
|
|
12
|
+
void main() {
|
|
13
|
+
vec4 pixel = texture(u_image, v_pos);
|
|
14
|
+
|
|
15
|
+
vec2 deriv = ((pixel.rg * 2.0) - 1.0);
|
|
16
|
+
|
|
17
|
+
// We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude
|
|
18
|
+
// to account for mercator projection distortion. see #4807 for details
|
|
19
|
+
float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));
|
|
20
|
+
// We also multiply the slope by an arbitrary z-factor of 1.25
|
|
21
|
+
float slope = atan(1.25 * length(deriv) / scaleFactor);
|
|
22
|
+
float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);
|
|
23
|
+
|
|
24
|
+
float intensity = u_light.x;
|
|
25
|
+
// We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal
|
|
26
|
+
// position property to account for 0deg corresponding to north/the top of the viewport in the style spec
|
|
27
|
+
// and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.
|
|
28
|
+
float azimuth = u_light.y + PI;
|
|
29
|
+
|
|
30
|
+
// We scale the slope exponentially based on intensity, using a calculation similar to
|
|
31
|
+
// the exponential interpolation function in the style spec:
|
|
32
|
+
// src/style-spec/expression/definitions/interpolate.js#L217-L228
|
|
33
|
+
// so that higher intensity values create more opaque hillshading.
|
|
34
|
+
float base = 1.875 - intensity * 1.75;
|
|
35
|
+
float maxValue = 0.5 * PI;
|
|
36
|
+
float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;
|
|
37
|
+
|
|
38
|
+
// The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine
|
|
39
|
+
// so that the accent color's rate of change eases in while the shade color's eases out.
|
|
40
|
+
float accent = cos(scaledSlope);
|
|
41
|
+
// We multiply both the accent and shade color by a clamped intensity value
|
|
42
|
+
// so that intensities >= 0.5 do not additionally affect the color values
|
|
43
|
+
// while intensity values < 0.5 make the overall color more transparent.
|
|
44
|
+
vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);
|
|
45
|
+
float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);
|
|
46
|
+
vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);
|
|
47
|
+
fragColor = accent_color * (1.0 - shade_color.a) + shade_color;
|
|
48
|
+
|
|
49
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
50
|
+
fragColor = vec4(1.0);
|
|
51
|
+
#endif
|
|
52
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#ifdef GL_ES
|
|
2
|
+
precision highp float;
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
uniform sampler2D u_image;
|
|
6
|
+
in vec2 v_pos;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
uniform vec2 u_dimension;
|
|
10
|
+
uniform float u_zoom;
|
|
11
|
+
uniform vec4 u_unpack;
|
|
12
|
+
|
|
13
|
+
float getElevation(vec2 coord, float bias) {
|
|
14
|
+
// Convert encoded elevation value to meters
|
|
15
|
+
vec4 data = texture(u_image, coord) * 255.0;
|
|
16
|
+
data.a = -1.0;
|
|
17
|
+
return dot(data, u_unpack) / 4.0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void main() {
|
|
21
|
+
vec2 epsilon = 1.0 / u_dimension;
|
|
22
|
+
|
|
23
|
+
// queried pixels:
|
|
24
|
+
// +-----------+
|
|
25
|
+
// | | | |
|
|
26
|
+
// | a | b | c |
|
|
27
|
+
// | | | |
|
|
28
|
+
// +-----------+
|
|
29
|
+
// | | | |
|
|
30
|
+
// | d | e | f |
|
|
31
|
+
// | | | |
|
|
32
|
+
// +-----------+
|
|
33
|
+
// | | | |
|
|
34
|
+
// | g | h | i |
|
|
35
|
+
// | | | |
|
|
36
|
+
// +-----------+
|
|
37
|
+
|
|
38
|
+
float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);
|
|
39
|
+
float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);
|
|
40
|
+
float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);
|
|
41
|
+
float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);
|
|
42
|
+
float e = getElevation(v_pos, 0.0);
|
|
43
|
+
float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);
|
|
44
|
+
float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);
|
|
45
|
+
float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);
|
|
46
|
+
float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);
|
|
47
|
+
|
|
48
|
+
// Here we divide the x and y slopes by 8 * pixel size
|
|
49
|
+
// where pixel size (aka meters/pixel) is:
|
|
50
|
+
// circumference of the world / (pixels per tile * number of tiles)
|
|
51
|
+
// which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))
|
|
52
|
+
// which can be reduced to: pow(2, 19.25619978527 - u_zoom).
|
|
53
|
+
// We want to vertically exaggerate the hillshading because otherwise
|
|
54
|
+
// it is barely noticeable at low zooms. To do this, we multiply this by
|
|
55
|
+
// a scale factor that is a function of zooms below 15, which is an arbitrary
|
|
56
|
+
// that corresponds to the max zoom level of Mapbox terrain-RGB tiles.
|
|
57
|
+
// See nickidlugash's awesome breakdown for more info:
|
|
58
|
+
// https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556
|
|
59
|
+
|
|
60
|
+
float exaggerationFactor = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;
|
|
61
|
+
float exaggeration = u_zoom < 15.0 ? (u_zoom - 15.0) * exaggerationFactor : 0.0;
|
|
62
|
+
|
|
63
|
+
vec2 deriv = vec2(
|
|
64
|
+
(c + f + f + i) - (a + d + d + g),
|
|
65
|
+
(g + h + h + i) - (a + b + b + c)
|
|
66
|
+
) / pow(2.0, exaggeration + (19.2562 - u_zoom));
|
|
67
|
+
|
|
68
|
+
fragColor = clamp(vec4(
|
|
69
|
+
deriv.x / 2.0 + 0.5,
|
|
70
|
+
deriv.y / 2.0 + 0.5,
|
|
71
|
+
1.0,
|
|
72
|
+
1.0), 0.0, 1.0);
|
|
73
|
+
|
|
74
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
75
|
+
fragColor = vec4(1.0);
|
|
76
|
+
#endif
|
|
77
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
uniform mat4 u_matrix;
|
|
2
|
+
uniform vec2 u_dimension;
|
|
3
|
+
|
|
4
|
+
in vec2 a_pos;
|
|
5
|
+
in vec2 a_texture_pos;
|
|
6
|
+
|
|
7
|
+
out vec2 v_pos;
|
|
8
|
+
|
|
9
|
+
void main() {
|
|
10
|
+
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
|
11
|
+
|
|
12
|
+
highp vec2 epsilon = 1.0 / u_dimension;
|
|
13
|
+
float scale = (u_dimension.x - 2.0) / u_dimension.x;
|
|
14
|
+
v_pos = (a_texture_pos / 8192.0) * scale + epsilon;
|
|
15
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
uniform lowp float u_device_pixel_ratio;
|
|
2
|
+
|
|
3
|
+
in vec2 v_width2;
|
|
4
|
+
in vec2 v_normal;
|
|
5
|
+
in float v_gamma_scale;
|
|
6
|
+
|
|
7
|
+
#pragma mapbox: define highp vec4 color
|
|
8
|
+
#pragma mapbox: define lowp float blur
|
|
9
|
+
#pragma mapbox: define lowp float opacity
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
#pragma mapbox: initialize highp vec4 color
|
|
13
|
+
#pragma mapbox: initialize lowp float blur
|
|
14
|
+
#pragma mapbox: initialize lowp float opacity
|
|
15
|
+
|
|
16
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
17
|
+
float dist = length(v_normal) * v_width2.s;
|
|
18
|
+
|
|
19
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
20
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
21
|
+
// (v_width2.s)
|
|
22
|
+
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
|
23
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
24
|
+
|
|
25
|
+
fragColor = color * (alpha * opacity);
|
|
26
|
+
|
|
27
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
28
|
+
fragColor = vec4(1.0);
|
|
29
|
+
#endif
|
|
30
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// floor(127 / 2) == 63.0
|
|
2
|
+
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
|
3
|
+
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
|
4
|
+
// there are also "special" normals that have a bigger length (of up to 126 in
|
|
5
|
+
// this case).
|
|
6
|
+
// #define scale 63.0
|
|
7
|
+
#define scale 0.015873016
|
|
8
|
+
|
|
9
|
+
in vec2 a_pos_normal;
|
|
10
|
+
in vec4 a_data;
|
|
11
|
+
|
|
12
|
+
uniform mat4 u_matrix;
|
|
13
|
+
uniform mediump float u_ratio;
|
|
14
|
+
uniform vec2 u_units_to_pixels;
|
|
15
|
+
uniform lowp float u_device_pixel_ratio;
|
|
16
|
+
|
|
17
|
+
out vec2 v_normal;
|
|
18
|
+
out vec2 v_width2;
|
|
19
|
+
out float v_gamma_scale;
|
|
20
|
+
out highp float v_linesofar;
|
|
21
|
+
|
|
22
|
+
#pragma mapbox: define highp vec4 color
|
|
23
|
+
#pragma mapbox: define lowp float blur
|
|
24
|
+
#pragma mapbox: define lowp float opacity
|
|
25
|
+
#pragma mapbox: define mediump float gapwidth
|
|
26
|
+
#pragma mapbox: define lowp float offset
|
|
27
|
+
#pragma mapbox: define mediump float width
|
|
28
|
+
|
|
29
|
+
void main() {
|
|
30
|
+
#pragma mapbox: initialize highp vec4 color
|
|
31
|
+
#pragma mapbox: initialize lowp float blur
|
|
32
|
+
#pragma mapbox: initialize lowp float opacity
|
|
33
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
34
|
+
#pragma mapbox: initialize lowp float offset
|
|
35
|
+
#pragma mapbox: initialize mediump float width
|
|
36
|
+
|
|
37
|
+
// the distance over which the line edge fades out.
|
|
38
|
+
// Retina devices need a smaller distance to avoid aliasing.
|
|
39
|
+
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
|
40
|
+
|
|
41
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
42
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
43
|
+
|
|
44
|
+
v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;
|
|
45
|
+
|
|
46
|
+
vec2 pos = floor(a_pos_normal * 0.5);
|
|
47
|
+
|
|
48
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
49
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
50
|
+
// We store these in the least significant bit of a_pos_normal
|
|
51
|
+
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
|
52
|
+
normal.y = normal.y * 2.0 - 1.0;
|
|
53
|
+
v_normal = normal;
|
|
54
|
+
|
|
55
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
56
|
+
// moved them into the shader for clarity and simplicity.
|
|
57
|
+
gapwidth = gapwidth / 2.0;
|
|
58
|
+
float halfwidth = width / 2.0;
|
|
59
|
+
offset = -1.0 * offset;
|
|
60
|
+
|
|
61
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
62
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
63
|
+
|
|
64
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
65
|
+
// of this vertex.
|
|
66
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
67
|
+
|
|
68
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
69
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
70
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
71
|
+
// extrude vector points in another direction.
|
|
72
|
+
mediump float u = 0.5 * a_direction;
|
|
73
|
+
mediump float t = 1.0 - abs(u);
|
|
74
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
75
|
+
|
|
76
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
77
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
78
|
+
|
|
79
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
80
|
+
#ifdef TERRAIN3D
|
|
81
|
+
v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh
|
|
82
|
+
#else
|
|
83
|
+
float extrude_length_without_perspective = length(dist);
|
|
84
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
|
85
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
v_width2 = vec2(outset, inset);
|
|
89
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
uniform lowp float u_device_pixel_ratio;
|
|
2
|
+
uniform sampler2D u_image;
|
|
3
|
+
|
|
4
|
+
in vec2 v_width2;
|
|
5
|
+
in vec2 v_normal;
|
|
6
|
+
in float v_gamma_scale;
|
|
7
|
+
in highp vec2 v_uv;
|
|
8
|
+
|
|
9
|
+
#pragma mapbox: define lowp float blur
|
|
10
|
+
#pragma mapbox: define lowp float opacity
|
|
11
|
+
|
|
12
|
+
void main() {
|
|
13
|
+
#pragma mapbox: initialize lowp float blur
|
|
14
|
+
#pragma mapbox: initialize lowp float opacity
|
|
15
|
+
|
|
16
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
17
|
+
float dist = length(v_normal) * v_width2.s;
|
|
18
|
+
|
|
19
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
20
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
21
|
+
// (v_width2.s)
|
|
22
|
+
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
|
23
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
24
|
+
|
|
25
|
+
// For gradient lines, v_lineprogress is the ratio along the
|
|
26
|
+
// entire line, the gradient ramp is stored in a texture.
|
|
27
|
+
vec4 color = texture(u_image, v_uv);
|
|
28
|
+
|
|
29
|
+
fragColor = color * (alpha * opacity);
|
|
30
|
+
|
|
31
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
32
|
+
fragColor = vec4(1.0);
|
|
33
|
+
#endif
|
|
34
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// floor(127 / 2) == 63.0
|
|
2
|
+
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
|
3
|
+
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
|
4
|
+
// there are also "special" normals that have a bigger length (of up to 126 in
|
|
5
|
+
// this case).
|
|
6
|
+
// #define scale 63.0
|
|
7
|
+
#define scale 0.015873016
|
|
8
|
+
|
|
9
|
+
in vec2 a_pos_normal;
|
|
10
|
+
in vec4 a_data;
|
|
11
|
+
in float a_uv_x;
|
|
12
|
+
in float a_split_index;
|
|
13
|
+
|
|
14
|
+
uniform mat4 u_matrix;
|
|
15
|
+
uniform mediump float u_ratio;
|
|
16
|
+
uniform lowp float u_device_pixel_ratio;
|
|
17
|
+
uniform vec2 u_units_to_pixels;
|
|
18
|
+
uniform float u_image_height;
|
|
19
|
+
|
|
20
|
+
out vec2 v_normal;
|
|
21
|
+
out vec2 v_width2;
|
|
22
|
+
out float v_gamma_scale;
|
|
23
|
+
out highp vec2 v_uv;
|
|
24
|
+
|
|
25
|
+
#pragma mapbox: define lowp float blur
|
|
26
|
+
#pragma mapbox: define lowp float opacity
|
|
27
|
+
#pragma mapbox: define mediump float gapwidth
|
|
28
|
+
#pragma mapbox: define lowp float offset
|
|
29
|
+
#pragma mapbox: define mediump float width
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
#pragma mapbox: initialize lowp float blur
|
|
33
|
+
#pragma mapbox: initialize lowp float opacity
|
|
34
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
35
|
+
#pragma mapbox: initialize lowp float offset
|
|
36
|
+
#pragma mapbox: initialize mediump float width
|
|
37
|
+
|
|
38
|
+
// the distance over which the line edge fades out.
|
|
39
|
+
// Retina devices need a smaller distance to avoid aliasing.
|
|
40
|
+
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
|
41
|
+
|
|
42
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
43
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
44
|
+
|
|
45
|
+
highp float texel_height = 1.0 / u_image_height;
|
|
46
|
+
highp float half_texel_height = 0.5 * texel_height;
|
|
47
|
+
v_uv = vec2(a_uv_x, a_split_index * texel_height - half_texel_height);
|
|
48
|
+
|
|
49
|
+
vec2 pos = floor(a_pos_normal * 0.5);
|
|
50
|
+
|
|
51
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
52
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
53
|
+
// We store these in the least significant bit of a_pos_normal
|
|
54
|
+
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
|
55
|
+
normal.y = normal.y * 2.0 - 1.0;
|
|
56
|
+
v_normal = normal;
|
|
57
|
+
|
|
58
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
59
|
+
// moved them into the shader for clarity and simplicity.
|
|
60
|
+
gapwidth = gapwidth / 2.0;
|
|
61
|
+
float halfwidth = width / 2.0;
|
|
62
|
+
offset = -1.0 * offset;
|
|
63
|
+
|
|
64
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
65
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
66
|
+
|
|
67
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
68
|
+
// of this vertex.
|
|
69
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
70
|
+
|
|
71
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
72
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
73
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
74
|
+
// extrude vector points in another direction.
|
|
75
|
+
mediump float u = 0.5 * a_direction;
|
|
76
|
+
mediump float t = 1.0 - abs(u);
|
|
77
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
78
|
+
|
|
79
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
80
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
81
|
+
|
|
82
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
83
|
+
#ifdef TERRAIN3D
|
|
84
|
+
v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh
|
|
85
|
+
#else
|
|
86
|
+
float extrude_length_without_perspective = length(dist);
|
|
87
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
|
88
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
v_width2 = vec2(outset, inset);
|
|
92
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#ifdef GL_ES
|
|
2
|
+
precision highp float;
|
|
3
|
+
#endif
|
|
4
|
+
uniform lowp float u_device_pixel_ratio;
|
|
5
|
+
uniform vec2 u_texsize;
|
|
6
|
+
uniform float u_fade;
|
|
7
|
+
uniform mediump vec3 u_scale;
|
|
8
|
+
|
|
9
|
+
uniform sampler2D u_image;
|
|
10
|
+
|
|
11
|
+
in vec2 v_normal;
|
|
12
|
+
in vec2 v_width2;
|
|
13
|
+
in float v_linesofar;
|
|
14
|
+
in float v_gamma_scale;
|
|
15
|
+
in float v_width;
|
|
16
|
+
|
|
17
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
18
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
19
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
20
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
21
|
+
#pragma mapbox: define lowp float blur
|
|
22
|
+
#pragma mapbox: define lowp float opacity
|
|
23
|
+
|
|
24
|
+
void main() {
|
|
25
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
26
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
27
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
28
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
29
|
+
|
|
30
|
+
#pragma mapbox: initialize lowp float blur
|
|
31
|
+
#pragma mapbox: initialize lowp float opacity
|
|
32
|
+
|
|
33
|
+
vec2 pattern_tl_a = pattern_from.xy;
|
|
34
|
+
vec2 pattern_br_a = pattern_from.zw;
|
|
35
|
+
vec2 pattern_tl_b = pattern_to.xy;
|
|
36
|
+
vec2 pattern_br_b = pattern_to.zw;
|
|
37
|
+
|
|
38
|
+
float tileZoomRatio = u_scale.x;
|
|
39
|
+
float fromScale = u_scale.y;
|
|
40
|
+
float toScale = u_scale.z;
|
|
41
|
+
|
|
42
|
+
vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixel_ratio_from;
|
|
43
|
+
vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixel_ratio_to;
|
|
44
|
+
|
|
45
|
+
vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y);
|
|
46
|
+
vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y);
|
|
47
|
+
|
|
48
|
+
float aspect_a = display_size_a.y / v_width;
|
|
49
|
+
float aspect_b = display_size_b.y / v_width;
|
|
50
|
+
|
|
51
|
+
// Calculate the distance of the pixel from the line in pixels.
|
|
52
|
+
float dist = length(v_normal) * v_width2.s;
|
|
53
|
+
|
|
54
|
+
// Calculate the antialiasing fade factor. This is either when fading in
|
|
55
|
+
// the line in case of an offset line (v_width2.t) or when fading out
|
|
56
|
+
// (v_width2.s)
|
|
57
|
+
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
|
58
|
+
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
|
59
|
+
|
|
60
|
+
float x_a = mod(v_linesofar / pattern_size_a.x * aspect_a, 1.0);
|
|
61
|
+
float x_b = mod(v_linesofar / pattern_size_b.x * aspect_b, 1.0);
|
|
62
|
+
|
|
63
|
+
float y = 0.5 * v_normal.y + 0.5;
|
|
64
|
+
|
|
65
|
+
vec2 texel_size = 1.0 / u_texsize;
|
|
66
|
+
|
|
67
|
+
vec2 pos_a = mix(pattern_tl_a * texel_size - texel_size, pattern_br_a * texel_size + texel_size, vec2(x_a, y));
|
|
68
|
+
vec2 pos_b = mix(pattern_tl_b * texel_size - texel_size, pattern_br_b * texel_size + texel_size, vec2(x_b, y));
|
|
69
|
+
|
|
70
|
+
vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade);
|
|
71
|
+
|
|
72
|
+
fragColor = color * alpha * opacity;
|
|
73
|
+
|
|
74
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
75
|
+
fragColor = vec4(1.0);
|
|
76
|
+
#endif
|
|
77
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// floor(127 / 2) == 63.0
|
|
2
|
+
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
|
3
|
+
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
|
4
|
+
// there are also "special" normals that have a bigger length (of up to 126 in
|
|
5
|
+
// this case).
|
|
6
|
+
// #define scale 63.0
|
|
7
|
+
#define scale 0.015873016
|
|
8
|
+
|
|
9
|
+
// We scale the distance before adding it to the buffers so that we can store
|
|
10
|
+
// long distances for long segments. Use this value to unscale the distance.
|
|
11
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
12
|
+
|
|
13
|
+
in vec2 a_pos_normal;
|
|
14
|
+
in vec4 a_data;
|
|
15
|
+
|
|
16
|
+
uniform mat4 u_matrix;
|
|
17
|
+
uniform vec2 u_units_to_pixels;
|
|
18
|
+
uniform mediump float u_ratio;
|
|
19
|
+
uniform lowp float u_device_pixel_ratio;
|
|
20
|
+
|
|
21
|
+
out vec2 v_normal;
|
|
22
|
+
out vec2 v_width2;
|
|
23
|
+
out float v_linesofar;
|
|
24
|
+
out float v_gamma_scale;
|
|
25
|
+
out float v_width;
|
|
26
|
+
|
|
27
|
+
#pragma mapbox: define lowp float blur
|
|
28
|
+
#pragma mapbox: define lowp float opacity
|
|
29
|
+
#pragma mapbox: define lowp float offset
|
|
30
|
+
#pragma mapbox: define mediump float gapwidth
|
|
31
|
+
#pragma mapbox: define mediump float width
|
|
32
|
+
#pragma mapbox: define lowp float floorwidth
|
|
33
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
34
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
35
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
36
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
37
|
+
|
|
38
|
+
void main() {
|
|
39
|
+
#pragma mapbox: initialize lowp float blur
|
|
40
|
+
#pragma mapbox: initialize lowp float opacity
|
|
41
|
+
#pragma mapbox: initialize lowp float offset
|
|
42
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
43
|
+
#pragma mapbox: initialize mediump float width
|
|
44
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
45
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
46
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
47
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
48
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
49
|
+
|
|
50
|
+
// the distance over which the line edge fades out.
|
|
51
|
+
// Retina devices need a smaller distance to avoid aliasing.
|
|
52
|
+
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
|
53
|
+
|
|
54
|
+
vec2 a_extrude = a_data.xy - 128.0;
|
|
55
|
+
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
|
56
|
+
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
|
57
|
+
// float tileRatio = u_scale.x;
|
|
58
|
+
vec2 pos = floor(a_pos_normal * 0.5);
|
|
59
|
+
|
|
60
|
+
// x is 1 if it's a round cap, 0 otherwise
|
|
61
|
+
// y is 1 if the normal points up, and -1 if it points down
|
|
62
|
+
// We store these in the least significant bit of a_pos_normal
|
|
63
|
+
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
|
64
|
+
normal.y = normal.y * 2.0 - 1.0;
|
|
65
|
+
v_normal = normal;
|
|
66
|
+
|
|
67
|
+
// these transformations used to be applied in the JS and native code bases.
|
|
68
|
+
// moved them into the shader for clarity and simplicity.
|
|
69
|
+
gapwidth = gapwidth / 2.0;
|
|
70
|
+
float halfwidth = width / 2.0;
|
|
71
|
+
offset = -1.0 * offset;
|
|
72
|
+
|
|
73
|
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
|
74
|
+
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
75
|
+
|
|
76
|
+
// Scale the extrusion vector down to a normal and then up by the line width
|
|
77
|
+
// of this vertex.
|
|
78
|
+
mediump vec2 dist = outset * a_extrude * scale;
|
|
79
|
+
|
|
80
|
+
// Calculate the offset when drawing a line that is to the side of the actual line.
|
|
81
|
+
// We do this by creating a vector that points towards the extrude, but rotate
|
|
82
|
+
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
|
83
|
+
// extrude vector points in another direction.
|
|
84
|
+
mediump float u = 0.5 * a_direction;
|
|
85
|
+
mediump float t = 1.0 - abs(u);
|
|
86
|
+
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
|
87
|
+
|
|
88
|
+
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
|
89
|
+
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
|
90
|
+
|
|
91
|
+
// calculate how much the perspective view squishes or stretches the extrude
|
|
92
|
+
#ifdef TERRAIN3D
|
|
93
|
+
v_gamma_scale = 1.0; // not needed, because this is done automatically via the mesh
|
|
94
|
+
#else
|
|
95
|
+
float extrude_length_without_perspective = length(dist);
|
|
96
|
+
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
|
97
|
+
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
|
98
|
+
#endif
|
|
99
|
+
|
|
100
|
+
v_linesofar = a_linesofar;
|
|
101
|
+
v_width2 = vec2(outset, inset);
|
|
102
|
+
v_width = floorwidth;
|
|
103
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}';
|