@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/dist/dist.dev.js CHANGED
@@ -15358,8 +15358,6 @@ __webpack_require__.r(__webpack_exports__);
15358
15358
 
15359
15359
 
15360
15360
  const RESOLUTION = 2; // (number of common space pixels) / (number texels)
15361
- const SIZE_2K = 2048;
15362
- const ZOOM_DEBOUNCE = 500; // milliseconds
15363
15361
  const TEXTURE_OPTIONS = {
15364
15362
  mipmaps: false,
15365
15363
  parameters: {
@@ -15385,7 +15383,9 @@ const defaultProps = {
15385
15383
  threshold: {type: 'number', min: 0, max: 1, value: 0.05},
15386
15384
  colorDomain: {type: 'array', value: null, optional: true},
15387
15385
  // 'SUM' or 'MEAN'
15388
- aggregation: 'SUM'
15386
+ aggregation: 'SUM',
15387
+ weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},
15388
+ debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}
15389
15389
  };
15390
15390
 
15391
15391
  const REQUIRED_FEATURES = [
@@ -15426,6 +15426,10 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15426
15426
  return;
15427
15427
  }
15428
15428
  super.updateState(opts);
15429
+ this._updateHeatmapState(opts);
15430
+ }
15431
+
15432
+ _updateHeatmapState(opts) {
15429
15433
  const {props, oldProps} = opts;
15430
15434
  const changeFlags = this._getChangeFlags(opts);
15431
15435
 
@@ -15453,7 +15457,6 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15453
15457
 
15454
15458
  this.setState({zoom: opts.context.viewport.zoom});
15455
15459
  }
15456
- /* eslint-enable max-statements,complexity */
15457
15460
 
15458
15461
  renderLayers() {
15459
15462
  if (!this.state.supported) {
@@ -15576,7 +15579,9 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15576
15579
 
15577
15580
  _setupTextureParams() {
15578
15581
  const {gl} = this.context;
15579
- const textureSize = Math.min(SIZE_2K, Object(_luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["getParameters"])(gl, gl.MAX_TEXTURE_SIZE));
15582
+ const {weightsTextureSize} = this.props;
15583
+
15584
+ const textureSize = Math.min(weightsTextureSize, Object(_luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["getParameters"])(gl, gl.MAX_TEXTURE_SIZE));
15580
15585
  const floatTargetSupport = Object(_luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["hasFeatures"])(gl, _luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["FEATURES"].COLOR_ATTACHMENT_RGBA32F);
15581
15586
  const {format, type} = Object(_heatmap_layer_utils__WEBPACK_IMPORTED_MODULE_1__["getTextureParams"])({gl, floatTargetSupport});
15582
15587
  const weightsScale = floatTargetSupport ? 1 : 1 / 255;
@@ -15590,18 +15595,25 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15590
15595
  }
15591
15596
  }
15592
15597
 
15593
- _createWeightsTransform(shaderOptions = {}) {
15598
+ getShaders(type) {
15599
+ return super.getShaders(
15600
+ type === 'max-weights-transform'
15601
+ ? {
15602
+ vs: _max_vs_glsl__WEBPACK_IMPORTED_MODULE_9__["default"],
15603
+ _fs: _max_fs_glsl__WEBPACK_IMPORTED_MODULE_10__["default"]
15604
+ }
15605
+ : {
15606
+ vs: _weights_vs_glsl__WEBPACK_IMPORTED_MODULE_7__["default"],
15607
+ _fs: _weights_fs_glsl__WEBPACK_IMPORTED_MODULE_8__["default"]
15608
+ }
15609
+ );
15610
+ }
15611
+
15612
+ _createWeightsTransform(shaders = {}) {
15594
15613
  const {gl} = this.context;
15595
15614
  let {weightsTransform} = this.state;
15596
15615
  const {weightsTexture} = this.state;
15597
15616
  weightsTransform?.delete();
15598
- const shaders = Object(_deck_gl_core__WEBPACK_IMPORTED_MODULE_3__["_mergeShaders"])(
15599
- {
15600
- vs: _weights_vs_glsl__WEBPACK_IMPORTED_MODULE_7__["default"],
15601
- _fs: _weights_fs_glsl__WEBPACK_IMPORTED_MODULE_8__["default"]
15602
- },
15603
- shaderOptions
15604
- );
15605
15617
 
15606
15618
  weightsTransform = new _luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["Transform"](gl, {
15607
15619
  id: `${this.id}-weights-transform`,
@@ -15617,7 +15629,11 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15617
15629
  const {gl} = this.context;
15618
15630
  this._createTextures();
15619
15631
  const {textureSize, weightsTexture, maxWeightsTexture} = this.state;
15620
- this._createWeightsTransform();
15632
+
15633
+ const weightsTransformShaders = this.getShaders('weights-transform');
15634
+ this._createWeightsTransform(weightsTransformShaders);
15635
+
15636
+ const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
15621
15637
  const maxWeightTransform = new _luma_gl_core__WEBPACK_IMPORTED_MODULE_2__["Transform"](gl, {
15622
15638
  id: `${this.id}-max-weights-transform`,
15623
15639
  _sourceTextures: {
@@ -15625,8 +15641,7 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15625
15641
  },
15626
15642
  _targetTexture: maxWeightsTexture,
15627
15643
  _targetTextureVarying: 'outTexture',
15628
- vs: _max_vs_glsl__WEBPACK_IMPORTED_MODULE_9__["default"],
15629
- _fs: _max_fs_glsl__WEBPACK_IMPORTED_MODULE_10__["default"],
15644
+ ...maxWeightsTransformShaders,
15630
15645
  elementCount: textureSize * textureSize
15631
15646
  });
15632
15647
 
@@ -15810,6 +15825,7 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15810
15825
 
15811
15826
  _debouncedUpdateWeightmap(fromTimer = false) {
15812
15827
  let {updateTimer} = this.state;
15828
+ const {debounceTimeout} = this.props;
15813
15829
 
15814
15830
  if (fromTimer) {
15815
15831
  updateTimer = null;
@@ -15820,7 +15836,7 @@ class HeatmapLayer extends _aggregation_layer__WEBPACK_IMPORTED_MODULE_5__["defa
15820
15836
  } else {
15821
15837
  this.setState({isWeightMapDirty: false});
15822
15838
  clearTimeout(updateTimer);
15823
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), ZOOM_DEBOUNCE);
15839
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
15824
15840
  }
15825
15841
 
15826
15842
  this.setState({updateTimer});
@@ -54,8 +54,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
54
54
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
55
55
 
56
56
  var RESOLUTION = 2;
57
- var SIZE_2K = 2048;
58
- var ZOOM_DEBOUNCE = 500;
59
57
  var TEXTURE_OPTIONS = {
60
58
  mipmaps: false,
61
59
  parameters: (_parameters = {}, (0, _defineProperty2.default)(_parameters, 10240, 9729), (0, _defineProperty2.default)(_parameters, 10241, 9729), (0, _defineProperty2.default)(_parameters, 10242, 33071), (0, _defineProperty2.default)(_parameters, 10243, 33071), _parameters),
@@ -100,7 +98,19 @@ var defaultProps = {
100
98
  value: null,
101
99
  optional: true
102
100
  },
103
- aggregation: 'SUM'
101
+ aggregation: 'SUM',
102
+ weightsTextureSize: {
103
+ type: 'number',
104
+ min: 128,
105
+ max: 2048,
106
+ value: 2048
107
+ },
108
+ debounceTimeout: {
109
+ type: 'number',
110
+ min: 0,
111
+ max: 1000,
112
+ value: 500
113
+ }
104
114
  };
105
115
  var REQUIRED_FEATURES = [_core.FEATURES.BLEND_EQUATION_MINMAX, _core.FEATURES.TEXTURE_FLOAT];
106
116
  var DIMENSIONS = {
@@ -160,6 +170,12 @@ var HeatmapLayer = function (_AggregationLayer) {
160
170
  }
161
171
 
162
172
  (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "updateState", this).call(this, opts);
173
+
174
+ this._updateHeatmapState(opts);
175
+ }
176
+ }, {
177
+ key: "_updateHeatmapState",
178
+ value: function _updateHeatmapState(opts) {
163
179
  var props = opts.props,
164
180
  oldProps = opts.oldProps;
165
181
 
@@ -325,7 +341,8 @@ var HeatmapLayer = function (_AggregationLayer) {
325
341
  key: "_setupTextureParams",
326
342
  value: function _setupTextureParams() {
327
343
  var gl = this.context.gl;
328
- var textureSize = Math.min(SIZE_2K, (0, _core.getParameters)(gl, 3379));
344
+ var weightsTextureSize = this.props.weightsTextureSize;
345
+ var textureSize = Math.min(weightsTextureSize, (0, _core.getParameters)(gl, 3379));
329
346
  var floatTargetSupport = (0, _core.hasFeatures)(gl, _core.FEATURES.COLOR_ATTACHMENT_RGBA32F);
330
347
 
331
348
  var _getTextureParams = (0, _heatmapLayerUtils.getTextureParams)({
@@ -347,20 +364,27 @@ var HeatmapLayer = function (_AggregationLayer) {
347
364
  _core2.log.warn("HeatmapLayer: ".concat(this.id, " rendering to float texture not supported, fallingback to low precession format"))();
348
365
  }
349
366
  }
367
+ }, {
368
+ key: "getShaders",
369
+ value: function getShaders(type) {
370
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "getShaders", this).call(this, type === 'max-weights-transform' ? {
371
+ vs: _maxVs.default,
372
+ _fs: _maxFs.default
373
+ } : {
374
+ vs: _weightsVs.default,
375
+ _fs: _weightsFs.default
376
+ });
377
+ }
350
378
  }, {
351
379
  key: "_createWeightsTransform",
352
380
  value: function _createWeightsTransform() {
353
381
  var _weightsTransform;
354
382
 
355
- var shaderOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
383
+ var shaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
356
384
  var gl = this.context.gl;
357
385
  var weightsTransform = this.state.weightsTransform;
358
386
  var weightsTexture = this.state.weightsTexture;
359
387
  (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
360
- var shaders = (0, _core2._mergeShaders)({
361
- vs: _weightsVs.default,
362
- _fs: _weightsFs.default
363
- }, shaderOptions);
364
388
  weightsTransform = new _core.Transform(gl, _objectSpread({
365
389
  id: "".concat(this.id, "-weights-transform"),
366
390
  elementCount: 1,
@@ -382,20 +406,21 @@ var HeatmapLayer = function (_AggregationLayer) {
382
406
  textureSize = _this$state4.textureSize,
383
407
  weightsTexture = _this$state4.weightsTexture,
384
408
  maxWeightsTexture = _this$state4.maxWeightsTexture;
409
+ var weightsTransformShaders = this.getShaders('weights-transform');
385
410
 
386
- this._createWeightsTransform();
411
+ this._createWeightsTransform(weightsTransformShaders);
387
412
 
388
- var maxWeightTransform = new _core.Transform(gl, {
413
+ var maxWeightsTransformShaders = this.getShaders('max-weights-transform');
414
+ var maxWeightTransform = new _core.Transform(gl, _objectSpread(_objectSpread({
389
415
  id: "".concat(this.id, "-max-weights-transform"),
390
416
  _sourceTextures: {
391
417
  inTexture: weightsTexture
392
418
  },
393
419
  _targetTexture: maxWeightsTexture,
394
- _targetTextureVarying: 'outTexture',
395
- vs: _maxVs.default,
396
- _fs: _maxFs.default,
420
+ _targetTextureVarying: 'outTexture'
421
+ }, maxWeightsTransformShaders), {}, {
397
422
  elementCount: textureSize * textureSize
398
- });
423
+ }));
399
424
  this.setState({
400
425
  weightsTexture: weightsTexture,
401
426
  maxWeightsTexture: maxWeightsTexture,
@@ -571,6 +596,7 @@ var HeatmapLayer = function (_AggregationLayer) {
571
596
  value: function _debouncedUpdateWeightmap() {
572
597
  var fromTimer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
573
598
  var updateTimer = this.state.updateTimer;
599
+ var debounceTimeout = this.props.debounceTimeout;
574
600
 
575
601
  if (fromTimer) {
576
602
  updateTimer = null;
@@ -587,7 +613,7 @@ var HeatmapLayer = function (_AggregationLayer) {
587
613
  isWeightMapDirty: false
588
614
  });
589
615
  clearTimeout(updateTimer);
590
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), ZOOM_DEBOUNCE);
616
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
591
617
  }
592
618
 
593
619
  this.setState({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer.js"],"names":["RESOLUTION","SIZE_2K","ZOOM_DEBOUNCE","TEXTURE_OPTIONS","mipmaps","parameters","dataFormat","DEFAULT_COLOR_DOMAIN","AGGREGATION_MODE","SUM","MEAN","defaultProps","getPosition","type","value","x","position","getWeight","intensity","min","radiusPixels","max","colorRange","defaultColorRange","threshold","colorDomain","optional","aggregation","REQUIRED_FEATURES","FEATURES","BLEND_EQUATION_MINMAX","TEXTURE_FLOAT","DIMENSIONS","data","props","HeatmapLayer","gl","context","setState","supported","log","error","id","_setupTextureParams","_setupAttributes","_setupResources","changeFlags","somethingChanged","opts","state","oldProps","_getChangeFlags","viewportChanged","boundsChanged","_updateBounds","_updateTextureRenderingBounds","dataChanged","clearTimeout","updateTimer","isWeightMapDirty","viewportZoomChanged","_debouncedUpdateWeightmap","_updateColorTexture","_updateWeightmap","zoom","viewport","weightsTexture","triPositionBuffer","triTexCoordBuffer","maxWeightsTexture","colorTexture","updateTriggers","TriangleLayerClass","getSubLayerClass","TriangleLayer","getSubLayerProps","coordinateSystem","COORDINATE_SYSTEM","DEFAULT","attributes","positions","texCoords","vertexCount","maxTexture","aggregationMode","texture","weightsTransform","maxWeightTransform","delete","AttributeManager","stats","dimensions","isAttributeChanged","isAggregationDirty","compareAll","dimension","textureSize","format","Texture2D","width","height","attributeManager","getAttributeManager","add","size","accessor","weights","positionAttributeName","Math","floatTargetSupport","COLOR_ATTACHMENT_RGBA32F","weightsScale","warn","shaderOptions","shaders","vs","weights_vs","_fs","weights_fs","Transform","elementCount","_targetTexture","_targetTextureVarying","_createTextures","_createWeightsTransform","_sourceTextures","inTexture","vs_max","fs_max","Buffer","byteLength","run","blend","depthTest","blendFunc","blendEquation","forceUpdate","viewportCorners","unproject","map","p","fround","visibleWorldBounds","newState","worldBounds","scaledCommonBounds","_worldToCommonBounds","_commonToWorldBounds","LNGLAT","normalizedCommonBounds","subData","textureBounds","projectPosition","colors","Uint8Array","setImageData","length","commonBounds","useLayerCoordinateSystem","metersPerPixel","distanceScales","metersPerUnit","uniforms","textureWidth","update","getNumInstances","clearRenderTarget","getAttributes","moduleSettings","getModuleSettings","_updateMaxWeightValue","setParameters","fromTimer","setTimeout","bind","minLong","minLat","maxLong","maxLat","offsetMode","LNGLAT_OFFSETS","METER_OFFSETS","offsetOriginCommon","coordinateOrigin","scale","bottomLeftCommon","topRightCommon","xMin","yMin","xMax","yMax","bottomLeftWorld","unprojectPosition","topRightWorld","slice","concat","AggregationLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;AAQA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,CAAnB;AACA,IAAMC,OAAO,GAAG,IAAhB;AACA,IAAMC,aAAa,GAAG,GAAtB;AACA,IAAMC,eAAe,GAAG;AACtBC,EAAAA,OAAO,EAAE,KADa;AAEtBC,EAAAA,UAAU,uQAFY;AAQtBC,EAAAA,UAAU;AARY,CAAxB;AAUA,IAAMC,oBAAoB,GAAG,CAAC,CAAD,EAAI,CAAJ,CAA7B;AACA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,GAAG,EAAE,CADkB;AAEvBC,EAAAA,IAAI,EAAE;AAFiB,CAAzB;AAKA,IAAMC,YAAY,GAAG;AACnBC,EAAAA,WAAW,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,eAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,QAAN;AAAA;AAA3B,GADM;AAEnBC,EAAAA,SAAS,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA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,GAA4BA,YAA5B","sourcesContent":["// Copyright (c) 2015 - 2019 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global setTimeout clearTimeout */\nimport GL from '@luma.gl/constants';\nimport {\n getBounds,\n boundsContain,\n packVertices,\n scaleToAspectRatio,\n getTextureCoordinates,\n getTextureParams\n} from './heatmap-layer-utils';\nimport {Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures} from '@luma.gl/core';\nimport {\n AttributeManager,\n COORDINATE_SYSTEM,\n log,\n _mergeShaders as mergeShaders\n} from '@deck.gl/core';\nimport TriangleLayer from './triangle-layer';\nimport AggregationLayer from '../aggregation-layer';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport weights_vs from './weights-vs.glsl';\nimport weights_fs from './weights-fs.glsl';\nimport vs_max from './max-vs.glsl';\nimport fs_max from './max-fs.glsl';\n\nconst RESOLUTION = 2; // (number of common space pixels) / (number texels)\nconst SIZE_2K = 2048;\nconst ZOOM_DEBOUNCE = 500; // milliseconds\nconst TEXTURE_OPTIONS = {\n mipmaps: false,\n parameters: {\n [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n },\n dataFormat: GL.RGBA\n};\nconst DEFAULT_COLOR_DOMAIN = [0, 0];\nconst AGGREGATION_MODE = {\n SUM: 0,\n MEAN: 1\n};\n\nconst defaultProps = {\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n intensity: {type: 'number', min: 0, value: 1},\n radiusPixels: {type: 'number', min: 1, max: 100, value: 50},\n colorRange: defaultColorRange,\n threshold: {type: 'number', min: 0, max: 1, value: 0.05},\n colorDomain: {type: 'array', value: null, optional: true},\n // 'SUM' or 'MEAN'\n aggregation: 'SUM'\n};\n\nconst REQUIRED_FEATURES = [\n FEATURES.BLEND_EQUATION_MINMAX, // max weight calculation\n FEATURES.TEXTURE_FLOAT // weight-map as texture\n // FEATURES.FLOAT_BLEND, // implictly supported when TEXTURE_FLOAT is supported\n];\n\nconst DIMENSIONS = {\n data: {\n props: ['radiusPixels']\n }\n};\n\nexport default class HeatmapLayer extends AggregationLayer {\n initializeState() {\n const {gl} = this.context;\n if (!hasFeatures(gl, REQUIRED_FEATURES)) {\n this.setState({supported: false});\n log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();\n return;\n }\n super.initializeState(DIMENSIONS);\n this.setState({supported: true, colorDomain: DEFAULT_COLOR_DOMAIN});\n this._setupTextureParams();\n this._setupAttributes();\n this._setupResources();\n }\n\n shouldUpdateState({changeFlags}) {\n // Need to be updated when viewport changes\n return changeFlags.somethingChanged;\n }\n\n /* eslint-disable max-statements,complexity */\n updateState(opts) {\n if (!this.state.supported) {\n return;\n }\n super.updateState(opts);\n const {props, oldProps} = opts;\n const changeFlags = this._getChangeFlags(opts);\n\n if (changeFlags.viewportChanged) {\n changeFlags.boundsChanged = this._updateBounds();\n this._updateTextureRenderingBounds();\n }\n\n if (changeFlags.dataChanged || changeFlags.boundsChanged) {\n // Update weight map immediately\n clearTimeout(this.state.updateTimer);\n this.setState({isWeightMapDirty: true});\n } else if (changeFlags.viewportZoomChanged) {\n // Update weight map when zoom stops\n this._debouncedUpdateWeightmap();\n }\n\n if (props.colorRange !== oldProps.colorRange) {\n this._updateColorTexture(opts);\n }\n\n if (this.state.isWeightMapDirty) {\n this._updateWeightmap();\n }\n\n this.setState({zoom: opts.context.viewport.zoom});\n }\n /* eslint-enable max-statements,complexity */\n\n renderLayers() {\n if (!this.state.supported) {\n return [];\n }\n const {\n weightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n maxWeightsTexture,\n colorTexture,\n colorDomain\n } = this.state;\n const {updateTriggers, intensity, threshold, aggregation} = this.props;\n\n const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);\n\n return new TriangleLayerClass(\n this.getSubLayerProps({\n id: 'triangle-layer',\n updateTriggers\n }),\n {\n // position buffer is filled with world coordinates generated from viewport.unproject\n // i.e. LNGLAT if geospatial, CARTESIAN otherwise\n coordinateSystem: COORDINATE_SYSTEM.DEFAULT,\n data: {\n attributes: {\n positions: triPositionBuffer,\n texCoords: triTexCoordBuffer\n }\n },\n vertexCount: 4,\n maxTexture: maxWeightsTexture,\n colorTexture,\n aggregationMode: AGGREGATION_MODE[aggregation] || 0,\n texture: weightsTexture,\n intensity,\n threshold,\n colorDomain\n }\n );\n }\n\n finalizeState() {\n super.finalizeState();\n const {\n weightsTransform,\n weightsTexture,\n maxWeightTransform,\n maxWeightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n colorTexture,\n updateTimer\n } = this.state;\n weightsTransform?.delete();\n weightsTexture?.delete();\n maxWeightTransform?.delete();\n maxWeightsTexture?.delete();\n triPositionBuffer?.delete();\n triTexCoordBuffer?.delete();\n colorTexture?.delete();\n updateTimer && clearTimeout(updateTimer);\n }\n\n // PRIVATE\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.gl, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n\n _getChangeFlags(opts) {\n const changeFlags = {};\n const {dimensions} = this.state;\n changeFlags.dataChanged =\n this.isAttributeChanged() || // if any attribute is changed\n this.isAggregationDirty(opts, {\n compareAll: true,\n dimension: dimensions.data\n });\n changeFlags.viewportChanged = opts.changeFlags.viewportChanged;\n\n const {zoom} = this.state;\n if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {\n changeFlags.viewportZoomChanged = true;\n }\n\n return changeFlags;\n }\n\n _createTextures() {\n const {gl} = this.context;\n const {textureSize, format, type} = this.state;\n\n this.setState({\n weightsTexture: new Texture2D(gl, {\n width: textureSize,\n height: textureSize,\n format,\n type,\n ...TEXTURE_OPTIONS\n }),\n maxWeightsTexture: new Texture2D(gl, {format, type, ...TEXTURE_OPTIONS}) // 1 X 1 texture,\n });\n }\n\n _setupAttributes() {\n const attributeManager = this.getAttributeManager();\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'},\n weights: {size: 1, accessor: 'getWeight'}\n });\n this.setState({positionAttributeName: 'positions'});\n }\n\n _setupTextureParams() {\n const {gl} = this.context;\n const textureSize = Math.min(SIZE_2K, getParameters(gl, gl.MAX_TEXTURE_SIZE));\n const floatTargetSupport = hasFeatures(gl, FEATURES.COLOR_ATTACHMENT_RGBA32F);\n const {format, type} = getTextureParams({gl, floatTargetSupport});\n const weightsScale = floatTargetSupport ? 1 : 1 / 255;\n this.setState({textureSize, format, type, weightsScale});\n if (!floatTargetSupport) {\n log.warn(\n `HeatmapLayer: ${\n this.id\n } rendering to float texture not supported, fallingback to low precession format`\n )();\n }\n }\n\n _createWeightsTransform(shaderOptions = {}) {\n const {gl} = this.context;\n let {weightsTransform} = this.state;\n const {weightsTexture} = this.state;\n weightsTransform?.delete();\n const shaders = mergeShaders(\n {\n vs: weights_vs,\n _fs: weights_fs\n },\n shaderOptions\n );\n\n weightsTransform = new Transform(gl, {\n id: `${this.id}-weights-transform`,\n elementCount: 1,\n _targetTexture: weightsTexture,\n _targetTextureVarying: 'weightsTexture',\n ...shaders\n });\n this.setState({weightsTransform});\n }\n\n _setupResources() {\n const {gl} = this.context;\n this._createTextures();\n const {textureSize, weightsTexture, maxWeightsTexture} = this.state;\n this._createWeightsTransform();\n const maxWeightTransform = new Transform(gl, {\n id: `${this.id}-max-weights-transform`,\n _sourceTextures: {\n inTexture: weightsTexture\n },\n _targetTexture: maxWeightsTexture,\n _targetTextureVarying: 'outTexture',\n vs: vs_max,\n _fs: fs_max,\n elementCount: textureSize * textureSize\n });\n\n this.setState({\n weightsTexture,\n maxWeightsTexture,\n maxWeightTransform,\n zoom: null,\n triPositionBuffer: new Buffer(gl, {\n byteLength: 48,\n accessor: {size: 3}\n }),\n triTexCoordBuffer: new Buffer(gl, {\n byteLength: 48,\n accessor: {size: 2}\n })\n });\n }\n\n // overwrite super class method to update transform model\n updateShaders(shaderOptions) {\n // sahder params (modules, injects) changed, update model object\n this._createWeightsTransform(shaderOptions);\n }\n\n _updateMaxWeightValue() {\n const {maxWeightTransform} = this.state;\n maxWeightTransform.run({\n parameters: {\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.MAX\n }\n });\n }\n\n // Computes world bounds area that needs to be processed for generate heatmap\n _updateBounds(forceUpdate = false) {\n const {viewport} = this.context;\n\n // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)\n // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)\n const viewportCorners = [\n viewport.unproject([0, 0]),\n viewport.unproject([viewport.width, 0]),\n viewport.unproject([viewport.width, viewport.height]),\n viewport.unproject([0, viewport.height])\n ].map(p => p.map(Math.fround));\n\n // #1: get world bounds for current viewport extends\n const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds\n\n const newState = {visibleWorldBounds, viewportCorners};\n let boundsChanged = false;\n\n if (\n forceUpdate ||\n !this.state.worldBounds ||\n !boundsContain(this.state.worldBounds, visibleWorldBounds)\n ) {\n // #2 : convert world bounds to common (Flat) bounds\n // #3 : extend common bounds to match aspect ratio with viewport\n const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);\n\n // #4 :convert aligned common bounds to world bounds\n const worldBounds = this._commonToWorldBounds(scaledCommonBounds);\n\n // Clip webmercator projection limits\n if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {\n worldBounds[1] = Math.max(worldBounds[1], -85.051129);\n worldBounds[3] = Math.min(worldBounds[3], 85.051129);\n worldBounds[0] = Math.max(worldBounds[0], -360);\n worldBounds[2] = Math.min(worldBounds[2], 360);\n }\n\n // #5: now convert world bounds to common using Layer's coordiante system and origin\n const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);\n\n newState.worldBounds = worldBounds;\n newState.normalizedCommonBounds = normalizedCommonBounds;\n\n boundsChanged = true;\n }\n this.setState(newState);\n return boundsChanged;\n }\n\n _updateTextureRenderingBounds() {\n // Just render visible portion of the texture\n const {\n triPositionBuffer,\n triTexCoordBuffer,\n normalizedCommonBounds,\n viewportCorners\n } = this.state;\n\n const {viewport} = this.context;\n\n triPositionBuffer.subData(packVertices(viewportCorners, 3));\n\n const textureBounds = viewportCorners.map(p =>\n getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds)\n );\n triTexCoordBuffer.subData(packVertices(textureBounds, 2));\n }\n\n _updateColorTexture(opts) {\n const {colorRange} = opts.props;\n let {colorTexture} = this.state;\n const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);\n\n if (colorTexture) {\n colorTexture.setImageData({\n data: colors,\n width: colorRange.length\n });\n } else {\n colorTexture = new Texture2D(this.context.gl, {\n data: colors,\n width: colorRange.length,\n height: 1,\n ...TEXTURE_OPTIONS\n });\n }\n this.setState({colorTexture});\n }\n\n _updateWeightmap() {\n const {radiusPixels, colorDomain, aggregation} = this.props;\n const {weightsTransform, worldBounds, textureSize, weightsTexture, weightsScale} = this.state;\n this.state.isWeightMapDirty = false;\n\n // convert world bounds to common using Layer's coordiante system and origin\n const commonBounds = this._worldToCommonBounds(worldBounds, {\n useLayerCoordinateSystem: true\n });\n\n if (colorDomain && aggregation === 'SUM') {\n // scale color domain to weight per pixel\n const {viewport} = this.context;\n const metersPerPixel =\n (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /\n textureSize;\n this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);\n } else {\n this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;\n }\n\n const uniforms = {\n radiusPixels,\n commonBounds,\n textureWidth: textureSize,\n weightsScale\n };\n // Attribute manager sets data array count as instaceCount on model\n // we need to set that as elementCount on 'weightsTransform'\n weightsTransform.update({\n elementCount: this.getNumInstances()\n });\n weightsTransform.run({\n uniforms,\n parameters: {\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.FUNC_ADD\n },\n clearRenderTarget: true,\n attributes: this.getAttributes(),\n moduleSettings: this.getModuleSettings()\n });\n this._updateMaxWeightValue();\n\n // reset filtering parameters (TODO: remove once luma issue#1193 is fixed)\n weightsTexture.setParameters({\n [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n [GL.TEXTURE_MIN_FILTER]: GL.LINEAR\n });\n }\n\n _debouncedUpdateWeightmap(fromTimer = false) {\n let {updateTimer} = this.state;\n\n if (fromTimer) {\n updateTimer = null;\n // update\n this._updateBounds(true);\n this._updateTextureRenderingBounds();\n this.setState({isWeightMapDirty: true});\n } else {\n this.setState({isWeightMapDirty: false});\n clearTimeout(updateTimer);\n updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), ZOOM_DEBOUNCE);\n }\n\n this.setState({updateTimer});\n }\n\n // input: worldBounds: [minLong, minLat, maxLong, maxLat]\n // input: opts.useLayerCoordinateSystem : layers coordiante system is used\n // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture\n _worldToCommonBounds(worldBounds, opts = {}) {\n const {useLayerCoordinateSystem = false} = opts;\n const [minLong, minLat, maxLong, maxLat] = worldBounds;\n const {viewport} = this.context;\n const {textureSize} = this.state;\n const {coordinateSystem} = this.props;\n\n const offsetMode =\n useLayerCoordinateSystem &&\n (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||\n coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);\n const offsetOriginCommon = offsetMode\n ? viewport.projectPosition(this.props.coordinateOrigin)\n : [0, 0];\n const size = (textureSize * RESOLUTION) / viewport.scale;\n\n let bottomLeftCommon;\n let topRightCommon;\n\n // Y-axis is flipped between World and Common bounds\n if (useLayerCoordinateSystem && !offsetMode) {\n bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);\n topRightCommon = this.projectPosition([maxLong, maxLat, 0]);\n } else {\n bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);\n topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);\n }\n // Ignore z component\n return scaleToAspectRatio(\n [\n bottomLeftCommon[0] - offsetOriginCommon[0],\n bottomLeftCommon[1] - offsetOriginCommon[1],\n topRightCommon[0] - offsetOriginCommon[0],\n topRightCommon[1] - offsetOriginCommon[1]\n ],\n size,\n size\n );\n }\n\n // input commonBounds: [xMin, yMin, xMax, yMax]\n // output worldBounds: [minLong, minLat, maxLong, maxLat]\n _commonToWorldBounds(commonBounds) {\n const [xMin, yMin, xMax, yMax] = commonBounds;\n const {viewport} = this.context;\n const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);\n const topRightWorld = viewport.unprojectPosition([xMax, yMax]);\n\n return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));\n }\n}\n\nHeatmapLayer.layerName = 'HeatmapLayer';\nHeatmapLayer.defaultProps = defaultProps;\n"],"file":"heatmap-layer.js"}
1
+ {"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer.js"],"names":["RESOLUTION","TEXTURE_OPTIONS","mipmaps","parameters","dataFormat","DEFAULT_COLOR_DOMAIN","AGGREGATION_MODE","SUM","MEAN","defaultProps","getPosition","type","value","x","position","getWeight","intensity","min","radiusPixels","max","colorRange","defaultColorRange","threshold","colorDomain","optional","aggregation","weightsTextureSize","debounceTimeout","REQUIRED_FEATURES","FEATURES","BLEND_EQUATION_MINMAX","TEXTURE_FLOAT","DIMENSIONS","data","props","HeatmapLayer","gl","context","setState","supported","log","error","id","_setupTextureParams","_setupAttributes","_setupResources","changeFlags","somethingChanged","opts","state","_updateHeatmapState","oldProps","_getChangeFlags","viewportChanged","boundsChanged","_updateBounds","_updateTextureRenderingBounds","dataChanged","clearTimeout","updateTimer","isWeightMapDirty","viewportZoomChanged","_debouncedUpdateWeightmap","_updateColorTexture","_updateWeightmap","zoom","viewport","weightsTexture","triPositionBuffer","triTexCoordBuffer","maxWeightsTexture","colorTexture","updateTriggers","TriangleLayerClass","getSubLayerClass","TriangleLayer","getSubLayerProps","coordinateSystem","COORDINATE_SYSTEM","DEFAULT","attributes","positions","texCoords","vertexCount","maxTexture","aggregationMode","texture","weightsTransform","maxWeightTransform","delete","AttributeManager","stats","dimensions","isAttributeChanged","isAggregationDirty","compareAll","dimension","textureSize","format","Texture2D","width","height","attributeManager","getAttributeManager","add","size","accessor","weights","positionAttributeName","Math","floatTargetSupport","COLOR_ATTACHMENT_RGBA32F","weightsScale","warn","vs","vs_max","_fs","fs_max","weights_vs","weights_fs","shaders","Transform","elementCount","_targetTexture","_targetTextureVarying","_createTextures","weightsTransformShaders","getShaders","_createWeightsTransform","maxWeightsTransformShaders","_sourceTextures","inTexture","Buffer","byteLength","shaderOptions","run","blend","depthTest","blendFunc","blendEquation","forceUpdate","viewportCorners","unproject","map","p","fround","visibleWorldBounds","newState","worldBounds","scaledCommonBounds","_worldToCommonBounds","_commonToWorldBounds","LNGLAT","normalizedCommonBounds","subData","textureBounds","projectPosition","colors","Uint8Array","setImageData","length","commonBounds","useLayerCoordinateSystem","metersPerPixel","distanceScales","metersPerUnit","uniforms","textureWidth","update","getNumInstances","clearRenderTarget","getAttributes","moduleSettings","getModuleSettings","_updateMaxWeightValue","setParameters","fromTimer","setTimeout","bind","minLong","minLat","maxLong","maxLat","offsetMode","LNGLAT_OFFSETS","METER_OFFSETS","offsetOriginCommon","coordinateOrigin","scale","bottomLeftCommon","topRightCommon","xMin","yMin","xMax","yMax","bottomLeftWorld","unprojectPosition","topRightWorld","slice","concat","AggregationLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,CAAnB;AACA,IAAMC,eAAe,GAAG;AACtBC,EAAAA,OAAO,EAAE,KADa;AAEtBC,EAAAA,UAAU,uQAFY;AAQtBC,EAAAA,UAAU;AARY,CAAxB;AAUA,IAAMC,oBAAoB,GAAG,CAAC,CAAD,EAAI,CAAJ,CAA7B;AACA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,GAAG,EAAE,CADkB;AAEvBC,EAAAA,IAAI,EAAE;AAFiB,CAAzB;AAKA,IAAMC,YAAY,GAAG;AACnBC,EAAAA,WAAW,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,eAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,QAAN;AAAA;AAA3B,GADM;AAEnBC,EAAAA,SAAS,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAFQ;AAGnBI,EAAAA,SAAS,EAAE;AAACL,IAAAA,IAAI,EAAE,QAAP;AAAiBM,IAAAA,GAAG,EAAE,CAAtB;AAAyBL,IAAAA,KAAK,EAAE;AAAhC,GAHQ;AAInBM,EAAAA,YAAY,EAAE;AAACP,IAAAA,IAAI,EAAE,QAAP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d,KAAK7B,OAFS,CAE1B6B,QAF0B;AAGjC,UAAMiI,eAAe,GAAGjI,QAAQ,CAACkI,iBAAT,CAA2B,CAACL,IAAD,EAAOC,IAAP,CAA3B,CAAxB;AACA,UAAMK,aAAa,GAAGnI,QAAQ,CAACkI,iBAAT,CAA2B,CAACH,IAAD,EAAOC,IAAP,CAA3B,CAAtB;AAEA,aAAOC,eAAe,CAACG,KAAhB,CAAsB,CAAtB,EAAyB,CAAzB,EAA4BC,MAA5B,CAAmCF,aAAa,CAACC,KAAd,CAAoB,CAApB,EAAuB,CAAvB,CAAnC,CAAP;AACD;;;EA9euCE,yB;;;AAif1CrK,YAAY,CAACsK,SAAb,GAAyB,cAAzB;AACAtK,YAAY,CAAC1B,YAAb,GAA4BA,YAA5B","sourcesContent":["// Copyright (c) 2015 - 2019 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global setTimeout clearTimeout */\nimport GL from '@luma.gl/constants';\nimport {\n getBounds,\n boundsContain,\n packVertices,\n scaleToAspectRatio,\n getTextureCoordinates,\n getTextureParams\n} from './heatmap-layer-utils';\nimport {Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures} from '@luma.gl/core';\nimport {AttributeManager, COORDINATE_SYSTEM, log} from '@deck.gl/core';\nimport TriangleLayer from './triangle-layer';\nimport AggregationLayer from '../aggregation-layer';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport weights_vs from './weights-vs.glsl';\nimport weights_fs from './weights-fs.glsl';\nimport vs_max from './max-vs.glsl';\nimport fs_max from './max-fs.glsl';\n\nconst RESOLUTION = 2; // (number of common space pixels) / (number texels)\nconst TEXTURE_OPTIONS = {\n mipmaps: false,\n parameters: {\n [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n },\n dataFormat: GL.RGBA\n};\nconst DEFAULT_COLOR_DOMAIN = [0, 0];\nconst AGGREGATION_MODE = {\n SUM: 0,\n MEAN: 1\n};\n\nconst defaultProps = {\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n intensity: {type: 'number', min: 0, value: 1},\n radiusPixels: {type: 'number', min: 1, max: 100, value: 50},\n colorRange: defaultColorRange,\n threshold: {type: 'number', min: 0, max: 1, value: 0.05},\n colorDomain: {type: 'array', value: null, optional: true},\n // 'SUM' or 'MEAN'\n aggregation: 'SUM',\n weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},\n debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}\n};\n\nconst REQUIRED_FEATURES = [\n FEATURES.BLEND_EQUATION_MINMAX, // max weight calculation\n FEATURES.TEXTURE_FLOAT // weight-map as texture\n // FEATURES.FLOAT_BLEND, // implictly supported when TEXTURE_FLOAT is supported\n];\n\nconst DIMENSIONS = {\n data: {\n props: ['radiusPixels']\n }\n};\n\nexport default class HeatmapLayer extends AggregationLayer {\n initializeState() {\n const {gl} = this.context;\n if (!hasFeatures(gl, REQUIRED_FEATURES)) {\n this.setState({supported: false});\n log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();\n return;\n }\n super.initializeState(DIMENSIONS);\n this.setState({supported: true, colorDomain: DEFAULT_COLOR_DOMAIN});\n this._setupTextureParams();\n this._setupAttributes();\n this._setupResources();\n }\n\n shouldUpdateState({changeFlags}) {\n // Need to be updated when viewport changes\n return changeFlags.somethingChanged;\n }\n\n /* eslint-disable max-statements,complexity */\n updateState(opts) {\n if (!this.state.supported) {\n return;\n }\n super.updateState(opts);\n this._updateHeatmapState(opts);\n }\n\n _updateHeatmapState(opts) {\n const {props, oldProps} = opts;\n const changeFlags = this._getChangeFlags(opts);\n\n if (changeFlags.viewportChanged) {\n changeFlags.boundsChanged = this._updateBounds();\n this._updateTextureRenderingBounds();\n }\n\n if (changeFlags.dataChanged || changeFlags.boundsChanged) {\n // Update weight map immediately\n clearTimeout(this.state.updateTimer);\n this.setState({isWeightMapDirty: true});\n } else if (changeFlags.viewportZoomChanged) {\n // Update weight map when zoom stops\n this._debouncedUpdateWeightmap();\n }\n\n if (props.colorRange !== oldProps.colorRange) {\n this._updateColorTexture(opts);\n }\n\n if (this.state.isWeightMapDirty) {\n this._updateWeightmap();\n }\n\n this.setState({zoom: opts.context.viewport.zoom});\n }\n\n renderLayers() {\n if (!this.state.supported) {\n return [];\n }\n const {\n weightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n maxWeightsTexture,\n colorTexture,\n colorDomain\n } = this.state;\n const {updateTriggers, intensity, threshold, aggregation} = this.props;\n\n const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);\n\n return new TriangleLayerClass(\n this.getSubLayerProps({\n id: 'triangle-layer',\n updateTriggers\n }),\n {\n // position buffer is filled with world coordinates generated from viewport.unproject\n // i.e. LNGLAT if geospatial, CARTESIAN otherwise\n coordinateSystem: COORDINATE_SYSTEM.DEFAULT,\n data: {\n attributes: {\n positions: triPositionBuffer,\n texCoords: triTexCoordBuffer\n }\n },\n vertexCount: 4,\n maxTexture: maxWeightsTexture,\n colorTexture,\n aggregationMode: AGGREGATION_MODE[aggregation] || 0,\n texture: weightsTexture,\n intensity,\n threshold,\n colorDomain\n }\n );\n }\n\n finalizeState() {\n super.finalizeState();\n const {\n weightsTransform,\n weightsTexture,\n maxWeightTransform,\n maxWeightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n colorTexture,\n updateTimer\n } = this.state;\n weightsTransform?.delete();\n weightsTexture?.delete();\n maxWeightTransform?.delete();\n maxWeightsTexture?.delete();\n triPositionBuffer?.delete();\n triTexCoordBuffer?.delete();\n colorTexture?.delete();\n updateTimer && clearTimeout(updateTimer);\n }\n\n // PRIVATE\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.gl, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n\n _getChangeFlags(opts) {\n const changeFlags = {};\n const {dimensions} = this.state;\n changeFlags.dataChanged =\n this.isAttributeChanged() || // if any attribute is changed\n this.isAggregationDirty(opts, {\n compareAll: true,\n dimension: dimensions.data\n });\n changeFlags.viewportChanged = opts.changeFlags.viewportChanged;\n\n const {zoom} = this.state;\n if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {\n changeFlags.viewportZoomChanged = true;\n }\n\n return changeFlags;\n }\n\n _createTextures() {\n const {gl} = this.context;\n const {textureSize, format, type} = this.state;\n\n this.setState({\n weightsTexture: new Texture2D(gl, {\n width: textureSize,\n height: textureSize,\n format,\n type,\n ...TEXTURE_OPTIONS\n }),\n maxWeightsTexture: new Texture2D(gl, {format, type, ...TEXTURE_OPTIONS}) // 1 X 1 texture,\n });\n }\n\n _setupAttributes() {\n const attributeManager = this.getAttributeManager();\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'},\n weights: {size: 1, accessor: 'getWeight'}\n });\n this.setState({positionAttributeName: 'positions'});\n }\n\n _setupTextureParams() {\n const {gl} = this.context;\n const {weightsTextureSize} = this.props;\n\n const textureSize = Math.min(weightsTextureSize, getParameters(gl, gl.MAX_TEXTURE_SIZE));\n const floatTargetSupport = hasFeatures(gl, FEATURES.COLOR_ATTACHMENT_RGBA32F);\n const {format, type} = getTextureParams({gl, floatTargetSupport});\n const weightsScale = floatTargetSupport ? 1 : 1 / 255;\n this.setState({textureSize, format, type, weightsScale});\n if (!floatTargetSupport) {\n log.warn(\n `HeatmapLayer: ${\n this.id\n } rendering to float texture not supported, fallingback to low precession format`\n )();\n }\n }\n\n getShaders(type) {\n return super.getShaders(\n type === 'max-weights-transform'\n ? {\n vs: vs_max,\n _fs: fs_max\n }\n : {\n vs: weights_vs,\n _fs: weights_fs\n }\n );\n }\n\n _createWeightsTransform(shaders = {}) {\n const {gl} = this.context;\n let {weightsTransform} = this.state;\n const {weightsTexture} = this.state;\n weightsTransform?.delete();\n\n weightsTransform = new Transform(gl, {\n id: `${this.id}-weights-transform`,\n elementCount: 1,\n _targetTexture: weightsTexture,\n _targetTextureVarying: 'weightsTexture',\n ...shaders\n });\n this.setState({weightsTransform});\n }\n\n _setupResources() {\n const {gl} = this.context;\n this._createTextures();\n const {textureSize, weightsTexture, maxWeightsTexture} = this.state;\n\n const weightsTransformShaders = this.getShaders('weights-transform');\n this._createWeightsTransform(weightsTransformShaders);\n\n const maxWeightsTransformShaders = this.getShaders('max-weights-transform');\n const maxWeightTransform = new Transform(gl, {\n id: `${this.id}-max-weights-transform`,\n _sourceTextures: {\n inTexture: weightsTexture\n },\n _targetTexture: maxWeightsTexture,\n _targetTextureVarying: 'outTexture',\n ...maxWeightsTransformShaders,\n elementCount: textureSize * textureSize\n });\n\n this.setState({\n weightsTexture,\n maxWeightsTexture,\n maxWeightTransform,\n zoom: null,\n triPositionBuffer: new Buffer(gl, {\n byteLength: 48,\n accessor: {size: 3}\n }),\n triTexCoordBuffer: new Buffer(gl, {\n byteLength: 48,\n accessor: {size: 2}\n })\n });\n }\n\n // overwrite super class method to update transform model\n updateShaders(shaderOptions) {\n // sahder params (modules, injects) changed, update model object\n this._createWeightsTransform(shaderOptions);\n }\n\n _updateMaxWeightValue() {\n const {maxWeightTransform} = this.state;\n maxWeightTransform.run({\n parameters: {\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.MAX\n }\n });\n }\n\n // Computes world bounds area that needs to be processed for generate heatmap\n _updateBounds(forceUpdate = false) {\n const {viewport} = this.context;\n\n // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)\n // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)\n const viewportCorners = [\n viewport.unproject([0, 0]),\n viewport.unproject([viewport.width, 0]),\n viewport.unproject([viewport.width, viewport.height]),\n viewport.unproject([0, viewport.height])\n ].map(p => p.map(Math.fround));\n\n // #1: get world bounds for current viewport extends\n const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds\n\n const newState = {visibleWorldBounds, viewportCorners};\n let boundsChanged = false;\n\n if (\n forceUpdate ||\n !this.state.worldBounds ||\n !boundsContain(this.state.worldBounds, visibleWorldBounds)\n ) {\n // #2 : convert world bounds to common (Flat) bounds\n // #3 : extend common bounds to match aspect ratio with viewport\n const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);\n\n // #4 :convert aligned common bounds to world bounds\n const worldBounds = this._commonToWorldBounds(scaledCommonBounds);\n\n // Clip webmercator projection limits\n if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {\n worldBounds[1] = Math.max(worldBounds[1], -85.051129);\n worldBounds[3] = Math.min(worldBounds[3], 85.051129);\n worldBounds[0] = Math.max(worldBounds[0], -360);\n worldBounds[2] = Math.min(worldBounds[2], 360);\n }\n\n // #5: now convert world bounds to common using Layer's coordiante system and origin\n const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);\n\n newState.worldBounds = worldBounds;\n newState.normalizedCommonBounds = normalizedCommonBounds;\n\n boundsChanged = true;\n }\n this.setState(newState);\n return boundsChanged;\n }\n\n _updateTextureRenderingBounds() {\n // Just render visible portion of the texture\n const {\n triPositionBuffer,\n triTexCoordBuffer,\n normalizedCommonBounds,\n viewportCorners\n } = this.state;\n\n const {viewport} = this.context;\n\n triPositionBuffer.subData(packVertices(viewportCorners, 3));\n\n const textureBounds = viewportCorners.map(p =>\n getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds)\n );\n triTexCoordBuffer.subData(packVertices(textureBounds, 2));\n }\n\n _updateColorTexture(opts) {\n const {colorRange} = opts.props;\n let {colorTexture} = this.state;\n const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);\n\n if (colorTexture) {\n colorTexture.setImageData({\n data: colors,\n width: colorRange.length\n });\n } else {\n colorTexture = new Texture2D(this.context.gl, {\n data: colors,\n width: colorRange.length,\n height: 1,\n ...TEXTURE_OPTIONS\n });\n }\n this.setState({colorTexture});\n }\n\n _updateWeightmap() {\n const {radiusPixels, colorDomain, aggregation} = this.props;\n const {weightsTransform, worldBounds, textureSize, weightsTexture, weightsScale} = this.state;\n this.state.isWeightMapDirty = false;\n\n // convert world bounds to common using Layer's coordiante system and origin\n const commonBounds = this._worldToCommonBounds(worldBounds, {\n useLayerCoordinateSystem: true\n });\n\n if (colorDomain && aggregation === 'SUM') {\n // scale color domain to weight per pixel\n const {viewport} = this.context;\n const metersPerPixel =\n (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /\n textureSize;\n this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);\n } else {\n this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;\n }\n\n const uniforms = {\n radiusPixels,\n commonBounds,\n textureWidth: textureSize,\n weightsScale\n };\n // Attribute manager sets data array count as instaceCount on model\n // we need to set that as elementCount on 'weightsTransform'\n weightsTransform.update({\n elementCount: this.getNumInstances()\n });\n weightsTransform.run({\n uniforms,\n parameters: {\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.FUNC_ADD\n },\n clearRenderTarget: true,\n attributes: this.getAttributes(),\n moduleSettings: this.getModuleSettings()\n });\n this._updateMaxWeightValue();\n\n // reset filtering parameters (TODO: remove once luma issue#1193 is fixed)\n weightsTexture.setParameters({\n [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,\n [GL.TEXTURE_MIN_FILTER]: GL.LINEAR\n });\n }\n\n _debouncedUpdateWeightmap(fromTimer = false) {\n let {updateTimer} = this.state;\n const {debounceTimeout} = this.props;\n\n if (fromTimer) {\n updateTimer = null;\n // update\n this._updateBounds(true);\n this._updateTextureRenderingBounds();\n this.setState({isWeightMapDirty: true});\n } else {\n this.setState({isWeightMapDirty: false});\n clearTimeout(updateTimer);\n updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);\n }\n\n this.setState({updateTimer});\n }\n\n // input: worldBounds: [minLong, minLat, maxLong, maxLat]\n // input: opts.useLayerCoordinateSystem : layers coordiante system is used\n // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture\n _worldToCommonBounds(worldBounds, opts = {}) {\n const {useLayerCoordinateSystem = false} = opts;\n const [minLong, minLat, maxLong, maxLat] = worldBounds;\n const {viewport} = this.context;\n const {textureSize} = this.state;\n const {coordinateSystem} = this.props;\n\n const offsetMode =\n useLayerCoordinateSystem &&\n (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||\n coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);\n const offsetOriginCommon = offsetMode\n ? viewport.projectPosition(this.props.coordinateOrigin)\n : [0, 0];\n const size = (textureSize * RESOLUTION) / viewport.scale;\n\n let bottomLeftCommon;\n let topRightCommon;\n\n // Y-axis is flipped between World and Common bounds\n if (useLayerCoordinateSystem && !offsetMode) {\n bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);\n topRightCommon = this.projectPosition([maxLong, maxLat, 0]);\n } else {\n bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);\n topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);\n }\n // Ignore z component\n return scaleToAspectRatio(\n [\n bottomLeftCommon[0] - offsetOriginCommon[0],\n bottomLeftCommon[1] - offsetOriginCommon[1],\n topRightCommon[0] - offsetOriginCommon[0],\n topRightCommon[1] - offsetOriginCommon[1]\n ],\n size,\n size\n );\n }\n\n // input commonBounds: [xMin, yMin, xMax, yMax]\n // output worldBounds: [minLong, minLat, maxLong, maxLat]\n _commonToWorldBounds(commonBounds) {\n const [xMin, yMin, xMax, yMax] = commonBounds;\n const {viewport} = this.context;\n const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);\n const topRightWorld = viewport.unprojectPosition([xMax, yMax]);\n\n return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));\n }\n}\n\nHeatmapLayer.layerName = 'HeatmapLayer';\nHeatmapLayer.defaultProps = defaultProps;\n"],"file":"heatmap-layer.js"}
@@ -1,6 +1,6 @@
1
1
  import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates, getTextureParams } from './heatmap-layer-utils';
2
2
  import { Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures } from '@luma.gl/core';
3
- import { AttributeManager, COORDINATE_SYSTEM, log, _mergeShaders as mergeShaders } from '@deck.gl/core';
3
+ import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
4
4
  import TriangleLayer from './triangle-layer';
5
5
  import AggregationLayer from '../aggregation-layer';
6
6
  import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
@@ -9,8 +9,6 @@ import weights_fs from './weights-fs.glsl';
9
9
  import vs_max from './max-vs.glsl';
10
10
  import fs_max from './max-fs.glsl';
11
11
  const RESOLUTION = 2;
12
- const SIZE_2K = 2048;
13
- const ZOOM_DEBOUNCE = 500;
14
12
  const TEXTURE_OPTIONS = {
15
13
  mipmaps: false,
16
14
  parameters: {
@@ -58,7 +56,19 @@ const defaultProps = {
58
56
  value: null,
59
57
  optional: true
60
58
  },
61
- aggregation: 'SUM'
59
+ aggregation: 'SUM',
60
+ weightsTextureSize: {
61
+ type: 'number',
62
+ min: 128,
63
+ max: 2048,
64
+ value: 2048
65
+ },
66
+ debounceTimeout: {
67
+ type: 'number',
68
+ min: 0,
69
+ max: 1000,
70
+ value: 500
71
+ }
62
72
  };
63
73
  const REQUIRED_FEATURES = [FEATURES.BLEND_EQUATION_MINMAX, FEATURES.TEXTURE_FLOAT];
64
74
  const DIMENSIONS = {
@@ -105,6 +115,11 @@ export default class HeatmapLayer extends AggregationLayer {
105
115
  }
106
116
 
107
117
  super.updateState(opts);
118
+
119
+ this._updateHeatmapState(opts);
120
+ }
121
+
122
+ _updateHeatmapState(opts) {
108
123
  const {
109
124
  props,
110
125
  oldProps
@@ -279,7 +294,10 @@ export default class HeatmapLayer extends AggregationLayer {
279
294
  const {
280
295
  gl
281
296
  } = this.context;
282
- const textureSize = Math.min(SIZE_2K, getParameters(gl, 3379));
297
+ const {
298
+ weightsTextureSize
299
+ } = this.props;
300
+ const textureSize = Math.min(weightsTextureSize, getParameters(gl, 3379));
283
301
  const floatTargetSupport = hasFeatures(gl, FEATURES.COLOR_ATTACHMENT_RGBA32F);
284
302
  const {
285
303
  format,
@@ -301,7 +319,17 @@ export default class HeatmapLayer extends AggregationLayer {
301
319
  }
302
320
  }
303
321
 
304
- _createWeightsTransform(shaderOptions = {}) {
322
+ getShaders(type) {
323
+ return super.getShaders(type === 'max-weights-transform' ? {
324
+ vs: vs_max,
325
+ _fs: fs_max
326
+ } : {
327
+ vs: weights_vs,
328
+ _fs: weights_fs
329
+ });
330
+ }
331
+
332
+ _createWeightsTransform(shaders = {}) {
305
333
  var _weightsTransform;
306
334
 
307
335
  const {
@@ -314,10 +342,6 @@ export default class HeatmapLayer extends AggregationLayer {
314
342
  weightsTexture
315
343
  } = this.state;
316
344
  (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
317
- const shaders = mergeShaders({
318
- vs: weights_vs,
319
- _fs: weights_fs
320
- }, shaderOptions);
321
345
  weightsTransform = new Transform(gl, {
322
346
  id: "".concat(this.id, "-weights-transform"),
323
347
  elementCount: 1,
@@ -342,9 +366,11 @@ export default class HeatmapLayer extends AggregationLayer {
342
366
  weightsTexture,
343
367
  maxWeightsTexture
344
368
  } = this.state;
369
+ const weightsTransformShaders = this.getShaders('weights-transform');
345
370
 
346
- this._createWeightsTransform();
371
+ this._createWeightsTransform(weightsTransformShaders);
347
372
 
373
+ const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
348
374
  const maxWeightTransform = new Transform(gl, {
349
375
  id: "".concat(this.id, "-max-weights-transform"),
350
376
  _sourceTextures: {
@@ -352,8 +378,7 @@ export default class HeatmapLayer extends AggregationLayer {
352
378
  },
353
379
  _targetTexture: maxWeightsTexture,
354
380
  _targetTextureVarying: 'outTexture',
355
- vs: vs_max,
356
- _fs: fs_max,
381
+ ...maxWeightsTransformShaders,
357
382
  elementCount: textureSize * textureSize
358
383
  });
359
384
  this.setState({
@@ -535,6 +560,9 @@ export default class HeatmapLayer extends AggregationLayer {
535
560
  let {
536
561
  updateTimer
537
562
  } = this.state;
563
+ const {
564
+ debounceTimeout
565
+ } = this.props;
538
566
 
539
567
  if (fromTimer) {
540
568
  updateTimer = null;
@@ -551,7 +579,7 @@ export default class HeatmapLayer extends AggregationLayer {
551
579
  isWeightMapDirty: false
552
580
  });
553
581
  clearTimeout(updateTimer);
554
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), ZOOM_DEBOUNCE);
582
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
555
583
  }
556
584
 
557
585
  this.setState({