@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,58 @@
|
|
|
1
|
+
#define SDF_PX 8.0
|
|
2
|
+
|
|
3
|
+
uniform bool u_is_halo;
|
|
4
|
+
uniform sampler2D u_texture;
|
|
5
|
+
uniform highp float u_gamma_scale;
|
|
6
|
+
uniform lowp float u_device_pixel_ratio;
|
|
7
|
+
uniform bool u_is_text;
|
|
8
|
+
|
|
9
|
+
in vec2 v_data0;
|
|
10
|
+
in vec3 v_data1;
|
|
11
|
+
|
|
12
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
13
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
14
|
+
#pragma mapbox: define lowp float opacity
|
|
15
|
+
#pragma mapbox: define lowp float halo_width
|
|
16
|
+
#pragma mapbox: define lowp float halo_blur
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
20
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
21
|
+
#pragma mapbox: initialize lowp float opacity
|
|
22
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
23
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
24
|
+
|
|
25
|
+
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
|
26
|
+
|
|
27
|
+
vec2 tex = v_data0.xy;
|
|
28
|
+
float gamma_scale = v_data1.x;
|
|
29
|
+
float size = v_data1.y;
|
|
30
|
+
float fade_opacity = v_data1[2];
|
|
31
|
+
|
|
32
|
+
float fontScale = u_is_text ? size / 24.0 : size;
|
|
33
|
+
|
|
34
|
+
lowp vec4 color = fill_color;
|
|
35
|
+
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
|
|
36
|
+
lowp float inner_edge = (256.0 - 64.0) / 256.0;
|
|
37
|
+
if (u_is_halo) {
|
|
38
|
+
color = halo_color;
|
|
39
|
+
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
|
|
40
|
+
inner_edge = inner_edge + gamma * gamma_scale;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
lowp float dist = texture(u_texture, tex).a;
|
|
44
|
+
highp float gamma_scaled = gamma * gamma_scale;
|
|
45
|
+
highp float alpha = smoothstep(inner_edge - gamma_scaled, inner_edge + gamma_scaled, dist);
|
|
46
|
+
if (u_is_halo) {
|
|
47
|
+
// When drawing halos, we want the inside of the halo to be transparent as well
|
|
48
|
+
// in case the text fill is transparent.
|
|
49
|
+
lowp float halo_edge = (6.0 - halo_width / fontScale) / SDF_PX;
|
|
50
|
+
alpha = min(smoothstep(halo_edge - gamma_scaled, halo_edge + gamma_scaled, dist), 1.0 - alpha);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fragColor = color * (alpha * opacity * fade_opacity);
|
|
54
|
+
|
|
55
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
56
|
+
fragColor = vec4(1.0);
|
|
57
|
+
#endif
|
|
58
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
in vec4 a_pos_offset;
|
|
2
|
+
in vec4 a_data;
|
|
3
|
+
in vec4 a_pixeloffset;
|
|
4
|
+
in vec3 a_projected_pos;
|
|
5
|
+
in float a_fade_opacity;
|
|
6
|
+
|
|
7
|
+
// contents of a_size vary based on the type of property value
|
|
8
|
+
// used for {text,icon}-size.
|
|
9
|
+
// For constants, a_size is disabled.
|
|
10
|
+
// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
|
|
11
|
+
// For composite functions:
|
|
12
|
+
// [ text-size(lowerZoomStop, feature),
|
|
13
|
+
// text-size(upperZoomStop, feature) ]
|
|
14
|
+
uniform bool u_is_size_zoom_constant;
|
|
15
|
+
uniform bool u_is_size_feature_constant;
|
|
16
|
+
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
|
17
|
+
uniform highp float u_size; // used when size is both zoom and feature constant
|
|
18
|
+
uniform mat4 u_matrix;
|
|
19
|
+
uniform mat4 u_label_plane_matrix;
|
|
20
|
+
uniform mat4 u_coord_matrix;
|
|
21
|
+
uniform bool u_is_text;
|
|
22
|
+
uniform bool u_pitch_with_map;
|
|
23
|
+
uniform bool u_is_along_line;
|
|
24
|
+
uniform bool u_is_variable_anchor;
|
|
25
|
+
uniform highp float u_pitch;
|
|
26
|
+
uniform bool u_rotate_symbol;
|
|
27
|
+
uniform highp float u_aspect_ratio;
|
|
28
|
+
uniform highp float u_camera_to_center_distance;
|
|
29
|
+
uniform float u_fade_change;
|
|
30
|
+
uniform vec2 u_texsize;
|
|
31
|
+
uniform vec2 u_translation;
|
|
32
|
+
uniform float u_pitched_scale;
|
|
33
|
+
|
|
34
|
+
out vec2 v_data0;
|
|
35
|
+
out vec3 v_data1;
|
|
36
|
+
|
|
37
|
+
vec4 projectTileWithElevation(vec2 posInTile, float elevation) {
|
|
38
|
+
return u_matrix * vec4(posInTile, elevation, 1.0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
42
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
43
|
+
#pragma mapbox: define lowp float opacity
|
|
44
|
+
#pragma mapbox: define lowp float halo_width
|
|
45
|
+
#pragma mapbox: define lowp float halo_blur
|
|
46
|
+
|
|
47
|
+
void main() {
|
|
48
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
49
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
50
|
+
#pragma mapbox: initialize lowp float opacity
|
|
51
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
52
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
53
|
+
|
|
54
|
+
vec2 a_pos = a_pos_offset.xy;
|
|
55
|
+
vec2 a_offset = a_pos_offset.zw;
|
|
56
|
+
|
|
57
|
+
vec2 a_tex = a_data.xy;
|
|
58
|
+
vec2 a_size = a_data.zw;
|
|
59
|
+
|
|
60
|
+
float a_size_min = floor(a_size[0] * 0.5);
|
|
61
|
+
vec2 a_pxoffset = a_pixeloffset.xy;
|
|
62
|
+
|
|
63
|
+
float ele = get_elevation(a_pos);
|
|
64
|
+
highp float segment_angle = -a_projected_pos[2];
|
|
65
|
+
float size;
|
|
66
|
+
|
|
67
|
+
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
|
68
|
+
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
|
69
|
+
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
|
70
|
+
size = a_size_min / 128.0;
|
|
71
|
+
} else {
|
|
72
|
+
size = u_size;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
vec2 translated_a_pos = a_pos + u_translation;
|
|
76
|
+
vec4 projectedPoint = projectTileWithElevation(translated_a_pos, ele);
|
|
77
|
+
|
|
78
|
+
highp float camera_to_anchor_distance = projectedPoint.w;
|
|
79
|
+
// If the label is pitched with the map, layout is done in pitched space,
|
|
80
|
+
// which makes labels in the distance smaller relative to viewport space.
|
|
81
|
+
// We counteract part of that effect by multiplying by the perspective ratio.
|
|
82
|
+
// If the label isn't pitched with the map, we do layout in viewport space,
|
|
83
|
+
// which makes labels in the distance larger relative to the features around
|
|
84
|
+
// them. We counteract part of that effect by dividing by the perspective ratio.
|
|
85
|
+
highp float distance_ratio = u_pitch_with_map ?
|
|
86
|
+
camera_to_anchor_distance / u_camera_to_center_distance :
|
|
87
|
+
u_camera_to_center_distance / camera_to_anchor_distance;
|
|
88
|
+
highp float perspective_ratio = clamp(
|
|
89
|
+
0.5 + 0.5 * distance_ratio,
|
|
90
|
+
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
|
91
|
+
4.0);
|
|
92
|
+
|
|
93
|
+
size *= perspective_ratio;
|
|
94
|
+
|
|
95
|
+
float fontScale = u_is_text ? size / 24.0 : size;
|
|
96
|
+
|
|
97
|
+
highp float symbol_rotation = 0.0;
|
|
98
|
+
if (u_rotate_symbol) {
|
|
99
|
+
// Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
|
|
100
|
+
// To figure out that angle in projected space, we draw a short horizontal line in tile
|
|
101
|
+
// space, project it, and measure its angle in projected space.
|
|
102
|
+
vec4 offsetProjectedPoint = projectTileWithElevation(translated_a_pos + vec2(1, 0), ele);
|
|
103
|
+
|
|
104
|
+
vec2 a = projectedPoint.xy / projectedPoint.w;
|
|
105
|
+
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
|
106
|
+
|
|
107
|
+
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
|
111
|
+
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
|
112
|
+
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
113
|
+
|
|
114
|
+
vec4 projected_pos;
|
|
115
|
+
if (u_is_along_line || u_is_variable_anchor) {
|
|
116
|
+
// Label plane matrix is identity in this case
|
|
117
|
+
projected_pos = vec4(a_projected_pos.xy, ele, 1.0);
|
|
118
|
+
} else if (u_pitch_with_map) {
|
|
119
|
+
projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy + u_translation, ele, 1.0);
|
|
120
|
+
} else {
|
|
121
|
+
projected_pos = u_label_plane_matrix * projectTileWithElevation(a_projected_pos.xy + u_translation, ele);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
float z = float(u_pitch_with_map) * projected_pos.z / projected_pos.w;
|
|
125
|
+
|
|
126
|
+
float projectionScaling = 1.0;
|
|
127
|
+
|
|
128
|
+
vec4 finalPos = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset) * projectionScaling, z, 1.0);
|
|
129
|
+
if(u_pitch_with_map) {
|
|
130
|
+
finalPos = projectTileWithElevation(finalPos.xy, finalPos.z);
|
|
131
|
+
}
|
|
132
|
+
float gamma_scale = finalPos.w;
|
|
133
|
+
gl_Position = finalPos;
|
|
134
|
+
|
|
135
|
+
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
|
136
|
+
float visibility = calculate_visibility(projectedPoint);
|
|
137
|
+
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
|
138
|
+
float interpolated_fade_opacity = max(0.0, min(visibility, fade_opacity[0] + fade_change));
|
|
139
|
+
|
|
140
|
+
v_data0 = a_tex / u_texsize;
|
|
141
|
+
v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);
|
|
142
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#define SDF_PX 8.0
|
|
2
|
+
|
|
3
|
+
#define SDF 1.0
|
|
4
|
+
#define ICON 0.0
|
|
5
|
+
|
|
6
|
+
uniform bool u_is_halo;
|
|
7
|
+
uniform sampler2D u_texture;
|
|
8
|
+
uniform sampler2D u_texture_icon;
|
|
9
|
+
uniform highp float u_gamma_scale;
|
|
10
|
+
uniform lowp float u_device_pixel_ratio;
|
|
11
|
+
|
|
12
|
+
in vec4 v_data0;
|
|
13
|
+
in vec4 v_data1;
|
|
14
|
+
|
|
15
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
16
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
17
|
+
#pragma mapbox: define lowp float opacity
|
|
18
|
+
#pragma mapbox: define lowp float halo_width
|
|
19
|
+
#pragma mapbox: define lowp float halo_blur
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
23
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
24
|
+
#pragma mapbox: initialize lowp float opacity
|
|
25
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
26
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
27
|
+
|
|
28
|
+
float fade_opacity = v_data1[2];
|
|
29
|
+
|
|
30
|
+
if (v_data1.w == ICON) {
|
|
31
|
+
vec2 tex_icon = v_data0.zw;
|
|
32
|
+
lowp float alpha = opacity * fade_opacity;
|
|
33
|
+
fragColor = texture(u_texture_icon, tex_icon) * alpha;
|
|
34
|
+
|
|
35
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
36
|
+
fragColor = vec4(1.0);
|
|
37
|
+
#endif
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
vec2 tex = v_data0.xy;
|
|
42
|
+
|
|
43
|
+
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
|
44
|
+
|
|
45
|
+
float gamma_scale = v_data1.x;
|
|
46
|
+
float size = v_data1.y;
|
|
47
|
+
|
|
48
|
+
float fontScale = size / 24.0;
|
|
49
|
+
|
|
50
|
+
lowp vec4 color = fill_color;
|
|
51
|
+
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
|
|
52
|
+
lowp float buff = (256.0 - 64.0) / 256.0;
|
|
53
|
+
if (u_is_halo) {
|
|
54
|
+
color = halo_color;
|
|
55
|
+
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
|
|
56
|
+
buff = (6.0 - halo_width / fontScale) / SDF_PX;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
lowp float dist = texture(u_texture, tex).a;
|
|
60
|
+
highp float gamma_scaled = gamma * gamma_scale;
|
|
61
|
+
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
|
62
|
+
|
|
63
|
+
fragColor = color * (alpha * opacity * fade_opacity);
|
|
64
|
+
|
|
65
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
66
|
+
fragColor = vec4(1.0);
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default '#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
in vec4 a_pos_offset;
|
|
2
|
+
in vec4 a_data;
|
|
3
|
+
in vec3 a_projected_pos;
|
|
4
|
+
in float a_fade_opacity;
|
|
5
|
+
|
|
6
|
+
// contents of a_size vary based on the type of property value
|
|
7
|
+
// used for {text,icon}-size.
|
|
8
|
+
// For constants, a_size is disabled.
|
|
9
|
+
// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
|
|
10
|
+
// For composite functions:
|
|
11
|
+
// [ text-size(lowerZoomStop, feature),
|
|
12
|
+
// text-size(upperZoomStop, feature) ]
|
|
13
|
+
uniform bool u_is_size_zoom_constant;
|
|
14
|
+
uniform bool u_is_size_feature_constant;
|
|
15
|
+
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
|
16
|
+
uniform highp float u_size; // used when size is both zoom and feature constant
|
|
17
|
+
uniform mat4 u_matrix;
|
|
18
|
+
uniform mat4 u_label_plane_matrix;
|
|
19
|
+
uniform mat4 u_coord_matrix;
|
|
20
|
+
uniform bool u_is_text;
|
|
21
|
+
uniform bool u_pitch_with_map;
|
|
22
|
+
uniform highp float u_pitch;
|
|
23
|
+
uniform bool u_rotate_symbol;
|
|
24
|
+
uniform highp float u_aspect_ratio;
|
|
25
|
+
uniform highp float u_camera_to_center_distance;
|
|
26
|
+
uniform float u_fade_change;
|
|
27
|
+
uniform vec2 u_texsize;
|
|
28
|
+
uniform vec2 u_texsize_icon;
|
|
29
|
+
uniform bool u_is_along_line;
|
|
30
|
+
uniform bool u_is_variable_anchor;
|
|
31
|
+
uniform vec2 u_translation;
|
|
32
|
+
uniform float u_pitched_scale;
|
|
33
|
+
|
|
34
|
+
out vec4 v_data0;
|
|
35
|
+
out vec4 v_data1;
|
|
36
|
+
|
|
37
|
+
vec4 projectTileWithElevation(vec2 posInTile, float elevation) {
|
|
38
|
+
return u_matrix * vec4(posInTile, elevation, 1.0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
42
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
43
|
+
#pragma mapbox: define lowp float opacity
|
|
44
|
+
#pragma mapbox: define lowp float halo_width
|
|
45
|
+
#pragma mapbox: define lowp float halo_blur
|
|
46
|
+
|
|
47
|
+
void main() {
|
|
48
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
49
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
50
|
+
#pragma mapbox: initialize lowp float opacity
|
|
51
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
52
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
53
|
+
|
|
54
|
+
vec2 a_pos = a_pos_offset.xy;
|
|
55
|
+
vec2 a_offset = a_pos_offset.zw;
|
|
56
|
+
|
|
57
|
+
vec2 a_tex = a_data.xy;
|
|
58
|
+
vec2 a_size = a_data.zw;
|
|
59
|
+
|
|
60
|
+
float a_size_min = floor(a_size[0] * 0.5);
|
|
61
|
+
float is_sdf = a_size[0] - 2.0 * a_size_min;
|
|
62
|
+
|
|
63
|
+
float ele = get_elevation(a_pos);
|
|
64
|
+
highp float segment_angle = -a_projected_pos[2];
|
|
65
|
+
float size;
|
|
66
|
+
|
|
67
|
+
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
|
68
|
+
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
|
69
|
+
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
|
70
|
+
size = a_size_min / 128.0;
|
|
71
|
+
} else {
|
|
72
|
+
size = u_size;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
vec2 translated_a_pos = a_pos + u_translation;
|
|
76
|
+
vec4 projectedPoint = projectTileWithElevation(translated_a_pos, ele);
|
|
77
|
+
|
|
78
|
+
highp float camera_to_anchor_distance = projectedPoint.w;
|
|
79
|
+
// If the label is pitched with the map, layout is done in pitched space,
|
|
80
|
+
// which makes labels in the distance smaller relative to viewport space.
|
|
81
|
+
// We counteract part of that effect by multiplying by the perspective ratio.
|
|
82
|
+
// If the label isn't pitched with the map, we do layout in viewport space,
|
|
83
|
+
// which makes labels in the distance larger relative to the features around
|
|
84
|
+
// them. We counteract part of that effect by dividing by the perspective ratio.
|
|
85
|
+
highp float distance_ratio = u_pitch_with_map ?
|
|
86
|
+
camera_to_anchor_distance / u_camera_to_center_distance :
|
|
87
|
+
u_camera_to_center_distance / camera_to_anchor_distance;
|
|
88
|
+
highp float perspective_ratio = clamp(
|
|
89
|
+
0.5 + 0.5 * distance_ratio,
|
|
90
|
+
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
|
91
|
+
4.0);
|
|
92
|
+
|
|
93
|
+
size *= perspective_ratio;
|
|
94
|
+
|
|
95
|
+
float fontScale = size / 24.0;
|
|
96
|
+
|
|
97
|
+
highp float symbol_rotation = 0.0;
|
|
98
|
+
if (u_rotate_symbol) {
|
|
99
|
+
// See comments in symbol_sdf.vertex
|
|
100
|
+
vec4 offsetProjectedPoint = projectTileWithElevation(translated_a_pos + vec2(1, 0), ele);
|
|
101
|
+
|
|
102
|
+
vec2 a = projectedPoint.xy / projectedPoint.w;
|
|
103
|
+
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
|
104
|
+
|
|
105
|
+
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
|
109
|
+
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
|
110
|
+
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
111
|
+
|
|
112
|
+
vec4 projected_pos;
|
|
113
|
+
if (u_is_along_line || u_is_variable_anchor) {
|
|
114
|
+
projected_pos = vec4(a_projected_pos.xy, ele, 1.0);
|
|
115
|
+
} else if (u_pitch_with_map) {
|
|
116
|
+
projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy + u_translation, ele, 1.0);
|
|
117
|
+
} else {
|
|
118
|
+
projected_pos = u_label_plane_matrix * projectTileWithElevation(a_projected_pos.xy + u_translation, ele);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
float z = float(u_pitch_with_map) * projected_pos.z / projected_pos.w;
|
|
122
|
+
|
|
123
|
+
float projectionScaling = 1.0;
|
|
124
|
+
|
|
125
|
+
vec4 finalPos = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale) * projectionScaling, z, 1.0);
|
|
126
|
+
if(u_pitch_with_map) {
|
|
127
|
+
finalPos = projectTileWithElevation(finalPos.xy, finalPos.z);
|
|
128
|
+
}
|
|
129
|
+
float gamma_scale = finalPos.w;
|
|
130
|
+
gl_Position = finalPos;
|
|
131
|
+
|
|
132
|
+
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
|
133
|
+
float visibility = calculate_visibility(projectedPoint);
|
|
134
|
+
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
|
135
|
+
float interpolated_fade_opacity = max(0.0, min(visibility, fade_opacity[0] + fade_change));
|
|
136
|
+
|
|
137
|
+
v_data0.xy = a_tex / u_texsize;
|
|
138
|
+
v_data0.zw = a_tex / u_texsize_icon;
|
|
139
|
+
v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf);
|
|
140
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
uniform sampler2D u_texture;
|
|
2
|
+
uniform vec4 u_fog_color;
|
|
3
|
+
uniform vec4 u_horizon_color;
|
|
4
|
+
uniform float u_fog_ground_blend;
|
|
5
|
+
uniform float u_fog_ground_blend_opacity;
|
|
6
|
+
uniform float u_horizon_fog_blend;
|
|
7
|
+
|
|
8
|
+
in vec2 v_texture_pos;
|
|
9
|
+
in float v_fog_depth;
|
|
10
|
+
|
|
11
|
+
const float gamma = 2.2;
|
|
12
|
+
|
|
13
|
+
vec4 gammaToLinear(vec4 color) {
|
|
14
|
+
return pow(color, vec4(gamma));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
vec4 linearToGamma(vec4 color) {
|
|
18
|
+
return pow(color, vec4(1.0 / gamma));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
vec4 surface_color = texture2D(u_texture, v_texture_pos);
|
|
23
|
+
if (v_fog_depth > u_fog_ground_blend) {
|
|
24
|
+
vec4 surface_color_linear = gammaToLinear(surface_color);
|
|
25
|
+
float blend_color = smoothstep(0.0, 1.0, max((v_fog_depth - u_horizon_fog_blend) / (1.0 - u_horizon_fog_blend), 0.0));
|
|
26
|
+
vec4 fog_horizon_color_linear = mix(gammaToLinear(u_fog_color), gammaToLinear(u_horizon_color), blend_color);
|
|
27
|
+
float factor_fog = max(v_fog_depth - u_fog_ground_blend, 0.0) / (1.0 - u_fog_ground_blend);
|
|
28
|
+
gl_FragColor = linearToGamma(mix(surface_color_linear, fog_horizon_color_linear, pow(factor_fog, 2.0) * u_fog_ground_blend_opacity));
|
|
29
|
+
} else {
|
|
30
|
+
gl_FragColor = surface_color;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -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_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
in vec3 a_pos3d;
|
|
2
|
+
|
|
3
|
+
uniform mat4 u_matrix;
|
|
4
|
+
uniform mat4 u_fog_matrix;
|
|
5
|
+
uniform float u_ele_delta;
|
|
6
|
+
|
|
7
|
+
out vec2 v_texture_pos;
|
|
8
|
+
out float v_fog_depth;
|
|
9
|
+
|
|
10
|
+
void main() {
|
|
11
|
+
float ele = get_elevation(a_pos3d.xy);
|
|
12
|
+
float ele_delta = a_pos3d.z == 1.0 ? u_ele_delta : 0.0;
|
|
13
|
+
v_texture_pos = a_pos3d.xy / 8192.0;
|
|
14
|
+
gl_Position = u_matrix * vec4(a_pos3d.xy, ele - ele_delta, 1.0);
|
|
15
|
+
vec4 pos = u_fog_matrix * vec4(a_pos3d.xy, ele, 1.0);
|
|
16
|
+
v_fog_depth = pos.z / pos.w * 0.5 + 0.5;
|
|
17
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
precision mediump float;
|
|
2
|
+
|
|
3
|
+
uniform sampler2D u_texture;
|
|
4
|
+
uniform float u_terrain_coords_id;
|
|
5
|
+
|
|
6
|
+
in vec2 v_texture_pos;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
vec4 rgba = texture(u_texture, v_texture_pos);
|
|
10
|
+
fragColor = vec4(rgba.r, rgba.g, rgba.b, u_terrain_coords_id);
|
|
11
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
attribute vec3 a_pos3d;
|
|
2
|
+
|
|
3
|
+
uniform mat4 u_matrix;
|
|
4
|
+
uniform float u_ele_delta;
|
|
5
|
+
|
|
6
|
+
out vec2 v_texture_pos;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
float ele = get_elevation(a_pos3d.xy);
|
|
10
|
+
float ele_delta = a_pos3d.z == 1.0 ? u_ele_delta : 0.0;
|
|
11
|
+
v_texture_pos = a_pos3d.xy / 8192.0;
|
|
12
|
+
gl_Position = u_matrix * vec4(a_pos3d.xy, ele - ele_delta, 1.0);
|
|
13
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
in float v_depth;
|
|
2
|
+
|
|
3
|
+
// methods for pack/unpack depth value to texture rgba
|
|
4
|
+
// https://stackoverflow.com/questions/34963366/encode-floating-point-data-in-a-rgba-texture
|
|
5
|
+
const highp vec4 bitSh = vec4(256. * 256. * 256., 256. * 256., 256., 1.);
|
|
6
|
+
const highp vec4 bitMsk = vec4(0.,vec3(1./256.0));
|
|
7
|
+
highp vec4 pack(highp float value) {
|
|
8
|
+
highp vec4 comp = fract(value * bitSh);
|
|
9
|
+
comp -= comp.xxyz * bitMsk;
|
|
10
|
+
return comp;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
void main() {
|
|
14
|
+
fragColor = pack(v_depth);
|
|
15
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
attribute vec3 a_pos3d;
|
|
2
|
+
|
|
3
|
+
uniform mat4 u_matrix;
|
|
4
|
+
uniform float u_ele_delta;
|
|
5
|
+
|
|
6
|
+
out float v_depth;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
float ele = get_elevation(a_pos3d.xy);
|
|
10
|
+
float ele_delta = a_pos3d.z == 1.0 ? u_ele_delta : 0.0;
|
|
11
|
+
gl_Position = u_matrix * vec4(a_pos3d.xy, ele - ele_delta, 1.0);
|
|
12
|
+
v_depth = gl_Position.z / gl_Position.w;
|
|
13
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is generated. Edit build/generate-shaders.ts, then run `npm run codegen`.
|
|
2
|
+
export default 'attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}';
|