maplibre-gl 3.2.0 → 3.2.2

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 (88) hide show
  1. package/build/generate-docs.ts +1 -1
  2. package/build/generate-struct-arrays.ts +3 -2
  3. package/dist/maplibre-gl-csp-worker.js +1 -1
  4. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  5. package/dist/maplibre-gl-csp.js +1 -1
  6. package/dist/maplibre-gl-csp.js.map +1 -1
  7. package/dist/maplibre-gl-dev.js +351 -281
  8. package/dist/maplibre-gl-dev.js.map +1 -1
  9. package/dist/maplibre-gl.d.ts +254 -181
  10. package/dist/maplibre-gl.js +4 -4
  11. package/dist/maplibre-gl.js.map +1 -1
  12. package/package.json +30 -30
  13. package/src/data/array_types.g.ts +32 -10
  14. package/src/data/bucket/circle_bucket.ts +1 -0
  15. package/src/data/bucket/line_bucket.ts +1 -0
  16. package/src/data/bucket/symbol_bucket.ts +1 -0
  17. package/src/data/feature_index.ts +1 -0
  18. package/src/data/program_configuration.ts +1 -0
  19. package/src/data/segment.ts +2 -0
  20. package/src/geo/transform.test.ts +9 -16
  21. package/src/geo/transform.ts +11 -32
  22. package/src/gl/context.ts +1 -0
  23. package/src/gl/framebuffer.ts +1 -0
  24. package/src/gl/index_buffer.ts +1 -0
  25. package/src/gl/render_pool.ts +2 -1
  26. package/src/gl/vertex_buffer.ts +1 -0
  27. package/src/render/draw_fill.test.ts +1 -1
  28. package/src/render/draw_symbol.test.ts +3 -3
  29. package/src/render/image_atlas.ts +1 -0
  30. package/src/render/line_atlas.ts +1 -0
  31. package/src/render/painter.ts +1 -1
  32. package/src/render/program.ts +1 -1
  33. package/src/render/render_to_texture.ts +31 -14
  34. package/src/render/terrain.test.ts +17 -0
  35. package/src/render/terrain.ts +34 -2
  36. package/src/render/texture.ts +1 -0
  37. package/src/render/uniform_binding.ts +2 -0
  38. package/src/render/vertex_array_object.ts +1 -0
  39. package/src/shaders/symbol_sdf.fragment.glsl +9 -3
  40. package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
  41. package/src/source/canvas_source.ts +1 -3
  42. package/src/source/geojson_source.ts +1 -3
  43. package/src/source/image_source.ts +2 -4
  44. package/src/source/raster_dem_tile_source.test.ts +14 -0
  45. package/src/source/raster_dem_tile_source.ts +0 -11
  46. package/src/source/raster_tile_source.test.ts +13 -0
  47. package/src/source/source_cache.ts +1 -0
  48. package/src/source/source_state.ts +1 -0
  49. package/src/source/terrain_source_cache.ts +1 -0
  50. package/src/source/tile.ts +1 -0
  51. package/src/source/tile_cache.ts +1 -1
  52. package/src/source/tile_id.ts +1 -0
  53. package/src/source/vector_tile_worker_source.test.ts +116 -67
  54. package/src/source/vector_tile_worker_source.ts +30 -16
  55. package/src/source/worker_source.ts +1 -0
  56. package/src/source/worker_tile.test.ts +143 -0
  57. package/src/source/worker_tile.ts +26 -7
  58. package/src/style/evaluation_parameters.ts +1 -0
  59. package/src/style/properties.ts +14 -0
  60. package/src/style/style.ts +1 -0
  61. package/src/style/style_glyph.ts +1 -0
  62. package/src/symbol/collision_index.ts +1 -0
  63. package/src/symbol/grid_index.ts +1 -0
  64. package/src/ui/camera.test.ts +12 -9
  65. package/src/ui/camera.ts +77 -95
  66. package/src/ui/handler/box_zoom.ts +1 -3
  67. package/src/ui/handler/click_zoom.ts +1 -3
  68. package/src/ui/handler/keyboard.ts +1 -3
  69. package/src/ui/handler/scroll_zoom.ts +1 -3
  70. package/src/ui/handler/shim/dblclick_zoom.ts +1 -3
  71. package/src/ui/handler/shim/drag_pan.ts +1 -3
  72. package/src/ui/handler/shim/drag_rotate.ts +1 -3
  73. package/src/ui/handler/shim/two_fingers_touch.ts +1 -3
  74. package/src/ui/handler/transform-provider.ts +1 -0
  75. package/src/ui/handler/two_fingers_touch.ts +1 -3
  76. package/src/ui/handler_manager.ts +2 -2
  77. package/src/ui/hash.ts +1 -2
  78. package/src/ui/map.test.ts +17 -12
  79. package/src/ui/map.ts +132 -44
  80. package/src/ui/map_events.test.ts +76 -0
  81. package/src/ui/marker.test.ts +1 -1
  82. package/src/util/ajax.test.ts +33 -0
  83. package/src/util/ajax.ts +5 -0
  84. package/src/util/image.ts +1 -0
  85. package/src/util/image_request.ts +2 -2
  86. package/src/util/performance.ts +1 -2
  87. package/src/util/struct_array.ts +5 -1
  88. package/src/util/test/mock_fetch.ts +51 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maplibre-gl",
3
3
  "description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
4
- "version": "3.2.0",
4
+ "version": "3.2.2",
5
5
  "main": "dist/maplibre-gl.js",
6
6
  "style": "dist/maplibre-gl.css",
7
7
  "license": "BSD-3-Clause",
@@ -20,11 +20,12 @@
20
20
  "@mapbox/unitbezier": "^0.0.1",
21
21
  "@mapbox/vector-tile": "^1.3.1",
22
22
  "@mapbox/whoots-js": "^3.1.0",
23
- "@maplibre/maplibre-gl-style-spec": "^19.2.1",
23
+ "@maplibre/maplibre-gl-style-spec": "^19.2.2",
24
24
  "@types/geojson": "^7946.0.10",
25
25
  "@types/mapbox__point-geometry": "^0.1.2",
26
26
  "@types/mapbox__vector-tile": "^1.3.0",
27
27
  "@types/pbf": "^3.0.2",
28
+ "@types/supercluster": "^7.1.0",
28
29
  "earcut": "^2.2.4",
29
30
  "geojson-vt": "^3.2.1",
30
31
  "gl-matrix": "^3.4.3",
@@ -41,7 +42,7 @@
41
42
  "devDependencies": {
42
43
  "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
43
44
  "@mapbox/mvt-fixtures": "^3.10.0",
44
- "@rollup/plugin-commonjs": "^25.0.2",
45
+ "@rollup/plugin-commonjs": "^25.0.3",
45
46
  "@rollup/plugin-json": "^6.0.0",
46
47
  "@rollup/plugin-node-resolve": "^15.1.0",
47
48
  "@rollup/plugin-replace": "^5.0.2",
@@ -53,49 +54,48 @@
53
54
  "@types/d3": "^7.4.0",
54
55
  "@types/diff": "^5.0.3",
55
56
  "@types/earcut": "^2.1.1",
56
- "@types/eslint": "^8.40.2",
57
+ "@types/eslint": "^8.44.1",
57
58
  "@types/gl": "^6.0.2",
58
59
  "@types/glob": "^8.1.0",
59
- "@types/jest": "^29.5.2",
60
+ "@types/jest": "^29.5.3",
60
61
  "@types/jsdom": "^21.1.1",
61
62
  "@types/minimist": "^1.2.2",
62
63
  "@types/murmurhash-js": "^1.0.4",
63
64
  "@types/nise": "^1.4.1",
64
- "@types/node": "^20.3.3",
65
+ "@types/node": "^20.4.5",
65
66
  "@types/offscreencanvas": "^2019.7.0",
66
67
  "@types/pixelmatch": "^5.2.4",
67
68
  "@types/pngjs": "^6.0.1",
68
- "@types/react": "^18.2.14",
69
- "@types/react-dom": "^18.2.6",
69
+ "@types/react": "^18.2.17",
70
+ "@types/react-dom": "^18.2.7",
70
71
  "@types/request": "^2.48.8",
71
72
  "@types/shuffle-seed": "^1.1.0",
72
- "@types/supercluster": "^7.1.0",
73
73
  "@types/window-or-global": "^1.0.4",
74
- "@typescript-eslint/eslint-plugin": "^5.60.1",
75
- "@typescript-eslint/parser": "^5.60.1",
74
+ "@typescript-eslint/eslint-plugin": "^6.2.0",
75
+ "@typescript-eslint/parser": "^6.2.0",
76
76
  "address": "^1.2.2",
77
77
  "benchmark": "^2.1.4",
78
78
  "canvas": "^2.11.2",
79
79
  "cssnano": "^6.0.1",
80
80
  "d3": "^7.8.5",
81
81
  "d3-queue": "^3.0.7",
82
- "devtools-protocol": "^0.0.1165014",
82
+ "devtools-protocol": "^0.0.1173815",
83
83
  "diff": "^5.1.0",
84
84
  "dts-bundle-generator": "^8.0.1",
85
- "eslint": "^8.44.0",
85
+ "eslint": "^8.46.0",
86
86
  "eslint-config-mourner": "^3.0.0",
87
87
  "eslint-plugin-html": "^7.1.0",
88
- "eslint-plugin-import": "^2.27.5",
89
- "eslint-plugin-jest": "^27.2.2",
88
+ "eslint-plugin-import": "^2.28.0",
89
+ "eslint-plugin-jest": "^27.2.3",
90
+ "eslint-plugin-react": "^7.33.1",
90
91
  "eslint-plugin-tsdoc": "0.2.17",
91
- "eslint-plugin-react": "^7.32.2",
92
- "expect": "^29.5.0",
92
+ "expect": "^29.6.2",
93
93
  "gl": "^6.0.2",
94
- "glob": "^10.3.1",
94
+ "glob": "^10.3.3",
95
95
  "is-builtin-module": "^3.2.1",
96
- "jest": "^29.5.0",
96
+ "jest": "^29.6.2",
97
97
  "jest-canvas-mock": "^2.5.2",
98
- "jest-environment-jsdom": "^29.5.0",
98
+ "jest-environment-jsdom": "^29.6.2",
99
99
  "jsdom": "^22.1.0",
100
100
  "json-stringify-pretty-compact": "^4.0.0",
101
101
  "minimist": "^1.2.8",
@@ -107,28 +107,28 @@
107
107
  "pdf-merger-js": "^4.3.0",
108
108
  "pixelmatch": "^5.3.0",
109
109
  "pngjs": "^7.0.0",
110
- "postcss": "^8.4.24",
110
+ "postcss": "^8.4.27",
111
111
  "postcss-cli": "^10.1.0",
112
112
  "postcss-inline-svg": "^6.0.0",
113
- "pretty-bytes": "^6.1.0",
114
- "puppeteer": "^20.7.4",
113
+ "pretty-bytes": "^6.1.1",
114
+ "puppeteer": "^20.9.0",
115
115
  "react": "^18.2.0",
116
116
  "react-dom": "^18.2.0",
117
- "rollup": "^3.26.0",
117
+ "rollup": "^3.27.0",
118
118
  "rollup-plugin-sourcemaps": "^0.6.3",
119
119
  "rw": "^1.3.3",
120
- "semver": "^7.5.3",
120
+ "semver": "^7.5.4",
121
121
  "shuffle-seed": "^1.1.6",
122
122
  "source-map-explorer": "^2.5.3",
123
123
  "st": "^3.0.0",
124
- "stylelint": "^15.10.1",
125
- "stylelint-config-standard": "^33.0.0",
124
+ "stylelint": "^15.10.2",
125
+ "stylelint-config-standard": "^34.0.0",
126
126
  "ts-jest": "^29.1.1",
127
127
  "ts-node": "^10.9.1",
128
- "tslib": "^2.6.0",
128
+ "tslib": "^2.6.1",
129
129
  "typedoc": "^0.24.8",
130
- "typedoc-plugin-markdown": "^3.15.3",
131
- "typedoc-plugin-missing-exports": "^2.0.0",
130
+ "typedoc-plugin-markdown": "^3.15.4",
131
+ "typedoc-plugin-missing-exports": "^2.0.1",
132
132
  "typescript": "^5.1.6"
133
133
  },
134
134
  "overrides": {
@@ -5,6 +5,7 @@ import {register} from '../util/web_worker_transfer';
5
5
  import Point from '@mapbox/point-geometry';
6
6
 
7
7
  /**
8
+ * @internal
8
9
  * Implementation of the StructArray layout:
9
10
  * [0]: Int16[2]
10
11
  *
@@ -36,6 +37,7 @@ StructArrayLayout2i4.prototype.bytesPerElement = 4;
36
37
  register('StructArrayLayout2i4', StructArrayLayout2i4);
37
38
 
38
39
  /**
40
+ * @internal
39
41
  * Implementation of the StructArray layout:
40
42
  * [0]: Int16[3]
41
43
  *
@@ -68,6 +70,7 @@ StructArrayLayout3i6.prototype.bytesPerElement = 6;
68
70
  register('StructArrayLayout3i6', StructArrayLayout3i6);
69
71
 
70
72
  /**
73
+ * @internal
71
74
  * Implementation of the StructArray layout:
72
75
  * [0]: Int16[4]
73
76
  *
@@ -101,6 +104,7 @@ StructArrayLayout4i8.prototype.bytesPerElement = 8;
101
104
  register('StructArrayLayout4i8', StructArrayLayout4i8);
102
105
 
103
106
  /**
107
+ * @internal
104
108
  * Implementation of the StructArray layout:
105
109
  * [0]: Int16[2]
106
110
  * [4]: Int16[4]
@@ -137,6 +141,7 @@ StructArrayLayout2i4i12.prototype.bytesPerElement = 12;
137
141
  register('StructArrayLayout2i4i12', StructArrayLayout2i4i12);
138
142
 
139
143
  /**
144
+ * @internal
140
145
  * Implementation of the StructArray layout:
141
146
  * [0]: Int16[2]
142
147
  * [4]: Uint8[4]
@@ -174,6 +179,7 @@ StructArrayLayout2i4ub8.prototype.bytesPerElement = 8;
174
179
  register('StructArrayLayout2i4ub8', StructArrayLayout2i4ub8);
175
180
 
176
181
  /**
182
+ * @internal
177
183
  * Implementation of the StructArray layout:
178
184
  * [0]: Float32[2]
179
185
  *
@@ -205,6 +211,7 @@ StructArrayLayout2f8.prototype.bytesPerElement = 8;
205
211
  register('StructArrayLayout2f8', StructArrayLayout2f8);
206
212
 
207
213
  /**
214
+ * @internal
208
215
  * Implementation of the StructArray layout:
209
216
  * [0]: Uint16[10]
210
217
  *
@@ -244,6 +251,7 @@ StructArrayLayout10ui20.prototype.bytesPerElement = 20;
244
251
  register('StructArrayLayout10ui20', StructArrayLayout10ui20);
245
252
 
246
253
  /**
254
+ * @internal
247
255
  * Implementation of the StructArray layout:
248
256
  * [0]: Int16[4]
249
257
  * [8]: Uint16[4]
@@ -289,6 +297,7 @@ StructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;
289
297
  register('StructArrayLayout4i4ui4i24', StructArrayLayout4i4ui4i24);
290
298
 
291
299
  /**
300
+ * @internal
292
301
  * Implementation of the StructArray layout:
293
302
  * [0]: Float32[3]
294
303
  *
@@ -321,6 +330,7 @@ StructArrayLayout3f12.prototype.bytesPerElement = 12;
321
330
  register('StructArrayLayout3f12', StructArrayLayout3f12);
322
331
 
323
332
  /**
333
+ * @internal
324
334
  * Implementation of the StructArray layout:
325
335
  * [0]: Uint32[1]
326
336
  *
@@ -351,6 +361,7 @@ StructArrayLayout1ul4.prototype.bytesPerElement = 4;
351
361
  register('StructArrayLayout1ul4', StructArrayLayout1ul4);
352
362
 
353
363
  /**
364
+ * @internal
354
365
  * Implementation of the StructArray layout:
355
366
  * [0]: Int16[6]
356
367
  * [12]: Uint32[1]
@@ -396,6 +407,7 @@ StructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;
396
407
  register('StructArrayLayout6i1ul2ui20', StructArrayLayout6i1ul2ui20);
397
408
 
398
409
  /**
410
+ * @internal
399
411
  * Implementation of the StructArray layout:
400
412
  * [0]: Int16[2]
401
413
  * [4]: Int16[2]
@@ -433,6 +445,7 @@ StructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;
433
445
  register('StructArrayLayout2i2i2i12', StructArrayLayout2i2i2i12);
434
446
 
435
447
  /**
448
+ * @internal
436
449
  * Implementation of the StructArray layout:
437
450
  * [0]: Float32[2]
438
451
  * [8]: Float32[1]
@@ -472,6 +485,7 @@ StructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;
472
485
  register('StructArrayLayout2f1f2i16', StructArrayLayout2f1f2i16);
473
486
 
474
487
  /**
488
+ * @internal
475
489
  * Implementation of the StructArray layout:
476
490
  * [0]: Uint8[2]
477
491
  * [4]: Float32[2]
@@ -507,6 +521,7 @@ StructArrayLayout2ub2f12.prototype.bytesPerElement = 12;
507
521
  register('StructArrayLayout2ub2f12', StructArrayLayout2ub2f12);
508
522
 
509
523
  /**
524
+ * @internal
510
525
  * Implementation of the StructArray layout:
511
526
  * [0]: Uint16[3]
512
527
  *
@@ -539,6 +554,7 @@ StructArrayLayout3ui6.prototype.bytesPerElement = 6;
539
554
  register('StructArrayLayout3ui6', StructArrayLayout3ui6);
540
555
 
541
556
  /**
557
+ * @internal
542
558
  * Implementation of the StructArray layout:
543
559
  * [0]: Int16[2]
544
560
  * [4]: Uint16[2]
@@ -600,6 +616,7 @@ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;
600
616
  register('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);
601
617
 
602
618
  /**
619
+ * @internal
603
620
  * Implementation of the StructArray layout:
604
621
  * [0]: Int16[8]
605
622
  * [16]: Uint16[15]
@@ -667,6 +684,7 @@ StructArrayLayout8i15ui1ul4f68.prototype.bytesPerElement = 68;
667
684
  register('StructArrayLayout8i15ui1ul4f68', StructArrayLayout8i15ui1ul4f68);
668
685
 
669
686
  /**
687
+ * @internal
670
688
  * Implementation of the StructArray layout:
671
689
  * [0]: Float32[1]
672
690
  *
@@ -697,6 +715,7 @@ StructArrayLayout1f4.prototype.bytesPerElement = 4;
697
715
  register('StructArrayLayout1f4', StructArrayLayout1f4);
698
716
 
699
717
  /**
718
+ * @internal
700
719
  * Implementation of the StructArray layout:
701
720
  * [0]: Uint32[1]
702
721
  * [4]: Uint16[2]
@@ -733,6 +752,7 @@ StructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;
733
752
  register('StructArrayLayout1ul2ui8', StructArrayLayout1ul2ui8);
734
753
 
735
754
  /**
755
+ * @internal
736
756
  * Implementation of the StructArray layout:
737
757
  * [0]: Uint16[2]
738
758
  *
@@ -764,6 +784,7 @@ StructArrayLayout2ui4.prototype.bytesPerElement = 4;
764
784
  register('StructArrayLayout2ui4', StructArrayLayout2ui4);
765
785
 
766
786
  /**
787
+ * @internal
767
788
  * Implementation of the StructArray layout:
768
789
  * [0]: Uint16[1]
769
790
  *
@@ -794,6 +815,7 @@ StructArrayLayout1ui2.prototype.bytesPerElement = 2;
794
815
  register('StructArrayLayout1ui2', StructArrayLayout1ui2);
795
816
 
796
817
  /**
818
+ * @internal
797
819
  * Implementation of the StructArray layout:
798
820
  * [0]: Float32[4]
799
821
  *
@@ -826,7 +848,7 @@ class StructArrayLayout4f16 extends StructArray {
826
848
  StructArrayLayout4f16.prototype.bytesPerElement = 16;
827
849
  register('StructArrayLayout4f16', StructArrayLayout4f16);
828
850
 
829
- /** */
851
+ /** @internal */
830
852
  class CollisionBoxStruct extends Struct {
831
853
  _structArray: CollisionBoxArray;
832
854
  get anchorPointX() { return this._structArray.int16[this._pos2 + 0]; }
@@ -845,7 +867,7 @@ CollisionBoxStruct.prototype.size = 20;
845
867
 
846
868
  export type CollisionBox = CollisionBoxStruct;
847
869
 
848
- /** */
870
+ /** @internal */
849
871
  export class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {
850
872
  /**
851
873
  * Return the CollisionBoxStruct at the given location in the array.
@@ -858,7 +880,7 @@ export class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 {
858
880
 
859
881
  register('CollisionBoxArray', CollisionBoxArray);
860
882
 
861
- /** */
883
+ /** @internal */
862
884
  class PlacedSymbolStruct extends Struct {
863
885
  _structArray: PlacedSymbolArray;
864
886
  get anchorX() { return this._structArray.int16[this._pos2 + 0]; }
@@ -887,7 +909,7 @@ PlacedSymbolStruct.prototype.size = 48;
887
909
 
888
910
  export type PlacedSymbol = PlacedSymbolStruct;
889
911
 
890
- /** */
912
+ /** @internal */
891
913
  export class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 {
892
914
  /**
893
915
  * Return the PlacedSymbolStruct at the given location in the array.
@@ -900,7 +922,7 @@ export class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48
900
922
 
901
923
  register('PlacedSymbolArray', PlacedSymbolArray);
902
924
 
903
- /** */
925
+ /** @internal */
904
926
  class SymbolInstanceStruct extends Struct {
905
927
  _structArray: SymbolInstanceArray;
906
928
  get anchorX() { return this._structArray.int16[this._pos2 + 0]; }
@@ -938,7 +960,7 @@ SymbolInstanceStruct.prototype.size = 68;
938
960
 
939
961
  export type SymbolInstance = SymbolInstanceStruct;
940
962
 
941
- /** */
963
+ /** @internal */
942
964
  export class SymbolInstanceArray extends StructArrayLayout8i15ui1ul4f68 {
943
965
  /**
944
966
  * Return the SymbolInstanceStruct at the given location in the array.
@@ -951,14 +973,14 @@ export class SymbolInstanceArray extends StructArrayLayout8i15ui1ul4f68 {
951
973
 
952
974
  register('SymbolInstanceArray', SymbolInstanceArray);
953
975
 
954
- /** */
976
+ /** @internal */
955
977
  export class GlyphOffsetArray extends StructArrayLayout1f4 {
956
978
  getoffsetX(index: number) { return this.float32[index * 1 + 0]; }
957
979
  }
958
980
 
959
981
  register('GlyphOffsetArray', GlyphOffsetArray);
960
982
 
961
- /** */
983
+ /** @internal */
962
984
  export class SymbolLineVertexArray extends StructArrayLayout3i6 {
963
985
  getx(index: number) { return this.int16[index * 3 + 0]; }
964
986
  gety(index: number) { return this.int16[index * 3 + 1]; }
@@ -967,7 +989,7 @@ export class SymbolLineVertexArray extends StructArrayLayout3i6 {
967
989
 
968
990
  register('SymbolLineVertexArray', SymbolLineVertexArray);
969
991
 
970
- /** */
992
+ /** @internal */
971
993
  class FeatureIndexStruct extends Struct {
972
994
  _structArray: FeatureIndexArray;
973
995
  get featureIndex() { return this._structArray.uint32[this._pos4 + 0]; }
@@ -979,7 +1001,7 @@ FeatureIndexStruct.prototype.size = 8;
979
1001
 
980
1002
  export type FeatureIndex = FeatureIndexStruct;
981
1003
 
982
- /** */
1004
+ /** @internal */
983
1005
  export class FeatureIndexArray extends StructArrayLayout1ul2ui8 {
984
1006
  /**
985
1007
  * Return the FeatureIndexStruct at the given location in the array.
@@ -35,6 +35,7 @@ function addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {
35
35
  }
36
36
 
37
37
  /**
38
+ * @internal
38
39
  * Circles are represented by two triangles.
39
40
  *
40
41
  * Each corner has a pos that is the center of the circle and an extrusion
@@ -82,6 +82,7 @@ type GradientTexture = {
82
82
  };
83
83
 
84
84
  /**
85
+ * @internal
85
86
  * Line bucket class
86
87
  */
87
88
  export class LineBucket implements Bucket {
@@ -276,6 +276,7 @@ class CollisionBuffers {
276
276
  register('CollisionBuffers', CollisionBuffers);
277
277
 
278
278
  /**
279
+ * @internal
279
280
  * Unlike other buckets, which simply implement #addFeature with type-specific
280
281
  * logic for (essentially) triangulating feature geometries, SymbolBucket
281
282
  * requires specialized behavior:
@@ -40,6 +40,7 @@ type QueryParameters = {
40
40
  };
41
41
 
42
42
  /**
43
+ * @internal
43
44
  * An in memory index class to allow fast interaction with features
44
45
  */
45
46
  export class FeatureIndex {
@@ -393,6 +393,7 @@ class CrossFadedCompositeBinder implements AttributeBinder {
393
393
  }
394
394
 
395
395
  /**
396
+ * @internal
396
397
  * ProgramConfiguration contains the logic for binding style layer properties and tile
397
398
  * layer feature data into GL program uniforms and vertex attributes.
398
399
  *
@@ -6,6 +6,7 @@ import type {VertexArrayObject} from '../render/vertex_array_object';
6
6
  import type {StructArray} from '../util/struct_array';
7
7
 
8
8
  /**
9
+ * @internal
9
10
  * A single segment of a vector
10
11
  */
11
12
  export type Segment = {
@@ -18,6 +19,7 @@ export type Segment = {
18
19
  };
19
20
 
20
21
  /**
22
+ * @internal
21
23
  * Used for calculations on vector segments
22
24
  */
23
25
  export class SegmentVector {
@@ -406,13 +406,16 @@ describe('transform', () => {
406
406
  transform.resize(512, 512);
407
407
 
408
408
  // expect same values because of no elevation change
409
- transform.getElevation = () => 200;
410
- transform.recalculateZoom(null);
409
+ const terrain = {
410
+ getElevationForLngLatZoom: () => 200,
411
+ pointCoordinate: () => null
412
+ };
413
+ transform.recalculateZoom(terrain as any);
411
414
  expect(transform.zoom).toBe(14);
412
415
 
413
416
  // expect new zoom because of elevation change
414
- transform.getElevation = () => 400;
415
- transform.recalculateZoom(null);
417
+ terrain.getElevationForLngLatZoom = () => 400;
418
+ transform.recalculateZoom(terrain as any);
416
419
  expect(transform.zoom).toBe(14.127997275621933);
417
420
  expect(transform.elevation).toBe(400);
418
421
 
@@ -420,8 +423,8 @@ describe('transform', () => {
420
423
  expect(transform._center.lat).toBe(50.00000000000017);
421
424
 
422
425
  // expect new zoom because of elevation change to point below sea level
423
- transform.getElevation = () => -200;
424
- transform.recalculateZoom(null);
426
+ terrain.getElevationForLngLatZoom = () => -200;
427
+ transform.recalculateZoom(terrain as any);
425
428
  expect(transform.zoom).toBe(13.773740316343467);
426
429
  expect(transform.elevation).toBe(-200);
427
430
  });
@@ -458,14 +461,4 @@ describe('transform', () => {
458
461
  expect(top).toBeCloseTo(79.1823898251593, 10);
459
462
  expect(transform.getBounds().getNorthWest().toArray()).toStrictEqual(transform.pointLocation(new Point(0, top)).toArray());
460
463
  });
461
-
462
- test('getElevation with lng less than -180 wraps correctly', () => {
463
- const OVERSCALETILEID_DOES_NOT_THROW = 4;
464
- const terrain = {
465
- getElevation: () => OVERSCALETILEID_DOES_NOT_THROW
466
- } as any as Terrain;
467
- const transform = new Transform(0, 22, 0, 85, true);
468
- expect(transform.getElevation(new LngLat(-183, 40), terrain)).toBe(OVERSCALETILEID_DOES_NOT_THROW);
469
- });
470
-
471
464
  });
@@ -14,6 +14,7 @@ import type {PaddingOptions} from './edge_insets';
14
14
  import {Terrain} from '../render/terrain';
15
15
 
16
16
  /**
17
+ * @internal
17
18
  * A single transform, generally used for a single tile to be
18
19
  * scaled, rotated, and zoomed.
19
20
  */
@@ -30,7 +31,6 @@ export class Transform {
30
31
  rotationMatrix: mat2;
31
32
  pixelsToGLUnits: [number, number];
32
33
  cameraToCenterDistance: number;
33
- cameraToSeaLevelDistance: number;
34
34
  mercatorMatrix: mat4;
35
35
  projMatrix: mat4;
36
36
  invProjMatrix: mat4;
@@ -40,7 +40,6 @@ export class Transform {
40
40
  pixelMatrixInverse: mat4;
41
41
  glCoordMatrix: mat4;
42
42
  labelPlaneMatrix: mat4;
43
- freezeElevation: boolean;
44
43
  _fov: number;
45
44
  _pitch: number;
46
45
  _zoom: number;
@@ -57,11 +56,11 @@ export class Transform {
57
56
  _constraining: boolean;
58
57
  _posMatrixCache: {[_: string]: mat4};
59
58
  _alignedPosMatrixCache: {[_: string]: mat4};
59
+ _minEleveationForCurrentTile: number;
60
60
 
61
61
  constructor(minZoom?: number, maxZoom?: number, minPitch?: number, maxPitch?: number, renderWorldCopies?: boolean) {
62
62
  this.tileSize = 512; // constant
63
63
  this.maxValidLatitude = 85.051129; // constant
64
- this.freezeElevation = false;
65
64
 
66
65
  this._renderWorldCopies = renderWorldCopies === undefined ? true : !!renderWorldCopies;
67
66
  this._minZoom = minZoom || 0;
@@ -84,6 +83,7 @@ export class Transform {
84
83
  this._edgeInsets = new EdgeInsets();
85
84
  this._posMatrixCache = {};
86
85
  this._alignedPosMatrixCache = {};
86
+ this._minEleveationForCurrentTile = 0;
87
87
  }
88
88
 
89
89
  clone(): Transform {
@@ -99,6 +99,7 @@ export class Transform {
99
99
  this.height = that.height;
100
100
  this._center = that._center;
101
101
  this._elevation = that._elevation;
102
+ this._minEleveationForCurrentTile = that._minEleveationForCurrentTile;
102
103
  this.zoom = that.zoom;
103
104
  this.angle = that.angle;
104
105
  this._fov = that._fov;
@@ -470,30 +471,6 @@ export class Transform {
470
471
 
471
472
  get point(): Point { return this.project(this.center); }
472
473
 
473
- /**
474
- * Updates the center-elevation value unless freezeElevation is activated.
475
- * @param terrain - the terrain
476
- */
477
- updateElevation(terrain?: Terrain) {
478
- if (this.freezeElevation) return;
479
- this.elevation = terrain ? this.getElevation(this._center, terrain) : 0;
480
- }
481
-
482
- /**
483
- * get the elevation from terrain for the current zoomlevel.
484
- * @param lnglat - the location
485
- * @param terrain - the terrain
486
- * @returns elevation in meters
487
- */
488
- getElevation(lnglat: LngLat, terrain: Terrain): number {
489
- const merc = MercatorCoordinate.fromLngLat(lnglat.wrap());
490
- const worldSize = (1 << this.tileZoom) * EXTENT;
491
- const mercX = merc.x * worldSize, mercY = merc.y * worldSize;
492
- const tileX = Math.floor(mercX / EXTENT), tileY = Math.floor(mercY / EXTENT);
493
- const tileID = new OverscaledTileID(this.tileZoom, 0, this.tileZoom, tileX, tileY);
494
- return terrain.getElevation(tileID, mercX % EXTENT, mercY % EXTENT, EXTENT);
495
- }
496
-
497
474
  /**
498
475
  * get the camera position in LngLat and altitudes in meter
499
476
  * @returns An object with lngLat & altitude.
@@ -516,7 +493,7 @@ export class Transform {
516
493
  recalculateZoom(terrain: Terrain) {
517
494
  // find position the camera is looking on
518
495
  const center = this.pointLocation(this.centerPoint, terrain);
519
- const elevation = this.getElevation(center, terrain);
496
+ const elevation = terrain.getElevationForLngLatZoom(center, this.tileZoom);
520
497
  const deltaElevation = this.elevation - elevation;
521
498
  if (!deltaElevation) return;
522
499
 
@@ -557,7 +534,7 @@ export class Transform {
557
534
  */
558
535
  locationPoint(lnglat: LngLat, terrain?: Terrain): Point {
559
536
  return terrain ?
560
- this.coordinatePoint(this.locationCoordinate(lnglat), this.getElevation(lnglat, terrain), this.pixelMatrix3D) :
537
+ this.coordinatePoint(this.locationCoordinate(lnglat), terrain.getElevationForLngLatZoom(lnglat, this.tileZoom), this.pixelMatrix3D) :
561
538
  this.coordinatePoint(this.locationCoordinate(lnglat));
562
539
  }
563
540
 
@@ -827,9 +804,11 @@ export class Transform {
827
804
  this.glCoordMatrix = m;
828
805
 
829
806
  // Calculate the camera to sea-level distance in pixel in respect of terrain
830
- // In case of negative elevation (e.g. the dead see) use the lower plane for calculation
831
- this.cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch);
832
- const lowestPlane = this._elevation < 0 ? this.cameraToCenterDistance : this.cameraToSeaLevelDistance;
807
+ const cameraToSeaLevelDistance = this.cameraToCenterDistance + this._elevation * this._pixelPerMeter / Math.cos(this._pitch);
808
+ // In case of negative minimum elevation (e.g. the dead see, under the sea maps) use a lower plane for calculation
809
+ const minElevation = Math.min(this.elevation, this._minEleveationForCurrentTile);
810
+ const cameraToLowestPointDistance = cameraToSeaLevelDistance - minElevation * this._pixelPerMeter / Math.cos(this._pitch);
811
+ const lowestPlane = minElevation < 0 ? cameraToLowestPointDistance : cameraToSeaLevelDistance;
833
812
 
834
813
  // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the
835
814
  // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.
package/src/gl/context.ts CHANGED
@@ -24,6 +24,7 @@ type ClearArgs = {
24
24
  };
25
25
 
26
26
  /**
27
+ * @internal
27
28
  * A webgl wrapper class to allow injection, mocking and abstaction
28
29
  */
29
30
  export class Context {
@@ -3,6 +3,7 @@ import {ColorAttachment, DepthAttachment, DepthStencilAttachment} from './value'
3
3
  import type {Context} from './context';
4
4
 
5
5
  /**
6
+ * @internal
6
7
  * A framebuffer holder object
7
8
  */
8
9
  export class Framebuffer {
@@ -4,6 +4,7 @@ import type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../d
4
4
  import type {Context} from '../gl/context';
5
5
 
6
6
  /**
7
+ * @internal
7
8
  * an index buffer class
8
9
  */
9
10
  export class IndexBuffer {
@@ -10,7 +10,8 @@ export type PoolObject = {
10
10
  inUse: boolean;
11
11
  };
12
12
  /**
13
- * RenderPool a resource pool for textures and framebuffers
13
+ * @internal
14
+ * `RenderPool` is a resource pool for textures and framebuffers
14
15
  */
15
16
  export class RenderPool {
16
17
  private _objects: Array<PoolObject>;
@@ -21,6 +21,7 @@ const AttributeType = {
21
21
  };
22
22
 
23
23
  /**
24
+ * @internal
24
25
  * The `VertexBuffer` class turns a `StructArray` into a WebGL buffer. Each member of the StructArray's
25
26
  * Struct type is converted to a WebGL attribute.
26
27
  */
@@ -28,7 +28,7 @@ describe('drawFill', () => {
28
28
  const painterMock: Painter = constructMockPainer();
29
29
  const layer: FillStyleLayer = constructMockLayer();
30
30
 
31
- const programMock = new Program(null as any, null as any, null as any, null as any, null as any, null as any, null as any);
31
+ const programMock = new Program(null as any, null as any, null as any, null as any, null as any, null as any);
32
32
  (painterMock.useProgram as jest.Mock).mockReturnValue(programMock);
33
33
 
34
34
  const mockTile = constructMockTile(layer);