@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
@@ -0,0 +1,120 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export default /* wgsl */ `\
6
+ const HEXBIN_DISTANCE: vec2<f32> = vec2<f32>(1.7320508, 1.5);
7
+
8
+ struct Attributes {
9
+ @builtin(instance_index) instanceIndex: u32,
10
+ @location(0) positions: vec3<f32>,
11
+ @location(1) normals: vec3<f32>,
12
+ @location(2) instancePositions: vec2<f32>,
13
+ @location(3) instanceColorValues: f32,
14
+ @location(4) instanceElevationValues: f32,
15
+ };
16
+
17
+ struct Varyings {
18
+ @builtin(position) position: vec4<f32>,
19
+ @location(0) color: vec4<f32>,
20
+ @location(1) pickingColor: vec3<f32>,
21
+ };
22
+
23
+ fn hexbinCentroid(binId: vec2<f32>, radius: f32) -> vec2<f32> {
24
+ var adjustedBinId = binId;
25
+ adjustedBinId.x += fract(adjustedBinId.y * 0.5);
26
+ return adjustedBinId * HEXBIN_DISTANCE * radius;
27
+ }
28
+
29
+ fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
30
+ let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
31
+ return mix(range.x, range.y, ratio);
32
+ }
33
+
34
+ fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
35
+ let ratio = (value - domain.x) / (domain.y - domain.x);
36
+ return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
37
+ }
38
+
39
+ @vertex
40
+ fn vertexMain(attributes: Attributes) -> Varyings {
41
+ var output: Varyings;
42
+ geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
43
+ output.pickingColor = geometry.pickingColor;
44
+
45
+ if (
46
+ attributes.instanceColorValues != attributes.instanceColorValues ||
47
+ attributes.instanceColorValues < hexagon.colorDomain.z ||
48
+ attributes.instanceColorValues > hexagon.colorDomain.w ||
49
+ attributes.instanceElevationValues < hexagon.elevationDomain.z ||
50
+ attributes.instanceElevationValues > hexagon.elevationDomain.w
51
+ ) {
52
+ output.position = vec4<f32>(0.0);
53
+ output.color = vec4<f32>(0.0);
54
+ return output;
55
+ }
56
+
57
+ var commonPosition =
58
+ hexbinCentroid(attributes.instancePositions, column.radius) +
59
+ (hexagon.originCommon - project.commonOrigin.xy);
60
+ commonPosition += attributes.positions.xy * column.radius * column.coverage;
61
+ geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
62
+ geometry.normal = project_normal(attributes.normals);
63
+
64
+ if (column.extruded > 0.5) {
65
+ var elevation = interpolate(
66
+ attributes.instanceElevationValues,
67
+ hexagon.elevationDomain.xy,
68
+ hexagon.elevationRange
69
+ );
70
+ elevation = project_size_float(elevation);
71
+ geometry.position.z = (attributes.positions.z + 1.0) / 2.0 * elevation;
72
+ }
73
+
74
+ output.position = project_common_position_to_clipspace(geometry.position);
75
+ var colorValue = sampleColorRange(attributes.instanceColorValues, hexagon.colorDomain.xy);
76
+ if (column.extruded > 0.5) {
77
+ colorValue = vec4<f32>(
78
+ lighting_getLightColor2(
79
+ colorValue.rgb,
80
+ project.cameraPosition,
81
+ geometry.position.xyz,
82
+ geometry.normal
83
+ ),
84
+ colorValue.a
85
+ );
86
+ }
87
+ output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
88
+ return output;
89
+ }
90
+
91
+ @fragment
92
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
93
+ if (picking.isActive > 0.5) {
94
+ if (!picking_isColorValid(varyings.pickingColor)) {
95
+ discard;
96
+ }
97
+ return vec4<f32>(varyings.pickingColor, 1.0);
98
+ }
99
+
100
+ var color = varyings.color;
101
+ if (picking.isHighlightActive > 0.5) {
102
+ let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
103
+ if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
104
+ let highLightAlpha = picking.highlightColor.a;
105
+ let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
106
+ if (blendedAlpha > 0.0) {
107
+ let highLightRatio = highLightAlpha / blendedAlpha;
108
+ color = vec4<f32>(
109
+ mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
110
+ blendedAlpha
111
+ );
112
+ } else {
113
+ color = vec4<f32>(color.rgb, 0.0);
114
+ }
115
+ }
116
+ }
117
+
118
+ return deckgl_premultiplied_alpha(color);
119
+ }
120
+ `;
@@ -5,6 +5,19 @@
5
5
  import {Texture} from '@luma.gl/core';
6
6
  import type {ShaderModule} from '@luma.gl/shadertools';
7
7
 
8
+ const uniformBlockWGSL = /* wgsl */ `\
9
+ struct HexagonUniforms {
10
+ colorDomain: vec4<f32>,
11
+ elevationDomain: vec4<f32>,
12
+ elevationRange: vec2<f32>,
13
+ originCommon: vec2<f32>,
14
+ };
15
+
16
+ @group(0) @binding(auto) var<uniform> hexagon: HexagonUniforms;
17
+ @group(0) @binding(auto) var colorRange: texture_2d<f32>;
18
+ @group(0) @binding(auto) var colorRangeSampler: sampler;
19
+ `;
20
+
8
21
  const uniformBlock = /* glsl */ `\
9
22
  layout(std140) uniform hexagonUniforms {
10
23
  vec4 colorDomain;
@@ -24,6 +37,7 @@ export type HexagonProps = {
24
37
 
25
38
  export const hexagonUniforms = {
26
39
  name: 'hexagon',
40
+ source: uniformBlockWGSL,
27
41
  vs: uniformBlock,
28
42
  uniformTypes: {
29
43
  colorDomain: 'vec4<f32>',
@@ -4,12 +4,12 @@
4
4
 
5
5
  import {Texture} from '@luma.gl/core';
6
6
  import {Model, Geometry} from '@luma.gl/engine';
7
- import {Layer, picking, UpdateParameters, Color} from '@deck.gl/core';
7
+ import {Layer, color, picking, UpdateParameters, Color} from '@deck.gl/core';
8
8
  import {createColorRangeTexture, updateColorRangeTexture} from '../common/utils/color-utils';
9
+ import source from './screen-grid-cell-layer.wgsl';
9
10
  import vs from './screen-grid-layer-vertex.glsl';
10
11
  import fs from './screen-grid-layer-fragment.glsl';
11
12
  import {ScreenGridProps, screenGridUniforms} from './screen-grid-layer-uniforms';
12
- import {ShaderModule} from '@luma.gl/shadertools';
13
13
  import type {ScaleType} from '../common/types';
14
14
 
15
15
  /** Proprties added by ScreenGridCellLayer. */
@@ -31,8 +31,8 @@ export default class ScreenGridCellLayer<ExtraPropsT extends {} = {}> extends La
31
31
  colorTexture: Texture;
32
32
  };
33
33
 
34
- getShaders(): {vs: string; fs: string; modules: ShaderModule[]} {
35
- return super.getShaders({vs, fs, modules: [picking, screenGridUniforms]});
34
+ getShaders() {
35
+ return super.getShaders({source, vs, fs, modules: [color, picking, screenGridUniforms]});
36
36
  }
37
37
 
38
38
  initializeState() {
@@ -0,0 +1,76 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export default /* wgsl */ `
6
+ struct Attributes {
7
+ @builtin(instance_index) instanceIndex: u32,
8
+ @location(0) positions: vec2<f32>,
9
+ @location(1) instancePositions: vec2<f32>,
10
+ @location(2) instanceWeights: f32,
11
+ };
12
+
13
+ struct Varyings {
14
+ @builtin(position) position: vec4<f32>,
15
+ @location(0) color: vec4<f32>,
16
+ @location(1) pickingColor: vec3<f32>,
17
+ };
18
+
19
+ fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
20
+ let ratio = (value - domain.x) / (domain.y - domain.x);
21
+ return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
22
+ }
23
+
24
+ @vertex
25
+ fn vertexMain(attributes: Attributes) -> Varyings {
26
+ var output: Varyings;
27
+ output.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
28
+
29
+ if (attributes.instanceWeights != attributes.instanceWeights) {
30
+ output.position = vec4<f32>(0.0);
31
+ output.color = vec4<f32>(0.0);
32
+ return output;
33
+ }
34
+
35
+ var position =
36
+ attributes.instancePositions * screenGrid.gridSizeClipspace +
37
+ attributes.positions * screenGrid.cellSizeClipspace;
38
+ position.x -= 1.0;
39
+ position.y = 1.0 - position.y;
40
+
41
+ output.position = vec4<f32>(position, 0.0, 1.0);
42
+ let colorValue = sampleColorRange(attributes.instanceWeights, screenGrid.colorDomain);
43
+ output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
44
+ return output;
45
+ }
46
+
47
+ @fragment
48
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
49
+ if (picking.isActive > 0.5) {
50
+ if (!picking_isColorValid(varyings.pickingColor)) {
51
+ discard;
52
+ }
53
+ return vec4<f32>(varyings.pickingColor, 1.0);
54
+ }
55
+
56
+ var color = varyings.color;
57
+ if (picking.isHighlightActive > 0.5) {
58
+ let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
59
+ if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
60
+ let highLightAlpha = picking.highlightColor.a;
61
+ let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
62
+ if (blendedAlpha > 0.0) {
63
+ let highLightRatio = highLightAlpha / blendedAlpha;
64
+ color = vec4<f32>(
65
+ mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
66
+ blendedAlpha
67
+ );
68
+ } else {
69
+ color = vec4<f32>(color.rgb, 0.0);
70
+ }
71
+ }
72
+ }
73
+
74
+ return deckgl_premultiplied_alpha(color);
75
+ }
76
+ `;
@@ -5,6 +5,18 @@
5
5
  import {Texture} from '@luma.gl/core';
6
6
  import type {ShaderModule} from '@luma.gl/shadertools';
7
7
 
8
+ const uniformBlockWGSL = /* wgsl */ `
9
+ struct ScreenGridUniforms {
10
+ cellSizeClipspace: vec2<f32>,
11
+ gridSizeClipspace: vec2<f32>,
12
+ colorDomain: vec2<f32>,
13
+ };
14
+
15
+ @group(0) @binding(auto) var<uniform> screenGrid: ScreenGridUniforms;
16
+ @group(0) @binding(auto) var colorRange: texture_2d<f32>;
17
+ @group(0) @binding(auto) var colorRangeSampler: sampler;
18
+ `;
19
+
8
20
  const uniformBlock = /* glsl */ `\
9
21
  layout(std140) uniform screenGridUniforms {
10
22
  vec2 cellSizeClipspace;
@@ -22,6 +34,7 @@ export type ScreenGridProps = {
22
34
 
23
35
  export const screenGridUniforms = {
24
36
  name: 'screenGrid',
37
+ source: uniformBlockWGSL,
25
38
  vs: uniformBlock,
26
39
  uniformTypes: {
27
40
  cellSizeClipspace: 'vec2<f32>',
@@ -10,7 +10,6 @@ export default /* glsl */ `\
10
10
  in vec2 positions;
11
11
  in vec2 instancePositions;
12
12
  in float instanceWeights;
13
- in vec3 instancePickingColors;
14
13
 
15
14
  uniform sampler2D colorRange;
16
15
 
@@ -37,6 +36,6 @@ void main(void) {
37
36
  vColor.a *= layer.opacity;
38
37
 
39
38
  // Set color to be rendered to picking fbo (also used to check for selection highlight).
40
- picking_setPickingColor(instancePickingColors);
39
+ picking_setPickingColorFromInstanceID();
41
40
  }
42
41
  `;