maplibre-gl 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/readme.md +0 -2
- package/dist/maplibre-gl-dev.mjs +179 -190
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +869 -825
- package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared.mjs +2 -2
- package/dist/maplibre-gl-shared.mjs.map +1 -1
- package/dist/maplibre-gl-worker-dev.mjs +14 -12
- package/dist/maplibre-gl-worker-dev.mjs.map +1 -1
- package/dist/maplibre-gl-worker.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs.map +1 -1
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +24 -6
- package/dist/maplibre-gl.mjs +13 -13
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +10 -13
- package/src/data/bucket/fill_extrusion_bucket.test.ts +22 -0
- package/src/data/bucket/fill_extrusion_bucket.ts +16 -4
- package/src/data/bucket/round_polygon_corners.test.ts +159 -0
- package/src/data/bucket/round_polygon_corners.ts +121 -0
- package/src/data/bucket/symbol_bucket.test.ts +1 -1
- package/src/data/dem_data.test.ts +23 -23
- package/src/data/feature_position_map.test.ts +1 -1
- package/src/data/segment.test.ts +14 -14
- package/src/geo/bounds.test.ts +4 -4
- package/src/geo/lng_lat_bounds.test.ts +1 -1
- package/src/geo/projection/mercator_transform.test.ts +1 -1
- package/src/geo/projection/mercator_utils.test.ts +8 -8
- package/src/index.test.ts +7 -12
- package/src/render/glyph_manager.test.ts +6 -22
- package/src/render/painter.test.ts +2 -0
- package/src/render/painter.ts +7 -5
- package/src/render/subdivision.test.ts +22 -22
- package/src/render/terrain.test.ts +68 -34
- package/src/render/terrain.ts +69 -26
- package/src/source/canvas_source.test.ts +1 -1
- package/src/source/geojson_source.test.ts +5 -4
- package/src/source/geojson_source_diff.test.ts +2 -2
- package/src/source/geojson_worker_source.test.ts +9 -5
- package/src/source/image_source.test.ts +0 -3
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_tile_source.test.ts +15 -9
- package/src/source/rtl_text_plugin_main_thread.test.ts +14 -14
- package/src/source/source.test.ts +8 -8
- package/src/source/vector_tile_source.test.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +7 -5
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker_tile.test.ts +4 -2
- package/src/style/load_glyph_range.test.ts +8 -8
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/style.test.ts +36 -34
- package/src/style/style_layer/color_relief_style_layer.test.ts +1 -1
- package/src/style/style_layer/fill_extrusion_style_layer.ts +6 -3
- package/src/style/style_layer/raster_style_layer.test.ts +2 -2
- package/src/style/style_layer.test.ts +3 -50
- package/src/symbol/collision_index.test.ts +1 -1
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/tile/terrain_tile_manager.test.ts +2 -2
- package/src/tile/tile_id.test.ts +5 -5
- package/src/tile/tile_manager.test.ts +85 -72
- package/src/tile/tile_manager_in_view_tiles.test.ts +2 -2
- package/src/ui/camera.test.ts +137 -134
- package/src/ui/control/geolocate_control.test.ts +6 -29
- package/src/ui/handler/dblclick_zoom.test.ts +2 -2
- package/src/ui/handler/scroll_zoom.test.ts +2 -0
- package/src/ui/handler_manager.test.ts +7 -7
- package/src/ui/hash.test.ts +1 -0
- package/src/ui/map.ts +28 -18
- package/src/ui/map_tests/map_basic.test.ts +11 -23
- package/src/ui/map_tests/map_calculate_camera_options.test.ts +6 -6
- package/src/ui/map_tests/map_events.test.ts +5 -5
- package/src/ui/map_tests/map_global_state.test.ts +3 -3
- package/src/ui/map_tests/map_images.test.ts +3 -3
- package/src/ui/map_tests/map_is_moving.test.ts +1 -1
- package/src/ui/map_tests/map_is_rotating.test.ts +1 -1
- package/src/ui/map_tests/map_layer.test.ts +2 -1
- package/src/ui/map_tests/map_options.test.ts +1 -5
- package/src/ui/map_tests/map_pitch.test.ts +6 -6
- package/src/ui/map_tests/map_refresh_tiles.test.ts +2 -2
- package/src/ui/map_tests/map_render.test.ts +1 -1
- package/src/ui/map_tests/map_set_lod_params.test.ts +1 -1
- package/src/ui/map_tests/map_style.test.ts +9 -1
- package/src/ui/map_tests/map_terrain.test.ts +20 -0
- package/src/ui/map_tests/map_zoom.test.ts +15 -15
- package/src/ui/marker.test.ts +7 -13
- package/src/ui/popup.test.ts +3 -3
- package/src/util/actor.test.ts +6 -6
- package/src/util/ajax.test.ts +27 -39
- package/src/util/browser.test.ts +7 -9
- package/src/util/create_tile_mesh.test.ts +2 -2
- package/src/util/dispatcher.test.ts +1 -1
- package/src/util/evented.test.ts +4 -1
- package/src/util/fast_maths.test.ts +4 -4
- package/src/util/image_request.test.ts +6 -4
- package/src/util/struct_array.test.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/test/util.ts +1 -0
- package/src/util/time_control.test.ts +2 -2
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/util.test.ts +27 -13
- package/src/util/verticalize_punctuation.test.ts +4 -4
- package/src/util/web_worker_transfer.test.ts +5 -5
- package/src/webgl/draw/draw_custom.test.ts +13 -13
- package/src/webgl/draw/draw_debug.test.ts +1 -1
- package/src/webgl/draw/draw_fill.test.ts +12 -12
- package/src/webgl/draw/draw_symbol.test.ts +16 -16
- package/src/webgl/program.ts +2 -0
- package/src/webgl/render_to_texture.test.ts +5 -5
- package/src/webgl/state.test.ts +1 -1
- package/src/webgl/texture.test.ts +3 -3
- package/src/webgl/vertex_buffer.test.ts +1 -1
- package/build/rolldown_plugins.ts +0 -18
package/src/data/segment.test.ts
CHANGED
|
@@ -34,7 +34,7 @@ describe('SegmentVector', () => {
|
|
|
34
34
|
const second = mockUseSegment(segmentVector, vertexBuffer, indexBuffer, 10);
|
|
35
35
|
expect(first).toBeTruthy();
|
|
36
36
|
expect(second).toBeTruthy();
|
|
37
|
-
expect(first
|
|
37
|
+
expect(first).not.toBe(second);
|
|
38
38
|
expect(first.vertexLength).toBe(10);
|
|
39
39
|
expect(second.vertexLength).toBe(10);
|
|
40
40
|
expect(segmentVector.segments).toHaveLength(2);
|
|
@@ -49,7 +49,7 @@ describe('SegmentVector', () => {
|
|
|
49
49
|
const second = mockUseSegment(segmentVector, vertexBuffer, indexBuffer, 5);
|
|
50
50
|
expect(first).toBeTruthy();
|
|
51
51
|
expect(second).toBeTruthy();
|
|
52
|
-
expect(first
|
|
52
|
+
expect(first).toBe(second);
|
|
53
53
|
expect(first.vertexLength).toBe(10);
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -66,8 +66,8 @@ describe('SegmentVector', () => {
|
|
|
66
66
|
expect(first).toBeTruthy();
|
|
67
67
|
expect(second).toBeTruthy();
|
|
68
68
|
expect(third).toBeTruthy();
|
|
69
|
-
expect(first
|
|
70
|
-
expect(second
|
|
69
|
+
expect(first).not.toBe(second);
|
|
70
|
+
expect(second).toBe(third);
|
|
71
71
|
expect(first.vertexLength).toBe(5);
|
|
72
72
|
expect(third.vertexLength).toBe(10);
|
|
73
73
|
});
|
|
@@ -86,8 +86,8 @@ describe('SegmentVector', () => {
|
|
|
86
86
|
expect(first).toBeTruthy();
|
|
87
87
|
expect(second).toBeTruthy();
|
|
88
88
|
expect(third).toBeTruthy();
|
|
89
|
-
expect(first
|
|
90
|
-
expect(second
|
|
89
|
+
expect(first).not.toBe(second);
|
|
90
|
+
expect(second).toBe(third);
|
|
91
91
|
expect(first.vertexLength).toBe(5);
|
|
92
92
|
expect(third.vertexLength).toBe(10);
|
|
93
93
|
});
|
|
@@ -115,8 +115,8 @@ describe('SegmentVector', () => {
|
|
|
115
115
|
expect(first).toBeTruthy();
|
|
116
116
|
expect(second).toBeTruthy();
|
|
117
117
|
expect(third).toBeTruthy();
|
|
118
|
-
expect(first
|
|
119
|
-
expect(second
|
|
118
|
+
expect(first).toBe(second);
|
|
119
|
+
expect(second).toBe(third);
|
|
120
120
|
expect(first.vertexLength).toBe(15);
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -134,8 +134,8 @@ describe('SegmentVector', () => {
|
|
|
134
134
|
expect(first).toBeTruthy();
|
|
135
135
|
expect(second).toBeTruthy();
|
|
136
136
|
expect(third).toBeTruthy();
|
|
137
|
-
expect(first
|
|
138
|
-
expect(second
|
|
137
|
+
expect(first).not.toBe(second);
|
|
138
|
+
expect(second).toBe(third);
|
|
139
139
|
expect(first.vertexLength).toBe(5);
|
|
140
140
|
expect(third.vertexLength).toBe(10);
|
|
141
141
|
});
|
|
@@ -152,8 +152,8 @@ describe('SegmentVector', () => {
|
|
|
152
152
|
expect(first).toBeTruthy();
|
|
153
153
|
expect(second).toBeTruthy();
|
|
154
154
|
expect(third).toBeTruthy();
|
|
155
|
-
expect(first
|
|
156
|
-
expect(second
|
|
155
|
+
expect(first).not.toBe(second);
|
|
156
|
+
expect(second).toBe(third);
|
|
157
157
|
expect(first.vertexLength).toBe(5);
|
|
158
158
|
expect(second.vertexLength).toBe(10);
|
|
159
159
|
expect(segmentVector.segments).toHaveLength(2);
|
|
@@ -170,7 +170,7 @@ describe('SegmentVector', () => {
|
|
|
170
170
|
const second = mockUseSegment(segmentVector, vertexBuffer, indexBuffer, 5);
|
|
171
171
|
expect(first).toBeTruthy();
|
|
172
172
|
expect(second).toBeTruthy();
|
|
173
|
-
expect(first
|
|
173
|
+
expect(first).not.toBe(second);
|
|
174
174
|
expect(first.vertexLength).toBe(5);
|
|
175
175
|
expect(second.vertexLength).toBe(5);
|
|
176
176
|
expect(segmentVector.segments).toHaveLength(2);
|
|
@@ -197,7 +197,7 @@ describe('SegmentVector', () => {
|
|
|
197
197
|
const second = mockUseSegment(segmentVector, vertexBuffer, indexBuffer, 5, 2);
|
|
198
198
|
expect(first).toBeTruthy();
|
|
199
199
|
expect(second).toBeTruthy();
|
|
200
|
-
expect(first
|
|
200
|
+
expect(first).not.toBe(second);
|
|
201
201
|
expect(first.vertexLength).toBe(5);
|
|
202
202
|
expect(second.vertexLength).toBe(5);
|
|
203
203
|
expect(segmentVector.segments).toHaveLength(2);
|
package/src/geo/bounds.test.ts
CHANGED
|
@@ -21,8 +21,8 @@ describe('Bounds', () => {
|
|
|
21
21
|
const bounds = new Bounds();
|
|
22
22
|
bounds.extend(new Point(1, 2));
|
|
23
23
|
expect(bounds.empty()).toBeFalsy();
|
|
24
|
-
expect(bounds.height()).
|
|
25
|
-
expect(bounds.width()).
|
|
24
|
+
expect(bounds.height()).toBe(0);
|
|
25
|
+
expect(bounds.width()).toBe(0);
|
|
26
26
|
|
|
27
27
|
expect(bounds.contains(new Point(1, 2))).toBeTruthy();
|
|
28
28
|
expect(bounds.contains(new Point(2, 2))).toBeFalsy();
|
|
@@ -36,8 +36,8 @@ describe('Bounds', () => {
|
|
|
36
36
|
bounds.extend(new Point(1, 2));
|
|
37
37
|
bounds.extend(new Point(3, 5));
|
|
38
38
|
expect(bounds.empty()).toBeFalsy();
|
|
39
|
-
expect(bounds.width()).
|
|
40
|
-
expect(bounds.height()).
|
|
39
|
+
expect(bounds.width()).toBe(2);
|
|
40
|
+
expect(bounds.height()).toBe(3);
|
|
41
41
|
|
|
42
42
|
expect(bounds.contains(new Point(1, 2))).toBeTruthy();
|
|
43
43
|
expect(bounds.contains(new Point(3, 2))).toBeTruthy();
|
|
@@ -110,7 +110,7 @@ describe('transform', () => {
|
|
|
110
110
|
expect(transform.tileZoom).toBe(5);
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
test('set zoom clamps tileZoom to non negative value
|
|
113
|
+
test('set zoom clamps tileZoom to non negative value', () => {
|
|
114
114
|
const transform = new MercatorTransform({minZoom: -2, maxZoom: 22, minPitch: 0, maxPitch: 60});
|
|
115
115
|
transform.setZoom(-2);
|
|
116
116
|
expect(transform.tileZoom).toBe(0);
|
|
@@ -58,25 +58,25 @@ describe('mercator utils', () => {
|
|
|
58
58
|
describe('tileCoordinatesToMercatorCoordinates', () => {
|
|
59
59
|
const precisionDigits = 10;
|
|
60
60
|
|
|
61
|
-
test('
|
|
61
|
+
test('0,0', () => {
|
|
62
62
|
const result = tileCoordinatesToMercatorCoordinates(0, 0, new CanonicalTileID(0, 0, 0));
|
|
63
63
|
expect(result.x).toBe(0);
|
|
64
64
|
expect(result.y).toBe(0);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
test('
|
|
67
|
+
test('tile center', () => {
|
|
68
68
|
const result = tileCoordinatesToMercatorCoordinates(EXTENT / 2, EXTENT / 2, new CanonicalTileID(0, 0, 0));
|
|
69
69
|
expect(result.x).toBeCloseTo(0.5, precisionDigits);
|
|
70
70
|
expect(result.y).toBeCloseTo(0.5, precisionDigits);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
test('
|
|
73
|
+
test('higher zoom 0,0', () => {
|
|
74
74
|
const result = tileCoordinatesToMercatorCoordinates(0, 0, new CanonicalTileID(3, 0, 0));
|
|
75
75
|
expect(result.x).toBe(0);
|
|
76
76
|
expect(result.y).toBe(0);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
test('
|
|
79
|
+
test('higher zoom tile center', () => {
|
|
80
80
|
const result = tileCoordinatesToMercatorCoordinates(EXTENT / 2, EXTENT / 2, new CanonicalTileID(3, 0, 0));
|
|
81
81
|
expect(result.x).toBeCloseTo(1 / 16, precisionDigits);
|
|
82
82
|
expect(result.y).toBeCloseTo(1 / 16, precisionDigits);
|
|
@@ -86,25 +86,25 @@ describe('mercator utils', () => {
|
|
|
86
86
|
describe('tileCoordinatesToLocation', () => {
|
|
87
87
|
const precisionDigits = 5;
|
|
88
88
|
|
|
89
|
-
test('
|
|
89
|
+
test('0,0', () => {
|
|
90
90
|
const result = tileCoordinatesToLocation(0, 0, new CanonicalTileID(0, 0, 0));
|
|
91
91
|
expect(result.lng).toBeCloseTo(-180, precisionDigits);
|
|
92
92
|
expect(result.lat).toBeCloseTo(MAX_VALID_LATITUDE, precisionDigits);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
test('
|
|
95
|
+
test('tile center', () => {
|
|
96
96
|
const result = tileCoordinatesToLocation(EXTENT / 2, EXTENT / 2, new CanonicalTileID(0, 0, 0));
|
|
97
97
|
expect(result.lng).toBeCloseTo(0, precisionDigits);
|
|
98
98
|
expect(result.lat).toBeCloseTo(0, precisionDigits);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
test('
|
|
101
|
+
test('higher zoom 0,0', () => {
|
|
102
102
|
const result = tileCoordinatesToLocation(0, 0, new CanonicalTileID(3, 0, 0));
|
|
103
103
|
expect(result.lng).toBeCloseTo(-180, precisionDigits);
|
|
104
104
|
expect(result.lat).toBeCloseTo(MAX_VALID_LATITUDE, precisionDigits);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
test('
|
|
107
|
+
test('higher zoom mercator center', () => {
|
|
108
108
|
const result = tileCoordinatesToLocation(EXTENT, EXTENT, new CanonicalTileID(3, 3, 3));
|
|
109
109
|
expect(result.lng).toBeCloseTo(0, precisionDigits);
|
|
110
110
|
expect(result.lat).toBeCloseTo(0, precisionDigits);
|
package/src/index.test.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {config} from './util/config.ts';
|
|
|
3
3
|
import {addProtocol, getWorkerCount, removeProtocol, getVersion} from './index.ts';
|
|
4
4
|
import {getJSON, getArrayBuffer} from './util/ajax.ts';
|
|
5
5
|
import {ImageRequest} from './util/image_request.ts';
|
|
6
|
-
import {isAbortError} from './util/abort_error.ts';
|
|
7
6
|
|
|
8
7
|
describe('maplibre', () => {
|
|
9
8
|
beforeEach(() => {
|
|
@@ -37,7 +36,7 @@ describe('maplibre', () => {
|
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
test('addProtocol - getJSON', async () => {
|
|
40
|
-
const mockProtocol = vi.fn().
|
|
39
|
+
const mockProtocol = vi.fn().mockResolvedValue({data: {'foo': 'bar'}});
|
|
41
40
|
addProtocol('custom', mockProtocol);
|
|
42
41
|
|
|
43
42
|
const response = await getJSON({url: 'custom://test/url/json'}, new AbortController());
|
|
@@ -46,7 +45,7 @@ describe('maplibre', () => {
|
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
test('addProtocol - getArrayBuffer', async () => {
|
|
49
|
-
const mockProtocol = vi.fn().
|
|
48
|
+
const mockProtocol = vi.fn().mockResolvedValue({data: new ArrayBuffer(1), cacheControl: 'cache-control', expires: 'expires'});
|
|
50
49
|
addProtocol('custom', mockProtocol);
|
|
51
50
|
|
|
52
51
|
const response = await getArrayBuffer({url: 'custom://test/url/getArrayBuffer'}, new AbortController());
|
|
@@ -57,7 +56,7 @@ describe('maplibre', () => {
|
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
test('addProtocol - null response for getArrayBuffer results in empty array buffer', async () => {
|
|
60
|
-
const mockProtocol = vi.fn().
|
|
59
|
+
const mockProtocol = vi.fn().mockResolvedValue({data: null, cacheControl: 'cache-control', expires: 'expires'});
|
|
61
60
|
addProtocol('custom', mockProtocol);
|
|
62
61
|
|
|
63
62
|
const response = await getArrayBuffer({url: 'custom://test/url/getArrayBuffer'}, new AbortController());
|
|
@@ -69,7 +68,7 @@ describe('maplibre', () => {
|
|
|
69
68
|
});
|
|
70
69
|
|
|
71
70
|
test('addProtocol - returning ImageBitmap for getImage', async () => {
|
|
72
|
-
const mockProtocol = vi.fn().
|
|
71
|
+
const mockProtocol = vi.fn().mockResolvedValue({data: new ImageBitmap()});
|
|
73
72
|
addProtocol('custom', mockProtocol);
|
|
74
73
|
|
|
75
74
|
const img = await ImageRequest.getImage({url: 'custom://test/url/getImage'}, new AbortController());
|
|
@@ -78,7 +77,7 @@ describe('maplibre', () => {
|
|
|
78
77
|
});
|
|
79
78
|
|
|
80
79
|
test('addProtocol - returning HTMLImageElement for getImage', async () => {
|
|
81
|
-
const mockProtocol = vi.fn().
|
|
80
|
+
const mockProtocol = vi.fn().mockResolvedValue({data: new Image()});
|
|
82
81
|
addProtocol('custom', mockProtocol);
|
|
83
82
|
|
|
84
83
|
const img = await ImageRequest.getImage({url: 'custom://test/url/getImage'}, new AbortController());
|
|
@@ -88,7 +87,7 @@ describe('maplibre', () => {
|
|
|
88
87
|
|
|
89
88
|
test('addProtocol - error', async () => {
|
|
90
89
|
const mockError = new Error('test error');
|
|
91
|
-
const mockProtocol = vi.fn().
|
|
90
|
+
const mockProtocol = vi.fn().mockRejectedValue(mockError);
|
|
92
91
|
addProtocol('custom', mockProtocol);
|
|
93
92
|
|
|
94
93
|
const successCallback = vi.fn();
|
|
@@ -110,11 +109,7 @@ describe('maplibre', () => {
|
|
|
110
109
|
const abortController = new AbortController();
|
|
111
110
|
const promise = getJSON({url: 'custom://test/url/json'}, abortController);
|
|
112
111
|
abortController.abort();
|
|
113
|
-
|
|
114
|
-
await promise;
|
|
115
|
-
} catch (err) {
|
|
116
|
-
expect(isAbortError(err)).toBeTruthy();
|
|
117
|
-
}
|
|
112
|
+
await promise;
|
|
118
113
|
|
|
119
114
|
expect(cancelCalled).toBeTruthy();
|
|
120
115
|
});
|
|
@@ -208,9 +208,7 @@ describe('GlyphManager', () => {
|
|
|
208
208
|
test('GlyphManager caches locally generated glyphs', async () => {
|
|
209
209
|
|
|
210
210
|
const manager = createGlyphManager(true, 'sans-serif');
|
|
211
|
-
const drawSpy = GlyphManager.TinySDF.prototype
|
|
212
|
-
return {data: new Uint8ClampedArray(60 * 60)} as any;
|
|
213
|
-
});
|
|
211
|
+
const drawSpy = vi.spyOn(GlyphManager.TinySDF.prototype, 'draw').mockReturnValue({data: new Uint8ClampedArray(60 * 60)} as any);
|
|
214
212
|
|
|
215
213
|
// Katakana letter te
|
|
216
214
|
const returnedGlyphs = await manager.getGlyphs({'Arial Unicode MS': [0x30c6]});
|
|
@@ -220,22 +218,14 @@ describe('GlyphManager', () => {
|
|
|
220
218
|
});
|
|
221
219
|
|
|
222
220
|
test('GlyphManager passes no language to TinySDF by default', async () => {
|
|
223
|
-
const langSpy =
|
|
224
|
-
return {
|
|
225
|
-
draw: () => GLYPHS[0]
|
|
226
|
-
};
|
|
227
|
-
});
|
|
221
|
+
const langSpy = vi.spyOn(GlyphManager, 'TinySDF').mockImplementation(class { draw = () => GLYPHS[0]; });
|
|
228
222
|
const manager = createGlyphManager(true, 'sans-serif');
|
|
229
223
|
await manager.getGlyphs({'Arial Unicode MS': [0x30c6]});
|
|
230
224
|
expect(langSpy).toHaveBeenCalledWith(expect.not.objectContaining({lang: expect.anything()}));
|
|
231
225
|
});
|
|
232
226
|
|
|
233
227
|
test('GlyphManager sets the language on TinySDF', async () => {
|
|
234
|
-
const langSpy =
|
|
235
|
-
return {
|
|
236
|
-
draw: () => GLYPHS[0]
|
|
237
|
-
};
|
|
238
|
-
});
|
|
228
|
+
const langSpy = vi.spyOn(GlyphManager, 'TinySDF').mockImplementation(class { draw = () => GLYPHS[0]; });
|
|
239
229
|
const manager = createGlyphManager(true, 'sans-serif', 'zh');
|
|
240
230
|
await manager.getGlyphs({'Arial Unicode MS': [0x30c6]});
|
|
241
231
|
expect(langSpy).toHaveBeenCalledWith(expect.objectContaining({lang: 'zh'}));
|
|
@@ -244,9 +234,7 @@ describe('GlyphManager', () => {
|
|
|
244
234
|
test('awaits document.fonts.load before instantiating TinySDF', async () => {
|
|
245
235
|
const loadSpy = vi.fn(() => Promise.resolve([]));
|
|
246
236
|
Object.defineProperty(document, 'fonts', {configurable: true, value: {load: loadSpy}});
|
|
247
|
-
const tinySdfSpy =
|
|
248
|
-
return {draw: () => GLYPHS[0]};
|
|
249
|
-
});
|
|
237
|
+
const tinySdfSpy = vi.spyOn(GlyphManager, 'TinySDF').mockImplementation(class { draw = () => GLYPHS[0]; });
|
|
250
238
|
|
|
251
239
|
const manager = createGlyphManager(false, 'sans-serif');
|
|
252
240
|
await manager.getGlyphs({'Arial Unicode MS': [0x41]});
|
|
@@ -260,9 +248,7 @@ describe('GlyphManager', () => {
|
|
|
260
248
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
261
249
|
const loadSpy = vi.fn(() => Promise.reject(new Error('font not found')));
|
|
262
250
|
Object.defineProperty(document, 'fonts', {configurable: true, value: {load: loadSpy}});
|
|
263
|
-
const tinySdfSpy =
|
|
264
|
-
return {draw: () => GLYPHS[0]};
|
|
265
|
-
});
|
|
251
|
+
const tinySdfSpy = vi.spyOn(GlyphManager, 'TinySDF').mockImplementation(class { draw = () => GLYPHS[0]; });
|
|
266
252
|
|
|
267
253
|
const manager = createGlyphManager(false, 'sans-serif');
|
|
268
254
|
const result = await manager.getGlyphs({'Arial Unicode MS': [0x41]});
|
|
@@ -275,9 +261,7 @@ describe('GlyphManager', () => {
|
|
|
275
261
|
test('memoizes document.fonts.load per fontstack', async () => {
|
|
276
262
|
const loadSpy = vi.fn(() => Promise.resolve([]));
|
|
277
263
|
Object.defineProperty(document, 'fonts', {configurable: true, value: {load: loadSpy}});
|
|
278
|
-
|
|
279
|
-
return {draw: () => GLYPHS[0]};
|
|
280
|
-
});
|
|
264
|
+
vi.spyOn(GlyphManager, 'TinySDF').mockImplementation(class { draw = () => GLYPHS[0]; });
|
|
281
265
|
|
|
282
266
|
const manager = createGlyphManager(false, 'sans-serif');
|
|
283
267
|
await manager.getGlyphs({'Arial Unicode MS': [0x41]});
|
package/src/render/painter.ts
CHANGED
|
@@ -318,12 +318,14 @@ export class Painter {
|
|
|
318
318
|
stencilRefs[tileID.key] = this.nextStencilID++;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
// A two-pass approach is needed. See comment in draw_raster.ts
|
|
322
|
-
//
|
|
321
|
+
// A two-pass approach is needed for subdivided projections. See comment in draw_raster.ts
|
|
322
|
+
// for more details. In non-subdivided projections the border flag does not change the mesh,
|
|
323
|
+
// so one pass produces the same stencil mask.
|
|
324
|
+
if (this.style.projection.useSubdivision) {
|
|
325
|
+
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
326
|
+
}
|
|
323
327
|
|
|
324
|
-
//
|
|
325
|
-
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
326
|
-
// Second pass - draw borderless tiles with GL_ALWAYS
|
|
328
|
+
// Final pass - draw borderless tiles with GL_ALWAYS
|
|
327
329
|
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, false);
|
|
328
330
|
|
|
329
331
|
this._tileClippingMaskIDs = stencilRefs;
|
|
@@ -224,7 +224,7 @@ describe('Fill subdivision', () => {
|
|
|
224
224
|
3, 0
|
|
225
225
|
]
|
|
226
226
|
]);
|
|
227
|
-
|
|
227
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
test('Polygon is unchanged when granularity=1, but winding order is corrected.', () => {
|
|
@@ -259,7 +259,7 @@ describe('Fill subdivision', () => {
|
|
|
259
259
|
3, 0
|
|
260
260
|
]
|
|
261
261
|
]);
|
|
262
|
-
|
|
262
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
263
263
|
});
|
|
264
264
|
|
|
265
265
|
test('Polygon inside cell is unchanged', () => {
|
|
@@ -294,7 +294,7 @@ describe('Fill subdivision', () => {
|
|
|
294
294
|
3, 0
|
|
295
295
|
]
|
|
296
296
|
]);
|
|
297
|
-
|
|
297
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
test('Subdivide a polygon', () => {
|
|
@@ -404,7 +404,7 @@ describe('Fill subdivision', () => {
|
|
|
404
404
|
6, 3
|
|
405
405
|
]
|
|
406
406
|
]);
|
|
407
|
-
|
|
407
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
408
408
|
});
|
|
409
409
|
|
|
410
410
|
describe('Polygon outline line list is correct', () => {
|
|
@@ -419,7 +419,7 @@ describe('Fill subdivision', () => {
|
|
|
419
419
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
420
420
|
testMeshIntegrity(result.indicesTriangles);
|
|
421
421
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
422
|
-
|
|
422
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
423
423
|
});
|
|
424
424
|
|
|
425
425
|
test('Small polygon', () => {
|
|
@@ -433,7 +433,7 @@ describe('Fill subdivision', () => {
|
|
|
433
433
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
434
434
|
testMeshIntegrity(result.indicesTriangles);
|
|
435
435
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
436
|
-
|
|
436
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
437
437
|
});
|
|
438
438
|
|
|
439
439
|
test('Medium polygon', () => {
|
|
@@ -447,7 +447,7 @@ describe('Fill subdivision', () => {
|
|
|
447
447
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
448
448
|
testMeshIntegrity(result.indicesTriangles);
|
|
449
449
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
450
|
-
|
|
450
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
451
451
|
});
|
|
452
452
|
|
|
453
453
|
test('Large polygon', () => {
|
|
@@ -461,7 +461,7 @@ describe('Fill subdivision', () => {
|
|
|
461
461
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
462
462
|
testMeshIntegrity(result.indicesTriangles);
|
|
463
463
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
464
|
-
|
|
464
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
465
465
|
});
|
|
466
466
|
|
|
467
467
|
test('Large polygon with hole', () => {
|
|
@@ -480,7 +480,7 @@ describe('Fill subdivision', () => {
|
|
|
480
480
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
481
481
|
testMeshIntegrity(result.indicesTriangles);
|
|
482
482
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
483
|
-
|
|
483
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
484
484
|
});
|
|
485
485
|
|
|
486
486
|
test('Large polygon with hole, granularity=0', () => {
|
|
@@ -499,7 +499,7 @@ describe('Fill subdivision', () => {
|
|
|
499
499
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
500
500
|
testMeshIntegrity(result.indicesTriangles);
|
|
501
501
|
testPolygonOutlineMatches(result.indicesTriangles, result.indicesLineList);
|
|
502
|
-
|
|
502
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
503
503
|
});
|
|
504
504
|
|
|
505
505
|
test('Large polygon with hole, finer granularity', () => {
|
|
@@ -517,7 +517,7 @@ describe('Fill subdivision', () => {
|
|
|
517
517
|
], canonicalDefault, EXTENT / 8);
|
|
518
518
|
|
|
519
519
|
expect(hasDuplicateVertices(result.verticesFlattened)).toBe(false);
|
|
520
|
-
|
|
520
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
521
521
|
|
|
522
522
|
// This polygon subdivision results in at least one edge that is shared among more than 2 triangles.
|
|
523
523
|
// This is not ideal, but it is also an edge case of a weird triangle getting subdivided by a very fine grid.
|
|
@@ -586,7 +586,7 @@ describe('Fill subdivision', () => {
|
|
|
586
586
|
5, 3
|
|
587
587
|
]
|
|
588
588
|
]);
|
|
589
|
-
|
|
589
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
590
590
|
});
|
|
591
591
|
|
|
592
592
|
test('Polygon with duplicate vertex with hole inside cell', () => {
|
|
@@ -640,7 +640,7 @@ describe('Fill subdivision', () => {
|
|
|
640
640
|
4, 0
|
|
641
641
|
]
|
|
642
642
|
]);
|
|
643
|
-
|
|
643
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
644
644
|
});
|
|
645
645
|
|
|
646
646
|
test('Polygon with duplicate edge inside cell', () => {
|
|
@@ -700,7 +700,7 @@ describe('Fill subdivision', () => {
|
|
|
700
700
|
3, 0
|
|
701
701
|
]
|
|
702
702
|
]);
|
|
703
|
-
|
|
703
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
704
704
|
});
|
|
705
705
|
});
|
|
706
706
|
|
|
@@ -777,7 +777,7 @@ describe('Fill subdivision', () => {
|
|
|
777
777
|
4, 0
|
|
778
778
|
]
|
|
779
779
|
]);
|
|
780
|
-
|
|
780
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
781
781
|
});
|
|
782
782
|
|
|
783
783
|
test('Generates pole geometry for north pole only (geometry not bordering other pole)', () => {
|
|
@@ -813,7 +813,7 @@ describe('Fill subdivision', () => {
|
|
|
813
813
|
2, 3, 3, 0
|
|
814
814
|
]
|
|
815
815
|
]);
|
|
816
|
-
|
|
816
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
817
817
|
});
|
|
818
818
|
|
|
819
819
|
test('Generates pole geometry for south pole only (geometry not bordering other pole)', () => {
|
|
@@ -849,7 +849,7 @@ describe('Fill subdivision', () => {
|
|
|
849
849
|
2, 3, 3, 0
|
|
850
850
|
]
|
|
851
851
|
]);
|
|
852
|
-
|
|
852
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
853
853
|
});
|
|
854
854
|
|
|
855
855
|
test('Generates pole geometry for north pole only (tile not bordering other pole)', () => {
|
|
@@ -885,7 +885,7 @@ describe('Fill subdivision', () => {
|
|
|
885
885
|
2, 3, 3, 0
|
|
886
886
|
]
|
|
887
887
|
]);
|
|
888
|
-
|
|
888
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
889
889
|
});
|
|
890
890
|
|
|
891
891
|
test('Generates pole geometry for south pole only (tile not bordering other pole)', () => {
|
|
@@ -921,7 +921,7 @@ describe('Fill subdivision', () => {
|
|
|
921
921
|
2, 3, 3, 0
|
|
922
922
|
]
|
|
923
923
|
]);
|
|
924
|
-
|
|
924
|
+
expectWindingOrder(result.verticesFlattened, result.indicesTriangles);
|
|
925
925
|
});
|
|
926
926
|
|
|
927
927
|
test('Scanline subdivision ring generation case 1', () => {
|
|
@@ -951,7 +951,7 @@ describe('Fill subdivision', () => {
|
|
|
951
951
|
const ring = [0, 1, 2, 3, 4, 5, 6, 7];
|
|
952
952
|
const finalIndices = [];
|
|
953
953
|
scanlineTriangulateVertexRing(vertices, ring, finalIndices);
|
|
954
|
-
|
|
954
|
+
expectWindingOrder(vertices, finalIndices);
|
|
955
955
|
});
|
|
956
956
|
|
|
957
957
|
test('Scanline subdivision ring generation case 2', () => {
|
|
@@ -960,7 +960,7 @@ describe('Fill subdivision', () => {
|
|
|
960
960
|
const ring = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
961
961
|
const finalIndices = [];
|
|
962
962
|
scanlineTriangulateVertexRing(vertices, ring, finalIndices);
|
|
963
|
-
|
|
963
|
+
expectWindingOrder(vertices, finalIndices);
|
|
964
964
|
});
|
|
965
965
|
});
|
|
966
966
|
|
|
@@ -1075,7 +1075,7 @@ function hasDuplicateVertices(flattened: number[]): boolean {
|
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Passes if all triangles have the correct winding order, otherwise throws.
|
|
1077
1077
|
*/
|
|
1078
|
-
function
|
|
1078
|
+
function expectWindingOrder(flattened: number[], indices: number[]): void {
|
|
1079
1079
|
for (let i = 0; i < indices.length; i += 3) {
|
|
1080
1080
|
const i0 = indices[i];
|
|
1081
1081
|
const i1 = indices[i + 1];
|