maplibre-gl 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/maplibre-gl-dev.mjs +257 -386
  2. package/dist/maplibre-gl-dev.mjs.map +1 -1
  3. package/dist/maplibre-gl-shared-dev.mjs +135 -45
  4. package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
  5. package/dist/maplibre-gl-shared.mjs +2 -2
  6. package/dist/maplibre-gl-shared.mjs.map +1 -1
  7. package/dist/maplibre-gl-worker-dev.mjs +2 -2
  8. package/dist/maplibre-gl-worker.mjs +2 -2
  9. package/dist/maplibre-gl-worker.mjs.map +1 -1
  10. package/dist/maplibre-gl.css +1 -1
  11. package/dist/maplibre-gl.d.ts +95 -36
  12. package/dist/maplibre-gl.mjs +15 -15
  13. package/dist/maplibre-gl.mjs.map +1 -1
  14. package/package.json +14 -13
  15. package/src/css/maplibre-gl.css +4 -0
  16. package/src/data/bucket/circle_bucket.ts +3 -2
  17. package/src/data/bucket/fill_bucket.ts +3 -2
  18. package/src/data/bucket/fill_extrusion_bucket.ts +3 -2
  19. package/src/data/bucket/line_bucket.test.ts +5 -5
  20. package/src/data/bucket/line_bucket.ts +3 -2
  21. package/src/data/bucket/symbol_bucket.test.ts +6 -6
  22. package/src/geo/projection/covering_tiles.bench.ts +39 -0
  23. package/src/geo/projection/covering_tiles.test.ts +3 -7
  24. package/src/geo/projection/covering_tiles.ts +37 -2
  25. package/src/geo/projection/globe_covering_tiles_details_provider.ts +4 -4
  26. package/src/geo/projection/globe_projection.test.ts +2 -2
  27. package/src/geo/projection/globe_projection.ts +6 -15
  28. package/src/geo/projection/globe_transform.test.ts +3 -6
  29. package/src/geo/projection/globe_transform.ts +4 -7
  30. package/src/geo/projection/mercator_covering_tiles_details_provider.ts +4 -4
  31. package/src/geo/projection/mercator_projection.ts +1 -13
  32. package/src/geo/projection/mercator_transform.ts +2 -1
  33. package/src/geo/projection/projection.ts +0 -27
  34. package/src/geo/projection/projection_data.ts +8 -0
  35. package/src/geo/projection/projection_factory.ts +3 -3
  36. package/src/geo/projection/vertical_perspective_projection.ts +3 -60
  37. package/src/geo/projection/vertical_perspective_transform.ts +16 -23
  38. package/src/geo/transform_interface.ts +1 -2
  39. package/src/index.ts +4 -2
  40. package/src/render/glyph_manager.test.ts +1 -0
  41. package/src/render/painter.ts +1 -6
  42. package/src/render/subdivision.bench.ts +39 -0
  43. package/src/render/subdivision.test.ts +0 -1
  44. package/src/render/subdivision.ts +46 -0
  45. package/src/shaders/glsl/_projection_globe.fragment.glsl +12 -0
  46. package/src/shaders/glsl/_projection_globe.fragment.glsl.g.ts +2 -0
  47. package/src/shaders/glsl/_projection_globe.vertex.glsl +29 -10
  48. package/src/shaders/glsl/_projection_globe.vertex.glsl.g.ts +1 -1
  49. package/src/shaders/glsl/_projection_mercator.fragment.glsl +4 -0
  50. package/src/shaders/glsl/_projection_mercator.fragment.glsl.g.ts +2 -0
  51. package/src/shaders/glsl/line.fragment.glsl +2 -0
  52. package/src/shaders/glsl/line.fragment.glsl.g.ts +1 -1
  53. package/src/shaders/glsl/line_gradient.fragment.glsl +2 -0
  54. package/src/shaders/glsl/line_gradient.fragment.glsl.g.ts +1 -1
  55. package/src/shaders/glsl/line_gradient_sdf.fragment.glsl +2 -0
  56. package/src/shaders/glsl/line_gradient_sdf.fragment.glsl.g.ts +1 -1
  57. package/src/shaders/glsl/line_pattern.fragment.glsl +2 -0
  58. package/src/shaders/glsl/line_pattern.fragment.glsl.g.ts +1 -1
  59. package/src/shaders/glsl/line_sdf.fragment.glsl +2 -0
  60. package/src/shaders/glsl/line_sdf.fragment.glsl.g.ts +1 -1
  61. package/src/shaders/shaders.ts +4 -6
  62. package/src/source/geojson_source.test.ts +27 -0
  63. package/src/source/geojson_source.ts +41 -0
  64. package/src/source/image_source.test.ts +140 -62
  65. package/src/source/image_source.ts +49 -12
  66. package/src/source/raster_tile_source.test.ts +49 -0
  67. package/src/source/raster_tile_source.ts +2 -1
  68. package/src/source/video_source.test.ts +1 -1
  69. package/src/source/worker_tile.test.ts +6 -6
  70. package/src/style/light.test.ts +9 -9
  71. package/src/style/light.ts +3 -3
  72. package/src/style/properties.test.ts +94 -2
  73. package/src/style/properties.ts +30 -1
  74. package/src/style/sky.test.ts +9 -9
  75. package/src/style/sky.ts +2 -2
  76. package/src/style/style.test.ts +2 -2
  77. package/src/style/style.ts +3 -3
  78. package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +14 -1
  79. package/src/style/style_layer.test.ts +2 -1
  80. package/src/style/validate_style.test.ts +1 -1
  81. package/src/tile/tile_manager.test.ts +28 -0
  82. package/src/tile/tile_manager.ts +2 -2
  83. package/src/ui/camera.test.ts +1 -1
  84. package/src/ui/control/geolocate_control.test.ts +1 -1
  85. package/src/ui/handler/mouse.ts +15 -7
  86. package/src/ui/handler/mouse_handler_interface.test.ts +21 -1
  87. package/src/ui/map.ts +17 -2
  88. package/src/ui/map_tests/map_events.test.ts +0 -2
  89. package/src/ui/map_tests/map_images.test.ts +1 -0
  90. package/src/ui/map_tests/map_terrain.test.ts +21 -1
  91. package/src/ui/marker.test.ts +64 -1
  92. package/src/ui/marker.ts +30 -6
  93. package/src/util/primitives/bounding_volume_cache.ts +3 -1
  94. package/src/webgl/draw/draw_fill.test.ts +1 -0
  95. package/src/webgl/draw/draw_symbol.test.ts +1 -0
  96. package/src/webgl/program/program_uniforms.ts +0 -3
  97. package/src/webgl/program/projection_program.ts +12 -10
  98. package/src/webgl/program/terrain_program.test.ts +2 -2
  99. package/src/webgl/program.ts +4 -4
  100. package/src/geo/projection/globe_projection_error_measurement.ts +0 -229
  101. package/src/shaders/glsl/projection_error_measurement.fragment.glsl +0 -5
  102. package/src/shaders/glsl/projection_error_measurement.fragment.glsl.g.ts +0 -2
  103. package/src/shaders/glsl/projection_error_measurement.vertex.glsl +0 -22
  104. package/src/shaders/glsl/projection_error_measurement.vertex.glsl.g.ts +0 -2
  105. package/src/webgl/program/projection_error_measurement_program.ts +0 -23
@@ -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.0.0/LICENSE.txt
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.1.0/LICENSE.txt
4
4
  */
5
- import { $n as findLineIntersection, $r as normalize, $t as validateStyle, A as earthRadius, Ai as rotate, Ar as warnOnce, At as SegmentVector, B as evaluateSizeForFeature, Bn as createMat4f64, Br as zero, Bt as isRasterStyleLayer, C as altitudeFromMercatorZ, Ci as rotateZ, Cn as addProtocol, Cr as rollPitchBearingToQuat, Ct as Uniform2f, D as mercatorYfromLat, Di as fromRotation, Dn as AbortError, Dr as threePlaneIntersection, Dt as UniformColorArray, E as mercatorXfromLng, Ei as create$4, En as config, Er as subscribe, Et as UniformColor, F as isBackgroundStyleLayer, Fn as bezier, Fr as create$3, Ft as PosArray, G as ImagePosition, Gn as degreesToRadians, Gr as transformMat4, Gt as EvaluationParameters, Hn as createVec4f64, Hr as slerp, Ht as Properties, I as isSymbolStyleLayer, In as clamp, Ir as length, It as QuadTriangleArray, J as parseGlyphPbf, Jn as easeCubicInOut, Jr as cross, Jt as ZoomHistory, K as potpack, Kn as differenceOfAnglesDegrees, Kr as add, L as SymbolBucket, Ln as clone$2, Lr as scale$1, Lt as RasterBoundsArray, M as createStyleLayer, Mi as offscreenCanvasSupported, Mn as angleToRotateBetweenVectors2D, Mr as zoomScale, Mt as CollisionCircleLayoutArray, N as isCustomStyleLayer, Ni as Point, Nn as arrayBufferToImage, Nr as pixelsToTileUnits, Nt as LineStripIndexArray, O as mercatorZfromAltitude, Oi as create$2, On as isAbortError, Or as translatePosition, Ot as UniformFloatArray, P as validateCustomStyleLayer, Pn as arrayBufferToImageBitmap, Pr as EXTENT, Pt as Pos3dArray, Qn as filterObject, Qr as negate, Qt as validateAndEmit, R as addDynamicAttributes, Rn as createIdentityMat4f32, Rr as sqrLen, Rt as TriangleIndexArray, S as MercatorCoordinate, Si as rotateY$1, Sn as sameOrigin, Sr as rollPitchBearingEqual, St as Uniform1i, T as lngFromMercatorX, Ti as translate, Tn as removeProtocol, Tr as sphericalToCartesian, Tt as Uniform4f, U as getAnchorAlignment, Un as deepEqual, Ur as mul, Ut as TRANSITION_SUFFIX, V as evaluateSizeForZoom, Vn as createVec3f64, Vr as fromEuler, Vt as DataConstantProperty, Wn as defaultEasing, Wr as scale$3, Wt as Transitionable, X as collisionCircleLayout, Xn as evaluateZoomSnap, Xr as len, Xt as SPEC_SOURCE_TYPES, Yn as ensureError, Yr as dot, Z as isLineStyleLayer, Zn as extend, Zr as length$1, Zt as emitValidationErrors, _ as OverscaledTileID, _i as invert$1, _n as getArrayBuffer, _r as pointPlaneSignedDistance, _t as RGBAImage, a as clipLine, ai as sub, an as derefLayers, ar as isImageBitmap, at as NORTH_POLE_Y, b as compareTileId, bi as perspective, bn as getVideo, br as readImageUsingVideoFrame, bt as toEvaluationFeature, ci as transformQuat, cn as featureFilter, cr as isTouchableEvent, ct as SubdivisionGranularitySetting, di as copy, dn as latest, dr as lerp, dt as Texture, ei as rotateX$1, en as validateStyleAndEmit, er as getAABB, et as isFillExtrusionStyleLayer, f as GEOJSON_TILE_LAYER_NAME, fi as create$1, fn as ErrorEvent, fr as mapObject, ft as isHillshadeStyleLayer, g as CanonicalTileID, gi as identity, gn as GLOBAL_DISPATCHER_ID, gr as pick, gt as AlphaImage, h as Bounds, hi as fromScaling, hn as AJAXError, hr as parseCacheControl, ht as renderColorRamp, ii as scaleAndAdd, ir as getRollPitchBearing, j as Actor, ji as isOffscreenCanvasDistorted, jn as MAX_VALID_LATITUDE, jr as wrap, jt as CollisionBoxArray, k as LngLat, ki as invert, kn as throwIfAborted, kr as uniqueId, kt as UniformMatrix4f, li as zero$1, lr as isTouchableOrPointableType, lt as isColorReliefStyleLayer, mi as exactEquals, mn as Evented, mr as nextPowerOfTwo, mt as isHeatmapStyleLayer, ni as rotateZ$1, nn as ProjectionDefinition, nr as getEdgeTiles, oi as transformMat3, on as diff, or as isPointableEvent, ot as SOUTH_POLE_Y, pi as equals, pn as Event, pr as mod, pt as HEATMAP_FULL_RENDER_FBO_KEY, q as renderStyleImage, qn as distanceOfAnglesRadians, qr as clone, qt as codePointUsesLocalIdeographFontFamily, r as TextAnchorEnum, ri as scale$2, rn as ValidationError, rt as isFillStyleLayer, s as TileCache, si as transformMat4$1, sn as emptyStyle, sr as isSafari, st as SubdivisionGranularityExpression, t as getAnchorJustification, ti as rotateY, tn as Color, tr as getAngleDelta, u as GeoJSONFeature, ui as clone$1, un as interpolateFactory, ur as isWorker, v as UnwrappedTileID, vi as multiply, vn as getJSON, vr as radiansToDegrees, vt as isCircleStyleLayer, w as latFromMercatorY, wi as scale, wn as getProtocol, wr as scaleZoom, wt as Uniform3f, x as isInBoundsForZoomLngLat, xi as rotateX, xn as makeRequest, xr as remapSaturate, xt as Uniform1f, y as calculateTileKey, yi as ortho, yn as getReferrer, yr as rayPlaneIntersection, yt as polygonIntersectsPolygon, z as getOverlapMode, zn as createIdentityMat4f64, zr as transformMat4$2, zt as createLayout } from "./maplibre-gl-shared-dev.mjs";
5
+ import { $n as getAABB, $r as rotateX$1, $t as validateStyle, A as earthRadius, Ai as isOffscreenCanvasDistorted, Ar as wrap, At as SegmentVector, B as evaluateSizeForFeature, Bn as createMat4f64, Br as fromEuler, Bt as isRasterStyleLayer, C as altitudeFromMercatorZ, Ci as scale, Cn as addProtocol, Cr as scaleZoom, Ct as Uniform2f, D as mercatorYfromLat, Di as create$2, Dn as AbortError, Dr as translatePosition, Dt as UniformColorArray, E as mercatorXfromLng, Ei as fromRotation, En as config, Er as threePlaneIntersection, Et as UniformColor, F as isBackgroundStyleLayer, Fn as bezier, Fr as length, Ft as PosArray, G as ImagePosition, Gn as degreesToRadians, Gr as add, Gt as EvaluationParameters, Hn as createVec4f64, Hr as mul, Ht as Properties, I as isSymbolStyleLayer, In as clamp, Ir as scale$1, It as QuadTriangleArray, J as parseGlyphPbf, Jn as ensureError, Jr as dot, Jt as ZoomHistory, K as potpack, Kn as differenceOfAnglesDegrees, Kr as clone, L as SymbolBucket, Ln as clone$2, Lr as sqrLen, Lt as RasterBoundsArray, M as createStyleLayer, Mi as Point, Mn as angleToRotateBetweenVectors2D, Mr as pixelsToTileUnits, Mt as CollisionCircleLayoutArray, N as isCustomStyleLayer, Nn as arrayBufferToImage, Nr as EXTENT, Nt as LineStripIndexArray, O as mercatorZfromAltitude, Oi as invert, On as isAbortError, Or as uniqueId, Ot as UniformFloatArray, P as validateCustomStyleLayer, Pn as arrayBufferToImageBitmap, Pr as create$3, Pt as Pos3dArray, Qn as findLineIntersection, Qr as normalize, Qt as validateAndEmit, R as addDynamicAttributes, Rn as createIdentityMat4f32, Rr as transformMat4$2, Rt as TriangleIndexArray, S as MercatorCoordinate, Si as rotateZ, Sn as sameOrigin, Sr as rollPitchBearingToQuat, St as Uniform1i, T as lngFromMercatorX, Ti as create$4, Tn as removeProtocol, Tr as subscribe, Tt as Uniform4f, U as getAnchorAlignment, Un as deepEqual, Ur as scale$3, Ut as TRANSITION_SUFFIX, V as evaluateSizeForZoom, Vn as createVec3f64, Vr as slerp, Vt as DataConstantProperty, Wn as defaultEasing, Wr as transformMat4, Wt as Transitionable, X as collisionCircleLayout, Xn as extend, Xr as length$1, Xt as SPEC_SOURCE_TYPES, Yn as evaluateZoomSnap, Yr as len, Z as isLineStyleLayer, Zn as filterObject, Zr as negate, Zt as emitValidationErrors, _ as OverscaledTileID, _i as multiply, _n as getArrayBuffer, _r as radiansToDegrees, _t as RGBAImage, a as clipLine, ai as transformMat3, an as derefLayers, ar as isPointableEvent, at as NORTH_POLE_Y, b as compareTileId, bi as rotateX, bn as getVideo, br as remapSaturate, bt as toEvaluationFeature, ci as zero$1, cn as featureFilter, cr as isTouchableOrPointableType, ct as SubdivisionGranularitySetting, di as create$1, dn as latest, dr as mapObject, dt as Texture, ei as rotateY, en as validateStyleAndEmit, er as getAngleDelta, et as isFillExtrusionStyleLayer, f as GEOJSON_TILE_LAYER_NAME, fi as equals, fn as ErrorEvent, fr as mod, ft as isHillshadeStyleLayer, g as CanonicalTileID, gi as invert$1, gn as GLOBAL_DISPATCHER_ID, gr as pointPlaneSignedDistance, gt as AlphaImage, h as Bounds, hi as identity, hn as AJAXError, hr as pick, ht as renderColorRamp, ii as sub, ir as isImageBitmap, j as Actor, ji as offscreenCanvasSupported, jn as MAX_VALID_LATITUDE, jr as zoomScale, jt as CollisionBoxArray, k as LngLat, ki as rotate, kn as throwIfAborted, kr as warnOnce, kt as UniformMatrix4f, li as clone$1, lr as isWorker, lt as isColorReliefStyleLayer, mi as fromScaling, mn as Evented, mr as parseCacheControl, mt as isHeatmapStyleLayer, ni as scale$2, nn as ProjectionDefinition, oi as transformMat4$1, on as diff, or as isSafari, ot as SOUTH_POLE_Y, pi as exactEquals, pn as Event, pr as nextPowerOfTwo, pt as HEATMAP_FULL_RENDER_FBO_KEY, q as renderStyleImage, qn as distanceOfAnglesRadians, qr as cross, qt as codePointUsesLocalIdeographFontFamily, r as TextAnchorEnum, ri as scaleAndAdd, rn as ValidationError, rr as getRollPitchBearing, rt as isFillStyleLayer, s as TileCache, si as transformQuat, sn as emptyStyle, sr as isTouchableEvent, st as SubdivisionGranularityExpression, t as getAnchorJustification, ti as rotateZ$1, tn as Color, tr as getEdgeTiles, u as GeoJSONFeature, ui as copy, un as interpolateFactory, ur as lerp, v as UnwrappedTileID, vi as ortho, vn as getJSON, vr as rayPlaneIntersection, vt as isCircleStyleLayer, w as latFromMercatorY, wi as translate, wn as getProtocol, wr as sphericalToCartesian, wt as Uniform3f, x as isInBoundsForZoomLngLat, xi as rotateY$1, xn as makeRequest, xr as rollPitchBearingEqual, xt as Uniform1f, y as calculateTileKey, yi as perspective, yn as getReferrer, yr as readImageUsingVideoFrame, yt as polygonIntersectsPolygon, z as getOverlapMode, zn as createIdentityMat4f64, zr as zero, zt as createLayout } from "./maplibre-gl-shared-dev.mjs";
6
6
  //#region package.json
7
- var version$2 = "6.0.0";
7
+ var version$2 = "6.1.0";
8
8
  //#endregion
9
9
  //#region src/util/browser.ts
10
10
  let linkEl;
@@ -1410,9 +1410,9 @@ const getProperties$2 = () => properties$2 = properties$2 || new Properties({
1410
1410
  //#endregion
1411
1411
  //#region src/style/light.ts
1412
1412
  var Light = class extends Evented {
1413
- constructor(lightOptions) {
1413
+ constructor(lightOptions, globalState) {
1414
1414
  super();
1415
- this._transitionable = new Transitionable(getProperties$2(), "light", void 0);
1415
+ this._transitionable = new Transitionable(getProperties$2(), "light", globalState);
1416
1416
  this.setLight(lightOptions);
1417
1417
  this._transitioning = this._transitionable.untransitioned();
1418
1418
  }
@@ -1461,9 +1461,9 @@ const getProperties$1 = () => properties$1 = properties$1 || new Properties({
1461
1461
  //#endregion
1462
1462
  //#region src/style/sky.ts
1463
1463
  var Sky = class extends Evented {
1464
- constructor(sky) {
1464
+ constructor(sky, globalState) {
1465
1465
  super();
1466
- this._transitionable = new Transitionable(getProperties$1(), "sky", void 0);
1466
+ this._transitionable = new Transitionable(getProperties$1(), "sky", globalState);
1467
1467
  this.setSky(sky);
1468
1468
  this._transitioning = this._transitionable.untransitioned();
1469
1469
  this.recalculate(new EvaluationParameters(0));
@@ -2777,9 +2777,10 @@ var RasterTileSource = class extends Evented {
2777
2777
  const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
2778
2778
  const premultiply = this._premultiplyAlpha;
2779
2779
  const imageBitmapOptions = premultiply ? void 0 : { premultiplyAlpha: "none" };
2780
+ const request = await this.map._requestManager.transformRequest(url, "Tile");
2780
2781
  tile.abortController = new AbortController();
2781
2782
  try {
2782
- const response = await ImageRequest.getImage(await this.map._requestManager.transformRequest(url, "Tile"), tile.abortController, this.map._refreshExpiredTiles, imageBitmapOptions);
2783
+ const response = await ImageRequest.getImage(request, tile.abortController, this.map._refreshExpiredTiles, imageBitmapOptions);
2783
2784
  delete tile.abortController;
2784
2785
  if (tile.aborted) {
2785
2786
  tile.state = "unloaded";
@@ -3314,6 +3315,9 @@ var GeoJSONSource = class extends Evented {
3314
3315
  _pixelsToTileUnits(pixelValue) {
3315
3316
  return pixelValue * (EXTENT / this.tileSize);
3316
3317
  }
3318
+ _tileUnitsToPixels(tileUnitValue) {
3319
+ return tileUnitValue / (EXTENT / this.tileSize);
3320
+ }
3317
3321
  _getClusterMaxZoom(clusterMaxZoom) {
3318
3322
  const effectiveClusterMaxZoom = clusterMaxZoom ? Math.round(clusterMaxZoom) : this.maxzoom - 1;
3319
3323
  if (!(Number.isInteger(clusterMaxZoom) || clusterMaxZoom === void 0)) warnOnce(`Integer expected for option 'clusterMaxZoom': provided value "${clusterMaxZoom}" rounded to "${effectiveClusterMaxZoom}"`);
@@ -3392,6 +3396,24 @@ var GeoJSONSource = class extends Evented {
3392
3396
  return this._updateWorkerData();
3393
3397
  }
3394
3398
  /**
3399
+ * Gets the cluster options currently configured on the source.
3400
+ * The returned values mirror the options accepted by `setClusterOptions`.
3401
+ *
3402
+ * @returns the source's current cluster options
3403
+ * @example
3404
+ * ```ts
3405
+ * const {cluster, clusterMaxZoom, clusterRadius} = map.getSource('some id').getClusterOptions();
3406
+ * ```
3407
+ */
3408
+ getClusterOptions() {
3409
+ const { cluster, clusterOptions } = this.workerOptions.geojsonVtOptions;
3410
+ return {
3411
+ cluster,
3412
+ clusterMaxZoom: clusterOptions.maxZoom,
3413
+ clusterRadius: this._tileUnitsToPixels(clusterOptions.radius)
3414
+ };
3415
+ }
3416
+ /**
3395
3417
  * For clustered sources, fetches the zoom at which the given cluster expands.
3396
3418
  *
3397
3419
  * @param clusterId - The value of the cluster's `cluster_id` property.
@@ -3714,6 +3736,10 @@ var GeoJSONSource = class extends Evented {
3714
3736
  * ]
3715
3737
  * })
3716
3738
  *
3739
+ * // update with an already-decoded image (no network request)
3740
+ * const bitmap = await createImageBitmap(myCanvas);
3741
+ * mySource.updateImage({image: bitmap});
3742
+ *
3717
3743
  * map.removeSource('some id'); // remove
3718
3744
  * ```
3719
3745
  */
@@ -3738,9 +3764,10 @@ var ImageSource = class extends Evented {
3738
3764
  this._loaded = false;
3739
3765
  this.fire(new MapSourceDataEvent("dataloading"));
3740
3766
  this.url = this.options.url;
3767
+ const request = await this.map._requestManager.transformRequest(this.url, "Image");
3741
3768
  this._request = new AbortController();
3742
3769
  try {
3743
- const image = await ImageRequest.getImage(await this.map._requestManager.transformRequest(this.url, "Image"), this._request);
3770
+ const image = await ImageRequest.getImage(request, this._request);
3744
3771
  this._request = null;
3745
3772
  this._loaded = true;
3746
3773
  if (image?.data) {
@@ -3758,17 +3785,29 @@ var ImageSource = class extends Evented {
3758
3785
  return this._loaded;
3759
3786
  }
3760
3787
  /**
3761
- * Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing,
3788
+ * Updates the image and, optionally, the coordinates. To avoid having the image flash after changing,
3762
3789
  * set the `raster-fade-duration` paint property on the raster layer to 0.
3763
3790
  *
3791
+ * Provide exactly one of `url` (to fetch a new image over the network) or `image` (an
3792
+ * already-decoded `HTMLImageElement`, `HTMLCanvasElement`, `ImageBitmap` or `ImageData` to
3793
+ * display directly, without a network request).
3794
+ *
3764
3795
  * @param options - The options object.
3765
3796
  */
3766
3797
  updateImage(options) {
3767
- if (!options.url) return this;
3768
3798
  if (this._request) {
3769
3799
  this._request.abort();
3770
3800
  this._request = null;
3771
3801
  }
3802
+ if ("image" in options) {
3803
+ this._loaded = true;
3804
+ this.image = options.image;
3805
+ if (options.coordinates) this.coordinates = options.coordinates;
3806
+ this.texture = null;
3807
+ this._finishLoading();
3808
+ return this;
3809
+ }
3810
+ if (!options.url) return this;
3772
3811
  this.options.url = options.url;
3773
3812
  this.load(options.coordinates).finally(() => this.texture = null);
3774
3813
  return this;
@@ -4861,6 +4900,35 @@ function coveringZoomLevel(transform, options) {
4861
4900
  return Math.max(0, z);
4862
4901
  }
4863
4902
  /**
4903
+ * Without terrain, `getTileBoundingVolume` has no knowledge of extruded features
4904
+ * (eg. 3D buildings): every tile's bounding box is flat at the camera's `elevation`.
4905
+ * That's a fine approximation of what's visible for most views, but it breaks down
4906
+ * as the frustum's bottom edge approaches horizontal (which depends on both `pitch`
4907
+ * and `fov`, not pitch alone) - a tall building can still be poking up into view
4908
+ * long after its tile's ground point has dropped out of the frustum.
4909
+ *
4910
+ * This is an assumed upper bound on real-world feature height (in metres), used to
4911
+ * grow the elevation used for tile culling as that bottom edge nears horizontal, so
4912
+ * such tiles are not dropped too early. It has no effect away from that edge case.
4913
+ */
4914
+ const ASSUMED_MAX_FEATURE_HEIGHT_METERS = 500;
4915
+ /**
4916
+ * Angle between the frustum's bottom edge and the mercator horizon below which
4917
+ * the culling elevation starts to grow.
4918
+ */
4919
+ const TILE_CULLING_HORIZON_ONSET_DEGREES = 15;
4920
+ /**
4921
+ * Returns the elevation to use when computing tile bounding volumes for culling:
4922
+ * `transform.elevation`, growing by up to `ASSUMED_MAX_FEATURE_HEIGHT_METERS` as
4923
+ * the frustum's bottom edge approaches the horizon, where a ground-level bounding
4924
+ * box would cull tiles whose extruded features are still visible.
4925
+ */
4926
+ function getElevationForTileCulling(transform) {
4927
+ const bottomEdgeDegreesAboveHorizontal = maxMercatorHorizonAngle - transform.pitch - transform.fov / 2;
4928
+ const proximityToHorizon = clamp((TILE_CULLING_HORIZON_ONSET_DEGREES - bottomEdgeDegreesAboveHorizontal) / TILE_CULLING_HORIZON_ONSET_DEGREES, 0, 1);
4929
+ return transform.elevation + proximityToHorizon * ASSUMED_MAX_FEATURE_HEIGHT_METERS;
4930
+ }
4931
+ /**
4864
4932
  * Returns a list of tiles that optimally covers the screen. Adapted for globe projection.
4865
4933
  * Correctly handles LOD when moving over the antimeridian.
4866
4934
  * @param transform - The transform instance.
@@ -4878,6 +4946,7 @@ function coveringTiles(transform, options) {
4878
4946
  const cameraCoord = transform.screenPointToMercatorCoordinate(transform.getCameraPoint());
4879
4947
  const centerCoord = MercatorCoordinate.fromLngLat(transform.center, transform.elevation);
4880
4948
  cameraCoord.z = centerCoord.z + Math.cos(transform.pitchInRadians) * transform.cameraToCenterDistance / transform.worldSize;
4949
+ const elevationForTileCulling = getElevationForTileCulling(transform);
4881
4950
  const detailsProvider = transform.getCoveringTilesDetailsProvider();
4882
4951
  const allowVariableZoom = detailsProvider.allowVariableZoom(transform, options);
4883
4952
  const desiredZ = coveringZoomLevel(transform, options);
@@ -4924,7 +4993,7 @@ function coveringTiles(transform, options) {
4924
4993
  y,
4925
4994
  z: it.zoom
4926
4995
  };
4927
- const boundingVolume = detailsProvider.getTileBoundingVolume(tileID, it.wrap, transform.elevation, options);
4996
+ const boundingVolume = detailsProvider.getTileBoundingVolume(tileID, it.wrap, elevationForTileCulling, options);
4928
4997
  if (!fullyVisible) {
4929
4998
  const intersectResult = isTileVisible(frustum, boundingVolume, plane);
4930
4999
  if (intersectResult === 0) continue;
@@ -5339,7 +5408,7 @@ var TileManager = class TileManager extends Evented {
5339
5408
  }
5340
5409
  /**
5341
5410
  * Reload tiles based on the current state of the source.
5342
- * @param sourceDataChanged - If `true`, reload all tiles using a state of 'expired', otherwise reload only non-errored tiles using state of 'reloading'.
5411
+ * @param sourceDataChanged - If `true`, reload all tiles using a state of 'expired' (errored tiles use 'loading' since they have nothing to show yet), otherwise reload only non-errored tiles using state of 'reloading'.
5343
5412
  * @param shouldReloadTileOptions - Set of options associated with a `MapSourceDataChangedEvent` that can be passed back to the associated `Source` determine whether a tile should be reloaded.
5344
5413
  */
5345
5414
  reload(sourceDataChanged, shouldReloadTileOptions = void 0) {
@@ -5351,7 +5420,7 @@ var TileManager = class TileManager extends Evented {
5351
5420
  for (const id of this._inViewTiles.getAllIds()) {
5352
5421
  const tile = this._inViewTiles.getTileById(id);
5353
5422
  if (shouldReloadTileOptions && !this._source.shouldReloadTile(tile, shouldReloadTileOptions)) continue;
5354
- else if (sourceDataChanged) this._reloadTile(id, "expired");
5423
+ else if (sourceDataChanged) this._reloadTile(id, tile.state === "errored" ? "loading" : "expired");
5355
5424
  else if (tile.state !== "errored") this._reloadTile(id, "reloading");
5356
5425
  }
5357
5426
  }
@@ -8267,8 +8336,8 @@ var clipping_mask_fragment_glsl_g_default = "void main() {fragColor=vec4(1.0);}"
8267
8336
  //#region src/shaders/shaders.ts
8268
8337
  const shaders = {
8269
8338
  prelude: prepare(_prelude_fragment_glsl_g_default, _prelude_vertex_glsl_g_default),
8270
- projectionMercator: prepare("", "float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),
8271
- projectionGlobe: prepare("", "#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),
8339
+ projectionMercator: prepare("\nvoid clipAntimeridian() {}", "float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),
8340
+ projectionGlobe: prepare("uniform bool u_projection_clip_antimeridian;in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}", "#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),
8272
8341
  background: prepare(background_fragment_glsl_g_default, background_vertex_glsl_g_default),
8273
8342
  backgroundPattern: prepare(background_pattern_fragment_glsl_g_default, background_pattern_vertex_glsl_g_default),
8274
8343
  circle: prepare(circle_fragment_glsl_g_default, circle_vertex_glsl_g_default),
@@ -8288,11 +8357,11 @@ const shaders = {
8288
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 vec4 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=a_normal_ed.xyz;float edgedistance=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=mod(normal.x,2.0);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=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\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;}"),
8289
8358
  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;}"),
8290
8359
  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;}}"),
8291
- 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\nfloat 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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
8292
- 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\nfloat 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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
8293
- 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\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 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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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;}"),
8294
- 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\nfloat 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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
8295
- 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\nfloat 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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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;}"),
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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
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 vec2 a_pos_normal;layout(location=1) in vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),
8296
8365
  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;}"),
8297
8366
  raster: prepare("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 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);vec4 color1=texture(u_image1,v_pos1);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 vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec2 v_pos0;out vec2 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);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),
8298
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 vec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in float 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=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);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;}"),
@@ -8301,7 +8370,6 @@ const shaders = {
8301
8370
  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;}"),
8302
8371
  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;}"),
8303
8372
  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);}"),
8304
- projectionErrorMeasurement: prepare("flat in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}", "layout(location=0) in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;flat out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),
8305
8373
  atmosphere: prepare("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}", "layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),
8306
8374
  sky: prepare("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}", "layout(location=0) in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")
8307
8375
  };
@@ -8444,11 +8512,7 @@ var MercatorProjection = class {
8444
8512
  get transitionState() {
8445
8513
  return 0;
8446
8514
  }
8447
- get latitudeErrorCorrectionRadians() {
8448
- return 0;
8449
- }
8450
8515
  destroy() {}
8451
- updateGPUdependent(_) {}
8452
8516
  getMeshFromTileID(context, _tileID, _hasBorder, _allowPoles, _usage) {
8453
8517
  if (this._cachedMesh) return this._cachedMesh;
8454
8518
  const tileExtentArray = new PosArray();
@@ -8469,7 +8533,6 @@ var MercatorProjection = class {
8469
8533
  hasTransition() {
8470
8534
  return false;
8471
8535
  }
8472
- setErrorQueryLatitudeDegrees(_value) {}
8473
8536
  };
8474
8537
  //#endregion
8475
8538
  //#region src/geo/edge_insets.ts
@@ -9164,13 +9227,13 @@ var MercatorCoveringTilesDetailsProvider = class {
9164
9227
  * @param tileID - Tile x, y and z for zoom.
9165
9228
  */
9166
9229
  getTileBoundingVolume(tileID, wrap, elevation, options) {
9167
- let minElevation = 0;
9168
- let maxElevation = 0;
9230
+ let minElevation = Math.min(0, elevation);
9231
+ let maxElevation = Math.max(0, elevation);
9169
9232
  if (options?.terrain) {
9170
9233
  const overscaledTileID = new OverscaledTileID(tileID.z, wrap, tileID.z, tileID.x, tileID.y);
9171
9234
  const minMax = options.terrain.getMinMaxElevation(overscaledTileID);
9172
- minElevation = minMax.minElevation ?? Math.min(0, elevation);
9173
- maxElevation = minMax.maxElevation ?? Math.max(0, elevation);
9235
+ minElevation = minMax.minElevation ?? minElevation;
9236
+ maxElevation = minMax.maxElevation ?? maxElevation;
9174
9237
  }
9175
9238
  const numTiles = 1 << tileID.z;
9176
9239
  return new Aabb([
@@ -9612,7 +9675,7 @@ var MercatorTransform = class MercatorTransform {
9612
9675
  get autoCalculateNearFarZ() {
9613
9676
  return this._helper.autoCalculateNearFarZ;
9614
9677
  }
9615
- setTransitionState(_value, _error) {}
9678
+ setTransitionState(_value) {}
9616
9679
  constructor(options) {
9617
9680
  this._posMatrixCache = /* @__PURE__ */ new Map();
9618
9681
  this._alignedPosMatrixCache = /* @__PURE__ */ new Map();
@@ -10020,7 +10083,8 @@ var MercatorTransform = class MercatorTransform {
10020
10083
  0
10021
10084
  ],
10022
10085
  projectionTransition: 0,
10023
- fallbackMatrix: mainMatrix
10086
+ fallbackMatrix: mainMatrix,
10087
+ clipAntimeridian: false
10024
10088
  };
10025
10089
  }
10026
10090
  isLocationOccluded(_) {
@@ -10290,238 +10354,6 @@ var MercatorCameraHelper = class {
10290
10354
  let properties;
10291
10355
  const getProperties = () => properties = properties || new Properties({ "type": new DataConstantProperty(latest["projection"]["type"], "type") });
10292
10356
  //#endregion
10293
- //#region src/webgl/color_mode.ts
10294
- const ZERO = 0;
10295
- const ONE = 1;
10296
- const ONE_MINUS_SRC_ALPHA = 771;
10297
- var ColorMode = class {
10298
- constructor(blendFunction, blendColor, mask) {
10299
- this.blendFunction = blendFunction;
10300
- this.blendColor = blendColor;
10301
- this.mask = mask;
10302
- }
10303
- };
10304
- ColorMode.Replace = [ONE, ZERO];
10305
- ColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [
10306
- false,
10307
- false,
10308
- false,
10309
- false
10310
- ]);
10311
- ColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [
10312
- true,
10313
- true,
10314
- true,
10315
- true
10316
- ]);
10317
- ColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [
10318
- true,
10319
- true,
10320
- true,
10321
- true
10322
- ]);
10323
- //#endregion
10324
- //#region src/webgl/cull_face_mode.ts
10325
- const FRONT = 1028;
10326
- const BACK = 1029;
10327
- const CCW = 2305;
10328
- var CullFaceMode = class {
10329
- constructor(enable, mode, frontFace) {
10330
- this.enable = enable;
10331
- this.mode = mode;
10332
- this.frontFace = frontFace;
10333
- }
10334
- };
10335
- CullFaceMode.disabled = new CullFaceMode(false, BACK, CCW);
10336
- CullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW);
10337
- CullFaceMode.frontCCW = new CullFaceMode(true, FRONT, CCW);
10338
- //#endregion
10339
- //#region src/webgl/depth_mode.ts
10340
- const ALWAYS$1 = 519;
10341
- var DepthMode = class {
10342
- constructor(depthFunc, depthMask, depthRange) {
10343
- this.func = depthFunc;
10344
- this.mask = depthMask;
10345
- this.range = depthRange;
10346
- }
10347
- };
10348
- DepthMode.ReadOnly = false;
10349
- DepthMode.ReadWrite = true;
10350
- DepthMode.disabled = new DepthMode(ALWAYS$1, DepthMode.ReadOnly, [0, 1]);
10351
- //#endregion
10352
- //#region src/webgl/stencil_mode.ts
10353
- const ALWAYS = 519;
10354
- const KEEP = 7680;
10355
- var StencilMode = class {
10356
- constructor(test, ref, mask, fail, depthFail, pass) {
10357
- this.test = test;
10358
- this.ref = ref;
10359
- this.mask = mask;
10360
- this.fail = fail;
10361
- this.depthFail = depthFail;
10362
- this.pass = pass;
10363
- }
10364
- };
10365
- StencilMode.disabled = new StencilMode({
10366
- func: ALWAYS,
10367
- mask: 0
10368
- }, 0, 0, KEEP, KEEP, KEEP);
10369
- //#endregion
10370
- //#region src/webgl/program/projection_error_measurement_program.ts
10371
- const projectionErrorMeasurementUniforms = (context, locations) => ({
10372
- "u_input": new Uniform1f(context, locations.u_input),
10373
- "u_output_expected": new Uniform1f(context, locations.u_output_expected)
10374
- });
10375
- const projectionErrorMeasurementUniformValues = (input, outputExpected) => ({
10376
- "u_input": input,
10377
- "u_output_expected": outputExpected
10378
- });
10379
- //#endregion
10380
- //#region src/geo/projection/globe_projection_error_measurement.ts
10381
- /**
10382
- * For vector globe the vertex shader projects mercator coordinates to angular coordinates on a sphere.
10383
- * This projection requires some inverse trigonometry `atan(exp(...))`, which is inaccurate on some GPUs (mainly on AMD and Nvidia).
10384
- * The inaccuracy is severe enough to require a workaround. The uncorrected map is shifted north-south by up to several hundred meters in some latitudes.
10385
- * Since the inaccuracy is hardware-dependant and may change in the future, we need to measure the error at runtime.
10386
- *
10387
- * Our approach relies on several assumptions:
10388
- *
10389
- * - the error is only present in the "latitude" component (longitude doesn't need any inverse trigonometry)
10390
- * - the error is continuous and changes slowly with latitude
10391
- * - at zoom levels where the error is noticeable, the error is more-or-less the same across the entire visible map area (and thus can be described with a single number)
10392
- *
10393
- * Solution:
10394
- *
10395
- * Every few frames, launch a GPU shader that measures the error for the current map center latitude, and writes it to a 1x1 texture.
10396
- * Read back that texture, and offset the globe projection matrix according to the error (interpolating smoothly from old error to new error if needed).
10397
- * The texture readback is done asynchronously using Pixel Pack Buffers (WebGL2) when possible, and has a few frames of latency, but that should not be a problem.
10398
- *
10399
- * General operation of this class each frame is:
10400
- *
10401
- * - render the error shader into a fbo, read that pixel into a PBO, place a fence
10402
- * - wait a few frames to allow the GPU (and driver) to actually execute the shader
10403
- * - wait for the fence to be signalled (guaranteeing the shader to actually be executed)
10404
- * - read back the PBO's contents
10405
- * - wait a few more frames
10406
- * - repeat
10407
- */
10408
- var ProjectionErrorMeasurement = class ProjectionErrorMeasurement {
10409
- get awaitingQuery() {
10410
- return !!this._readbackQueue;
10411
- }
10412
- constructor(renderContext) {
10413
- this._readbackWaitFrames = 4;
10414
- this._measureWaitFrames = 6;
10415
- this._texWidth = 1;
10416
- this._texHeight = 1;
10417
- this._measuredError = 0;
10418
- this._updateCount = 0;
10419
- this._lastReadbackFrame = -1e3;
10420
- this._readbackQueue = null;
10421
- this._cachedRenderContext = renderContext;
10422
- const context = renderContext.context;
10423
- const gl = context.gl;
10424
- this._texFormat = gl.RGBA;
10425
- this._texType = gl.UNSIGNED_BYTE;
10426
- const vertexArray = new PosArray();
10427
- vertexArray.emplaceBack(-1, -1);
10428
- vertexArray.emplaceBack(2, -1);
10429
- vertexArray.emplaceBack(-1, 2);
10430
- const indexArray = new TriangleIndexArray();
10431
- indexArray.emplaceBack(0, 1, 2);
10432
- this._fullscreenTriangle = new Mesh(context.createVertexBuffer(vertexArray, posAttributes.members), context.createIndexBuffer(indexArray), SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length));
10433
- this._resultBuffer = /* @__PURE__ */ new Uint8Array(4);
10434
- context.activeTexture.set(gl.TEXTURE1);
10435
- const texture = gl.createTexture();
10436
- gl.bindTexture(gl.TEXTURE_2D, texture);
10437
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
10438
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
10439
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
10440
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
10441
- gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, this._texWidth, this._texHeight);
10442
- this._fbo = context.createFramebuffer(this._texWidth, this._texHeight, false, false);
10443
- this._fbo.colorAttachment.set(texture);
10444
- this._pbo = gl.createBuffer();
10445
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo);
10446
- gl.bufferData(gl.PIXEL_PACK_BUFFER, 4, gl.STREAM_READ);
10447
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
10448
- }
10449
- destroy() {
10450
- const gl = this._cachedRenderContext.context.gl;
10451
- this._fullscreenTriangle.destroy();
10452
- this._fbo.destroy();
10453
- gl.deleteBuffer(this._pbo);
10454
- this._fullscreenTriangle = null;
10455
- this._fbo = null;
10456
- this._pbo = null;
10457
- this._resultBuffer = null;
10458
- }
10459
- updateErrorLoop(normalizedMercatorY, expectedAngleY) {
10460
- const currentFrame = this._updateCount;
10461
- if (this._readbackQueue) {
10462
- if (currentFrame >= this._readbackQueue.frameNumberIssued + this._readbackWaitFrames) this._tryReadback();
10463
- } else if (currentFrame >= this._lastReadbackFrame + this._measureWaitFrames) this._renderErrorTexture(normalizedMercatorY, expectedAngleY);
10464
- this._updateCount++;
10465
- return this._measuredError;
10466
- }
10467
- _bindFramebuffer() {
10468
- const context = this._cachedRenderContext.context;
10469
- const gl = context.gl;
10470
- context.activeTexture.set(gl.TEXTURE1);
10471
- gl.bindTexture(gl.TEXTURE_2D, this._fbo.colorAttachment.get());
10472
- context.bindFramebuffer.set(this._fbo.framebuffer);
10473
- }
10474
- _renderErrorTexture(input, outputExpected) {
10475
- const context = this._cachedRenderContext.context;
10476
- const gl = context.gl;
10477
- this._bindFramebuffer();
10478
- context.viewport.set([
10479
- 0,
10480
- 0,
10481
- this._texWidth,
10482
- this._texHeight
10483
- ]);
10484
- context.clear({ color: Color.transparent });
10485
- this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(context, gl.TRIANGLES, DepthMode.disabled, StencilMode.disabled, ColorMode.unblended, CullFaceMode.disabled, projectionErrorMeasurementUniformValues(input, outputExpected), null, null, "$clipping", this._fullscreenTriangle.vertexBuffer, this._fullscreenTriangle.indexBuffer, this._fullscreenTriangle.segments);
10486
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo);
10487
- gl.readBuffer(gl.COLOR_ATTACHMENT0);
10488
- gl.readPixels(0, 0, this._texWidth, this._texHeight, this._texFormat, this._texType, 0);
10489
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
10490
- const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
10491
- gl.flush();
10492
- this._readbackQueue = {
10493
- frameNumberIssued: this._updateCount,
10494
- sync
10495
- };
10496
- }
10497
- _tryReadback() {
10498
- const gl = this._cachedRenderContext.context.gl;
10499
- if (!this._readbackQueue) return;
10500
- const waitResult = gl.clientWaitSync(this._readbackQueue.sync, 0, 0);
10501
- if (waitResult === gl.WAIT_FAILED) {
10502
- warnOnce("WebGL2 clientWaitSync failed.");
10503
- this._readbackQueue = null;
10504
- this._lastReadbackFrame = this._updateCount;
10505
- return;
10506
- }
10507
- if (waitResult === gl.TIMEOUT_EXPIRED) return;
10508
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo);
10509
- gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, this._resultBuffer, 0, 4);
10510
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
10511
- this._readbackQueue = null;
10512
- this._measuredError = ProjectionErrorMeasurement._parseRGBA8float(this._resultBuffer);
10513
- this._lastReadbackFrame = this._updateCount;
10514
- }
10515
- static _parseRGBA8float(buffer) {
10516
- let result = 0;
10517
- result += buffer[0] / 256;
10518
- result += buffer[1] / 65536;
10519
- result += buffer[2] / 16777216;
10520
- if (buffer[3] < 127) result = -result;
10521
- return result / 128;
10522
- }
10523
- };
10524
- //#endregion
10525
10357
  //#region src/util/create_tile_mesh.ts
10526
10358
  /**
10527
10359
  * The size of border region for stencil masks, in internal tile coordinates.
@@ -10622,7 +10454,6 @@ function createTileMesh(options, forceIndicesSize) {
10622
10454
  //#region src/geo/projection/vertical_perspective_projection.ts
10623
10455
  const VerticalPerspectiveShaderDefine = "#define GLOBE";
10624
10456
  const VerticalPerspectiveShaderVariantKey = "globe";
10625
- const globeConstants = { errorTransitionTimeSeconds: .5 };
10626
10457
  const granularitySettingsGlobe = new SubdivisionGranularitySetting({
10627
10458
  fill: new SubdivisionGranularityExpression(128, 2),
10628
10459
  line: new SubdivisionGranularityExpression(512, 0),
@@ -10633,10 +10464,6 @@ const granularitySettingsGlobe = new SubdivisionGranularitySetting({
10633
10464
  var VerticalPerspectiveProjection = class {
10634
10465
  constructor() {
10635
10466
  this._tileMeshCache = {};
10636
- this._errorCorrectionUsable = 0;
10637
- this._errorMeasurementLastValue = 0;
10638
- this._errorCorrectionPreviousValue = 0;
10639
- this._errorMeasurementLastChangeTime = -1e3;
10640
10467
  }
10641
10468
  get name() {
10642
10469
  return "vertical-perspective";
@@ -10665,35 +10492,7 @@ var VerticalPerspectiveProjection = class {
10665
10492
  get useGlobeControls() {
10666
10493
  return true;
10667
10494
  }
10668
- /**
10669
- * @internal
10670
- * Globe projection periodically measures the error of the GPU's
10671
- * projection from mercator to globe and computes how much to correct
10672
- * the globe's latitude alignment.
10673
- * This stores the correction that should be applied to the projection matrix.
10674
- */
10675
- get latitudeErrorCorrectionRadians() {
10676
- return this._errorCorrectionUsable;
10677
- }
10678
- destroy() {
10679
- if (this._errorMeasurement) this._errorMeasurement.destroy();
10680
- }
10681
- updateGPUdependent(renderContext) {
10682
- this._errorMeasurement ||= new ProjectionErrorMeasurement(renderContext);
10683
- const mercatorY = mercatorYfromLat(this._errorQueryLatitudeDegrees);
10684
- const expectedResult = 2 * Math.atan(Math.exp(Math.PI - mercatorY * Math.PI * 2)) - Math.PI * .5;
10685
- const newValue = this._errorMeasurement.updateErrorLoop(mercatorY, expectedResult);
10686
- const currentTime = now();
10687
- if (newValue !== this._errorMeasurementLastValue) {
10688
- this._errorCorrectionPreviousValue = this._errorCorrectionUsable;
10689
- this._errorMeasurementLastValue = newValue;
10690
- this._errorMeasurementLastChangeTime = currentTime;
10691
- }
10692
- const sinceUpdateSeconds = (currentTime - this._errorMeasurementLastChangeTime) / 1e3;
10693
- const mix = Math.min(Math.max(sinceUpdateSeconds / globeConstants.errorTransitionTimeSeconds, 0), 1);
10694
- const newCorrection = -this._errorMeasurementLastValue;
10695
- this._errorCorrectionUsable = lerp(this._errorCorrectionPreviousValue, newCorrection, easeCubicInOut(mix));
10696
- }
10495
+ destroy() {}
10697
10496
  _getMeshKey(options) {
10698
10497
  return `${options.granularity.toString(36)}_${options.generateBorders ? "b" : ""}${options.extendToNorthPole ? "n" : ""}${options.extendToSouthPole ? "s" : ""}`;
10699
10498
  }
@@ -10717,22 +10516,15 @@ var VerticalPerspectiveProjection = class {
10717
10516
  }
10718
10517
  recalculate(_params) {}
10719
10518
  hasTransition() {
10720
- const currentTime = now();
10721
- let dirty = false;
10722
- dirty ||= (currentTime - this._errorMeasurementLastChangeTime) / 1e3 < globeConstants.errorTransitionTimeSeconds + .2;
10723
- dirty ||= this._errorMeasurement?.awaitingQuery;
10724
- return dirty;
10725
- }
10726
- setErrorQueryLatitudeDegrees(value) {
10727
- this._errorQueryLatitudeDegrees = value;
10519
+ return false;
10728
10520
  }
10729
10521
  };
10730
10522
  //#endregion
10731
10523
  //#region src/geo/projection/globe_projection.ts
10732
10524
  var GlobeProjection = class extends Evented {
10733
- constructor(projection) {
10525
+ constructor(projection, globalState) {
10734
10526
  super();
10735
- this._transitionable = new Transitionable(getProperties(), "projection", void 0);
10527
+ this._transitionable = new Transitionable(getProperties(), "projection", globalState);
10736
10528
  this.setProjection(projection);
10737
10529
  this._transitioning = this._transitionable.untransitioned();
10738
10530
  this.recalculate(new EvaluationParameters(0));
@@ -10744,6 +10536,7 @@ var GlobeProjection = class extends Evented {
10744
10536
  if (typeof currentProjectionSpecValue === "string" && currentProjectionSpecValue === "mercator") return 0;
10745
10537
  if (typeof currentProjectionSpecValue === "string" && currentProjectionSpecValue === "vertical-perspective") return 1;
10746
10538
  if (currentProjectionSpecValue instanceof ProjectionDefinition) {
10539
+ if (currentProjectionSpecValue.from === currentProjectionSpecValue.to) return currentProjectionSpecValue.from === "mercator" ? 0 : 1;
10747
10540
  if (currentProjectionSpecValue.from === "vertical-perspective" && currentProjectionSpecValue.to === "mercator") return 1 - currentProjectionSpecValue.transition;
10748
10541
  if (currentProjectionSpecValue.from === "mercator" && currentProjectionSpecValue.to === "vertical-perspective") return currentProjectionSpecValue.transition;
10749
10542
  }
@@ -10752,9 +10545,6 @@ var GlobeProjection = class extends Evented {
10752
10545
  get useGlobeRendering() {
10753
10546
  return this.transitionState > 0;
10754
10547
  }
10755
- get latitudeErrorCorrectionRadians() {
10756
- return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians;
10757
- }
10758
10548
  get currentProjection() {
10759
10549
  return this.useGlobeRendering ? this._verticalPerspectiveProjection : this._mercatorProjection;
10760
10550
  }
@@ -10786,10 +10576,6 @@ var GlobeProjection = class extends Evented {
10786
10576
  this._mercatorProjection.destroy();
10787
10577
  this._verticalPerspectiveProjection.destroy();
10788
10578
  }
10789
- updateGPUdependent(context) {
10790
- this._mercatorProjection.updateGPUdependent(context);
10791
- this._verticalPerspectiveProjection.updateGPUdependent(context);
10792
- }
10793
10579
  getMeshFromTileID(context, _tileID, _hasBorder, _allowPoles, _usage) {
10794
10580
  return this.currentProjection.getMeshFromTileID(context, _tileID, _hasBorder, _allowPoles, _usage);
10795
10581
  }
@@ -10805,10 +10591,6 @@ var GlobeProjection = class extends Evented {
10805
10591
  recalculate(parameters) {
10806
10592
  this.properties = this._transitioning.possiblyEvaluate(parameters);
10807
10593
  }
10808
- setErrorQueryLatitudeDegrees(value) {
10809
- this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(value);
10810
- this._mercatorProjection.setErrorQueryLatitudeDegrees(value);
10811
- }
10812
10594
  };
10813
10595
  //#endregion
10814
10596
  //#region src/geo/projection/globe_utils.ts
@@ -11006,7 +10788,7 @@ var BoundingVolumeCache = class {
11006
10788
  * @param tileID - Tile x, y and z for zoom.
11007
10789
  */
11008
10790
  getTileBoundingVolume(tileID, wrap, elevation, options) {
11009
- const key = `${tileID.z}_${tileID.x}_${tileID.y}_${options?.terrain ? "t" : ""}`;
10791
+ const key = `${tileID.z}_${tileID.x}_${tileID.y}_${options?.terrain ? "t" : ""}_${Math.round(elevation)}`;
11010
10792
  const cached = this._cache.get(key);
11011
10793
  if (cached) return cached;
11012
10794
  const cachedPrevious = this._cachePrevious.get(key);
@@ -11277,13 +11059,13 @@ var GlobeCoveringTilesDetailsProvider = class {
11277
11059
  return this._boundingVolumeCache.getTileBoundingVolume(tileID, wrap, elevation, options);
11278
11060
  }
11279
11061
  _computeTileBoundingVolume(tileID, wrap, elevation, options) {
11280
- let minElevation = 0;
11281
- let maxElevation = 0;
11062
+ let minElevation = Math.min(0, elevation);
11063
+ let maxElevation = Math.max(0, elevation);
11282
11064
  if (options?.terrain) {
11283
11065
  const overscaledTileID = new OverscaledTileID(tileID.z, wrap, tileID.z, tileID.x, tileID.y);
11284
11066
  const minMax = options.terrain.getMinMaxElevation(overscaledTileID);
11285
- minElevation = minMax.minElevation ?? Math.min(0, elevation);
11286
- maxElevation = minMax.maxElevation ?? Math.max(0, elevation);
11067
+ minElevation = minMax.minElevation ?? minElevation;
11068
+ maxElevation = minMax.maxElevation ?? maxElevation;
11287
11069
  }
11288
11070
  minElevation /= earthRadius;
11289
11071
  maxElevation /= earthRadius;
@@ -11608,11 +11390,10 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11608
11390
  this._cachedClippingPlane = createVec4f64();
11609
11391
  this._projectionMatrix = createIdentityMat4f64();
11610
11392
  this._globeViewProjMatrix32f = createIdentityMat4f32();
11611
- this._globeViewProjMatrixNoCorrection = createIdentityMat4f64();
11612
- this._globeViewProjMatrixNoCorrectionInverted = createIdentityMat4f64();
11393
+ this._globeViewProjMatrixF64 = createIdentityMat4f64();
11394
+ this._globeViewProjMatrixF64Inverted = createIdentityMat4f64();
11613
11395
  this._globeProjMatrixInverted = createIdentityMat4f64();
11614
11396
  this._cameraPosition = createVec3f64();
11615
- this._globeLatitudeErrorCorrectionRadians = 0;
11616
11397
  this.defaultConstrain = (lngLat, zoom) => {
11617
11398
  const constrainedLat = clamp(lngLat.lat, -MAX_VALID_LATITUDE, MAX_VALID_LATITUDE);
11618
11399
  const constrainedZoom = clamp(+zoom, this.minZoom + getZoomAdjustment(0, constrainedLat), this.maxZoom);
@@ -11637,15 +11418,14 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11637
11418
  clone.apply(this, false);
11638
11419
  return clone;
11639
11420
  }
11640
- apply(that, constrain, globeLatitudeErrorCorrectionRadians) {
11641
- this._globeLatitudeErrorCorrectionRadians = globeLatitudeErrorCorrectionRadians || 0;
11421
+ apply(that, constrain) {
11642
11422
  this._helper.apply(that, constrain);
11643
11423
  }
11644
11424
  get projectionMatrix() {
11645
11425
  return this._projectionMatrix;
11646
11426
  }
11647
11427
  get modelViewProjectionMatrix() {
11648
- return this._globeViewProjMatrixNoCorrection;
11428
+ return this._globeViewProjMatrixF64;
11649
11429
  }
11650
11430
  get inverseProjectionMatrix() {
11651
11431
  return this._globeProjMatrixInverted;
@@ -11668,7 +11448,8 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11668
11448
  tileMercatorCoords: mercatorTileCoordinates,
11669
11449
  clippingPlane: this._cachedClippingPlane,
11670
11450
  projectionTransition: applyGlobeMatrix ? 1 : 0,
11671
- fallbackMatrix: this._globeViewProjMatrix32f
11451
+ fallbackMatrix: this._globeViewProjMatrix32f,
11452
+ clipAntimeridian: overscaledTileID?.canonical.z === 0
11672
11453
  };
11673
11454
  }
11674
11455
  _computeClippingPlane(globeRadiusPixels) {
@@ -11766,7 +11547,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11766
11547
  spherePos[2] * vectorMultiplier,
11767
11548
  1
11768
11549
  ];
11769
- transformMat4(pos, pos, this._globeViewProjMatrixNoCorrection);
11550
+ transformMat4(pos, pos, this._globeViewProjMatrixF64);
11770
11551
  const plane = this._cachedClippingPlane;
11771
11552
  const isOccluded = plane[0] * spherePos[0] + plane[1] * spherePos[1] + plane[2] * spherePos[2] + plane[3] < 0;
11772
11553
  return {
@@ -11779,7 +11560,6 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11779
11560
  if (!this._helper._width || !this._helper._height) return;
11780
11561
  const globeRadiusPixels = getGlobeRadiusPixels(this.worldSize, this.center.lat);
11781
11562
  const globeMatrix = createMat4f64();
11782
- const globeMatrixUncorrected = createMat4f64();
11783
11563
  if (this._helper.autoCalculateNearFarZ) {
11784
11564
  this._helper._nearZ = .5;
11785
11565
  this._helper._farZ = this.cameraToCenterDistance + globeRadiusPixels * 2;
@@ -11808,16 +11588,13 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11808
11588
  scaleVec[0] = globeRadiusPixels;
11809
11589
  scaleVec[1] = globeRadiusPixels;
11810
11590
  scaleVec[2] = globeRadiusPixels;
11811
- rotateX(globeMatrixUncorrected, globeMatrix, this.center.lat * Math.PI / 180);
11812
- rotateY$1(globeMatrixUncorrected, globeMatrixUncorrected, -this.center.lng * Math.PI / 180);
11813
- scale(globeMatrixUncorrected, globeMatrixUncorrected, scaleVec);
11814
- this._globeViewProjMatrixNoCorrection = globeMatrixUncorrected;
11815
- rotateX(globeMatrix, globeMatrix, this.center.lat * Math.PI / 180 - this._globeLatitudeErrorCorrectionRadians);
11591
+ rotateX(globeMatrix, globeMatrix, this.center.lat * Math.PI / 180);
11816
11592
  rotateY$1(globeMatrix, globeMatrix, -this.center.lng * Math.PI / 180);
11817
11593
  scale(globeMatrix, globeMatrix, scaleVec);
11594
+ this._globeViewProjMatrixF64 = globeMatrix;
11818
11595
  this._globeViewProjMatrix32f = new Float32Array(globeMatrix);
11819
- this._globeViewProjMatrixNoCorrectionInverted = createMat4f64();
11820
- invert$1(this._globeViewProjMatrixNoCorrectionInverted, globeMatrixUncorrected);
11596
+ this._globeViewProjMatrixF64Inverted = createMat4f64();
11597
+ invert$1(this._globeViewProjMatrixF64Inverted, globeMatrix);
11821
11598
  const zero = createVec3f64();
11822
11599
  this._cameraPosition = createVec3f64();
11823
11600
  this._cameraPosition[2] = this.cameraToCenterDistance / globeRadiusPixels;
@@ -11832,7 +11609,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11832
11609
  rotateX$1(this._cameraPosition, this._cameraPosition, zero, -this.center.lat * Math.PI / 180);
11833
11610
  rotateY(this._cameraPosition, this._cameraPosition, zero, this.center.lng * Math.PI / 180);
11834
11611
  this._cachedClippingPlane = this._computeClippingPlane(globeRadiusPixels);
11835
- const matrix = clone$1(this._globeViewProjMatrixNoCorrectionInverted);
11612
+ const matrix = clone$1(this._globeViewProjMatrixF64Inverted);
11836
11613
  scale(matrix, matrix, [
11837
11614
  1,
11838
11615
  1,
@@ -11878,7 +11655,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11878
11655
  return this._helper.getCameraLngLat();
11879
11656
  }
11880
11657
  lngLatToCameraDepth(lngLat, elevation) {
11881
- if (!this._globeViewProjMatrixNoCorrection) return 1;
11658
+ if (!this._globeViewProjMatrixF64) return 1;
11882
11659
  const vec = angularCoordinatesToSurfaceVector(lngLat);
11883
11660
  scale$2(vec, vec, 1 + elevation / earthRadius);
11884
11661
  const result = createVec4f64();
@@ -11887,7 +11664,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
11887
11664
  vec[1],
11888
11665
  vec[2],
11889
11666
  1
11890
- ], this._globeViewProjMatrixNoCorrection);
11667
+ ], this._globeViewProjMatrixF64);
11891
11668
  return result[2] / result[3];
11892
11669
  }
11893
11670
  populateCache(_coords) {}
@@ -12013,7 +11790,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
12013
11790
  */
12014
11791
  _projectSurfacePointToScreen(pos) {
12015
11792
  const projected = createVec4f64();
12016
- transformMat4(projected, [...pos, 1], this._globeViewProjMatrixNoCorrection);
11793
+ transformMat4(projected, [...pos, 1], this._globeViewProjMatrixF64);
12017
11794
  projected[0] /= projected[3];
12018
11795
  projected[1] /= projected[3];
12019
11796
  return new Point((projected[0] * .5 + .5) * this.width, (-projected[1] * .5 + .5) * this.height);
@@ -12042,7 +11819,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
12042
11819
  pos[1] = (p.y / this.height * 2 - 1) * -1;
12043
11820
  pos[2] = 1;
12044
11821
  pos[3] = 1;
12045
- transformMat4(pos, pos, this._globeViewProjMatrixNoCorrectionInverted);
11822
+ transformMat4(pos, pos, this._globeViewProjMatrixF64Inverted);
12046
11823
  pos[0] /= pos[3];
12047
11824
  pos[1] /= pos[3];
12048
11825
  pos[2] /= pos[3];
@@ -12069,7 +11846,7 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
12069
11846
  isSurfacePointOnScreen(vec) {
12070
11847
  if (!this.isSurfacePointVisible(vec)) return false;
12071
11848
  const projected = createVec4f64();
12072
- transformMat4(projected, [...vec, 1], this._globeViewProjMatrixNoCorrection);
11849
+ transformMat4(projected, [...vec, 1], this._globeViewProjMatrixF64);
12073
11850
  projected[0] /= projected[3];
12074
11851
  projected[1] /= projected[3];
12075
11852
  projected[2] /= projected[3];
@@ -12370,9 +12147,8 @@ var GlobeTransform = class GlobeTransform {
12370
12147
  get isGlobeRendering() {
12371
12148
  return this._globeness > 0;
12372
12149
  }
12373
- setTransitionState(globeness, errorCorrectionValue) {
12150
+ setTransitionState(globeness) {
12374
12151
  this._globeness = globeness;
12375
- this._globeLatitudeErrorCorrectionRadians = errorCorrectionValue;
12376
12152
  this._calcMatrices();
12377
12153
  this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame();
12378
12154
  this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame();
@@ -12381,7 +12157,6 @@ var GlobeTransform = class GlobeTransform {
12381
12157
  return this.isGlobeRendering ? this._verticalPerspectiveTransform : this._mercatorTransform;
12382
12158
  }
12383
12159
  constructor(options) {
12384
- this._globeLatitudeErrorCorrectionRadians = 0;
12385
12160
  this._globeness = 1;
12386
12161
  this.defaultConstrain = (lngLat, zoom) => {
12387
12162
  return this.currentTransform.defaultConstrain(lngLat, zoom);
@@ -12402,14 +12177,13 @@ var GlobeTransform = class GlobeTransform {
12402
12177
  clone() {
12403
12178
  const clone = new GlobeTransform();
12404
12179
  clone._globeness = this._globeness;
12405
- clone._globeLatitudeErrorCorrectionRadians = this._globeLatitudeErrorCorrectionRadians;
12406
12180
  clone.apply(this, false);
12407
12181
  return clone;
12408
12182
  }
12409
12183
  apply(that, constrain) {
12410
12184
  this._helper.apply(that, constrain);
12411
12185
  this._mercatorTransform.apply(this, false);
12412
- this._verticalPerspectiveTransform.apply(this, false, this._globeLatitudeErrorCorrectionRadians);
12186
+ this._verticalPerspectiveTransform.apply(this, false);
12413
12187
  }
12414
12188
  get projectionMatrix() {
12415
12189
  return this.currentTransform.projectionMatrix;
@@ -12431,7 +12205,8 @@ var GlobeTransform = class GlobeTransform {
12431
12205
  clippingPlane: verticalPerspectiveProjectionData.clippingPlane,
12432
12206
  tileMercatorCoords: verticalPerspectiveProjectionData.tileMercatorCoords,
12433
12207
  projectionTransition: params.applyGlobeMatrix ? this._globeness : 0,
12434
- fallbackMatrix: mercatorProjectionData.fallbackMatrix
12208
+ fallbackMatrix: mercatorProjectionData.fallbackMatrix,
12209
+ clipAntimeridian: verticalPerspectiveProjectionData.clipAntimeridian
12435
12210
  };
12436
12211
  }
12437
12212
  isLocationOccluded(location) {
@@ -12454,7 +12229,7 @@ var GlobeTransform = class GlobeTransform {
12454
12229
  }
12455
12230
  _calcMatrices() {
12456
12231
  if (!this._helper._width || !this._helper._height) return;
12457
- this._verticalPerspectiveTransform.apply(this, false, this._globeLatitudeErrorCorrectionRadians);
12232
+ this._verticalPerspectiveTransform.apply(this, false);
12458
12233
  this._helper._nearZ = this._verticalPerspectiveTransform.nearZ;
12459
12234
  this._helper._farZ = this._verticalPerspectiveTransform.farZ;
12460
12235
  this._mercatorTransform.apply(this, true, this.isGlobeRendering);
@@ -12875,10 +12650,10 @@ var GlobeCameraHelper = class {
12875
12650
  };
12876
12651
  //#endregion
12877
12652
  //#region src/geo/projection/projection_factory.ts
12878
- function createProjectionFromName(name, transformConstrain) {
12653
+ function createProjectionFromName(name, transformConstrain, globalState) {
12879
12654
  const transformOptions = { constrainOverride: transformConstrain };
12880
12655
  if (Array.isArray(name)) {
12881
- const globeProjection = new GlobeProjection({ type: name });
12656
+ const globeProjection = new GlobeProjection({ type: name }, globalState);
12882
12657
  return {
12883
12658
  projection: globeProjection,
12884
12659
  transform: new GlobeTransform(transformOptions),
@@ -12900,7 +12675,7 @@ function createProjectionFromName(name, transformConstrain) {
12900
12675
  "vertical-perspective",
12901
12676
  12,
12902
12677
  "mercator"
12903
- ] });
12678
+ ] }, {});
12904
12679
  return {
12905
12680
  projection: globeProjection,
12906
12681
  transform: new GlobeTransform(transformOptions),
@@ -13090,9 +12865,9 @@ var Style = class extends Evented {
13090
12865
  else this.imageManager.setLoaded(true);
13091
12866
  this.glyphManager.setURL(nextState.glyphs);
13092
12867
  this._createLayers();
13093
- this.light = new Light(this.stylesheet.light);
12868
+ this.light = new Light(this.stylesheet.light ?? {}, this._globalState);
13094
12869
  this._setProjectionInternal(this.stylesheet.projection?.type || "mercator");
13095
- this.sky = new Sky(this.stylesheet.sky);
12870
+ this.sky = new Sky(this.stylesheet.sky, this._globalState);
13096
12871
  this.map.setTerrain(this.stylesheet.terrain ?? null, { validate: false });
13097
12872
  this.fire(new MapStyleDataEvent("data"));
13098
12873
  this.fire(new MapStyleLoadEvent());
@@ -13938,7 +13713,7 @@ var Style = class extends Evented {
13938
13713
  this.sky.updateTransitions(parameters);
13939
13714
  }
13940
13715
  _setProjectionInternal(name) {
13941
- const projectionObjects = createProjectionFromName(name, this.map._camera?.transform.constrainOverride);
13716
+ const projectionObjects = createProjectionFromName(name, this.map._camera?.transform.constrainOverride, this._globalState);
13942
13717
  this.projection = projectionObjects.projection;
13943
13718
  this.map.migrateProjection(projectionObjects.transform, projectionObjects.cameraHelper);
13944
13719
  for (const key in this.tileManagers) this.tileManagers[key].reload();
@@ -14309,18 +14084,20 @@ const projectionUniforms = (context, locations) => ({
14309
14084
  "u_projection_tile_mercator_coords": new Uniform4f(context, locations.u_projection_tile_mercator_coords),
14310
14085
  "u_projection_clipping_plane": new Uniform4f(context, locations.u_projection_clipping_plane),
14311
14086
  "u_projection_transition": new Uniform1f(context, locations.u_projection_transition),
14312
- "u_projection_fallback_matrix": new UniformMatrix4f(context, locations.u_projection_fallback_matrix)
14087
+ "u_projection_fallback_matrix": new UniformMatrix4f(context, locations.u_projection_fallback_matrix),
14088
+ "u_projection_clip_antimeridian": new Uniform1i(context, locations.u_projection_clip_antimeridian)
14313
14089
  });
14314
14090
  /**
14315
- * Maps a field name in {@link ProjectionData} to its corresponding uniform name in {@link ProjectionPreludeUniformsType}.
14091
+ * Converts a {@link ProjectionData} object into the values expected by the projection prelude's uniforms.
14316
14092
  */
14317
- const projectionObjectToUniformMap = {
14318
- mainMatrix: "u_projection_matrix",
14319
- tileMercatorCoords: "u_projection_tile_mercator_coords",
14320
- clippingPlane: "u_projection_clipping_plane",
14321
- projectionTransition: "u_projection_transition",
14322
- fallbackMatrix: "u_projection_fallback_matrix"
14323
- };
14093
+ const projectionUniformValues = (projectionData) => ({
14094
+ "u_projection_matrix": projectionData.mainMatrix,
14095
+ "u_projection_tile_mercator_coords": projectionData.tileMercatorCoords,
14096
+ "u_projection_clipping_plane": projectionData.clippingPlane,
14097
+ "u_projection_transition": projectionData.projectionTransition,
14098
+ "u_projection_fallback_matrix": projectionData.fallbackMatrix,
14099
+ "u_projection_clip_antimeridian": projectionData.clipAntimeridian ? 1 : 0
14100
+ });
14324
14101
  //#endregion
14325
14102
  //#region src/webgl/program.ts
14326
14103
  function getTokenizedAttributesAndUniforms(array) {
@@ -14412,9 +14189,9 @@ var Program = class {
14412
14189
  gl.bindTexture(gl.TEXTURE_2D, terrain.texture);
14413
14190
  for (const name in this.terrainUniforms) this.terrainUniforms[name].set(terrain[name]);
14414
14191
  }
14415
- if (projectionData) for (const fieldName in projectionData) {
14416
- const uniformName = projectionObjectToUniformMap[fieldName];
14417
- this.projectionUniforms[uniformName].set(projectionData[fieldName]);
14192
+ if (projectionData) {
14193
+ const values = projectionUniformValues(projectionData);
14194
+ for (const name in this.projectionUniforms) this.projectionUniforms[name].set(values[name]);
14418
14195
  }
14419
14196
  if (uniformValues) for (const name in this.fixedUniforms) this.fixedUniforms[name].set(uniformValues[name]);
14420
14197
  if (configuration) configuration.setUniforms(context, this.binderUniforms, currentProperties, { zoom });
@@ -15173,7 +14950,6 @@ const programUniforms = {
15173
14950
  terrain: terrainUniforms,
15174
14951
  terrainDepth: terrainDepthUniforms,
15175
14952
  terrainCoords: terrainCoordsUniforms,
15176
- projectionErrorMeasurement: projectionErrorMeasurementUniforms,
15177
14953
  atmosphere: atmosphereUniforms,
15178
14954
  sky: skyUniforms
15179
14955
  };
@@ -15762,6 +15538,37 @@ var Framebuffer = class {
15762
15538
  }
15763
15539
  };
15764
15540
  //#endregion
15541
+ //#region src/webgl/color_mode.ts
15542
+ const ZERO = 0;
15543
+ const ONE = 1;
15544
+ const ONE_MINUS_SRC_ALPHA = 771;
15545
+ var ColorMode = class {
15546
+ constructor(blendFunction, blendColor, mask) {
15547
+ this.blendFunction = blendFunction;
15548
+ this.blendColor = blendColor;
15549
+ this.mask = mask;
15550
+ }
15551
+ };
15552
+ ColorMode.Replace = [ONE, ZERO];
15553
+ ColorMode.disabled = new ColorMode(ColorMode.Replace, Color.transparent, [
15554
+ false,
15555
+ false,
15556
+ false,
15557
+ false
15558
+ ]);
15559
+ ColorMode.unblended = new ColorMode(ColorMode.Replace, Color.transparent, [
15560
+ true,
15561
+ true,
15562
+ true,
15563
+ true
15564
+ ]);
15565
+ ColorMode.alphaBlended = new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [
15566
+ true,
15567
+ true,
15568
+ true,
15569
+ true
15570
+ ]);
15571
+ //#endregion
15765
15572
  //#region src/webgl/context.ts
15766
15573
  /**
15767
15574
  * @internal
@@ -15965,6 +15772,52 @@ var Context = class {
15965
15772
  }
15966
15773
  };
15967
15774
  //#endregion
15775
+ //#region src/webgl/depth_mode.ts
15776
+ const ALWAYS$1 = 519;
15777
+ var DepthMode = class {
15778
+ constructor(depthFunc, depthMask, depthRange) {
15779
+ this.func = depthFunc;
15780
+ this.mask = depthMask;
15781
+ this.range = depthRange;
15782
+ }
15783
+ };
15784
+ DepthMode.ReadOnly = false;
15785
+ DepthMode.ReadWrite = true;
15786
+ DepthMode.disabled = new DepthMode(ALWAYS$1, DepthMode.ReadOnly, [0, 1]);
15787
+ //#endregion
15788
+ //#region src/webgl/stencil_mode.ts
15789
+ const ALWAYS = 519;
15790
+ const KEEP = 7680;
15791
+ var StencilMode = class {
15792
+ constructor(test, ref, mask, fail, depthFail, pass) {
15793
+ this.test = test;
15794
+ this.ref = ref;
15795
+ this.mask = mask;
15796
+ this.fail = fail;
15797
+ this.depthFail = depthFail;
15798
+ this.pass = pass;
15799
+ }
15800
+ };
15801
+ StencilMode.disabled = new StencilMode({
15802
+ func: ALWAYS,
15803
+ mask: 0
15804
+ }, 0, 0, KEEP, KEEP, KEEP);
15805
+ //#endregion
15806
+ //#region src/webgl/cull_face_mode.ts
15807
+ const FRONT = 1028;
15808
+ const BACK = 1029;
15809
+ const CCW = 2305;
15810
+ var CullFaceMode = class {
15811
+ constructor(enable, mode, frontFace) {
15812
+ this.enable = enable;
15813
+ this.mode = mode;
15814
+ this.frontFace = frontFace;
15815
+ }
15816
+ };
15817
+ CullFaceMode.disabled = new CullFaceMode(false, BACK, CCW);
15818
+ CullFaceMode.backCCW = new CullFaceMode(true, BACK, CCW);
15819
+ CullFaceMode.frontCCW = new CullFaceMode(true, FRONT, CCW);
15820
+ //#endregion
15968
15821
  //#region src/webgl/draw/draw_collision_debug.ts
15969
15822
  let quadTriangles;
15970
15823
  function drawCollisionDebug(painter, tileManager, layer, coords, isText) {
@@ -17733,7 +17586,8 @@ var Painter = class Painter {
17733
17586
  0
17734
17587
  ],
17735
17588
  projectionTransition: 0,
17736
- fallbackMatrix: matrix
17589
+ fallbackMatrix: matrix,
17590
+ clipAntimeridian: false
17737
17591
  };
17738
17592
  this.useProgram("clippingMask", null, true).draw(context, gl.TRIANGLES, DepthMode.disabled, this.stencilClearMode, ColorMode.disabled, CullFaceMode.disabled, null, null, projectionData, "$clipping", this.viewportBuffer, this.quadTriangleIndexBuffer, this.viewportSegments);
17739
17593
  }
@@ -17942,10 +17796,6 @@ var Painter = class Painter {
17942
17796
  if (layer.type !== "custom" && !coords.length) continue;
17943
17797
  this.renderLayer(this, tileManagers[layer.source], layer, coords, renderOptions);
17944
17798
  }
17945
- this.style.projection?.updateGPUdependent({
17946
- context: this.context,
17947
- useProgram: (name) => this.useProgram(name)
17948
- });
17949
17799
  this.context.viewport.set([
17950
17800
  0,
17951
17801
  0,
@@ -19037,13 +18887,13 @@ function generateMousePanHandler({ enable, clickTolerance }) {
19037
18887
  assignEvents
19038
18888
  });
19039
18889
  }
19040
- function generateMouseRotationHandler({ enable, clickTolerance, aroundCenter = true, minPixelCenterThreshold = 100, rotateDegreesPerPixelMoved = .8 }, getCenter) {
18890
+ function generateMouseRotationHandler({ enable, clickTolerance, aroundCenter = true, minPixelCenterThreshold = 100, rotateSpeed = .8 }, getCenter) {
19041
18891
  return new DragHandler({
19042
18892
  clickTolerance,
19043
18893
  move: (lastPoint, currentPoint) => {
19044
18894
  const center = getCenter();
19045
18895
  if (aroundCenter && Math.abs(center.y - lastPoint.y) > minPixelCenterThreshold) return { bearingDelta: getAngleDelta(new Point(lastPoint.x, currentPoint.y), currentPoint, center) };
19046
- let bearingDelta = (currentPoint.x - lastPoint.x) * rotateDegreesPerPixelMoved;
18896
+ let bearingDelta = (currentPoint.x - lastPoint.x) * rotateSpeed;
19047
18897
  if (aroundCenter && currentPoint.y < center.y) bearingDelta = -bearingDelta;
19048
18898
  return { bearingDelta };
19049
18899
  },
@@ -19052,10 +18902,10 @@ function generateMouseRotationHandler({ enable, clickTolerance, aroundCenter = t
19052
18902
  assignEvents
19053
18903
  });
19054
18904
  }
19055
- function generateMousePitchHandler({ enable, clickTolerance, pitchDegreesPerPixelMoved = -.5 }) {
18905
+ function generateMousePitchHandler({ enable, clickTolerance, pitchSpeed = -.5 }) {
19056
18906
  return new DragHandler({
19057
18907
  clickTolerance,
19058
- move: (lastPoint, point) => ({ pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved }),
18908
+ move: (lastPoint, point) => ({ pitchDelta: (point.y - lastPoint.y) * pitchSpeed }),
19059
18909
  moveStateManager: new MouseMoveStateManager({ checkCorrectEvent: (e) => e.button === LEFT_BUTTON && e.ctrlKey || e.button === RIGHT_BUTTON }),
19060
18910
  enable,
19061
18911
  assignEvents
@@ -22508,6 +22358,8 @@ const defaultOptions$4 = {
22508
22358
  localIdeographFontFamily: "sans-serif",
22509
22359
  pitchWithRotate: true,
22510
22360
  rollEnabled: false,
22361
+ rotateSpeed: .8,
22362
+ pitchSpeed: -.5,
22511
22363
  reduceMotion: void 0,
22512
22364
  validateStyle: true,
22513
22365
  /**Because GL MAX_TEXTURE_SIZE is usually at least 4096px. */
@@ -24439,6 +24291,7 @@ var Map$1 = class extends Evented {
24439
24291
  if (thisLayer.type === "hillshade" && thisLayer.source === options.source) warnOnce("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");
24440
24292
  if (thisLayer.type === "color-relief" && thisLayer.source === options.source) warnOnce("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");
24441
24293
  }
24294
+ if (this.terrain) this.terrain.destroy();
24442
24295
  this.terrain = new Terrain(this.painter, tileManager, options, this._terrainSkirtLength);
24443
24296
  this.painter.renderToTexture = new RenderToTexture(this.painter, this.terrain);
24444
24297
  this._camera.terrain = this.terrain;
@@ -25546,8 +25399,7 @@ var Map$1 = class extends Evented {
25546
25399
  this.style.update(parameters);
25547
25400
  }
25548
25401
  const globeRenderingChanged = this.style.projection?.transitionState > 0 !== isGlobeRendering;
25549
- this.style.projection?.setErrorQueryLatitudeDegrees(this._camera.transform.center.lat);
25550
- this._camera.transform.setTransitionState(this.style.projection?.transitionState, this.style.projection?.latitudeErrorCorrectionRadians);
25402
+ this._camera.transform.setTransitionState(this.style.projection?.transitionState);
25551
25403
  if (this.style && (this._sourcesDirty || globeRenderingChanged)) {
25552
25404
  this._sourcesDirty = false;
25553
25405
  this.style._updateSources(this._camera.transform);
@@ -26203,6 +26055,7 @@ var Marker = class extends Evented {
26203
26055
  this._clickTolerance = options?.clickTolerance || 0;
26204
26056
  this._subpixelPositioning = options?.subpixelPositioning || false;
26205
26057
  this._isDragging = false;
26058
+ this._roleManaged = false;
26206
26059
  this._state = "inactive";
26207
26060
  this._rotation = options?.rotation || 0;
26208
26061
  this._rotationAlignment = options?.rotationAlignment || "auto";
@@ -26337,8 +26190,8 @@ var Marker = class extends Evented {
26337
26190
  addTo(map) {
26338
26191
  this.remove();
26339
26192
  this._map = map;
26340
- if (!this._element.hasAttribute("aria-label")) this._element.setAttribute("aria-label", map._getUIString("Marker.Title"));
26341
- if (!this._element.hasAttribute("role")) this._element.setAttribute("role", "button");
26193
+ if (this._defaultMarker && !this._element.hasAttribute("aria-label")) this._element.setAttribute("aria-label", map._getUIString("Marker.Title"));
26194
+ this._updateAccessibilityRole();
26342
26195
  map.getCanvasContainer().appendChild(this._element);
26343
26196
  map.on("move", this._update);
26344
26197
  map.on("moveend", this._update);
@@ -26470,6 +26323,7 @@ var Marker = class extends Evented {
26470
26323
  if (!this._originalTabIndex) this._element.setAttribute("tabindex", "0");
26471
26324
  this._element.addEventListener("keypress", this._onKeyPress);
26472
26325
  }
26326
+ this._updateAccessibilityRole();
26473
26327
  return this;
26474
26328
  }
26475
26329
  /**
@@ -26628,6 +26482,7 @@ var Marker = class extends Evented {
26628
26482
  */
26629
26483
  setDraggable(shouldBeDraggable) {
26630
26484
  this._draggable = !!shouldBeDraggable;
26485
+ this._element.classList.toggle("maplibregl-marker-draggable", this._draggable);
26631
26486
  if (this._map) if (shouldBeDraggable) {
26632
26487
  this._map.on("mousedown", this._addDragHandler);
26633
26488
  this._map.on("touchstart", this._addDragHandler);
@@ -26635,6 +26490,7 @@ var Marker = class extends Evented {
26635
26490
  this._map.off("mousedown", this._addDragHandler);
26636
26491
  this._map.off("touchstart", this._addDragHandler);
26637
26492
  }
26493
+ this._updateAccessibilityRole();
26638
26494
  return this;
26639
26495
  }
26640
26496
  /**
@@ -26645,6 +26501,21 @@ var Marker = class extends Evented {
26645
26501
  return this._draggable;
26646
26502
  }
26647
26503
  /**
26504
+ * Keep the default marker role aligned with interactivity.
26505
+ * Default markers need a role because `aria-label` is set in {@link Marker.addTo}.
26506
+ * Non-interactive markers use `role=img`; interactive ones (draggable or with a popup) use `role=button`.
26507
+ * Click listeners are application-owned and do not automatically change the role.
26508
+ * Custom marker elements are left alone so applications own their a11y tree.
26509
+ * Explicit roles set by the application are preserved.
26510
+ */
26511
+ _updateAccessibilityRole() {
26512
+ if (!this._defaultMarker) return;
26513
+ if (this._element.hasAttribute("role") && !this._roleManaged) return;
26514
+ const role = this._draggable || !!this._popup ? "button" : "img";
26515
+ this._element.setAttribute("role", role);
26516
+ this._roleManaged = true;
26517
+ }
26518
+ /**
26648
26519
  * Sets the `rotation` property of the marker.
26649
26520
  * @param rotation - The rotation angle of the marker (clockwise, in degrees), relative to its respective {@link Marker.setRotationAlignment} setting.
26650
26521
  */