@mapwhit/tilerenderer 0.52.1 → 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.
Files changed (249) hide show
  1. package/README.md +7 -0
  2. package/build/min/package.json +2 -1
  3. package/build/min/src/shaders/_prelude.fragment.glsl.js +2 -2
  4. package/build/min/src/shaders/_prelude.vertex.glsl.js +2 -2
  5. package/build/min/src/shaders/background.fragment.glsl.js +2 -2
  6. package/build/min/src/shaders/background.vertex.glsl.js +1 -1
  7. package/build/min/src/shaders/background_pattern.fragment.glsl.js +2 -2
  8. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
  9. package/build/min/src/shaders/circle.fragment.glsl.js +2 -2
  10. package/build/min/src/shaders/circle.vertex.glsl.js +2 -2
  11. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
  12. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
  13. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
  14. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
  15. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
  16. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
  17. package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
  18. package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
  19. package/build/min/src/shaders/fill.fragment.glsl.js +2 -2
  20. package/build/min/src/shaders/fill.vertex.glsl.js +2 -2
  21. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +2 -2
  22. package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +2 -2
  23. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +2 -2
  24. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +2 -2
  25. package/build/min/src/shaders/fill_outline.fragment.glsl.js +2 -2
  26. package/build/min/src/shaders/fill_outline.vertex.glsl.js +2 -2
  27. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +2 -2
  28. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +2 -2
  29. package/build/min/src/shaders/fill_pattern.fragment.glsl.js +2 -2
  30. package/build/min/src/shaders/fill_pattern.vertex.glsl.js +2 -2
  31. package/build/min/src/shaders/heatmap.fragment.glsl.js +2 -2
  32. package/build/min/src/shaders/heatmap.vertex.glsl.js +2 -2
  33. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +2 -2
  34. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
  35. package/build/min/src/shaders/hillshade.fragment.glsl.js +2 -2
  36. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
  37. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +2 -2
  38. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
  39. package/build/min/src/shaders/line.fragment.glsl.js +2 -2
  40. package/build/min/src/shaders/line.vertex.glsl.js +2 -2
  41. package/build/min/src/shaders/line_gradient.fragment.glsl.js +2 -2
  42. package/build/min/src/shaders/line_gradient.vertex.glsl.js +2 -2
  43. package/build/min/src/shaders/line_pattern.fragment.glsl.js +2 -2
  44. package/build/min/src/shaders/line_pattern.vertex.glsl.js +2 -2
  45. package/build/min/src/shaders/line_sdf.fragment.glsl.js +2 -2
  46. package/build/min/src/shaders/line_sdf.vertex.glsl.js +2 -2
  47. package/build/min/src/shaders/raster.fragment.glsl.js +2 -2
  48. package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
  49. package/build/min/src/shaders/symbol_icon.fragment.glsl.js +2 -2
  50. package/build/min/src/shaders/symbol_icon.vertex.glsl.js +2 -2
  51. package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +2 -2
  52. package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +2 -2
  53. package/package.json +5 -4
  54. package/src/data/array_types.js +55 -117
  55. package/src/data/bucket/circle_attributes.js +2 -4
  56. package/src/data/bucket/circle_bucket.js +19 -16
  57. package/src/data/bucket/fill_attributes.js +2 -4
  58. package/src/data/bucket/fill_bucket.js +38 -27
  59. package/src/data/bucket/fill_extrusion_attributes.js +2 -4
  60. package/src/data/bucket/fill_extrusion_bucket.js +56 -37
  61. package/src/data/bucket/heatmap_bucket.js +2 -11
  62. package/src/data/bucket/line_attributes.js +2 -4
  63. package/src/data/bucket/line_bucket.js +208 -163
  64. package/src/data/bucket/pattern_attributes.js +2 -4
  65. package/src/data/bucket/pattern_bucket_features.js +7 -9
  66. package/src/data/bucket/symbol_attributes.js +12 -26
  67. package/src/data/bucket/symbol_bucket.js +174 -323
  68. package/src/data/bucket/symbol_buffers.js +62 -0
  69. package/src/data/bucket/symbol_collision_buffers.js +33 -0
  70. package/src/data/bucket.js +26 -25
  71. package/src/data/dem_data.js +11 -10
  72. package/src/data/extent.js +1 -1
  73. package/src/data/feature_index.js +38 -28
  74. package/src/data/index_array_type.js +1 -6
  75. package/src/data/load_geometry.js +6 -9
  76. package/src/data/pos_attributes.js +2 -3
  77. package/src/data/program_configuration.js +47 -38
  78. package/src/data/raster_bounds_attributes.js +2 -2
  79. package/src/data/segment.js +4 -7
  80. package/src/geo/coordinate.js +1 -1
  81. package/src/geo/lng_lat.js +3 -3
  82. package/src/geo/lng_lat_bounds.js +8 -4
  83. package/src/geo/transform.js +69 -30
  84. package/src/gl/color_mode.js +2 -2
  85. package/src/gl/context.js +28 -29
  86. package/src/gl/cull_face_mode.js +1 -1
  87. package/src/gl/depth_mode.js +1 -1
  88. package/src/gl/framebuffer.js +8 -4
  89. package/src/gl/index_buffer.js +2 -2
  90. package/src/gl/stencil_mode.js +1 -1
  91. package/src/gl/value.js +33 -68
  92. package/src/gl/vertex_buffer.js +2 -2
  93. package/src/index.js +49 -25
  94. package/src/render/draw_background.js +17 -12
  95. package/src/render/draw_circle.js +15 -12
  96. package/src/render/draw_collision_debug.js +11 -8
  97. package/src/render/draw_debug.js +16 -14
  98. package/src/render/draw_fill.js +27 -20
  99. package/src/render/draw_fill_extrusion.js +20 -17
  100. package/src/render/draw_heatmap.js +21 -16
  101. package/src/render/draw_hillshade.js +12 -9
  102. package/src/render/draw_line.js +36 -22
  103. package/src/render/draw_raster.js +22 -18
  104. package/src/render/draw_symbol.js +38 -33
  105. package/src/render/glyph_atlas.js +9 -8
  106. package/src/render/glyph_manager.js +2 -3
  107. package/src/render/image_atlas.js +4 -11
  108. package/src/render/image_manager.js +39 -28
  109. package/src/render/line_atlas.js +2 -2
  110. package/src/render/painter.js +78 -61
  111. package/src/render/program/background_program.js +6 -13
  112. package/src/render/program/circle_program.js +8 -10
  113. package/src/render/program/clipping_mask_program.js +3 -5
  114. package/src/render/program/collision_program.js +4 -6
  115. package/src/render/program/debug_program.js +3 -5
  116. package/src/render/program/fill_extrusion_program.js +9 -15
  117. package/src/render/program/fill_program.js +10 -21
  118. package/src/render/program/heatmap_program.js +9 -15
  119. package/src/render/program/hillshade_program.js +16 -22
  120. package/src/render/program/line_program.js +14 -25
  121. package/src/render/program/pattern.js +5 -7
  122. package/src/render/program/program_uniforms.js +13 -20
  123. package/src/render/program/raster_program.js +9 -11
  124. package/src/render/program/symbol_program.js +5 -7
  125. package/src/render/program.js +5 -6
  126. package/src/render/texture.js +1 -1
  127. package/src/render/tile_mask.js +6 -4
  128. package/src/render/uniform_binding.js +9 -20
  129. package/src/render/vertex_array_object.js +5 -3
  130. package/src/shaders/encode_attribute.js +2 -6
  131. package/src/shaders/index.js +103 -51
  132. package/src/source/geojson_source.js +25 -30
  133. package/src/source/geojson_worker_source.js +46 -74
  134. package/src/source/geojson_wrapper.js +13 -5
  135. package/src/source/image_source.js +17 -28
  136. package/src/source/load_tilejson.js +3 -3
  137. package/src/source/pixels_to_tile_units.js +3 -3
  138. package/src/source/query_features.js +17 -15
  139. package/src/source/raster_dem_tile_source.js +54 -71
  140. package/src/source/raster_tile_source.js +14 -15
  141. package/src/source/resources/glyphs.js +4 -5
  142. package/src/source/resources/index.js +4 -12
  143. package/src/source/rtl_text_plugin.js +62 -35
  144. package/src/source/source.js +14 -22
  145. package/src/source/source_cache.js +221 -179
  146. package/src/source/source_state.js +125 -13
  147. package/src/source/tile.js +67 -66
  148. package/src/source/tile_bounds.js +36 -29
  149. package/src/source/tile_cache.js +2 -2
  150. package/src/source/tile_id.js +30 -26
  151. package/src/source/vector_tile_source.js +23 -21
  152. package/src/source/vector_tile_worker_source.js +22 -26
  153. package/src/source/worker_tile.js +139 -134
  154. package/src/style/create_style_layer.js +11 -11
  155. package/src/style/evaluation_parameters.js +4 -6
  156. package/src/style/light.js +5 -5
  157. package/src/style/load_sprite.js +6 -6
  158. package/src/style/parse_glyph_pbf.js +21 -17
  159. package/src/style/pauseable_placement.js +7 -9
  160. package/src/style/properties.js +21 -51
  161. package/src/style/query_utils.js +7 -13
  162. package/src/style/style.js +314 -221
  163. package/src/style/style_layer/background_style_layer.js +3 -4
  164. package/src/style/style_layer/background_style_layer_properties.js +2 -2
  165. package/src/style/style_layer/circle_style_layer.js +25 -20
  166. package/src/style/style_layer/circle_style_layer_properties.js +2 -2
  167. package/src/style/style_layer/fill_extrusion_style_layer.js +55 -37
  168. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
  169. package/src/style/style_layer/fill_style_layer.js +11 -12
  170. package/src/style/style_layer/fill_style_layer_properties.js +2 -2
  171. package/src/style/style_layer/heatmap_style_layer.js +6 -7
  172. package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
  173. package/src/style/style_layer/hillshade_style_layer.js +4 -5
  174. package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
  175. package/src/style/style_layer/line_style_layer.js +33 -30
  176. package/src/style/style_layer/line_style_layer_properties.js +5 -5
  177. package/src/style/style_layer/raster_style_layer.js +3 -4
  178. package/src/style/style_layer/raster_style_layer_properties.js +2 -2
  179. package/src/style/style_layer/symbol_style_layer.js +20 -21
  180. package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
  181. package/src/style/style_layer.js +66 -47
  182. package/src/style/style_layer_index.js +17 -42
  183. package/src/style/zoom_history.js +1 -1
  184. package/src/style-spec/error/parsing_error.js +1 -1
  185. package/src/style-spec/error/validation_error.js +5 -3
  186. package/src/style-spec/feature_filter/convert.js +17 -9
  187. package/src/style-spec/feature_filter/index.js +13 -9
  188. package/src/style-spec/util/eval_support.js +2 -2
  189. package/src/style-spec/util/ref_properties.js +1 -1
  190. package/src/symbol/anchor.js +2 -6
  191. package/src/symbol/check_max_angle.js +13 -5
  192. package/src/symbol/clip_line.js +2 -3
  193. package/src/symbol/collision_feature.js +8 -4
  194. package/src/symbol/collision_index.js +5 -7
  195. package/src/symbol/cross_tile_symbol_index.js +7 -10
  196. package/src/symbol/get_anchors.js +15 -8
  197. package/src/symbol/grid_index.js +5 -3
  198. package/src/symbol/mergelines.js +2 -2
  199. package/src/symbol/opacity_state.js +1 -5
  200. package/src/symbol/placement.js +28 -23
  201. package/src/symbol/projection.js +29 -28
  202. package/src/symbol/quads.js +14 -16
  203. package/src/symbol/shaping.js +27 -19
  204. package/src/symbol/symbol_layout.js +24 -28
  205. package/src/symbol/symbol_size.js +13 -12
  206. package/src/symbol/transform_text.js +4 -4
  207. package/src/ui/camera.js +34 -18
  208. package/src/ui/map.js +102 -44
  209. package/src/util/async.js +11 -5
  210. package/src/util/browser.js +1 -1
  211. package/src/util/callback.js +3 -9
  212. package/src/util/classify_rings.js +13 -8
  213. package/src/util/color_ramp.js +3 -3
  214. package/src/util/config.js +4 -4
  215. package/src/util/dictionary_coder.js +2 -3
  216. package/src/util/dom.js +7 -3
  217. package/src/util/find_pole_of_inaccessibility.js +29 -14
  218. package/src/util/group_layers.js +41 -0
  219. package/src/util/image.js +3 -13
  220. package/src/util/interpolate.js +1 -1
  221. package/src/util/intersection_tests.js +80 -42
  222. package/src/util/is_char_in_unicode_block.js +1 -1
  223. package/src/util/key.js +25 -0
  224. package/src/util/loader/image.js +1 -1
  225. package/src/util/object.js +33 -76
  226. package/src/util/script_detection.js +212 -91
  227. package/src/util/struct_array.js +8 -40
  228. package/src/util/task_queue.js +11 -7
  229. package/src/util/throttle.js +2 -2
  230. package/src/util/tile_cover.js +8 -5
  231. package/src/util/token.js +1 -1
  232. package/src/util/unique_id.js +2 -2
  233. package/src/util/util.js +21 -29
  234. package/src/util/vectortile_to_geojson.js +4 -2
  235. package/src/util/verticalize_punctuation.js +3 -7
  236. package/src/util/warn.js +4 -4
  237. package/src/util/web_worker.js +3 -3
  238. package/src/worker.js +1 -4
  239. package/src/source/resources/images.js +0 -68
  240. package/src/source/worker.js +0 -110
  241. package/src/source/worker_source.js +0 -14
  242. package/src/style-spec/deref.js +0 -51
  243. package/src/style-spec/group_by_layout.js +0 -46
  244. package/src/util/actor.js +0 -108
  245. package/src/util/dispatcher.js +0 -65
  246. package/src/util/global_worker_pool.js +0 -15
  247. package/src/util/transfer_registry.js +0 -168
  248. package/src/util/web_worker_transfer.js +0 -43
  249. package/src/util/worker_pool.js +0 -41
@@ -1,13 +1,12 @@
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;
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
- const opacity = layer.paint.get('fill-extrusion-opacity');
9
+ const opacity = layer._paint.get('fill-extrusion-opacity');
11
10
  if (opacity === 0) {
12
11
  return;
13
12
  }
@@ -15,7 +14,7 @@ function draw(painter, source, layer, coords) {
15
14
  if (painter.renderPass === 'translucent') {
16
15
  const depthMode = new DepthMode(painter.context.gl.LEQUAL, DepthMode.ReadWrite, painter.depthRangeFor3D);
17
16
 
18
- if (opacity === 1 && !layer.paint.get('fill-extrusion-pattern').constantOr(1)) {
17
+ if (opacity === 1 && !layer._paint.get('fill-extrusion-pattern').constantOr(1)) {
19
18
  const colorMode = painter.colorModeForRenderPass();
20
19
  drawExtrusionTiles(painter, source, layer, coords, depthMode, StencilMode.disabled, colorMode);
21
20
  } else {
@@ -43,15 +42,17 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
43
42
  const context = painter.context;
44
43
  const gl = context.gl;
45
44
 
46
- const patternProperty = layer.paint.get('fill-extrusion-pattern');
45
+ const patternProperty = layer._paint.get('fill-extrusion-pattern');
47
46
  const image = patternProperty.constantOr(1);
48
47
  const crossfade = layer.getCrossfadeParameters();
49
- const opacity = layer.paint.get('fill-extrusion-opacity');
48
+ const opacity = layer._paint.get('fill-extrusion-opacity');
50
49
 
51
50
  for (const coord of coords) {
52
51
  const tile = source.getTile(coord);
53
52
  const bucket = tile.getBucket(layer);
54
- if (!bucket) continue;
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,17 +67,19 @@ 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) programConfiguration.setConstantPatternPositions(posTo, posFrom);
70
+ if (posTo && posFrom) {
71
+ programConfiguration.setConstantPatternPositions(posTo, posFrom);
72
+ }
70
73
  }
71
74
 
72
75
  const matrix = painter.translatePosMatrix(
73
76
  coord.posMatrix,
74
77
  tile,
75
- layer.paint.get('fill-extrusion-translate'),
76
- layer.paint.get('fill-extrusion-translate-anchor')
78
+ layer._paint.get('fill-extrusion-translate'),
79
+ layer._paint.get('fill-extrusion-translate-anchor')
77
80
  );
78
81
 
79
- const shouldUseVerticalGradient = layer.paint.get('fill-extrusion-vertical-gradient');
82
+ const shouldUseVerticalGradient = layer._paint.get('fill-extrusion-vertical-gradient');
80
83
  const uniformValues = image
81
84
  ? fillExtrusionPatternUniformValues(matrix, painter, shouldUseVerticalGradient, opacity, coord, crossfade, tile)
82
85
  : fillExtrusionUniformValues(matrix, painter, shouldUseVerticalGradient, opacity);
@@ -93,7 +96,7 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
93
96
  bucket.layoutVertexBuffer,
94
97
  bucket.indexBuffer,
95
98
  bucket.segments,
96
- layer.paint,
99
+ layer._paint,
97
100
  painter.transform.zoom,
98
101
  programConfiguration
99
102
  );
@@ -1,15 +1,14 @@
1
- const Texture = require('./texture');
2
- const { Color } = require('@mapwhit/style-expressions');
3
- const DepthMode = require('../gl/depth_mode');
4
- const StencilMode = require('../gl/stencil_mode');
5
- const ColorMode = require('../gl/color_mode');
6
- const CullFaceMode = require('../gl/cull_face_mode');
7
- const { heatmapUniformValues, heatmapTextureUniformValues } = require('./program/heatmap_program');
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
- if (layer.paint.get('heatmap-opacity') === 0) {
11
+ if (layer._paint.get('heatmap-opacity') === 0) {
13
12
  return;
14
13
  }
15
14
 
@@ -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)) continue;
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) continue;
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);
@@ -51,12 +54,12 @@ function drawHeatmap(painter, sourceCache, layer, coords) {
51
54
  stencilMode,
52
55
  colorMode,
53
56
  CullFaceMode.disabled,
54
- heatmapUniformValues(coord.posMatrix, tile, zoom, layer.paint.get('heatmap-intensity')),
57
+ heatmapUniformValues(coord.posMatrix, tile, zoom, layer._paint.get('heatmap-intensity')),
55
58
  layer.id,
56
59
  bucket.layoutVertexBuffer,
57
60
  bucket.indexBuffer,
58
61
  bucket.segments,
59
- layer.paint,
62
+ layer._paint,
60
63
  painter.transform.zoom,
61
64
  programConfiguration
62
65
  );
@@ -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) return;
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
 
@@ -153,7 +158,7 @@ function renderTextureToMap(painter, layer) {
153
158
  painter.viewportBuffer,
154
159
  painter.quadTriangleIndexBuffer,
155
160
  painter.viewportSegments,
156
- layer.paint,
161
+ layer._paint,
157
162
  painter.transform.zoom
158
163
  );
159
164
  }
@@ -1,13 +1,14 @@
1
- const Texture = require('./texture');
2
- const StencilMode = require('../gl/stencil_mode');
3
- const DepthMode = require('../gl/depth_mode');
4
- const CullFaceMode = require('../gl/cull_face_mode');
5
- const { hillshadeUniformValues, hillshadeUniformPrepareValues } = require('./program/hillshade_program');
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') return;
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) return;
36
+ if (!fbo) {
37
+ return;
38
+ }
36
39
 
37
40
  const program = painter.useProgram('hillshade');
38
41
 
@@ -1,27 +1,31 @@
1
- const DepthMode = require('../gl/depth_mode');
2
- const Texture = require('./texture');
3
- const CullFaceMode = require('../gl/cull_face_mode');
4
- const {
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
- lineGradientUniformValues
9
- } = require('./program/line_program');
7
+ lineUniformValues
8
+ } from './program/line_program.js';
9
+ import Texture from './texture.js';
10
10
 
11
- module.exports = function drawLine(painter, sourceCache, layer, coords) {
12
- if (painter.renderPass !== 'translucent') return;
11
+ export default function drawLine(painter, sourceCache, layer, coords) {
12
+ if (painter.renderPass !== 'translucent') {
13
+ return;
14
+ }
13
15
 
14
- const opacity = layer.paint.get('line-opacity');
15
- const width = layer.paint.get('line-width');
16
- if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;
16
+ const opacity = layer._paint.get('line-opacity');
17
+ const width = layer._paint.get('line-width');
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();
20
24
 
21
- const dasharray = layer.paint.get('line-dasharray');
22
- const patternProperty = layer.paint.get('line-pattern');
25
+ const dasharray = layer._paint.get('line-dasharray');
26
+ const patternProperty = layer._paint.get('line-pattern');
23
27
  const image = patternProperty.constantOr(1);
24
- const gradient = layer.paint.get('line-gradient');
28
+ const gradient = layer._paint.get('line-gradient');
25
29
  const crossfade = layer.getCrossfadeParameters();
26
30
 
27
31
  const programId = dasharray ? 'lineSDF' : image ? 'linePattern' : gradient ? 'lineGradient' : 'line';
@@ -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) return;
39
- if (!gradientTexture) gradientTexture = layer.gradientTexture = new Texture(context, layer.gradient, gl.RGBA);
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()) continue;
54
+ if (image && !tile.patternsLoaded()) {
55
+ continue;
56
+ }
47
57
 
48
58
  const bucket = tile.getBucket(layer);
49
- if (!bucket) continue;
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) programConfiguration.setConstantPatternPositions(posTo, posFrom);
72
+ if (posTo && posFrom) {
73
+ programConfiguration.setConstantPatternPositions(posTo, posFrom);
74
+ }
61
75
  }
62
76
 
63
77
  const uniformValues = dasharray
@@ -88,7 +102,7 @@ module.exports = function drawLine(painter, sourceCache, layer, coords) {
88
102
  bucket.layoutVertexBuffer,
89
103
  bucket.indexBuffer,
90
104
  bucket.segments,
91
- layer.paint,
105
+ layer._paint,
92
106
  painter.transform.zoom,
93
107
  programConfiguration
94
108
  );
@@ -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
- const { clamp } = require('../util/util');
2
-
3
- const ImageSource = require('../source/image_source');
4
- const browser = require('../util/browser');
5
- const StencilMode = require('../gl/stencil_mode');
6
- const DepthMode = require('../gl/depth_mode');
7
- const CullFaceMode = require('../gl/cull_face_mode');
8
- const { rasterUniformValues } = require('./program/raster_program');
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') return;
14
- if (layer.paint.get('raster-opacity') === 0) return;
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;
@@ -27,14 +29,14 @@ function drawRaster(painter, sourceCache, layer, coords) {
27
29
  // Use gl.LESS to prevent double drawing in areas where tiles overlap.
28
30
  const depthMode = painter.depthModeForSublayer(
29
31
  coord.overscaledZ - minTileZ,
30
- layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly,
32
+ layer._paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly,
31
33
  gl.LESS
32
34
  );
33
35
 
34
36
  const tile = sourceCache.getTile(coord);
35
37
  const posMatrix = painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);
36
38
 
37
- tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));
39
+ tile.registerFadeDuration(layer._paint.get('raster-fade-duration'));
38
40
 
39
41
  const parentTile = sourceCache.findLoadedParent(coord, 0);
40
42
  const fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform);
@@ -42,7 +44,7 @@ function drawRaster(painter, sourceCache, layer, coords) {
42
44
  let parentScaleBy;
43
45
  let parentTL;
44
46
 
45
- const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;
47
+ const textureFilter = layer._paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;
46
48
 
47
49
  context.activeTexture.set(gl.TEXTURE0);
48
50
  tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
@@ -86,7 +88,7 @@ function drawRaster(painter, sourceCache, layer, coords) {
86
88
  tile.maskedBoundsBuffer,
87
89
  tile.maskedIndexBuffer,
88
90
  tile.segments,
89
- layer.paint,
91
+ layer._paint,
90
92
  painter.transform.zoom
91
93
  );
92
94
  } else {
@@ -108,7 +110,7 @@ function drawRaster(painter, sourceCache, layer, coords) {
108
110
  }
109
111
 
110
112
  function getFadeValues(tile, parentTile, sourceCache, layer, transform) {
111
- const fadeDuration = layer.paint.get('raster-fade-duration');
113
+ const fadeDuration = layer._paint.get('raster-fade-duration');
112
114
 
113
115
  if (fadeDuration > 0) {
114
116
  const now = browser.now();
@@ -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) tile.refreshedUponExpiration = false;
136
+ if (tile.refreshedUponExpiration && sinceTile >= 1) {
137
+ tile.refreshedUponExpiration = false;
138
+ }
135
139
 
136
140
  if (parentTile) {
137
141
  return {
@@ -1,55 +1,56 @@
1
- const drawCollisionDebug = require('./draw_collision_debug');
2
-
3
- const pixelsToTileUnits = require('../source/pixels_to_tile_units');
4
- const symbolProjection = require('../symbol/projection');
5
- const symbolSize = require('../symbol/symbol_size');
6
- const { mat4 } = require('@mapbox/gl-matrix');
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') return;
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;
22
23
  const colorMode = painter.colorModeForRenderPass();
23
24
 
24
- if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {
25
+ if (layer._paint.get('icon-opacity').constantOr(1) !== 0) {
25
26
  drawLayerSymbols(
26
27
  painter,
27
28
  sourceCache,
28
29
  layer,
29
30
  coords,
30
31
  false,
31
- layer.paint.get('icon-translate'),
32
- layer.paint.get('icon-translate-anchor'),
33
- layer.layout.get('icon-rotation-alignment'),
34
- layer.layout.get('icon-pitch-alignment'),
35
- layer.layout.get('icon-keep-upright'),
32
+ layer._paint.get('icon-translate'),
33
+ layer._paint.get('icon-translate-anchor'),
34
+ layer._layout.get('icon-rotation-alignment'),
35
+ layer._layout.get('icon-pitch-alignment'),
36
+ layer._layout.get('icon-keep-upright'),
36
37
  stencilMode,
37
38
  colorMode
38
39
  );
39
40
  }
40
41
 
41
- if (layer.paint.get('text-opacity').constantOr(1) !== 0) {
42
+ if (layer._paint.get('text-opacity').constantOr(1) !== 0) {
42
43
  drawLayerSymbols(
43
44
  painter,
44
45
  sourceCache,
45
46
  layer,
46
47
  coords,
47
48
  true,
48
- layer.paint.get('text-translate'),
49
- layer.paint.get('text-translate-anchor'),
50
- layer.layout.get('text-rotation-alignment'),
51
- layer.layout.get('text-pitch-alignment'),
52
- layer.layout.get('text-keep-upright'),
49
+ layer._paint.get('text-translate'),
50
+ layer._paint.get('text-translate-anchor'),
51
+ layer._layout.get('text-rotation-alignment'),
52
+ layer._layout.get('text-pitch-alignment'),
53
+ layer._layout.get('text-keep-upright'),
53
54
  stencilMode,
54
55
  colorMode
55
56
  );
@@ -80,7 +81,7 @@ function drawLayerSymbols(
80
81
 
81
82
  const rotateWithMap = rotationAlignment === 'map';
82
83
  const pitchWithMap = pitchAlignment === 'map';
83
- const alongLine = rotateWithMap && layer.layout.get('symbol-placement') !== 'point';
84
+ const alongLine = rotateWithMap && layer._layout.get('symbol-placement') !== 'point';
84
85
  // Line label rotation happens in `updateLineLabels`
85
86
  // Pitched point labels are automatically rotated by the labelPlaneMatrix projection
86
87
  // Unpitched point labels need to have their rotation applied after projection
@@ -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) continue;
98
+ if (!bucket) {
99
+ continue;
100
+ }
98
101
  const buffers = isText ? bucket.text : bucket.icon;
99
- if (!buffers || !buffers.segments.get().length) continue;
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;
@@ -119,7 +124,7 @@ function drawLayerSymbols(
119
124
  tile.glyphAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
120
125
  texSize = tile.glyphAtlasTexture.size;
121
126
  } else {
122
- const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;
127
+ const iconScaled = layer._layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;
123
128
  const iconTransformed = pitchWithMap || tr.pitch !== 0;
124
129
 
125
130
  tile.imageAtlasTexture.bind(
@@ -167,7 +172,7 @@ function drawLayerSymbols(
167
172
 
168
173
  let uniformValues;
169
174
  if (isSDF) {
170
- const hasHalo = layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
175
+ const hasHalo = layer._paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
171
176
 
172
177
  uniformValues = symbolSDFUniformValues(
173
178
  sizeData.functionType,
@@ -222,7 +227,7 @@ function drawSymbolElements(buffers, layer, painter, program, depthMode, stencil
222
227
  buffers.layoutVertexBuffer,
223
228
  buffers.indexBuffer,
224
229
  buffers.segments,
225
- layer.paint,
230
+ layer._paint,
226
231
  painter.transform.zoom,
227
232
  buffers.programConfigurations.get(layer.id),
228
233
  buffers.dynamicLayoutVertexBuffer,
@@ -1,6 +1,5 @@
1
- const { AlphaImage } = require('../util/image');
2
- const { register } = require('../util/transfer_registry');
3
- const { default: potpack } = require('potpack');
1
+ import potpack from 'potpack';
2
+ import { AlphaImage } from '../util/image.js';
4
3
 
5
4
  const padding = 1;
6
5
 
@@ -15,7 +14,9 @@ class GlyphAtlas {
15
14
 
16
15
  for (const id in glyphs) {
17
16
  const src = glyphs[+id];
18
- if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
17
+ if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) {
18
+ continue;
19
+ }
19
20
 
20
21
  const bin = {
21
22
  x: 0,
@@ -36,7 +37,9 @@ class GlyphAtlas {
36
37
 
37
38
  for (const id in glyphs) {
38
39
  const src = glyphs[+id];
39
- if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
40
+ if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) {
41
+ continue;
42
+ }
40
43
  const bin = positions[stack][id].rect;
41
44
  AlphaImage.copy(src.bitmap, image, { x: 0, y: 0 }, { x: bin.x + padding, y: bin.y + padding }, src.bitmap);
42
45
  }
@@ -47,6 +50,4 @@ class GlyphAtlas {
47
50
  }
48
51
  }
49
52
 
50
- register('GlyphAtlas', GlyphAtlas);
51
-
52
- module.exports = GlyphAtlas;
53
+ export default GlyphAtlas;
@@ -8,9 +8,8 @@ class GlyphManager {
8
8
  async loadGlyphRange(stack, range) {
9
9
  this.#cache[stack] ??= {};
10
10
  const promise = (this.#cache[stack][range] ??= this.loader(stack, range));
11
- const response = await promise;
12
- return response.slice();
11
+ return await promise;
13
12
  }
14
13
  }
15
14
 
16
- module.exports = GlyphManager;
15
+ export default GlyphManager;
@@ -1,10 +1,9 @@
1
- const { RGBAImage } = require('../util/image');
2
- const { register } = require('../util/transfer_registry');
3
- const { default: potpack } = require('potpack');
1
+ import potpack from 'potpack';
2
+ import { RGBAImage } from '../util/image.js';
4
3
 
5
4
  const padding = 1;
6
5
 
7
- class ImagePosition {
6
+ export class ImagePosition {
8
7
  constructor(paddedRect, { pixelRatio }) {
9
8
  this.paddedRect = paddedRect;
10
9
  this.pixelRatio = pixelRatio;
@@ -27,7 +26,7 @@ class ImagePosition {
27
26
  }
28
27
  }
29
28
 
30
- class ImageAtlas {
29
+ export default class ImageAtlas {
31
30
  constructor(icons, patterns) {
32
31
  const iconPositions = {};
33
32
  const patternPositions = {};
@@ -86,9 +85,3 @@ class ImageAtlas {
86
85
  this.patternPositions = patternPositions;
87
86
  }
88
87
  }
89
-
90
- ImageAtlas.ImagePosition = ImagePosition;
91
- module.exports = ImageAtlas;
92
-
93
- register('ImagePosition', ImagePosition);
94
- register('ImageAtlas', ImageAtlas);