@deck.gl/aggregation-layers 8.5.5 → 8.5.9

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/aggregation-layers",
3
3
  "description": "deck.gl layers that aggregate the input data into alternative representations",
4
4
  "license": "MIT",
5
- "version": "8.5.5",
5
+ "version": "8.5.9",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -37,5 +37,5 @@
37
37
  "@deck.gl/core": "^8.0.0",
38
38
  "@deck.gl/layers": "^8.0.0"
39
39
  },
40
- "gitHead": "13e0ae29b8d362ee54603353ef1007c20c01483e"
40
+ "gitHead": "1ffc5262097af4c9ee3d316fcf5871e47b5c0755"
41
41
  }
@@ -29,12 +29,7 @@ import {
29
29
  getTextureParams
30
30
  } from './heatmap-layer-utils';
31
31
  import {Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures} from '@luma.gl/core';
32
- import {
33
- AttributeManager,
34
- COORDINATE_SYSTEM,
35
- log,
36
- _mergeShaders as mergeShaders
37
- } from '@deck.gl/core';
32
+ import {AttributeManager, COORDINATE_SYSTEM, log} from '@deck.gl/core';
38
33
  import TriangleLayer from './triangle-layer';
39
34
  import AggregationLayer from '../aggregation-layer';
40
35
  import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
@@ -44,8 +39,6 @@ import vs_max from './max-vs.glsl';
44
39
  import fs_max from './max-fs.glsl';
45
40
 
46
41
  const RESOLUTION = 2; // (number of common space pixels) / (number texels)
47
- const SIZE_2K = 2048;
48
- const ZOOM_DEBOUNCE = 500; // milliseconds
49
42
  const TEXTURE_OPTIONS = {
50
43
  mipmaps: false,
51
44
  parameters: {
@@ -71,7 +64,9 @@ const defaultProps = {
71
64
  threshold: {type: 'number', min: 0, max: 1, value: 0.05},
72
65
  colorDomain: {type: 'array', value: null, optional: true},
73
66
  // 'SUM' or 'MEAN'
74
- aggregation: 'SUM'
67
+ aggregation: 'SUM',
68
+ weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},
69
+ debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}
75
70
  };
76
71
 
77
72
  const REQUIRED_FEATURES = [
@@ -112,6 +107,10 @@ export default class HeatmapLayer extends AggregationLayer {
112
107
  return;
113
108
  }
114
109
  super.updateState(opts);
110
+ this._updateHeatmapState(opts);
111
+ }
112
+
113
+ _updateHeatmapState(opts) {
115
114
  const {props, oldProps} = opts;
116
115
  const changeFlags = this._getChangeFlags(opts);
117
116
 
@@ -139,7 +138,6 @@ export default class HeatmapLayer extends AggregationLayer {
139
138
 
140
139
  this.setState({zoom: opts.context.viewport.zoom});
141
140
  }
142
- /* eslint-enable max-statements,complexity */
143
141
 
144
142
  renderLayers() {
145
143
  if (!this.state.supported) {
@@ -262,7 +260,9 @@ export default class HeatmapLayer extends AggregationLayer {
262
260
 
263
261
  _setupTextureParams() {
264
262
  const {gl} = this.context;
265
- const textureSize = Math.min(SIZE_2K, getParameters(gl, gl.MAX_TEXTURE_SIZE));
263
+ const {weightsTextureSize} = this.props;
264
+
265
+ const textureSize = Math.min(weightsTextureSize, getParameters(gl, gl.MAX_TEXTURE_SIZE));
266
266
  const floatTargetSupport = hasFeatures(gl, FEATURES.COLOR_ATTACHMENT_RGBA32F);
267
267
  const {format, type} = getTextureParams({gl, floatTargetSupport});
268
268
  const weightsScale = floatTargetSupport ? 1 : 1 / 255;
@@ -276,18 +276,25 @@ export default class HeatmapLayer extends AggregationLayer {
276
276
  }
277
277
  }
278
278
 
279
- _createWeightsTransform(shaderOptions = {}) {
279
+ getShaders(type) {
280
+ return super.getShaders(
281
+ type === 'max-weights-transform'
282
+ ? {
283
+ vs: vs_max,
284
+ _fs: fs_max
285
+ }
286
+ : {
287
+ vs: weights_vs,
288
+ _fs: weights_fs
289
+ }
290
+ );
291
+ }
292
+
293
+ _createWeightsTransform(shaders = {}) {
280
294
  const {gl} = this.context;
281
295
  let {weightsTransform} = this.state;
282
296
  const {weightsTexture} = this.state;
283
297
  weightsTransform?.delete();
284
- const shaders = mergeShaders(
285
- {
286
- vs: weights_vs,
287
- _fs: weights_fs
288
- },
289
- shaderOptions
290
- );
291
298
 
292
299
  weightsTransform = new Transform(gl, {
293
300
  id: `${this.id}-weights-transform`,
@@ -303,7 +310,11 @@ export default class HeatmapLayer extends AggregationLayer {
303
310
  const {gl} = this.context;
304
311
  this._createTextures();
305
312
  const {textureSize, weightsTexture, maxWeightsTexture} = this.state;
306
- this._createWeightsTransform();
313
+
314
+ const weightsTransformShaders = this.getShaders('weights-transform');
315
+ this._createWeightsTransform(weightsTransformShaders);
316
+
317
+ const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
307
318
  const maxWeightTransform = new Transform(gl, {
308
319
  id: `${this.id}-max-weights-transform`,
309
320
  _sourceTextures: {
@@ -311,8 +322,7 @@ export default class HeatmapLayer extends AggregationLayer {
311
322
  },
312
323
  _targetTexture: maxWeightsTexture,
313
324
  _targetTextureVarying: 'outTexture',
314
- vs: vs_max,
315
- _fs: fs_max,
325
+ ...maxWeightsTransformShaders,
316
326
  elementCount: textureSize * textureSize
317
327
  });
318
328
 
@@ -496,6 +506,7 @@ export default class HeatmapLayer extends AggregationLayer {
496
506
 
497
507
  _debouncedUpdateWeightmap(fromTimer = false) {
498
508
  let {updateTimer} = this.state;
509
+ const {debounceTimeout} = this.props;
499
510
 
500
511
  if (fromTimer) {
501
512
  updateTimer = null;
@@ -506,7 +517,7 @@ export default class HeatmapLayer extends AggregationLayer {
506
517
  } else {
507
518
  this.setState({isWeightMapDirty: false});
508
519
  clearTimeout(updateTimer);
509
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), ZOOM_DEBOUNCE);
520
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
510
521
  }
511
522
 
512
523
  this.setState({updateTimer});