@mapwhit/tilerenderer 0.47.1
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 +87 -0
- package/README.md +25 -0
- package/build/min/.dir +0 -0
- package/build/min/package.json +3 -0
- package/build/min/src/shaders/_prelude.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/_prelude.vertex.glsl.txt +14 -0
- package/build/min/src/shaders/background.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/background.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/background_pattern.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/background_pattern.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/circle.fragment.glsl.txt +20 -0
- package/build/min/src/shaders/circle.vertex.glsl.txt +17 -0
- package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/collision_box.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/collision_box.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/collision_circle.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/collision_circle.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/debug.fragment.glsl.txt +1 -0
- package/build/min/src/shaders/debug.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/fill.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/fill.vertex.glsl.txt +7 -0
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_extrusion.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.txt +15 -0
- package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.txt +11 -0
- package/build/min/src/shaders/fill_outline.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/fill_outline.vertex.glsl.txt +7 -0
- package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/fill_pattern.fragment.glsl.txt +13 -0
- package/build/min/src/shaders/fill_pattern.vertex.glsl.txt +9 -0
- package/build/min/src/shaders/heatmap.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/heatmap.vertex.glsl.txt +8 -0
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/hillshade.fragment.glsl.txt +7 -0
- package/build/min/src/shaders/hillshade.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/hillshade_prepare.fragment.glsl.txt +8 -0
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/line.fragment.glsl.txt +12 -0
- package/build/min/src/shaders/line.vertex.glsl.txt +17 -0
- package/build/min/src/shaders/line_gradient.fragment.glsl.txt +10 -0
- package/build/min/src/shaders/line_gradient.vertex.glsl.txt +16 -0
- package/build/min/src/shaders/line_pattern.fragment.glsl.txt +15 -0
- package/build/min/src/shaders/line_pattern.vertex.glsl.txt +20 -0
- package/build/min/src/shaders/line_sdf.fragment.glsl.txt +17 -0
- package/build/min/src/shaders/line_sdf.vertex.glsl.txt +20 -0
- package/build/min/src/shaders/raster.fragment.glsl.txt +5 -0
- package/build/min/src/shaders/raster.vertex.glsl.txt +1 -0
- package/build/min/src/shaders/symbol_icon.fragment.glsl.txt +9 -0
- package/build/min/src/shaders/symbol_icon.vertex.glsl.txt +5 -0
- package/build/min/src/shaders/symbol_sdf.fragment.glsl.txt +19 -0
- package/build/min/src/shaders/symbol_sdf.vertex.glsl.txt +13 -0
- package/package.json +44 -0
- package/src/css/mapbox-gl.css +506 -0
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate-background.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-logo-compact.svg +2 -0
- package/src/css/svg/mapboxgl-ctrl-logo.svg +1 -0
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.js +1138 -0
- package/src/data/bucket/circle_attributes.js +5 -0
- package/src/data/bucket/circle_bucket.js +118 -0
- package/src/data/bucket/fill_attributes.js +5 -0
- package/src/data/bucket/fill_bucket.js +166 -0
- package/src/data/bucket/fill_extrusion_attributes.js +11 -0
- package/src/data/bucket/fill_extrusion_bucket.js +247 -0
- package/src/data/bucket/heatmap_bucket.js +12 -0
- package/src/data/bucket/line_attributes.js +11 -0
- package/src/data/bucket/line_bucket.js +625 -0
- package/src/data/bucket/pattern_attributes.js +9 -0
- package/src/data/bucket/pattern_bucket_features.js +44 -0
- package/src/data/bucket/symbol_attributes.js +95 -0
- package/src/data/bucket/symbol_bucket.js +697 -0
- package/src/data/bucket.js +53 -0
- package/src/data/dem_data.js +126 -0
- package/src/data/extent.js +17 -0
- package/src/data/feature_index.js +254 -0
- package/src/data/index_array_type.js +14 -0
- package/src/data/load_geometry.js +42 -0
- package/src/data/pos_attributes.js +3 -0
- package/src/data/program_configuration.js +782 -0
- package/src/data/raster_bounds_attributes.js +6 -0
- package/src/data/segment.js +63 -0
- package/src/geo/coordinate.js +78 -0
- package/src/geo/lng_lat.js +129 -0
- package/src/geo/lng_lat_bounds.js +253 -0
- package/src/geo/transform.js +605 -0
- package/src/gl/color_mode.js +21 -0
- package/src/gl/context.js +193 -0
- package/src/gl/cull_face_mode.js +22 -0
- package/src/gl/depth_mode.js +18 -0
- package/src/gl/framebuffer.js +28 -0
- package/src/gl/index_buffer.js +52 -0
- package/src/gl/stencil_mode.js +17 -0
- package/src/gl/types.js +0 -0
- package/src/gl/value.js +676 -0
- package/src/gl/vertex_buffer.js +101 -0
- package/src/index.js +50 -0
- package/src/render/draw_background.js +60 -0
- package/src/render/draw_circle.js +55 -0
- package/src/render/draw_collision_debug.js +45 -0
- package/src/render/draw_debug.js +429 -0
- package/src/render/draw_fill.js +143 -0
- package/src/render/draw_fill_extrusion.js +101 -0
- package/src/render/draw_heatmap.js +159 -0
- package/src/render/draw_hillshade.js +144 -0
- package/src/render/draw_line.js +99 -0
- package/src/render/draw_raster.js +151 -0
- package/src/render/draw_symbol.js +231 -0
- package/src/render/glyph_atlas.js +55 -0
- package/src/render/glyph_manager.js +145 -0
- package/src/render/image_atlas.js +97 -0
- package/src/render/image_manager.js +183 -0
- package/src/render/line_atlas.js +139 -0
- package/src/render/painter.js +483 -0
- package/src/render/program/background_program.js +46 -0
- package/src/render/program/circle_program.js +40 -0
- package/src/render/program/clipping_mask_program.js +11 -0
- package/src/render/program/collision_program.js +28 -0
- package/src/render/program/debug_program.js +13 -0
- package/src/render/program/fill_extrusion_program.js +76 -0
- package/src/render/program/fill_program.js +60 -0
- package/src/render/program/heatmap_program.js +46 -0
- package/src/render/program/hillshade_program.js +77 -0
- package/src/render/program/line_program.js +119 -0
- package/src/render/program/pattern.js +57 -0
- package/src/render/program/program_uniforms.js +46 -0
- package/src/render/program/raster_program.js +50 -0
- package/src/render/program/symbol_program.js +112 -0
- package/src/render/program.js +133 -0
- package/src/render/texture.js +88 -0
- package/src/render/tile_mask.js +108 -0
- package/src/render/uniform_binding.js +129 -0
- package/src/render/vertex_array_object.js +155 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +17 -0
- package/src/shaders/_prelude.vertex.glsl +73 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.vertex.glsl +20 -0
- package/src/shaders/circle.fragment.glsl +39 -0
- package/src/shaders/circle.vertex.glsl +63 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/collision_box.fragment.glsl +21 -0
- package/src/shaders/collision_box.vertex.glsl +26 -0
- package/src/shaders/collision_circle.fragment.glsl +34 -0
- package/src/shaders/collision_circle.vertex.glsl +36 -0
- package/src/shaders/debug.fragment.glsl +5 -0
- package/src/shaders/debug.vertex.glsl +7 -0
- package/src/shaders/encode_attribute.js +19 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill_extrusion.fragment.glsl +16 -0
- package/src/shaders/fill_extrusion.vertex.glsl +66 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +41 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +76 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +41 -0
- package/src/shaders/fill_pattern.fragment.glsl +36 -0
- package/src/shaders/fill_pattern.vertex.glsl +36 -0
- package/src/shaders/heatmap.fragment.glsl +21 -0
- package/src/shaders/heatmap.vertex.glsl +53 -0
- package/src/shaders/heatmap_texture.fragment.glsl +14 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +72 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/index.js +194 -0
- package/src/shaders/line.fragment.glsl +28 -0
- package/src/shaders/line.vertex.glsl +84 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.vertex.glsl +84 -0
- package/src/shaders/line_pattern.fragment.glsl +69 -0
- package/src/shaders/line_pattern.vertex.glsl +88 -0
- package/src/shaders/line_sdf.fragment.glsl +44 -0
- package/src/shaders/line_sdf.vertex.glsl +95 -0
- package/src/shaders/raster.fragment.glsl +52 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.vertex.glsl +91 -0
- package/src/shaders/symbol_sdf.fragment.glsl +50 -0
- package/src/shaders/symbol_sdf.vertex.glsl +117 -0
- package/src/source/geojson_source.js +267 -0
- package/src/source/geojson_worker_source.js +210 -0
- package/src/source/geojson_wrapper.js +67 -0
- package/src/source/image_source.js +213 -0
- package/src/source/load_tilejson.js +40 -0
- package/src/source/pixels_to_tile_units.js +17 -0
- package/src/source/query_features.js +198 -0
- package/src/source/raster_dem_tile_source.js +140 -0
- package/src/source/raster_dem_tile_worker_source.js +26 -0
- package/src/source/raster_tile_source.js +126 -0
- package/src/source/rtl_text_plugin.js +63 -0
- package/src/source/source.js +75 -0
- package/src/source/source_cache.js +794 -0
- package/src/source/source_state.js +55 -0
- package/src/source/tile.js +332 -0
- package/src/source/tile_bounds.js +40 -0
- package/src/source/tile_cache.js +122 -0
- package/src/source/tile_id.js +150 -0
- package/src/source/vector_tile_source.js +144 -0
- package/src/source/vector_tile_worker_source.js +126 -0
- package/src/source/worker.js +175 -0
- package/src/source/worker_source.js +14 -0
- package/src/source/worker_tile.js +199 -0
- package/src/style/create_style_layer.js +25 -0
- package/src/style/evaluation_parameters.js +45 -0
- package/src/style/light.js +112 -0
- package/src/style/load_glyph_range.js +17 -0
- package/src/style/load_sprite.js +26 -0
- package/src/style/parse_glyph_pbf.js +45 -0
- package/src/style/pauseable_placement.js +88 -0
- package/src/style/properties.js +691 -0
- package/src/style/query_utils.js +39 -0
- package/src/style/style.js +955 -0
- package/src/style/style_layer/background_style_layer.js +11 -0
- package/src/style/style_layer/background_style_layer_properties.js +25 -0
- package/src/style/style_layer/circle_style_layer.js +93 -0
- package/src/style/style_layer/circle_style_layer_properties.js +76 -0
- package/src/style/style_layer/fill_extrusion_style_layer.js +194 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +56 -0
- package/src/style/style_layer/fill_style_layer.js +46 -0
- package/src/style/style_layer/fill_style_layer_properties.js +45 -0
- package/src/style/style_layer/heatmap_style_layer.js +51 -0
- package/src/style/style_layer/heatmap_style_layer_properties.js +52 -0
- package/src/style/style_layer/hillshade_style_layer.js +15 -0
- package/src/style/style_layer/hillshade_style_layer_properties.js +43 -0
- package/src/style/style_layer/line_style_layer.js +129 -0
- package/src/style/style_layer/line_style_layer_properties.js +104 -0
- package/src/style/style_layer/raster_style_layer.js +11 -0
- package/src/style/style_layer/raster_style_layer_properties.js +55 -0
- package/src/style/style_layer/symbol_style_layer.js +66 -0
- package/src/style/style_layer/symbol_style_layer_properties.js +288 -0
- package/src/style/style_layer.js +183 -0
- package/src/style/style_layer_index.js +61 -0
- package/src/style/zoom_history.js +36 -0
- package/src/style-spec/deref.js +51 -0
- package/src/style-spec/error/parsing_error.js +8 -0
- package/src/style-spec/error/validation_error.js +10 -0
- package/src/style-spec/expression/compound_expression.js +118 -0
- package/src/style-spec/expression/definitions/array.js +82 -0
- package/src/style-spec/expression/definitions/assertion.js +69 -0
- package/src/style-spec/expression/definitions/at.js +57 -0
- package/src/style-spec/expression/definitions/case.js +73 -0
- package/src/style-spec/expression/definitions/coalesce.js +68 -0
- package/src/style-spec/expression/definitions/coercion.js +96 -0
- package/src/style-spec/expression/definitions/collator.js +102 -0
- package/src/style-spec/expression/definitions/equals.js +93 -0
- package/src/style-spec/expression/definitions/index.js +407 -0
- package/src/style-spec/expression/definitions/interpolate.js +235 -0
- package/src/style-spec/expression/definitions/length.js +54 -0
- package/src/style-spec/expression/definitions/let.js +60 -0
- package/src/style-spec/expression/definitions/literal.js +64 -0
- package/src/style-spec/expression/definitions/match.js +142 -0
- package/src/style-spec/expression/definitions/step.js +116 -0
- package/src/style-spec/expression/definitions/var.js +38 -0
- package/src/style-spec/expression/evaluation_context.js +35 -0
- package/src/style-spec/expression/index.js +329 -0
- package/src/style-spec/expression/is_constant.js +63 -0
- package/src/style-spec/expression/parsing_context.js +213 -0
- package/src/style-spec/expression/parsing_error.js +9 -0
- package/src/style-spec/expression/runtime_error.js +12 -0
- package/src/style-spec/expression/scope.js +34 -0
- package/src/style-spec/expression/stops.js +37 -0
- package/src/style-spec/expression/types.js +77 -0
- package/src/style-spec/expression/values.js +126 -0
- package/src/style-spec/feature_filter/README.md +55 -0
- package/src/style-spec/feature_filter/index.js +158 -0
- package/src/style-spec/function/convert.js +256 -0
- package/src/style-spec/function/index.js +299 -0
- package/src/style-spec/group_by_layout.js +68 -0
- package/src/style-spec/reference/v8.json +5356 -0
- package/src/style-spec/util/color.js +73 -0
- package/src/style-spec/util/color_spaces.js +128 -0
- package/src/style-spec/util/eval_support.js +8 -0
- package/src/style-spec/util/get_type.js +18 -0
- package/src/style-spec/util/interpolate.js +21 -0
- package/src/style-spec/util/properties.js +17 -0
- package/src/style-spec/util/ref_properties.js +1 -0
- package/src/style-spec/util/result.js +19 -0
- package/src/symbol/anchor.js +21 -0
- package/src/symbol/check_max_angle.js +75 -0
- package/src/symbol/clip_line.js +73 -0
- package/src/symbol/collision_feature.js +230 -0
- package/src/symbol/collision_index.js +379 -0
- package/src/symbol/cross_tile_symbol_index.js +270 -0
- package/src/symbol/get_anchors.js +177 -0
- package/src/symbol/grid_index.js +318 -0
- package/src/symbol/mergelines.js +75 -0
- package/src/symbol/opacity_state.js +21 -0
- package/src/symbol/placement.js +563 -0
- package/src/symbol/projection.js +601 -0
- package/src/symbol/quads.js +173 -0
- package/src/symbol/shaping.js +347 -0
- package/src/symbol/symbol_layout.js +519 -0
- package/src/symbol/symbol_size.js +110 -0
- package/src/symbol/transform_text.js +16 -0
- package/src/ui/anchor.js +24 -0
- package/src/ui/bind_handlers.js +199 -0
- package/src/ui/camera.js +954 -0
- package/src/ui/events.js +210 -0
- package/src/ui/handler/box_zoom.js +151 -0
- package/src/ui/handler/dblclick_zoom.js +91 -0
- package/src/ui/handler/drag_pan.js +285 -0
- package/src/ui/handler/drag_rotate.js +290 -0
- package/src/ui/handler/frame.js +28 -0
- package/src/ui/handler/inertia.js +45 -0
- package/src/ui/handler/keyboard.js +148 -0
- package/src/ui/handler/scroll_zoom.js +284 -0
- package/src/ui/handler/touch_zoom_rotate.js +263 -0
- package/src/ui/map.js +1645 -0
- package/src/util/actor.js +104 -0
- package/src/util/async.js +23 -0
- package/src/util/browser.js +61 -0
- package/src/util/callback.js +26 -0
- package/src/util/classify_rings.js +43 -0
- package/src/util/color_ramp.js +24 -0
- package/src/util/config.js +24 -0
- package/src/util/dictionary_coder.js +25 -0
- package/src/util/dispatcher.js +68 -0
- package/src/util/dom.js +102 -0
- package/src/util/evented.js +182 -0
- package/src/util/find_pole_of_inaccessibility.js +129 -0
- package/src/util/global_worker_pool.js +15 -0
- package/src/util/image.js +124 -0
- package/src/util/interpolate.js +5 -0
- package/src/util/intersection_tests.js +207 -0
- package/src/util/is_char_in_unicode_block.js +287 -0
- package/src/util/loader/image.js +32 -0
- package/src/util/object.js +178 -0
- package/src/util/script_detection.js +337 -0
- package/src/util/struct_array.js +197 -0
- package/src/util/task_queue.js +57 -0
- package/src/util/throttle.js +26 -0
- package/src/util/tile_cover.js +114 -0
- package/src/util/token.js +13 -0
- package/src/util/unique_id.js +12 -0
- package/src/util/util.js +192 -0
- package/src/util/vectortile_to_geojson.js +44 -0
- package/src/util/verticalize_punctuation.js +112 -0
- package/src/util/warn.js +21 -0
- package/src/util/web_worker.js +5 -0
- package/src/util/web_worker_transfer.js +228 -0
- package/src/util/worker_pool.js +41 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
const { mat4 } = require('@mapbox/gl-matrix');
|
|
2
|
+
const EXTENT = require('../data/extent');
|
|
3
|
+
const { PosArray } = require('../data/array_types');
|
|
4
|
+
const { LineIndexArray } = require('../data/index_array_type');
|
|
5
|
+
const posAttributes = require('../data/pos_attributes');
|
|
6
|
+
const SegmentVector = require('../data/segment');
|
|
7
|
+
const DepthMode = require('../gl/depth_mode');
|
|
8
|
+
const StencilMode = require('../gl/stencil_mode');
|
|
9
|
+
const CullFaceMode = require('../gl/cull_face_mode');
|
|
10
|
+
const { debugUniformValues } = require('./program/debug_program');
|
|
11
|
+
const Color = require('../style-spec/util/color');
|
|
12
|
+
|
|
13
|
+
module.exports = drawDebug;
|
|
14
|
+
|
|
15
|
+
function drawDebug(painter, sourceCache, coords) {
|
|
16
|
+
for (let i = 0; i < coords.length; i++) {
|
|
17
|
+
drawDebugTile(painter, sourceCache, coords[i]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function drawDebugTile(painter, sourceCache, coord) {
|
|
22
|
+
const context = painter.context;
|
|
23
|
+
const gl = context.gl;
|
|
24
|
+
|
|
25
|
+
const posMatrix = coord.posMatrix;
|
|
26
|
+
const program = painter.useProgram('debug');
|
|
27
|
+
|
|
28
|
+
const depthMode = DepthMode.disabled;
|
|
29
|
+
const stencilMode = StencilMode.disabled;
|
|
30
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
31
|
+
const id = '$debug';
|
|
32
|
+
|
|
33
|
+
program.draw(
|
|
34
|
+
context,
|
|
35
|
+
gl.LINE_STRIP,
|
|
36
|
+
depthMode,
|
|
37
|
+
stencilMode,
|
|
38
|
+
colorMode,
|
|
39
|
+
CullFaceMode.disabled,
|
|
40
|
+
debugUniformValues(posMatrix, Color.red),
|
|
41
|
+
id,
|
|
42
|
+
painter.debugBuffer,
|
|
43
|
+
painter.tileBorderIndexBuffer,
|
|
44
|
+
painter.debugSegments
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData;
|
|
48
|
+
const tileByteLength = tileRawData?.byteLength || 0;
|
|
49
|
+
const tileSizeKb = Math.floor(tileByteLength / 1024);
|
|
50
|
+
const vertices = createTextVertices(`${coord.toString()} ${tileSizeKb}kb`, 50, 200, 5);
|
|
51
|
+
const debugTextArray = new PosArray();
|
|
52
|
+
const debugTextIndices = new LineIndexArray();
|
|
53
|
+
for (let v = 0; v < vertices.length; v += 2) {
|
|
54
|
+
debugTextArray.emplaceBack(vertices[v], vertices[v + 1]);
|
|
55
|
+
debugTextIndices.emplaceBack(v, v + 1);
|
|
56
|
+
}
|
|
57
|
+
const debugTextBuffer = context.createVertexBuffer(debugTextArray, posAttributes.members);
|
|
58
|
+
const debugTextIndexBuffer = context.createIndexBuffer(debugTextIndices);
|
|
59
|
+
const debugTextSegment = SegmentVector.simpleSegment(0, 0, debugTextArray.length / 2, debugTextArray.length / 2);
|
|
60
|
+
|
|
61
|
+
// Draw the halo with multiple 1px lines instead of one wider line because
|
|
62
|
+
// the gl spec doesn't guarantee support for lines with width > 1.
|
|
63
|
+
const tileSize = sourceCache.getTile(coord).tileSize;
|
|
64
|
+
const onePixel = EXTENT / (2 ** (painter.transform.zoom - coord.overscaledZ) * tileSize);
|
|
65
|
+
const translations = [
|
|
66
|
+
[-1, -1],
|
|
67
|
+
[-1, 1],
|
|
68
|
+
[1, -1],
|
|
69
|
+
[1, 1]
|
|
70
|
+
];
|
|
71
|
+
for (let i = 0; i < translations.length; i++) {
|
|
72
|
+
const translation = translations[i];
|
|
73
|
+
|
|
74
|
+
program.draw(
|
|
75
|
+
context,
|
|
76
|
+
gl.LINES,
|
|
77
|
+
depthMode,
|
|
78
|
+
stencilMode,
|
|
79
|
+
colorMode,
|
|
80
|
+
CullFaceMode.disabled,
|
|
81
|
+
debugUniformValues(
|
|
82
|
+
mat4.translate([], posMatrix, [onePixel * translation[0], onePixel * translation[1], 0]),
|
|
83
|
+
Color.white
|
|
84
|
+
),
|
|
85
|
+
id,
|
|
86
|
+
debugTextBuffer,
|
|
87
|
+
debugTextIndexBuffer,
|
|
88
|
+
debugTextSegment
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
program.draw(
|
|
93
|
+
context,
|
|
94
|
+
gl.LINES,
|
|
95
|
+
depthMode,
|
|
96
|
+
stencilMode,
|
|
97
|
+
colorMode,
|
|
98
|
+
CullFaceMode.disabled,
|
|
99
|
+
debugUniformValues(posMatrix, Color.black),
|
|
100
|
+
id,
|
|
101
|
+
debugTextBuffer,
|
|
102
|
+
debugTextIndexBuffer,
|
|
103
|
+
debugTextSegment
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Font data From Hershey Simplex Font
|
|
108
|
+
// http://paulbourke.net/dataformats/hershey/
|
|
109
|
+
const simplexFont = {
|
|
110
|
+
' ': [16, []],
|
|
111
|
+
'!': [10, [5, 21, 5, 7, -1, -1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2]],
|
|
112
|
+
'"': [16, [4, 21, 4, 14, -1, -1, 12, 21, 12, 14]],
|
|
113
|
+
'#': [21, [11, 25, 4, -7, -1, -1, 17, 25, 10, -7, -1, -1, 4, 12, 18, 12, -1, -1, 3, 6, 17, 6]],
|
|
114
|
+
$: [
|
|
115
|
+
20,
|
|
116
|
+
[
|
|
117
|
+
8, 25, 8, -4, -1, -1, 12, 25, 12, -4, -1, -1, 17, 18, 15, 20, 12, 21, 8, 21, 5, 20, 3, 18, 3, 16, 4, 14, 5, 13, 7,
|
|
118
|
+
12, 13, 10, 15, 9, 16, 8, 17, 6, 17, 3, 15, 1, 12, 0, 8, 0, 5, 1, 3, 3
|
|
119
|
+
]
|
|
120
|
+
],
|
|
121
|
+
'%': [
|
|
122
|
+
24,
|
|
123
|
+
[
|
|
124
|
+
21, 21, 3, 0, -1, -1, 8, 21, 10, 19, 10, 17, 9, 15, 7, 14, 5, 14, 3, 16, 3, 18, 4, 20, 6, 21, 8, 21, 10, 20, 13,
|
|
125
|
+
19, 16, 19, 19, 20, 21, 21, -1, -1, 17, 7, 15, 6, 14, 4, 14, 2, 16, 0, 18, 0, 20, 1, 21, 3, 21, 5, 19, 7, 17, 7
|
|
126
|
+
]
|
|
127
|
+
],
|
|
128
|
+
'&': [
|
|
129
|
+
26,
|
|
130
|
+
[
|
|
131
|
+
23, 12, 23, 13, 22, 14, 21, 14, 20, 13, 19, 11, 17, 6, 15, 3, 13, 1, 11, 0, 7, 0, 5, 1, 4, 2, 3, 4, 3, 6, 4, 8, 5,
|
|
132
|
+
9, 12, 13, 13, 14, 14, 16, 14, 18, 13, 20, 11, 21, 9, 20, 8, 18, 8, 16, 9, 13, 11, 10, 16, 3, 18, 1, 20, 0, 22, 0,
|
|
133
|
+
23, 1, 23, 2
|
|
134
|
+
]
|
|
135
|
+
],
|
|
136
|
+
"'": [10, [5, 19, 4, 20, 5, 21, 6, 20, 6, 18, 5, 16, 4, 15]],
|
|
137
|
+
'(': [14, [11, 25, 9, 23, 7, 20, 5, 16, 4, 11, 4, 7, 5, 2, 7, -2, 9, -5, 11, -7]],
|
|
138
|
+
')': [14, [3, 25, 5, 23, 7, 20, 9, 16, 10, 11, 10, 7, 9, 2, 7, -2, 5, -5, 3, -7]],
|
|
139
|
+
'*': [16, [8, 21, 8, 9, -1, -1, 3, 18, 13, 12, -1, -1, 13, 18, 3, 12]],
|
|
140
|
+
'+': [26, [13, 18, 13, 0, -1, -1, 4, 9, 22, 9]],
|
|
141
|
+
',': [10, [6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6, -1, 5, -3, 4, -4]],
|
|
142
|
+
'-': [26, [4, 9, 22, 9]],
|
|
143
|
+
'.': [10, [5, 2, 4, 1, 5, 0, 6, 1, 5, 2]],
|
|
144
|
+
'/': [22, [20, 25, 2, -7]],
|
|
145
|
+
0: [
|
|
146
|
+
20,
|
|
147
|
+
[
|
|
148
|
+
9, 21, 6, 20, 4, 17, 3, 12, 3, 9, 4, 4, 6, 1, 9, 0, 11, 0, 14, 1, 16, 4, 17, 9, 17, 12, 16, 17, 14, 20, 11, 21, 9,
|
|
149
|
+
21
|
|
150
|
+
]
|
|
151
|
+
],
|
|
152
|
+
1: [20, [6, 17, 8, 18, 11, 21, 11, 0]],
|
|
153
|
+
2: [20, [4, 16, 4, 17, 5, 19, 6, 20, 8, 21, 12, 21, 14, 20, 15, 19, 16, 17, 16, 15, 15, 13, 13, 10, 3, 0, 17, 0]],
|
|
154
|
+
3: [20, [5, 21, 16, 21, 10, 13, 13, 13, 15, 12, 16, 11, 17, 8, 17, 6, 16, 3, 14, 1, 11, 0, 8, 0, 5, 1, 4, 2, 3, 4]],
|
|
155
|
+
4: [20, [13, 21, 3, 7, 18, 7, -1, -1, 13, 21, 13, 0]],
|
|
156
|
+
5: [
|
|
157
|
+
20,
|
|
158
|
+
[
|
|
159
|
+
15, 21, 5, 21, 4, 12, 5, 13, 8, 14, 11, 14, 14, 13, 16, 11, 17, 8, 17, 6, 16, 3, 14, 1, 11, 0, 8, 0, 5, 1, 4, 2,
|
|
160
|
+
3, 4
|
|
161
|
+
]
|
|
162
|
+
],
|
|
163
|
+
6: [
|
|
164
|
+
20,
|
|
165
|
+
[
|
|
166
|
+
16, 18, 15, 20, 12, 21, 10, 21, 7, 20, 5, 17, 4, 12, 4, 7, 5, 3, 7, 1, 10, 0, 11, 0, 14, 1, 16, 3, 17, 6, 17, 7,
|
|
167
|
+
16, 10, 14, 12, 11, 13, 10, 13, 7, 12, 5, 10, 4, 7
|
|
168
|
+
]
|
|
169
|
+
],
|
|
170
|
+
7: [20, [17, 21, 7, 0, -1, -1, 3, 21, 17, 21]],
|
|
171
|
+
8: [
|
|
172
|
+
20,
|
|
173
|
+
[
|
|
174
|
+
8, 21, 5, 20, 4, 18, 4, 16, 5, 14, 7, 13, 11, 12, 14, 11, 16, 9, 17, 7, 17, 4, 16, 2, 15, 1, 12, 0, 8, 0, 5, 1, 4,
|
|
175
|
+
2, 3, 4, 3, 7, 4, 9, 6, 11, 9, 12, 13, 13, 15, 14, 16, 16, 16, 18, 15, 20, 12, 21, 8, 21
|
|
176
|
+
]
|
|
177
|
+
],
|
|
178
|
+
9: [
|
|
179
|
+
20,
|
|
180
|
+
[
|
|
181
|
+
16, 14, 15, 11, 13, 9, 10, 8, 9, 8, 6, 9, 4, 11, 3, 14, 3, 15, 4, 18, 6, 20, 9, 21, 10, 21, 13, 20, 15, 18, 16,
|
|
182
|
+
14, 16, 9, 15, 4, 13, 1, 10, 0, 8, 0, 5, 1, 4, 3
|
|
183
|
+
]
|
|
184
|
+
],
|
|
185
|
+
':': [10, [5, 14, 4, 13, 5, 12, 6, 13, 5, 14, -1, -1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2]],
|
|
186
|
+
';': [10, [5, 14, 4, 13, 5, 12, 6, 13, 5, 14, -1, -1, 6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6, -1, 5, -3, 4, -4]],
|
|
187
|
+
'<': [24, [20, 18, 4, 9, 20, 0]],
|
|
188
|
+
'=': [26, [4, 12, 22, 12, -1, -1, 4, 6, 22, 6]],
|
|
189
|
+
'>': [24, [4, 18, 20, 9, 4, 0]],
|
|
190
|
+
'?': [
|
|
191
|
+
18,
|
|
192
|
+
[
|
|
193
|
+
3, 16, 3, 17, 4, 19, 5, 20, 7, 21, 11, 21, 13, 20, 14, 19, 15, 17, 15, 15, 14, 13, 13, 12, 9, 10, 9, 7, -1, -1, 9,
|
|
194
|
+
2, 8, 1, 9, 0, 10, 1, 9, 2
|
|
195
|
+
]
|
|
196
|
+
],
|
|
197
|
+
'@': [
|
|
198
|
+
27,
|
|
199
|
+
[
|
|
200
|
+
18, 13, 17, 15, 15, 16, 12, 16, 10, 15, 9, 14, 8, 11, 8, 8, 9, 6, 11, 5, 14, 5, 16, 6, 17, 8, -1, -1, 12, 16, 10,
|
|
201
|
+
14, 9, 11, 9, 8, 10, 6, 11, 5, -1, -1, 18, 16, 17, 8, 17, 6, 19, 5, 21, 5, 23, 7, 24, 10, 24, 12, 23, 15, 22, 17,
|
|
202
|
+
20, 19, 18, 20, 15, 21, 12, 21, 9, 20, 7, 19, 5, 17, 4, 15, 3, 12, 3, 9, 4, 6, 5, 4, 7, 2, 9, 1, 12, 0, 15, 0, 18,
|
|
203
|
+
1, 20, 2, 21, 3, -1, -1, 19, 16, 18, 8, 18, 6, 19, 5
|
|
204
|
+
]
|
|
205
|
+
],
|
|
206
|
+
A: [18, [9, 21, 1, 0, -1, -1, 9, 21, 17, 0, -1, -1, 4, 7, 14, 7]],
|
|
207
|
+
B: [
|
|
208
|
+
21,
|
|
209
|
+
[
|
|
210
|
+
4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 15, 17, 13, 16, 12, 13, 11, -1, -1, 4, 11, 13, 11,
|
|
211
|
+
16, 10, 17, 9, 18, 7, 18, 4, 17, 2, 16, 1, 13, 0, 4, 0
|
|
212
|
+
]
|
|
213
|
+
],
|
|
214
|
+
C: [
|
|
215
|
+
21,
|
|
216
|
+
[
|
|
217
|
+
18, 16, 17, 18, 15, 20, 13, 21, 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17,
|
|
218
|
+
3, 18, 5
|
|
219
|
+
]
|
|
220
|
+
],
|
|
221
|
+
D: [
|
|
222
|
+
21,
|
|
223
|
+
[4, 21, 4, 0, -1, -1, 4, 21, 11, 21, 14, 20, 16, 18, 17, 16, 18, 13, 18, 8, 17, 5, 16, 3, 14, 1, 11, 0, 4, 0]
|
|
224
|
+
],
|
|
225
|
+
E: [19, [4, 21, 4, 0, -1, -1, 4, 21, 17, 21, -1, -1, 4, 11, 12, 11, -1, -1, 4, 0, 17, 0]],
|
|
226
|
+
F: [18, [4, 21, 4, 0, -1, -1, 4, 21, 17, 21, -1, -1, 4, 11, 12, 11]],
|
|
227
|
+
G: [
|
|
228
|
+
21,
|
|
229
|
+
[
|
|
230
|
+
18, 16, 17, 18, 15, 20, 13, 21, 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17,
|
|
231
|
+
3, 18, 5, 18, 8, -1, -1, 13, 8, 18, 8
|
|
232
|
+
]
|
|
233
|
+
],
|
|
234
|
+
H: [22, [4, 21, 4, 0, -1, -1, 18, 21, 18, 0, -1, -1, 4, 11, 18, 11]],
|
|
235
|
+
I: [8, [4, 21, 4, 0]],
|
|
236
|
+
J: [16, [12, 21, 12, 5, 11, 2, 10, 1, 8, 0, 6, 0, 4, 1, 3, 2, 2, 5, 2, 7]],
|
|
237
|
+
K: [21, [4, 21, 4, 0, -1, -1, 18, 21, 4, 7, -1, -1, 9, 12, 18, 0]],
|
|
238
|
+
L: [17, [4, 21, 4, 0, -1, -1, 4, 0, 16, 0]],
|
|
239
|
+
M: [24, [4, 21, 4, 0, -1, -1, 4, 21, 12, 0, -1, -1, 20, 21, 12, 0, -1, -1, 20, 21, 20, 0]],
|
|
240
|
+
N: [22, [4, 21, 4, 0, -1, -1, 4, 21, 18, 0, -1, -1, 18, 21, 18, 0]],
|
|
241
|
+
O: [
|
|
242
|
+
22,
|
|
243
|
+
[
|
|
244
|
+
9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5, 19, 8, 19, 13, 18,
|
|
245
|
+
16, 17, 18, 15, 20, 13, 21, 9, 21
|
|
246
|
+
]
|
|
247
|
+
],
|
|
248
|
+
P: [21, [4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 14, 17, 12, 16, 11, 13, 10, 4, 10]],
|
|
249
|
+
Q: [
|
|
250
|
+
22,
|
|
251
|
+
[
|
|
252
|
+
9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5, 19, 8, 19, 13, 18,
|
|
253
|
+
16, 17, 18, 15, 20, 13, 21, 9, 21, -1, -1, 12, 4, 18, -2
|
|
254
|
+
]
|
|
255
|
+
],
|
|
256
|
+
R: [
|
|
257
|
+
21,
|
|
258
|
+
[
|
|
259
|
+
4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 15, 17, 13, 16, 12, 13, 11, 4, 11, -1, -1, 11, 11,
|
|
260
|
+
18, 0
|
|
261
|
+
]
|
|
262
|
+
],
|
|
263
|
+
S: [
|
|
264
|
+
20,
|
|
265
|
+
[
|
|
266
|
+
17, 18, 15, 20, 12, 21, 8, 21, 5, 20, 3, 18, 3, 16, 4, 14, 5, 13, 7, 12, 13, 10, 15, 9, 16, 8, 17, 6, 17, 3, 15,
|
|
267
|
+
1, 12, 0, 8, 0, 5, 1, 3, 3
|
|
268
|
+
]
|
|
269
|
+
],
|
|
270
|
+
T: [16, [8, 21, 8, 0, -1, -1, 1, 21, 15, 21]],
|
|
271
|
+
U: [22, [4, 21, 4, 6, 5, 3, 7, 1, 10, 0, 12, 0, 15, 1, 17, 3, 18, 6, 18, 21]],
|
|
272
|
+
V: [18, [1, 21, 9, 0, -1, -1, 17, 21, 9, 0]],
|
|
273
|
+
W: [24, [2, 21, 7, 0, -1, -1, 12, 21, 7, 0, -1, -1, 12, 21, 17, 0, -1, -1, 22, 21, 17, 0]],
|
|
274
|
+
X: [20, [3, 21, 17, 0, -1, -1, 17, 21, 3, 0]],
|
|
275
|
+
Y: [18, [1, 21, 9, 11, 9, 0, -1, -1, 17, 21, 9, 11]],
|
|
276
|
+
Z: [20, [17, 21, 3, 0, -1, -1, 3, 21, 17, 21, -1, -1, 3, 0, 17, 0]],
|
|
277
|
+
'[': [14, [4, 25, 4, -7, -1, -1, 5, 25, 5, -7, -1, -1, 4, 25, 11, 25, -1, -1, 4, -7, 11, -7]],
|
|
278
|
+
'\\': [14, [0, 21, 14, -3]],
|
|
279
|
+
']': [14, [9, 25, 9, -7, -1, -1, 10, 25, 10, -7, -1, -1, 3, 25, 10, 25, -1, -1, 3, -7, 10, -7]],
|
|
280
|
+
'^': [16, [6, 15, 8, 18, 10, 15, -1, -1, 3, 12, 8, 17, 13, 12, -1, -1, 8, 17, 8, 0]],
|
|
281
|
+
_: [16, [0, -2, 16, -2]],
|
|
282
|
+
'`': [10, [6, 21, 5, 20, 4, 18, 4, 16, 5, 15, 6, 16, 5, 17]],
|
|
283
|
+
a: [
|
|
284
|
+
19,
|
|
285
|
+
[
|
|
286
|
+
15, 14, 15, 0, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1,
|
|
287
|
+
15, 3
|
|
288
|
+
]
|
|
289
|
+
],
|
|
290
|
+
b: [
|
|
291
|
+
19,
|
|
292
|
+
[
|
|
293
|
+
4, 21, 4, 0, -1, -1, 4, 11, 6, 13, 8, 14, 11, 14, 13, 13, 15, 11, 16, 8, 16, 6, 15, 3, 13, 1, 11, 0, 8, 0, 6, 1,
|
|
294
|
+
4, 3
|
|
295
|
+
]
|
|
296
|
+
],
|
|
297
|
+
c: [18, [15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3]],
|
|
298
|
+
d: [
|
|
299
|
+
19,
|
|
300
|
+
[
|
|
301
|
+
15, 21, 15, 0, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1,
|
|
302
|
+
15, 3
|
|
303
|
+
]
|
|
304
|
+
],
|
|
305
|
+
e: [
|
|
306
|
+
18,
|
|
307
|
+
[
|
|
308
|
+
3, 8, 15, 8, 15, 10, 14, 12, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15,
|
|
309
|
+
3
|
|
310
|
+
]
|
|
311
|
+
],
|
|
312
|
+
f: [12, [10, 21, 8, 21, 6, 20, 5, 17, 5, 0, -1, -1, 2, 14, 9, 14]],
|
|
313
|
+
g: [
|
|
314
|
+
19,
|
|
315
|
+
[
|
|
316
|
+
15, 14, 15, -2, 14, -5, 13, -6, 11, -7, 8, -7, 6, -6, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8,
|
|
317
|
+
3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3
|
|
318
|
+
]
|
|
319
|
+
],
|
|
320
|
+
h: [19, [4, 21, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0]],
|
|
321
|
+
i: [8, [3, 21, 4, 20, 5, 21, 4, 22, 3, 21, -1, -1, 4, 14, 4, 0]],
|
|
322
|
+
j: [10, [5, 21, 6, 20, 7, 21, 6, 22, 5, 21, -1, -1, 6, 14, 6, -3, 5, -6, 3, -7, 1, -7]],
|
|
323
|
+
k: [17, [4, 21, 4, 0, -1, -1, 14, 14, 4, 4, -1, -1, 8, 8, 15, 0]],
|
|
324
|
+
l: [8, [4, 21, 4, 0]],
|
|
325
|
+
m: [
|
|
326
|
+
30,
|
|
327
|
+
[
|
|
328
|
+
4, 14, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0, -1, -1, 15, 10, 18, 13, 20, 14, 23, 14,
|
|
329
|
+
25, 13, 26, 10, 26, 0
|
|
330
|
+
]
|
|
331
|
+
],
|
|
332
|
+
n: [19, [4, 14, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0]],
|
|
333
|
+
o: [
|
|
334
|
+
19,
|
|
335
|
+
[
|
|
336
|
+
8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3, 16, 6, 16, 8, 15, 11, 13, 13, 11, 14, 8,
|
|
337
|
+
14
|
|
338
|
+
]
|
|
339
|
+
],
|
|
340
|
+
p: [
|
|
341
|
+
19,
|
|
342
|
+
[
|
|
343
|
+
4, 14, 4, -7, -1, -1, 4, 11, 6, 13, 8, 14, 11, 14, 13, 13, 15, 11, 16, 8, 16, 6, 15, 3, 13, 1, 11, 0, 8, 0, 6, 1,
|
|
344
|
+
4, 3
|
|
345
|
+
]
|
|
346
|
+
],
|
|
347
|
+
q: [
|
|
348
|
+
19,
|
|
349
|
+
[
|
|
350
|
+
15, 14, 15, -7, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1,
|
|
351
|
+
15, 3
|
|
352
|
+
]
|
|
353
|
+
],
|
|
354
|
+
r: [13, [4, 14, 4, 0, -1, -1, 4, 8, 5, 11, 7, 13, 9, 14, 12, 14]],
|
|
355
|
+
s: [
|
|
356
|
+
17,
|
|
357
|
+
[
|
|
358
|
+
14, 11, 13, 13, 10, 14, 7, 14, 4, 13, 3, 11, 4, 9, 6, 8, 11, 7, 13, 6, 14, 4, 14, 3, 13, 1, 10, 0, 7, 0, 4, 1, 3,
|
|
359
|
+
3
|
|
360
|
+
]
|
|
361
|
+
],
|
|
362
|
+
t: [12, [5, 21, 5, 4, 6, 1, 8, 0, 10, 0, -1, -1, 2, 14, 9, 14]],
|
|
363
|
+
u: [19, [4, 14, 4, 4, 5, 1, 7, 0, 10, 0, 12, 1, 15, 4, -1, -1, 15, 14, 15, 0]],
|
|
364
|
+
v: [16, [2, 14, 8, 0, -1, -1, 14, 14, 8, 0]],
|
|
365
|
+
w: [22, [3, 14, 7, 0, -1, -1, 11, 14, 7, 0, -1, -1, 11, 14, 15, 0, -1, -1, 19, 14, 15, 0]],
|
|
366
|
+
x: [17, [3, 14, 14, 0, -1, -1, 14, 14, 3, 0]],
|
|
367
|
+
y: [16, [2, 14, 8, 0, -1, -1, 14, 14, 8, 0, 6, -4, 4, -6, 2, -7, 1, -7]],
|
|
368
|
+
z: [17, [14, 14, 3, 0, -1, -1, 3, 14, 14, 14, -1, -1, 3, 0, 14, 0]],
|
|
369
|
+
'{': [
|
|
370
|
+
14,
|
|
371
|
+
[
|
|
372
|
+
9, 25, 7, 24, 6, 23, 5, 21, 5, 19, 6, 17, 7, 16, 8, 14, 8, 12, 6, 10, -1, -1, 7, 24, 6, 22, 6, 20, 7, 18, 8, 17,
|
|
373
|
+
9, 15, 9, 13, 8, 11, 4, 9, 8, 7, 9, 5, 9, 3, 8, 1, 7, 0, 6, -2, 6, -4, 7, -6, -1, -1, 6, 8, 8, 6, 8, 4, 7, 2, 6,
|
|
374
|
+
1, 5, -1, 5, -3, 6, -5, 7, -6, 9, -7
|
|
375
|
+
]
|
|
376
|
+
],
|
|
377
|
+
'|': [8, [4, 25, 4, -7]],
|
|
378
|
+
'}': [
|
|
379
|
+
14,
|
|
380
|
+
[
|
|
381
|
+
5, 25, 7, 24, 8, 23, 9, 21, 9, 19, 8, 17, 7, 16, 6, 14, 6, 12, 8, 10, -1, -1, 7, 24, 8, 22, 8, 20, 7, 18, 6, 17,
|
|
382
|
+
5, 15, 5, 13, 6, 11, 10, 9, 6, 7, 5, 5, 5, 3, 6, 1, 7, 0, 8, -2, 8, -4, 7, -6, -1, -1, 8, 8, 6, 6, 6, 4, 7, 2, 8,
|
|
383
|
+
1, 9, -1, 9, -3, 8, -5, 7, -6, 5, -7
|
|
384
|
+
]
|
|
385
|
+
],
|
|
386
|
+
'~': [
|
|
387
|
+
24,
|
|
388
|
+
[
|
|
389
|
+
3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16, 7, 18, 7, 20, 8, 21, 10, -1, -1, 3, 8, 4, 10, 6, 11, 8, 11,
|
|
390
|
+
10, 10, 14, 7, 16, 6, 18, 6, 20, 7, 21, 10, 21, 12
|
|
391
|
+
]
|
|
392
|
+
]
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
function createTextVertices(text, left, baseline, scale) {
|
|
396
|
+
scale = scale || 1;
|
|
397
|
+
|
|
398
|
+
const strokes = [];
|
|
399
|
+
let i;
|
|
400
|
+
let len;
|
|
401
|
+
let j;
|
|
402
|
+
let len2;
|
|
403
|
+
let glyph;
|
|
404
|
+
let x;
|
|
405
|
+
let y;
|
|
406
|
+
let prev;
|
|
407
|
+
|
|
408
|
+
for (i = 0, len = text.length; i < len; i++) {
|
|
409
|
+
glyph = simplexFont[text[i]];
|
|
410
|
+
if (!glyph) continue;
|
|
411
|
+
prev = null;
|
|
412
|
+
|
|
413
|
+
for (j = 0, len2 = glyph[1].length; j < len2; j += 2) {
|
|
414
|
+
if (glyph[1][j] === -1 && glyph[1][j + 1] === -1) {
|
|
415
|
+
prev = null;
|
|
416
|
+
} else {
|
|
417
|
+
x = left + glyph[1][j] * scale;
|
|
418
|
+
y = baseline - glyph[1][j + 1] * scale;
|
|
419
|
+
if (prev) {
|
|
420
|
+
strokes.push(prev.x, prev.y, x, y);
|
|
421
|
+
}
|
|
422
|
+
prev = { x: x, y: y };
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
left += glyph[0] * scale;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return strokes;
|
|
429
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const Color = require('../style-spec/util/color');
|
|
2
|
+
const DepthMode = require('../gl/depth_mode');
|
|
3
|
+
const CullFaceMode = require('../gl/cull_face_mode');
|
|
4
|
+
const {
|
|
5
|
+
fillUniformValues,
|
|
6
|
+
fillPatternUniformValues,
|
|
7
|
+
fillOutlineUniformValues,
|
|
8
|
+
fillOutlinePatternUniformValues
|
|
9
|
+
} = require('./program/fill_program');
|
|
10
|
+
|
|
11
|
+
module.exports = drawFill;
|
|
12
|
+
|
|
13
|
+
function drawFill(painter, sourceCache, layer, coords) {
|
|
14
|
+
const color = layer.paint.get('fill-color');
|
|
15
|
+
const opacity = layer.paint.get('fill-opacity');
|
|
16
|
+
|
|
17
|
+
if (opacity.constantOr(1) === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
22
|
+
|
|
23
|
+
const pattern = layer.paint.get('fill-pattern');
|
|
24
|
+
const pass =
|
|
25
|
+
painter.opaquePassEnabledForLayer() &&
|
|
26
|
+
!pattern.constantOr(1) &&
|
|
27
|
+
color.constantOr(Color.transparent).a === 1 &&
|
|
28
|
+
opacity.constantOr(0) === 1
|
|
29
|
+
? 'opaque'
|
|
30
|
+
: 'translucent';
|
|
31
|
+
|
|
32
|
+
// Draw fill
|
|
33
|
+
if (painter.renderPass === pass) {
|
|
34
|
+
const depthMode = painter.depthModeForSublayer(
|
|
35
|
+
1,
|
|
36
|
+
painter.renderPass === 'opaque' ? DepthMode.ReadWrite : DepthMode.ReadOnly
|
|
37
|
+
);
|
|
38
|
+
drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Draw stroke
|
|
42
|
+
if (painter.renderPass === 'translucent' && layer.paint.get('fill-antialias')) {
|
|
43
|
+
// If we defined a different color for the fill outline, we are
|
|
44
|
+
// going to ignore the bits in 0x07 and just care about the global
|
|
45
|
+
// clipping mask.
|
|
46
|
+
// Otherwise, we only want to drawFill the antialiased parts that are
|
|
47
|
+
// *outside* the current shape. This is important in case the fill
|
|
48
|
+
// or stroke color is translucent. If we wouldn't clip to outside
|
|
49
|
+
// the current shape, some pixels from the outline stroke overlapped
|
|
50
|
+
// the (non-antialiased) fill.
|
|
51
|
+
const depthMode = painter.depthModeForSublayer(
|
|
52
|
+
layer.getPaintProperty('fill-outline-color') ? 2 : 0,
|
|
53
|
+
DepthMode.ReadOnly
|
|
54
|
+
);
|
|
55
|
+
drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, true);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode, isOutline) {
|
|
60
|
+
const gl = painter.context.gl;
|
|
61
|
+
|
|
62
|
+
const patternProperty = layer.paint.get('fill-pattern');
|
|
63
|
+
const image = patternProperty?.constantOr(1);
|
|
64
|
+
const crossfade = layer.getCrossfadeParameters();
|
|
65
|
+
|
|
66
|
+
let drawMode;
|
|
67
|
+
let programName;
|
|
68
|
+
let uniformValues;
|
|
69
|
+
let indexBuffer;
|
|
70
|
+
let segments;
|
|
71
|
+
|
|
72
|
+
if (!isOutline) {
|
|
73
|
+
programName = image ? 'fillPattern' : 'fill';
|
|
74
|
+
drawMode = gl.TRIANGLES;
|
|
75
|
+
} else {
|
|
76
|
+
programName = image && !layer.getPaintProperty('fill-outline-color') ? 'fillOutlinePattern' : 'fillOutline';
|
|
77
|
+
drawMode = gl.LINES;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
for (const coord of coords) {
|
|
81
|
+
const tile = sourceCache.getTile(coord);
|
|
82
|
+
if (image && !tile.patternsLoaded()) continue;
|
|
83
|
+
|
|
84
|
+
const bucket = tile.getBucket(layer);
|
|
85
|
+
if (!bucket) continue;
|
|
86
|
+
|
|
87
|
+
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
88
|
+
const program = painter.useProgram(programName, programConfiguration);
|
|
89
|
+
|
|
90
|
+
if (image) {
|
|
91
|
+
painter.context.activeTexture.set(gl.TEXTURE0);
|
|
92
|
+
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
93
|
+
programConfiguration.updatePatternPaintBuffers(crossfade);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const constantPattern = patternProperty.constantOr(null);
|
|
97
|
+
if (constantPattern && tile.imageAtlas) {
|
|
98
|
+
const posTo = tile.imageAtlas.patternPositions[constantPattern.to];
|
|
99
|
+
const posFrom = tile.imageAtlas.patternPositions[constantPattern.from];
|
|
100
|
+
if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const tileMatrix = painter.translatePosMatrix(
|
|
104
|
+
coord.posMatrix,
|
|
105
|
+
tile,
|
|
106
|
+
layer.paint.get('fill-translate'),
|
|
107
|
+
layer.paint.get('fill-translate-anchor')
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (!isOutline) {
|
|
111
|
+
indexBuffer = bucket.indexBuffer;
|
|
112
|
+
segments = bucket.segments;
|
|
113
|
+
uniformValues = image
|
|
114
|
+
? fillPatternUniformValues(tileMatrix, painter, crossfade, tile)
|
|
115
|
+
: fillUniformValues(tileMatrix);
|
|
116
|
+
} else {
|
|
117
|
+
indexBuffer = bucket.indexBuffer2;
|
|
118
|
+
segments = bucket.segments2;
|
|
119
|
+
const drawingBufferSize = [gl.drawingBufferWidth, gl.drawingBufferHeight];
|
|
120
|
+
uniformValues =
|
|
121
|
+
programName === 'fillOutlinePattern' && image
|
|
122
|
+
? fillOutlinePatternUniformValues(tileMatrix, painter, crossfade, tile, drawingBufferSize)
|
|
123
|
+
: fillOutlineUniformValues(tileMatrix, drawingBufferSize);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
program.draw(
|
|
127
|
+
painter.context,
|
|
128
|
+
drawMode,
|
|
129
|
+
depthMode,
|
|
130
|
+
painter.stencilModeForClipping(coord),
|
|
131
|
+
colorMode,
|
|
132
|
+
CullFaceMode.disabled,
|
|
133
|
+
uniformValues,
|
|
134
|
+
layer.id,
|
|
135
|
+
bucket.layoutVertexBuffer,
|
|
136
|
+
indexBuffer,
|
|
137
|
+
segments,
|
|
138
|
+
layer.paint,
|
|
139
|
+
painter.transform.zoom,
|
|
140
|
+
programConfiguration
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const DepthMode = require('../gl/depth_mode');
|
|
2
|
+
const StencilMode = require('../gl/stencil_mode');
|
|
3
|
+
const ColorMode = require('../gl/color_mode');
|
|
4
|
+
const CullFaceMode = require('../gl/cull_face_mode');
|
|
5
|
+
const { fillExtrusionUniformValues, fillExtrusionPatternUniformValues } = require('./program/fill_extrusion_program');
|
|
6
|
+
|
|
7
|
+
module.exports = draw;
|
|
8
|
+
|
|
9
|
+
function draw(painter, source, layer, coords) {
|
|
10
|
+
const opacity = layer.paint.get('fill-extrusion-opacity');
|
|
11
|
+
if (opacity === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (painter.renderPass === 'translucent') {
|
|
16
|
+
const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);
|
|
17
|
+
|
|
18
|
+
if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1)) {
|
|
19
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
20
|
+
drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode);
|
|
21
|
+
} else {
|
|
22
|
+
// Draw transparent buildings in two passes so that only the closest surface is drawn.
|
|
23
|
+
// First draw all the extrusions into only the depth buffer. No colors are drawn.
|
|
24
|
+
drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, ColorMode.disabled);
|
|
25
|
+
|
|
26
|
+
// Then draw all the extrusions a second type, only coloring fragments if they have the
|
|
27
|
+
// same depth value as the closest fragment in the previous pass. Use the stencil buffer
|
|
28
|
+
// to prevent the second draw in cases where we have coincident polygons.
|
|
29
|
+
drawExtrusionTiles(
|
|
30
|
+
painter,
|
|
31
|
+
source,
|
|
32
|
+
layer,
|
|
33
|
+
coords,
|
|
34
|
+
depthMode,
|
|
35
|
+
painter.stencilModeFor3D(),
|
|
36
|
+
painter.colorModeForRenderPass()
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMode, colorMode) {
|
|
43
|
+
const context = painter.context;
|
|
44
|
+
const gl = context.gl;
|
|
45
|
+
|
|
46
|
+
const patternProperty = layer.paint.get('fill-extrusion-pattern');
|
|
47
|
+
const image = patternProperty.constantOr(1);
|
|
48
|
+
const crossfade = layer.getCrossfadeParameters();
|
|
49
|
+
const opacity = layer.paint.get('fill-extrusion-opacity');
|
|
50
|
+
|
|
51
|
+
for (const coord of coords) {
|
|
52
|
+
const tile = source.getTile(coord);
|
|
53
|
+
const bucket = tile.getBucket(layer);
|
|
54
|
+
if (!bucket) continue;
|
|
55
|
+
|
|
56
|
+
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
57
|
+
const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration);
|
|
58
|
+
|
|
59
|
+
if (image) {
|
|
60
|
+
painter.context.activeTexture.set(gl.TEXTURE0);
|
|
61
|
+
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
62
|
+
programConfiguration.updatePatternPaintBuffers(crossfade);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const constantPattern = patternProperty.constantOr(null);
|
|
66
|
+
if (constantPattern && tile.imageAtlas) {
|
|
67
|
+
const posTo = tile.imageAtlas.patternPositions[constantPattern.to];
|
|
68
|
+
const posFrom = tile.imageAtlas.patternPositions[constantPattern.from];
|
|
69
|
+
if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const matrix = painter.translatePosMatrix(
|
|
73
|
+
coord.posMatrix,
|
|
74
|
+
tile,
|
|
75
|
+
layer.paint.get('fill-extrusion-translate'),
|
|
76
|
+
layer.paint.get('fill-extrusion-translate-anchor')
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient');
|
|
80
|
+
const uniformValues = image
|
|
81
|
+
? fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile)
|
|
82
|
+
: fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity);
|
|
83
|
+
|
|
84
|
+
program.draw(
|
|
85
|
+
context,
|
|
86
|
+
context.gl.TRIANGLES,
|
|
87
|
+
depthMode,
|
|
88
|
+
stencilMode,
|
|
89
|
+
colorMode,
|
|
90
|
+
CullFaceMode.backCCW,
|
|
91
|
+
uniformValues,
|
|
92
|
+
layer.id,
|
|
93
|
+
bucket.layoutVertexBuffer,
|
|
94
|
+
bucket.indexBuffer,
|
|
95
|
+
bucket.segments,
|
|
96
|
+
layer.paint,
|
|
97
|
+
painter.transform.zoom,
|
|
98
|
+
programConfiguration
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|