@deck.gl/aggregation-layers 8.10.0-alpha.6 → 9.0.0-alpha.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 (184) hide show
  1. package/dist/dist.dev.js +9369 -356
  2. package/dist/es5/aggregation-layer.js +4 -6
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +13 -2
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +12 -1
  7. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  8. package/dist/es5/cpu-grid-layer/grid-aggregator.js +12 -8
  9. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  10. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +27 -13
  11. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  12. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +19 -10
  13. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  14. package/dist/es5/grid-aggregation-layer.js +7 -9
  15. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  16. package/dist/es5/grid-layer/grid-layer.js +1 -1
  17. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  18. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +3 -3
  19. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  20. package/dist/es5/heatmap-layer/heatmap-layer.js +58 -55
  21. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  22. package/dist/es5/heatmap-layer/triangle-layer.js +22 -12
  23. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  24. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  25. package/dist/es5/hexagon-layer/hexagon-layer.js +2 -0
  26. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  27. package/dist/es5/index.js.map +1 -1
  28. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +23 -20
  29. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  30. package/dist/es5/screen-grid-layer/screen-grid-layer.js +6 -6
  31. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  32. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  33. package/dist/es5/utils/bin-sorter.js.map +1 -1
  34. package/dist/es5/utils/cpu-aggregator.js +11 -7
  35. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  36. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +7 -2
  37. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  38. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +83 -60
  39. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  40. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  41. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  42. package/dist/es5/utils/prop-utils.js.map +1 -1
  43. package/dist/es5/utils/resource-utils.js +12 -23
  44. package/dist/es5/utils/resource-utils.js.map +1 -1
  45. package/dist/esm/aggregation-layer.js +4 -5
  46. package/dist/esm/aggregation-layer.js.map +1 -1
  47. package/dist/esm/contour-layer/contour-layer.js +7 -1
  48. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  49. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -0
  50. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  51. package/dist/esm/cpu-grid-layer/grid-aggregator.js +2 -1
  52. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
  53. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +19 -10
  54. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  55. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +13 -10
  56. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  57. package/dist/esm/grid-aggregation-layer.js +4 -8
  58. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  59. package/dist/esm/grid-layer/grid-layer.js +1 -1
  60. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  61. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +3 -3
  62. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  63. package/dist/esm/heatmap-layer/heatmap-layer.js +40 -58
  64. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  65. package/dist/esm/heatmap-layer/triangle-layer.js +13 -7
  66. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  67. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +1 -1
  68. package/dist/esm/hexagon-layer/hexagon-layer.js +1 -0
  69. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  70. package/dist/esm/index.js.map +1 -1
  71. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +21 -24
  72. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  73. package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -8
  74. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  75. package/dist/esm/utils/aggregation-operation-utils.js.map +1 -1
  76. package/dist/esm/utils/bin-sorter.js.map +1 -1
  77. package/dist/esm/utils/cpu-aggregator.js +11 -7
  78. package/dist/esm/utils/cpu-aggregator.js.map +1 -1
  79. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
  80. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
  81. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
  82. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
  83. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +4 -3
  84. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  85. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +62 -51
  86. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  87. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  88. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
  89. package/dist/esm/utils/grid-aggregation-utils.js.map +1 -1
  90. package/dist/esm/utils/prop-utils.js.map +1 -1
  91. package/dist/esm/utils/resource-utils.js +10 -17
  92. package/dist/esm/utils/resource-utils.js.map +1 -1
  93. package/dist.min.js +185 -30
  94. package/package.json +8 -6
  95. package/src/aggregation-layer.ts +7 -6
  96. package/src/contour-layer/contour-layer.ts +25 -9
  97. package/src/cpu-grid-layer/cpu-grid-layer.ts +8 -3
  98. package/src/cpu-grid-layer/{grid-aggregator.js → grid-aggregator.ts} +28 -4
  99. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +38 -27
  100. package/src/gpu-grid-layer/gpu-grid-layer.ts +18 -12
  101. package/src/grid-aggregation-layer.ts +39 -13
  102. package/src/grid-layer/grid-layer.ts +2 -2
  103. package/src/heatmap-layer/heatmap-layer-utils.ts +10 -4
  104. package/src/heatmap-layer/heatmap-layer.ts +74 -67
  105. package/src/heatmap-layer/triangle-layer.ts +26 -22
  106. package/src/hexagon-layer/{hexagon-aggregator.js → hexagon-aggregator.ts} +5 -1
  107. package/src/hexagon-layer/hexagon-layer.ts +8 -5
  108. package/src/index.ts +0 -1
  109. package/src/screen-grid-layer/screen-grid-cell-layer.ts +36 -33
  110. package/src/screen-grid-layer/screen-grid-layer.ts +12 -11
  111. package/src/utils/{aggregation-operation-utils.js → aggregation-operation-utils.ts} +8 -2
  112. package/src/utils/bin-sorter.ts +1 -1
  113. package/src/utils/{cpu-aggregator.js → cpu-aggregator.ts} +42 -30
  114. package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-constants.js → gpu-grid-aggregator-constants.ts} +4 -4
  115. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  116. package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator.js → gpu-grid-aggregator.ts} +123 -94
  117. package/src/utils/{grid-aggregation-utils.js → grid-aggregation-utils.ts} +1 -1
  118. package/src/utils/resource-utils.ts +59 -0
  119. package/typed/aggregation-layer.d.ts +4 -3
  120. package/typed/aggregation-layer.d.ts.map +1 -1
  121. package/typed/contour-layer/contour-layer.d.ts +19 -5
  122. package/typed/contour-layer/contour-layer.d.ts.map +1 -1
  123. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +8 -3
  124. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
  125. package/typed/cpu-grid-layer/grid-aggregator.d.ts +16 -4
  126. package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -1
  127. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +18 -4
  128. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
  129. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +8 -3
  130. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
  131. package/typed/grid-aggregation-layer.d.ts +39 -4
  132. package/typed/grid-aggregation-layer.d.ts.map +1 -1
  133. package/typed/grid-layer/grid-layer.d.ts +2 -2
  134. package/typed/grid-layer/grid-layer.d.ts.map +1 -1
  135. package/typed/heatmap-layer/heatmap-layer-utils.d.ts +7 -5
  136. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  137. package/typed/heatmap-layer/heatmap-layer.d.ts +19 -6
  138. package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  139. package/typed/heatmap-layer/triangle-layer.d.ts +10 -6
  140. package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
  141. package/typed/hexagon-layer/hexagon-aggregator.d.ts +6 -3
  142. package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -1
  143. package/typed/hexagon-layer/hexagon-layer.d.ts +5 -4
  144. package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  145. package/typed/index.d.ts.map +1 -1
  146. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +10 -9
  147. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  148. package/typed/screen-grid-layer/screen-grid-layer.d.ts +6 -4
  149. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  150. package/typed/utils/aggregation-operation-utils.d.ts +18 -12
  151. package/typed/utils/aggregation-operation-utils.d.ts.map +1 -1
  152. package/typed/utils/bin-sorter.d.ts +1 -1
  153. package/typed/utils/bin-sorter.d.ts.map +1 -1
  154. package/typed/utils/cpu-aggregator.d.ts +28 -14
  155. package/typed/utils/cpu-aggregator.d.ts.map +1 -1
  156. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +1 -1
  157. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -1
  158. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +1 -1
  159. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -1
  160. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +1 -1
  161. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -1
  162. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +1 -1
  163. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -1
  164. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +35 -33
  165. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -1
  166. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -1
  167. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +29 -19
  168. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  169. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +1 -1
  170. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -1
  171. package/typed/utils/grid-aggregation-utils.d.ts +11 -5
  172. package/typed/utils/grid-aggregation-utils.d.ts.map +1 -1
  173. package/typed/utils/prop-utils.d.ts +1 -1
  174. package/typed/utils/prop-utils.d.ts.map +1 -1
  175. package/typed/utils/resource-utils.d.ts +13 -3
  176. package/typed/utils/resource-utils.d.ts.map +1 -1
  177. package/src/utils/resource-utils.js +0 -51
  178. /package/src/utils/gpu-grid-aggregation/{aggregate-all-fs.glsl.js → aggregate-all-fs.glsl.ts} +0 -0
  179. /package/src/utils/gpu-grid-aggregation/{aggregate-all-vs.glsl.js → aggregate-all-vs.glsl.ts} +0 -0
  180. /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-fs.glsl.js → aggregate-to-grid-fs.glsl.ts} +0 -0
  181. /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-vs.glsl.js → aggregate-to-grid-vs.glsl.ts} +0 -0
  182. /package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-utils.js → gpu-grid-aggregator-utils.ts} +0 -0
  183. /package/src/utils/gpu-grid-aggregation/{transform-mean-vs.glsl.js → transform-mean-vs.glsl.ts} +0 -0
  184. /package/src/utils/{prop-utils.js → prop-utils.ts} +0 -0
@@ -19,7 +19,6 @@
19
19
  // THE SOFTWARE.
20
20
 
21
21
  /* global setTimeout clearTimeout */
22
- import GL from '@luma.gl/constants';
23
22
  import {
24
23
  getBounds,
25
24
  boundsContain,
@@ -28,15 +27,10 @@ import {
28
27
  getTextureCoordinates,
29
28
  getTextureParams
30
29
  } from './heatmap-layer-utils';
31
- import {
32
- Buffer,
33
- Texture2D,
34
- Transform,
35
- getParameters,
36
- withParameters,
37
- FEATURES,
38
- hasFeatures
39
- } from '@luma.gl/core';
30
+ import {DeviceFeature, Texture, TextureProps, TextureFormat} from '@luma.gl/core';
31
+ import {GL} from '@luma.gl/constants';
32
+ import {Transform} from '@luma.gl/engine';
33
+ import {BufferWithAccessor, withGLParameters} from '@luma.gl/webgl';
40
34
  import {
41
35
  Accessor,
42
36
  AccessorFunction,
@@ -61,15 +55,15 @@ import vsMax from './max-vs.glsl';
61
55
  import fsMax from './max-fs.glsl';
62
56
 
63
57
  const RESOLUTION = 2; // (number of common space pixels) / (number texels)
64
- const TEXTURE_OPTIONS = {
58
+ const TEXTURE_PROPS: TextureProps = {
59
+ format: 'rgba8unorm',
65
60
  mipmaps: false,
66
- parameters: {
67
- [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
68
- [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
69
- [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
70
- [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
71
- },
72
- dataFormat: GL.RGBA
61
+ sampler: {
62
+ minFilter: 'nearest',
63
+ magFilter: 'nearest',
64
+ addressModeU: 'clamp-to-edge',
65
+ addressModeV: 'clamp-to-edge'
66
+ }
73
67
  };
74
68
  const DEFAULT_COLOR_DOMAIN = [0, 0];
75
69
  const AGGREGATION_MODE = {
@@ -78,7 +72,7 @@ const AGGREGATION_MODE = {
78
72
  };
79
73
 
80
74
  const defaultProps: DefaultProps<HeatmapLayerProps> = {
81
- getPosition: {type: 'accessor', value: x => x.position},
75
+ getPosition: {type: 'accessor', value: (x: any) => x.position},
82
76
  getWeight: {type: 'accessor', value: 1},
83
77
  intensity: {type: 'number', min: 0, value: 1},
84
78
  radiusPixels: {type: 'number', min: 1, max: 100, value: 50},
@@ -91,14 +85,14 @@ const defaultProps: DefaultProps<HeatmapLayerProps> = {
91
85
  debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}
92
86
  };
93
87
 
94
- const REQUIRED_FEATURES = [
95
- FEATURES.BLEND_EQUATION_MINMAX, // max weight calculation
96
- FEATURES.TEXTURE_FLOAT // weight-map as texture
88
+ const REQUIRED_FEATURES: DeviceFeature[] = [
89
+ 'blend-minmax-webgl1', // max weight calculation
90
+ 'texture-formats-float32-webgl1' // weight-map as texture
97
91
  ];
98
92
 
99
- const FLOAT_TARGET_FEATURES = [
100
- FEATURES.COLOR_ATTACHMENT_RGBA32F, // ability to render to float texture
101
- FEATURES.FLOAT_BLEND // ability to blend when rendering to float texture
93
+ const FLOAT_TARGET_FEATURES: DeviceFeature[] = [
94
+ 'texture-renderable-float32-webgl', // ability to render to float texture
95
+ 'texture-blend-float-webgl1' // ability to blend when rendering to float texture
102
96
  ];
103
97
 
104
98
  const DIMENSIONS = {
@@ -107,7 +101,7 @@ const DIMENSIONS = {
107
101
  }
108
102
  };
109
103
 
110
- export type HeatmapLayerProps<DataT = any> = _HeatmapLayerProps<DataT> &
104
+ export type HeatmapLayerProps<DataT = unknown> = _HeatmapLayerProps<DataT> &
111
105
  AggregationLayerProps<DataT>;
112
106
 
113
107
  type _HeatmapLayerProps<DataT> = {
@@ -198,18 +192,27 @@ export default class HeatmapLayer<
198
192
  supported: boolean;
199
193
  colorDomain?: number[];
200
194
  isWeightMapDirty?: boolean;
201
- weightsTexture?: Texture2D;
195
+ weightsTexture?: Texture;
196
+ maxWeightsTexture?: Texture;
197
+ colorTexture?: Texture;
202
198
  zoom?: number;
203
199
  worldBounds?: number[];
204
200
  normalizedCommonBounds?: number[];
205
201
  updateTimer?: any;
206
- triPositionBuffer?: Buffer;
207
- triTexCoordBuffer?: Buffer;
202
+ triPositionBuffer?: BufferWithAccessor;
203
+ triTexCoordBuffer?: BufferWithAccessor;
204
+ weightsTransform?: Transform;
205
+ maxWeightTransform?: Transform;
206
+ textureSize: number;
207
+ format: TextureFormat;
208
+ type: GL;
209
+ weightsScale: number;
210
+ visibleWorldBounds: number[];
211
+ viewportCorners: number[][];
208
212
  };
209
213
 
210
214
  initializeState() {
211
- const {gl} = this.context;
212
- if (!hasFeatures(gl, REQUIRED_FEATURES)) {
215
+ if (!REQUIRED_FEATURES.every(feature => this.context.device.features.has(feature))) {
213
216
  this.setState({supported: false});
214
217
  log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
215
218
  return;
@@ -320,13 +323,13 @@ export default class HeatmapLayer<
320
323
  colorTexture,
321
324
  updateTimer
322
325
  } = this.state;
323
- weightsTransform?.delete();
324
- weightsTexture?.delete();
325
- maxWeightTransform?.delete();
326
- maxWeightsTexture?.delete();
327
- triPositionBuffer?.delete();
328
- triTexCoordBuffer?.delete();
329
- colorTexture?.delete();
326
+ weightsTransform?.destroy();
327
+ weightsTexture?.destroy();
328
+ maxWeightTransform?.destroy();
329
+ maxWeightsTexture?.destroy();
330
+ triPositionBuffer?.destroy();
331
+ triTexCoordBuffer?.destroy();
332
+ colorTexture?.destroy();
330
333
  if (updateTimer) {
331
334
  clearTimeout(updateTimer);
332
335
  }
@@ -336,7 +339,7 @@ export default class HeatmapLayer<
336
339
 
337
340
  // override Composite layer private method to create AttributeManager instance
338
341
  _getAttributeManager() {
339
- return new AttributeManager(this.context.gl, {
342
+ return new AttributeManager(this.context.device, {
340
343
  id: this.props.id,
341
344
  stats: this.context.stats
342
345
  });
@@ -349,11 +352,12 @@ export default class HeatmapLayer<
349
352
  } = {};
350
353
  const {dimensions} = this.state;
351
354
  changeFlags.dataChanged =
352
- this.isAttributeChanged() || // if any attribute is changed
353
- this.isAggregationDirty(opts, {
355
+ (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed
356
+ (this.isAggregationDirty(opts, {
354
357
  compareAll: true,
355
358
  dimension: dimensions.data
356
- });
359
+ }) &&
360
+ 'aggregation is dirty');
357
361
  changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
358
362
 
359
363
  const {zoom} = this.state;
@@ -365,18 +369,17 @@ export default class HeatmapLayer<
365
369
  }
366
370
 
367
371
  _createTextures() {
368
- const {gl} = this.context;
369
372
  const {textureSize, format, type} = this.state;
370
373
 
371
374
  this.setState({
372
- weightsTexture: new Texture2D(gl, {
375
+ weightsTexture: this.context.device.createTexture({
373
376
  width: textureSize,
374
377
  height: textureSize,
375
378
  format,
376
379
  type,
377
- ...TEXTURE_OPTIONS
380
+ ...TEXTURE_PROPS
378
381
  }),
379
- maxWeightsTexture: new Texture2D(gl, {format, type, ...TEXTURE_OPTIONS}) // 1 X 1 texture,
382
+ maxWeightsTexture: this.context.device.createTexture({format, type, ...TEXTURE_PROPS}) // 1 X 1 texture,
380
383
  });
381
384
  }
382
385
 
@@ -390,12 +393,12 @@ export default class HeatmapLayer<
390
393
  }
391
394
 
392
395
  _setupTextureParams() {
393
- const {gl} = this.context;
396
+ const {device} = this.context;
394
397
  const {weightsTextureSize} = this.props;
395
398
 
396
- const textureSize = Math.min(weightsTextureSize, getParameters(gl, gl.MAX_TEXTURE_SIZE));
397
- const floatTargetSupport = hasFeatures(gl, FLOAT_TARGET_FEATURES);
398
- const {format, type} = getTextureParams({gl, floatTargetSupport});
399
+ const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D as number);
400
+ const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
401
+ const {format, type} = getTextureParams({device, floatTargetSupport});
399
402
  const weightsScale = floatTargetSupport ? 1 : 1 / 255;
400
403
  this.setState({textureSize, format, type, weightsScale});
401
404
  if (!floatTargetSupport) {
@@ -420,12 +423,11 @@ export default class HeatmapLayer<
420
423
  }
421
424
 
422
425
  _createWeightsTransform(shaders = {}) {
423
- const {gl} = this.context;
424
426
  let {weightsTransform} = this.state;
425
427
  const {weightsTexture} = this.state;
426
428
  weightsTransform?.delete();
427
429
 
428
- weightsTransform = new Transform(gl, {
430
+ weightsTransform = new Transform(this.context.device, {
429
431
  id: `${this.id}-weights-transform`,
430
432
  elementCount: 1,
431
433
  _targetTexture: weightsTexture,
@@ -436,7 +438,6 @@ export default class HeatmapLayer<
436
438
  }
437
439
 
438
440
  _setupResources() {
439
- const {gl} = this.context;
440
441
  this._createTextures();
441
442
  const {textureSize, weightsTexture, maxWeightsTexture} = this.state;
442
443
 
@@ -444,7 +445,7 @@ export default class HeatmapLayer<
444
445
  this._createWeightsTransform(weightsTransformShaders);
445
446
 
446
447
  const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
447
- const maxWeightTransform = new Transform(gl, {
448
+ const maxWeightTransform = new Transform(this.context.device, {
448
449
  id: `${this.id}-max-weights-transform`,
449
450
  _sourceTextures: {
450
451
  inTexture: weightsTexture
@@ -460,12 +461,14 @@ export default class HeatmapLayer<
460
461
  maxWeightsTexture,
461
462
  maxWeightTransform,
462
463
  zoom: null,
463
- triPositionBuffer: new Buffer(gl, {
464
+ triPositionBuffer: this.context.device.createBuffer({
464
465
  byteLength: 48,
466
+ // @ts-expect-error
465
467
  accessor: {size: 3}
466
468
  }),
467
- triTexCoordBuffer: new Buffer(gl, {
469
+ triTexCoordBuffer: this.context.device.createBuffer({
468
470
  byteLength: 48,
471
+ // @ts-expect-error
469
472
  accessor: {size: 2}
470
473
  })
471
474
  });
@@ -479,7 +482,7 @@ export default class HeatmapLayer<
479
482
 
480
483
  _updateMaxWeightValue() {
481
484
  const {maxWeightTransform} = this.state;
482
- maxWeightTransform.run({
485
+ maxWeightTransform!.run({
483
486
  parameters: {
484
487
  blend: true,
485
488
  depthTest: false,
@@ -547,12 +550,12 @@ export default class HeatmapLayer<
547
550
 
548
551
  const {viewport} = this.context;
549
552
 
550
- triPositionBuffer.subData(packVertices(viewportCorners, 3));
553
+ triPositionBuffer!.subData(packVertices(viewportCorners, 3));
551
554
 
552
555
  const textureBounds = viewportCorners.map(p =>
553
556
  getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds!)
554
557
  );
555
- triTexCoordBuffer.subData(packVertices(textureBounds, 2));
558
+ triTexCoordBuffer!.subData(packVertices(textureBounds, 2));
556
559
  }
557
560
 
558
561
  _updateColorTexture(opts) {
@@ -561,16 +564,17 @@ export default class HeatmapLayer<
561
564
  const colors = colorRangeToFlatArray(colorRange, false, Uint8Array as any);
562
565
 
563
566
  if (colorTexture) {
567
+ // @ts-expect-error TODO - no longer supported in v9?
564
568
  colorTexture.setImageData({
565
569
  data: colors,
566
570
  width: colorRange.length
567
571
  });
568
572
  } else {
569
- colorTexture = new Texture2D(this.context.gl, {
573
+ colorTexture = this.context.device.createTexture({
570
574
  data: colors,
571
575
  width: colorRange.length,
572
576
  height: 1,
573
- ...TEXTURE_OPTIONS
577
+ ...TEXTURE_PROPS
574
578
  });
575
579
  }
576
580
  this.setState({colorTexture});
@@ -578,7 +582,8 @@ export default class HeatmapLayer<
578
582
 
579
583
  _updateWeightmap() {
580
584
  const {radiusPixels, colorDomain, aggregation} = this.props;
581
- const {weightsTransform, worldBounds, textureSize, weightsTexture, weightsScale} = this.state;
585
+ const {worldBounds, textureSize, weightsScale} = this.state;
586
+ const weightsTransform = this.state.weightsTransform!;
582
587
  this.state.isWeightMapDirty = false;
583
588
 
584
589
  // convert world bounds to common using Layer's coordiante system and origin
@@ -609,7 +614,7 @@ export default class HeatmapLayer<
609
614
  elementCount: this.getNumInstances()
610
615
  });
611
616
  // Need to explictly specify clearColor as external context may have modified it
612
- withParameters(this.context.gl, {clearColor: [0, 0, 0, 0]}, () => {
617
+ withGLParameters(this.context.gl, {clearColor: [0, 0, 0, 0]}, () => {
613
618
  weightsTransform.run({
614
619
  uniforms,
615
620
  parameters: {
@@ -619,6 +624,7 @@ export default class HeatmapLayer<
619
624
  blendEquation: GL.FUNC_ADD
620
625
  },
621
626
  clearRenderTarget: true,
627
+ // @ts-expect-error TODO - no longer supported in v9?
622
628
  attributes: this.getAttributes(),
623
629
  moduleSettings: this.getModuleSettings()
624
630
  });
@@ -626,10 +632,11 @@ export default class HeatmapLayer<
626
632
  this._updateMaxWeightValue();
627
633
 
628
634
  // reset filtering parameters (TODO: remove once luma issue#1193 is fixed)
629
- weightsTexture.setParameters({
630
- [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
631
- [GL.TEXTURE_MIN_FILTER]: GL.LINEAR
632
- });
635
+ // TODO v9 sampler support in luma.gl needs to improve
636
+ // weightsTexture.setSampler({
637
+ // magFilter: 'linear',
638
+ // minFilter: 'linear'
639
+ // });
633
640
  }
634
641
 
635
642
  _debouncedUpdateWeightmap(fromTimer = false) {
@@ -18,8 +18,9 @@
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
20
 
21
- import GL from '@luma.gl/constants';
22
- import {Model, Geometry, Texture2D} from '@luma.gl/core';
21
+ import type {Device, Texture} from '@luma.gl/core';
22
+ import {Model, Geometry} from '@luma.gl/engine';
23
+ import {GL} from '@luma.gl/constants';
23
24
  import {Layer, LayerContext, project32} from '@deck.gl/core';
24
25
  import vs from './triangle-layer-vertex.glsl';
25
26
  import fs from './triangle-layer-fragment.glsl';
@@ -30,37 +31,41 @@ type _TriangleLayerProps = {
30
31
  threshold: number;
31
32
  intensity: number;
32
33
  vertexCount: number;
33
- colorTexture: Texture2D;
34
- maxTexture: Texture2D;
35
- texture: Texture2D;
34
+ colorTexture: Texture;
35
+ maxTexture: Texture;
36
+ texture: Texture;
36
37
  };
37
38
 
38
39
  export default class TriangleLayer extends Layer<_TriangleLayerProps> {
39
40
  static layerName = 'TriangleLayer';
40
41
 
42
+ state!: {
43
+ model: Model;
44
+ };
45
+
41
46
  getShaders() {
42
47
  return {vs, fs, modules: [project32]};
43
48
  }
44
49
 
45
- initializeState({gl}: LayerContext): void {
50
+ initializeState({device}: LayerContext): void {
46
51
  const attributeManager = this.getAttributeManager()!;
47
52
  attributeManager.add({
48
53
  positions: {size: 3, noAlloc: true},
49
54
  texCoords: {size: 2, noAlloc: true}
50
55
  });
51
56
  this.setState({
52
- model: this._getModel(gl)
57
+ model: this._getModel(device)
53
58
  });
54
59
  }
55
60
 
56
- _getModel(gl: WebGLRenderingContext): Model {
61
+ _getModel(device: Device): Model {
57
62
  const {vertexCount} = this.props;
58
63
 
59
- return new Model(gl, {
64
+ return new Model(device, {
60
65
  ...this.getShaders(),
61
66
  id: this.props.id,
62
67
  geometry: new Geometry({
63
- drawMode: GL.TRIANGLE_FAN,
68
+ topology: 'triangle-fan-webgl',
64
69
  vertexCount
65
70
  })
66
71
  });
@@ -72,17 +77,16 @@ export default class TriangleLayer extends Layer<_TriangleLayerProps> {
72
77
  const {texture, maxTexture, colorTexture, intensity, threshold, aggregationMode, colorDomain} =
73
78
  this.props;
74
79
 
75
- model
76
- .setUniforms({
77
- ...uniforms,
78
- texture,
79
- maxTexture,
80
- colorTexture,
81
- intensity,
82
- threshold,
83
- aggregationMode,
84
- colorDomain
85
- })
86
- .draw();
80
+ model.setUniforms({
81
+ ...uniforms,
82
+ texture,
83
+ maxTexture,
84
+ colorTexture,
85
+ intensity,
86
+ threshold,
87
+ aggregationMode,
88
+ colorDomain
89
+ });
90
+ model.draw(this.context.renderPass);
87
91
  }
88
92
  }
@@ -38,7 +38,11 @@ export function pointToHexbin(props, aggregationParams) {
38
38
  const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
39
39
 
40
40
  // add world space coordinates to points
41
- const screenPoints = [];
41
+ const screenPoints: {
42
+ screenCoord: number[];
43
+ source: any;
44
+ index: number;
45
+ }[] = [];
42
46
  const {iterable, objectInfo} = createIterable(data);
43
47
  const positions = attributes.positions.value;
44
48
  const {size} = attributes.positions.getAccessor();
@@ -29,6 +29,7 @@ import {
29
29
  DefaultProps
30
30
  } from '@deck.gl/core';
31
31
  import {ColumnLayer} from '@deck.gl/layers';
32
+ import {GL} from '@luma.gl/constants';
32
33
 
33
34
  import {defaultColorRange} from '../utils/color-utils';
34
35
 
@@ -36,7 +37,6 @@ import {pointToHexbin} from './hexagon-aggregator';
36
37
  import CPUAggregator from '../utils/cpu-aggregator';
37
38
  import AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';
38
39
 
39
- import GL from '@luma.gl/constants';
40
40
  import {AggregateAccessor} from '../types';
41
41
 
42
42
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -70,7 +70,7 @@ const defaultProps: DefaultProps<HexagonLayerProps> = {
70
70
  coverage: {type: 'number', min: 0, max: 1, value: 1},
71
71
  extruded: false,
72
72
  hexagonAggregator: pointToHexbin,
73
- getPosition: {type: 'accessor', value: x => x.position},
73
+ getPosition: {type: 'accessor', value: (x: any) => x.position},
74
74
  // Optional material for 'lighting' shader module
75
75
  material: true,
76
76
 
@@ -79,11 +79,11 @@ const defaultProps: DefaultProps<HexagonLayerProps> = {
79
79
  };
80
80
 
81
81
  /** All properties supported by by HexagonLayer. */
82
- export type HexagonLayerProps<DataT = any> = _HexagonLayerProps<DataT> &
82
+ export type HexagonLayerProps<DataT = unknown> = _HexagonLayerProps<DataT> &
83
83
  AggregationLayerProps<DataT>;
84
84
 
85
85
  /** Properties added by HexagonLayer. */
86
- type _HexagonLayerProps<DataT = any> = {
86
+ type _HexagonLayerProps<DataT = unknown> = {
87
87
  /**
88
88
  * Radius of hexagon bin in meters. The hexagons are pointy-topped (rather than flat-topped).
89
89
  * @default 1000
@@ -256,7 +256,8 @@ export default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends Ag
256
256
 
257
257
  state!: AggregationLayer<DataT>['state'] & {
258
258
  cpuAggregator: CPUAggregator;
259
- aggregatorState: any;
259
+ aggregatorState: CPUAggregator['state'];
260
+ vertices: number[][] | null;
260
261
  };
261
262
  initializeState() {
262
263
  const cpuAggregator = new CPUAggregator({
@@ -288,6 +289,7 @@ export default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends Ag
288
289
  if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
289
290
  // if user provided custom aggregator and returns hexagonVertices,
290
291
  // Need to recalculate radius and angle based on vertices
292
+ // @ts-expect-error
291
293
  const {hexagonVertices} = aggregatorState.layerData || {};
292
294
  this.setState({
293
295
  vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
@@ -359,6 +361,7 @@ export default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends Ag
359
361
  ? {vertices, radius: 1}
360
362
  : {
361
363
  // default geometry
364
+ // @ts-expect-error TODO - undefined property?
362
365
  radius: aggregatorState.layerData.radiusCommon || 1,
363
366
  radiusUnits: 'common',
364
367
  angle: 90
package/src/index.ts CHANGED
@@ -17,7 +17,6 @@
17
17
  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
- /* eslint-disable max-len */
21
20
 
22
21
  export {default as ScreenGridLayer} from './screen-grid-layer/screen-grid-layer';
23
22
  export {default as CPUGridLayer} from './cpu-grid-layer/cpu-grid-layer';
@@ -18,9 +18,10 @@
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
20
 
21
- import GL from '@luma.gl/constants';
22
- import {Model, Geometry, FEATURES, hasFeatures, Texture2D, DefaultProps} from '@luma.gl/core';
23
- import {Layer, LayerProps, log, picking, UpdateParameters} from '@deck.gl/core';
21
+ import {Device, Texture} from '@luma.gl/core';
22
+ import {Model, Geometry} from '@luma.gl/engine';
23
+ import {GL} from '@luma.gl/constants';
24
+ import {Layer, LayerProps, log, picking, UpdateParameters, DefaultProps} from '@deck.gl/core';
24
25
  import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
25
26
  import vs from './screen-grid-layer-vertex.glsl';
26
27
  import fs from './screen-grid-layer-fragment.glsl';
@@ -31,19 +32,20 @@ const DEFAULT_MAXCOLOR = [0, 255, 0, 255];
31
32
  const COLOR_PROPS = ['minColor', 'maxColor', 'colorRange', 'colorDomain'];
32
33
 
33
34
  const defaultProps: DefaultProps<ScreenGridCellLayerProps> = {
34
- cellSizePixels: {value: 100, min: 1},
35
- cellMarginPixels: {value: 2, min: 0, max: 5},
35
+ cellSizePixels: {type: 'number', value: 100, min: 1},
36
+ cellMarginPixels: {type: 'number', value: 2, min: 0, max: 5},
36
37
 
37
38
  colorDomain: null,
38
39
  colorRange: defaultColorRange
39
40
  };
40
41
 
41
42
  /** All properties supported by ScreenGridCellLayer. */
42
- export type ScreenGridCellLayerProps<DataT = any> = _ScreenGridCellLayerProps<DataT> & LayerProps;
43
+ export type ScreenGridCellLayerProps<DataT = unknown> = _ScreenGridCellLayerProps<DataT> &
44
+ LayerProps;
43
45
 
44
46
  /** Proprties added by ScreenGridCellLayer. */
45
47
  export type _ScreenGridCellLayerProps<DataT> = _ScreenGridLayerProps<DataT> & {
46
- maxTexture: Texture2D;
48
+ maxTexture: Texture;
47
49
  };
48
50
 
49
51
  export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
@@ -52,19 +54,18 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
52
54
  static layerName = 'ScreenGridCellLayer';
53
55
  static defaultProps = defaultProps;
54
56
 
55
- static isSupported(gl) {
56
- return hasFeatures(gl, [FEATURES.TEXTURE_FLOAT]);
57
+ static isSupported(device: Device) {
58
+ return device.features.has('texture-formats-float32-webgl1');
57
59
  }
58
60
 
59
- state!: Layer['state'] & {
60
- model: Model;
61
+ state!: {
62
+ model?: Model;
61
63
  };
62
64
  getShaders() {
63
65
  return {vs, fs, modules: [picking]};
64
66
  }
65
67
 
66
68
  initializeState() {
67
- const {gl} = this.context;
68
69
  const attributeManager = this.getAttributeManager()!;
69
70
  attributeManager.addInstanced({
70
71
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -72,7 +73,7 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
72
73
  instanceCounts: {size: 4, noAlloc: true}
73
74
  });
74
75
  this.setState({
75
- model: this._getModel(gl)
76
+ model: this._getModel()
76
77
  });
77
78
  }
78
79
 
@@ -104,22 +105,23 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
104
105
  // If colorDomain not specified we use default domain [1, maxCount]
105
106
  // maxCount value will be sampled form maxTexture in vertex shader.
106
107
  const colorDomain = this.props.colorDomain || [1, 0];
107
- const {model} = this.state;
108
- model
109
- .setUniforms(uniforms)
110
- .setUniforms({
111
- minColor,
112
- maxColor,
113
- maxTexture,
114
- colorDomain
115
- })
116
- .draw({
117
- parameters: {
118
- depthTest: false,
119
- depthMask: false,
120
- ...parameters
121
- }
122
- });
108
+ const model = this.state.model!;
109
+ model.setUniforms(uniforms);
110
+ model.setBindings({
111
+ maxTexture
112
+ });
113
+ model.setUniforms({
114
+ minColor,
115
+ maxColor,
116
+ colorDomain
117
+ });
118
+ model.setParameters({
119
+ depthWriteEnabled: false,
120
+ // How to specify depth mask in WebGPU?
121
+ // depthMask: false,
122
+ ...parameters
123
+ });
124
+ model.draw(this.context.renderPass);
123
125
  }
124
126
 
125
127
  calculateInstancePositions(attribute, {numInstances}) {
@@ -140,16 +142,17 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
140
142
 
141
143
  // Private Methods
142
144
 
143
- _getModel(gl: WebGLRenderingContext): Model {
144
- return new Model(gl, {
145
+ _getModel(): Model {
146
+ return new Model(this.context.device, {
145
147
  ...this.getShaders(),
146
148
  id: this.props.id,
147
149
  geometry: new Geometry({
148
- drawMode: GL.TRIANGLE_FAN,
150
+ topology: 'triangle-fan-webgl',
149
151
  attributes: {
150
152
  positions: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0])
151
153
  }
152
154
  }),
155
+ // @ts-expect-error TODO v9 API not as dynamic
153
156
  isInstanced: true
154
157
  });
155
158
  }
@@ -170,7 +173,7 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
170
173
  }
171
174
 
172
175
  _updateUniforms(oldProps, props, changeFlags): void {
173
- const {model} = this.state;
176
+ const model = this.state.model!;
174
177
  if (COLOR_PROPS.some(key => oldProps[key] !== props[key])) {
175
178
  model.setUniforms({shouldUseMinMax: this._shouldUseMinMax()});
176
179
  }