@deck.gl/geo-layers 9.0.40 → 9.1.0-beta.3

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 (147) hide show
  1. package/dist/dist.dev.js +23224 -6553
  2. package/dist/geo-cell-layer/GeoCellLayer.d.ts.map +1 -1
  3. package/dist/geo-cell-layer/GeoCellLayer.js +4 -0
  4. package/dist/geo-cell-layer/GeoCellLayer.js.map +1 -0
  5. package/dist/geohash-layer/geohash-layer.d.ts.map +1 -1
  6. package/dist/geohash-layer/geohash-layer.js +4 -0
  7. package/dist/geohash-layer/geohash-layer.js.map +1 -0
  8. package/dist/geohash-layer/geohash-utils.d.ts.map +1 -1
  9. package/dist/geohash-layer/geohash-utils.js +4 -0
  10. package/dist/geohash-layer/geohash-utils.js.map +1 -0
  11. package/dist/great-circle-layer/great-circle-layer.d.ts.map +1 -1
  12. package/dist/great-circle-layer/great-circle-layer.js +4 -0
  13. package/dist/great-circle-layer/great-circle-layer.js.map +1 -0
  14. package/dist/h3-layers/h3-cluster-layer.d.ts.map +1 -1
  15. package/dist/h3-layers/h3-cluster-layer.js +4 -0
  16. package/dist/h3-layers/h3-cluster-layer.js.map +1 -0
  17. package/dist/h3-layers/h3-hexagon-layer.d.ts.map +1 -1
  18. package/dist/h3-layers/h3-hexagon-layer.js +4 -0
  19. package/dist/h3-layers/h3-hexagon-layer.js.map +1 -0
  20. package/dist/h3-layers/h3-utils.d.ts.map +1 -1
  21. package/dist/h3-layers/h3-utils.js +4 -0
  22. package/dist/h3-layers/h3-utils.js.map +1 -0
  23. package/dist/index.cjs +175 -50
  24. package/dist/index.cjs.map +4 -4
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -19
  27. package/dist/index.js.map +1 -0
  28. package/dist/mesh-layer/mesh-layer-fragment.glsl.d.ts +1 -1
  29. package/dist/mesh-layer/mesh-layer-fragment.glsl.d.ts.map +1 -1
  30. package/dist/mesh-layer/mesh-layer-fragment.glsl.js +9 -8
  31. package/dist/mesh-layer/mesh-layer-fragment.glsl.js.map +1 -0
  32. package/dist/mesh-layer/mesh-layer-uniforms.d.ts +12 -0
  33. package/dist/mesh-layer/mesh-layer-uniforms.d.ts.map +1 -0
  34. package/dist/mesh-layer/mesh-layer-uniforms.js +17 -0
  35. package/dist/mesh-layer/mesh-layer-uniforms.js.map +1 -0
  36. package/dist/mesh-layer/mesh-layer-vertex.glsl.d.ts +1 -1
  37. package/dist/mesh-layer/mesh-layer-vertex.glsl.d.ts.map +1 -1
  38. package/dist/mesh-layer/mesh-layer-vertex.glsl.js +8 -7
  39. package/dist/mesh-layer/mesh-layer-vertex.glsl.js.map +1 -0
  40. package/dist/mesh-layer/mesh-layer.d.ts +2 -2
  41. package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
  42. package/dist/mesh-layer/mesh-layer.js +36 -16
  43. package/dist/mesh-layer/mesh-layer.js.map +1 -0
  44. package/dist/mvt-layer/coordinate-transform.d.ts.map +1 -1
  45. package/dist/mvt-layer/coordinate-transform.js +4 -0
  46. package/dist/mvt-layer/coordinate-transform.js.map +1 -0
  47. package/dist/mvt-layer/find-index-binary.d.ts.map +1 -1
  48. package/dist/mvt-layer/find-index-binary.js +4 -0
  49. package/dist/mvt-layer/find-index-binary.js.map +1 -0
  50. package/dist/mvt-layer/mvt-layer.d.ts.map +1 -1
  51. package/dist/mvt-layer/mvt-layer.js +4 -0
  52. package/dist/mvt-layer/mvt-layer.js.map +1 -0
  53. package/dist/quadkey-layer/quadkey-layer.d.ts.map +1 -1
  54. package/dist/quadkey-layer/quadkey-layer.js +4 -0
  55. package/dist/quadkey-layer/quadkey-layer.js.map +1 -0
  56. package/dist/quadkey-layer/quadkey-utils.d.ts.map +1 -1
  57. package/dist/quadkey-layer/quadkey-utils.js +4 -0
  58. package/dist/quadkey-layer/quadkey-utils.js.map +1 -0
  59. package/dist/s2-layer/s2-geometry.d.ts.map +1 -1
  60. package/dist/s2-layer/s2-geometry.js +4 -0
  61. package/dist/s2-layer/s2-geometry.js.map +1 -0
  62. package/dist/s2-layer/s2-layer.d.ts.map +1 -1
  63. package/dist/s2-layer/s2-layer.js +4 -19
  64. package/dist/s2-layer/s2-layer.js.map +1 -0
  65. package/dist/s2-layer/s2-utils.d.ts.map +1 -1
  66. package/dist/s2-layer/s2-utils.js +4 -0
  67. package/dist/s2-layer/s2-utils.js.map +1 -0
  68. package/dist/terrain-layer/terrain-layer.d.ts.map +1 -1
  69. package/dist/terrain-layer/terrain-layer.js +4 -19
  70. package/dist/terrain-layer/terrain-layer.js.map +1 -0
  71. package/dist/tile-3d-layer/tile-3d-layer.d.ts +6 -6
  72. package/dist/tile-3d-layer/tile-3d-layer.d.ts.map +1 -1
  73. package/dist/tile-3d-layer/tile-3d-layer.js +4 -0
  74. package/dist/tile-3d-layer/tile-3d-layer.js.map +1 -0
  75. package/dist/tile-layer/tile-layer.d.ts.map +1 -1
  76. package/dist/tile-layer/tile-layer.js +4 -0
  77. package/dist/tile-layer/tile-layer.js.map +1 -0
  78. package/dist/tileset-2d/index.d.ts.map +1 -1
  79. package/dist/tileset-2d/index.js +4 -1
  80. package/dist/tileset-2d/index.js.map +1 -0
  81. package/dist/tileset-2d/memoize.d.ts.map +1 -1
  82. package/dist/tileset-2d/memoize.js +4 -0
  83. package/dist/tileset-2d/memoize.js.map +1 -0
  84. package/dist/tileset-2d/tile-2d-header.d.ts.map +1 -1
  85. package/dist/tileset-2d/tile-2d-header.js +4 -0
  86. package/dist/tileset-2d/tile-2d-header.js.map +1 -0
  87. package/dist/tileset-2d/tile-2d-traversal.d.ts.map +1 -1
  88. package/dist/tileset-2d/tile-2d-traversal.js +4 -0
  89. package/dist/tileset-2d/tile-2d-traversal.js.map +1 -0
  90. package/dist/tileset-2d/tileset-2d.d.ts.map +1 -1
  91. package/dist/tileset-2d/tileset-2d.js +7 -3
  92. package/dist/tileset-2d/tileset-2d.js.map +1 -0
  93. package/dist/tileset-2d/types.d.ts.map +1 -1
  94. package/dist/tileset-2d/types.js +4 -0
  95. package/dist/tileset-2d/types.js.map +1 -0
  96. package/dist/tileset-2d/utils.d.ts.map +1 -1
  97. package/dist/tileset-2d/utils.js +4 -0
  98. package/dist/tileset-2d/utils.js.map +1 -0
  99. package/dist/trips-layer/trips-layer-uniforms.d.ts +16 -0
  100. package/dist/trips-layer/trips-layer-uniforms.d.ts.map +1 -0
  101. package/dist/trips-layer/trips-layer-uniforms.js +21 -0
  102. package/dist/trips-layer/trips-layer-uniforms.js.map +1 -0
  103. package/dist/trips-layer/trips-layer.d.ts.map +1 -1
  104. package/dist/trips-layer/trips-layer.js +12 -32
  105. package/dist/trips-layer/trips-layer.js.map +1 -0
  106. package/dist/wms-layer/utils.d.ts.map +1 -1
  107. package/dist/wms-layer/utils.js +4 -0
  108. package/dist/wms-layer/utils.js.map +1 -0
  109. package/dist/wms-layer/wms-layer.d.ts.map +1 -1
  110. package/dist/wms-layer/wms-layer.js +4 -0
  111. package/dist/wms-layer/wms-layer.js.map +1 -0
  112. package/dist.min.js +530 -260
  113. package/package.json +13 -13
  114. package/src/geo-cell-layer/GeoCellLayer.ts +4 -0
  115. package/src/geohash-layer/geohash-layer.ts +4 -0
  116. package/src/geohash-layer/geohash-utils.ts +4 -0
  117. package/src/great-circle-layer/great-circle-layer.ts +4 -19
  118. package/src/h3-layers/h3-cluster-layer.ts +4 -0
  119. package/src/h3-layers/h3-hexagon-layer.ts +4 -0
  120. package/src/h3-layers/h3-utils.ts +4 -0
  121. package/src/index.ts +4 -19
  122. package/src/mesh-layer/mesh-layer-fragment.glsl.ts +9 -8
  123. package/src/mesh-layer/mesh-layer-uniforms.ts +24 -0
  124. package/src/mesh-layer/mesh-layer-vertex.glsl.ts +8 -9
  125. package/src/mesh-layer/mesh-layer.ts +37 -16
  126. package/src/mvt-layer/coordinate-transform.ts +4 -0
  127. package/src/mvt-layer/find-index-binary.ts +4 -0
  128. package/src/mvt-layer/mvt-layer.ts +4 -0
  129. package/src/quadkey-layer/quadkey-layer.ts +4 -0
  130. package/src/quadkey-layer/quadkey-utils.ts +4 -0
  131. package/src/s2-layer/s2-geometry.ts +4 -0
  132. package/src/s2-layer/s2-layer.ts +3 -19
  133. package/src/s2-layer/s2-utils.ts +4 -0
  134. package/src/terrain-layer/terrain-layer.ts +3 -19
  135. package/src/tile-3d-layer/tile-3d-layer.ts +4 -0
  136. package/src/tile-layer/tile-layer.ts +4 -0
  137. package/src/tileset-2d/index.ts +4 -0
  138. package/src/tileset-2d/memoize.ts +4 -0
  139. package/src/tileset-2d/tile-2d-header.ts +4 -0
  140. package/src/tileset-2d/tile-2d-traversal.ts +4 -0
  141. package/src/tileset-2d/tileset-2d.ts +7 -3
  142. package/src/tileset-2d/types.ts +4 -0
  143. package/src/tileset-2d/utils.ts +4 -0
  144. package/src/trips-layer/trips-layer-uniforms.ts +30 -0
  145. package/src/trips-layer/trips-layer.ts +12 -33
  146. package/src/wms-layer/utils.ts +4 -0
  147. package/src/wms-layer/wms-layer.ts +4 -0
package/dist/index.cjs CHANGED
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -69,6 +73,7 @@ var defaultProps = {
69
73
  layers: { type: "array", compare: true, value: [] },
70
74
  onMetadataLoad: { type: "function", value: () => {
71
75
  } },
76
+ // eslint-disable-next-line
72
77
  onMetadataLoadError: { type: "function", value: console.error },
73
78
  onImageLoadStart: { type: "function", value: () => {
74
79
  } },
@@ -77,14 +82,17 @@ var defaultProps = {
77
82
  onImageLoadError: {
78
83
  type: "function",
79
84
  compare: false,
85
+ // eslint-disable-next-line
80
86
  value: (requestId, error) => console.error(error, requestId)
81
87
  }
82
88
  };
83
89
  var WMSLayer = class extends import_core.CompositeLayer {
90
+ /** Returns true if all async resources are loaded */
84
91
  get isLoaded() {
85
92
  var _a;
86
93
  return ((_a = this.state) == null ? void 0 : _a.loadCounter) === 0 && super.isLoaded;
87
94
  }
95
+ /** Lets deck.gl know that we want viewport change events */
88
96
  shouldUpdateState() {
89
97
  return true;
90
98
  }
@@ -144,6 +152,7 @@ var WMSLayer = class extends import_core.CompositeLayer {
144
152
  }
145
153
  throw new Error("invalid image source in props.data");
146
154
  }
155
+ /** Run a getMetadata on the image service */
147
156
  async _loadMetadata() {
148
157
  var _a, _b;
149
158
  const { imageSource } = this.state;
@@ -159,6 +168,7 @@ var WMSLayer = class extends import_core.CompositeLayer {
159
168
  this.state.loadCounter--;
160
169
  }
161
170
  }
171
+ /** Load an image */
162
172
  async loadImage(viewport, reason) {
163
173
  var _a, _b;
164
174
  const { layers, serviceType } = this.props;
@@ -207,9 +217,12 @@ var WMSLayer = class extends import_core.CompositeLayer {
207
217
  this.state.loadCounter--;
208
218
  }
209
219
  }
220
+ // HELPERS
221
+ /** Global counter for issuing unique request ids */
210
222
  getRequestId() {
211
223
  return this.state._nextRequestId++;
212
224
  }
225
+ /** Runs an action in the future, cancels it if the new action is issued before it executes */
213
226
  debounce(fn, ms = 500) {
214
227
  clearTimeout(this.state._timeoutId);
215
228
  this.state._timeoutId = setTimeout(() => fn(), ms);
@@ -237,6 +250,7 @@ var defaultProps3 = {
237
250
  ...import_layers3.PolygonLayer.defaultProps
238
251
  };
239
252
  var GeoCellLayer = class extends import_core2.CompositeLayer {
253
+ /** Implement to generate props to create geometry. */
240
254
  indexToBounds() {
241
255
  return null;
242
256
  }
@@ -534,9 +548,11 @@ var Tile2DHeader = class {
534
548
  this._isCancelled = false;
535
549
  this._needsReload = false;
536
550
  }
551
+ /** @deprecated use `boundingBox` instead */
537
552
  get bbox() {
538
553
  return this._bbox;
539
554
  }
555
+ // TODO - remove in v9
540
556
  set bbox(value) {
541
557
  if (this._bbox)
542
558
  return;
@@ -572,6 +588,7 @@ var Tile2DHeader = class {
572
588
  }
573
589
  return result;
574
590
  }
591
+ /* eslint-disable max-statements */
575
592
  async _loadData({ getData, requestScheduler, onLoad, onError }) {
576
593
  const { index, id, bbox, userData, zoom } = this;
577
594
  const loaderId = this._loaderId;
@@ -682,6 +699,7 @@ var OSMNode = class {
682
699
  }
683
700
  return this._children;
684
701
  }
702
+ // eslint-disable-next-line complexity
685
703
  update(params) {
686
704
  const { viewport, cullingVolume, elevationBounds, minZ, maxZ, bounds, offset, project } = params;
687
705
  const boundingVolume = this.getBoundingVolume(elevationBounds, offset, project);
@@ -749,7 +767,10 @@ var OSMNode = class {
749
767
  }
750
768
  };
751
769
  function getOSMTileIndices(viewport, maxZ, zRange, bounds) {
752
- const project = viewport instanceof import_core3._GlobeViewport && viewport.resolution ? viewport.projectPosition : null;
770
+ const project = viewport instanceof import_core3._GlobeViewport && viewport.resolution ? (
771
+ // eslint-disable-next-line @typescript-eslint/unbound-method
772
+ viewport.projectPosition
773
+ ) : null;
753
774
  const planes = Object.values(viewport.getFrustumPlanes()).map(({ normal, distance }) => new import_culling.Plane(normal.clone().negate(), distance));
754
775
  const cullingVolume = new import_culling.CullingVolume(planes);
755
776
  const unitsPerMeter = viewport.distanceScales.unitsPerMeter[2];
@@ -771,6 +792,7 @@ function getOSMTileIndices(viewport, maxZ, zRange, bounds) {
771
792
  minZ,
772
793
  maxZ,
773
794
  bounds,
795
+ // num. of worlds from the center. For repeated maps
774
796
  offset: 0
775
797
  };
776
798
  root.update(traversalParams);
@@ -819,15 +841,23 @@ var urlType = {
819
841
  };
820
842
  function transformBox(bbox, modelMatrix) {
821
843
  const transformedCoords = [
844
+ // top-left
822
845
  modelMatrix.transformAsPoint([bbox[0], bbox[1]]),
846
+ // top-right
823
847
  modelMatrix.transformAsPoint([bbox[2], bbox[1]]),
848
+ // bottom-left
824
849
  modelMatrix.transformAsPoint([bbox[0], bbox[3]]),
850
+ // bottom-right
825
851
  modelMatrix.transformAsPoint([bbox[2], bbox[3]])
826
852
  ];
827
853
  const transformedBox = [
854
+ // Minimum x coord
828
855
  Math.min(...transformedCoords.map((i) => i[0])),
856
+ // Minimum y coord
829
857
  Math.min(...transformedCoords.map((i) => i[1])),
858
+ // Max x coord
830
859
  Math.max(...transformedCoords.map((i) => i[0])),
860
+ // Max y coord
831
861
  Math.max(...transformedCoords.map((i) => i[1]))
832
862
  ];
833
863
  return transformedBox;
@@ -871,8 +901,10 @@ function getBoundingBox(viewport, zRange, extent) {
871
901
  }
872
902
  if (!viewport.isGeospatial) {
873
903
  return [
904
+ // Top corner should not be more then bottom corner in either direction
874
905
  Math.max(Math.min(bounds[0], extent[2]), extent[0]),
875
906
  Math.max(Math.min(bounds[1], extent[3]), extent[1]),
907
+ // Bottom corner should not be less then top corner in either direction
876
908
  Math.min(Math.max(bounds[2], extent[0]), extent[2]),
877
909
  Math.min(Math.max(bounds[3], extent[1]), extent[3])
878
910
  ];
@@ -1040,6 +1072,8 @@ var DEFAULT_TILESET2D_PROPS = {
1040
1072
  maxRequests: 6,
1041
1073
  debounceTime: 0,
1042
1074
  zoomOffset: 0,
1075
+ // onTileLoad: (tile: Tile2DHeader) => void, // onTileUnload: (tile: Tile2DHeader) => void, // onTileError: (error: any, tile: Tile2DHeader) => void, /** Called when all tiles in the current viewport are loaded. */
1076
+ // onViewportLoad: ((tiles: Tile2DHeader<DataT>[]) => void) | null,
1043
1077
  onTileLoad: () => {
1044
1078
  },
1045
1079
  onTileUnload: () => {
@@ -1048,6 +1082,10 @@ var DEFAULT_TILESET2D_PROPS = {
1048
1082
  }
1049
1083
  };
1050
1084
  var Tileset2D = class {
1085
+ /**
1086
+ * Takes in a function that returns tile data, a cache size, and a max and a min zoom level.
1087
+ * Cache size defaults to 5 * number of tiles in the current viewport
1088
+ */
1051
1089
  constructor(opts) {
1052
1090
  this._getCullBounds = memoize(getCullBounds);
1053
1091
  this.opts = { ...DEFAULT_TILESET2D_PROPS, ...opts };
@@ -1055,7 +1093,7 @@ var Tileset2D = class {
1055
1093
  this.onTileLoad = (tile) => {
1056
1094
  var _a, _b;
1057
1095
  (_b = (_a = this.opts).onTileLoad) == null ? void 0 : _b.call(_a, tile);
1058
- if (this.opts.maxCacheByteSize != null) {
1096
+ if (this.opts.maxCacheByteSize !== null) {
1059
1097
  this._cacheByteSize += tile.byteLength;
1060
1098
  this._resizeCache();
1061
1099
  }
@@ -1076,6 +1114,7 @@ var Tileset2D = class {
1076
1114
  this._modelMatrix = new import_core4.Matrix4();
1077
1115
  this._modelMatrixInverse = new import_core4.Matrix4();
1078
1116
  }
1117
+ /* Public API */
1079
1118
  get tiles() {
1080
1119
  return this._tiles;
1081
1120
  }
@@ -1097,6 +1136,7 @@ var Tileset2D = class {
1097
1136
  this._minZoom = Math.ceil(opts.minZoom);
1098
1137
  }
1099
1138
  }
1139
+ // Clean up any outstanding tile requests.
1100
1140
  finalize() {
1101
1141
  for (const tile of this._cache.values()) {
1102
1142
  if (tile.isLoading) {
@@ -1117,6 +1157,9 @@ var Tileset2D = class {
1117
1157
  }
1118
1158
  }
1119
1159
  }
1160
+ /**
1161
+ * Update the cache with the given viewport and model matrix and triggers callback onUpdate.
1162
+ */
1120
1163
  update(viewport, { zRange, modelMatrix } = {
1121
1164
  zRange: null,
1122
1165
  modelMatrix: null
@@ -1155,6 +1198,7 @@ var Tileset2D = class {
1155
1198
  }
1156
1199
  return this._frameNumber;
1157
1200
  }
1201
+ // eslint-disable-next-line complexity
1158
1202
  isTileVisible(tile, cullRect) {
1159
1203
  if (!tile.isVisible) {
1160
1204
  return false;
@@ -1183,6 +1227,8 @@ var Tileset2D = class {
1183
1227
  }
1184
1228
  return true;
1185
1229
  }
1230
+ /* Public interface for subclassing */
1231
+ /** Returns array of tile indices in the current viewport */
1186
1232
  getTileIndices({ viewport, maxZoom, minZoom, zRange, modelMatrix, modelMatrixInverse }) {
1187
1233
  const { tileSize, extent, zoomOffset } = this.opts;
1188
1234
  return getTileIndices({
@@ -1197,22 +1243,27 @@ var Tileset2D = class {
1197
1243
  zoomOffset
1198
1244
  });
1199
1245
  }
1246
+ /** Returns unique string key for a tile index */
1200
1247
  getTileId(index) {
1201
1248
  return `${index.x}-${index.y}-${index.z}`;
1202
1249
  }
1250
+ /** Returns a zoom level for a tile index */
1203
1251
  getTileZoom(index) {
1204
1252
  return index.z;
1205
1253
  }
1254
+ /** Returns additional metadata to add to tile, bbox by default */
1206
1255
  getTileMetadata(index) {
1207
1256
  const { tileSize } = this.opts;
1208
1257
  return { bbox: tileToBoundingBox(this._viewport, index.x, index.y, index.z, tileSize) };
1209
1258
  }
1259
+ /** Returns index of the parent tile */
1210
1260
  getParentIndex(index) {
1211
1261
  const x = Math.floor(index.x / 2);
1212
1262
  const y = Math.floor(index.y / 2);
1213
1263
  const z = index.z - 1;
1214
1264
  return { x, y, z };
1215
1265
  }
1266
+ // Returns true if any tile's visibility changed
1216
1267
  updateTileStates() {
1217
1268
  const refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
1218
1269
  const visibilities = new Array(this._cache.size);
@@ -1253,6 +1304,7 @@ var Tileset2D = class {
1253
1304
  ongoingRequestCount--;
1254
1305
  }
1255
1306
  }
1307
+ // This needs to be called every time some tiles have been added/removed from cache
1256
1308
  _rebuildTree() {
1257
1309
  const { _cache } = this;
1258
1310
  for (const tile of _cache.values()) {
@@ -1269,16 +1321,21 @@ var Tileset2D = class {
1269
1321
  }
1270
1322
  }
1271
1323
  }
1324
+ /**
1325
+ * Clear tiles that are not visible when the cache is full
1326
+ */
1327
+ /* eslint-disable complexity */
1272
1328
  _resizeCache() {
1273
1329
  var _a, _b;
1274
1330
  const { _cache, opts } = this;
1275
- const maxCacheSize = opts.maxCacheSize ?? (opts.maxCacheByteSize != null ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
1331
+ const maxCacheSize = opts.maxCacheSize ?? // @ts-expect-error called only when selectedTiles is initialized
1332
+ (opts.maxCacheByteSize !== null ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
1276
1333
  const maxCacheByteSize = opts.maxCacheByteSize ?? Infinity;
1277
1334
  const overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;
1278
1335
  if (overflown) {
1279
1336
  for (const [id, tile] of _cache) {
1280
1337
  if (!tile.isVisible && !tile.isSelected) {
1281
- this._cacheByteSize -= opts.maxCacheByteSize != null ? tile.byteLength : 0;
1338
+ this._cacheByteSize -= opts.maxCacheByteSize !== null ? tile.byteLength : 0;
1282
1339
  _cache.delete(id);
1283
1340
  (_b = (_a = this.opts).onTileUnload) == null ? void 0 : _b.call(_a, tile);
1284
1341
  }
@@ -1393,11 +1450,13 @@ var defaultProps6 = {
1393
1450
  dataComparator: urlType.equal,
1394
1451
  renderSubLayers: { type: "function", value: (props) => new import_layers4.GeoJsonLayer(props) },
1395
1452
  getTileData: { type: "function", optional: true, value: null },
1453
+ // TODO - change to onViewportLoad to align with Tile3DLayer
1396
1454
  onViewportLoad: { type: "function", optional: true, value: null },
1397
1455
  onTileLoad: { type: "function", value: (tile) => {
1398
1456
  } },
1399
1457
  onTileUnload: { type: "function", value: (tile) => {
1400
1458
  } },
1459
+ // eslint-disable-next-line
1401
1460
  onTileError: { type: "function", value: (err) => console.error(err) },
1402
1461
  extent: { type: "array", optional: true, value: null, compare: true },
1403
1462
  tileSize: 512,
@@ -1502,6 +1561,7 @@ var TileLayer = class extends import_core5.CompositeLayer {
1502
1561
  _onTileUnload(tile) {
1503
1562
  this.props.onTileUnload(tile);
1504
1563
  }
1564
+ // Methods for subclass to override
1505
1565
  getTileData(tile) {
1506
1566
  const { data, getTileData, fetch } = this.props;
1507
1567
  const { signal } = tile;
@@ -1570,6 +1630,26 @@ var tile_layer_default = TileLayer;
1570
1630
 
1571
1631
  // dist/trips-layer/trips-layer.js
1572
1632
  var import_layers5 = require("@deck.gl/layers");
1633
+
1634
+ // dist/trips-layer/trips-layer-uniforms.js
1635
+ var uniformBlock = `uniform tripsUniforms {
1636
+ bool fadeTrail;
1637
+ float trailLength;
1638
+ float currentTime;
1639
+ } trips;
1640
+ `;
1641
+ var tripsUniforms = {
1642
+ name: "trips",
1643
+ vs: uniformBlock,
1644
+ fs: uniformBlock,
1645
+ uniformTypes: {
1646
+ fadeTrail: "f32",
1647
+ trailLength: "f32",
1648
+ currentTime: "f32"
1649
+ }
1650
+ };
1651
+
1652
+ // dist/trips-layer/trips-layer.js
1573
1653
  var defaultProps7 = {
1574
1654
  fadeTrail: true,
1575
1655
  trailLength: { type: "number", value: 120, min: 0 },
@@ -1580,27 +1660,27 @@ var TripsLayer = class extends import_layers5.PathLayer {
1580
1660
  getShaders() {
1581
1661
  const shaders = super.getShaders();
1582
1662
  shaders.inject = {
1583
- "vs:#decl": `uniform float trailLength;
1584
- in float instanceTimestamps;
1663
+ "vs:#decl": `in float instanceTimestamps;
1585
1664
  in float instanceNextTimestamps;
1586
1665
  out float vTime;
1587
1666
  `,
1667
+ // Timestamp of the vertex
1588
1668
  "vs:#main-end": `vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
1589
1669
  `,
1590
- "fs:#decl": `uniform bool fadeTrail;
1591
- uniform float trailLength;
1592
- uniform float currentTime;
1593
- in float vTime;
1670
+ "fs:#decl": `in float vTime;
1594
1671
  `,
1595
- "fs:#main-start": `if(vTime > currentTime || (fadeTrail && (vTime < currentTime - trailLength))) {
1672
+ // Drop the segments outside of the time window
1673
+ "fs:#main-start": `if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {
1596
1674
  discard;
1597
1675
  }
1598
1676
  `,
1599
- "fs:DECKGL_FILTER_COLOR": `if(fadeTrail) {
1600
- color.a *= 1.0 - (currentTime - vTime) / trailLength;
1677
+ // Fade the color (currentTime - 100%, end of trail - 0%)
1678
+ "fs:DECKGL_FILTER_COLOR": `if(trips.fadeTrail) {
1679
+ color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
1601
1680
  }
1602
1681
  `
1603
1682
  };
1683
+ shaders.modules = [...shaders.modules, tripsUniforms];
1604
1684
  return shaders;
1605
1685
  }
1606
1686
  initializeState() {
@@ -1623,12 +1703,9 @@ in float vTime;
1623
1703
  }
1624
1704
  draw(params) {
1625
1705
  const { fadeTrail, trailLength, currentTime } = this.props;
1626
- params.uniforms = {
1627
- ...params.uniforms,
1628
- fadeTrail,
1629
- trailLength,
1630
- currentTime
1631
- };
1706
+ const tripsProps = { fadeTrail, trailLength, currentTime };
1707
+ const model = this.state.model;
1708
+ model.shaderInputs.setProps({ trips: tripsProps });
1632
1709
  super.draw(params);
1633
1710
  }
1634
1711
  };
@@ -1864,6 +1941,7 @@ var H3HexagonLayer = class extends import_core7.CompositeLayer {
1864
1941
  }), {
1865
1942
  data,
1866
1943
  diskResolution: 6,
1944
+ // generate an extruded hexagon as the base geometry
1867
1945
  radius: 1,
1868
1946
  vertices: this.state.vertices,
1869
1947
  getPosition: getHexagonCentroid.bind(null, getHexagon)
@@ -1931,12 +2009,23 @@ var import_shadertools = require("@luma.gl/shadertools");
1931
2009
  var import_engine = require("@luma.gl/engine");
1932
2010
  var import_mesh_layers = require("@deck.gl/mesh-layers");
1933
2011
 
2012
+ // dist/mesh-layer/mesh-layer-uniforms.js
2013
+ var uniformBlock2 = `uniform meshUniforms {
2014
+ bool pickFeatureIds;
2015
+ } mesh;
2016
+ `;
2017
+ var meshUniforms = {
2018
+ name: "mesh",
2019
+ vs: uniformBlock2,
2020
+ fs: uniformBlock2,
2021
+ uniformTypes: {
2022
+ pickFeatureIds: "f32"
2023
+ }
2024
+ };
2025
+
1934
2026
  // dist/mesh-layer/mesh-layer-vertex.glsl.js
1935
2027
  var mesh_layer_vertex_glsl_default = `#version 300 es
1936
2028
  #define SHADER_NAME simple-mesh-layer-vs
1937
- uniform float sizeScale;
1938
- uniform bool composeModelMatrix;
1939
- uniform bool pickFeatureIds;
1940
2029
  in vec3 positions;
1941
2030
  in vec3 normals;
1942
2031
  in vec3 colors;
@@ -1963,16 +2052,16 @@ return uv;
1963
2052
  void main(void) {
1964
2053
  vec2 uv = applyUVRegion(texCoords);
1965
2054
  geometry.uv = uv;
1966
- if (pickFeatureIds) {
2055
+ if (mesh.pickFeatureIds) {
1967
2056
  geometry.pickingColor = featureIdsPickingColors;
1968
2057
  } else {
1969
2058
  geometry.pickingColor = instancePickingColors;
1970
2059
  }
1971
2060
  mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
1972
2061
  vTexCoord = uv;
1973
- cameraPosition = project_uCameraPosition;
2062
+ cameraPosition = project.cameraPosition;
1974
2063
  vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
1975
- vec3 pos = (instanceModelMatrix * positions) * sizeScale;
2064
+ vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale;
1976
2065
  vec3 projectedPosition = project_position(positions);
1977
2066
  position_commonspace = vec4(projectedPosition, 1.0);
1978
2067
  gl_Position = project_common_position_to_clipspace(position_commonspace);
@@ -1980,7 +2069,7 @@ geometry.position = position_commonspace;
1980
2069
  normals_commonspace = project_normal(instanceModelMatrix * normals);
1981
2070
  geometry.normal = normals_commonspace;
1982
2071
  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
1983
- #ifdef MODULE_PBR
2072
+ #ifdef MODULE_PBRMATERIAL
1984
2073
  pbr_vPosition = geometry.position.xyz;
1985
2074
  #ifdef HAS_NORMALS
1986
2075
  pbr_vNormal = geometry.normal;
@@ -2000,10 +2089,7 @@ DECKGL_FILTER_COLOR(vColor, geometry);
2000
2089
  var mesh_layer_fragment_glsl_default = `#version 300 es
2001
2090
  #define SHADER_NAME simple-mesh-layer-fs
2002
2091
  precision highp float;
2003
- uniform bool hasTexture;
2004
2092
  uniform sampler2D sampler;
2005
- uniform bool flatShading;
2006
- uniform float opacity;
2007
2093
  in vec2 vTexCoord;
2008
2094
  in vec3 cameraPosition;
2009
2095
  in vec3 normals_commonspace;
@@ -2011,21 +2097,21 @@ in vec4 position_commonspace;
2011
2097
  in vec4 vColor;
2012
2098
  out vec4 fragColor;
2013
2099
  void main(void) {
2014
- #ifdef MODULE_PBR
2100
+ #ifdef MODULE_PBRMATERIAL
2015
2101
  fragColor = vColor * pbr_filterColor(vec4(0));
2016
2102
  geometry.uv = pbr_vUV;
2017
- fragColor.a *= opacity;
2103
+ fragColor.a *= layer.opacity;
2018
2104
  #else
2019
2105
  geometry.uv = vTexCoord;
2020
2106
  vec3 normal;
2021
- if (flatShading) {
2107
+ if (simpleMesh.flatShading) {
2022
2108
  normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
2023
2109
  } else {
2024
2110
  normal = normals_commonspace;
2025
2111
  }
2026
- vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
2112
+ vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
2027
2113
  vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
2028
- fragColor = vec4(lightColor, color.a * opacity);
2114
+ fragColor = vec4(lightColor, color.a * layer.opacity);
2029
2115
  #endif
2030
2116
  DECKGL_FILTER_COLOR(fragColor, geometry);
2031
2117
  }
@@ -2052,7 +2138,7 @@ var MeshLayer = class extends import_mesh_layers.SimpleMeshLayer {
2052
2138
  getShaders() {
2053
2139
  const shaders = super.getShaders();
2054
2140
  const modules = shaders.modules;
2055
- modules.push(import_shadertools.pbr);
2141
+ modules.push(import_shadertools.pbrMaterial, meshUniforms);
2056
2142
  return { ...shaders, vs: mesh_layer_vertex_glsl_default, fs: mesh_layer_fragment_glsl_default };
2057
2143
  }
2058
2144
  initializeState() {
@@ -2065,6 +2151,7 @@ var MeshLayer = class extends import_mesh_layers.SimpleMeshLayer {
2065
2151
  type: "uint8",
2066
2152
  size: 3,
2067
2153
  noAlloc: true,
2154
+ // eslint-disable-next-line @typescript-eslint/unbound-method
2068
2155
  update: this.calculateFeatureIdsPickingColors
2069
2156
  }
2070
2157
  });
@@ -2079,18 +2166,26 @@ var MeshLayer = class extends import_mesh_layers.SimpleMeshLayer {
2079
2166
  }
2080
2167
  draw(opts) {
2081
2168
  const { featureIds } = this.props;
2082
- if (!this.state.model) {
2169
+ const { model } = this.state;
2170
+ if (!model) {
2083
2171
  return;
2084
2172
  }
2085
- this.state.model.setUniforms({
2086
- u_Camera: this.state.model.uniforms.project_uCameraPosition,
2173
+ const meshProps = {
2087
2174
  pickFeatureIds: Boolean(featureIds)
2175
+ };
2176
+ const pbrProjectionProps = {
2177
+ // Needed for PBR (TODO: find better way to get it)
2178
+ camera: model.uniforms.cameraPosition
2179
+ };
2180
+ model.shaderInputs.setProps({
2181
+ pbrProjection: pbrProjectionProps,
2182
+ mesh: meshProps
2088
2183
  });
2089
2184
  super.draw(opts);
2090
2185
  }
2091
2186
  getModel(mesh) {
2092
- const { id, pbrMaterial } = this.props;
2093
- const parsedPBRMaterial = this.parseMaterial(pbrMaterial, mesh);
2187
+ const { id } = this.props;
2188
+ const parsedPBRMaterial = this.parseMaterial(this.props.pbrMaterial, mesh);
2094
2189
  this.setState({ parsedPBRMaterial });
2095
2190
  const shaders = this.getShaders();
2096
2191
  validateGeometryAttributes(mesh.attributes);
@@ -2109,19 +2204,28 @@ var MeshLayer = class extends import_mesh_layers.SimpleMeshLayer {
2109
2204
  });
2110
2205
  return model;
2111
2206
  }
2112
- updatePbrMaterialUniforms(pbrMaterial) {
2207
+ updatePbrMaterialUniforms(material) {
2113
2208
  const { model } = this.state;
2114
2209
  if (model) {
2115
2210
  const { mesh } = this.props;
2116
- const parsedPBRMaterial = this.parseMaterial(pbrMaterial, mesh);
2211
+ const parsedPBRMaterial = this.parseMaterial(material, mesh);
2117
2212
  this.setState({ parsedPBRMaterial });
2118
- model.setBindings(parsedPBRMaterial.bindings);
2119
- model.setUniforms(parsedPBRMaterial.uniforms);
2120
- }
2121
- }
2122
- parseMaterial(pbrMaterial, mesh) {
2123
- const unlit = Boolean(pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorTexture);
2124
- return (0, import_gltf.parsePBRMaterial)(this.context.device, { unlit, ...pbrMaterial }, { NORMAL: mesh.attributes.normals, TEXCOORD_0: mesh.attributes.texCoords }, {
2213
+ const { pbr_baseColorSampler } = parsedPBRMaterial.bindings;
2214
+ const { emptyTexture } = this.state;
2215
+ const simpleMeshProps = {
2216
+ sampler: pbr_baseColorSampler || emptyTexture,
2217
+ hasTexture: Boolean(pbr_baseColorSampler)
2218
+ };
2219
+ const { camera, ...pbrMaterialProps } = {
2220
+ ...parsedPBRMaterial.bindings,
2221
+ ...parsedPBRMaterial.uniforms
2222
+ };
2223
+ model.shaderInputs.setProps({ simpleMesh: simpleMeshProps, pbrMaterial: pbrMaterialProps });
2224
+ }
2225
+ }
2226
+ parseMaterial(material, mesh) {
2227
+ const unlit = Boolean(material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture);
2228
+ return (0, import_gltf.parsePBRMaterial)(this.context.device, { unlit, ...material }, { NORMAL: mesh.attributes.normals, TEXCOORD_0: mesh.attributes.texCoords }, {
2125
2229
  pbrDebug: false,
2126
2230
  lights: true,
2127
2231
  useTangents: false
@@ -2158,6 +2262,7 @@ var SINGLE_DATA = [0];
2158
2262
  var defaultProps11 = {
2159
2263
  getPointColor: { type: "accessor", value: [0, 0, 0, 255] },
2160
2264
  pointSize: 1,
2265
+ // Disable async data loading (handling it in _loadTileSet)
2161
2266
  data: "",
2162
2267
  loader: import_d_tiles.Tiles3DLoader,
2163
2268
  onTilesetLoad: { type: "function", value: (tileset3d) => {
@@ -2446,11 +2551,17 @@ var import_terrain = require("@loaders.gl/terrain");
2446
2551
  var DUMMY_DATA = [1];
2447
2552
  var defaultProps12 = {
2448
2553
  ...tile_layer_default.defaultProps,
2554
+ // Image url that encodes height data
2449
2555
  elevationData: urlType,
2556
+ // Image url to use as texture
2450
2557
  texture: { ...urlType, optional: true },
2558
+ // Martini error tolerance in meters, smaller number -> more detailed mesh
2451
2559
  meshMaxError: { type: "number", value: 4 },
2560
+ // Bounding box of the terrain image, [minX, minY, maxX, maxY] in world coordinates
2452
2561
  bounds: { type: "array", value: null, optional: true, compare: true },
2562
+ // Color to use if texture is unavailable
2453
2563
  color: { type: "color", value: [255, 255, 255] },
2564
+ // Object to decode height data, from (r, g, b) to height in meters
2454
2565
  elevationDecoder: {
2455
2566
  type: "object",
2456
2567
  value: {
@@ -2460,7 +2571,9 @@ var defaultProps12 = {
2460
2571
  offset: 0
2461
2572
  }
2462
2573
  },
2574
+ // Supply url to local terrain worker bundle. Only required if running offline and cannot access CDN.
2463
2575
  workerUrl: "",
2576
+ // Same as SimpleMeshLayer wireframe
2464
2577
  wireframe: false,
2465
2578
  material: true,
2466
2579
  loaders: [import_terrain.TerrainWorkerLoader]
@@ -2531,7 +2644,10 @@ var TerrainLayer = class extends import_core11.CompositeLayer {
2531
2644
  meshMaxError,
2532
2645
  signal
2533
2646
  });
2534
- const surface = textureUrl ? fetch(textureUrl, { propName: "texture", layer: this, loaders: [], signal }).catch((_) => null) : Promise.resolve(null);
2647
+ const surface = textureUrl ? (
2648
+ // If surface image fails to load, the tile should still be displayed
2649
+ fetch(textureUrl, { propName: "texture", layer: this, loaders: [], signal }).catch((_) => null)
2650
+ ) : Promise.resolve(null);
2535
2651
  return Promise.all([terrain, surface]);
2536
2652
  }
2537
2653
  renderSubLayers(props) {
@@ -2554,6 +2670,7 @@ var TerrainLayer = class extends import_core11.CompositeLayer {
2554
2670
  material
2555
2671
  });
2556
2672
  }
2673
+ // Update zRange of viewport
2557
2674
  onViewportLoad(tiles) {
2558
2675
  if (!tiles) {
2559
2676
  return;
@@ -2793,6 +2910,7 @@ var MVTLayer = class extends tile_layer_default {
2793
2910
  this.setState({ highlightColor });
2794
2911
  }
2795
2912
  }
2913
+ /* eslint-disable complexity */
2796
2914
  async _updateTileData() {
2797
2915
  let data = this.props.data;
2798
2916
  let tileJSON = null;
@@ -2830,6 +2948,7 @@ var MVTLayer = class extends tile_layer_default {
2830
2948
  }
2831
2949
  return opts;
2832
2950
  }
2951
+ /* eslint-disable complexity */
2833
2952
  renderLayers() {
2834
2953
  var _a;
2835
2954
  if (!((_a = this.state) == null ? void 0 : _a.data))
@@ -2852,6 +2971,10 @@ var MVTLayer = class extends tile_layer_default {
2852
2971
  ...loadOptions == null ? void 0 : loadOptions.mvt,
2853
2972
  coordinates: this.context.viewport.resolution ? "wgs84" : "local",
2854
2973
  tileIndex: index
2974
+ // Local worker debug
2975
+ // workerUrl: `modules/mvt/dist/mvt-loader.worker.js`
2976
+ // Set worker to null to skip web workers
2977
+ // workerUrl: null
2855
2978
  },
2856
2979
  gis: binary ? { format: "binary" } : {}
2857
2980
  };
@@ -2915,6 +3038,7 @@ var MVTLayer = class extends tile_layer_default {
2915
3038
  info.object = transformTileCoordsToWGS84(
2916
3039
  info.object,
2917
3040
  info.tile.bbox,
3041
+ // eslint-disable-line
2918
3042
  this.context.viewport
2919
3043
  );
2920
3044
  }
@@ -2956,6 +3080,7 @@ var MVTLayer = class extends tile_layer_default {
2956
3080
  const layerIds = [this.id];
2957
3081
  return deck.pickObjects({ x, y, width, height, layerIds, maxObjects });
2958
3082
  }
3083
+ /** Get the rendered features in the current viewport. */
2959
3084
  getRenderedFeatures(maxFeatures = null) {
2960
3085
  const features = this._pickObjects(maxFeatures);
2961
3086
  const featureCache = /* @__PURE__ */ new Set();