@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,15 +1,16 @@
1
- const { mat4 } = require('@mapbox/gl-matrix');
1
+ import glMatrix from '@mapbox/gl-matrix';
2
+ import pixelsToTileUnits from '../../source/pixels_to_tile_units.js';
3
+ import { Uniform1f, Uniform1i, Uniform2f, UniformMatrix4f } from '../uniform_binding.js';
2
4
 
3
- const { Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f } = require('../uniform_binding');
4
- const pixelsToTileUnits = require('../../source/pixels_to_tile_units');
5
+ const { mat4 } = glMatrix;
5
6
 
6
- const heatmapUniforms = (context, locations) => ({
7
+ export const heatmapUniforms = (context, locations) => ({
7
8
  u_extrude_scale: new Uniform1f(context, locations.u_extrude_scale),
8
9
  u_intensity: new Uniform1f(context, locations.u_intensity),
9
10
  u_matrix: new UniformMatrix4f(context, locations.u_matrix)
10
11
  });
11
12
 
12
- const heatmapTextureUniforms = (context, locations) => ({
13
+ export const heatmapTextureUniforms = (context, locations) => ({
13
14
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
14
15
  u_world: new Uniform2f(context, locations.u_world),
15
16
  u_image: new Uniform1i(context, locations.u_image),
@@ -17,13 +18,13 @@ const heatmapTextureUniforms = (context, locations) => ({
17
18
  u_opacity: new Uniform1f(context, locations.u_opacity)
18
19
  });
19
20
 
20
- const heatmapUniformValues = (matrix, tile, zoom, intensity) => ({
21
+ export const heatmapUniformValues = (matrix, tile, zoom, intensity) => ({
21
22
  u_matrix: matrix,
22
23
  u_extrude_scale: pixelsToTileUnits(tile, 1, zoom),
23
24
  u_intensity: intensity
24
25
  });
25
26
 
26
- const heatmapTextureUniformValues = (painter, layer, textureUnit, colorRampUnit) => {
27
+ export const heatmapTextureUniformValues = (painter, layer, textureUnit, colorRampUnit) => {
27
28
  const matrix = mat4.create();
28
29
  mat4.ortho(matrix, 0, painter.width, painter.height, 0, 0, 1);
29
30
 
@@ -34,13 +35,6 @@ const heatmapTextureUniformValues = (painter, layer, textureUnit, colorRampUnit)
34
35
  u_world: [gl.drawingBufferWidth, gl.drawingBufferHeight],
35
36
  u_image: textureUnit,
36
37
  u_color_ramp: colorRampUnit,
37
- u_opacity: layer.paint.get('heatmap-opacity')
38
+ u_opacity: layer._paint.get('heatmap-opacity')
38
39
  };
39
40
  };
40
-
41
- module.exports = {
42
- heatmapUniforms,
43
- heatmapTextureUniforms,
44
- heatmapUniformValues,
45
- heatmapTextureUniformValues
46
- };
@@ -1,11 +1,12 @@
1
- const assert = require('assert');
2
- const { mat4 } = require('@mapbox/gl-matrix');
1
+ import glMatrix from '@mapbox/gl-matrix';
2
+ import assert from 'assert';
3
+ import EXTENT from '../../data/extent.js';
4
+ import Coordinate from '../../geo/coordinate.js';
5
+ import { Uniform1f, Uniform1i, Uniform2f, UniformColor, UniformMatrix4f } from '../uniform_binding.js';
3
6
 
4
- const { Uniform1i, Uniform1f, Uniform2f, UniformColor, UniformMatrix4f } = require('../uniform_binding');
5
- const EXTENT = require('../../data/extent');
6
- const Coordinate = require('../../geo/coordinate');
7
+ const { mat4 } = glMatrix;
7
8
 
8
- const hillshadeUniforms = (context, locations) => ({
9
+ export const hillshadeUniforms = (context, locations) => ({
9
10
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
10
11
  u_image: new Uniform1i(context, locations.u_image),
11
12
  u_latrange: new Uniform2f(context, locations.u_latrange),
@@ -15,7 +16,7 @@ const hillshadeUniforms = (context, locations) => ({
15
16
  u_accent: new UniformColor(context, locations.u_accent)
16
17
  });
17
18
 
18
- const hillshadePrepareUniforms = (context, locations) => ({
19
+ export const hillshadePrepareUniforms = (context, locations) => ({
19
20
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
20
21
  u_image: new Uniform1i(context, locations.u_image),
21
22
  u_dimension: new Uniform2f(context, locations.u_dimension),
@@ -23,14 +24,14 @@ const hillshadePrepareUniforms = (context, locations) => ({
23
24
  u_maxzoom: new Uniform1f(context, locations.u_maxzoom)
24
25
  });
25
26
 
26
- const hillshadeUniformValues = (painter, tile, layer) => {
27
- const shadow = layer.paint.get('hillshade-shadow-color');
28
- const highlight = layer.paint.get('hillshade-highlight-color');
29
- const accent = layer.paint.get('hillshade-accent-color');
27
+ export const hillshadeUniformValues = (painter, tile, layer) => {
28
+ const shadow = layer._paint.get('hillshade-shadow-color');
29
+ const highlight = layer._paint.get('hillshade-highlight-color');
30
+ const accent = layer._paint.get('hillshade-accent-color');
30
31
 
31
- let azimuthal = layer.paint.get('hillshade-illumination-direction') * (Math.PI / 180);
32
+ let azimuthal = layer._paint.get('hillshade-illumination-direction') * (Math.PI / 180);
32
33
  // modify azimuthal angle by map rotation if light is anchored at the viewport
33
- if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {
34
+ if (layer._paint.get('hillshade-illumination-anchor') === 'viewport') {
34
35
  azimuthal -= painter.transform.angle;
35
36
  }
36
37
  const align = !painter.options.moving;
@@ -38,14 +39,14 @@ const hillshadeUniformValues = (painter, tile, layer) => {
38
39
  u_matrix: painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),
39
40
  u_image: 0,
40
41
  u_latrange: getTileLatRange(painter, tile.tileID),
41
- u_light: [layer.paint.get('hillshade-exaggeration'), azimuthal],
42
+ u_light: [layer._paint.get('hillshade-exaggeration'), azimuthal],
42
43
  u_shadow: shadow,
43
44
  u_highlight: highlight,
44
45
  u_accent: accent
45
46
  };
46
47
  };
47
48
 
48
- const hillshadeUniformPrepareValues = (tile, maxzoom) => {
49
+ export const hillshadeUniformPrepareValues = (tile, maxzoom) => {
49
50
  assert(tile.dem);
50
51
  const stride = tile.dem.stride;
51
52
  const matrix = mat4.create();
@@ -68,10 +69,3 @@ function getTileLatRange(painter, tileID) {
68
69
  const coordinate1 = new Coordinate(coordinate0.column, coordinate0.row + 1, coordinate0.zoom);
69
70
  return [painter.transform.coordinateLocation(coordinate0).lat, painter.transform.coordinateLocation(coordinate1).lat];
70
71
  }
71
-
72
- module.exports = {
73
- hillshadeUniforms,
74
- hillshadePrepareUniforms,
75
- hillshadeUniformValues,
76
- hillshadeUniformPrepareValues
77
- };
@@ -1,21 +1,21 @@
1
- const { Uniform1i, Uniform1f, Uniform2f, Uniform4f, UniformMatrix4f } = require('../uniform_binding');
2
- const pixelsToTileUnits = require('../../source/pixels_to_tile_units');
3
- const browser = require('../../util/browser');
1
+ import pixelsToTileUnits from '../../source/pixels_to_tile_units.js';
2
+ import browser from '../../util/browser.js';
3
+ import { Uniform1f, Uniform1i, Uniform2f, Uniform4f, UniformMatrix4f } from '../uniform_binding.js';
4
4
 
5
- const lineUniforms = (context, locations) => ({
5
+ export const lineUniforms = (context, locations) => ({
6
6
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
7
7
  u_ratio: new Uniform1f(context, locations.u_ratio),
8
8
  u_gl_units_to_pixels: new Uniform2f(context, locations.u_gl_units_to_pixels)
9
9
  });
10
10
 
11
- const lineGradientUniforms = (context, locations) => ({
11
+ export const lineGradientUniforms = (context, locations) => ({
12
12
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
13
13
  u_ratio: new Uniform1f(context, locations.u_ratio),
14
14
  u_gl_units_to_pixels: new Uniform2f(context, locations.u_gl_units_to_pixels),
15
15
  u_image: new Uniform1i(context, locations.u_image)
16
16
  });
17
17
 
18
- const linePatternUniforms = (context, locations) => ({
18
+ export const linePatternUniforms = (context, locations) => ({
19
19
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
20
20
  u_texsize: new Uniform2f(context, locations.u_texsize),
21
21
  u_ratio: new Uniform1f(context, locations.u_ratio),
@@ -25,7 +25,7 @@ const linePatternUniforms = (context, locations) => ({
25
25
  u_fade: new Uniform1f(context, locations.u_fade)
26
26
  });
27
27
 
28
- const lineSDFUniforms = (context, locations) => ({
28
+ export const lineSDFUniforms = (context, locations) => ({
29
29
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
30
30
  u_ratio: new Uniform1f(context, locations.u_ratio),
31
31
  u_gl_units_to_pixels: new Uniform2f(context, locations.u_gl_units_to_pixels),
@@ -38,7 +38,7 @@ const lineSDFUniforms = (context, locations) => ({
38
38
  u_mix: new Uniform1f(context, locations.u_mix)
39
39
  });
40
40
 
41
- const lineUniformValues = (painter, tile, layer) => {
41
+ export const lineUniformValues = (painter, tile, layer) => {
42
42
  const transform = painter.transform;
43
43
 
44
44
  return {
@@ -48,13 +48,13 @@ const lineUniformValues = (painter, tile, layer) => {
48
48
  };
49
49
  };
50
50
 
51
- const lineGradientUniformValues = (painter, tile, layer) => {
51
+ export const lineGradientUniformValues = (painter, tile, layer) => {
52
52
  return Object.assign(lineUniformValues(painter, tile, layer), {
53
53
  u_image: 0
54
54
  });
55
55
  };
56
56
 
57
- const linePatternUniformValues = (painter, tile, layer, crossfade) => {
57
+ export const linePatternUniformValues = (painter, tile, layer, crossfade) => {
58
58
  const transform = painter.transform;
59
59
  const tileZoomRatio = calculateTileRatio(tile, transform);
60
60
  return {
@@ -70,12 +70,12 @@ const linePatternUniformValues = (painter, tile, layer, crossfade) => {
70
70
  };
71
71
  };
72
72
 
73
- const lineSDFUniformValues = (painter, tile, layer, dasharray, crossfade) => {
73
+ export const lineSDFUniformValues = (painter, tile, layer, dasharray, crossfade) => {
74
74
  const transform = painter.transform;
75
75
  const lineAtlas = painter.lineAtlas;
76
76
  const tileRatio = calculateTileRatio(tile, transform);
77
77
 
78
- const round = layer.layout.get('line-cap') === 'round';
78
+ const round = layer._layout.get('line-cap') === 'round';
79
79
 
80
80
  const posA = lineAtlas.getDash(dasharray.from, round);
81
81
  const posB = lineAtlas.getDash(dasharray.to, round);
@@ -102,18 +102,7 @@ function calculateMatrix(painter, tile, layer) {
102
102
  return painter.translatePosMatrix(
103
103
  tile.tileID.posMatrix,
104
104
  tile,
105
- layer.paint.get('line-translate'),
106
- layer.paint.get('line-translate-anchor')
105
+ layer._paint.get('line-translate'),
106
+ layer._paint.get('line-translate-anchor')
107
107
  );
108
108
  }
109
-
110
- module.exports = {
111
- lineUniforms,
112
- lineGradientUniforms,
113
- linePatternUniforms,
114
- lineSDFUniforms,
115
- lineUniformValues,
116
- lineGradientUniformValues,
117
- linePatternUniformValues,
118
- lineSDFUniformValues
119
- };
@@ -1,8 +1,8 @@
1
- const assert = require('assert');
2
- const browser = require('../../util/browser');
3
- const pixelsToTileUnits = require('../../source/pixels_to_tile_units');
1
+ import assert from 'assert';
2
+ import pixelsToTileUnits from '../../source/pixels_to_tile_units.js';
3
+ import browser from '../../util/browser.js';
4
4
 
5
- function patternUniformValues(crossfade, painter, tile) {
5
+ export function patternUniformValues(crossfade, painter, tile) {
6
6
  const tileRatio = 1 / pixelsToTileUnits(tile, 1, painter.transform.tileZoom);
7
7
 
8
8
  const numTiles = 2 ** tile.tileID.overscaledZ;
@@ -23,7 +23,7 @@ function patternUniformValues(crossfade, painter, tile) {
23
23
  };
24
24
  }
25
25
 
26
- function bgPatternUniformValues(image, crossfade, painter, tile) {
26
+ export function bgPatternUniformValues(image, crossfade, painter, tile) {
27
27
  const imagePosA = painter.imageManager.getPattern(image.from);
28
28
  const imagePosB = painter.imageManager.getPattern(image.to);
29
29
  assert(imagePosA && imagePosB);
@@ -53,5 +53,3 @@ function bgPatternUniformValues(image, crossfade, painter, tile) {
53
53
  u_pixel_coord_lower: [pixelX & 0xffff, pixelY & 0xffff]
54
54
  };
55
55
  }
56
-
57
- module.exports = { bgPatternUniformValues, patternUniformValues };
@@ -1,22 +1,17 @@
1
- const { fillExtrusionUniforms, fillExtrusionPatternUniforms } = require('./fill_extrusion_program');
2
- const {
3
- fillUniforms,
4
- fillPatternUniforms,
5
- fillOutlineUniforms,
6
- fillOutlinePatternUniforms
7
- } = require('./fill_program');
8
- const { circleUniforms } = require('./circle_program');
9
- const { collisionUniforms } = require('./collision_program');
10
- const { debugUniforms } = require('./debug_program');
11
- const { clippingMaskUniforms } = require('./clipping_mask_program');
12
- const { heatmapUniforms, heatmapTextureUniforms } = require('./heatmap_program');
13
- const { hillshadeUniforms, hillshadePrepareUniforms } = require('./hillshade_program');
14
- const { lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms } = require('./line_program');
15
- const { rasterUniforms } = require('./raster_program');
16
- const { symbolIconUniforms, symbolSDFUniforms } = require('./symbol_program');
17
- const { backgroundUniforms, backgroundPatternUniforms } = require('./background_program');
1
+ import { backgroundPatternUniforms, backgroundUniforms } from './background_program.js';
2
+ import { circleUniforms } from './circle_program.js';
3
+ import { clippingMaskUniforms } from './clipping_mask_program.js';
4
+ import { collisionUniforms } from './collision_program.js';
5
+ import { debugUniforms } from './debug_program.js';
6
+ import { fillExtrusionPatternUniforms, fillExtrusionUniforms } from './fill_extrusion_program.js';
7
+ import { fillOutlinePatternUniforms, fillOutlineUniforms, fillPatternUniforms, fillUniforms } from './fill_program.js';
8
+ import { heatmapTextureUniforms, heatmapUniforms } from './heatmap_program.js';
9
+ import { hillshadePrepareUniforms, hillshadeUniforms } from './hillshade_program.js';
10
+ import { lineGradientUniforms, linePatternUniforms, lineSDFUniforms, lineUniforms } from './line_program.js';
11
+ import { rasterUniforms } from './raster_program.js';
12
+ import { symbolIconUniforms, symbolSDFUniforms } from './symbol_program.js';
18
13
 
19
- const programUniforms = {
14
+ export const programUniforms = {
20
15
  fillExtrusion: fillExtrusionUniforms,
21
16
  fillExtrusionPattern: fillExtrusionPatternUniforms,
22
17
  fill: fillUniforms,
@@ -42,5 +37,3 @@ const programUniforms = {
42
37
  background: backgroundUniforms,
43
38
  backgroundPattern: backgroundPatternUniforms
44
39
  };
45
-
46
- module.exports = { programUniforms };
@@ -1,6 +1,6 @@
1
- const { Uniform1i, Uniform1f, Uniform2f, Uniform3f, UniformMatrix4f } = require('../uniform_binding');
1
+ import { Uniform1f, Uniform1i, Uniform2f, Uniform3f, UniformMatrix4f } from '../uniform_binding.js';
2
2
 
3
- const rasterUniforms = (context, locations) => ({
3
+ export const rasterUniforms = (context, locations) => ({
4
4
  u_matrix: new UniformMatrix4f(context, locations.u_matrix),
5
5
  u_tl_parent: new Uniform2f(context, locations.u_tl_parent),
6
6
  u_scale_parent: new Uniform1f(context, locations.u_scale_parent),
@@ -16,20 +16,20 @@ const rasterUniforms = (context, locations) => ({
16
16
  u_spin_weights: new Uniform3f(context, locations.u_spin_weights)
17
17
  });
18
18
 
19
- const rasterUniformValues = (matrix, parentTL, parentScaleBy, fade, layer) => ({
19
+ export const rasterUniformValues = (matrix, parentTL, parentScaleBy, fade, layer) => ({
20
20
  u_matrix: matrix,
21
21
  u_tl_parent: parentTL,
22
22
  u_scale_parent: parentScaleBy,
23
23
  u_buffer_scale: 1,
24
24
  u_fade_t: fade.mix,
25
- u_opacity: fade.opacity * layer.paint.get('raster-opacity'),
25
+ u_opacity: fade.opacity * layer._paint.get('raster-opacity'),
26
26
  u_image0: 0,
27
27
  u_image1: 1,
28
- u_brightness_low: layer.paint.get('raster-brightness-min'),
29
- u_brightness_high: layer.paint.get('raster-brightness-max'),
30
- u_saturation_factor: saturationFactor(layer.paint.get('raster-saturation')),
31
- u_contrast_factor: contrastFactor(layer.paint.get('raster-contrast')),
32
- u_spin_weights: spinWeights(layer.paint.get('raster-hue-rotate'))
28
+ u_brightness_low: layer._paint.get('raster-brightness-min'),
29
+ u_brightness_high: layer._paint.get('raster-brightness-max'),
30
+ u_saturation_factor: saturationFactor(layer._paint.get('raster-saturation')),
31
+ u_contrast_factor: contrastFactor(layer._paint.get('raster-contrast')),
32
+ u_spin_weights: spinWeights(layer._paint.get('raster-hue-rotate'))
33
33
  });
34
34
 
35
35
  function spinWeights(angle) {
@@ -46,5 +46,3 @@ function contrastFactor(contrast) {
46
46
  function saturationFactor(saturation) {
47
47
  return saturation > 0 ? 1 - 1 / (1.001 - saturation) : -saturation;
48
48
  }
49
-
50
- module.exports = { rasterUniforms, rasterUniformValues };
@@ -1,6 +1,6 @@
1
- const { Uniform1i, Uniform1f, Uniform2f, UniformMatrix4f } = require('../uniform_binding');
1
+ import { Uniform1f, Uniform1i, Uniform2f, UniformMatrix4f } from '../uniform_binding.js';
2
2
 
3
- const symbolIconUniforms = (context, locations) => ({
3
+ export const symbolIconUniforms = (context, locations) => ({
4
4
  u_is_size_zoom_constant: new Uniform1i(context, locations.u_is_size_zoom_constant),
5
5
  u_is_size_feature_constant: new Uniform1i(context, locations.u_is_size_feature_constant),
6
6
  u_size_t: new Uniform1f(context, locations.u_size_t),
@@ -19,7 +19,7 @@ const symbolIconUniforms = (context, locations) => ({
19
19
  u_texture: new Uniform1i(context, locations.u_texture)
20
20
  });
21
21
 
22
- const symbolSDFUniforms = (context, locations) => ({
22
+ export const symbolSDFUniforms = (context, locations) => ({
23
23
  u_is_size_zoom_constant: new Uniform1i(context, locations.u_is_size_zoom_constant),
24
24
  u_is_size_feature_constant: new Uniform1i(context, locations.u_is_size_feature_constant),
25
25
  u_size_t: new Uniform1f(context, locations.u_size_t),
@@ -40,7 +40,7 @@ const symbolSDFUniforms = (context, locations) => ({
40
40
  u_is_halo: new Uniform1f(context, locations.u_is_halo)
41
41
  });
42
42
 
43
- const symbolIconUniformValues = (
43
+ export const symbolIconUniformValues = (
44
44
  functionType,
45
45
  size,
46
46
  rotateInShader,
@@ -74,7 +74,7 @@ const symbolIconUniformValues = (
74
74
  };
75
75
  };
76
76
 
77
- const symbolSDFUniformValues = (
77
+ export const symbolSDFUniformValues = (
78
78
  functionType,
79
79
  size,
80
80
  rotateInShader,
@@ -108,5 +108,3 @@ const symbolSDFUniformValues = (
108
108
  }
109
109
  );
110
110
  };
111
-
112
- module.exports = { symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues };
@@ -1,8 +1,7 @@
1
- const browser = require('../util/browser');
2
-
3
- const shaders = require('../shaders');
4
- const assert = require('assert');
5
- const VertexArrayObject = require('./vertex_array_object');
1
+ import assert from 'assert';
2
+ import shaders from '../shaders/index.js';
3
+ import browser from '../util/browser.js';
4
+ import VertexArrayObject from './vertex_array_object.js';
6
5
 
7
6
  class Program {
8
7
  constructor(context, source, configuration, fixedUniforms, showOverdrawInspector) {
@@ -130,4 +129,4 @@ class Program {
130
129
  }
131
130
  }
132
131
 
133
- module.exports = Program;
132
+ export default Program;
@@ -85,4 +85,4 @@ class Texture {
85
85
  }
86
86
  }
87
87
 
88
- module.exports = Texture;
88
+ export default Texture;
@@ -1,4 +1,4 @@
1
- const { OverscaledTileID, CanonicalTileID } = require('../source/tile_id');
1
+ import { CanonicalTileID, OverscaledTileID } from '../source/tile_id.js';
2
2
 
3
3
  // Updates the TileMasks for all renderable tiles. A TileMask describes all regions
4
4
  // within that tile that are *not* covered by other renderable tiles.
@@ -50,7 +50,7 @@ const { OverscaledTileID, CanonicalTileID } = require('../source/tile_id');
50
50
  // be considered. For example, adding TileID 4/8/13 to renderableTiles won't affect the TileMask for
51
51
  // 2/1/3, since it is not a descendant of it.
52
52
 
53
- module.exports = function (renderableTiles, context) {
53
+ export default function (renderableTiles, context) {
54
54
  const sortedRenderables = renderableTiles.sort((a, b) => {
55
55
  return a.tileID.isLessThan(b.tileID) ? -1 : b.tileID.isLessThan(a.tileID) ? 1 : 0;
56
56
  });
@@ -73,14 +73,16 @@ module.exports = function (renderableTiles, context) {
73
73
  );
74
74
  tile.setMask(mask, context);
75
75
  }
76
- };
76
+ }
77
77
 
78
78
  function computeTileMasks(rootTile, ref, childArray, lowerBound, mask) {
79
79
  // If the reference or any of its children is found in the list, we need to recurse.
80
80
  for (let i = 0; i < childArray.length; i++) {
81
81
  const childTile = childArray[i];
82
82
  // childTile is from a larger wrap than the rootTile so it cannot be a child tile
83
- if (lowerBound.isLessThan(childTile.tileID)) break;
83
+ if (lowerBound.isLessThan(childTile.tileID)) {
84
+ break;
85
+ }
84
86
  // The current tile is masked out, so we don't need to add them to the mask set.
85
87
  if (ref.key === childTile.tileID.key) {
86
88
  return;
@@ -1,13 +1,13 @@
1
- const { Color } = require('@mapwhit/style-expressions');
1
+ import { Color } from '@mapwhit/style-expressions';
2
2
 
3
- class Uniform {
3
+ export class Uniform {
4
4
  constructor(context, location) {
5
5
  this.gl = context.gl;
6
6
  this.location = location;
7
7
  }
8
8
  }
9
9
 
10
- class Uniform1i extends Uniform {
10
+ export class Uniform1i extends Uniform {
11
11
  constructor(context, location) {
12
12
  super(context, location);
13
13
  this.current = 0;
@@ -21,7 +21,7 @@ class Uniform1i extends Uniform {
21
21
  }
22
22
  }
23
23
 
24
- class Uniform1f extends Uniform {
24
+ export class Uniform1f extends Uniform {
25
25
  constructor(context, location) {
26
26
  super(context, location);
27
27
  this.current = 0;
@@ -35,7 +35,7 @@ class Uniform1f extends Uniform {
35
35
  }
36
36
  }
37
37
 
38
- class Uniform2f extends Uniform {
38
+ export class Uniform2f extends Uniform {
39
39
  constructor(context, location) {
40
40
  super(context, location);
41
41
  this.current = [0, 0];
@@ -49,7 +49,7 @@ class Uniform2f extends Uniform {
49
49
  }
50
50
  }
51
51
 
52
- class Uniform3f extends Uniform {
52
+ export class Uniform3f extends Uniform {
53
53
  constructor(context, location) {
54
54
  super(context, location);
55
55
  this.current = [0, 0, 0];
@@ -63,7 +63,7 @@ class Uniform3f extends Uniform {
63
63
  }
64
64
  }
65
65
 
66
- class Uniform4f extends Uniform {
66
+ export class Uniform4f extends Uniform {
67
67
  constructor(context, location) {
68
68
  super(context, location);
69
69
  this.current = [0, 0, 0, 0];
@@ -77,7 +77,7 @@ class Uniform4f extends Uniform {
77
77
  }
78
78
  }
79
79
 
80
- class UniformColor extends Uniform {
80
+ export class UniformColor extends Uniform {
81
81
  constructor(context, location) {
82
82
  super(context, location);
83
83
  this.current = Color.transparent;
@@ -92,7 +92,7 @@ class UniformColor extends Uniform {
92
92
  }
93
93
 
94
94
  const emptyMat4 = new Float32Array(16);
95
- class UniformMatrix4f extends Uniform {
95
+ export class UniformMatrix4f extends Uniform {
96
96
  constructor(context, location) {
97
97
  super(context, location);
98
98
  this.current = emptyMat4;
@@ -116,14 +116,3 @@ class UniformMatrix4f extends Uniform {
116
116
  }
117
117
  }
118
118
  }
119
-
120
- module.exports = {
121
- Uniform,
122
- Uniform1i,
123
- Uniform1f,
124
- Uniform2f,
125
- Uniform3f,
126
- Uniform4f,
127
- UniformColor,
128
- UniformMatrix4f
129
- };
@@ -1,4 +1,4 @@
1
- const assert = require('assert');
1
+ import assert from 'assert';
2
2
 
3
3
  class VertexArrayObject {
4
4
  constructor() {
@@ -84,7 +84,9 @@ class VertexArrayObject {
84
84
  const gl = context.gl;
85
85
 
86
86
  if (context.extVertexArrayObject) {
87
- if (this.vao) this.destroy();
87
+ if (this.vao) {
88
+ this.destroy();
89
+ }
88
90
  this.vao = context.extVertexArrayObject.createVertexArrayOES();
89
91
  context.bindVertexArrayOES.set(this.vao);
90
92
  numPrevAttributes = 0;
@@ -152,4 +154,4 @@ class VertexArrayObject {
152
154
  }
153
155
  }
154
156
 
155
- module.exports = VertexArrayObject;
157
+ export default VertexArrayObject;
@@ -1,4 +1,4 @@
1
- const { clamp } = require('../util/util');
1
+ import { clamp } from '../util/util.js';
2
2
 
3
3
  /**
4
4
  * Packs two numbers, interpreted as 8-bit unsigned integers, into a single
@@ -7,13 +7,9 @@ const { clamp } = require('../util/util');
7
7
  *
8
8
  * @private
9
9
  */
10
- function pack(a, b) {
10
+ export function packUint8ToFloat(a, b) {
11
11
  // coerce a and b to 8-bit ints
12
12
  a = clamp(Math.floor(a), 0, 255);
13
13
  b = clamp(Math.floor(b), 0, 255);
14
14
  return 256 * a + b;
15
15
  }
16
-
17
- module.exports = {
18
- packUint8ToFloat: pack
19
- };