@mapwhit/tilerenderer 1.0.0 → 1.1.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/build/min/package.json +2 -1
- package/build/min/src/shaders/_prelude.fragment.glsl.js +1 -1
- package/build/min/src/shaders/_prelude.vertex.glsl.js +1 -1
- package/build/min/src/shaders/background.fragment.glsl.js +1 -1
- package/build/min/src/shaders/background.vertex.glsl.js +1 -1
- package/build/min/src/shaders/background_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/circle.fragment.glsl.js +1 -1
- package/build/min/src/shaders/circle.vertex.glsl.js +1 -1
- package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
- package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
- package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
- package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/heatmap.fragment.glsl.js +1 -1
- package/build/min/src/shaders/heatmap.vertex.glsl.js +1 -1
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +1 -1
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade.fragment.glsl.js +1 -1
- package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +1 -1
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_gradient.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_gradient.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_sdf.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_sdf.vertex.glsl.js +1 -1
- package/build/min/src/shaders/raster.fragment.glsl.js +1 -1
- package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
- package/build/min/src/shaders/symbol_icon.fragment.glsl.js +1 -1
- package/build/min/src/shaders/symbol_icon.vertex.glsl.js +1 -1
- package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +1 -1
- package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +1 -1
- package/package.json +3 -2
- package/src/data/array_types.js +54 -81
- package/src/data/bucket/circle_attributes.js +2 -4
- package/src/data/bucket/circle_bucket.js +19 -13
- package/src/data/bucket/fill_attributes.js +2 -4
- package/src/data/bucket/fill_bucket.js +38 -24
- package/src/data/bucket/fill_extrusion_attributes.js +2 -4
- package/src/data/bucket/fill_extrusion_bucket.js +56 -34
- package/src/data/bucket/heatmap_bucket.js +2 -7
- package/src/data/bucket/line_attributes.js +2 -4
- package/src/data/bucket/line_bucket.js +207 -159
- package/src/data/bucket/pattern_attributes.js +2 -4
- package/src/data/bucket/pattern_bucket_features.js +5 -7
- package/src/data/bucket/symbol_attributes.js +12 -26
- package/src/data/bucket/symbol_bucket.js +111 -221
- package/src/data/bucket/symbol_buffers.js +62 -0
- package/src/data/bucket/symbol_collision_buffers.js +33 -0
- package/src/data/bucket.js +2 -6
- package/src/data/dem_data.js +11 -7
- package/src/data/extent.js +1 -1
- package/src/data/feature_index.js +35 -20
- package/src/data/index_array_type.js +1 -6
- package/src/data/load_geometry.js +6 -9
- package/src/data/pos_attributes.js +2 -3
- package/src/data/program_configuration.js +44 -26
- package/src/data/raster_bounds_attributes.js +2 -2
- package/src/data/segment.js +4 -3
- package/src/geo/coordinate.js +1 -1
- package/src/geo/lng_lat.js +3 -3
- package/src/geo/lng_lat_bounds.js +8 -4
- package/src/geo/transform.js +69 -30
- package/src/gl/color_mode.js +2 -2
- package/src/gl/context.js +28 -29
- package/src/gl/cull_face_mode.js +1 -1
- package/src/gl/depth_mode.js +1 -1
- package/src/gl/framebuffer.js +8 -4
- package/src/gl/index_buffer.js +2 -2
- package/src/gl/stencil_mode.js +1 -1
- package/src/gl/value.js +33 -68
- package/src/gl/vertex_buffer.js +2 -2
- package/src/index.js +49 -25
- package/src/render/draw_background.js +14 -9
- package/src/render/draw_circle.js +11 -8
- package/src/render/draw_collision_debug.js +11 -8
- package/src/render/draw_debug.js +16 -14
- package/src/render/draw_fill.js +19 -12
- package/src/render/draw_fill_extrusion.js +12 -9
- package/src/render/draw_heatmap.js +17 -12
- package/src/render/draw_hillshade.js +12 -9
- package/src/render/draw_line.js +30 -16
- package/src/render/draw_raster.js +17 -13
- package/src/render/draw_symbol.js +22 -17
- package/src/render/glyph_atlas.js +9 -5
- package/src/render/glyph_manager.js +1 -1
- package/src/render/image_atlas.js +4 -7
- package/src/render/image_manager.js +6 -9
- package/src/render/line_atlas.js +2 -2
- package/src/render/painter.js +65 -47
- package/src/render/program/background_program.js +6 -13
- package/src/render/program/circle_program.js +4 -6
- package/src/render/program/clipping_mask_program.js +3 -5
- package/src/render/program/collision_program.js +4 -6
- package/src/render/program/debug_program.js +3 -5
- package/src/render/program/fill_extrusion_program.js +8 -14
- package/src/render/program/fill_program.js +10 -21
- package/src/render/program/heatmap_program.js +8 -14
- package/src/render/program/hillshade_program.js +10 -16
- package/src/render/program/line_program.js +11 -22
- package/src/render/program/pattern.js +5 -7
- package/src/render/program/program_uniforms.js +13 -20
- package/src/render/program/raster_program.js +3 -5
- package/src/render/program/symbol_program.js +5 -7
- package/src/render/program.js +5 -6
- package/src/render/texture.js +1 -1
- package/src/render/tile_mask.js +6 -4
- package/src/render/uniform_binding.js +9 -20
- package/src/render/vertex_array_object.js +5 -3
- package/src/shaders/encode_attribute.js +2 -6
- package/src/shaders/index.js +103 -51
- package/src/source/geojson_source.js +11 -7
- package/src/source/geojson_worker_source.js +7 -7
- package/src/source/geojson_wrapper.js +4 -4
- package/src/source/image_source.js +11 -12
- package/src/source/load_tilejson.js +3 -3
- package/src/source/pixels_to_tile_units.js +3 -3
- package/src/source/query_features.js +13 -10
- package/src/source/raster_dem_tile_source.js +12 -10
- package/src/source/raster_tile_source.js +13 -9
- package/src/source/resources/glyphs.js +2 -3
- package/src/source/resources/index.js +2 -4
- package/src/source/rtl_text_plugin.js +8 -8
- package/src/source/source.js +9 -15
- package/src/source/source_cache.js +105 -47
- package/src/source/source_state.js +37 -14
- package/src/source/tile.js +38 -23
- package/src/source/tile_bounds.js +15 -8
- package/src/source/tile_cache.js +2 -2
- package/src/source/tile_id.js +30 -23
- package/src/source/vector_tile_source.js +10 -8
- package/src/source/vector_tile_worker_source.js +4 -4
- package/src/source/worker_tile.js +24 -22
- package/src/style/create_style_layer.js +11 -11
- package/src/style/evaluation_parameters.js +4 -6
- package/src/style/light.js +5 -5
- package/src/style/load_sprite.js +6 -6
- package/src/style/parse_glyph_pbf.js +21 -17
- package/src/style/pauseable_placement.js +3 -4
- package/src/style/properties.js +21 -44
- package/src/style/query_utils.js +4 -10
- package/src/style/style.js +58 -33
- package/src/style/style_layer/background_style_layer.js +3 -4
- package/src/style/style_layer/background_style_layer_properties.js +2 -2
- package/src/style/style_layer/circle_style_layer.js +12 -9
- package/src/style/style_layer/circle_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_extrusion_style_layer.js +16 -13
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_style_layer.js +6 -7
- package/src/style/style_layer/fill_style_layer_properties.js +2 -2
- package/src/style/style_layer/heatmap_style_layer.js +5 -6
- package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
- package/src/style/style_layer/hillshade_style_layer.js +3 -4
- package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
- package/src/style/style_layer/line_style_layer.js +10 -11
- package/src/style/style_layer/line_style_layer_properties.js +5 -5
- package/src/style/style_layer/raster_style_layer.js +3 -4
- package/src/style/style_layer/raster_style_layer_properties.js +2 -2
- package/src/style/style_layer/symbol_style_layer.js +7 -8
- package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
- package/src/style/style_layer.js +21 -20
- package/src/style/style_layer_index.js +2 -2
- package/src/style/zoom_history.js +1 -1
- package/src/style-spec/error/parsing_error.js +1 -1
- package/src/style-spec/error/validation_error.js +5 -3
- package/src/style-spec/feature_filter/convert.js +17 -9
- package/src/style-spec/feature_filter/index.js +13 -9
- package/src/style-spec/util/eval_support.js +2 -2
- package/src/style-spec/util/ref_properties.js +1 -1
- package/src/symbol/anchor.js +2 -2
- package/src/symbol/check_max_angle.js +13 -5
- package/src/symbol/clip_line.js +2 -3
- package/src/symbol/collision_feature.js +8 -4
- package/src/symbol/collision_index.js +5 -7
- package/src/symbol/cross_tile_symbol_index.js +5 -5
- package/src/symbol/get_anchors.js +15 -8
- package/src/symbol/grid_index.js +5 -3
- package/src/symbol/mergelines.js +2 -2
- package/src/symbol/opacity_state.js +1 -1
- package/src/symbol/placement.js +25 -20
- package/src/symbol/projection.js +29 -28
- package/src/symbol/quads.js +10 -12
- package/src/symbol/shaping.js +27 -19
- package/src/symbol/symbol_layout.js +17 -21
- package/src/symbol/symbol_size.js +13 -12
- package/src/symbol/transform_text.js +3 -3
- package/src/ui/camera.js +34 -18
- package/src/ui/map.js +53 -33
- package/src/util/async.js +11 -5
- package/src/util/browser.js +1 -1
- package/src/util/callback.js +3 -9
- package/src/util/classify_rings.js +13 -8
- package/src/util/color_ramp.js +3 -3
- package/src/util/config.js +4 -4
- package/src/util/dictionary_coder.js +2 -3
- package/src/util/dom.js +7 -3
- package/src/util/find_pole_of_inaccessibility.js +29 -14
- package/src/util/group_layers.js +1 -1
- package/src/util/image.js +3 -8
- package/src/util/interpolate.js +1 -1
- package/src/util/intersection_tests.js +80 -42
- package/src/util/is_char_in_unicode_block.js +1 -1
- package/src/util/key.js +7 -3
- package/src/util/loader/image.js +1 -1
- package/src/util/object.js +25 -23
- package/src/util/script_detection.js +212 -91
- package/src/util/struct_array.js +8 -40
- package/src/util/task_queue.js +11 -7
- package/src/util/throttle.js +2 -2
- package/src/util/tile_cover.js +8 -5
- package/src/util/token.js +1 -1
- package/src/util/unique_id.js +2 -2
- package/src/util/util.js +21 -29
- package/src/util/vectortile_to_geojson.js +4 -2
- package/src/util/verticalize_punctuation.js +3 -7
- package/src/util/warn.js +4 -4
- package/src/util/web_worker.js +3 -3
package/src/render/draw_debug.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import glMatrix from '@mapbox/gl-matrix';
|
|
2
|
+
import { Color } from '@mapwhit/style-expressions';
|
|
3
|
+
import { PosArray } from '../data/array_types.js';
|
|
4
|
+
import EXTENT from '../data/extent.js';
|
|
5
|
+
import { LineIndexArray } from '../data/index_array_type.js';
|
|
6
|
+
import posAttributes from '../data/pos_attributes.js';
|
|
7
|
+
import SegmentVector from '../data/segment.js';
|
|
8
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
9
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
10
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
11
|
+
import { debugUniformValues } from './program/debug_program.js';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const { mat4 } = glMatrix;
|
|
14
14
|
|
|
15
|
-
function drawDebug(painter, sourceCache, coords) {
|
|
15
|
+
export default function drawDebug(painter, sourceCache, coords) {
|
|
16
16
|
for (let i = 0; i < coords.length; i++) {
|
|
17
17
|
drawDebugTile(painter, sourceCache, coords[i]);
|
|
18
18
|
}
|
|
@@ -407,7 +407,9 @@ function createTextVertices(text, left, baseline, scale) {
|
|
|
407
407
|
|
|
408
408
|
for (i = 0, len = text.length; i < len; i++) {
|
|
409
409
|
glyph = simplexFont[text[i]];
|
|
410
|
-
if (!glyph)
|
|
410
|
+
if (!glyph) {
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
411
413
|
prev = null;
|
|
412
414
|
|
|
413
415
|
for (j = 0, len2 = glyph[1].length; j < len2; j += 2) {
|
package/src/render/draw_fill.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Color } from '@mapwhit/style-expressions';
|
|
2
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
3
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
fillOutlinePatternUniformValues,
|
|
7
7
|
fillOutlineUniformValues,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
fillPatternUniformValues,
|
|
9
|
+
fillUniformValues
|
|
10
|
+
} from './program/fill_program.js';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
export default drawFill;
|
|
12
13
|
|
|
13
14
|
function drawFill(painter, sourceCache, layer, coords) {
|
|
14
15
|
const color = layer._paint.get('fill-color');
|
|
@@ -79,10 +80,14 @@ function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode
|
|
|
79
80
|
|
|
80
81
|
for (const coord of coords) {
|
|
81
82
|
const tile = sourceCache.getTile(coord);
|
|
82
|
-
if (image && !tile.patternsLoaded())
|
|
83
|
+
if (image && !tile.patternsLoaded()) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
83
86
|
|
|
84
87
|
const bucket = tile.getBucket(layer);
|
|
85
|
-
if (!bucket)
|
|
88
|
+
if (!bucket) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
86
91
|
|
|
87
92
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
88
93
|
const program = painter.useProgram(programName, programConfiguration);
|
|
@@ -97,7 +102,9 @@ function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode
|
|
|
97
102
|
if (constantPattern && tile.imageAtlas) {
|
|
98
103
|
const posTo = tile.imageAtlas.patternPositions[constantPattern.to];
|
|
99
104
|
const posFrom = tile.imageAtlas.patternPositions[constantPattern.from];
|
|
100
|
-
if (posTo && posFrom)
|
|
105
|
+
if (posTo && posFrom) {
|
|
106
|
+
programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
const tileMatrix = painter.translatePosMatrix(
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
module.exports = draw;
|
|
1
|
+
import ColorMode from '../gl/color_mode.js';
|
|
2
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
3
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
4
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
5
|
+
import { fillExtrusionPatternUniformValues, fillExtrusionUniformValues } from './program/fill_extrusion_program.js';
|
|
6
|
+
export default draw;
|
|
8
7
|
|
|
9
8
|
function draw(painter, source, layer, coords) {
|
|
10
9
|
const opacity = layer._paint.get('fill-extrusion-opacity');
|
|
@@ -51,7 +50,9 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
|
|
|
51
50
|
for (const coord of coords) {
|
|
52
51
|
const tile = source.getTile(coord);
|
|
53
52
|
const bucket = tile.getBucket(layer);
|
|
54
|
-
if (!bucket)
|
|
53
|
+
if (!bucket) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
55
56
|
|
|
56
57
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
57
58
|
const program = painter.useProgram(image ? 'fillExtrusionPattern' : 'fillExtrusion', programConfiguration);
|
|
@@ -66,7 +67,9 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
|
|
|
66
67
|
if (constantPattern && tile.imageAtlas) {
|
|
67
68
|
const posTo = tile.imageAtlas.patternPositions[constantPattern.to];
|
|
68
69
|
const posFrom = tile.imageAtlas.patternPositions[constantPattern.from];
|
|
69
|
-
if (posTo && posFrom)
|
|
70
|
+
if (posTo && posFrom) {
|
|
71
|
+
programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
const matrix = painter.translatePosMatrix(
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = drawHeatmap;
|
|
1
|
+
import { Color } from '@mapwhit/style-expressions';
|
|
2
|
+
import ColorMode from '../gl/color_mode.js';
|
|
3
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
4
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
5
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
6
|
+
import { heatmapTextureUniformValues, heatmapUniformValues } from './program/heatmap_program.js';
|
|
7
|
+
import Texture from './texture.js';
|
|
8
|
+
export default drawHeatmap;
|
|
10
9
|
|
|
11
10
|
function drawHeatmap(painter, sourceCache, layer, coords) {
|
|
12
11
|
if (layer._paint.get('heatmap-opacity') === 0) {
|
|
@@ -34,11 +33,15 @@ function drawHeatmap(painter, sourceCache, layer, coords) {
|
|
|
34
33
|
// Skip tiles that have uncovered parents to avoid flickering; we don't need
|
|
35
34
|
// to use complex tile masking here because the change between zoom levels is subtle,
|
|
36
35
|
// so it's fine to simply render the parent until all its 4 children are loaded
|
|
37
|
-
if (sourceCache.hasRenderableParent(coord))
|
|
36
|
+
if (sourceCache.hasRenderableParent(coord)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
38
39
|
|
|
39
40
|
const tile = sourceCache.getTile(coord);
|
|
40
41
|
const bucket = tile.getBucket(layer);
|
|
41
|
-
if (!bucket)
|
|
42
|
+
if (!bucket) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
44
47
|
const program = painter.useProgram('heatmap', programConfiguration);
|
|
@@ -128,7 +131,9 @@ function renderTextureToMap(painter, layer) {
|
|
|
128
131
|
// heatmaps: the kernel texture, prepared in the offscreen pass, and a
|
|
129
132
|
// color ramp texture.
|
|
130
133
|
const fbo = layer.heatmapFbo;
|
|
131
|
-
if (!fbo)
|
|
134
|
+
if (!fbo) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
132
137
|
context.activeTexture.set(gl.TEXTURE0);
|
|
133
138
|
gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());
|
|
134
139
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
module.exports = drawHillshade;
|
|
1
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
2
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
3
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
4
|
+
import { hillshadeUniformPrepareValues, hillshadeUniformValues } from './program/hillshade_program.js';
|
|
5
|
+
import Texture from './texture.js';
|
|
6
|
+
export default drawHillshade;
|
|
8
7
|
|
|
9
8
|
function drawHillshade(painter, sourceCache, layer, tileIDs) {
|
|
10
|
-
if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent')
|
|
9
|
+
if (painter.renderPass !== 'offscreen' && painter.renderPass !== 'translucent') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
11
12
|
|
|
12
13
|
const context = painter.context;
|
|
13
14
|
const sourceMaxZoom = sourceCache.getSource().maxzoom;
|
|
@@ -32,7 +33,9 @@ function renderHillshade(painter, tile, layer, depthMode, stencilMode, colorMode
|
|
|
32
33
|
const context = painter.context;
|
|
33
34
|
const gl = context.gl;
|
|
34
35
|
const fbo = tile.fbo;
|
|
35
|
-
if (!fbo)
|
|
36
|
+
if (!fbo) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
36
39
|
|
|
37
40
|
const program = painter.useProgram('hillshade');
|
|
38
41
|
|
package/src/render/draw_line.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
lineUniformValues,
|
|
1
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
2
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
3
|
+
import {
|
|
4
|
+
lineGradientUniformValues,
|
|
6
5
|
linePatternUniformValues,
|
|
7
6
|
lineSDFUniformValues,
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
lineUniformValues
|
|
8
|
+
} from './program/line_program.js';
|
|
9
|
+
import Texture from './texture.js';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
if (painter.renderPass !== 'translucent')
|
|
11
|
+
export default function drawLine(painter, sourceCache, layer, coords) {
|
|
12
|
+
if (painter.renderPass !== 'translucent') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
13
15
|
|
|
14
16
|
const opacity = layer._paint.get('line-opacity');
|
|
15
17
|
const width = layer._paint.get('line-width');
|
|
16
|
-
if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0)
|
|
18
|
+
if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
|
|
18
22
|
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
19
23
|
const colorMode = painter.colorModeForRenderPass();
|
|
@@ -35,18 +39,26 @@ module.exports = function drawLine(painter, sourceCache, layer, coords) {
|
|
|
35
39
|
context.activeTexture.set(gl.TEXTURE0);
|
|
36
40
|
|
|
37
41
|
let gradientTexture = layer.gradientTexture;
|
|
38
|
-
if (!layer.gradient)
|
|
39
|
-
|
|
42
|
+
if (!layer.gradient) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!gradientTexture) {
|
|
46
|
+
gradientTexture = layer.gradientTexture = new Texture(context, layer.gradient, gl.RGBA);
|
|
47
|
+
}
|
|
40
48
|
gradientTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
for (const coord of coords) {
|
|
44
52
|
const tile = sourceCache.getTile(coord);
|
|
45
53
|
|
|
46
|
-
if (image && !tile.patternsLoaded())
|
|
54
|
+
if (image && !tile.patternsLoaded()) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
47
57
|
|
|
48
58
|
const bucket = tile.getBucket(layer);
|
|
49
|
-
if (!bucket)
|
|
59
|
+
if (!bucket) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
50
62
|
|
|
51
63
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
52
64
|
const prevProgram = painter.context.program.get();
|
|
@@ -57,7 +69,9 @@ module.exports = function drawLine(painter, sourceCache, layer, coords) {
|
|
|
57
69
|
if (constantPattern && tile.imageAtlas) {
|
|
58
70
|
const posTo = tile.imageAtlas.patternPositions[constantPattern.to];
|
|
59
71
|
const posFrom = tile.imageAtlas.patternPositions[constantPattern.from];
|
|
60
|
-
if (posTo && posFrom)
|
|
72
|
+
if (posTo && posFrom) {
|
|
73
|
+
programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
74
|
+
}
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
const uniformValues = dasharray
|
|
@@ -96,4 +110,4 @@ module.exports = function drawLine(painter, sourceCache, layer, coords) {
|
|
|
96
110
|
firstTile = false;
|
|
97
111
|
// once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic
|
|
98
112
|
}
|
|
99
|
-
}
|
|
113
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports = drawRaster;
|
|
1
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
2
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
3
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
4
|
+
import ImageSource from '../source/image_source.js';
|
|
5
|
+
import browser from '../util/browser.js';
|
|
6
|
+
import { clamp } from '../util/util.js';
|
|
7
|
+
import { rasterUniformValues } from './program/raster_program.js';
|
|
8
|
+
export default drawRaster;
|
|
11
9
|
|
|
12
10
|
function drawRaster(painter, sourceCache, layer, coords) {
|
|
13
|
-
if (painter.renderPass !== 'translucent')
|
|
14
|
-
|
|
11
|
+
if (painter.renderPass !== 'translucent') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (layer._paint.get('raster-opacity') === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
const context = painter.context;
|
|
17
19
|
const gl = context.gl;
|
|
@@ -131,7 +133,9 @@ function getFadeValues(tile, parentTile, sourceCache, layer, transform) {
|
|
|
131
133
|
// once they're old enough to pass the crossfading threshold
|
|
132
134
|
// (fadeDuration), unset the `refreshedUponExpiration` flag so we don't
|
|
133
135
|
// incorrectly fail to crossfade them when zooming
|
|
134
|
-
if (tile.refreshedUponExpiration && sinceTile >= 1)
|
|
136
|
+
if (tile.refreshedUponExpiration && sinceTile >= 1) {
|
|
137
|
+
tile.refreshedUponExpiration = false;
|
|
138
|
+
}
|
|
135
139
|
|
|
136
140
|
if (parentTile) {
|
|
137
141
|
return {
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import glMatrix from '@mapbox/gl-matrix';
|
|
2
|
+
import CullFaceMode from '../gl/cull_face_mode.js';
|
|
3
|
+
import DepthMode from '../gl/depth_mode.js';
|
|
4
|
+
import StencilMode from '../gl/stencil_mode.js';
|
|
5
|
+
import pixelsToTileUnits from '../source/pixels_to_tile_units.js';
|
|
6
|
+
import properties from '../style/style_layer/symbol_style_layer_properties.js';
|
|
7
|
+
import * as symbolProjection from '../symbol/projection.js';
|
|
8
|
+
import * as symbolSize from '../symbol/symbol_size.js';
|
|
9
|
+
import drawCollisionDebug from './draw_collision_debug.js';
|
|
10
|
+
import { symbolIconUniformValues, symbolSDFUniformValues } from './program/symbol_program.js';
|
|
11
|
+
|
|
12
|
+
const { mat4 } = glMatrix;
|
|
7
13
|
const identityMat4 = mat4.identity(new Float32Array(16));
|
|
8
|
-
const properties = require('../style/style_layer/symbol_style_layer_properties');
|
|
9
14
|
const symbolLayoutProperties = properties.layout;
|
|
10
|
-
const StencilMode = require('../gl/stencil_mode');
|
|
11
|
-
const DepthMode = require('../gl/depth_mode');
|
|
12
|
-
const CullFaceMode = require('../gl/cull_face_mode');
|
|
13
|
-
const { symbolIconUniformValues, symbolSDFUniformValues } = require('./program/symbol_program');
|
|
14
|
-
|
|
15
|
-
module.exports = drawSymbols;
|
|
16
15
|
|
|
17
|
-
function drawSymbols(painter, sourceCache, layer, coords) {
|
|
18
|
-
if (painter.renderPass !== 'translucent')
|
|
16
|
+
export default function drawSymbols(painter, sourceCache, layer, coords) {
|
|
17
|
+
if (painter.renderPass !== 'translucent') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
19
20
|
|
|
20
21
|
// Disable the stencil test so that labels aren't clipped to tile boundaries.
|
|
21
22
|
const stencilMode = StencilMode.disabled;
|
|
@@ -94,9 +95,13 @@ function drawLayerSymbols(
|
|
|
94
95
|
for (const coord of coords) {
|
|
95
96
|
const tile = sourceCache.getTile(coord);
|
|
96
97
|
const bucket = tile.getBucket(layer);
|
|
97
|
-
if (!bucket)
|
|
98
|
+
if (!bucket) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
98
101
|
const buffers = isText ? bucket.text : bucket.icon;
|
|
99
|
-
if (!buffers || !buffers.segments.get().length)
|
|
102
|
+
if (!buffers || !buffers.segments.get().length) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
100
105
|
const programConfiguration = buffers.programConfigurations.get(layer.id);
|
|
101
106
|
|
|
102
107
|
const isSDF = isText || bucket.sdfIcons;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import potpack from 'potpack';
|
|
2
|
+
import { AlphaImage } from '../util/image.js';
|
|
3
3
|
|
|
4
4
|
const padding = 1;
|
|
5
5
|
|
|
@@ -14,7 +14,9 @@ class GlyphAtlas {
|
|
|
14
14
|
|
|
15
15
|
for (const id in glyphs) {
|
|
16
16
|
const src = glyphs[+id];
|
|
17
|
-
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0)
|
|
17
|
+
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
const bin = {
|
|
20
22
|
x: 0,
|
|
@@ -35,7 +37,9 @@ class GlyphAtlas {
|
|
|
35
37
|
|
|
36
38
|
for (const id in glyphs) {
|
|
37
39
|
const src = glyphs[+id];
|
|
38
|
-
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0)
|
|
40
|
+
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
39
43
|
const bin = positions[stack][id].rect;
|
|
40
44
|
AlphaImage.copy(src.bitmap, image, { x: 0, y: 0 }, { x: bin.x + padding, y: bin.y + padding }, src.bitmap);
|
|
41
45
|
}
|
|
@@ -46,4 +50,4 @@ class GlyphAtlas {
|
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
export default GlyphAtlas;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import potpack from 'potpack';
|
|
2
|
+
import { RGBAImage } from '../util/image.js';
|
|
3
3
|
|
|
4
4
|
const padding = 1;
|
|
5
5
|
|
|
6
|
-
class ImagePosition {
|
|
6
|
+
export class ImagePosition {
|
|
7
7
|
constructor(paddedRect, { pixelRatio }) {
|
|
8
8
|
this.paddedRect = paddedRect;
|
|
9
9
|
this.pixelRatio = pixelRatio;
|
|
@@ -26,7 +26,7 @@ class ImagePosition {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
class ImageAtlas {
|
|
29
|
+
export default class ImageAtlas {
|
|
30
30
|
constructor(icons, patterns) {
|
|
31
31
|
const iconPositions = {};
|
|
32
32
|
const patternPositions = {};
|
|
@@ -85,6 +85,3 @@ class ImageAtlas {
|
|
|
85
85
|
this.patternPositions = patternPositions;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
ImageAtlas.ImagePosition = ImagePosition;
|
|
90
|
-
module.exports = ImageAtlas;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const assert = require('assert');
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import potpack from 'potpack';
|
|
3
|
+
import { RGBAImage } from '../util/image.js';
|
|
4
|
+
import { ImagePosition } from './image_atlas.js';
|
|
5
|
+
import Texture from './texture.js';
|
|
7
6
|
|
|
8
7
|
// When copied into the atlas texture, image data is padded by one pixel on each side. Icon
|
|
9
8
|
// images are padded with fully transparent pixels, while pattern images are padded with a
|
|
@@ -21,7 +20,7 @@ const padding = 1;
|
|
|
21
20
|
data-driven support for `*-pattern`, we'll likely use per-bucket pattern atlases, and that would be a good time
|
|
22
21
|
to refactor this.
|
|
23
22
|
*/
|
|
24
|
-
class ImageManager {
|
|
23
|
+
export default class ImageManager {
|
|
25
24
|
#loadedState = Promise.withResolvers();
|
|
26
25
|
#imageQueue = new Map();
|
|
27
26
|
constructor() {
|
|
@@ -165,5 +164,3 @@ class ImageManager {
|
|
|
165
164
|
this.dirty = true;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
module.exports = ImageManager;
|
package/src/render/line_atlas.js
CHANGED