@deck.gl/aggregation-layers 9.3.7 → 9.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/common/aggregation-layer.d.ts.map +1 -1
  2. package/dist/common/aggregation-layer.js +1 -3
  3. package/dist/common/aggregation-layer.js.map +1 -1
  4. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
  5. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
  6. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
  7. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
  8. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
  9. package/dist/dist.dev.js +502 -32
  10. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +1 -1
  11. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -1
  12. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +1 -2
  13. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -1
  14. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
  15. package/dist/grid-layer/grid-cell-layer.js +2 -1
  16. package/dist/grid-layer/grid-cell-layer.js.map +1 -1
  17. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
  18. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
  19. package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
  20. package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
  21. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  22. package/dist/heatmap-layer/heatmap-layer.js +59 -12
  23. package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
  24. package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
  25. package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
  26. package/dist/heatmap-layer/max.wgsl.js +48 -0
  27. package/dist/heatmap-layer/max.wgsl.js.map +1 -0
  28. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
  29. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
  30. package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
  31. package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
  32. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  33. package/dist/heatmap-layer/triangle-layer.js +3 -2
  34. package/dist/heatmap-layer/triangle-layer.js.map +1 -1
  35. package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
  36. package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
  37. package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
  38. package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
  39. package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
  40. package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
  41. package/dist/heatmap-layer/weights.wgsl.js +64 -0
  42. package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
  43. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -1
  44. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +1 -2
  45. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -1
  46. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
  47. package/dist/hexagon-layer/hexagon-cell-layer.js +2 -1
  48. package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
  49. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
  50. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
  51. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
  52. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
  53. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
  54. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
  55. package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
  56. package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
  57. package/dist/index.cjs +502 -32
  58. package/dist/index.cjs.map +4 -4
  59. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
  60. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  61. package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
  62. package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  63. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
  64. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
  65. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
  66. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
  67. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
  68. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
  69. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
  70. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
  71. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  72. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  73. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -2
  74. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  75. package/dist.min.js +428 -40
  76. package/package.json +11 -7
  77. package/src/common/aggregation-layer.ts +1 -3
  78. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
  79. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
  80. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +1 -2
  81. package/src/grid-layer/grid-cell-layer.ts +2 -1
  82. package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
  83. package/src/heatmap-layer/heatmap-layer.ts +67 -13
  84. package/src/heatmap-layer/max.wgsl.ts +48 -0
  85. package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
  86. package/src/heatmap-layer/triangle-layer.ts +3 -2
  87. package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
  88. package/src/heatmap-layer/weights.wgsl.ts +64 -0
  89. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +1 -2
  90. package/src/hexagon-layer/hexagon-cell-layer.ts +2 -1
  91. package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
  92. package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
  93. package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
  94. package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
  95. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
  96. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +1 -2
package/dist/index.cjs CHANGED
@@ -554,7 +554,6 @@ void main() {
554
554
  const model = new import_engine.Model(device, {
555
555
  bufferLayout: props.bufferLayout,
556
556
  modules: [...props.modules || [], binSorterUniforms],
557
- // @ts-expect-error TODO fix luma type
558
557
  defines: { ...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount },
559
558
  isInstanced: false,
560
559
  vs,
@@ -665,6 +664,7 @@ var WebGLAggregationTransform = class {
665
664
  transform.run({
666
665
  id: "gpu-aggregation-domain",
667
666
  framebuffer: target,
667
+ discard: false,
668
668
  parameters: {
669
669
  viewport: [0, 0, 2, 1]
670
670
  },
@@ -792,11 +792,8 @@ void main() {
792
792
  blendAlphaOperation: "max"
793
793
  },
794
794
  defines: {
795
- // @ts-expect-error TODO fix luma type
796
795
  NUM_DIMS: props.dimensions,
797
- // @ts-expect-error TODO fix luma type
798
796
  NUM_CHANNELS: props.channelCount,
799
- // @ts-expect-error TODO fix luma type
800
797
  SAMPLER_WIDTH: TEXTURE_WIDTH
801
798
  },
802
799
  varyings: ["binIds", "values"],
@@ -997,7 +994,6 @@ var AggregationLayer = class extends import_core3.CompositeLayer {
997
994
  return true;
998
995
  }
999
996
  initializeState() {
1000
- this.getAttributeManager().remove(["instancePickingColors"]);
1001
997
  }
1002
998
  // Extend Layer.updateState to update the Aggregator instance
1003
999
  // returns true if aggregator is changed
@@ -1069,11 +1065,11 @@ function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float3
1069
1065
  flatArray = new ArrayType(colorRange.length * 4);
1070
1066
  let index = 0;
1071
1067
  for (let i = 0; i < colorRange.length; i++) {
1072
- const color = colorRange[i];
1073
- flatArray[index++] = color[0];
1074
- flatArray[index++] = color[1];
1075
- flatArray[index++] = color[2];
1076
- flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
1068
+ const color3 = colorRange[i];
1069
+ flatArray[index++] = color3[0];
1070
+ flatArray[index++] = color3[1];
1071
+ flatArray[index++] = color3[2];
1072
+ flatArray[index++] = Number.isFinite(color3[3]) ? color3[3] : 255;
1077
1073
  }
1078
1074
  }
1079
1075
  if (normalize) {
@@ -1111,6 +1107,83 @@ function createColorRangeTexture(device, colorRange, type = "linear") {
1111
1107
  });
1112
1108
  }
1113
1109
 
1110
+ // dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js
1111
+ var screen_grid_cell_layer_wgsl_default = (
1112
+ /* wgsl */
1113
+ `
1114
+ struct Attributes {
1115
+ @builtin(instance_index) instanceIndex: u32,
1116
+ @location(0) positions: vec2<f32>,
1117
+ @location(1) instancePositions: vec2<f32>,
1118
+ @location(2) instanceWeights: f32,
1119
+ };
1120
+
1121
+ struct Varyings {
1122
+ @builtin(position) position: vec4<f32>,
1123
+ @location(0) color: vec4<f32>,
1124
+ @location(1) pickingColor: vec3<f32>,
1125
+ };
1126
+
1127
+ fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
1128
+ let ratio = (value - domain.x) / (domain.y - domain.x);
1129
+ return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
1130
+ }
1131
+
1132
+ @vertex
1133
+ fn vertexMain(attributes: Attributes) -> Varyings {
1134
+ var output: Varyings;
1135
+ output.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
1136
+
1137
+ if (attributes.instanceWeights != attributes.instanceWeights) {
1138
+ output.position = vec4<f32>(0.0);
1139
+ output.color = vec4<f32>(0.0);
1140
+ return output;
1141
+ }
1142
+
1143
+ var position =
1144
+ attributes.instancePositions * screenGrid.gridSizeClipspace +
1145
+ attributes.positions * screenGrid.cellSizeClipspace;
1146
+ position.x -= 1.0;
1147
+ position.y = 1.0 - position.y;
1148
+
1149
+ output.position = vec4<f32>(position, 0.0, 1.0);
1150
+ let colorValue = sampleColorRange(attributes.instanceWeights, screenGrid.colorDomain);
1151
+ output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
1152
+ return output;
1153
+ }
1154
+
1155
+ @fragment
1156
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
1157
+ if (picking.isActive > 0.5) {
1158
+ if (!picking_isColorValid(varyings.pickingColor)) {
1159
+ discard;
1160
+ }
1161
+ return vec4<f32>(varyings.pickingColor, 1.0);
1162
+ }
1163
+
1164
+ var color = varyings.color;
1165
+ if (picking.isHighlightActive > 0.5) {
1166
+ let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
1167
+ if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
1168
+ let highLightAlpha = picking.highlightColor.a;
1169
+ let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
1170
+ if (blendedAlpha > 0.0) {
1171
+ let highLightRatio = highLightAlpha / blendedAlpha;
1172
+ color = vec4<f32>(
1173
+ mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
1174
+ blendedAlpha
1175
+ );
1176
+ } else {
1177
+ color = vec4<f32>(color.rgb, 0.0);
1178
+ }
1179
+ }
1180
+ }
1181
+
1182
+ return deckgl_premultiplied_alpha(color);
1183
+ }
1184
+ `
1185
+ );
1186
+
1114
1187
  // dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js
1115
1188
  var screen_grid_layer_vertex_glsl_default = (
1116
1189
  /* glsl */
@@ -1120,7 +1193,6 @@ var screen_grid_layer_vertex_glsl_default = (
1120
1193
  in vec2 positions;
1121
1194
  in vec2 instancePositions;
1122
1195
  in float instanceWeights;
1123
- in vec3 instancePickingColors;
1124
1196
  uniform sampler2D colorRange;
1125
1197
  out vec4 vColor;
1126
1198
  vec4 interp(float value, vec2 domain, sampler2D range) {
@@ -1138,7 +1210,7 @@ pos.y = 1.0 - pos.y;
1138
1210
  gl_Position = vec4(pos, 0., 1.);
1139
1211
  vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
1140
1212
  vColor.a *= layer.opacity;
1141
- picking_setPickingColor(instancePickingColors);
1213
+ picking_setPickingColorFromInstanceID();
1142
1214
  }
1143
1215
  `
1144
1216
  );
@@ -1159,6 +1231,20 @@ DECKGL_FILTER_COLOR(fragColor, geometry);
1159
1231
  );
1160
1232
 
1161
1233
  // dist/screen-grid-layer/screen-grid-layer-uniforms.js
1234
+ var uniformBlockWGSL = (
1235
+ /* wgsl */
1236
+ `
1237
+ struct ScreenGridUniforms {
1238
+ cellSizeClipspace: vec2<f32>,
1239
+ gridSizeClipspace: vec2<f32>,
1240
+ colorDomain: vec2<f32>,
1241
+ };
1242
+
1243
+ @group(0) @binding(auto) var<uniform> screenGrid: ScreenGridUniforms;
1244
+ @group(0) @binding(auto) var colorRange: texture_2d<f32>;
1245
+ @group(0) @binding(auto) var colorRangeSampler: sampler;
1246
+ `
1247
+ );
1162
1248
  var uniformBlock3 = (
1163
1249
  /* glsl */
1164
1250
  `layout(std140) uniform screenGridUniforms {
@@ -1170,6 +1256,7 @@ var uniformBlock3 = (
1170
1256
  );
1171
1257
  var screenGridUniforms = {
1172
1258
  name: "screenGrid",
1259
+ source: uniformBlockWGSL,
1173
1260
  vs: uniformBlock3,
1174
1261
  uniformTypes: {
1175
1262
  cellSizeClipspace: "vec2<f32>",
@@ -1181,7 +1268,7 @@ var screenGridUniforms = {
1181
1268
  // dist/screen-grid-layer/screen-grid-cell-layer.js
1182
1269
  var ScreenGridCellLayer = class extends import_core4.Layer {
1183
1270
  getShaders() {
1184
- return super.getShaders({ vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core4.picking, screenGridUniforms] });
1271
+ return super.getShaders({ source: screen_grid_cell_layer_wgsl_default, vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core4.color, import_core4.picking, screenGridUniforms] });
1185
1272
  }
1186
1273
  initializeState() {
1187
1274
  this.getAttributeManager().addInstanced({
@@ -1636,6 +1723,126 @@ function getBinIdRange({ dataBounds, getBinId, padding = 0 }) {
1636
1723
  // dist/hexagon-layer/hexagon-cell-layer.js
1637
1724
  var import_layers = require("@deck.gl/layers");
1638
1725
 
1726
+ // dist/hexagon-layer/hexagon-cell-layer.wgsl.js
1727
+ var hexagon_cell_layer_wgsl_default = (
1728
+ /* wgsl */
1729
+ `const HEXBIN_DISTANCE: vec2<f32> = vec2<f32>(1.7320508, 1.5);
1730
+
1731
+ struct Attributes {
1732
+ @builtin(instance_index) instanceIndex: u32,
1733
+ @location(0) positions: vec3<f32>,
1734
+ @location(1) normals: vec3<f32>,
1735
+ @location(2) instancePositions: vec2<f32>,
1736
+ @location(3) instanceColorValues: f32,
1737
+ @location(4) instanceElevationValues: f32,
1738
+ };
1739
+
1740
+ struct Varyings {
1741
+ @builtin(position) position: vec4<f32>,
1742
+ @location(0) color: vec4<f32>,
1743
+ @location(1) pickingColor: vec3<f32>,
1744
+ };
1745
+
1746
+ fn hexbinCentroid(binId: vec2<f32>, radius: f32) -> vec2<f32> {
1747
+ var adjustedBinId = binId;
1748
+ adjustedBinId.x += fract(adjustedBinId.y * 0.5);
1749
+ return adjustedBinId * HEXBIN_DISTANCE * radius;
1750
+ }
1751
+
1752
+ fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
1753
+ let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
1754
+ return mix(range.x, range.y, ratio);
1755
+ }
1756
+
1757
+ fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
1758
+ let ratio = (value - domain.x) / (domain.y - domain.x);
1759
+ return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
1760
+ }
1761
+
1762
+ @vertex
1763
+ fn vertexMain(attributes: Attributes) -> Varyings {
1764
+ var output: Varyings;
1765
+ geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
1766
+ output.pickingColor = geometry.pickingColor;
1767
+
1768
+ if (
1769
+ attributes.instanceColorValues != attributes.instanceColorValues ||
1770
+ attributes.instanceColorValues < hexagon.colorDomain.z ||
1771
+ attributes.instanceColorValues > hexagon.colorDomain.w ||
1772
+ attributes.instanceElevationValues < hexagon.elevationDomain.z ||
1773
+ attributes.instanceElevationValues > hexagon.elevationDomain.w
1774
+ ) {
1775
+ output.position = vec4<f32>(0.0);
1776
+ output.color = vec4<f32>(0.0);
1777
+ return output;
1778
+ }
1779
+
1780
+ var commonPosition =
1781
+ hexbinCentroid(attributes.instancePositions, column.radius) +
1782
+ (hexagon.originCommon - project.commonOrigin.xy);
1783
+ commonPosition += attributes.positions.xy * column.radius * column.coverage;
1784
+ geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
1785
+ geometry.normal = project_normal(attributes.normals);
1786
+
1787
+ if (column.extruded > 0.5) {
1788
+ var elevation = interpolate(
1789
+ attributes.instanceElevationValues,
1790
+ hexagon.elevationDomain.xy,
1791
+ hexagon.elevationRange
1792
+ );
1793
+ elevation = project_size_float(elevation);
1794
+ geometry.position.z = (attributes.positions.z + 1.0) / 2.0 * elevation;
1795
+ }
1796
+
1797
+ output.position = project_common_position_to_clipspace(geometry.position);
1798
+ var colorValue = sampleColorRange(attributes.instanceColorValues, hexagon.colorDomain.xy);
1799
+ if (column.extruded > 0.5) {
1800
+ colorValue = vec4<f32>(
1801
+ lighting_getLightColor2(
1802
+ colorValue.rgb,
1803
+ project.cameraPosition,
1804
+ geometry.position.xyz,
1805
+ geometry.normal
1806
+ ),
1807
+ colorValue.a
1808
+ );
1809
+ }
1810
+ output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
1811
+ return output;
1812
+ }
1813
+
1814
+ @fragment
1815
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
1816
+ if (picking.isActive > 0.5) {
1817
+ if (!picking_isColorValid(varyings.pickingColor)) {
1818
+ discard;
1819
+ }
1820
+ return vec4<f32>(varyings.pickingColor, 1.0);
1821
+ }
1822
+
1823
+ var color = varyings.color;
1824
+ if (picking.isHighlightActive > 0.5) {
1825
+ let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
1826
+ if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
1827
+ let highLightAlpha = picking.highlightColor.a;
1828
+ let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
1829
+ if (blendedAlpha > 0.0) {
1830
+ let highLightRatio = highLightAlpha / blendedAlpha;
1831
+ color = vec4<f32>(
1832
+ mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
1833
+ blendedAlpha
1834
+ );
1835
+ } else {
1836
+ color = vec4<f32>(color.rgb, 0.0);
1837
+ }
1838
+ }
1839
+ }
1840
+
1841
+ return deckgl_premultiplied_alpha(color);
1842
+ }
1843
+ `
1844
+ );
1845
+
1639
1846
  // dist/hexagon-layer/hexbin.js
1640
1847
  var THIRD_PI = Math.PI / 3;
1641
1848
  var DIST_X = 2 * Math.sin(THIRD_PI);
@@ -1709,7 +1916,6 @@ in vec3 normals;
1709
1916
  in vec2 instancePositions;
1710
1917
  in float instanceElevationValues;
1711
1918
  in float instanceColorValues;
1712
- in vec3 instancePickingColors;
1713
1919
  uniform sampler2D colorRange;
1714
1920
  out vec4 vColor;
1715
1921
  ${getHexbinCentroidGLSL}
@@ -1722,7 +1928,7 @@ float r = (value - domain.x) / (domain.y - domain.x);
1722
1928
  return texture(range, vec2(r, 0.5));
1723
1929
  }
1724
1930
  void main(void) {
1725
- geometry.pickingColor = instancePickingColors;
1931
+ geometry.pickingColor = picking_getPickingColorFromInstanceID();
1726
1932
  if (isnan(instanceColorValues) ||
1727
1933
  instanceColorValues < hexagon.colorDomain.z ||
1728
1934
  instanceColorValues > hexagon.colorDomain.w ||
@@ -1755,6 +1961,20 @@ DECKGL_FILTER_COLOR(vColor, geometry);
1755
1961
  );
1756
1962
 
1757
1963
  // dist/hexagon-layer/hexagon-layer-uniforms.js
1964
+ var uniformBlockWGSL2 = (
1965
+ /* wgsl */
1966
+ `struct HexagonUniforms {
1967
+ colorDomain: vec4<f32>,
1968
+ elevationDomain: vec4<f32>,
1969
+ elevationRange: vec2<f32>,
1970
+ originCommon: vec2<f32>,
1971
+ };
1972
+
1973
+ @group(0) @binding(auto) var<uniform> hexagon: HexagonUniforms;
1974
+ @group(0) @binding(auto) var colorRange: texture_2d<f32>;
1975
+ @group(0) @binding(auto) var colorRangeSampler: sampler;
1976
+ `
1977
+ );
1758
1978
  var uniformBlock5 = (
1759
1979
  /* glsl */
1760
1980
  `layout(std140) uniform hexagonUniforms {
@@ -1767,6 +1987,7 @@ var uniformBlock5 = (
1767
1987
  );
1768
1988
  var hexagonUniforms = {
1769
1989
  name: "hexagon",
1990
+ source: uniformBlockWGSL2,
1770
1991
  vs: uniformBlock5,
1771
1992
  uniformTypes: {
1772
1993
  colorDomain: "vec4<f32>",
@@ -1781,7 +2002,7 @@ var HexagonCellLayer = class extends import_layers.ColumnLayer {
1781
2002
  getShaders() {
1782
2003
  const shaders = super.getShaders();
1783
2004
  shaders.modules.push(hexagonUniforms);
1784
- return { ...shaders, vs: hexagon_cell_layer_vertex_glsl_default };
2005
+ return { ...shaders, source: hexagon_cell_layer_wgsl_default, vs: hexagon_cell_layer_vertex_glsl_default };
1785
2006
  }
1786
2007
  initializeState() {
1787
2008
  super.initializeState();
@@ -3035,7 +3256,6 @@ in vec3 normals;
3035
3256
  in vec2 instancePositions;
3036
3257
  in float instanceElevationValues;
3037
3258
  in float instanceColorValues;
3038
- in vec3 instancePickingColors;
3039
3259
  uniform sampler2D colorRange;
3040
3260
  out vec4 vColor;
3041
3261
  float interp(float value, vec2 domain, vec2 range) {
@@ -3047,7 +3267,7 @@ float r = (value - domain.x) / (domain.y - domain.x);
3047
3267
  return texture(range, vec2(r, 0.5));
3048
3268
  }
3049
3269
  void main(void) {
3050
- geometry.pickingColor = instancePickingColors;
3270
+ geometry.pickingColor = picking_getPickingColorFromInstanceID();
3051
3271
  if (isnan(instanceColorValues) ||
3052
3272
  instanceColorValues < grid.colorDomain.z ||
3053
3273
  instanceColorValues > grid.colorDomain.w ||
@@ -3157,7 +3377,8 @@ var GridCellLayer = class extends import_layers3.ColumnLayer {
3157
3377
  }
3158
3378
  _updateGeometry() {
3159
3379
  const geometry = new import_engine4.CubeGeometry();
3160
- this.state.fillModel.setGeometry(geometry);
3380
+ this._setFillGeometry(geometry);
3381
+ this._setWireframeGeometry(geometry);
3161
3382
  }
3162
3383
  draw({ uniforms }) {
3163
3384
  const { cellOriginCommon, cellSizeCommon, elevationRange, elevationScale, extruded, coverage, colorDomain, elevationDomain } = this.props;
@@ -3611,6 +3832,71 @@ var import_core12 = require("@deck.gl/core");
3611
3832
  var import_engine5 = require("@luma.gl/engine");
3612
3833
  var import_core10 = require("@deck.gl/core");
3613
3834
 
3835
+ // dist/heatmap-layer/triangle-layer.wgsl.js
3836
+ var triangle_layer_wgsl_default = (
3837
+ /* wgsl */
3838
+ `struct TriangleAttributes {
3839
+ @location(0) positions: vec3<f32>,
3840
+ @location(1) texCoords: vec2<f32>,
3841
+ };
3842
+
3843
+ struct TriangleVaryings {
3844
+ @builtin(position) position: vec4<f32>,
3845
+ @location(0) textureCoordinates: vec2<f32>,
3846
+ @location(1) intensityMinimum: f32,
3847
+ @location(2) intensityMaximum: f32,
3848
+ };
3849
+
3850
+ @vertex
3851
+ fn vertexMain(attributes: TriangleAttributes) -> TriangleVaryings {
3852
+ var output: TriangleVaryings;
3853
+ output.position = project_position_to_clipspace(
3854
+ attributes.positions,
3855
+ vec3<f32>(0.0),
3856
+ vec3<f32>(0.0)
3857
+ );
3858
+ // WebGPU render-target textures use a top-left origin.
3859
+ output.textureCoordinates = vec2<f32>(attributes.texCoords.x, 1.0 - attributes.texCoords.y);
3860
+
3861
+ let maxWeights = textureLoad(maxTexture, vec2<i32>(0), 0);
3862
+ var maximumValue = select(maxWeights.r, maxWeights.g, triangle.aggregationMode > 0.5);
3863
+ var minimumValue = maximumValue * triangle.threshold;
3864
+
3865
+ if (triangle.colorDomain.y > 0.0) {
3866
+ maximumValue = triangle.colorDomain.y;
3867
+ minimumValue = triangle.colorDomain.x;
3868
+ }
3869
+
3870
+ output.intensityMaximum = triangle.intensity / maximumValue;
3871
+ output.intensityMinimum = triangle.intensity / minimumValue;
3872
+ return output;
3873
+ }
3874
+
3875
+ @fragment
3876
+ fn fragmentMain(varyings: TriangleVaryings) -> @location(0) vec4<f32> {
3877
+ let weights = textureSample(weightsTexture, weightsTextureSampler, varyings.textureCoordinates);
3878
+ var weight = weights.r;
3879
+
3880
+ if (triangle.aggregationMode > 0.5) {
3881
+ weight /= max(1.0, weights.a);
3882
+ }
3883
+
3884
+ let colorCoordinates = vec2<f32>(
3885
+ clamp(weight * varyings.intensityMaximum, 0.0, 1.0),
3886
+ 0.5
3887
+ );
3888
+ var color = textureSample(colorTexture, colorTextureSampler, colorCoordinates);
3889
+
3890
+ if (weight <= 0.0) {
3891
+ discard;
3892
+ }
3893
+
3894
+ color.a *= min(weight * varyings.intensityMinimum, 1.0) * layer.opacity;
3895
+ return deckgl_premultiplied_alpha(color);
3896
+ }
3897
+ `
3898
+ );
3899
+
3614
3900
  // dist/heatmap-layer/triangle-layer-vertex.glsl.js
3615
3901
  var triangle_layer_vertex_glsl_default = `#version 300 es
3616
3902
  #define SHADER_NAME heatp-map-layer-vertex-shader
@@ -3667,6 +3953,23 @@ fragColor = linearColor;
3667
3953
  `;
3668
3954
 
3669
3955
  // dist/heatmap-layer/triangle-layer-uniforms.js
3956
+ var uniformBlockWGSL3 = (
3957
+ /* wgsl */
3958
+ `struct triangleUniforms {
3959
+ aggregationMode: f32,
3960
+ colorDomain: vec2<f32>,
3961
+ intensity: f32,
3962
+ threshold: f32,
3963
+ };
3964
+
3965
+ @group(0) @binding(auto) var<uniform> triangle: triangleUniforms;
3966
+ @group(0) @binding(auto) var colorTexture: texture_2d<f32>;
3967
+ @group(0) @binding(auto) var colorTextureSampler: sampler;
3968
+ @group(0) @binding(auto) var maxTexture: texture_2d<f32>;
3969
+ @group(0) @binding(auto) var weightsTexture: texture_2d<f32>;
3970
+ @group(0) @binding(auto) var weightsTextureSampler: sampler;
3971
+ `
3972
+ );
3670
3973
  var uniformBlock10 = `layout(std140) uniform triangleUniforms {
3671
3974
  float aggregationMode;
3672
3975
  vec2 colorDomain;
@@ -3676,6 +3979,7 @@ var uniformBlock10 = `layout(std140) uniform triangleUniforms {
3676
3979
  `;
3677
3980
  var triangleUniforms = {
3678
3981
  name: "triangle",
3982
+ source: uniformBlockWGSL3,
3679
3983
  vs: uniformBlock10,
3680
3984
  fs: uniformBlock10,
3681
3985
  uniformTypes: {
@@ -3689,7 +3993,7 @@ var triangleUniforms = {
3689
3993
  // dist/heatmap-layer/triangle-layer.js
3690
3994
  var TriangleLayer = class extends import_core10.Layer {
3691
3995
  getShaders() {
3692
- return super.getShaders({ vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core10.project32, triangleUniforms] });
3996
+ return super.getShaders({ source: triangle_layer_wgsl_default, vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core10.project32, import_core10.color, triangleUniforms] });
3693
3997
  }
3694
3998
  initializeState({ device }) {
3695
3999
  this.setState({ model: this._getModel(device) });
@@ -3923,7 +4227,131 @@ fragColor.g = outTexture.r / max(1.0, outTexture.a);
3923
4227
  }
3924
4228
  `;
3925
4229
 
4230
+ // dist/heatmap-layer/max.wgsl.js
4231
+ var max_wgsl_default = (
4232
+ /* wgsl */
4233
+ `struct MaxWeightVaryings {
4234
+ @builtin(position) position: vec4<f32>,
4235
+ @location(0) weights: vec4<f32>,
4236
+ };
4237
+
4238
+ const MAX_WEIGHT_REDUCTION_SIZE: u32 = 16u;
4239
+
4240
+ @vertex
4241
+ fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> MaxWeightVaryings {
4242
+ var output: MaxWeightVaryings;
4243
+ let textureSize = u32(maxWeight.textureSize);
4244
+ let reducedTextureSize =
4245
+ (textureSize + MAX_WEIGHT_REDUCTION_SIZE - 1u) / MAX_WEIGHT_REDUCTION_SIZE;
4246
+ let blockCoordinates = vec2<u32>(
4247
+ vertexIndex % reducedTextureSize,
4248
+ vertexIndex / reducedTextureSize
4249
+ );
4250
+ var maximumWeights = vec4<f32>(0.0);
4251
+
4252
+ for (var y = 0u; y < MAX_WEIGHT_REDUCTION_SIZE; y++) {
4253
+ for (var x = 0u; x < MAX_WEIGHT_REDUCTION_SIZE; x++) {
4254
+ let textureCoordinates = blockCoordinates * MAX_WEIGHT_REDUCTION_SIZE + vec2<u32>(x, y);
4255
+
4256
+ if (textureCoordinates.x < textureSize && textureCoordinates.y < textureSize) {
4257
+ let weights = textureLoad(inTexture, vec2<i32>(textureCoordinates), 0);
4258
+ maximumWeights.r = max(maximumWeights.r, weights.r);
4259
+ maximumWeights.g = max(maximumWeights.g, weights.r / max(1.0, weights.a));
4260
+ maximumWeights.b = max(maximumWeights.b, weights.b);
4261
+ maximumWeights.a = max(maximumWeights.a, weights.a);
4262
+ }
4263
+ }
4264
+ }
4265
+
4266
+ output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
4267
+ output.weights = maximumWeights;
4268
+ return output;
4269
+ }
4270
+
4271
+ @fragment
4272
+ fn fragmentMain(varyings: MaxWeightVaryings) -> @location(0) vec4<f32> {
4273
+ return varyings.weights;
4274
+ }
4275
+ `
4276
+ );
4277
+
4278
+ // dist/heatmap-layer/weights.wgsl.js
4279
+ var weights_wgsl_default = (
4280
+ /* wgsl */
4281
+ `struct WeightAttributes {
4282
+ @builtin(vertex_index) vertexIndex: u32,
4283
+ @location(0) instancePositions: vec3<f32>,
4284
+ @location(1) instancePositions64Low: vec3<f32>,
4285
+ @location(2) instanceWeights: f32,
4286
+ };
4287
+
4288
+ struct WeightVaryings {
4289
+ @builtin(position) position: vec4<f32>,
4290
+ @location(0) pointCoordinates: vec2<f32>,
4291
+ @location(1) weights: vec4<f32>,
4292
+ };
4293
+
4294
+ const WEIGHT_QUAD_POSITIONS = array<vec2<f32>, 6>(
4295
+ vec2<f32>(-1.0, -1.0),
4296
+ vec2<f32>(1.0, -1.0),
4297
+ vec2<f32>(-1.0, 1.0),
4298
+ vec2<f32>(-1.0, 1.0),
4299
+ vec2<f32>(1.0, -1.0),
4300
+ vec2<f32>(1.0, 1.0)
4301
+ );
4302
+
4303
+ @vertex
4304
+ fn vertexMain(attributes: WeightAttributes) -> WeightVaryings {
4305
+ var output: WeightVaryings;
4306
+ let commonPosition = project_position_vec3_f64(
4307
+ attributes.instancePositions,
4308
+ attributes.instancePositions64Low
4309
+ );
4310
+ let clipPosition =
4311
+ (commonPosition.xy - weight.commonBounds.xy) /
4312
+ (weight.commonBounds.zw - weight.commonBounds.xy) * 2.0 - vec2<f32>(1.0);
4313
+ let radiusTexels =
4314
+ project_pixel_size_float(weight.radiusPixels) * weight.textureWidth /
4315
+ (weight.commonBounds.z - weight.commonBounds.x);
4316
+ let offset = WEIGHT_QUAD_POSITIONS[attributes.vertexIndex];
4317
+
4318
+ output.position = vec4<f32>(
4319
+ clipPosition + offset * radiusTexels * 2.0 / weight.textureWidth,
4320
+ 0.0,
4321
+ 1.0
4322
+ );
4323
+ output.pointCoordinates = (offset + vec2<f32>(1.0)) * 0.5;
4324
+ output.weights = vec4<f32>(attributes.instanceWeights * weight.weightsScale, 0.0, 0.0, 1.0);
4325
+ return output;
4326
+ }
4327
+
4328
+ @fragment
4329
+ fn fragmentMain(varyings: WeightVaryings) -> @location(0) vec4<f32> {
4330
+ let distanceFromCenter = length(varyings.pointCoordinates - vec2<f32>(0.5));
4331
+ if (distanceFromCenter > 0.5) {
4332
+ discard;
4333
+ }
4334
+
4335
+ let gaussian = exp(-pow(2.0 * distanceFromCenter, 2.0) / 0.05555) /
4336
+ (1.77245385 * 0.166666);
4337
+ return varyings.weights * gaussian;
4338
+ }
4339
+ `
4340
+ );
4341
+
3926
4342
  // dist/heatmap-layer/heatmap-layer-uniforms.js
4343
+ var uniformBlockWGSL4 = (
4344
+ /* wgsl */
4345
+ `struct weightUniforms {
4346
+ commonBounds: vec4<f32>,
4347
+ radiusPixels: f32,
4348
+ textureWidth: f32,
4349
+ weightsScale: f32,
4350
+ };
4351
+
4352
+ @group(0) @binding(auto) var<uniform> weight: weightUniforms;
4353
+ `
4354
+ );
3927
4355
  var uniformBlock11 = `layout(std140) uniform weightUniforms {
3928
4356
  vec4 commonBounds;
3929
4357
  float radiusPixels;
@@ -3933,6 +4361,7 @@ var uniformBlock11 = `layout(std140) uniform weightUniforms {
3933
4361
  `;
3934
4362
  var weightUniforms = {
3935
4363
  name: "weight",
4364
+ source: uniformBlockWGSL4,
3936
4365
  vs: uniformBlock11,
3937
4366
  uniformTypes: {
3938
4367
  commonBounds: "vec4<f32>",
@@ -3943,6 +4372,16 @@ var weightUniforms = {
3943
4372
  };
3944
4373
  var maxWeightUniforms = {
3945
4374
  name: "maxWeight",
4375
+ source: (
4376
+ /* wgsl */
4377
+ `struct maxWeightUniforms {
4378
+ textureSize: f32,
4379
+ };
4380
+
4381
+ @group(0) @binding(auto) var<uniform> maxWeight: maxWeightUniforms;
4382
+ @group(0) @binding(auto) var inTexture: texture_2d<f32>;
4383
+ `
4384
+ ),
3946
4385
  vs: `layout(std140) uniform maxWeightUniforms {
3947
4386
  float textureSize;
3948
4387
  } maxWeight;
@@ -3954,6 +4393,7 @@ var maxWeightUniforms = {
3954
4393
 
3955
4394
  // dist/heatmap-layer/heatmap-layer.js
3956
4395
  var RESOLUTION = 2;
4396
+ var MAX_WEIGHT_REDUCTION_SIZE = 16;
3957
4397
  var TEXTURE_PROPS = {
3958
4398
  format: "rgba8unorm",
3959
4399
  dimension: "2d",
@@ -4126,18 +4566,33 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4126
4566
  }
4127
4567
  _setupAttributes() {
4128
4568
  const attributeManager = this.getAttributeManager();
4129
- attributeManager.add({
4130
- positions: { size: 3, type: "float64", accessor: "getPosition" },
4131
- weights: { size: 1, accessor: "getWeight" }
4132
- });
4133
- this.setState({ positionAttributeName: "positions" });
4569
+ if (this.context.device.type === "webgpu") {
4570
+ attributeManager.addInstanced({
4571
+ instancePositions: {
4572
+ size: 3,
4573
+ type: "float64",
4574
+ accessor: "getPosition",
4575
+ // Normalize binary XY positions into the packed XYZ high/low layout WebGPU requires.
4576
+ transform: (position) => [position[0], position[1], position[2] ?? 0]
4577
+ },
4578
+ instanceWeights: { size: 1, accessor: "getWeight" }
4579
+ });
4580
+ this.setState({ positionAttributeName: "instancePositions" });
4581
+ } else {
4582
+ attributeManager.add({
4583
+ positions: { size: 3, type: "float64", accessor: "getPosition" },
4584
+ weights: { size: 1, accessor: "getWeight" }
4585
+ });
4586
+ this.setState({ positionAttributeName: "positions" });
4587
+ }
4134
4588
  }
4135
4589
  _setupTextureParams() {
4136
4590
  const { device } = this.context;
4137
4591
  const { weightsTextureSize } = this.props;
4138
4592
  const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
4139
- const floatTargetSupport = FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
4140
- const format = floatTargetSupport ? "rgba32float" : "rgba8unorm";
4593
+ const isWebGPU = device.type === "webgpu";
4594
+ const floatTargetSupport = isWebGPU ? device.getTextureFormatCapabilities("rgba16float").blend : FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
4595
+ const format = floatTargetSupport ? isWebGPU ? "rgba16float" : "rgba32float" : "rgba8unorm";
4141
4596
  const weightsScale = floatTargetSupport ? 1 : 1 / 255;
4142
4597
  this.setState({ textureSize, format, weightsScale });
4143
4598
  if (!floatTargetSupport) {
@@ -4147,13 +4602,20 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4147
4602
  _createWeightsTransform(shaders) {
4148
4603
  let { weightsTransform } = this.state;
4149
4604
  const { weightsTexture } = this.state;
4605
+ const isWebGPU = this.context.device.type === "webgpu";
4150
4606
  const attributeManager = this.getAttributeManager();
4151
4607
  weightsTransform == null ? void 0 : weightsTransform.destroy();
4152
4608
  weightsTransform = new import_engine6.TextureTransform(this.context.device, {
4153
4609
  id: `${this.id}-weights-transform`,
4154
4610
  ...shaders,
4155
- bufferLayout: attributeManager.getBufferLayouts(),
4156
- vertexCount: 1,
4611
+ source: weights_wgsl_default,
4612
+ bufferLayout: attributeManager.getBufferLayouts({ isInstanced: isWebGPU }),
4613
+ vertexCount: isWebGPU ? 6 : 1,
4614
+ ...isWebGPU ? {
4615
+ colorAttachmentFormats: [weightsTexture.format],
4616
+ isInstanced: true,
4617
+ instanceCount: this.getNumInstances()
4618
+ } : {},
4157
4619
  targetTexture: weightsTexture,
4158
4620
  parameters: {
4159
4621
  depthWriteEnabled: false,
@@ -4164,7 +4626,7 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4164
4626
  blendAlphaSrcFactor: "one",
4165
4627
  blendAlphaDstFactor: "one"
4166
4628
  },
4167
- topology: "point-list",
4629
+ topology: isWebGPU ? "triangle-list" : "point-list",
4168
4630
  modules: [...shaders.modules, weightUniforms]
4169
4631
  });
4170
4632
  this.setState({ weightsTransform });
@@ -4179,6 +4641,7 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4179
4641
  });
4180
4642
  this._createWeightsTransform(weightsTransformShaders);
4181
4643
  const maxWeightsTransformShaders = this.getShaders({
4644
+ source: max_wgsl_default,
4182
4645
  vs: max_vs_glsl_default,
4183
4646
  fs: max_fs_glsl_default,
4184
4647
  modules: [maxWeightUniforms]
@@ -4187,7 +4650,8 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4187
4650
  id: `${this.id}-max-weights-transform`,
4188
4651
  targetTexture: maxWeightsTexture,
4189
4652
  ...maxWeightsTransformShaders,
4190
- vertexCount: textureSize * textureSize,
4653
+ ...device.type === "webgpu" ? { colorAttachmentFormats: [maxWeightsTexture.format] } : {},
4654
+ vertexCount: device.type === "webgpu" ? Math.ceil(textureSize / MAX_WEIGHT_REDUCTION_SIZE) ** 2 : textureSize * textureSize,
4191
4655
  topology: "point-list",
4192
4656
  parameters: {
4193
4657
  depthWriteEnabled: false,
@@ -4299,7 +4763,13 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4299
4763
  const attributes = attributeManager.getAttributes();
4300
4764
  const moduleSettings = this.getModuleSettings();
4301
4765
  this._setModelAttributes(weightsTransform.model, attributes);
4302
- weightsTransform.model.setVertexCount(this.getNumInstances());
4766
+ if (this.context.device.type === "webgpu") {
4767
+ const instanceCount = this.getNumInstances();
4768
+ weightsTransform.model.setVertexCount(instanceCount > 0 ? 6 : 0);
4769
+ weightsTransform.model.setInstanceCount(instanceCount);
4770
+ } else {
4771
+ weightsTransform.model.setVertexCount(this.getNumInstances());
4772
+ }
4303
4773
  const weightProps = {
4304
4774
  radiusPixels,
4305
4775
  commonBounds,