maplibre-gl 6.1.0 → 6.3.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 +694 -406
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +971 -882
- 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 +35 -59
- 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 +238 -65
- package/dist/maplibre-gl.mjs +44 -44
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +13 -26
- 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_index.bench.ts +21 -0
- package/src/data/feature_position_map.test.ts +1 -1
- package/src/data/segment.test.ts +16 -16
- package/src/geo/bounds.test.ts +4 -4
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/lng_lat.test.ts +7 -7
- package/src/geo/lng_lat_bounds.test.ts +5 -5
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/projection/camera_helper.ts +5 -0
- package/src/geo/projection/globe_transform.test.ts +25 -0
- package/src/geo/projection/globe_transform.ts +7 -3
- package/src/geo/projection/mercator_camera_helper.ts +1 -1
- package/src/geo/projection/mercator_transform.test.ts +1 -1
- package/src/geo/projection/mercator_transform.ts +21 -5
- package/src/geo/projection/mercator_utils.test.ts +8 -8
- package/src/geo/projection/vertical_perspective_camera_helper.ts +60 -31
- package/src/geo/projection/vertical_perspective_transform.ts +7 -1
- package/src/geo/transform_interface.ts +13 -1
- package/src/index.test.ts +7 -12
- package/src/index.ts +7 -2
- package/src/render/glyph_manager.test.ts +6 -22
- package/src/render/image_atlas.test.ts +72 -0
- package/src/render/image_atlas.ts +17 -2
- package/src/render/image_manager.test.ts +46 -0
- package/src/render/image_manager.ts +9 -2
- package/src/render/painter.test.ts +2 -0
- package/src/render/painter.ts +8 -17
- 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/render/update_pattern_positions_in_program.test.ts +1 -1
- package/src/shaders/glsl/_prelude.vertex.glsl +2 -3
- package/src/shaders/glsl/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/circle.vertex.glsl +4 -4
- package/src/shaders/glsl/circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/fill_extrusion.vertex.glsl +3 -3
- package/src/shaders/glsl/fill_extrusion.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl +5 -5
- package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/heatmap.vertex.glsl +4 -4
- package/src/shaders/glsl/heatmap.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line.vertex.glsl +7 -7
- package/src/shaders/glsl/line.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_gradient.vertex.glsl +6 -6
- package/src/shaders/glsl/line_gradient.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_gradient_sdf.vertex.glsl +7 -7
- package/src/shaders/glsl/line_gradient_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_pattern.vertex.glsl +7 -7
- package/src/shaders/glsl/line_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_sdf.vertex.glsl +7 -7
- package/src/shaders/glsl/line_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/raster.fragment.glsl +4 -4
- package/src/shaders/glsl/raster.fragment.glsl.g.ts +1 -1
- package/src/shaders/glsl/raster.vertex.glsl +11 -6
- package/src/shaders/glsl/raster.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_icon.vertex.glsl +5 -5
- package/src/shaders/glsl/symbol_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_sdf.vertex.glsl +5 -5
- package/src/shaders/glsl/symbol_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl +6 -6
- package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
- package/src/source/canvas_source.test.ts +32 -1
- package/src/source/canvas_source.ts +2 -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 +97 -5
- package/src/source/geojson_worker_source.ts +22 -39
- package/src/source/image_source.test.ts +205 -10
- package/src/source/image_source.ts +118 -4
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.test.ts +1 -1
- 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 +101 -7
- package/src/source/vector_tile_worker_source.ts +18 -27
- package/src/source/video_source.test.ts +12 -8
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker_tile.bench.ts +10 -0
- package/src/source/worker_tile.test.ts +4 -2
- package/src/source/worker_tile.ts +0 -3
- package/src/style/create_style_layer.bench.ts +15 -0
- package/src/style/load_glyph_range.test.ts +8 -8
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/properties.bench.ts +81 -0
- package/src/style/style.test.ts +47 -44
- package/src/style/style_image.ts +67 -9
- 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.bench.ts +65 -0
- package/src/style/style_layer.test.ts +4 -51
- package/src/style/style_layer.ts +2 -2
- package/src/style/validate_style.bench.ts +11 -0
- package/src/style/validate_style.test.ts +2 -2
- package/src/symbol/anchor.test.ts +2 -2
- package/src/symbol/collision_index.bench.ts +116 -0
- package/src/symbol/collision_index.test.ts +1 -1
- package/src/symbol/cross_tile_symbol_index.bench.ts +49 -0
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/shaping.test.ts +2 -1
- package/src/symbol/symbol_layout.bench.ts +30 -0
- package/src/tile/terrain_tile_manager.test.ts +2 -2
- package/src/tile/tile_id.test.ts +6 -6
- package/src/tile/tile_manager.test.ts +85 -72
- package/src/tile/tile_manager.ts +2 -2
- package/src/tile/tile_manager_in_view_tiles.test.ts +2 -2
- package/src/ui/camera.test.ts +137 -134
- package/src/ui/control/fullscreen_control.test.ts +10 -10
- package/src/ui/control/geolocate_control.test.ts +9 -34
- package/src/ui/control/globe_control.test.ts +6 -6
- package/src/ui/events.ts +1 -1
- package/src/ui/handler/dblclick_zoom.test.ts +2 -2
- package/src/ui/handler/scroll_zoom.test.ts +52 -0
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler_manager.test.ts +250 -10
- package/src/ui/handler_manager.ts +79 -16
- package/src/ui/hash.test.ts +1 -0
- package/src/ui/map.ts +45 -21
- 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_cross_window.test.ts +2 -2
- package/src/ui/map_tests/map_events.test.ts +8 -8
- package/src/ui/map_tests/map_global_state.test.ts +3 -3
- package/src/ui/map_tests/map_images.test.ts +32 -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 +18 -9
- package/src/ui/map_tests/map_terrain.test.ts +20 -0
- package/src/ui/map_tests/map_webgl.test.ts +29 -0
- package/src/ui/map_tests/map_zoom.test.ts +15 -15
- package/src/ui/marker.test.ts +33 -55
- package/src/ui/popup.test.ts +17 -17
- 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 +37 -29
- package/src/util/evented.ts +69 -43
- 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/null_gl.ts +10 -0
- package/src/util/test/util.ts +3 -1
- 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 +28 -14
- package/src/util/verticalize_punctuation.test.ts +4 -4
- package/src/util/web_worker_transfer.test.ts +10 -10
- package/src/webgl/context.ts +20 -0
- 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_raster.ts +11 -6
- package/src/webgl/draw/draw_symbol.test.ts +16 -16
- package/src/webgl/program/raster_program.ts +11 -0
- package/src/webgl/program.ts +31 -14
- package/src/webgl/render_to_texture.test.ts +5 -5
- package/src/webgl/state.test.ts +1 -1
- package/src/webgl/texture.test.ts +19 -4
- package/src/webgl/texture.ts +3 -0
- package/src/webgl/vertex_buffer.test.ts +18 -3
- package/src/webgl/vertex_buffer.ts +24 -13
- package/build/rolldown_plugins.ts +0 -18
package/dist/maplibre-gl-dev.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MapLibre GL JS
|
|
3
|
-
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.3.0/LICENSE.txt
|
|
4
4
|
*/
|
|
5
|
-
import { $n as
|
|
5
|
+
import { $ as projectToWorldCoordinates, $n as defaultEasing, $r as add, $t as Transitionable, A as getOverlapMode, Ai as rotateZ, An as makeRequest, Ar as rollPitchBearingEqual, At as Uniform1f, B as parseGlyphPbf, Bi as offscreenCanvasSupported, Bn as MAX_VALID_LATITUDE, Br as zoomScale, Bt as CollisionBoxArray, C as createStyleLayer, Ci as identity, Cn as Evented, Cr as parseCacheControl, Ct as isHeatmapStyleLayer, D as isSymbolStyleLayer, Di as perspective, Dn as getJSON, Dr as rayPlaneIntersection, Dt as isCircleStyleLayer, E as isBackgroundStyleLayer, Ei as ortho, En as getArrayBuffer, Er as radiansToDegrees, Et as RGBAImage, Fi as create$2, Fn as config, Fr as threePlaneIntersection, Ft as UniformColor, Gn as clamp, Gr as scale$1, Gt as QuadTriangleArray, H as collisionCircleLayout, Hn as arrayBufferToImage, Hr as EXTENT, Ht as LineStripIndexArray, I as ImagePosition, Ii as determinant, In as AbortError, Ir as translatePosition, It as UniformColorArray, J as calculateTileMatrix, Jn as createIdentityMat4f64, Jr as fromEuler, Jt as createLayout, K as isFillExtrusionStyleLayer, Kn as clone$2, Kr as sqrLen, Kt as RasterBoundsArray, L as potpack, Li as invert, Ln as isAbortError, Lr as uniqueId, Lt as UniformFloatArray, M as evaluateSizeForZoom, Mi as translate, Mn as addProtocol, Mr as scaleZoom, Mt as Uniform2f, Ni as create$4, Nn as getProtocol, Nr as sphericalToCartesian, Nt as Uniform3f, O as SymbolBucket, Oi as rotateX, On as getReferrer, Or as readImageUsingVideoFrame, Ot as polygonIntersectsPolygon, P as getAnchorAlignment, Pi as fromRotation, Pn as removeProtocol, Pr as subscribe, Pt as Uniform4f, Q as maxMercatorHorizonAngle, Qn as deepEqual, Qr as transformMat4, Qt as TRANSITION_SUFFIX, R as isStyleImageWebGLData, Ri as rotate, Rn as throwIfAborted, Rr as warnOnce, Rt as UniformMatrix4f, S as Actor, Si as fromScaling, Sn as Event, Sr as nextPowerOfTwo, St as HEATMAP_FULL_RENDER_FBO_KEY, T as validateCustomStyleLayer, Ti as multiply, Tn as GLOBAL_DISPATCHER_ID, Tr as pointPlaneSignedDistance, Tt as AlphaImage, U as isLineStyleLayer, Un as arrayBufferToImageBitmap, Ur as create$3, Ut as Pos3dArray, Vi as Point, Vn as angleToRotateBetweenVectors2D, Vr as pixelsToTileUnits, Vt as CollisionCircleLayoutArray, Wn as bezier, Wr as length, Wt as PosArray, X as cameraMercatorCoordinateFromCenterAndRotation, Xn as createVec3f64, Xr as mul, Xt as DataConstantProperty, Y as cameraDirectionFromPitchBearing, Yn as createMat4f64, Yr as slerp, Yt as isRasterStyleLayer, Z as getMercatorHorizon, Zn as createVec4f64, Zr as scale$3, Zt as Properties, _ as OverscaledTileID, _i as clone$1, _n as featureFilter, _r as isTouchableOrPointableType, _t as SubdivisionGranularitySetting, a as clipLine, ai as negate, an as SPEC_SOURCE_TYPES, ar as extend, at as lngFromMercatorX, b as compareTileId, bi as equals, bn as latest, br as mapObject, bt as Texture, ci as rotateY, cn as validateStyle, cr as getAABB, ct as mercatorZfromAltitude, di as scaleAndAdd, dn as ProjectionDefinition, ei as clone, en as EvaluationParameters, er as degreesToRadians, et as tileCoordinatesToMercatorCoordinates, f as GEOJSON_TILE_LAYER_NAME, fi as sub, fn as ValidationError, fr as getRollPitchBearing, ft as isFillStyleLayer, g as CanonicalTileID, gi as zero$1, gn as emptyStyle, gr as isTouchableEvent, gt as SubdivisionGranularityExpression, h as Bounds, hi as transformQuat, hn as diff, hr as isSafari, ht as SOUTH_POLE_Y, ii as length$1, ir as evaluateZoomSnap, it as latFromMercatorY, j as evaluateSizeForFeature, ji as scale, jn as sameOrigin, jr as rollPitchBearingToQuat, jt as Uniform1i, k as addDynamicAttributes, ki as rotateY$1, kn as getVideo, kr as remapSaturate, kt as toEvaluationFeature, li as rotateZ$1, ln as validateStyleAndEmit, lr as getAngleDelta, lt as LngLat, mi as transformMat4$1, mn as derefLayers, mr as isPointableEvent, mt as NORTH_POLE_Y, ni as dot, nn as codePointUsesLocalIdeographFontFamily, nr as distanceOfAnglesRadians, nt as MercatorCoordinate, oi as normalize, on as emitValidationErrors, or as filterObject, ot as mercatorXfromLng, pi as transformMat3, pr as isImageBitmap, qn as createIdentityMat4f32, qr as zero, qt as TriangleIndexArray, r as TextAnchorEnum, ri as len, rn as ZoomHistory, rr as ensureError, rt as altitudeFromMercatorZ, s as TileCache, si as rotateX$1, sn as validateAndEmit, sr as findLineIntersection, st as mercatorYfromLat, t as getAnchorJustification, ti as cross, tr as differenceOfAnglesDegrees, tt as unprojectFromWorldCoordinates, u as GeoJSONFeature, ui as scale$2, un as Color, ur as getEdgeTiles, ut as earthRadius, v as UnwrappedTileID, vi as copy, vr as isWorker, vt as isColorReliefStyleLayer, w as isCustomStyleLayer, wi as invert$1, wn as AJAXError, wr as pick, wt as renderColorRamp, x as isInBoundsForZoomLngLat, xi as exactEquals, xn as ErrorEvent, xr as mod, xt as isHillshadeStyleLayer, y as calculateTileKey, yi as create$1, yn as interpolateFactory, yr as lerp, z as renderStyleImage, zi as isOffscreenCanvasDistorted, zr as wrap, zt as SegmentVector } from "./maplibre-gl-shared-dev.mjs";
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version$2 = "6.
|
|
7
|
+
var version$2 = "6.3.0";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/util/browser.ts
|
|
10
10
|
let linkEl;
|
|
@@ -709,7 +709,8 @@ async function loadSprite(originalSprite, requestManager, pixelRatio, abortContr
|
|
|
709
709
|
const jsonsMap = {};
|
|
710
710
|
const imagesMap = {};
|
|
711
711
|
for (const { id, url } of spriteArray) {
|
|
712
|
-
|
|
712
|
+
const jsonRequestParameters = await requestManager.transformRequest(normalizeSpriteURL(url, format, ".json"), "SpriteJSON");
|
|
713
|
+
jsonsMap[id] = getJSON(jsonRequestParameters, abortController);
|
|
713
714
|
const imageRequestParameters = await requestManager.transformRequest(normalizeSpriteURL(url, format, ".png"), "SpriteImage");
|
|
714
715
|
imagesMap[id] = ImageRequest.getImage(imageRequestParameters, abortController);
|
|
715
716
|
}
|
|
@@ -824,7 +825,10 @@ var ImageManager = class extends Evented {
|
|
|
824
825
|
}
|
|
825
826
|
addImage(id, image) {
|
|
826
827
|
if (this.images[id]) throw new Error(`Image id ${id} already exist, use updateImage instead`);
|
|
827
|
-
if (this._validate(id, image))
|
|
828
|
+
if (this._validate(id, image)) {
|
|
829
|
+
this.images[id] = image;
|
|
830
|
+
if (image.isWebGLImage) this.updateImage(id, image, false);
|
|
831
|
+
}
|
|
828
832
|
}
|
|
829
833
|
_validate(id, image) {
|
|
830
834
|
let valid = true;
|
|
@@ -916,7 +920,8 @@ var ImageManager = class extends Evented {
|
|
|
916
920
|
content: image.content,
|
|
917
921
|
textFitWidth: image.textFitWidth,
|
|
918
922
|
textFitHeight: image.textFitHeight,
|
|
919
|
-
hasRenderCallback: Boolean(image.userImage?.render)
|
|
923
|
+
hasRenderCallback: Boolean(image.userImage?.render),
|
|
924
|
+
isWebGLImage: image.isWebGLImage
|
|
920
925
|
};
|
|
921
926
|
}
|
|
922
927
|
}
|
|
@@ -940,8 +945,8 @@ var ImageManager = class extends Evented {
|
|
|
940
945
|
if (pattern && pattern.position.version === image.version) return pattern.position;
|
|
941
946
|
if (!pattern) {
|
|
942
947
|
const bin = {
|
|
943
|
-
w: image.data.width +
|
|
944
|
-
h: image.data.height +
|
|
948
|
+
w: image.data.width + 2,
|
|
949
|
+
h: image.data.height + 2,
|
|
945
950
|
x: 0,
|
|
946
951
|
y: 0
|
|
947
952
|
};
|
|
@@ -1061,7 +1066,8 @@ var ImageManager = class extends Evented {
|
|
|
1061
1066
|
async function loadGlyphRange(fontstack, range, urlTemplate, requestManager) {
|
|
1062
1067
|
const begin = range * 256;
|
|
1063
1068
|
const end = begin + 255;
|
|
1064
|
-
const
|
|
1069
|
+
const request = await requestManager.transformRequest(urlTemplate.replace("{fontstack}", fontstack).replace("{range}", `${begin}-${end}`), "Glyphs");
|
|
1070
|
+
const response = await getArrayBuffer(request, new AbortController());
|
|
1065
1071
|
if (!response?.data) throw new Error(`Could not load glyph range. range: ${range}, ${begin}-${end}`);
|
|
1066
1072
|
const glyphs = {};
|
|
1067
1073
|
for (const glyph of parseGlyphPbf(response.data)) glyphs[glyph.id] = glyph;
|
|
@@ -1280,7 +1286,9 @@ var GlyphManager = class GlyphManager {
|
|
|
1280
1286
|
}
|
|
1281
1287
|
_warnOnMissingGlyphRange(glyph, range, id, err) {
|
|
1282
1288
|
const begin = range * 256;
|
|
1283
|
-
|
|
1289
|
+
const end = begin + 255;
|
|
1290
|
+
const codePoint = id.toString(16).padStart(4, "0").toUpperCase();
|
|
1291
|
+
warnOnce(`Unable to load glyph range ${range}, ${begin}-${end}. Rendering codepoint U+${codePoint} locally instead. ${err}`);
|
|
1284
1292
|
}
|
|
1285
1293
|
/**
|
|
1286
1294
|
* Returns whether the given codepoint should be rendered locally.
|
|
@@ -1315,8 +1323,8 @@ var GlyphManager = class GlyphManager {
|
|
|
1315
1323
|
return {
|
|
1316
1324
|
id,
|
|
1317
1325
|
bitmap: new AlphaImage({
|
|
1318
|
-
width: char.width ||
|
|
1319
|
-
height: char.height ||
|
|
1326
|
+
width: char.width || 60,
|
|
1327
|
+
height: char.height || 60
|
|
1320
1328
|
}, char.data),
|
|
1321
1329
|
metrics: {
|
|
1322
1330
|
width: isControl ? 0 : char.glyphWidth / textureScale || 24,
|
|
@@ -1332,7 +1340,7 @@ var GlyphManager = class GlyphManager {
|
|
|
1332
1340
|
const fontFamilies = stack ? stack.split(",") : [];
|
|
1333
1341
|
fontFamilies.push(defaultGenericFontFamily);
|
|
1334
1342
|
const fontFamily = fontFamilies.map((fontName) => /[-\w]+/.test(fontName) ? fontName : `'${CSS.escape(fontName)}'`).join(",");
|
|
1335
|
-
const fontSize =
|
|
1343
|
+
const fontSize = 48;
|
|
1336
1344
|
const fontWeight = this._fontWeight(fontFamilies[0]);
|
|
1337
1345
|
const fontStyle = this._fontStyle(fontFamilies[0]);
|
|
1338
1346
|
if (typeof document !== "undefined" && document.fonts?.load) try {
|
|
@@ -1342,8 +1350,8 @@ var GlyphManager = class GlyphManager {
|
|
|
1342
1350
|
}
|
|
1343
1351
|
return new GlyphManager.TinySDF({
|
|
1344
1352
|
fontSize,
|
|
1345
|
-
buffer:
|
|
1346
|
-
radius:
|
|
1353
|
+
buffer: 6,
|
|
1354
|
+
radius: 16,
|
|
1347
1355
|
cutoff: .25,
|
|
1348
1356
|
fontFamily,
|
|
1349
1357
|
fontWeight,
|
|
@@ -1810,10 +1818,12 @@ function prewarm() {
|
|
|
1810
1818
|
*/
|
|
1811
1819
|
function clearPrewarmedResources() {
|
|
1812
1820
|
const pool = globalWorkerPool;
|
|
1813
|
-
if (pool)
|
|
1814
|
-
pool.
|
|
1815
|
-
|
|
1816
|
-
|
|
1821
|
+
if (pool) {
|
|
1822
|
+
if (pool.isPreloaded() && pool.numActive() === 1) {
|
|
1823
|
+
pool.release(PRELOAD_POOL_ID);
|
|
1824
|
+
globalWorkerPool = null;
|
|
1825
|
+
} else console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()");
|
|
1826
|
+
}
|
|
1817
1827
|
}
|
|
1818
1828
|
//#endregion
|
|
1819
1829
|
//#region src/util/dispatcher.ts
|
|
@@ -2086,8 +2096,10 @@ var LngLatBounds = class LngLatBounds {
|
|
|
2086
2096
|
*/
|
|
2087
2097
|
constructor(sw, ne) {
|
|
2088
2098
|
if (!sw) {} else if (ne) this.setSouthWest(sw).setNorthEast(ne);
|
|
2089
|
-
else if (Array.isArray(sw))
|
|
2090
|
-
|
|
2099
|
+
else if (Array.isArray(sw)) {
|
|
2100
|
+
if (sw.length === 4) this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
|
|
2101
|
+
else this.setSouthWest(sw[0]).setNorthEast(sw[1]);
|
|
2102
|
+
}
|
|
2091
2103
|
}
|
|
2092
2104
|
/**
|
|
2093
2105
|
* Set the northeast corner of the bounding box
|
|
@@ -2123,14 +2135,15 @@ var LngLatBounds = class LngLatBounds {
|
|
|
2123
2135
|
ne2 = obj._ne;
|
|
2124
2136
|
if (!sw2 || !ne2) return this;
|
|
2125
2137
|
} else {
|
|
2126
|
-
if (Array.isArray(obj))
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2138
|
+
if (Array.isArray(obj)) {
|
|
2139
|
+
if (obj.length === 4 || obj.every(Array.isArray)) {
|
|
2140
|
+
const lngLatBoundsObj = obj;
|
|
2141
|
+
return this.extend(LngLatBounds.convert(lngLatBoundsObj));
|
|
2142
|
+
} else {
|
|
2143
|
+
const lngLatObj = obj;
|
|
2144
|
+
return this.extend(LngLat.convert(lngLatObj));
|
|
2145
|
+
}
|
|
2146
|
+
} else if (obj && ("lng" in obj || "lon" in obj) && "lat" in obj) return this.extend(LngLat.convert(obj));
|
|
2134
2147
|
return this;
|
|
2135
2148
|
}
|
|
2136
2149
|
if (!sw && !ne) {
|
|
@@ -3185,9 +3198,7 @@ function getGeoJSONBounds(data) {
|
|
|
3185
3198
|
case "Feature":
|
|
3186
3199
|
coordinates = getCoordinatesFromGeometry(data.geometry);
|
|
3187
3200
|
break;
|
|
3188
|
-
default:
|
|
3189
|
-
coordinates = getCoordinatesFromGeometry(data);
|
|
3190
|
-
break;
|
|
3201
|
+
default: coordinates = getCoordinatesFromGeometry(data);
|
|
3191
3202
|
}
|
|
3192
3203
|
if (coordinates.length === 0) return bounds;
|
|
3193
3204
|
for (const coordinate of coordinates) {
|
|
@@ -3695,6 +3706,76 @@ var GeoJSONSource = class extends Evented {
|
|
|
3695
3706
|
}
|
|
3696
3707
|
};
|
|
3697
3708
|
//#endregion
|
|
3709
|
+
//#region src/webgl/program/raster_program.ts
|
|
3710
|
+
/**
|
|
3711
|
+
* Affine texture coordinates represented as a homogeneous transform.
|
|
3712
|
+
*/
|
|
3713
|
+
const identityPerspectiveTransform = [
|
|
3714
|
+
0,
|
|
3715
|
+
0,
|
|
3716
|
+
1
|
|
3717
|
+
];
|
|
3718
|
+
const rasterUniforms = (context, locations) => ({
|
|
3719
|
+
"u_tl_parent": new Uniform2f(context, locations.u_tl_parent),
|
|
3720
|
+
"u_scale_parent": new Uniform1f(context, locations.u_scale_parent),
|
|
3721
|
+
"u_buffer_scale": new Uniform1f(context, locations.u_buffer_scale),
|
|
3722
|
+
"u_perspective_transform": new Uniform3f(context, locations.u_perspective_transform),
|
|
3723
|
+
"u_fade_t": new Uniform1f(context, locations.u_fade_t),
|
|
3724
|
+
"u_opacity": new Uniform1f(context, locations.u_opacity),
|
|
3725
|
+
"u_image0": new Uniform1i(context, locations.u_image0),
|
|
3726
|
+
"u_image1": new Uniform1i(context, locations.u_image1),
|
|
3727
|
+
"u_brightness_low": new Uniform1f(context, locations.u_brightness_low),
|
|
3728
|
+
"u_brightness_high": new Uniform1f(context, locations.u_brightness_high),
|
|
3729
|
+
"u_saturation_factor": new Uniform1f(context, locations.u_saturation_factor),
|
|
3730
|
+
"u_contrast_factor": new Uniform1f(context, locations.u_contrast_factor),
|
|
3731
|
+
"u_spin_weights": new Uniform3f(context, locations.u_spin_weights),
|
|
3732
|
+
"u_coords_top": new Uniform4f(context, locations.u_coords_top),
|
|
3733
|
+
"u_coords_bottom": new Uniform4f(context, locations.u_coords_bottom)
|
|
3734
|
+
});
|
|
3735
|
+
const rasterUniformValues = (parentTL, parentScaleBy, fade, layer, cornerCoords, perspectiveTransform) => ({
|
|
3736
|
+
"u_tl_parent": parentTL,
|
|
3737
|
+
"u_scale_parent": parentScaleBy,
|
|
3738
|
+
"u_buffer_scale": 1,
|
|
3739
|
+
"u_perspective_transform": perspectiveTransform,
|
|
3740
|
+
"u_fade_t": fade.mix,
|
|
3741
|
+
"u_opacity": fade.opacity * layer.paint.get("raster-opacity"),
|
|
3742
|
+
"u_image0": 0,
|
|
3743
|
+
"u_image1": 1,
|
|
3744
|
+
"u_brightness_low": layer.paint.get("raster-brightness-min"),
|
|
3745
|
+
"u_brightness_high": layer.paint.get("raster-brightness-max"),
|
|
3746
|
+
"u_saturation_factor": saturationFactor(layer.paint.get("raster-saturation")),
|
|
3747
|
+
"u_contrast_factor": contrastFactor(layer.paint.get("raster-contrast")),
|
|
3748
|
+
"u_spin_weights": spinWeights(layer.paint.get("raster-hue-rotate")),
|
|
3749
|
+
"u_coords_top": [
|
|
3750
|
+
cornerCoords[0].x,
|
|
3751
|
+
cornerCoords[0].y,
|
|
3752
|
+
cornerCoords[1].x,
|
|
3753
|
+
cornerCoords[1].y
|
|
3754
|
+
],
|
|
3755
|
+
"u_coords_bottom": [
|
|
3756
|
+
cornerCoords[3].x,
|
|
3757
|
+
cornerCoords[3].y,
|
|
3758
|
+
cornerCoords[2].x,
|
|
3759
|
+
cornerCoords[2].y
|
|
3760
|
+
]
|
|
3761
|
+
});
|
|
3762
|
+
function spinWeights(angle) {
|
|
3763
|
+
angle *= Math.PI / 180;
|
|
3764
|
+
const s = Math.sin(angle);
|
|
3765
|
+
const c = Math.cos(angle);
|
|
3766
|
+
return [
|
|
3767
|
+
(2 * c + 1) / 3,
|
|
3768
|
+
(-Math.sqrt(3) * s - c + 1) / 3,
|
|
3769
|
+
(Math.sqrt(3) * s - c + 1) / 3
|
|
3770
|
+
];
|
|
3771
|
+
}
|
|
3772
|
+
function contrastFactor(contrast) {
|
|
3773
|
+
return contrast > 0 ? 1 / (1 - contrast) : 1 + contrast;
|
|
3774
|
+
}
|
|
3775
|
+
function saturationFactor(saturation) {
|
|
3776
|
+
return saturation > 0 ? 1 - 1 / (1.001 - saturation) : -saturation;
|
|
3777
|
+
}
|
|
3778
|
+
//#endregion
|
|
3698
3779
|
//#region src/source/image_source.ts
|
|
3699
3780
|
/**
|
|
3700
3781
|
* A data source containing an image.
|
|
@@ -3747,7 +3828,9 @@ var ImageSource = class extends Evented {
|
|
|
3747
3828
|
/** @internal */
|
|
3748
3829
|
constructor(id, options, dispatcher, eventedParent) {
|
|
3749
3830
|
super();
|
|
3831
|
+
this.perspectiveTransform = identityPerspectiveTransform;
|
|
3750
3832
|
this.flippedWindingOrder = false;
|
|
3833
|
+
this._imageDirty = false;
|
|
3751
3834
|
this.id = id;
|
|
3752
3835
|
this.dispatcher = dispatcher;
|
|
3753
3836
|
this.coordinates = options.coordinates;
|
|
@@ -3771,7 +3854,7 @@ var ImageSource = class extends Evented {
|
|
|
3771
3854
|
this._request = null;
|
|
3772
3855
|
this._loaded = true;
|
|
3773
3856
|
if (image?.data) {
|
|
3774
|
-
this.image
|
|
3857
|
+
this._setImage(image.data);
|
|
3775
3858
|
if (newCoordinates) this.coordinates = newCoordinates;
|
|
3776
3859
|
this._finishLoading();
|
|
3777
3860
|
}
|
|
@@ -3801,17 +3884,26 @@ var ImageSource = class extends Evented {
|
|
|
3801
3884
|
}
|
|
3802
3885
|
if ("image" in options) {
|
|
3803
3886
|
this._loaded = true;
|
|
3804
|
-
this.
|
|
3887
|
+
this._setImage(options.image);
|
|
3805
3888
|
if (options.coordinates) this.coordinates = options.coordinates;
|
|
3806
|
-
this.texture = null;
|
|
3807
3889
|
this._finishLoading();
|
|
3808
3890
|
return this;
|
|
3809
3891
|
}
|
|
3810
3892
|
if (!options.url) return this;
|
|
3811
3893
|
this.options.url = options.url;
|
|
3812
|
-
this.load(options.coordinates)
|
|
3894
|
+
this.load(options.coordinates);
|
|
3813
3895
|
return this;
|
|
3814
3896
|
}
|
|
3897
|
+
/** Loaded tiles hold `this.texture`, so the wrapper has to outlive the images in it. */
|
|
3898
|
+
_setImage(image) {
|
|
3899
|
+
this.image = image;
|
|
3900
|
+
this._imageDirty = true;
|
|
3901
|
+
}
|
|
3902
|
+
/** Teardown only: dropping the reference alone leaves the allocation to the GC. */
|
|
3903
|
+
_disposeTexture() {
|
|
3904
|
+
this.texture?.destroy();
|
|
3905
|
+
this.texture = null;
|
|
3906
|
+
}
|
|
3815
3907
|
_finishLoading() {
|
|
3816
3908
|
if (this.map) {
|
|
3817
3909
|
this.setCoordinates(this.coordinates);
|
|
@@ -3827,6 +3919,9 @@ var ImageSource = class extends Evented {
|
|
|
3827
3919
|
this._request.abort();
|
|
3828
3920
|
this._request = null;
|
|
3829
3921
|
}
|
|
3922
|
+
this._disposeTexture();
|
|
3923
|
+
this.image = null;
|
|
3924
|
+
this.tiles = {};
|
|
3830
3925
|
}
|
|
3831
3926
|
/**
|
|
3832
3927
|
* Sets the image's coordinates and re-renders the map.
|
|
@@ -3843,6 +3938,7 @@ var ImageSource = class extends Evented {
|
|
|
3843
3938
|
this.terrainTileRanges = this._getOverlappingTileRanges(cornerCoords);
|
|
3844
3939
|
this.minzoom = this.maxzoom = this.tileID.z;
|
|
3845
3940
|
this.tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round());
|
|
3941
|
+
this.perspectiveTransform = calculateRasterPerspectiveTransform(this.tileCoords);
|
|
3846
3942
|
this.flippedWindingOrder = hasWrongWindingOrder(this.tileCoords);
|
|
3847
3943
|
this.fire(new MapSourceDataEvent("data", { sourceDataType: "content" }));
|
|
3848
3944
|
return this;
|
|
@@ -3854,7 +3950,11 @@ var ImageSource = class extends Evented {
|
|
|
3854
3950
|
if (!this.texture) {
|
|
3855
3951
|
this.texture = new Texture(context, this.image, gl.RGBA);
|
|
3856
3952
|
this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
3953
|
+
} else if (this._imageDirty) {
|
|
3954
|
+
this.texture.update(this.image);
|
|
3955
|
+
this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
3857
3956
|
}
|
|
3957
|
+
this._imageDirty = false;
|
|
3858
3958
|
let newTilesLoaded = false;
|
|
3859
3959
|
for (const w in this.tiles) {
|
|
3860
3960
|
const tile = this.tiles[w];
|
|
@@ -3902,9 +4002,11 @@ var ImageSource = class extends Evented {
|
|
|
3902
4002
|
const maxTileY = Math.floor(maxY * tilesAtZoom);
|
|
3903
4003
|
const minTileXWrapped = (minTileX % tilesAtZoom + tilesAtZoom) % tilesAtZoom;
|
|
3904
4004
|
const maxTileXWrapped = maxTileX % tilesAtZoom;
|
|
4005
|
+
const minWrap = Math.floor(minTileX / tilesAtZoom);
|
|
4006
|
+
const maxWrap = Math.floor(maxTileX / tilesAtZoom);
|
|
3905
4007
|
ranges[z] = {
|
|
3906
|
-
minWrap
|
|
3907
|
-
maxWrap
|
|
4008
|
+
minWrap,
|
|
4009
|
+
maxWrap,
|
|
3908
4010
|
minTileXWrapped,
|
|
3909
4011
|
maxTileXWrapped,
|
|
3910
4012
|
minTileY,
|
|
@@ -3934,6 +4036,83 @@ function hasWrongWindingOrder(coords) {
|
|
|
3934
4036
|
const e1x = coords[2].x - coords[0].x;
|
|
3935
4037
|
return e0x * (coords[2].y - coords[0].y) - e0y * e1x < 0;
|
|
3936
4038
|
}
|
|
4039
|
+
const perspectiveEpsilon = Number.EPSILON;
|
|
4040
|
+
const perspectiveErrorFactor = 8;
|
|
4041
|
+
/**
|
|
4042
|
+
* Calculates the inverse-homography denominator used to sample non-affine
|
|
4043
|
+
* image-source texture coordinates. Image source tile coordinates are rounded
|
|
4044
|
+
* to integers before this runs, so singularity checks use exact zero or
|
|
4045
|
+
* Number.EPSILON scaled to the corner denominators.
|
|
4046
|
+
*
|
|
4047
|
+
* Based on Paul S. Heckbert, "Fundamentals of Texture Mapping and Image
|
|
4048
|
+
* Warping", UCB/CSD-89-516, 1989, section 2.2.3 and appendix A.2.
|
|
4049
|
+
*
|
|
4050
|
+
* @see https://www2.eecs.berkeley.edu/Pubs/TechRpts/1989/5504.html
|
|
4051
|
+
* @see https://www.cs.cmu.edu/~ph/texfund/texfund.pdf
|
|
4052
|
+
*/
|
|
4053
|
+
function calculateRasterPerspectiveTransform(cornerCoords) {
|
|
4054
|
+
if (isParallelogram(cornerCoords)) return identityPerspectiveTransform;
|
|
4055
|
+
const [topLeft, topRight, bottomRight, bottomLeft] = cornerCoords;
|
|
4056
|
+
const sx = topLeft.x - topRight.x + bottomRight.x - bottomLeft.x;
|
|
4057
|
+
const sy = topLeft.y - topRight.y + bottomRight.y - bottomLeft.y;
|
|
4058
|
+
const dx1 = topRight.x - bottomRight.x;
|
|
4059
|
+
const dy1 = topRight.y - bottomRight.y;
|
|
4060
|
+
const dx2 = bottomLeft.x - bottomRight.x;
|
|
4061
|
+
const dy2 = bottomLeft.y - bottomRight.y;
|
|
4062
|
+
const determinant$1 = determinant([
|
|
4063
|
+
dx1,
|
|
4064
|
+
dy1,
|
|
4065
|
+
dx2,
|
|
4066
|
+
dy2
|
|
4067
|
+
]);
|
|
4068
|
+
if (Math.abs(determinant$1) < perspectiveEpsilon) return identityPerspectiveTransform;
|
|
4069
|
+
const perspectiveX = (sx * dy2 - dx2 * sy) / determinant$1;
|
|
4070
|
+
const perspectiveY = (dx1 * sy - sx * dy1) / determinant$1;
|
|
4071
|
+
const forwardDenominators = [
|
|
4072
|
+
1,
|
|
4073
|
+
1 + perspectiveX,
|
|
4074
|
+
1 + perspectiveX + perspectiveY,
|
|
4075
|
+
1 + perspectiveY
|
|
4076
|
+
];
|
|
4077
|
+
const forwardDenominatorScale = Math.max(...forwardDenominators.map((value) => Math.abs(value)));
|
|
4078
|
+
const hasInvalidForwardDenominator = forwardDenominators.some((value) => !Number.isFinite(value) || value <= perspectiveErrorFactor * perspectiveEpsilon * forwardDenominatorScale);
|
|
4079
|
+
if (!Number.isFinite(forwardDenominatorScale) || forwardDenominatorScale === 0 || hasInvalidForwardDenominator) return identityPerspectiveTransform;
|
|
4080
|
+
const a = topRight.x - topLeft.x + perspectiveX * topRight.x;
|
|
4081
|
+
const b = bottomLeft.x - topLeft.x + perspectiveY * bottomLeft.x;
|
|
4082
|
+
const d = topRight.y - topLeft.y + perspectiveX * topRight.y;
|
|
4083
|
+
const e = bottomLeft.y - topLeft.y + perspectiveY * bottomLeft.y;
|
|
4084
|
+
const inverseDenominator = [
|
|
4085
|
+
0,
|
|
4086
|
+
0,
|
|
4087
|
+
0
|
|
4088
|
+
];
|
|
4089
|
+
cross(inverseDenominator, [
|
|
4090
|
+
a,
|
|
4091
|
+
d,
|
|
4092
|
+
perspectiveX
|
|
4093
|
+
], [
|
|
4094
|
+
b,
|
|
4095
|
+
e,
|
|
4096
|
+
perspectiveY
|
|
4097
|
+
]);
|
|
4098
|
+
const normalizationScale = Math.max(...inverseDenominator.map((value) => Math.abs(value)));
|
|
4099
|
+
const cornerDenominators = cornerCoords.map(({ x, y }) => dot(inverseDenominator, [
|
|
4100
|
+
x,
|
|
4101
|
+
y,
|
|
4102
|
+
1
|
|
4103
|
+
]));
|
|
4104
|
+
const cornerDenominatorErrors = cornerCoords.map(({ x, y }) => perspectiveErrorFactor * perspectiveEpsilon * (Math.abs(inverseDenominator[0] * x) + Math.abs(inverseDenominator[1] * y) + Math.abs(inverseDenominator[2])));
|
|
4105
|
+
const denominatorScale = Math.max(...cornerDenominators.map((value) => Math.abs(value)));
|
|
4106
|
+
const denominatorSign = Math.sign(cornerDenominators[0]);
|
|
4107
|
+
const hasInvalidDenominator = cornerDenominators.some((value, index) => !Number.isFinite(value) || Math.abs(value) <= Math.max(perspectiveEpsilon * denominatorScale, cornerDenominatorErrors[index]) || Math.sign(value) !== denominatorSign);
|
|
4108
|
+
if (!Number.isFinite(normalizationScale) || normalizationScale === 0 || !Number.isFinite(denominatorScale) || denominatorScale === 0 || hasInvalidDenominator) return identityPerspectiveTransform;
|
|
4109
|
+
const transform = inverseDenominator.map((value) => value / normalizationScale);
|
|
4110
|
+
return transform.every(Number.isFinite) ? transform : identityPerspectiveTransform;
|
|
4111
|
+
}
|
|
4112
|
+
function isParallelogram(cornerCoords) {
|
|
4113
|
+
const [tl, tr, br, bl] = cornerCoords;
|
|
4114
|
+
return Math.abs(tl.x + br.x - tr.x - bl.x) < perspectiveEpsilon && Math.abs(tl.y + br.y - tr.y - bl.y) < perspectiveEpsilon;
|
|
4115
|
+
}
|
|
3937
4116
|
//#endregion
|
|
3938
4117
|
//#region src/source/video_source.ts
|
|
3939
4118
|
/**
|
|
@@ -4172,7 +4351,8 @@ var CanvasSource = class extends ImageSource {
|
|
|
4172
4351
|
}
|
|
4173
4352
|
}
|
|
4174
4353
|
onRemove() {
|
|
4175
|
-
this.
|
|
4354
|
+
this._playing = false;
|
|
4355
|
+
super.onRemove();
|
|
4176
4356
|
}
|
|
4177
4357
|
prepare() {
|
|
4178
4358
|
let resize = false;
|
|
@@ -4315,11 +4495,12 @@ var RTLMainThreadPlugin = class extends Evented {
|
|
|
4315
4495
|
if (this.url) throw new Error("setRTLTextPlugin cannot be called multiple times.");
|
|
4316
4496
|
this.url = browser.resolveURL(url);
|
|
4317
4497
|
if (!this.url) throw new Error(`requested url ${url} is invalid`);
|
|
4318
|
-
if (this.status === "unavailable")
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4498
|
+
if (this.status === "unavailable") {
|
|
4499
|
+
if (deferred) {
|
|
4500
|
+
this.status = "deferred";
|
|
4501
|
+
this._syncState(this.status);
|
|
4502
|
+
} else return this._requestImport();
|
|
4503
|
+
} else if (this.status === "requested") return this._requestImport();
|
|
4323
4504
|
}
|
|
4324
4505
|
/** Send a message to worker which will import the RTL plugin script */
|
|
4325
4506
|
async _requestImport() {
|
|
@@ -4564,7 +4745,8 @@ var Tile = class {
|
|
|
4564
4745
|
const evaluationFeature = toEvaluationFeature(feature, true);
|
|
4565
4746
|
if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue;
|
|
4566
4747
|
} else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) continue;
|
|
4567
|
-
const
|
|
4748
|
+
const id = featureIndex.getId(feature, sourceLayer);
|
|
4749
|
+
const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id);
|
|
4568
4750
|
geojsonFeature.tile = coord;
|
|
4569
4751
|
result.push(geojsonFeature);
|
|
4570
4752
|
}
|
|
@@ -4599,8 +4781,10 @@ var Tile = class {
|
|
|
4599
4781
|
}
|
|
4600
4782
|
}
|
|
4601
4783
|
getExpiryTimeout() {
|
|
4602
|
-
if (this.expirationTime)
|
|
4603
|
-
|
|
4784
|
+
if (this.expirationTime) {
|
|
4785
|
+
if (this.expiredRequestCount) return 1e3 * (1 << Math.min(this.expiredRequestCount - 1, 31));
|
|
4786
|
+
else return Math.min(this.expirationTime - (/* @__PURE__ */ new Date()).getTime(), Math.pow(2, 31) - 1);
|
|
4787
|
+
}
|
|
4604
4788
|
}
|
|
4605
4789
|
setFeatureState(states, painter, revision) {
|
|
4606
4790
|
if (!this.latestFeatureIndex?.rawTileData || Object.keys(states).length === 0) return;
|
|
@@ -4697,11 +4881,12 @@ var SourceFeatureState = class {
|
|
|
4697
4881
|
this.deletedStates[sourceLayer][feature] ||= {};
|
|
4698
4882
|
this.deletedStates[sourceLayer][feature][key] = null;
|
|
4699
4883
|
}
|
|
4700
|
-
} else if (featureId !== void 0)
|
|
4701
|
-
this.
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4884
|
+
} else if (featureId !== void 0) {
|
|
4885
|
+
if (this.stateChanges[sourceLayer]?.[feature]) {
|
|
4886
|
+
this.deletedStates[sourceLayer][feature] = {};
|
|
4887
|
+
for (key in this.stateChanges[sourceLayer][feature]) this.deletedStates[sourceLayer][feature][key] = null;
|
|
4888
|
+
} else this.deletedStates[sourceLayer][feature] = null;
|
|
4889
|
+
} else this.deletedStates[sourceLayer] = null;
|
|
4705
4890
|
}
|
|
4706
4891
|
getState(sourceLayer, featureId) {
|
|
4707
4892
|
const feature = String(featureId);
|
|
@@ -4755,86 +4940,6 @@ var SourceFeatureState = class {
|
|
|
4755
4940
|
}
|
|
4756
4941
|
};
|
|
4757
4942
|
//#endregion
|
|
4758
|
-
//#region src/geo/projection/mercator_utils.ts
|
|
4759
|
-
const maxMercatorHorizonAngle = 89.25;
|
|
4760
|
-
/**
|
|
4761
|
-
* Returns mercator coordinates in range 0..1 for given coordinates inside a specified tile.
|
|
4762
|
-
* @param inTileX - X coordinate in tile units - range [0..EXTENT].
|
|
4763
|
-
* @param inTileY - Y coordinate in tile units - range [0..EXTENT].
|
|
4764
|
-
* @param canonicalTileID - Tile canonical ID - mercator X, Y and zoom.
|
|
4765
|
-
* @returns Mercator coordinates of the specified point in range [0..1].
|
|
4766
|
-
*/
|
|
4767
|
-
function tileCoordinatesToMercatorCoordinates(inTileX, inTileY, canonicalTileID) {
|
|
4768
|
-
const scale = 1 / (1 << canonicalTileID.z);
|
|
4769
|
-
return new MercatorCoordinate(inTileX / EXTENT * scale + canonicalTileID.x * scale, inTileY / EXTENT * scale + canonicalTileID.y * scale);
|
|
4770
|
-
}
|
|
4771
|
-
/**
|
|
4772
|
-
* Convert from LngLat to world coordinates (Mercator coordinates scaled by world size).
|
|
4773
|
-
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
4774
|
-
* @param lnglat - The location to convert.
|
|
4775
|
-
* @returns Point
|
|
4776
|
-
*/
|
|
4777
|
-
function projectToWorldCoordinates(worldSize, lnglat) {
|
|
4778
|
-
const lat = clamp(lnglat.lat, -MAX_VALID_LATITUDE, MAX_VALID_LATITUDE);
|
|
4779
|
-
return new Point(mercatorXfromLng(lnglat.lng) * worldSize, mercatorYfromLat(lat) * worldSize);
|
|
4780
|
-
}
|
|
4781
|
-
/**
|
|
4782
|
-
* Convert from world coordinates (mercator coordinates scaled by world size) to LngLat.
|
|
4783
|
-
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
4784
|
-
* @param point - World coordinate.
|
|
4785
|
-
* @returns LngLat
|
|
4786
|
-
*/
|
|
4787
|
-
function unprojectFromWorldCoordinates(worldSize, point) {
|
|
4788
|
-
return new MercatorCoordinate(point.x / worldSize, point.y / worldSize).toLngLat();
|
|
4789
|
-
}
|
|
4790
|
-
/**
|
|
4791
|
-
* Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),
|
|
4792
|
-
* multiplied by a static factor to simulate the earth-radius.
|
|
4793
|
-
* The calculated value is the horizontal line from the camera-height to sea-level.
|
|
4794
|
-
* @returns Horizon above center in pixels.
|
|
4795
|
-
*/
|
|
4796
|
-
function getMercatorHorizon(transform) {
|
|
4797
|
-
return transform.cameraToCenterDistance * Math.min(Math.tan(degreesToRadians(90 - transform.pitch)) * .85, Math.tan(degreesToRadians(maxMercatorHorizonAngle - transform.pitch)));
|
|
4798
|
-
}
|
|
4799
|
-
function calculateTileMatrix(unwrappedTileID, worldSize) {
|
|
4800
|
-
const canonical = unwrappedTileID.canonical;
|
|
4801
|
-
const scale$5 = worldSize / zoomScale(canonical.z);
|
|
4802
|
-
const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;
|
|
4803
|
-
const worldMatrix = /* @__PURE__ */ new Float64Array(16);
|
|
4804
|
-
identity(worldMatrix);
|
|
4805
|
-
translate(worldMatrix, worldMatrix, [
|
|
4806
|
-
unwrappedX * scale$5,
|
|
4807
|
-
canonical.y * scale$5,
|
|
4808
|
-
0
|
|
4809
|
-
]);
|
|
4810
|
-
scale(worldMatrix, worldMatrix, [
|
|
4811
|
-
scale$5 / EXTENT,
|
|
4812
|
-
scale$5 / EXTENT,
|
|
4813
|
-
1
|
|
4814
|
-
]);
|
|
4815
|
-
return worldMatrix;
|
|
4816
|
-
}
|
|
4817
|
-
function cameraMercatorCoordinateFromCenterAndRotation(center, elevation, pitch, bearing, distance) {
|
|
4818
|
-
const centerMercator = MercatorCoordinate.fromLngLat(center, elevation);
|
|
4819
|
-
const dMercator = distance * mercatorZfromAltitude(1, center.lat);
|
|
4820
|
-
const { x, y, z } = cameraDirectionFromPitchBearing(pitch, bearing);
|
|
4821
|
-
const dxMercator = dMercator * -x;
|
|
4822
|
-
const dyMercator = dMercator * -y;
|
|
4823
|
-
const dzMercator = dMercator * -z;
|
|
4824
|
-
return new MercatorCoordinate(centerMercator.x + dxMercator, centerMercator.y + dyMercator, centerMercator.z + dzMercator);
|
|
4825
|
-
}
|
|
4826
|
-
function cameraDirectionFromPitchBearing(pitch, bearing) {
|
|
4827
|
-
const pitchRadians = degreesToRadians(pitch);
|
|
4828
|
-
const bearingRadians = degreesToRadians(bearing);
|
|
4829
|
-
const z = Math.cos(-pitchRadians);
|
|
4830
|
-
const h = Math.sin(pitchRadians);
|
|
4831
|
-
return {
|
|
4832
|
-
x: h * Math.sin(bearingRadians),
|
|
4833
|
-
y: -h * Math.cos(bearingRadians),
|
|
4834
|
-
z
|
|
4835
|
-
};
|
|
4836
|
-
}
|
|
4837
|
-
//#endregion
|
|
4838
4943
|
//#region src/geo/projection/covering_tiles.ts
|
|
4839
4944
|
/**
|
|
4840
4945
|
* A simple/heuristic function that returns whether the tile is visible under the current transform.
|
|
@@ -6912,12 +7017,13 @@ var CollisionIndex = class {
|
|
|
6912
7017
|
const featureKey = feature.key;
|
|
6913
7018
|
if (seenFeatures[featureKey.bucketInstanceId] === void 0) seenFeatures[featureKey.bucketInstanceId] = {};
|
|
6914
7019
|
if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) continue;
|
|
6915
|
-
|
|
7020
|
+
const bbox = [
|
|
6916
7021
|
new Point(feature.x1, feature.y1),
|
|
6917
7022
|
new Point(feature.x2, feature.y1),
|
|
6918
7023
|
new Point(feature.x2, feature.y2),
|
|
6919
7024
|
new Point(feature.x1, feature.y2)
|
|
6920
|
-
]
|
|
7025
|
+
];
|
|
7026
|
+
if (!polygonIntersectsPolygon(query, bbox)) continue;
|
|
6921
7027
|
seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true;
|
|
6922
7028
|
if (result[featureKey.bucketInstanceId] === void 0) result[featureKey.bucketInstanceId] = [];
|
|
6923
7029
|
result[featureKey.bucketInstanceId].push(featureKey.featureIndex);
|
|
@@ -7040,7 +7146,8 @@ var CollisionIndex = class {
|
|
|
7040
7146
|
distanceMultiplier = Math.pow(2, -zoomFraction);
|
|
7041
7147
|
distanceMultiplier *= this.transform.getPitchedTextCorrection(translatedAnchorX, translatedAnchorY, unwrappedTileID);
|
|
7042
7148
|
if (!shift) {
|
|
7043
|
-
const
|
|
7149
|
+
const distanceRatio = projectedPoint.signedDistanceFromCamera / this.transform.cameraToCenterDistance;
|
|
7150
|
+
const perspectiveRatio = clamp(.5 + .5 * distanceRatio, 0, 4);
|
|
7044
7151
|
distanceMultiplier *= perspectiveRatio;
|
|
7045
7152
|
}
|
|
7046
7153
|
}
|
|
@@ -7463,8 +7570,10 @@ var Placement = class {
|
|
|
7463
7570
|
else if (!iconWithoutText) placeIcon &&= placeText;
|
|
7464
7571
|
const hasTextBox = placeText && placedGlyphBoxes.placeable;
|
|
7465
7572
|
const hasIconBox = placeIcon && placedIconBoxes.placeable;
|
|
7466
|
-
if (hasTextBox)
|
|
7467
|
-
|
|
7573
|
+
if (hasTextBox) {
|
|
7574
|
+
if (placedVerticalText && placedVerticalText.placeable && verticalTextFeatureIndex) this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, textOverlapMode, layout.get("text-ignore-placement"), bucket.bucketInstanceId, verticalTextFeatureIndex, collisionGroup.ID);
|
|
7575
|
+
else this.collisionIndex.insertCollisionBox(placedGlyphBoxes.box, textOverlapMode, layout.get("text-ignore-placement"), bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID);
|
|
7576
|
+
}
|
|
7468
7577
|
if (hasIconBox) this.collisionIndex.insertCollisionBox(placedIconBoxes.box, iconOverlapMode, layout.get("icon-ignore-placement"), bucket.bucketInstanceId, iconFeatureIndex, collisionGroup.ID);
|
|
7469
7578
|
if (placedGlyphCircles) {
|
|
7470
7579
|
if (placeText) this.collisionIndex.insertCollisionCircles(placedGlyphCircles.circles, textOverlapMode, layout.get("text-ignore-placement"), bucket.bucketInstanceId, textFeatureIndex, collisionGroup.ID);
|
|
@@ -7533,8 +7642,10 @@ var Placement = class {
|
|
|
7533
7642
|
symbolInstance.rightJustifiedTextSymbolIndex,
|
|
7534
7643
|
symbolInstance.verticalPlacedTextSymbolIndex
|
|
7535
7644
|
];
|
|
7536
|
-
for (const index of indexes) if (index >= 0)
|
|
7537
|
-
|
|
7645
|
+
for (const index of indexes) if (index >= 0) {
|
|
7646
|
+
if (autoIndex >= 0 && index !== autoIndex) bucket.text.placedSymbolArray.get(index).crossTileID = 0;
|
|
7647
|
+
else bucket.text.placedSymbolArray.get(index).crossTileID = symbolInstance.crossTileID;
|
|
7648
|
+
}
|
|
7538
7649
|
}
|
|
7539
7650
|
markUsedOrientation(bucket, orientation, symbolInstance) {
|
|
7540
7651
|
const horizontal = orientation === 1 || orientation === 3 ? orientation : 0;
|
|
@@ -7898,7 +8009,7 @@ var KDBush = class KDBush {
|
|
|
7898
8009
|
this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
7899
8010
|
this._pos = 0;
|
|
7900
8011
|
this._finished = false;
|
|
7901
|
-
new Uint8Array(data, 0, 2).set([219,
|
|
8012
|
+
new Uint8Array(data, 0, 2).set([219, 16 + arrayTypeIndex]);
|
|
7902
8013
|
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
7903
8014
|
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
7904
8015
|
}
|
|
@@ -8227,8 +8338,10 @@ var CrossTileSymbolLayerIndex = class {
|
|
|
8227
8338
|
this.lng = lng;
|
|
8228
8339
|
}
|
|
8229
8340
|
addBucket(tileID, bucket, crossTileIDs) {
|
|
8230
|
-
if (this.indexes[tileID.overscaledZ]?.[tileID.key])
|
|
8231
|
-
|
|
8341
|
+
if (this.indexes[tileID.overscaledZ]?.[tileID.key]) {
|
|
8342
|
+
if (this.indexes[tileID.overscaledZ][tileID.key].bucketInstanceId === bucket.bucketInstanceId) return false;
|
|
8343
|
+
else this.removeBucketCrossTileIDs(tileID.overscaledZ, this.indexes[tileID.overscaledZ][tileID.key]);
|
|
8344
|
+
}
|
|
8232
8345
|
for (let i = 0; i < bucket.symbolInstances.length; i++) {
|
|
8233
8346
|
const symbolInstance = bucket.symbolInstances.get(i);
|
|
8234
8347
|
symbolInstance.crossTileID = 0;
|
|
@@ -8310,7 +8423,7 @@ var CrossTileSymbolIndex = class {
|
|
|
8310
8423
|
var _prelude_fragment_glsl_g_default = "#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;";
|
|
8311
8424
|
//#endregion
|
|
8312
8425
|
//#region src/shaders/glsl/_prelude.vertex.glsl.g.ts
|
|
8313
|
-
var _prelude_vertex_glsl_g_default = "#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const
|
|
8426
|
+
var _prelude_vertex_glsl_g_default = "#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;";
|
|
8314
8427
|
//#endregion
|
|
8315
8428
|
//#region src/shaders/glsl/background.fragment.glsl.g.ts
|
|
8316
8429
|
var background_fragment_glsl_g_default = "uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}";
|
|
@@ -8328,7 +8441,7 @@ var background_pattern_vertex_glsl_g_default = "uniform vec2 u_pattern_size_a;un
|
|
|
8328
8441
|
var circle_fragment_glsl_g_default = "in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}";
|
|
8329
8442
|
//#endregion
|
|
8330
8443
|
//#region src/shaders/glsl/circle.vertex.glsl.g.ts
|
|
8331
|
-
var circle_vertex_glsl_g_default = "uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;layout(location=0) in
|
|
8444
|
+
var circle_vertex_glsl_g_default = "uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}";
|
|
8332
8445
|
//#endregion
|
|
8333
8446
|
//#region src/shaders/glsl/clipping_mask.fragment.glsl.g.ts
|
|
8334
8447
|
var clipping_mask_fragment_glsl_g_default = "void main() {fragColor=vec4(1.0);}";
|
|
@@ -8342,7 +8455,7 @@ const shaders = {
|
|
|
8342
8455
|
backgroundPattern: prepare(background_pattern_fragment_glsl_g_default, background_pattern_vertex_glsl_g_default),
|
|
8343
8456
|
circle: prepare(circle_fragment_glsl_g_default, circle_vertex_glsl_g_default),
|
|
8344
8457
|
clippingMask: prepare(clipping_mask_fragment_glsl_g_default, "layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),
|
|
8345
|
-
heatmap: prepare("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in
|
|
8458
|
+
heatmap: prepare("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=vec2(pos_raw >> 3);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),
|
|
8346
8459
|
heatmapTexture: prepare("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_world;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),
|
|
8347
8460
|
collisionBox: prepare("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}", "layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),
|
|
8348
8461
|
collisionCircle: prepare("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}", "layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;uniform vec2 u_viewport_size;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),
|
|
@@ -8353,20 +8466,20 @@ const shaders = {
|
|
|
8353
8466
|
fillOutline: prepare("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_world;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),
|
|
8354
8467
|
fillOutlinePattern: prepare("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),
|
|
8355
8468
|
fillPattern: prepare("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),
|
|
8356
|
-
fillExtrusion: prepare("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in
|
|
8357
|
-
fillExtrusionPattern: prepare("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in
|
|
8469
|
+
fillExtrusion: prepare("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=vec3(a_normal_ed.xyz);\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),
|
|
8470
|
+
fillExtrusionPattern: prepare("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),
|
|
8358
8471
|
hillshadePrepare: prepare("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),
|
|
8359
8472
|
hillshade: prepare("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),
|
|
8360
|
-
line: prepare("uniform lowp float u_device_pixel_ratio;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\nlayout(location=0) in
|
|
8361
|
-
lineGradient: prepare("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\nlayout(location=0) in
|
|
8362
|
-
linePattern: prepare("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in
|
|
8363
|
-
lineSDF: prepare("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in
|
|
8364
|
-
lineGradientSDF: prepare("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in
|
|
8473
|
+
line: prepare("uniform lowp float u_device_pixel_ratio;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),
|
|
8474
|
+
lineGradient: prepare("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),
|
|
8475
|
+
linePattern: prepare("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),
|
|
8476
|
+
lineSDF: prepare("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),
|
|
8477
|
+
lineGradientSDF: prepare("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),
|
|
8365
8478
|
layerOpacity: prepare("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}", "layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),
|
|
8366
|
-
raster: prepare("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in
|
|
8367
|
-
symbolIcon: prepare("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in
|
|
8368
|
-
symbolSDF: prepare("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in
|
|
8369
|
-
symbolTextAndIcon: prepare("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in
|
|
8479
|
+
raster: prepare("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_perspective_transform;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}\n#endif\nfloat perspectiveRatio=dot(u_perspective_transform,vec3(position,1.0));v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),
|
|
8480
|
+
symbolIcon: prepare("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),
|
|
8481
|
+
symbolSDF: prepare("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),
|
|
8482
|
+
symbolTextAndIcon: prepare("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}", "layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}"),
|
|
8370
8483
|
terrain: prepare("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}", "layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),
|
|
8371
8484
|
terrainDepth: prepare("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}", "layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),
|
|
8372
8485
|
terrainCoords: prepare("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}", "layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),
|
|
@@ -8400,7 +8513,8 @@ uniform ${precision} ${type} u_${name};
|
|
|
8400
8513
|
vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {
|
|
8401
8514
|
const attrType = type === "float" ? "vec2" : "vec4";
|
|
8402
8515
|
const unpackType = name.match(/color/) ? "color" : attrType;
|
|
8403
|
-
if (fragmentPragmas[name])
|
|
8516
|
+
if (fragmentPragmas[name]) {
|
|
8517
|
+
if (operation === "define") return `
|
|
8404
8518
|
#ifndef HAS_UNIFORM_u_${name}
|
|
8405
8519
|
uniform lowp float u_${name}_t;
|
|
8406
8520
|
layout(location = ${locationCounter++}) in ${precision} ${attrType} a_${name};
|
|
@@ -8409,21 +8523,21 @@ out ${precision} ${type} ${name};
|
|
|
8409
8523
|
uniform ${precision} ${type} u_${name};
|
|
8410
8524
|
#endif
|
|
8411
8525
|
`;
|
|
8412
|
-
|
|
8526
|
+
else if (unpackType === "vec4") return `
|
|
8413
8527
|
#ifndef HAS_UNIFORM_u_${name}
|
|
8414
8528
|
${name} = a_${name};
|
|
8415
8529
|
#else
|
|
8416
8530
|
${precision} ${type} ${name} = u_${name};
|
|
8417
8531
|
#endif
|
|
8418
8532
|
`;
|
|
8419
|
-
|
|
8533
|
+
else return `
|
|
8420
8534
|
#ifndef HAS_UNIFORM_u_${name}
|
|
8421
8535
|
${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t);
|
|
8422
8536
|
#else
|
|
8423
8537
|
${precision} ${type} ${name} = u_${name};
|
|
8424
8538
|
#endif
|
|
8425
8539
|
`;
|
|
8426
|
-
else if (operation === "define") return `
|
|
8540
|
+
} else if (operation === "define") return `
|
|
8427
8541
|
#ifndef HAS_UNIFORM_u_${name}
|
|
8428
8542
|
uniform lowp float u_${name}_t;
|
|
8429
8543
|
layout(location = ${locationCounter++}) in ${precision} ${attrType} a_${name};
|
|
@@ -8575,7 +8689,9 @@ var EdgeInsets = class EdgeInsets {
|
|
|
8575
8689
|
* @returns the point
|
|
8576
8690
|
*/
|
|
8577
8691
|
getCenter(width, height) {
|
|
8578
|
-
|
|
8692
|
+
const x = clamp((this.left + width - this.right) / 2, 0, width);
|
|
8693
|
+
const y = clamp((this.top + height - this.bottom) / 2, 0, height);
|
|
8694
|
+
return new Point(x, y);
|
|
8579
8695
|
}
|
|
8580
8696
|
equals(other) {
|
|
8581
8697
|
return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
|
|
@@ -9247,7 +9363,8 @@ var MercatorCoveringTilesDetailsProvider = class {
|
|
|
9247
9363
|
]);
|
|
9248
9364
|
}
|
|
9249
9365
|
allowVariableZoom(transform, options) {
|
|
9250
|
-
const
|
|
9366
|
+
const zfov = transform.fov * (Math.abs(Math.cos(transform.rollInRadians)) * transform.height + Math.abs(Math.sin(transform.rollInRadians)) * transform.width) / transform.height;
|
|
9367
|
+
const maxConstantZoomPitch = clamp(78.5 - zfov / 2, 0, 60);
|
|
9251
9368
|
return !!options.terrain || transform.pitch > maxConstantZoomPitch;
|
|
9252
9369
|
}
|
|
9253
9370
|
allowWorldCopies() {
|
|
@@ -9381,7 +9498,9 @@ var Frustum = class Frustum {
|
|
|
9381
9498
|
const frustumCoords = clipSpaceCorners.map((v) => unprojectClipSpacePoint(v, invProj, worldSize, scale));
|
|
9382
9499
|
if (horizonPlane) adjustFarPlaneByHorizonPlane(frustumCoords, frustumPlanePointIndices[0], horizonPlane, flippedNearFar);
|
|
9383
9500
|
const frustumPlanes = frustumPlanePointIndices.map((p) => {
|
|
9384
|
-
const
|
|
9501
|
+
const a = sub([], frustumCoords[p[0]], frustumCoords[p[1]]);
|
|
9502
|
+
const b = sub([], frustumCoords[p[2]], frustumCoords[p[1]]);
|
|
9503
|
+
const n = normalize([], cross([], a, b));
|
|
9385
9504
|
const d = -dot(n, frustumCoords[p[1]]);
|
|
9386
9505
|
return n.concat(d);
|
|
9387
9506
|
});
|
|
@@ -9475,12 +9594,15 @@ function getNormalizedNearPlane(frustumCoords, nearPlanePointsIndices) {
|
|
|
9475
9594
|
* Returns the ideal distance between the frustum's near and far plane so that the far plane only lies as far as the horizon.
|
|
9476
9595
|
*/
|
|
9477
9596
|
function getIdealNearFarPlaneDistance(horizonPlane, nearPlaneNormalized) {
|
|
9478
|
-
const
|
|
9597
|
+
const horizonPlaneLen = len(horizonPlane);
|
|
9598
|
+
const normalizedHorizonPlane = scale$3([], horizonPlane, 1 / horizonPlaneLen);
|
|
9479
9599
|
const projectedViewDirection = sub([], nearPlaneNormalized, scale$2([], normalizedHorizonPlane, dot(nearPlaneNormalized, normalizedHorizonPlane)));
|
|
9480
9600
|
const projectedViewLength = len(projectedViewDirection);
|
|
9481
9601
|
if (projectedViewLength > 0) {
|
|
9482
9602
|
const horizonCircleRadius = Math.sqrt(1 - normalizedHorizonPlane[3] * normalizedHorizonPlane[3]);
|
|
9483
|
-
|
|
9603
|
+
const horizonCircleCenter = scale$2([], normalizedHorizonPlane, -normalizedHorizonPlane[3]);
|
|
9604
|
+
const pointFurthestOnHorizonCircle = add([], horizonCircleCenter, scale$2([], projectedViewDirection, horizonCircleRadius / projectedViewLength));
|
|
9605
|
+
return pointPlaneSignedDistance(nearPlaneNormalized, pointFurthestOnHorizonCircle);
|
|
9484
9606
|
} else return null;
|
|
9485
9607
|
}
|
|
9486
9608
|
//#endregion
|
|
@@ -9687,7 +9809,7 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9687
9809
|
zoom
|
|
9688
9810
|
};
|
|
9689
9811
|
let lngRange = this._helper._lngRange;
|
|
9690
|
-
if (!this._helper._renderWorldCopies && lngRange === null) lngRange = [-179.9999999999,
|
|
9812
|
+
if (!this._helper._renderWorldCopies && lngRange === null) lngRange = [-179.9999999999, 180 - 1e-10];
|
|
9691
9813
|
const worldSize = this.tileSize * zoomScale(result.zoom);
|
|
9692
9814
|
let minY = 0;
|
|
9693
9815
|
let maxY = worldSize;
|
|
@@ -9712,7 +9834,8 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9712
9834
|
let modifiedX, modifiedY;
|
|
9713
9835
|
const scale = Math.max(scaleX || 0, scaleY || 0);
|
|
9714
9836
|
if (scale) {
|
|
9715
|
-
|
|
9837
|
+
const newPoint = new Point(scaleX ? (maxX + minX) / 2 : originalX, scaleY ? (maxY + minY) / 2 : originalY);
|
|
9838
|
+
result.center = unprojectFromWorldCoordinates(worldSize, newPoint).wrap();
|
|
9716
9839
|
result.zoom += scaleZoom(scale);
|
|
9717
9840
|
return result;
|
|
9718
9841
|
}
|
|
@@ -9729,7 +9852,10 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9729
9852
|
if (wrappedX - w2 < minX) modifiedX = minX + w2;
|
|
9730
9853
|
if (wrappedX + w2 > maxX) modifiedX = maxX - w2;
|
|
9731
9854
|
}
|
|
9732
|
-
if (modifiedX !== void 0 || modifiedY !== void 0)
|
|
9855
|
+
if (modifiedX !== void 0 || modifiedY !== void 0) {
|
|
9856
|
+
const newPoint = new Point(modifiedX ?? originalX, modifiedY ?? originalY);
|
|
9857
|
+
result.center = unprojectFromWorldCoordinates(worldSize, newPoint).wrap();
|
|
9858
|
+
}
|
|
9733
9859
|
return result;
|
|
9734
9860
|
};
|
|
9735
9861
|
this.applyConstrain = (lngLat, zoom) => {
|
|
@@ -9797,10 +9923,18 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9797
9923
|
const elevation = terrain ? terrain.getElevationForLngLatZoom(center, this._helper._tileZoom) : 0;
|
|
9798
9924
|
this._helper.recalculateZoomAndCenter(elevation);
|
|
9799
9925
|
}
|
|
9800
|
-
|
|
9801
|
-
|
|
9926
|
+
/**
|
|
9927
|
+
* Moves the center so that `lnglat`, on the ground at `elevation` meters, renders
|
|
9928
|
+
* at the screen `point`. Both rays are cast through the same inverse pixel matrix
|
|
9929
|
+
* so its inversion error cancels out of their difference; the current-center ray
|
|
9930
|
+
* must be intersected at the center's own elevation (z=0) — intersecting it with
|
|
9931
|
+
* the elevated plane would land `(elevation - centerElevation)·tan(pitch)` away
|
|
9932
|
+
* from the center and make repeated calls drift.
|
|
9933
|
+
*/
|
|
9934
|
+
setLocationAtPoint(lnglat, point, elevation = this.elevation) {
|
|
9935
|
+
const z = elevation - this.elevation;
|
|
9802
9936
|
const a = this.screenPointToMercatorCoordinateAtZ(point, z);
|
|
9803
|
-
const b = this.screenPointToMercatorCoordinateAtZ(this.centerPoint,
|
|
9937
|
+
const b = this.screenPointToMercatorCoordinateAtZ(this.centerPoint, 0);
|
|
9804
9938
|
const loc = MercatorCoordinate.fromLngLat(lnglat);
|
|
9805
9939
|
const newCenter = new MercatorCoordinate(loc.x - (a.x - b.x), loc.y - (a.y - b.y));
|
|
9806
9940
|
this.setCenter(newCenter?.toLngLat());
|
|
@@ -9812,6 +9946,9 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9812
9946
|
screenPointToLocation(p, terrain) {
|
|
9813
9947
|
return this.screenPointToMercatorCoordinate(p, terrain)?.toLngLat();
|
|
9814
9948
|
}
|
|
9949
|
+
screenPointToLocationAtElevation(p, elevation) {
|
|
9950
|
+
return this.screenPointToMercatorCoordinateAtZ(p, elevation - this.elevation)?.toLngLat();
|
|
9951
|
+
}
|
|
9815
9952
|
screenPointToMercatorCoordinate(p, terrain) {
|
|
9816
9953
|
if (terrain) {
|
|
9817
9954
|
const coordinate = terrain.pointCoordinate(p);
|
|
@@ -9819,8 +9956,12 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9819
9956
|
}
|
|
9820
9957
|
return this.screenPointToMercatorCoordinateAtZ(p);
|
|
9821
9958
|
}
|
|
9822
|
-
|
|
9823
|
-
|
|
9959
|
+
/**
|
|
9960
|
+
* Intersects the ray through a screen point with the horizontal plane at `z`,
|
|
9961
|
+
* given in meters relative to the plane at the center's elevation (not mercator units).
|
|
9962
|
+
*/
|
|
9963
|
+
screenPointToMercatorCoordinateAtZ(p, z) {
|
|
9964
|
+
const targetZ = z ? z : 0;
|
|
9824
9965
|
const coord0 = [
|
|
9825
9966
|
p.x,
|
|
9826
9967
|
p.y,
|
|
@@ -10179,21 +10320,22 @@ function cameraBoundsWarning() {
|
|
|
10179
10320
|
* Set a transform's rotation to a value interpolated between startEulerAngles and endEulerAngles
|
|
10180
10321
|
*/
|
|
10181
10322
|
function updateRotation(args) {
|
|
10182
|
-
if (args.useSlerp)
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10323
|
+
if (args.useSlerp) {
|
|
10324
|
+
if (args.k < 1) {
|
|
10325
|
+
const startRotation = rollPitchBearingToQuat(args.startEulerAngles.roll, args.startEulerAngles.pitch, args.startEulerAngles.bearing);
|
|
10326
|
+
const endRotation = rollPitchBearingToQuat(args.endEulerAngles.roll, args.endEulerAngles.pitch, args.endEulerAngles.bearing);
|
|
10327
|
+
const rotation = /* @__PURE__ */ new Float64Array(4);
|
|
10328
|
+
slerp(rotation, startRotation, endRotation, args.k);
|
|
10329
|
+
const eulerAngles = getRollPitchBearing(rotation);
|
|
10330
|
+
args.tr.setRoll(eulerAngles.roll);
|
|
10331
|
+
args.tr.setPitch(eulerAngles.pitch);
|
|
10332
|
+
args.tr.setBearing(eulerAngles.bearing);
|
|
10333
|
+
} else {
|
|
10334
|
+
args.tr.setRoll(args.endEulerAngles.roll);
|
|
10335
|
+
args.tr.setPitch(args.endEulerAngles.pitch);
|
|
10336
|
+
args.tr.setBearing(args.endEulerAngles.bearing);
|
|
10337
|
+
}
|
|
10191
10338
|
} else {
|
|
10192
|
-
args.tr.setRoll(args.endEulerAngles.roll);
|
|
10193
|
-
args.tr.setPitch(args.endEulerAngles.pitch);
|
|
10194
|
-
args.tr.setBearing(args.endEulerAngles.bearing);
|
|
10195
|
-
}
|
|
10196
|
-
else {
|
|
10197
10339
|
args.tr.setRoll(interpolateFactory.number(args.startEulerAngles.roll, args.endEulerAngles.roll, args.k));
|
|
10198
10340
|
args.tr.setPitch(interpolateFactory.number(args.startEulerAngles.pitch, args.endEulerAngles.pitch, args.k));
|
|
10199
10341
|
args.tr.setBearing(interpolateFactory.number(args.startEulerAngles.bearing, args.endEulerAngles.bearing, args.k));
|
|
@@ -10223,7 +10365,9 @@ function cameraForBoxAndBearing(options, padding, bounds, bearing, tr) {
|
|
|
10223
10365
|
}
|
|
10224
10366
|
const zoom = Math.min(scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
|
|
10225
10367
|
const offset = Point.convert(options.offset);
|
|
10226
|
-
const
|
|
10368
|
+
const paddingOffsetX = (padding.left - padding.right) / 2;
|
|
10369
|
+
const paddingOffsetY = (padding.top - padding.bottom) / 2;
|
|
10370
|
+
const rotatedPaddingOffset = new Point(paddingOffsetX, paddingOffsetY).rotate(degreesToRadians(bearing));
|
|
10227
10371
|
const offsetAtFinalZoom = offset.add(rotatedPaddingOffset).mult(tr.scale / zoomScale(zoom));
|
|
10228
10372
|
return {
|
|
10229
10373
|
center: unprojectFromWorldCoordinates(tr.worldSize, nwWorld.add(seWorld).div(2).sub(offsetAtFinalZoom)),
|
|
@@ -10256,7 +10400,7 @@ var MercatorCameraHelper = class {
|
|
|
10256
10400
|
}
|
|
10257
10401
|
handleMapControlsPan(deltas, tr, preZoomAroundLoc) {
|
|
10258
10402
|
if (deltas.around.distSqr(tr.centerPoint) < .01) return;
|
|
10259
|
-
tr.setLocationAtPoint(preZoomAroundLoc, deltas.around);
|
|
10403
|
+
tr.setLocationAtPoint(preZoomAroundLoc, deltas.around, deltas.aroundElevation);
|
|
10260
10404
|
}
|
|
10261
10405
|
cameraForBoxAndBearing(options, padding, bounds, bearing, tr) {
|
|
10262
10406
|
return cameraForBoxAndBearing(options, padding, bounds, bearing, tr);
|
|
@@ -10599,7 +10743,9 @@ function getGlobeCircumferencePixels(transform) {
|
|
|
10599
10743
|
return 2 * Math.PI * radius;
|
|
10600
10744
|
}
|
|
10601
10745
|
function globeDistanceOfLocationsPixels(transform, a, b) {
|
|
10602
|
-
const
|
|
10746
|
+
const vecA = angularCoordinatesToSurfaceVector(a);
|
|
10747
|
+
const vecB = angularCoordinatesToSurfaceVector(b);
|
|
10748
|
+
const dot$2 = dot(vecA, vecB);
|
|
10603
10749
|
const radians = Math.acos(dot$2);
|
|
10604
10750
|
const circumference = getGlobeCircumferencePixels(transform);
|
|
10605
10751
|
return radians / (2 * Math.PI) * circumference;
|
|
@@ -10665,7 +10811,8 @@ function sphereSurfacePointToCoordinates(surface) {
|
|
|
10665
10811
|
const projX = surface[0] / lengthXZ;
|
|
10666
10812
|
const projZ = surface[2] / lengthXZ;
|
|
10667
10813
|
const acosZ = Math.acos(projZ);
|
|
10668
|
-
|
|
10814
|
+
const lngDegrees = (projX > 0 ? acosZ : -acosZ) / Math.PI * 180;
|
|
10815
|
+
return new LngLat(wrap(lngDegrees, -180, 180), latDegrees);
|
|
10669
10816
|
} else return new LngLat(0, latDegrees);
|
|
10670
10817
|
}
|
|
10671
10818
|
/**
|
|
@@ -10711,7 +10858,8 @@ function planetScaleAtLatitude(latitudeDegrees) {
|
|
|
10711
10858
|
*/
|
|
10712
10859
|
function getZoomAdjustment(oldLat, newLat) {
|
|
10713
10860
|
const oldCircumference = planetScaleAtLatitude(oldLat);
|
|
10714
|
-
|
|
10861
|
+
const newCircumference = planetScaleAtLatitude(newLat);
|
|
10862
|
+
return scaleZoom(newCircumference / oldCircumference);
|
|
10715
10863
|
}
|
|
10716
10864
|
function getDegreesPerPixel(worldSize, lat) {
|
|
10717
10865
|
return 360 / getGlobeCircumferencePixels({
|
|
@@ -10759,8 +10907,12 @@ function interpolateLngLatForGlobe(start, deltaLng, deltaLat, t) {
|
|
|
10759
10907
|
const valueStart = integrateSecX(samplePointStart);
|
|
10760
10908
|
const valueEnd = integrateSecX(samplePointEnd);
|
|
10761
10909
|
const newT = (valueT - valueStart) / (valueEnd - valueStart);
|
|
10762
|
-
|
|
10763
|
-
|
|
10910
|
+
const interpolatedLng = start.lng + deltaLng * newT;
|
|
10911
|
+
return new LngLat(interpolatedLng, interpolatedLat);
|
|
10912
|
+
} else {
|
|
10913
|
+
const interpolatedLng = start.lng + deltaLng * t;
|
|
10914
|
+
return new LngLat(interpolatedLng, interpolatedLat);
|
|
10915
|
+
}
|
|
10764
10916
|
}
|
|
10765
10917
|
//#endregion
|
|
10766
10918
|
//#region src/util/primitives/bounding_volume_cache.ts
|
|
@@ -11026,9 +11178,8 @@ var GlobeCoveringTilesDetailsProvider = class {
|
|
|
11026
11178
|
const tileMercatorSize = 1 / scale;
|
|
11027
11179
|
const tileCornerX = tileID.x / scale;
|
|
11028
11180
|
const tileCornerY = tileID.y / scale;
|
|
11029
|
-
const
|
|
11030
|
-
|
|
11031
|
-
let smallestDistance = 2 * worldSize;
|
|
11181
|
+
const halfWorld = .5;
|
|
11182
|
+
let smallestDistance = 2;
|
|
11032
11183
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX, tileCornerY, tileMercatorSize));
|
|
11033
11184
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX + halfWorld, -tileCornerY - tileMercatorSize, tileMercatorSize));
|
|
11034
11185
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX + halfWorld, 2 - tileCornerY - tileMercatorSize, tileMercatorSize));
|
|
@@ -11726,7 +11877,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
|
|
|
11726
11877
|
* Note: automatically adjusts zoom to keep planet size consistent
|
|
11727
11878
|
* (same size before and after a {@link setLocationAtPoint} call).
|
|
11728
11879
|
*/
|
|
11729
|
-
setLocationAtPoint(lnglat, point) {
|
|
11880
|
+
setLocationAtPoint(lnglat, point, _elevation) {
|
|
11730
11881
|
const vecToPixelCurrent = angularCoordinatesToSurfaceVector(this.unprojectScreenPoint(point));
|
|
11731
11882
|
const vecToTarget = angularCoordinatesToSurfaceVector(lnglat);
|
|
11732
11883
|
const zero = createVec3f64();
|
|
@@ -11781,7 +11932,10 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
|
|
|
11781
11932
|
}
|
|
11782
11933
|
locationToScreenPoint(lnglat, terrain) {
|
|
11783
11934
|
const pos = angularCoordinatesToSurfaceVector(lnglat);
|
|
11784
|
-
if (terrain)
|
|
11935
|
+
if (terrain) {
|
|
11936
|
+
const elevation = terrain.getElevationForLngLatZoom(lnglat, this._helper._tileZoom);
|
|
11937
|
+
scale$2(pos, pos, 1 + elevation / earthRadius);
|
|
11938
|
+
}
|
|
11785
11939
|
return this._projectSurfacePointToScreen(pos);
|
|
11786
11940
|
}
|
|
11787
11941
|
/**
|
|
@@ -11805,6 +11959,9 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
|
|
|
11805
11959
|
screenPointToLocation(p, terrain) {
|
|
11806
11960
|
return this.screenPointToMercatorCoordinate(p, terrain)?.toLngLat();
|
|
11807
11961
|
}
|
|
11962
|
+
screenPointToLocationAtElevation(p, _elevation) {
|
|
11963
|
+
return this.screenPointToLocation(p);
|
|
11964
|
+
}
|
|
11808
11965
|
isPointOnMapSurface(p, _terrain) {
|
|
11809
11966
|
const rayOrigin = this._cameraPosition;
|
|
11810
11967
|
const rayDirection = this.getRayDirectionFromPixel(p);
|
|
@@ -12222,7 +12379,9 @@ var GlobeTransform = class GlobeTransform {
|
|
|
12222
12379
|
return lerp(this._mercatorTransform.getCircleRadiusCorrection(), this._verticalPerspectiveTransform.getCircleRadiusCorrection(), this._globeness);
|
|
12223
12380
|
}
|
|
12224
12381
|
getPitchedTextCorrection(textAnchorX, textAnchorY, tileID) {
|
|
12225
|
-
|
|
12382
|
+
const mercatorCorrection = this._mercatorTransform.getPitchedTextCorrection(textAnchorX, textAnchorY, tileID);
|
|
12383
|
+
const verticalCorrection = this._verticalPerspectiveTransform.getPitchedTextCorrection(textAnchorX, textAnchorY, tileID);
|
|
12384
|
+
return lerp(mercatorCorrection, verticalCorrection, this._globeness);
|
|
12226
12385
|
}
|
|
12227
12386
|
projectTileCoordinates(x, y, unwrappedTileID, getElevation) {
|
|
12228
12387
|
return this.currentTransform.projectTileCoordinates(x, y, unwrappedTileID, getElevation);
|
|
@@ -12283,13 +12442,13 @@ var GlobeTransform = class GlobeTransform {
|
|
|
12283
12442
|
* Note: automatically adjusts zoom to keep planet size consistent
|
|
12284
12443
|
* (same size before and after a {@link setLocationAtPoint} call).
|
|
12285
12444
|
*/
|
|
12286
|
-
setLocationAtPoint(lnglat, point) {
|
|
12445
|
+
setLocationAtPoint(lnglat, point, elevation) {
|
|
12287
12446
|
if (!this.isGlobeRendering) {
|
|
12288
|
-
this._mercatorTransform.setLocationAtPoint(lnglat, point);
|
|
12447
|
+
this._mercatorTransform.setLocationAtPoint(lnglat, point, elevation);
|
|
12289
12448
|
this.apply(this._mercatorTransform, false);
|
|
12290
12449
|
return;
|
|
12291
12450
|
}
|
|
12292
|
-
this._verticalPerspectiveTransform.setLocationAtPoint(lnglat, point);
|
|
12451
|
+
this._verticalPerspectiveTransform.setLocationAtPoint(lnglat, point, elevation);
|
|
12293
12452
|
this.apply(this._verticalPerspectiveTransform, false);
|
|
12294
12453
|
}
|
|
12295
12454
|
locationToScreenPoint(lnglat, terrain) {
|
|
@@ -12301,6 +12460,9 @@ var GlobeTransform = class GlobeTransform {
|
|
|
12301
12460
|
screenPointToLocation(p, terrain) {
|
|
12302
12461
|
return this.currentTransform.screenPointToLocation(p, terrain);
|
|
12303
12462
|
}
|
|
12463
|
+
screenPointToLocationAtElevation(p, elevation) {
|
|
12464
|
+
return this.currentTransform.screenPointToLocationAtElevation(p, elevation);
|
|
12465
|
+
}
|
|
12304
12466
|
isPointOnMapSurface(p, terrain) {
|
|
12305
12467
|
return this.currentTransform.isPointOnMapSurface(p, terrain);
|
|
12306
12468
|
}
|
|
@@ -12324,6 +12486,35 @@ var GlobeTransform = class GlobeTransform {
|
|
|
12324
12486
|
//#endregion
|
|
12325
12487
|
//#region src/geo/projection/vertical_perspective_camera_helper.ts
|
|
12326
12488
|
/**
|
|
12489
|
+
* Zoom movement slowing starts when the mouse ray passes further than this above the planet surface,
|
|
12490
|
+
* so a cursor off the globe does not move the map unnaturally. Globe radius is 1, so 0.3 is ~2000 km.
|
|
12491
|
+
*/
|
|
12492
|
+
const RAY_SURFACE_DISTANCE_FOR_SLOWING_START = .3;
|
|
12493
|
+
/** How sharply zoom movement slows as the mouse ray rises above the planet surface. Lower is more gradual. */
|
|
12494
|
+
const SLOWING_MULTIPLIER = .5;
|
|
12495
|
+
/** Longitude difference between zoom location and map center at which the blend from exact to heuristic zooming starts, in degrees. */
|
|
12496
|
+
const INTERPOLATE_TO_HEURISTIC_START_LNG = 45;
|
|
12497
|
+
/** Longitude difference at which the blend to heuristic zooming is complete, in degrees. */
|
|
12498
|
+
const INTERPOLATE_TO_HEURISTIC_END_LNG = 85;
|
|
12499
|
+
/** Exponent applied to the blend factor: below 1, so the blend leans towards heuristic zooming and flattens as it completes. */
|
|
12500
|
+
const INTERPOLATE_TO_HEURISTIC_EXPONENT = .25;
|
|
12501
|
+
/**
|
|
12502
|
+
* Distance of the mouse ray from the globe center at which the blend from exact to heuristic zooming
|
|
12503
|
+
* starts. Globe radius is 1, so 1 is a ray grazing the horizon.
|
|
12504
|
+
*/
|
|
12505
|
+
const INTERPOLATE_TO_HEURISTIC_START_HORIZON = .95;
|
|
12506
|
+
/** Ray distance at which the blend to heuristic zooming is complete. */
|
|
12507
|
+
const INTERPOLATE_TO_HEURISTIC_END_HORIZON = .999;
|
|
12508
|
+
/**
|
|
12509
|
+
* Globe radius relative to the smaller viewport dimension below which zoom movement near the horizon
|
|
12510
|
+
* starts being inhibited, avoiding unnatural movements when the map is zoomed out a lot.
|
|
12511
|
+
*/
|
|
12512
|
+
const SLOWING_RADIUS_START = .9;
|
|
12513
|
+
/** Globe radius relative to the smaller viewport dimension at which that inhibition is at full strength. */
|
|
12514
|
+
const SLOWING_RADIUS_STOP = .5;
|
|
12515
|
+
/** Fraction of the zoom movement that remains once the globe has shrunk to `SLOWING_RADIUS_STOP`. */
|
|
12516
|
+
const SLOWING_RADIUS_SLOW_FACTOR = .25;
|
|
12517
|
+
/**
|
|
12327
12518
|
* @internal
|
|
12328
12519
|
*/
|
|
12329
12520
|
var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
@@ -12338,6 +12529,13 @@ var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
|
12338
12529
|
easingOffset: new Point(0, 0)
|
|
12339
12530
|
};
|
|
12340
12531
|
}
|
|
12532
|
+
/**
|
|
12533
|
+
* Zooms around the pointer.
|
|
12534
|
+
*
|
|
12535
|
+
* `setLocationAtPoint` is exact but degenerates when called repeatedly for a
|
|
12536
|
+
* location whose longitude is far from the center's, or one near the horizon,
|
|
12537
|
+
* so those cases blend towards a heuristic.
|
|
12538
|
+
*/
|
|
12341
12539
|
handleMapControlsRollPitchBearingZoom(deltas, tr) {
|
|
12342
12540
|
const zoomPixel = deltas.around;
|
|
12343
12541
|
const zoomLoc = tr.screenPointToLocation(zoomPixel);
|
|
@@ -12348,16 +12546,6 @@ var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
|
12348
12546
|
if (deltas.zoomDelta) tr.setZoom(tr.zoom + deltas.zoomDelta);
|
|
12349
12547
|
const actualZoomDelta = tr.zoom - oldZoomPreZoomDelta;
|
|
12350
12548
|
if (actualZoomDelta === 0) return;
|
|
12351
|
-
const raySurfaceDistanceForSlowingStart = .3;
|
|
12352
|
-
const slowingMultiplier = .5;
|
|
12353
|
-
const interpolateToHeuristicStartLng = 45;
|
|
12354
|
-
const interpolateToHeuristicEndLng = 85;
|
|
12355
|
-
const interpolateToHeuristicExponent = .25;
|
|
12356
|
-
const interpolateToHeuristicStartRadius = .75;
|
|
12357
|
-
const interpolateToHeuristicEndRadius = .35;
|
|
12358
|
-
const slowingRadiusStart = .9;
|
|
12359
|
-
const slowingRadiusStop = .5;
|
|
12360
|
-
const slowingRadiusSlowFactor = .25;
|
|
12361
12549
|
const dLngRaw = differenceOfAnglesDegrees(tr.center.lng, zoomLoc.lng);
|
|
12362
12550
|
const dLng = dLngRaw / (Math.abs(dLngRaw / 180) + 1);
|
|
12363
12551
|
const dLat = differenceOfAnglesDegrees(tr.center.lat, zoomLoc.lat);
|
|
@@ -12370,19 +12558,21 @@ var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
|
12370
12558
|
rayDirection[1] * distanceToClosestPoint,
|
|
12371
12559
|
rayDirection[2] * distanceToClosestPoint
|
|
12372
12560
|
]);
|
|
12373
|
-
const
|
|
12374
|
-
const
|
|
12561
|
+
const rayDistanceFromGlobeCenter = length$1(closestPoint);
|
|
12562
|
+
const distanceFromSurface = rayDistanceFromGlobeCenter - 1;
|
|
12563
|
+
const distanceFactor = Math.exp(-Math.max(distanceFromSurface - RAY_SURFACE_DISTANCE_FOR_SLOWING_START, 0) * SLOWING_MULTIPLIER);
|
|
12564
|
+
const interpolationFactorHorizon = remapSaturate(rayDistanceFromGlobeCenter, INTERPOLATE_TO_HEURISTIC_START_HORIZON, INTERPOLATE_TO_HEURISTIC_END_HORIZON, 0, 1);
|
|
12375
12565
|
const radius = getGlobeRadiusPixels(tr.worldSize, tr.center.lat) / Math.min(tr.width, tr.height);
|
|
12376
|
-
const radiusFactor = remapSaturate(radius,
|
|
12377
|
-
const
|
|
12566
|
+
const radiusFactor = remapSaturate(radius, SLOWING_RADIUS_START, SLOWING_RADIUS_STOP, 1, SLOWING_RADIUS_SLOW_FACTOR);
|
|
12567
|
+
const slowingFactor = Math.min(distanceFactor, lerp(1, radiusFactor, interpolationFactorHorizon));
|
|
12568
|
+
const factor = (1 - zoomScale(-actualZoomDelta)) * slowingFactor;
|
|
12378
12569
|
const oldCenterLat = tr.center.lat;
|
|
12379
12570
|
const oldZoom = tr.zoom;
|
|
12380
12571
|
const heuristicCenter = new LngLat(tr.center.lng + dLng * factor, clamp(tr.center.lat + dLat * factor, -MAX_VALID_LATITUDE, MAX_VALID_LATITUDE));
|
|
12381
12572
|
tr.setLocationAtPoint(zoomLoc, zoomPixel);
|
|
12382
12573
|
const exactCenter = tr.center;
|
|
12383
|
-
const interpolationFactorLongitude = remapSaturate(Math.abs(dLngRaw),
|
|
12384
|
-
const
|
|
12385
|
-
const heuristicFactor = Math.pow(Math.max(interpolationFactorLongitude, interpolationFactorRadius), interpolateToHeuristicExponent);
|
|
12574
|
+
const interpolationFactorLongitude = remapSaturate(Math.abs(dLngRaw), INTERPOLATE_TO_HEURISTIC_START_LNG, INTERPOLATE_TO_HEURISTIC_END_LNG, 0, 1);
|
|
12575
|
+
const heuristicFactor = Math.pow(Math.max(interpolationFactorLongitude, interpolationFactorHorizon), INTERPOLATE_TO_HEURISTIC_EXPONENT);
|
|
12386
12576
|
const lngExactToHeuristic = differenceOfAnglesDegrees(exactCenter.lng, heuristicCenter.lng);
|
|
12387
12577
|
const latExactToHeuristic = differenceOfAnglesDegrees(exactCenter.lat, heuristicCenter.lat);
|
|
12388
12578
|
tr.setCenter(new LngLat(exactCenter.lng + lngExactToHeuristic * heuristicFactor, exactCenter.lat + latExactToHeuristic * heuristicFactor).wrap());
|
|
@@ -12535,7 +12725,8 @@ var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
|
12535
12725
|
const requestedMinZoom = typeof options.minZoom === "number" ? +options.minZoom : tr.minZoom;
|
|
12536
12726
|
const normalizedEffectiveMinZoom = Math.max(requestedMinZoom, tr.minZoom) + getZoomAdjustment(targetCenter.lat, 0);
|
|
12537
12727
|
const minZoomPreConstrain = Math.min(normalizedEffectiveMinZoom, normalizedStartZoom, normalizedTargetZoom) + getZoomAdjustment(0, targetCenter.lat);
|
|
12538
|
-
const
|
|
12728
|
+
const normalizedMinZoom = tr.applyConstrain(targetCenter, minZoomPreConstrain).zoom + getZoomAdjustment(targetCenter.lat, 0);
|
|
12729
|
+
const scaleOfMinZoom = zoomScale(normalizedMinZoom - normalizedStartZoom);
|
|
12539
12730
|
const deltaLng = differenceOfAnglesDegrees(startCenter.lng, targetCenter.lng);
|
|
12540
12731
|
const deltaLat = differenceOfAnglesDegrees(startCenter.lat, targetCenter.lat);
|
|
12541
12732
|
const easeFunc = (k, scale, centerFactor, _pointAtOffset) => {
|
|
@@ -13159,9 +13350,7 @@ var Style = class extends Evented {
|
|
|
13159
13350
|
case "setTransition":
|
|
13160
13351
|
operations.push(() => {});
|
|
13161
13352
|
break;
|
|
13162
|
-
default:
|
|
13163
|
-
unimplemented.push(op.command);
|
|
13164
|
-
break;
|
|
13353
|
+
default: unimplemented.push(op.command);
|
|
13165
13354
|
}
|
|
13166
13355
|
return {
|
|
13167
13356
|
operations,
|
|
@@ -14109,6 +14298,25 @@ function getTokenizedAttributesAndUniforms(array) {
|
|
|
14109
14298
|
}
|
|
14110
14299
|
return result;
|
|
14111
14300
|
}
|
|
14301
|
+
function getIntegerAttributeNames(gl, program) {
|
|
14302
|
+
const integerTypes = /* @__PURE__ */ new Set([
|
|
14303
|
+
gl.INT,
|
|
14304
|
+
gl.INT_VEC2,
|
|
14305
|
+
gl.INT_VEC3,
|
|
14306
|
+
gl.INT_VEC4,
|
|
14307
|
+
gl.UNSIGNED_INT,
|
|
14308
|
+
gl.UNSIGNED_INT_VEC2,
|
|
14309
|
+
gl.UNSIGNED_INT_VEC3,
|
|
14310
|
+
gl.UNSIGNED_INT_VEC4
|
|
14311
|
+
]);
|
|
14312
|
+
const names = /* @__PURE__ */ new Set();
|
|
14313
|
+
const numActiveAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
14314
|
+
for (let i = 0; i < numActiveAttributes; i++) {
|
|
14315
|
+
const attribute = gl.getActiveAttrib(program, i);
|
|
14316
|
+
if (attribute && integerTypes.has(attribute.type)) names.add(attribute.name);
|
|
14317
|
+
}
|
|
14318
|
+
return names;
|
|
14319
|
+
}
|
|
14112
14320
|
/**
|
|
14113
14321
|
* @internal
|
|
14114
14322
|
* A webgl program to execute in the GPU space
|
|
@@ -14156,13 +14364,17 @@ var Program = class {
|
|
|
14156
14364
|
this.attributes = {};
|
|
14157
14365
|
const uniformLocations = {};
|
|
14158
14366
|
this.numAttributes = allAttrInfo.length;
|
|
14159
|
-
for (let i = 0; i < this.numAttributes; i++) if (allAttrInfo[i]) this.attributes[allAttrInfo[i]] = i;
|
|
14160
14367
|
gl.linkProgram(this.program);
|
|
14161
|
-
for (const name in this.attributes) {
|
|
14162
|
-
const actual = gl.getAttribLocation(this.program, name);
|
|
14163
|
-
if (actual >= 0) this.attributes[name] = actual;
|
|
14164
|
-
}
|
|
14165
14368
|
if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
|
|
14369
|
+
const integerAttributeNames = getIntegerAttributeNames(gl, this.program);
|
|
14370
|
+
for (const name of allAttrInfo) {
|
|
14371
|
+
if (!name) continue;
|
|
14372
|
+
const location = gl.getAttribLocation(this.program, name);
|
|
14373
|
+
if (location >= 0) this.attributes[name] = {
|
|
14374
|
+
location,
|
|
14375
|
+
isInteger: integerAttributeNames.has(name)
|
|
14376
|
+
};
|
|
14377
|
+
}
|
|
14166
14378
|
gl.deleteShader(vertexShader);
|
|
14167
14379
|
gl.deleteShader(fragmentShader);
|
|
14168
14380
|
for (const uniform of allUniformsInfo) if (uniform && !uniformLocations[uniform]) {
|
|
@@ -14203,9 +14415,7 @@ var Program = class {
|
|
|
14203
14415
|
case gl.TRIANGLES:
|
|
14204
14416
|
primitiveSize = 3;
|
|
14205
14417
|
break;
|
|
14206
|
-
case gl.LINE_STRIP:
|
|
14207
|
-
primitiveSize = 1;
|
|
14208
|
-
break;
|
|
14418
|
+
case gl.LINE_STRIP: primitiveSize = 1;
|
|
14209
14419
|
}
|
|
14210
14420
|
for (const segment of segments.get()) {
|
|
14211
14421
|
segment.vaos ||= {};
|
|
@@ -14472,9 +14682,7 @@ const hillshadeUniformValues = (painter, tile, layer) => {
|
|
|
14472
14682
|
case "multidirectional":
|
|
14473
14683
|
method = 3;
|
|
14474
14684
|
break;
|
|
14475
|
-
default:
|
|
14476
|
-
method = 0;
|
|
14477
|
-
break;
|
|
14685
|
+
default: method = 0;
|
|
14478
14686
|
}
|
|
14479
14687
|
const illumination = layer.getIlluminationProperties();
|
|
14480
14688
|
for (let i = 0; i < illumination.directionRadians.length; i++) if (layer.paint.get("hillshade-illumination-anchor") === "viewport") illumination.directionRadians[i] += painter.transform.bearingInRadians;
|
|
@@ -14666,66 +14874,6 @@ const layerOpacityUniformValues = (opacity, textureUnit) => ({
|
|
|
14666
14874
|
"u_opacity": opacity
|
|
14667
14875
|
});
|
|
14668
14876
|
//#endregion
|
|
14669
|
-
//#region src/webgl/program/raster_program.ts
|
|
14670
|
-
const rasterUniforms = (context, locations) => ({
|
|
14671
|
-
"u_tl_parent": new Uniform2f(context, locations.u_tl_parent),
|
|
14672
|
-
"u_scale_parent": new Uniform1f(context, locations.u_scale_parent),
|
|
14673
|
-
"u_buffer_scale": new Uniform1f(context, locations.u_buffer_scale),
|
|
14674
|
-
"u_fade_t": new Uniform1f(context, locations.u_fade_t),
|
|
14675
|
-
"u_opacity": new Uniform1f(context, locations.u_opacity),
|
|
14676
|
-
"u_image0": new Uniform1i(context, locations.u_image0),
|
|
14677
|
-
"u_image1": new Uniform1i(context, locations.u_image1),
|
|
14678
|
-
"u_brightness_low": new Uniform1f(context, locations.u_brightness_low),
|
|
14679
|
-
"u_brightness_high": new Uniform1f(context, locations.u_brightness_high),
|
|
14680
|
-
"u_saturation_factor": new Uniform1f(context, locations.u_saturation_factor),
|
|
14681
|
-
"u_contrast_factor": new Uniform1f(context, locations.u_contrast_factor),
|
|
14682
|
-
"u_spin_weights": new Uniform3f(context, locations.u_spin_weights),
|
|
14683
|
-
"u_coords_top": new Uniform4f(context, locations.u_coords_top),
|
|
14684
|
-
"u_coords_bottom": new Uniform4f(context, locations.u_coords_bottom)
|
|
14685
|
-
});
|
|
14686
|
-
const rasterUniformValues = (parentTL, parentScaleBy, fade, layer, cornerCoords) => ({
|
|
14687
|
-
"u_tl_parent": parentTL,
|
|
14688
|
-
"u_scale_parent": parentScaleBy,
|
|
14689
|
-
"u_buffer_scale": 1,
|
|
14690
|
-
"u_fade_t": fade.mix,
|
|
14691
|
-
"u_opacity": fade.opacity * layer.paint.get("raster-opacity"),
|
|
14692
|
-
"u_image0": 0,
|
|
14693
|
-
"u_image1": 1,
|
|
14694
|
-
"u_brightness_low": layer.paint.get("raster-brightness-min"),
|
|
14695
|
-
"u_brightness_high": layer.paint.get("raster-brightness-max"),
|
|
14696
|
-
"u_saturation_factor": saturationFactor(layer.paint.get("raster-saturation")),
|
|
14697
|
-
"u_contrast_factor": contrastFactor(layer.paint.get("raster-contrast")),
|
|
14698
|
-
"u_spin_weights": spinWeights(layer.paint.get("raster-hue-rotate")),
|
|
14699
|
-
"u_coords_top": [
|
|
14700
|
-
cornerCoords[0].x,
|
|
14701
|
-
cornerCoords[0].y,
|
|
14702
|
-
cornerCoords[1].x,
|
|
14703
|
-
cornerCoords[1].y
|
|
14704
|
-
],
|
|
14705
|
-
"u_coords_bottom": [
|
|
14706
|
-
cornerCoords[3].x,
|
|
14707
|
-
cornerCoords[3].y,
|
|
14708
|
-
cornerCoords[2].x,
|
|
14709
|
-
cornerCoords[2].y
|
|
14710
|
-
]
|
|
14711
|
-
});
|
|
14712
|
-
function spinWeights(angle) {
|
|
14713
|
-
angle *= Math.PI / 180;
|
|
14714
|
-
const s = Math.sin(angle);
|
|
14715
|
-
const c = Math.cos(angle);
|
|
14716
|
-
return [
|
|
14717
|
-
(2 * c + 1) / 3,
|
|
14718
|
-
(-Math.sqrt(3) * s - c + 1) / 3,
|
|
14719
|
-
(Math.sqrt(3) * s - c + 1) / 3
|
|
14720
|
-
];
|
|
14721
|
-
}
|
|
14722
|
-
function contrastFactor(contrast) {
|
|
14723
|
-
return contrast > 0 ? 1 / (1 - contrast) : 1 + contrast;
|
|
14724
|
-
}
|
|
14725
|
-
function saturationFactor(saturation) {
|
|
14726
|
-
return saturation > 0 ? 1 - 1 / (1.001 - saturation) : -saturation;
|
|
14727
|
-
}
|
|
14728
|
-
//#endregion
|
|
14729
14877
|
//#region src/webgl/program/symbol_program.ts
|
|
14730
14878
|
const symbolIconUniforms = (context, locations) => ({
|
|
14731
14879
|
"u_is_size_zoom_constant": new Uniform1i(context, locations.u_is_size_zoom_constant),
|
|
@@ -15034,8 +15182,8 @@ var VertexBuffer = class {
|
|
|
15034
15182
|
}
|
|
15035
15183
|
enableAttributes(gl, program) {
|
|
15036
15184
|
for (const member of this.attributes) {
|
|
15037
|
-
const
|
|
15038
|
-
if (
|
|
15185
|
+
const attribute = program.attributes[member.name];
|
|
15186
|
+
if (attribute !== void 0) gl.enableVertexAttribArray(attribute.location);
|
|
15039
15187
|
}
|
|
15040
15188
|
}
|
|
15041
15189
|
/**
|
|
@@ -15046,8 +15194,12 @@ var VertexBuffer = class {
|
|
|
15046
15194
|
*/
|
|
15047
15195
|
setVertexAttribPointers(gl, program, vertexOffset) {
|
|
15048
15196
|
for (const member of this.attributes) {
|
|
15049
|
-
const
|
|
15050
|
-
if (
|
|
15197
|
+
const attribute = program.attributes[member.name];
|
|
15198
|
+
if (attribute !== void 0) {
|
|
15199
|
+
const offset = member.offset + this.itemSize * (vertexOffset || 0);
|
|
15200
|
+
if (attribute.isInteger) gl.vertexAttribIPointer(attribute.location, member.components, gl[AttributeType[member.type]], this.itemSize, offset);
|
|
15201
|
+
else gl.vertexAttribPointer(attribute.location, member.components, gl[AttributeType[member.type]], false, this.itemSize, offset);
|
|
15202
|
+
}
|
|
15051
15203
|
}
|
|
15052
15204
|
}
|
|
15053
15205
|
/**
|
|
@@ -15675,6 +15827,24 @@ var Context = class {
|
|
|
15675
15827
|
this.pixelStoreUnpackPremultiplyAlpha.dirty = true;
|
|
15676
15828
|
this.pixelStoreUnpackFlipY.dirty = true;
|
|
15677
15829
|
}
|
|
15830
|
+
/**
|
|
15831
|
+
* Reset some GL state to default values before handing users the raw context, as we do for
|
|
15832
|
+
* custom layers and WebGL style images, to avoid hard-to-debug bugs in their code.
|
|
15833
|
+
*
|
|
15834
|
+
* MapLibre restores all of its own state afterwards, so the only state worth resetting first
|
|
15835
|
+
* is state users would be surprised to find dirty: `CULL_FACE`, `TEXTURE0` and the three
|
|
15836
|
+
* `UNPACK_` settings, whose defaults are meaningful enough that most code assumes them.
|
|
15837
|
+
* The vertex array is unbound rather than reset, so that MapLibre never has to track it and
|
|
15838
|
+
* a user's `vertexAttribPointer` calls cannot land on one of ours.
|
|
15839
|
+
*/
|
|
15840
|
+
setCustomLayerDefaults() {
|
|
15841
|
+
this.unbindVAO();
|
|
15842
|
+
this.cullFace.setDefault();
|
|
15843
|
+
this.activeTexture.setDefault();
|
|
15844
|
+
this.pixelStoreUnpack.setDefault();
|
|
15845
|
+
this.pixelStoreUnpackPremultiplyAlpha.setDefault();
|
|
15846
|
+
this.pixelStoreUnpackFlipY.setDefault();
|
|
15847
|
+
}
|
|
15678
15848
|
createIndexBuffer(array, dynamicDraw) {
|
|
15679
15849
|
return new IndexBuffer(this, array, dynamicDraw);
|
|
15680
15850
|
}
|
|
@@ -16083,9 +16253,10 @@ function drawLayerSymbols(painter, tileManager, layer, coords, isText, translate
|
|
|
16083
16253
|
const uLabelPlaneMatrix = alongLine || shaderVariableAnchor ? identityMat4 : combinedLabelPlaneMatrix;
|
|
16084
16254
|
const hasHalo = isSDF && layer.paint.get(isText ? "text-halo-width" : "icon-halo-width").constantOr(1) !== 0;
|
|
16085
16255
|
let uniformValues;
|
|
16086
|
-
if (isSDF)
|
|
16087
|
-
|
|
16088
|
-
|
|
16256
|
+
if (isSDF) {
|
|
16257
|
+
if (!bucket.iconsInText) uniformValues = symbolSDFUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, alongLine, shaderVariableAnchor, painter, uLabelPlaneMatrix, glCoordMatrixForShader, translation, isText, texSize, hasHalo, pitchedTextRescaling, isOffset);
|
|
16258
|
+
else uniformValues = symbolTextAndIconUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, alongLine, shaderVariableAnchor, painter, uLabelPlaneMatrix, glCoordMatrixForShader, translation, texSize, texSizeIcon, pitchedTextRescaling, isOffset);
|
|
16259
|
+
} else uniformValues = symbolIconUniformValues(sizeData.kind, size, rotateInShader, pitchWithMap, alongLine, shaderVariableAnchor, painter, uLabelPlaneMatrix, glCoordMatrixForShader, translation, isText, texSize, pitchedTextRescaling, isOffset);
|
|
16089
16260
|
const state = {
|
|
16090
16261
|
program,
|
|
16091
16262
|
buffers,
|
|
@@ -16167,7 +16338,9 @@ function drawCircles(painter, tileManager, layer, coords, renderOptions) {
|
|
|
16167
16338
|
const tile = tileManager.getTile(coord);
|
|
16168
16339
|
const bucket = tile.getBucket(layer);
|
|
16169
16340
|
if (!bucket) continue;
|
|
16170
|
-
const
|
|
16341
|
+
const styleTranslate = layer.paint.get("circle-translate");
|
|
16342
|
+
const styleTranslateAnchor = layer.paint.get("circle-translate-anchor");
|
|
16343
|
+
const translateForUniforms = translatePosition(transform, tile, styleTranslate, styleTranslateAnchor);
|
|
16171
16344
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
16172
16345
|
const program = painter.useProgram("circle", programConfiguration);
|
|
16173
16346
|
const layoutVertexBuffer = bucket.layoutVertexBuffer;
|
|
@@ -16447,7 +16620,8 @@ function updateGradientTexture(painter, tileManager, context, gl, layer, bucket,
|
|
|
16447
16620
|
if (layer.stepInterpolant) {
|
|
16448
16621
|
const sourceMaxZoom = tileManager.getSource().maxzoom;
|
|
16449
16622
|
const potentialOverzoom = coord.canonical.z === sourceMaxZoom ? Math.ceil(1 << painter.transform.maxZoom - coord.canonical.z) : 1;
|
|
16450
|
-
|
|
16623
|
+
const maxTextureCoverage = bucket.maxLineLength / EXTENT * 1024 * potentialOverzoom;
|
|
16624
|
+
textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);
|
|
16451
16625
|
}
|
|
16452
16626
|
layerGradient.gradient = renderColorRamp({
|
|
16453
16627
|
expression: layer.gradientExpression(),
|
|
@@ -16767,13 +16941,15 @@ function drawHillshade(painter, tileManager, layer, tileIDs, renderOptions) {
|
|
|
16767
16941
|
painter.width,
|
|
16768
16942
|
painter.height
|
|
16769
16943
|
]);
|
|
16770
|
-
} else if (painter.renderPass === "translucent")
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16944
|
+
} else if (painter.renderPass === "translucent") {
|
|
16945
|
+
if (useSubdivision) {
|
|
16946
|
+
const [stencilBorderless, stencilBorders, coords] = painter.stencilConfigForOverlapTwoPass(tileIDs);
|
|
16947
|
+
renderHillshade(painter, tileManager, layer, coords, stencilBorderless, depthMode, colorMode, false, isRenderingToTexture);
|
|
16948
|
+
renderHillshade(painter, tileManager, layer, coords, stencilBorders, depthMode, colorMode, true, isRenderingToTexture);
|
|
16949
|
+
} else {
|
|
16950
|
+
const [stencil, coords] = painter.getStencilConfigForOverlapAndUpdateStencilID(tileIDs);
|
|
16951
|
+
renderHillshade(painter, tileManager, layer, coords, stencil, depthMode, colorMode, false, isRenderingToTexture);
|
|
16952
|
+
}
|
|
16777
16953
|
}
|
|
16778
16954
|
}
|
|
16779
16955
|
function renderHillshade(painter, tileManager, layer, coords, stencilModes, depthMode, colorMode, useBorder, isRenderingToTexture) {
|
|
@@ -16930,17 +17106,17 @@ function drawRaster(painter, tileManager, layer, tileIDs, renderOptions) {
|
|
|
16930
17106
|
const { isRenderingToTexture } = renderOptions;
|
|
16931
17107
|
const source = tileManager.getSource();
|
|
16932
17108
|
const useSubdivision = painter.style.projection.useSubdivision;
|
|
16933
|
-
if (source instanceof ImageSource) drawTiles(painter, tileManager, layer, tileIDs, null, false, false, source.tileCoords, source.flippedWindingOrder, isRenderingToTexture);
|
|
17109
|
+
if (source instanceof ImageSource) drawTiles(painter, tileManager, layer, tileIDs, null, false, false, source.tileCoords, source.perspectiveTransform, source.flippedWindingOrder, isRenderingToTexture);
|
|
16934
17110
|
else if (useSubdivision) {
|
|
16935
17111
|
const [stencilBorderless, stencilBorders, coords] = painter.stencilConfigForOverlapTwoPass(tileIDs);
|
|
16936
|
-
drawTiles(painter, tileManager, layer, coords, stencilBorderless, false, true, cornerCoords, false, isRenderingToTexture);
|
|
16937
|
-
drawTiles(painter, tileManager, layer, coords, stencilBorders, true, true, cornerCoords, false, isRenderingToTexture);
|
|
17112
|
+
drawTiles(painter, tileManager, layer, coords, stencilBorderless, false, true, cornerCoords, identityPerspectiveTransform, false, isRenderingToTexture);
|
|
17113
|
+
drawTiles(painter, tileManager, layer, coords, stencilBorders, true, true, cornerCoords, identityPerspectiveTransform, false, isRenderingToTexture);
|
|
16938
17114
|
} else {
|
|
16939
17115
|
const [stencil, coords] = painter.getStencilConfigForOverlapAndUpdateStencilID(tileIDs);
|
|
16940
|
-
drawTiles(painter, tileManager, layer, coords, stencil, false, true, cornerCoords, false, isRenderingToTexture);
|
|
17116
|
+
drawTiles(painter, tileManager, layer, coords, stencil, false, true, cornerCoords, identityPerspectiveTransform, false, isRenderingToTexture);
|
|
16941
17117
|
}
|
|
16942
17118
|
}
|
|
16943
|
-
function drawTiles(painter, tileManager, layer, coords, stencilModes, useBorder, allowPoles, corners, flipCullfaceMode = false, isRenderingToTexture = false) {
|
|
17119
|
+
function drawTiles(painter, tileManager, layer, coords, stencilModes, useBorder, allowPoles, corners, perspectiveTransform, flipCullfaceMode = false, isRenderingToTexture = false) {
|
|
16944
17120
|
const minTileZ = coords[coords.length - 1].overscaledZ;
|
|
16945
17121
|
const context = painter.context;
|
|
16946
17122
|
const gl = context.gl;
|
|
@@ -16973,7 +17149,7 @@ function drawTiles(painter, tileManager, layer, coords, stencilModes, useBorder,
|
|
|
16973
17149
|
applyGlobeMatrix: !isRenderingToTexture,
|
|
16974
17150
|
applyTerrainMatrix: true
|
|
16975
17151
|
});
|
|
16976
|
-
const uniformValues = rasterUniformValues(parentTopLeft, parentScaleBy, fadeValues.fadeMix, layer, corners);
|
|
17152
|
+
const uniformValues = rasterUniformValues(parentTopLeft, parentScaleBy, fadeValues.fadeMix, layer, corners, perspectiveTransform);
|
|
16977
17153
|
const mesh = projection.getMeshFromTileID(context, coord.canonical, useBorder, allowPoles, "raster");
|
|
16978
17154
|
const stencilMode = stencilModes ? stencilModes[coord.overscaledZ] : StencilMode.disabled;
|
|
16979
17155
|
program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, flipCullfaceMode ? CullFaceMode.frontCCW : CullFaceMode.backCCW, uniformValues, terrainData, projectionData, layer.id, mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);
|
|
@@ -17040,7 +17216,8 @@ function getCrossFadeValues(tile, parentTile, fadeDuration) {
|
|
|
17040
17216
|
* Simple fade-in values for tile without a parent (i.e. edge tiles)
|
|
17041
17217
|
*/
|
|
17042
17218
|
function getSelfFadeValues(tile, fadeDuration) {
|
|
17043
|
-
const
|
|
17219
|
+
const timeSinceTile = (now() - tile.timeAdded) / fadeDuration;
|
|
17220
|
+
const tileOpacity = clamp(timeSinceTile, 0, 1);
|
|
17044
17221
|
return {
|
|
17045
17222
|
tileOpacity,
|
|
17046
17223
|
fadeMix: {
|
|
@@ -17600,7 +17777,7 @@ var Painter = class Painter {
|
|
|
17600
17777
|
context.setDepthMode(DepthMode.disabled);
|
|
17601
17778
|
const stencilRefs = {};
|
|
17602
17779
|
for (const tileID of tileIDs) stencilRefs[tileID.key] = this.nextStencilID++;
|
|
17603
|
-
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
17780
|
+
if (this.style.projection.useSubdivision) this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
17604
17781
|
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, false);
|
|
17605
17782
|
this._tileClippingMaskIDs = stencilRefs;
|
|
17606
17783
|
}
|
|
@@ -17992,12 +18169,7 @@ var Painter = class Painter {
|
|
|
17992
18169
|
return this.cache[key];
|
|
17993
18170
|
}
|
|
17994
18171
|
setCustomLayerDefaults() {
|
|
17995
|
-
this.context.
|
|
17996
|
-
this.context.cullFace.setDefault();
|
|
17997
|
-
this.context.activeTexture.setDefault();
|
|
17998
|
-
this.context.pixelStoreUnpack.setDefault();
|
|
17999
|
-
this.context.pixelStoreUnpackPremultiplyAlpha.setDefault();
|
|
18000
|
-
this.context.pixelStoreUnpackFlipY.setDefault();
|
|
18172
|
+
this.context.setCustomLayerDefaults();
|
|
18001
18173
|
}
|
|
18002
18174
|
setBaseState() {
|
|
18003
18175
|
const gl = this.context.gl;
|
|
@@ -18152,7 +18324,7 @@ var Hash = class {
|
|
|
18152
18324
|
location = location.replace("&&", "&");
|
|
18153
18325
|
window.history.replaceState(window.history.state, null, location);
|
|
18154
18326
|
};
|
|
18155
|
-
this._updateHash = throttle(this._updateHashUnthrottled,
|
|
18327
|
+
this._updateHash = throttle(this._updateHashUnthrottled, 300);
|
|
18156
18328
|
this._hashName = hashName && encodeURIComponent(hashName);
|
|
18157
18329
|
}
|
|
18158
18330
|
/**
|
|
@@ -19631,7 +19803,8 @@ var ScrollZoomHandler = class {
|
|
|
19631
19803
|
const t = (now() - currentEase.start) / currentEase.duration;
|
|
19632
19804
|
const speed = currentEase.easing(t + .01) - currentEase.easing(t);
|
|
19633
19805
|
const x = .27 / Math.sqrt(speed * speed + 1e-4) * .01;
|
|
19634
|
-
|
|
19806
|
+
const y = Math.sqrt(.0729 - x * x);
|
|
19807
|
+
easing = bezier(x, y, .25, 1);
|
|
19635
19808
|
}
|
|
19636
19809
|
this._prevEase = {
|
|
19637
19810
|
start: now(),
|
|
@@ -20188,6 +20361,11 @@ var TransformProvider = class {
|
|
|
20188
20361
|
//#endregion
|
|
20189
20362
|
//#region src/ui/handler_manager.ts
|
|
20190
20363
|
const isMoving = (p) => p.zoom || p.drag || p.roll || p.pitch || p.rotate;
|
|
20364
|
+
/**
|
|
20365
|
+
* A terrain gesture's anchor plane must stay below this fraction of the camera's
|
|
20366
|
+
* altitude over the center-elevation plane, or the ray-plane solve degenerates.
|
|
20367
|
+
*/
|
|
20368
|
+
const TERRAIN_ANCHOR_MAX_CAMERA_ALTITUDE_FRACTION = .9;
|
|
20191
20369
|
var RenderFrameEvent = class extends Event {};
|
|
20192
20370
|
function hasChange(result) {
|
|
20193
20371
|
return result.panDelta?.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta || result.rollDelta;
|
|
@@ -20208,6 +20386,7 @@ var HandlerManager = class {
|
|
|
20208
20386
|
return this._el?.ownerDocument?.defaultView || window;
|
|
20209
20387
|
}
|
|
20210
20388
|
constructor(map, camera, options) {
|
|
20389
|
+
this._terrainGestureAnchorElevation = null;
|
|
20211
20390
|
this.handleWindowEvent = (e) => {
|
|
20212
20391
|
this.handleEvent(e, `${e.type}Window`);
|
|
20213
20392
|
};
|
|
@@ -20505,20 +20684,20 @@ var HandlerManager = class {
|
|
|
20505
20684
|
return;
|
|
20506
20685
|
}
|
|
20507
20686
|
this._camera.stop(true);
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
if (terrain && !tr.isPointOnMapSurface(around)) around = tr.centerPoint;
|
|
20687
|
+
const { panDelta, zoomDelta, bearingDelta, pitchDelta, rollDelta } = combinedResult;
|
|
20688
|
+
let { around, aroundOnSurface } = this._resolveAround(combinedResult, terrain, tr);
|
|
20689
|
+
const aroundElevation = terrain ? this._terrainGestureElevation(terrain, around, aroundOnSurface, tr, combinedEventsInProgress) : void 0;
|
|
20512
20690
|
const deltasForHelper = {
|
|
20513
20691
|
panDelta,
|
|
20514
20692
|
zoomDelta,
|
|
20515
20693
|
rollDelta,
|
|
20516
20694
|
pitchDelta,
|
|
20517
20695
|
bearingDelta,
|
|
20518
|
-
around
|
|
20696
|
+
around,
|
|
20697
|
+
aroundElevation
|
|
20519
20698
|
};
|
|
20520
20699
|
if (this._camera.cameraHelper.useGlobeControls && !tr.isPointOnMapSurface(around)) around = tr.centerPoint;
|
|
20521
|
-
const preZoomAroundLoc =
|
|
20700
|
+
const preZoomAroundLoc = this._computePreZoomAroundLoc(tr, around, panDelta, aroundElevation);
|
|
20522
20701
|
this._handleMapControls({
|
|
20523
20702
|
terrain,
|
|
20524
20703
|
tr,
|
|
@@ -20532,6 +20711,54 @@ var HandlerManager = class {
|
|
|
20532
20711
|
if (!combinedResult.noInertia) this._inertia.record(combinedResult);
|
|
20533
20712
|
this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);
|
|
20534
20713
|
}
|
|
20714
|
+
/**
|
|
20715
|
+
* The gesture's anchor point: the pinch midpoint when pinching, otherwise the
|
|
20716
|
+
* pan's anchor, clamped to the center point when it does not lie on the map.
|
|
20717
|
+
*/
|
|
20718
|
+
_resolveAround(combinedResult, terrain, tr) {
|
|
20719
|
+
let around = combinedResult.pinchAround !== void 0 ? combinedResult.pinchAround : combinedResult.around;
|
|
20720
|
+
around ||= this._camera.transform.centerPoint;
|
|
20721
|
+
if (terrain && !tr.isPointOnMapSurface(around)) return {
|
|
20722
|
+
around: tr.centerPoint,
|
|
20723
|
+
aroundOnSurface: false
|
|
20724
|
+
};
|
|
20725
|
+
return {
|
|
20726
|
+
around,
|
|
20727
|
+
aroundOnSurface: true
|
|
20728
|
+
};
|
|
20729
|
+
}
|
|
20730
|
+
/**
|
|
20731
|
+
* The elevation of the plane a terrain gesture is solved on: the elevation of the
|
|
20732
|
+
* terrain point grabbed at gesture start, captured here on the gesture's first
|
|
20733
|
+
* frame. Undefined means the gesture is solved at the center's elevation instead —
|
|
20734
|
+
* when the grabbed terrain is not loaded, the anchor is the center point (a
|
|
20735
|
+
* center-point anchor is skipped by the camera helper and would lose the pan), or
|
|
20736
|
+
* the anchor plane is too close to the camera for a stable ray-plane solve.
|
|
20737
|
+
*/
|
|
20738
|
+
_terrainGestureElevation(terrain, around, aroundOnSurface, tr, combinedEventsInProgress) {
|
|
20739
|
+
if (!aroundOnSurface) return;
|
|
20740
|
+
if (!this._terrainMovement && (combinedEventsInProgress.drag || combinedEventsInProgress.zoom)) {
|
|
20741
|
+
const anchor = terrain.pointCoordinate(around);
|
|
20742
|
+
this._terrainGestureAnchorElevation = anchor ? anchor.z : null;
|
|
20743
|
+
}
|
|
20744
|
+
if (this._terrainGestureAnchorElevation === null) return;
|
|
20745
|
+
const elevation = this._terrainGestureAnchorElevation;
|
|
20746
|
+
if (around.distSqr(tr.centerPoint) < .01) return;
|
|
20747
|
+
if (elevation - tr.elevation >= TERRAIN_ANCHOR_MAX_CAMERA_ALTITUDE_FRACTION * (tr.getCameraAltitude() - tr.elevation)) return;
|
|
20748
|
+
return elevation;
|
|
20749
|
+
}
|
|
20750
|
+
/**
|
|
20751
|
+
* The location that was under `around` before this frame's deltas — the point the
|
|
20752
|
+
* camera helper re-anchors after zooming — solved at `aroundElevation` when a
|
|
20753
|
+
* terrain gesture provides one. When rotating about the center point, the
|
|
20754
|
+
* transform's center is used directly to avoid numerical issues near the horizon.
|
|
20755
|
+
*/
|
|
20756
|
+
_computePreZoomAroundLoc(tr, around, panDelta, aroundElevation) {
|
|
20757
|
+
if (around.distSqr(tr.centerPoint) < .01) return tr.center;
|
|
20758
|
+
const aroundPreviousPoint = panDelta ? around.sub(panDelta) : around;
|
|
20759
|
+
if (aroundElevation !== void 0) return tr.screenPointToLocationAtElevation(aroundPreviousPoint, aroundElevation);
|
|
20760
|
+
return tr.screenPointToLocation(aroundPreviousPoint);
|
|
20761
|
+
}
|
|
20535
20762
|
_handleMapControls({ terrain, tr, deltasForHelper, preZoomAroundLoc, combinedEventsInProgress, panDelta }) {
|
|
20536
20763
|
const cameraHelper = this._camera.cameraHelper;
|
|
20537
20764
|
cameraHelper.handleMapControlsRollPitchBearingZoom(deltasForHelper, tr);
|
|
@@ -20553,7 +20780,7 @@ var HandlerManager = class {
|
|
|
20553
20780
|
cameraHelper.handleMapControlsPan(deltasForHelper, tr, preZoomAroundLoc);
|
|
20554
20781
|
return;
|
|
20555
20782
|
}
|
|
20556
|
-
if (combinedEventsInProgress.drag && this._terrainMovement && panDelta) {
|
|
20783
|
+
if (deltasForHelper.aroundElevation === void 0 && combinedEventsInProgress.drag && this._terrainMovement && panDelta) {
|
|
20557
20784
|
tr.setCenter(tr.screenPointToLocation(tr.centerPoint.sub(panDelta)));
|
|
20558
20785
|
return;
|
|
20559
20786
|
}
|
|
@@ -20591,6 +20818,7 @@ var HandlerManager = class {
|
|
|
20591
20818
|
if (finishedMoving && this._terrainMovement) {
|
|
20592
20819
|
this._camera.elevationFreeze = false;
|
|
20593
20820
|
this._terrainMovement = false;
|
|
20821
|
+
this._terrainGestureAnchorElevation = null;
|
|
20594
20822
|
const tr = this._camera.getTransformForUpdate();
|
|
20595
20823
|
if (this._map.getCenterClampedToGround()) tr.recalculateZoomAndCenter(this._map.terrain);
|
|
20596
20824
|
this._camera.applyUpdatedTransform(tr);
|
|
@@ -21266,12 +21494,14 @@ var AttributionControl = class {
|
|
|
21266
21494
|
*/
|
|
21267
21495
|
constructor(options = defaultAttributionControlOptions) {
|
|
21268
21496
|
this._toggleAttribution = () => {
|
|
21269
|
-
if (this._container.classList.contains("maplibregl-compact"))
|
|
21270
|
-
this._container.
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21497
|
+
if (this._container.classList.contains("maplibregl-compact")) {
|
|
21498
|
+
if (this._container.classList.contains("maplibregl-compact-show")) {
|
|
21499
|
+
this._container.setAttribute("open", "");
|
|
21500
|
+
this._container.classList.remove("maplibregl-compact-show");
|
|
21501
|
+
} else {
|
|
21502
|
+
this._container.classList.add("maplibregl-compact-show");
|
|
21503
|
+
this._container.removeAttribute("open");
|
|
21504
|
+
}
|
|
21275
21505
|
}
|
|
21276
21506
|
};
|
|
21277
21507
|
this._updateData = (e) => {
|
|
@@ -21775,7 +22005,8 @@ var Terrain = class {
|
|
|
21775
22005
|
this._terrainSkirtLength = terrainSkirtLength;
|
|
21776
22006
|
this.qualityFactor = 2;
|
|
21777
22007
|
this.meshSize = 128;
|
|
21778
|
-
this._demMatrixCache =
|
|
22008
|
+
this._demMatrixCache = /* @__PURE__ */ new Map();
|
|
22009
|
+
this._elevationSamplerCache = /* @__PURE__ */ new Map();
|
|
21779
22010
|
this.coordsIndex = [];
|
|
21780
22011
|
this._coordsTextureSize = 1024;
|
|
21781
22012
|
}
|
|
@@ -21821,12 +22052,8 @@ var Terrain = class {
|
|
|
21821
22052
|
getDEMElevation(tileID, x, y, extent = EXTENT) {
|
|
21822
22053
|
const normalized = tileID.normalizeCoordinates(x, y, extent);
|
|
21823
22054
|
if (!normalized) return 0;
|
|
21824
|
-
const
|
|
21825
|
-
|
|
21826
|
-
if (!dem) return 0;
|
|
21827
|
-
const pos = transformMat4$2([], [normalized.x / extent * EXTENT, normalized.y / extent * EXTENT], terrain.u_terrain_matrix);
|
|
21828
|
-
const coord = [pos[0] * dem.dim, pos[1] * dem.dim];
|
|
21829
|
-
return dem.sampleBilinear(coord[0], coord[1]);
|
|
22055
|
+
const sampler = this._getElevationSampler(normalized.tileID);
|
|
22056
|
+
return sampler ? sampler(normalized.x, normalized.y, extent) : 0;
|
|
21830
22057
|
}
|
|
21831
22058
|
/**
|
|
21832
22059
|
* Get the elevation for given {@link LngLat} in respect of exaggeration.
|
|
@@ -21868,6 +22095,57 @@ var Terrain = class {
|
|
|
21868
22095
|
return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;
|
|
21869
22096
|
}
|
|
21870
22097
|
/**
|
|
22098
|
+
* Clear CPU elevation samplers that may retain a previously selected DEM tile.
|
|
22099
|
+
* @internal
|
|
22100
|
+
*/
|
|
22101
|
+
resetElevationCache() {
|
|
22102
|
+
this._elevationSamplerCache.clear();
|
|
22103
|
+
}
|
|
22104
|
+
_getElevationSampler(tileID) {
|
|
22105
|
+
const key = tileID.key;
|
|
22106
|
+
const cachedSampler = this._elevationSamplerCache.get(key);
|
|
22107
|
+
if (cachedSampler) return cachedSampler;
|
|
22108
|
+
const sourceTile = this.tileManager.getSourceTile(tileID, true);
|
|
22109
|
+
const dem = sourceTile?.dem;
|
|
22110
|
+
if (!sourceTile || !dem) return null;
|
|
22111
|
+
const matrix = this._getDEMTileMatrix(tileID, sourceTile);
|
|
22112
|
+
const demPixelScaleX = matrix[0] * dem.dim;
|
|
22113
|
+
const demPixelScaleY = matrix[5] * dem.dim;
|
|
22114
|
+
const demPixelOffsetX = matrix[12] * dem.dim;
|
|
22115
|
+
const demPixelOffsetY = matrix[13] * dem.dim;
|
|
22116
|
+
const sampler = (x, y, extent) => {
|
|
22117
|
+
const extentScale = extent === 8192 ? 1 : EXTENT / extent;
|
|
22118
|
+
return dem.sampleBilinear(x * extentScale * demPixelScaleX + demPixelOffsetX, y * extentScale * demPixelScaleY + demPixelOffsetY);
|
|
22119
|
+
};
|
|
22120
|
+
this._elevationSamplerCache.set(key, sampler);
|
|
22121
|
+
return sampler;
|
|
22122
|
+
}
|
|
22123
|
+
_getDEMTileMatrix(tileID, sourceTile) {
|
|
22124
|
+
const matrixKey = `${sourceTile.tileID.key}/${tileID.key}`;
|
|
22125
|
+
const cachedMatrix = this._demMatrixCache.get(matrixKey);
|
|
22126
|
+
if (cachedMatrix) return cachedMatrix;
|
|
22127
|
+
const maxzoom = this.tileManager.getSource().maxzoom;
|
|
22128
|
+
let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;
|
|
22129
|
+
if (tileID.overscaledZ > tileID.canonical.z) {
|
|
22130
|
+
if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;
|
|
22131
|
+
else warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom");
|
|
22132
|
+
}
|
|
22133
|
+
const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);
|
|
22134
|
+
const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);
|
|
22135
|
+
const demMatrix = fromScaling(/* @__PURE__ */ new Float64Array(16), [
|
|
22136
|
+
1 / (EXTENT << dz),
|
|
22137
|
+
1 / (EXTENT << dz),
|
|
22138
|
+
0
|
|
22139
|
+
]);
|
|
22140
|
+
translate(demMatrix, demMatrix, [
|
|
22141
|
+
dx * EXTENT,
|
|
22142
|
+
dy * EXTENT,
|
|
22143
|
+
0
|
|
22144
|
+
]);
|
|
22145
|
+
this._demMatrixCache.set(matrixKey, demMatrix);
|
|
22146
|
+
return demMatrix;
|
|
22147
|
+
}
|
|
22148
|
+
/**
|
|
21871
22149
|
* returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object
|
|
21872
22150
|
* @param tileID - the tile to get the terrain for
|
|
21873
22151
|
* @returns the terrain data to use in the program
|
|
@@ -21902,34 +22180,12 @@ var Terrain = class {
|
|
|
21902
22180
|
sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
21903
22181
|
sourceTile.needsTerrainPrepare = false;
|
|
21904
22182
|
}
|
|
21905
|
-
const
|
|
21906
|
-
if (matrixKey && !this._demMatrixCache[matrixKey]) {
|
|
21907
|
-
const maxzoom = this.tileManager.getSource().maxzoom;
|
|
21908
|
-
let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;
|
|
21909
|
-
if (tileID.overscaledZ > tileID.canonical.z) if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;
|
|
21910
|
-
else warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom");
|
|
21911
|
-
const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);
|
|
21912
|
-
const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);
|
|
21913
|
-
const demMatrix = fromScaling(/* @__PURE__ */ new Float64Array(16), [
|
|
21914
|
-
1 / (EXTENT << dz),
|
|
21915
|
-
1 / (EXTENT << dz),
|
|
21916
|
-
0
|
|
21917
|
-
]);
|
|
21918
|
-
translate(demMatrix, demMatrix, [
|
|
21919
|
-
dx * EXTENT,
|
|
21920
|
-
dy * EXTENT,
|
|
21921
|
-
0
|
|
21922
|
-
]);
|
|
21923
|
-
this._demMatrixCache[matrixKey] = {
|
|
21924
|
-
matrix: demMatrix,
|
|
21925
|
-
coord: tileID
|
|
21926
|
-
};
|
|
21927
|
-
}
|
|
22183
|
+
const terrainMatrix = sourceTile ? this._getDEMTileMatrix(tileID, sourceTile) : this._emptyDemMatrix;
|
|
21928
22184
|
return {
|
|
21929
22185
|
"u_depth": 2,
|
|
21930
22186
|
"u_terrain": 3,
|
|
21931
22187
|
"u_terrain_dim": sourceTile?.dem?.dim || 1,
|
|
21932
|
-
"u_terrain_matrix":
|
|
22188
|
+
"u_terrain_matrix": terrainMatrix,
|
|
21933
22189
|
"u_terrain_unpack": sourceTile?.dem?.getUnpackVector() || this._emptyDemUnpack,
|
|
21934
22190
|
"u_terrain_exaggeration": this.exaggeration,
|
|
21935
22191
|
texture: (sourceTile?.demTexture || this._emptyDemTexture).texture,
|
|
@@ -21997,10 +22253,11 @@ var Terrain = class {
|
|
|
21997
22253
|
data[i + 2] = x >> 8 << 4 | y >> 8;
|
|
21998
22254
|
data[i + 3] = 0;
|
|
21999
22255
|
}
|
|
22000
|
-
const
|
|
22256
|
+
const image = new RGBAImage({
|
|
22001
22257
|
width: this._coordsTextureSize,
|
|
22002
22258
|
height: this._coordsTextureSize
|
|
22003
|
-
}, new Uint8Array(data.buffer))
|
|
22259
|
+
}, new Uint8Array(data.buffer));
|
|
22260
|
+
const texture = new Texture(context, image, context.gl.RGBA, { premultiply: false });
|
|
22004
22261
|
texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
22005
22262
|
this._coordsTexture = texture;
|
|
22006
22263
|
return texture;
|
|
@@ -22041,7 +22298,7 @@ var Terrain = class {
|
|
|
22041
22298
|
context.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer);
|
|
22042
22299
|
gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);
|
|
22043
22300
|
context.bindFramebuffer.set(null);
|
|
22044
|
-
return (rgba[0] /
|
|
22301
|
+
return (rgba[0] / 16777216 + rgba[1] / 65536 + rgba[2] / 256 + rgba[3]) / 256;
|
|
22045
22302
|
}
|
|
22046
22303
|
/**
|
|
22047
22304
|
* create a regular mesh which will be used by all terrain-tiles
|
|
@@ -22108,8 +22365,9 @@ var Terrain = class {
|
|
|
22108
22365
|
const worldSize = (1 << zoom) * EXTENT;
|
|
22109
22366
|
const mercatorX = mercatorCoordinate.x * worldSize;
|
|
22110
22367
|
const mercatorY = mercatorCoordinate.y * worldSize;
|
|
22368
|
+
const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);
|
|
22111
22369
|
return {
|
|
22112
|
-
tileID: new OverscaledTileID(zoom, 0, zoom,
|
|
22370
|
+
tileID: new OverscaledTileID(zoom, 0, zoom, tileX, tileY),
|
|
22113
22371
|
mercatorX,
|
|
22114
22372
|
mercatorY
|
|
22115
22373
|
};
|
|
@@ -22444,7 +22702,13 @@ var Map$1 = class extends Evented {
|
|
|
22444
22702
|
};
|
|
22445
22703
|
this._contextRestored = (event) => {
|
|
22446
22704
|
if (this._lostContextStyle.style) this.setStyle(this._lostContextStyle.style, { diff: false });
|
|
22447
|
-
if (this._lostContextStyle.images && this.style)
|
|
22705
|
+
if (this._lostContextStyle.images && this.style) {
|
|
22706
|
+
this.style.imageManager.images = this._lostContextStyle.images;
|
|
22707
|
+
for (const id in this._lostContextStyle.images) {
|
|
22708
|
+
const image = this._lostContextStyle.images[id];
|
|
22709
|
+
if (image.isWebGLImage) this.style.imageManager.updateImage(id, image, false);
|
|
22710
|
+
}
|
|
22711
|
+
}
|
|
22448
22712
|
this._lostContextStyle = {
|
|
22449
22713
|
style: null,
|
|
22450
22714
|
images: null
|
|
@@ -22626,8 +22890,10 @@ var Map$1 = class extends Evented {
|
|
|
22626
22890
|
* @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/display-map-navigation-controls/)
|
|
22627
22891
|
*/
|
|
22628
22892
|
addControl(control, position) {
|
|
22629
|
-
if (position === void 0)
|
|
22630
|
-
|
|
22893
|
+
if (position === void 0) {
|
|
22894
|
+
if (control.getDefaultPosition) position = control.getDefaultPosition();
|
|
22895
|
+
else position = "top-right";
|
|
22896
|
+
}
|
|
22631
22897
|
if (!control?.onAdd) return this.fire(new ErrorEvent(/* @__PURE__ */ new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));
|
|
22632
22898
|
const controlElement = control.onAdd(this);
|
|
22633
22899
|
this._controls.push(control);
|
|
@@ -24297,22 +24563,30 @@ var Map$1 = class extends Evented {
|
|
|
24297
24563
|
this._camera.terrain = this.terrain;
|
|
24298
24564
|
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24299
24565
|
this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24300
|
-
this._terrainDataCallback = (e) =>
|
|
24301
|
-
if (e.dataType === "style") this.terrain.tileManager.releaseAllRTT();
|
|
24302
|
-
else if (e.dataType === "source" && e.tile) {
|
|
24303
|
-
if (e.sourceId === options.source && !this._camera.elevationFreeze) {
|
|
24304
|
-
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24305
|
-
if (this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24306
|
-
}
|
|
24307
|
-
if (e.source?.type === "image") this.terrain.tileManager.releaseAllRTT();
|
|
24308
|
-
else this.terrain.tileManager.releaseRTT(e.tile.tileID);
|
|
24309
|
-
}
|
|
24310
|
-
};
|
|
24566
|
+
this._terrainDataCallback = (e) => this._handleTerrainDataEvent(e, options.source);
|
|
24311
24567
|
this.style.on("data", this._terrainDataCallback);
|
|
24312
24568
|
}
|
|
24313
24569
|
this.fire(new MapTerrainEvent({ terrain: options }));
|
|
24314
24570
|
return this;
|
|
24315
24571
|
}
|
|
24572
|
+
_handleTerrainDataEvent(event, terrainSourceId) {
|
|
24573
|
+
if (event.dataType === "style") {
|
|
24574
|
+
this.terrain.tileManager.releaseAllRTT();
|
|
24575
|
+
return;
|
|
24576
|
+
}
|
|
24577
|
+
const isTerrainSourceEvent = event.sourceId === terrainSourceId;
|
|
24578
|
+
if (isTerrainSourceEvent) this.terrain.resetElevationCache();
|
|
24579
|
+
if (isTerrainSourceEvent && event.tile && !this._camera.elevationFreeze) {
|
|
24580
|
+
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24581
|
+
if (this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24582
|
+
}
|
|
24583
|
+
if (!event.tile) return;
|
|
24584
|
+
if (event.source?.type === "image") {
|
|
24585
|
+
this.terrain.tileManager.releaseAllRTT();
|
|
24586
|
+
return;
|
|
24587
|
+
}
|
|
24588
|
+
this.terrain.tileManager.releaseRTT(event.tile.tileID);
|
|
24589
|
+
}
|
|
24316
24590
|
/**
|
|
24317
24591
|
* Get the terrain-options if terrain is loaded
|
|
24318
24592
|
* @returns the TerrainSpecification passed to setTerrain
|
|
@@ -24513,8 +24787,12 @@ var Map$1 = class extends Evented {
|
|
|
24513
24787
|
} else {
|
|
24514
24788
|
const { width, height, data } = image;
|
|
24515
24789
|
const userImage = image;
|
|
24790
|
+
const isWebGLImage = isStyleImageWebGLData(userImage.data);
|
|
24516
24791
|
return {
|
|
24517
|
-
data: new RGBAImage({
|
|
24792
|
+
data: isWebGLImage ? new RGBAImage({
|
|
24793
|
+
width,
|
|
24794
|
+
height
|
|
24795
|
+
}) : new RGBAImage({
|
|
24518
24796
|
width,
|
|
24519
24797
|
height
|
|
24520
24798
|
}, new Uint8Array(data)),
|
|
@@ -24526,6 +24804,7 @@ var Map$1 = class extends Evented {
|
|
|
24526
24804
|
textFitHeight,
|
|
24527
24805
|
sdf,
|
|
24528
24806
|
version,
|
|
24807
|
+
isWebGLImage,
|
|
24529
24808
|
userImage
|
|
24530
24809
|
};
|
|
24531
24810
|
}
|
|
@@ -24556,8 +24835,12 @@ var Map$1 = class extends Evented {
|
|
|
24556
24835
|
const { width, height, data } = image instanceof HTMLImageElement || isImageBitmap(image) ? browser.getImageData(image) : image;
|
|
24557
24836
|
if (width === void 0 || height === void 0) return this.fire(new ErrorEvent(/* @__PURE__ */ new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));
|
|
24558
24837
|
if (width !== existingImage.data.width || height !== existingImage.data.height) return this.fire(new ErrorEvent(/* @__PURE__ */ new Error("The width and height of the updated image must be that same as the previous version of the image")));
|
|
24559
|
-
|
|
24560
|
-
existingImage.
|
|
24838
|
+
existingImage.isWebGLImage = isStyleImageWebGLData(data);
|
|
24839
|
+
if (existingImage.isWebGLImage) existingImage.userImage = image;
|
|
24840
|
+
else {
|
|
24841
|
+
const copy = !(image instanceof HTMLImageElement || isImageBitmap(image));
|
|
24842
|
+
existingImage.data.replace(data, copy);
|
|
24843
|
+
}
|
|
24561
24844
|
this.style.updateImage(id, existingImage);
|
|
24562
24845
|
return this;
|
|
24563
24846
|
}
|
|
@@ -25406,6 +25689,7 @@ var Map$1 = class extends Evented {
|
|
|
25406
25689
|
}
|
|
25407
25690
|
if (this.terrain) {
|
|
25408
25691
|
this.terrain.tileManager.update(this._camera.transform, this.terrain);
|
|
25692
|
+
this.terrain.resetElevationCache();
|
|
25409
25693
|
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
25410
25694
|
if (!this._camera.elevationFreeze && this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
25411
25695
|
} else {
|
|
@@ -26304,7 +26588,6 @@ var Marker = class extends Evented {
|
|
|
26304
26588
|
}
|
|
26305
26589
|
if (popup) {
|
|
26306
26590
|
if (!("offset" in popup.options)) {
|
|
26307
|
-
const markerHeight = 41 - 5.8 / 2;
|
|
26308
26591
|
const markerRadius = 13.5;
|
|
26309
26592
|
const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
|
|
26310
26593
|
popup.options.offset = this._defaultMarker ? {
|
|
@@ -26312,10 +26595,10 @@ var Marker = class extends Evented {
|
|
|
26312
26595
|
"top-left": [0, 0],
|
|
26313
26596
|
"top-right": [0, 0],
|
|
26314
26597
|
"bottom": [0, -38.1],
|
|
26315
|
-
"bottom-left": [linearOffset, (
|
|
26316
|
-
"bottom-right": [-linearOffset, (
|
|
26317
|
-
"left": [markerRadius,
|
|
26318
|
-
"right": [-13.5,
|
|
26598
|
+
"bottom-left": [linearOffset, (24.6 + linearOffset) * -1],
|
|
26599
|
+
"bottom-right": [-linearOffset, (24.6 + linearOffset) * -1],
|
|
26600
|
+
"left": [markerRadius, -24.6],
|
|
26601
|
+
"right": [-13.5, -24.6]
|
|
26319
26602
|
} : this._offset;
|
|
26320
26603
|
}
|
|
26321
26604
|
this._popup = popup;
|
|
@@ -26483,12 +26766,14 @@ var Marker = class extends Evented {
|
|
|
26483
26766
|
setDraggable(shouldBeDraggable) {
|
|
26484
26767
|
this._draggable = !!shouldBeDraggable;
|
|
26485
26768
|
this._element.classList.toggle("maplibregl-marker-draggable", this._draggable);
|
|
26486
|
-
if (this._map)
|
|
26487
|
-
|
|
26488
|
-
|
|
26489
|
-
|
|
26490
|
-
|
|
26491
|
-
|
|
26769
|
+
if (this._map) {
|
|
26770
|
+
if (shouldBeDraggable) {
|
|
26771
|
+
this._map.on("mousedown", this._addDragHandler);
|
|
26772
|
+
this._map.on("touchstart", this._addDragHandler);
|
|
26773
|
+
} else {
|
|
26774
|
+
this._map.off("mousedown", this._addDragHandler);
|
|
26775
|
+
this._map.off("touchstart", this._addDragHandler);
|
|
26776
|
+
}
|
|
26492
26777
|
}
|
|
26493
26778
|
this._updateAccessibilityRole();
|
|
26494
26779
|
return this;
|
|
@@ -26841,7 +27126,8 @@ var GeolocateControl = class extends Evented {
|
|
|
26841
27126
|
this._updateCamera = (position) => {
|
|
26842
27127
|
const center = new LngLat(position.coords.longitude, position.coords.latitude);
|
|
26843
27128
|
const radius = position.coords.accuracy;
|
|
26844
|
-
const
|
|
27129
|
+
const bearing = this._map.getBearing();
|
|
27130
|
+
const options = extend({ bearing }, this.options.fitBoundsOptions);
|
|
26845
27131
|
const newBounds = LngLatBounds.fromLngLat(center, radius);
|
|
26846
27132
|
this._map.fitBounds(newBounds, options, { geolocateSource: true });
|
|
26847
27133
|
};
|
|
@@ -27249,8 +27535,10 @@ var FullscreenControl = class extends Evented {
|
|
|
27249
27535
|
};
|
|
27250
27536
|
this._fullscreen = false;
|
|
27251
27537
|
this._pseudo = options.pseudo ?? false;
|
|
27252
|
-
if (options?.container)
|
|
27253
|
-
|
|
27538
|
+
if (options?.container) {
|
|
27539
|
+
if (options.container instanceof HTMLElement) this._container = options.container;
|
|
27540
|
+
else warnOnce("Full screen control 'container' must be a DOM element.");
|
|
27541
|
+
}
|
|
27254
27542
|
if ("onfullscreenchange" in document) this._fullscreenchange = "fullscreenchange";
|
|
27255
27543
|
else if ("onmozfullscreenchange" in document) this._fullscreenchange = "mozfullscreenchange";
|
|
27256
27544
|
else if ("onwebkitfullscreenchange" in document) this._fullscreenchange = "webkitfullscreenchange";
|