@deck.gl/aggregation-layers 9.4.0-alpha.1 → 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 (78) hide show
  1. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
  2. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
  3. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
  4. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
  5. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
  6. package/dist/dist.dev.js +499 -25
  7. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
  8. package/dist/grid-layer/grid-cell-layer.js +2 -1
  9. package/dist/grid-layer/grid-cell-layer.js.map +1 -1
  10. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
  11. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
  12. package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
  13. package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
  14. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  15. package/dist/heatmap-layer/heatmap-layer.js +59 -12
  16. package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
  17. package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
  18. package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
  19. package/dist/heatmap-layer/max.wgsl.js +48 -0
  20. package/dist/heatmap-layer/max.wgsl.js.map +1 -0
  21. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
  22. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
  23. package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
  24. package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
  25. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  26. package/dist/heatmap-layer/triangle-layer.js +3 -2
  27. package/dist/heatmap-layer/triangle-layer.js.map +1 -1
  28. package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
  29. package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
  30. package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
  31. package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
  32. package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
  33. package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
  34. package/dist/heatmap-layer/weights.wgsl.js +64 -0
  35. package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
  36. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
  37. package/dist/hexagon-layer/hexagon-cell-layer.js +2 -1
  38. package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
  39. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
  40. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
  41. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
  42. package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
  43. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
  44. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
  45. package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
  46. package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
  47. package/dist/index.cjs +499 -25
  48. package/dist/index.cjs.map +4 -4
  49. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
  50. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  51. package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
  52. package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  53. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
  54. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
  55. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
  56. package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
  57. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
  58. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
  59. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
  60. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
  61. package/dist.min.js +426 -35
  62. package/package.json +9 -5
  63. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
  64. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
  65. package/src/grid-layer/grid-cell-layer.ts +2 -1
  66. package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
  67. package/src/heatmap-layer/heatmap-layer.ts +67 -13
  68. package/src/heatmap-layer/max.wgsl.ts +48 -0
  69. package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
  70. package/src/heatmap-layer/triangle-layer.ts +3 -2
  71. package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
  72. package/src/heatmap-layer/weights.wgsl.ts +64 -0
  73. package/src/hexagon-layer/hexagon-cell-layer.ts +2 -1
  74. package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
  75. package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
  76. package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
  77. package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
  78. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
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"],
@@ -1068,11 +1065,11 @@ function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float3
1068
1065
  flatArray = new ArrayType(colorRange.length * 4);
1069
1066
  let index = 0;
1070
1067
  for (let i = 0; i < colorRange.length; i++) {
1071
- const color = colorRange[i];
1072
- flatArray[index++] = color[0];
1073
- flatArray[index++] = color[1];
1074
- flatArray[index++] = color[2];
1075
- 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;
1076
1073
  }
1077
1074
  }
1078
1075
  if (normalize) {
@@ -1110,6 +1107,83 @@ function createColorRangeTexture(device, colorRange, type = "linear") {
1110
1107
  });
1111
1108
  }
1112
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
+
1113
1187
  // dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js
1114
1188
  var screen_grid_layer_vertex_glsl_default = (
1115
1189
  /* glsl */
@@ -1157,6 +1231,20 @@ DECKGL_FILTER_COLOR(fragColor, geometry);
1157
1231
  );
1158
1232
 
1159
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
+ );
1160
1248
  var uniformBlock3 = (
1161
1249
  /* glsl */
1162
1250
  `layout(std140) uniform screenGridUniforms {
@@ -1168,6 +1256,7 @@ var uniformBlock3 = (
1168
1256
  );
1169
1257
  var screenGridUniforms = {
1170
1258
  name: "screenGrid",
1259
+ source: uniformBlockWGSL,
1171
1260
  vs: uniformBlock3,
1172
1261
  uniformTypes: {
1173
1262
  cellSizeClipspace: "vec2<f32>",
@@ -1179,7 +1268,7 @@ var screenGridUniforms = {
1179
1268
  // dist/screen-grid-layer/screen-grid-cell-layer.js
1180
1269
  var ScreenGridCellLayer = class extends import_core4.Layer {
1181
1270
  getShaders() {
1182
- 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] });
1183
1272
  }
1184
1273
  initializeState() {
1185
1274
  this.getAttributeManager().addInstanced({
@@ -1634,6 +1723,126 @@ function getBinIdRange({ dataBounds, getBinId, padding = 0 }) {
1634
1723
  // dist/hexagon-layer/hexagon-cell-layer.js
1635
1724
  var import_layers = require("@deck.gl/layers");
1636
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
+
1637
1846
  // dist/hexagon-layer/hexbin.js
1638
1847
  var THIRD_PI = Math.PI / 3;
1639
1848
  var DIST_X = 2 * Math.sin(THIRD_PI);
@@ -1752,6 +1961,20 @@ DECKGL_FILTER_COLOR(vColor, geometry);
1752
1961
  );
1753
1962
 
1754
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
+ );
1755
1978
  var uniformBlock5 = (
1756
1979
  /* glsl */
1757
1980
  `layout(std140) uniform hexagonUniforms {
@@ -1764,6 +1987,7 @@ var uniformBlock5 = (
1764
1987
  );
1765
1988
  var hexagonUniforms = {
1766
1989
  name: "hexagon",
1990
+ source: uniformBlockWGSL2,
1767
1991
  vs: uniformBlock5,
1768
1992
  uniformTypes: {
1769
1993
  colorDomain: "vec4<f32>",
@@ -1778,7 +2002,7 @@ var HexagonCellLayer = class extends import_layers.ColumnLayer {
1778
2002
  getShaders() {
1779
2003
  const shaders = super.getShaders();
1780
2004
  shaders.modules.push(hexagonUniforms);
1781
- 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 };
1782
2006
  }
1783
2007
  initializeState() {
1784
2008
  super.initializeState();
@@ -3153,7 +3377,8 @@ var GridCellLayer = class extends import_layers3.ColumnLayer {
3153
3377
  }
3154
3378
  _updateGeometry() {
3155
3379
  const geometry = new import_engine4.CubeGeometry();
3156
- this.state.fillModel.setGeometry(geometry);
3380
+ this._setFillGeometry(geometry);
3381
+ this._setWireframeGeometry(geometry);
3157
3382
  }
3158
3383
  draw({ uniforms }) {
3159
3384
  const { cellOriginCommon, cellSizeCommon, elevationRange, elevationScale, extruded, coverage, colorDomain, elevationDomain } = this.props;
@@ -3607,6 +3832,71 @@ var import_core12 = require("@deck.gl/core");
3607
3832
  var import_engine5 = require("@luma.gl/engine");
3608
3833
  var import_core10 = require("@deck.gl/core");
3609
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
+
3610
3900
  // dist/heatmap-layer/triangle-layer-vertex.glsl.js
3611
3901
  var triangle_layer_vertex_glsl_default = `#version 300 es
3612
3902
  #define SHADER_NAME heatp-map-layer-vertex-shader
@@ -3663,6 +3953,23 @@ fragColor = linearColor;
3663
3953
  `;
3664
3954
 
3665
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
+ );
3666
3973
  var uniformBlock10 = `layout(std140) uniform triangleUniforms {
3667
3974
  float aggregationMode;
3668
3975
  vec2 colorDomain;
@@ -3672,6 +3979,7 @@ var uniformBlock10 = `layout(std140) uniform triangleUniforms {
3672
3979
  `;
3673
3980
  var triangleUniforms = {
3674
3981
  name: "triangle",
3982
+ source: uniformBlockWGSL3,
3675
3983
  vs: uniformBlock10,
3676
3984
  fs: uniformBlock10,
3677
3985
  uniformTypes: {
@@ -3685,7 +3993,7 @@ var triangleUniforms = {
3685
3993
  // dist/heatmap-layer/triangle-layer.js
3686
3994
  var TriangleLayer = class extends import_core10.Layer {
3687
3995
  getShaders() {
3688
- 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] });
3689
3997
  }
3690
3998
  initializeState({ device }) {
3691
3999
  this.setState({ model: this._getModel(device) });
@@ -3919,7 +4227,131 @@ fragColor.g = outTexture.r / max(1.0, outTexture.a);
3919
4227
  }
3920
4228
  `;
3921
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
+
3922
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
+ );
3923
4355
  var uniformBlock11 = `layout(std140) uniform weightUniforms {
3924
4356
  vec4 commonBounds;
3925
4357
  float radiusPixels;
@@ -3929,6 +4361,7 @@ var uniformBlock11 = `layout(std140) uniform weightUniforms {
3929
4361
  `;
3930
4362
  var weightUniforms = {
3931
4363
  name: "weight",
4364
+ source: uniformBlockWGSL4,
3932
4365
  vs: uniformBlock11,
3933
4366
  uniformTypes: {
3934
4367
  commonBounds: "vec4<f32>",
@@ -3939,6 +4372,16 @@ var weightUniforms = {
3939
4372
  };
3940
4373
  var maxWeightUniforms = {
3941
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
+ ),
3942
4385
  vs: `layout(std140) uniform maxWeightUniforms {
3943
4386
  float textureSize;
3944
4387
  } maxWeight;
@@ -3950,6 +4393,7 @@ var maxWeightUniforms = {
3950
4393
 
3951
4394
  // dist/heatmap-layer/heatmap-layer.js
3952
4395
  var RESOLUTION = 2;
4396
+ var MAX_WEIGHT_REDUCTION_SIZE = 16;
3953
4397
  var TEXTURE_PROPS = {
3954
4398
  format: "rgba8unorm",
3955
4399
  dimension: "2d",
@@ -4122,18 +4566,33 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4122
4566
  }
4123
4567
  _setupAttributes() {
4124
4568
  const attributeManager = this.getAttributeManager();
4125
- attributeManager.add({
4126
- positions: { size: 3, type: "float64", accessor: "getPosition" },
4127
- weights: { size: 1, accessor: "getWeight" }
4128
- });
4129
- 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
+ }
4130
4588
  }
4131
4589
  _setupTextureParams() {
4132
4590
  const { device } = this.context;
4133
4591
  const { weightsTextureSize } = this.props;
4134
4592
  const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
4135
- const floatTargetSupport = FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
4136
- 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";
4137
4596
  const weightsScale = floatTargetSupport ? 1 : 1 / 255;
4138
4597
  this.setState({ textureSize, format, weightsScale });
4139
4598
  if (!floatTargetSupport) {
@@ -4143,13 +4602,20 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4143
4602
  _createWeightsTransform(shaders) {
4144
4603
  let { weightsTransform } = this.state;
4145
4604
  const { weightsTexture } = this.state;
4605
+ const isWebGPU = this.context.device.type === "webgpu";
4146
4606
  const attributeManager = this.getAttributeManager();
4147
4607
  weightsTransform == null ? void 0 : weightsTransform.destroy();
4148
4608
  weightsTransform = new import_engine6.TextureTransform(this.context.device, {
4149
4609
  id: `${this.id}-weights-transform`,
4150
4610
  ...shaders,
4151
- bufferLayout: attributeManager.getBufferLayouts(),
4152
- 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
+ } : {},
4153
4619
  targetTexture: weightsTexture,
4154
4620
  parameters: {
4155
4621
  depthWriteEnabled: false,
@@ -4160,7 +4626,7 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4160
4626
  blendAlphaSrcFactor: "one",
4161
4627
  blendAlphaDstFactor: "one"
4162
4628
  },
4163
- topology: "point-list",
4629
+ topology: isWebGPU ? "triangle-list" : "point-list",
4164
4630
  modules: [...shaders.modules, weightUniforms]
4165
4631
  });
4166
4632
  this.setState({ weightsTransform });
@@ -4175,6 +4641,7 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4175
4641
  });
4176
4642
  this._createWeightsTransform(weightsTransformShaders);
4177
4643
  const maxWeightsTransformShaders = this.getShaders({
4644
+ source: max_wgsl_default,
4178
4645
  vs: max_vs_glsl_default,
4179
4646
  fs: max_fs_glsl_default,
4180
4647
  modules: [maxWeightUniforms]
@@ -4183,7 +4650,8 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4183
4650
  id: `${this.id}-max-weights-transform`,
4184
4651
  targetTexture: maxWeightsTexture,
4185
4652
  ...maxWeightsTransformShaders,
4186
- 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,
4187
4655
  topology: "point-list",
4188
4656
  parameters: {
4189
4657
  depthWriteEnabled: false,
@@ -4295,7 +4763,13 @@ var HeatmapLayer = class extends aggregation_layer_default2 {
4295
4763
  const attributes = attributeManager.getAttributes();
4296
4764
  const moduleSettings = this.getModuleSettings();
4297
4765
  this._setModelAttributes(weightsTransform.model, attributes);
4298
- 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
+ }
4299
4773
  const weightProps = {
4300
4774
  radiusPixels,
4301
4775
  commonBounds,