@deck.gl/aggregation-layers 8.10.0-alpha.2 → 8.10.0-alpha.5

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 (142) hide show
  1. package/LICENSE +1 -1
  2. package/dist/dist.dev.js +58 -709
  3. package/dist/es5/aggregation-layer.js +120 -134
  4. package/dist/es5/aggregation-layer.js.map +1 -1
  5. package/dist/es5/contour-layer/contour-layer.js +225 -234
  6. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  7. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +90 -100
  8. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  9. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -140
  10. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  11. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +285 -295
  12. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  13. package/dist/es5/grid-aggregation-layer.js +194 -209
  14. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  15. package/dist/es5/grid-layer/grid-layer.js +59 -66
  16. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  17. package/dist/es5/heatmap-layer/heatmap-layer.js +471 -497
  18. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  19. package/dist/es5/heatmap-layer/triangle-layer.js +64 -69
  20. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  21. package/dist/es5/hexagon-layer/hexagon-layer.js +129 -140
  22. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  23. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +153 -166
  24. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  25. package/dist/es5/screen-grid-layer/screen-grid-layer.js +207 -220
  26. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  27. package/dist/es5/utils/bin-sorter.js +163 -173
  28. package/dist/es5/utils/bin-sorter.js.map +1 -1
  29. package/dist/es5/utils/cpu-aggregator.js +300 -323
  30. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  31. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +483 -504
  32. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  33. package/dist/esm/aggregation-layer.js +2 -5
  34. package/dist/esm/aggregation-layer.js.map +1 -1
  35. package/dist/esm/contour-layer/contour-layer.js +2 -5
  36. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  37. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +2 -5
  38. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  39. package/dist/esm/cpu-grid-layer/grid-aggregator.js +1 -1
  40. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
  41. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +15 -1
  42. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  43. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +121 -1
  44. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  45. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +2 -5
  46. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  47. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +3 -6
  48. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  49. package/dist/esm/grid-aggregation-layer.js +3 -6
  50. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  51. package/dist/esm/grid-layer/grid-layer.js +3 -7
  52. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  53. package/dist/esm/heatmap-layer/heatmap-layer.js +7 -11
  54. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  55. package/dist/esm/heatmap-layer/max-fs.glsl.js +7 -1
  56. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  57. package/dist/esm/heatmap-layer/max-vs.glsl.js +12 -1
  58. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  59. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +39 -1
  60. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  61. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +31 -1
  62. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  63. package/dist/esm/heatmap-layer/triangle-layer.js +1 -3
  64. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  65. package/dist/esm/heatmap-layer/weights-fs.glsl.js +19 -1
  66. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  67. package/dist/esm/heatmap-layer/weights-vs.glsl.js +23 -1
  68. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  69. package/dist/esm/hexagon-layer/hexagon-layer.js +3 -7
  70. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  71. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +3 -7
  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-fragment.glsl.js +17 -1
  74. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  75. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +64 -1
  76. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  77. package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -9
  78. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  79. package/dist/esm/utils/bin-sorter.js +7 -16
  80. package/dist/esm/utils/bin-sorter.js.map +1 -1
  81. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +20 -1
  82. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
  83. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +34 -1
  84. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
  85. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +12 -1
  86. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
  87. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +58 -1
  88. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
  89. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +14 -14
  90. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  91. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +17 -1
  92. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
  93. package/dist/esm/utils/scale-utils.js +2 -2
  94. package/dist/esm/utils/scale-utils.js.map +1 -1
  95. package/dist.min.js +30 -27
  96. package/package.json +2 -2
  97. package/typed/aggregation-layer.js +0 -151
  98. package/typed/contour-layer/contour-layer.js +0 -234
  99. package/typed/contour-layer/contour-utils.js +0 -64
  100. package/typed/contour-layer/marching-squares-codes.js +0 -337
  101. package/typed/contour-layer/marching-squares.js +0 -147
  102. package/typed/cpu-grid-layer/cpu-grid-layer.js +0 -129
  103. package/typed/cpu-grid-layer/grid-aggregator.js +0 -141
  104. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -34
  105. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -141
  106. package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +0 -143
  107. package/typed/gpu-grid-layer/gpu-grid-layer.js +0 -289
  108. package/typed/grid-aggregation-layer.js +0 -172
  109. package/typed/grid-layer/grid-layer.js +0 -60
  110. package/typed/heatmap-layer/heatmap-layer-utils.js +0 -78
  111. package/typed/heatmap-layer/heatmap-layer.js +0 -478
  112. package/typed/heatmap-layer/max-fs.glsl.js +0 -7
  113. package/typed/heatmap-layer/max-vs.glsl.js +0 -12
  114. package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +0 -58
  115. package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +0 -51
  116. package/typed/heatmap-layer/triangle-layer.js +0 -67
  117. package/typed/heatmap-layer/weights-fs.glsl.js +0 -19
  118. package/typed/heatmap-layer/weights-vs.glsl.js +0 -23
  119. package/typed/hexagon-layer/hexagon-aggregator.js +0 -112
  120. package/typed/hexagon-layer/hexagon-layer.js +0 -171
  121. package/typed/index.js +0 -33
  122. package/typed/screen-grid-layer/screen-grid-cell-layer.js +0 -159
  123. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -37
  124. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -83
  125. package/typed/screen-grid-layer/screen-grid-layer.js +0 -216
  126. package/typed/types.js +0 -1
  127. package/typed/utils/aggregation-operation-utils.js +0 -94
  128. package/typed/utils/bin-sorter.js +0 -167
  129. package/typed/utils/color-utils.js +0 -53
  130. package/typed/utils/cpu-aggregator.js +0 -417
  131. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -39
  132. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -53
  133. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -31
  134. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -77
  135. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  136. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  137. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -562
  138. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -36
  139. package/typed/utils/grid-aggregation-utils.js +0 -114
  140. package/typed/utils/prop-utils.js +0 -28
  141. package/typed/utils/resource-utils.js +0 -40
  142. package/typed/utils/scale-utils.js +0 -184
@@ -11,10 +11,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
14
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
19
15
 
20
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -137,560 +133,538 @@ var HeatmapLayer = function (_AggregationLayer) {
137
133
  }
138
134
 
139
135
  _this = _super.call.apply(_super, [this].concat(args));
140
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
136
+ _this.state = void 0;
141
137
  return _this;
142
138
  }
143
139
 
144
- (0, _createClass2.default)(HeatmapLayer, [{
145
- key: "initializeState",
146
- value: function initializeState() {
147
- var gl = this.context.gl;
148
-
149
- if (!(0, _core.hasFeatures)(gl, REQUIRED_FEATURES)) {
150
- this.setState({
151
- supported: false
152
- });
140
+ var _proto = HeatmapLayer.prototype;
153
141
 
154
- _core2.log.error("HeatmapLayer: ".concat(this.id, " is not supported on this browser"))();
142
+ _proto.initializeState = function initializeState() {
143
+ var gl = this.context.gl;
155
144
 
156
- return;
157
- }
158
-
159
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "initializeAggregationLayer", this).call(this, DIMENSIONS);
145
+ if (!(0, _core.hasFeatures)(gl, REQUIRED_FEATURES)) {
160
146
  this.setState({
161
- supported: true,
162
- colorDomain: DEFAULT_COLOR_DOMAIN
147
+ supported: false
163
148
  });
164
149
 
165
- this._setupTextureParams();
166
-
167
- this._setupAttributes();
150
+ _core2.log.error("HeatmapLayer: ".concat(this.id, " is not supported on this browser"))();
168
151
 
169
- this._setupResources();
152
+ return;
170
153
  }
171
- }, {
172
- key: "shouldUpdateState",
173
- value: function shouldUpdateState(_ref) {
174
- var changeFlags = _ref.changeFlags;
175
- return changeFlags.somethingChanged;
176
- }
177
- }, {
178
- key: "updateState",
179
- value: function updateState(opts) {
180
- if (!this.state.supported) {
181
- return;
182
- }
183
154
 
184
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "updateState", this).call(this, opts);
155
+ (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "initializeAggregationLayer", this).call(this, DIMENSIONS);
156
+ this.setState({
157
+ supported: true,
158
+ colorDomain: DEFAULT_COLOR_DOMAIN
159
+ });
160
+
161
+ this._setupTextureParams();
162
+
163
+ this._setupAttributes();
164
+
165
+ this._setupResources();
166
+ };
185
167
 
186
- this._updateHeatmapState(opts);
168
+ _proto.shouldUpdateState = function shouldUpdateState(_ref) {
169
+ var changeFlags = _ref.changeFlags;
170
+ return changeFlags.somethingChanged;
171
+ };
172
+
173
+ _proto.updateState = function updateState(opts) {
174
+ if (!this.state.supported) {
175
+ return;
187
176
  }
188
- }, {
189
- key: "_updateHeatmapState",
190
- value: function _updateHeatmapState(opts) {
191
- var props = opts.props,
192
- oldProps = opts.oldProps;
193
177
 
194
- var changeFlags = this._getChangeFlags(opts);
178
+ (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "updateState", this).call(this, opts);
195
179
 
196
- if (changeFlags.dataChanged || changeFlags.viewportChanged) {
197
- changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
180
+ this._updateHeatmapState(opts);
181
+ };
198
182
 
199
- this._updateTextureRenderingBounds();
200
- }
183
+ _proto._updateHeatmapState = function _updateHeatmapState(opts) {
184
+ var props = opts.props,
185
+ oldProps = opts.oldProps;
201
186
 
202
- if (changeFlags.dataChanged || changeFlags.boundsChanged) {
203
- clearTimeout(this.state.updateTimer);
204
- this.setState({
205
- isWeightMapDirty: true
206
- });
207
- } else if (changeFlags.viewportZoomChanged) {
208
- this._debouncedUpdateWeightmap();
209
- }
187
+ var changeFlags = this._getChangeFlags(opts);
210
188
 
211
- if (props.colorRange !== oldProps.colorRange) {
212
- this._updateColorTexture(opts);
213
- }
189
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
190
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
214
191
 
215
- if (this.state.isWeightMapDirty) {
216
- this._updateWeightmap();
217
- }
192
+ this._updateTextureRenderingBounds();
193
+ }
218
194
 
195
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
196
+ clearTimeout(this.state.updateTimer);
219
197
  this.setState({
220
- zoom: opts.context.viewport.zoom
198
+ isWeightMapDirty: true
221
199
  });
200
+ } else if (changeFlags.viewportZoomChanged) {
201
+ this._debouncedUpdateWeightmap();
222
202
  }
223
- }, {
224
- key: "renderLayers",
225
- value: function renderLayers() {
226
- if (!this.state.supported) {
227
- return [];
228
- }
229
203
 
230
- var _this$state = this.state,
231
- weightsTexture = _this$state.weightsTexture,
232
- triPositionBuffer = _this$state.triPositionBuffer,
233
- triTexCoordBuffer = _this$state.triTexCoordBuffer,
234
- maxWeightsTexture = _this$state.maxWeightsTexture,
235
- colorTexture = _this$state.colorTexture,
236
- colorDomain = _this$state.colorDomain;
237
- var _this$props = this.props,
238
- updateTriggers = _this$props.updateTriggers,
239
- intensity = _this$props.intensity,
240
- threshold = _this$props.threshold,
241
- aggregation = _this$props.aggregation;
242
- var TriangleLayerClass = this.getSubLayerClass('triangle', _triangleLayer.default);
243
- return new TriangleLayerClass(this.getSubLayerProps({
244
- id: 'triangle-layer',
245
- updateTriggers: updateTriggers
246
- }), {
247
- coordinateSystem: _core2.COORDINATE_SYSTEM.DEFAULT,
248
- data: {
249
- attributes: {
250
- positions: triPositionBuffer,
251
- texCoords: triTexCoordBuffer
252
- }
253
- },
254
- vertexCount: 4,
255
- maxTexture: maxWeightsTexture,
256
- colorTexture: colorTexture,
257
- aggregationMode: AGGREGATION_MODE[aggregation] || 0,
258
- texture: weightsTexture,
259
- intensity: intensity,
260
- threshold: threshold,
261
- colorDomain: colorDomain
262
- });
263
- }
264
- }, {
265
- key: "finalizeState",
266
- value: function finalizeState(context) {
267
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "finalizeState", this).call(this, context);
268
- var _this$state2 = this.state,
269
- weightsTransform = _this$state2.weightsTransform,
270
- weightsTexture = _this$state2.weightsTexture,
271
- maxWeightTransform = _this$state2.maxWeightTransform,
272
- maxWeightsTexture = _this$state2.maxWeightsTexture,
273
- triPositionBuffer = _this$state2.triPositionBuffer,
274
- triTexCoordBuffer = _this$state2.triTexCoordBuffer,
275
- colorTexture = _this$state2.colorTexture,
276
- updateTimer = _this$state2.updateTimer;
277
- weightsTransform === null || weightsTransform === void 0 ? void 0 : weightsTransform.delete();
278
- weightsTexture === null || weightsTexture === void 0 ? void 0 : weightsTexture.delete();
279
- maxWeightTransform === null || maxWeightTransform === void 0 ? void 0 : maxWeightTransform.delete();
280
- maxWeightsTexture === null || maxWeightsTexture === void 0 ? void 0 : maxWeightsTexture.delete();
281
- triPositionBuffer === null || triPositionBuffer === void 0 ? void 0 : triPositionBuffer.delete();
282
- triTexCoordBuffer === null || triTexCoordBuffer === void 0 ? void 0 : triTexCoordBuffer.delete();
283
- colorTexture === null || colorTexture === void 0 ? void 0 : colorTexture.delete();
284
-
285
- if (updateTimer) {
286
- clearTimeout(updateTimer);
287
- }
204
+ if (props.colorRange !== oldProps.colorRange) {
205
+ this._updateColorTexture(opts);
288
206
  }
289
- }, {
290
- key: "_getAttributeManager",
291
- value: function _getAttributeManager() {
292
- return new _core2.AttributeManager(this.context.gl, {
293
- id: this.props.id,
294
- stats: this.context.stats
295
- });
207
+
208
+ if (this.state.isWeightMapDirty) {
209
+ this._updateWeightmap();
296
210
  }
297
- }, {
298
- key: "_getChangeFlags",
299
- value: function _getChangeFlags(opts) {
300
- var changeFlags = {};
301
- var dimensions = this.state.dimensions;
302
- changeFlags.dataChanged = this.isAttributeChanged() || this.isAggregationDirty(opts, {
303
- compareAll: true,
304
- dimension: dimensions.data
305
- });
306
- changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
307
- var zoom = this.state.zoom;
308
211
 
309
- if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
310
- changeFlags.viewportZoomChanged = true;
311
- }
212
+ this.setState({
213
+ zoom: opts.context.viewport.zoom
214
+ });
215
+ };
312
216
 
313
- return changeFlags;
217
+ _proto.renderLayers = function renderLayers() {
218
+ if (!this.state.supported) {
219
+ return [];
314
220
  }
315
- }, {
316
- key: "_createTextures",
317
- value: function _createTextures() {
318
- var gl = this.context.gl;
319
- var _this$state3 = this.state,
320
- textureSize = _this$state3.textureSize,
321
- format = _this$state3.format,
322
- type = _this$state3.type;
323
- this.setState({
324
- weightsTexture: new _core.Texture2D(gl, _objectSpread({
325
- width: textureSize,
326
- height: textureSize,
327
- format: format,
328
- type: type
329
- }, TEXTURE_OPTIONS)),
330
- maxWeightsTexture: new _core.Texture2D(gl, _objectSpread({
331
- format: format,
332
- type: type
333
- }, TEXTURE_OPTIONS))
334
- });
335
- }
336
- }, {
337
- key: "_setupAttributes",
338
- value: function _setupAttributes() {
339
- var attributeManager = this.getAttributeManager();
340
- attributeManager.add({
341
- positions: {
342
- size: 3,
343
- type: 5130,
344
- accessor: 'getPosition'
345
- },
346
- weights: {
347
- size: 1,
348
- accessor: 'getWeight'
221
+
222
+ var _this$state = this.state,
223
+ weightsTexture = _this$state.weightsTexture,
224
+ triPositionBuffer = _this$state.triPositionBuffer,
225
+ triTexCoordBuffer = _this$state.triTexCoordBuffer,
226
+ maxWeightsTexture = _this$state.maxWeightsTexture,
227
+ colorTexture = _this$state.colorTexture,
228
+ colorDomain = _this$state.colorDomain;
229
+ var _this$props = this.props,
230
+ updateTriggers = _this$props.updateTriggers,
231
+ intensity = _this$props.intensity,
232
+ threshold = _this$props.threshold,
233
+ aggregation = _this$props.aggregation;
234
+ var TriangleLayerClass = this.getSubLayerClass('triangle', _triangleLayer.default);
235
+ return new TriangleLayerClass(this.getSubLayerProps({
236
+ id: 'triangle-layer',
237
+ updateTriggers: updateTriggers
238
+ }), {
239
+ coordinateSystem: _core2.COORDINATE_SYSTEM.DEFAULT,
240
+ data: {
241
+ attributes: {
242
+ positions: triPositionBuffer,
243
+ texCoords: triTexCoordBuffer
349
244
  }
350
- });
351
- this.setState({
352
- positionAttributeName: 'positions'
353
- });
245
+ },
246
+ vertexCount: 4,
247
+ maxTexture: maxWeightsTexture,
248
+ colorTexture: colorTexture,
249
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
250
+ texture: weightsTexture,
251
+ intensity: intensity,
252
+ threshold: threshold,
253
+ colorDomain: colorDomain
254
+ });
255
+ };
256
+
257
+ _proto.finalizeState = function finalizeState(context) {
258
+ (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "finalizeState", this).call(this, context);
259
+ var _this$state2 = this.state,
260
+ weightsTransform = _this$state2.weightsTransform,
261
+ weightsTexture = _this$state2.weightsTexture,
262
+ maxWeightTransform = _this$state2.maxWeightTransform,
263
+ maxWeightsTexture = _this$state2.maxWeightsTexture,
264
+ triPositionBuffer = _this$state2.triPositionBuffer,
265
+ triTexCoordBuffer = _this$state2.triTexCoordBuffer,
266
+ colorTexture = _this$state2.colorTexture,
267
+ updateTimer = _this$state2.updateTimer;
268
+ weightsTransform === null || weightsTransform === void 0 ? void 0 : weightsTransform.delete();
269
+ weightsTexture === null || weightsTexture === void 0 ? void 0 : weightsTexture.delete();
270
+ maxWeightTransform === null || maxWeightTransform === void 0 ? void 0 : maxWeightTransform.delete();
271
+ maxWeightsTexture === null || maxWeightsTexture === void 0 ? void 0 : maxWeightsTexture.delete();
272
+ triPositionBuffer === null || triPositionBuffer === void 0 ? void 0 : triPositionBuffer.delete();
273
+ triTexCoordBuffer === null || triTexCoordBuffer === void 0 ? void 0 : triTexCoordBuffer.delete();
274
+ colorTexture === null || colorTexture === void 0 ? void 0 : colorTexture.delete();
275
+
276
+ if (updateTimer) {
277
+ clearTimeout(updateTimer);
278
+ }
279
+ };
280
+
281
+ _proto._getAttributeManager = function _getAttributeManager() {
282
+ return new _core2.AttributeManager(this.context.gl, {
283
+ id: this.props.id,
284
+ stats: this.context.stats
285
+ });
286
+ };
287
+
288
+ _proto._getChangeFlags = function _getChangeFlags(opts) {
289
+ var changeFlags = {};
290
+ var dimensions = this.state.dimensions;
291
+ changeFlags.dataChanged = this.isAttributeChanged() || this.isAggregationDirty(opts, {
292
+ compareAll: true,
293
+ dimension: dimensions.data
294
+ });
295
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
296
+ var zoom = this.state.zoom;
297
+
298
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
299
+ changeFlags.viewportZoomChanged = true;
354
300
  }
355
- }, {
356
- key: "_setupTextureParams",
357
- value: function _setupTextureParams() {
358
- var gl = this.context.gl;
359
- var weightsTextureSize = this.props.weightsTextureSize;
360
- var textureSize = Math.min(weightsTextureSize, (0, _core.getParameters)(gl, 3379));
361
- var floatTargetSupport = (0, _core.hasFeatures)(gl, FLOAT_TARGET_FEATURES);
362
-
363
- var _getTextureParams = (0, _heatmapLayerUtils.getTextureParams)({
364
- gl: gl,
365
- floatTargetSupport: floatTargetSupport
366
- }),
367
- format = _getTextureParams.format,
368
- type = _getTextureParams.type;
369
301
 
370
- var weightsScale = floatTargetSupport ? 1 : 1 / 255;
371
- this.setState({
372
- textureSize: textureSize,
302
+ return changeFlags;
303
+ };
304
+
305
+ _proto._createTextures = function _createTextures() {
306
+ var gl = this.context.gl;
307
+ var _this$state3 = this.state,
308
+ textureSize = _this$state3.textureSize,
309
+ format = _this$state3.format,
310
+ type = _this$state3.type;
311
+ this.setState({
312
+ weightsTexture: new _core.Texture2D(gl, _objectSpread({
313
+ width: textureSize,
314
+ height: textureSize,
373
315
  format: format,
374
- type: type,
375
- weightsScale: weightsScale
376
- });
377
-
378
- if (!floatTargetSupport) {
379
- _core2.log.warn("HeatmapLayer: ".concat(this.id, " rendering to float texture not supported, fallingback to low precession format"))();
316
+ type: type
317
+ }, TEXTURE_OPTIONS)),
318
+ maxWeightsTexture: new _core.Texture2D(gl, _objectSpread({
319
+ format: format,
320
+ type: type
321
+ }, TEXTURE_OPTIONS))
322
+ });
323
+ };
324
+
325
+ _proto._setupAttributes = function _setupAttributes() {
326
+ var attributeManager = this.getAttributeManager();
327
+ attributeManager.add({
328
+ positions: {
329
+ size: 3,
330
+ type: 5130,
331
+ accessor: 'getPosition'
332
+ },
333
+ weights: {
334
+ size: 1,
335
+ accessor: 'getWeight'
380
336
  }
337
+ });
338
+ this.setState({
339
+ positionAttributeName: 'positions'
340
+ });
341
+ };
342
+
343
+ _proto._setupTextureParams = function _setupTextureParams() {
344
+ var gl = this.context.gl;
345
+ var weightsTextureSize = this.props.weightsTextureSize;
346
+ var textureSize = Math.min(weightsTextureSize, (0, _core.getParameters)(gl, 3379));
347
+ var floatTargetSupport = (0, _core.hasFeatures)(gl, FLOAT_TARGET_FEATURES);
348
+
349
+ var _getTextureParams = (0, _heatmapLayerUtils.getTextureParams)({
350
+ gl: gl,
351
+ floatTargetSupport: floatTargetSupport
352
+ }),
353
+ format = _getTextureParams.format,
354
+ type = _getTextureParams.type;
355
+
356
+ var weightsScale = floatTargetSupport ? 1 : 1 / 255;
357
+ this.setState({
358
+ textureSize: textureSize,
359
+ format: format,
360
+ type: type,
361
+ weightsScale: weightsScale
362
+ });
363
+
364
+ if (!floatTargetSupport) {
365
+ _core2.log.warn("HeatmapLayer: ".concat(this.id, " rendering to float texture not supported, fallingback to low precession format"))();
381
366
  }
382
- }, {
383
- key: "getShaders",
384
- value: function getShaders(type) {
385
- return (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "getShaders", this).call(this, type === 'max-weights-transform' ? {
386
- vs: _maxVs.default,
387
- _fs: _maxFs.default
388
- } : {
389
- vs: _weightsVs.default,
390
- _fs: _weightsFs.default
391
- });
367
+ };
368
+
369
+ _proto.getShaders = 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
+ };
378
+
379
+ _proto._createWeightsTransform = function _createWeightsTransform() {
380
+ var _weightsTransform;
381
+
382
+ var shaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
383
+ var gl = this.context.gl;
384
+ var weightsTransform = this.state.weightsTransform;
385
+ var weightsTexture = this.state.weightsTexture;
386
+ (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
387
+ weightsTransform = new _core.Transform(gl, _objectSpread({
388
+ id: "".concat(this.id, "-weights-transform"),
389
+ elementCount: 1,
390
+ _targetTexture: weightsTexture,
391
+ _targetTextureVarying: 'weightsTexture'
392
+ }, shaders));
393
+ this.setState({
394
+ weightsTransform: weightsTransform
395
+ });
396
+ };
397
+
398
+ _proto._setupResources = function _setupResources() {
399
+ var gl = this.context.gl;
400
+
401
+ this._createTextures();
402
+
403
+ var _this$state4 = this.state,
404
+ textureSize = _this$state4.textureSize,
405
+ weightsTexture = _this$state4.weightsTexture,
406
+ maxWeightsTexture = _this$state4.maxWeightsTexture;
407
+ var weightsTransformShaders = this.getShaders('weights-transform');
408
+
409
+ this._createWeightsTransform(weightsTransformShaders);
410
+
411
+ var maxWeightsTransformShaders = this.getShaders('max-weights-transform');
412
+ var maxWeightTransform = new _core.Transform(gl, _objectSpread(_objectSpread({
413
+ id: "".concat(this.id, "-max-weights-transform"),
414
+ _sourceTextures: {
415
+ inTexture: weightsTexture
416
+ },
417
+ _targetTexture: maxWeightsTexture,
418
+ _targetTextureVarying: 'outTexture'
419
+ }, maxWeightsTransformShaders), {}, {
420
+ elementCount: textureSize * textureSize
421
+ }));
422
+ this.setState({
423
+ weightsTexture: weightsTexture,
424
+ maxWeightsTexture: maxWeightsTexture,
425
+ maxWeightTransform: maxWeightTransform,
426
+ zoom: null,
427
+ triPositionBuffer: new _core.Buffer(gl, {
428
+ byteLength: 48,
429
+ accessor: {
430
+ size: 3
431
+ }
432
+ }),
433
+ triTexCoordBuffer: new _core.Buffer(gl, {
434
+ byteLength: 48,
435
+ accessor: {
436
+ size: 2
437
+ }
438
+ })
439
+ });
440
+ };
441
+
442
+ _proto.updateShaders = function updateShaders(shaderOptions) {
443
+ this._createWeightsTransform(shaderOptions);
444
+ };
445
+
446
+ _proto._updateMaxWeightValue = function _updateMaxWeightValue() {
447
+ var maxWeightTransform = this.state.maxWeightTransform;
448
+ maxWeightTransform.run({
449
+ parameters: {
450
+ blend: true,
451
+ depthTest: false,
452
+ blendFunc: [1, 1],
453
+ blendEquation: 32776
454
+ }
455
+ });
456
+ };
457
+
458
+ _proto._updateBounds = function _updateBounds() {
459
+ var forceUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
460
+ var viewport = this.context.viewport;
461
+ var viewportCorners = [viewport.unproject([0, 0]), viewport.unproject([viewport.width, 0]), viewport.unproject([viewport.width, viewport.height]), viewport.unproject([0, viewport.height])].map(function (p) {
462
+ return p.map(Math.fround);
463
+ });
464
+ var visibleWorldBounds = (0, _heatmapLayerUtils.getBounds)(viewportCorners);
465
+ var newState = {
466
+ visibleWorldBounds: visibleWorldBounds,
467
+ viewportCorners: viewportCorners
468
+ };
469
+ var boundsChanged = false;
470
+
471
+ if (forceUpdate || !this.state.worldBounds || !(0, _heatmapLayerUtils.boundsContain)(this.state.worldBounds, visibleWorldBounds)) {
472
+ var scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
473
+
474
+ var worldBounds = this._commonToWorldBounds(scaledCommonBounds);
475
+
476
+ if (this.props.coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT) {
477
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
478
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
479
+ worldBounds[0] = Math.max(worldBounds[0], -360);
480
+ worldBounds[2] = Math.min(worldBounds[2], 360);
481
+ }
482
+
483
+ var normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
484
+
485
+ newState.worldBounds = worldBounds;
486
+ newState.normalizedCommonBounds = normalizedCommonBounds;
487
+ boundsChanged = true;
392
488
  }
393
- }, {
394
- key: "_createWeightsTransform",
395
- value: function _createWeightsTransform() {
396
- var _weightsTransform;
397
-
398
- var shaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
399
- var gl = this.context.gl;
400
- var weightsTransform = this.state.weightsTransform;
401
- var weightsTexture = this.state.weightsTexture;
402
- (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
403
- weightsTransform = new _core.Transform(gl, _objectSpread({
404
- id: "".concat(this.id, "-weights-transform"),
405
- elementCount: 1,
406
- _targetTexture: weightsTexture,
407
- _targetTextureVarying: 'weightsTexture'
408
- }, shaders));
409
- this.setState({
410
- weightsTransform: weightsTransform
489
+
490
+ this.setState(newState);
491
+ return boundsChanged;
492
+ };
493
+
494
+ _proto._updateTextureRenderingBounds = function _updateTextureRenderingBounds() {
495
+ var _this$state5 = this.state,
496
+ triPositionBuffer = _this$state5.triPositionBuffer,
497
+ triTexCoordBuffer = _this$state5.triTexCoordBuffer,
498
+ normalizedCommonBounds = _this$state5.normalizedCommonBounds,
499
+ viewportCorners = _this$state5.viewportCorners;
500
+ var viewport = this.context.viewport;
501
+ triPositionBuffer.subData((0, _heatmapLayerUtils.packVertices)(viewportCorners, 3));
502
+ var textureBounds = viewportCorners.map(function (p) {
503
+ return (0, _heatmapLayerUtils.getTextureCoordinates)(viewport.projectPosition(p), normalizedCommonBounds);
504
+ });
505
+ triTexCoordBuffer.subData((0, _heatmapLayerUtils.packVertices)(textureBounds, 2));
506
+ };
507
+
508
+ _proto._updateColorTexture = function _updateColorTexture(opts) {
509
+ var colorRange = opts.props.colorRange;
510
+ var colorTexture = this.state.colorTexture;
511
+ var colors = (0, _colorUtils.colorRangeToFlatArray)(colorRange, false, Uint8Array);
512
+
513
+ if (colorTexture) {
514
+ colorTexture.setImageData({
515
+ data: colors,
516
+ width: colorRange.length
411
517
  });
518
+ } else {
519
+ colorTexture = new _core.Texture2D(this.context.gl, _objectSpread({
520
+ data: colors,
521
+ width: colorRange.length,
522
+ height: 1
523
+ }, TEXTURE_OPTIONS));
412
524
  }
413
- }, {
414
- key: "_setupResources",
415
- value: function _setupResources() {
416
- var gl = this.context.gl;
417
-
418
- this._createTextures();
419
-
420
- var _this$state4 = this.state,
421
- textureSize = _this$state4.textureSize,
422
- weightsTexture = _this$state4.weightsTexture,
423
- maxWeightsTexture = _this$state4.maxWeightsTexture;
424
- var weightsTransformShaders = this.getShaders('weights-transform');
425
-
426
- this._createWeightsTransform(weightsTransformShaders);
427
-
428
- var maxWeightsTransformShaders = this.getShaders('max-weights-transform');
429
- var maxWeightTransform = new _core.Transform(gl, _objectSpread(_objectSpread({
430
- id: "".concat(this.id, "-max-weights-transform"),
431
- _sourceTextures: {
432
- inTexture: weightsTexture
433
- },
434
- _targetTexture: maxWeightsTexture,
435
- _targetTextureVarying: 'outTexture'
436
- }, maxWeightsTransformShaders), {}, {
437
- elementCount: textureSize * textureSize
438
- }));
439
- this.setState({
440
- weightsTexture: weightsTexture,
441
- maxWeightsTexture: maxWeightsTexture,
442
- maxWeightTransform: maxWeightTransform,
443
- zoom: null,
444
- triPositionBuffer: new _core.Buffer(gl, {
445
- byteLength: 48,
446
- accessor: {
447
- size: 3
448
- }
449
- }),
450
- triTexCoordBuffer: new _core.Buffer(gl, {
451
- byteLength: 48,
452
- accessor: {
453
- size: 2
454
- }
455
- })
525
+
526
+ this.setState({
527
+ colorTexture: colorTexture
528
+ });
529
+ };
530
+
531
+ _proto._updateWeightmap = function _updateWeightmap() {
532
+ var _this2 = this,
533
+ _weightsTexture$setPa;
534
+
535
+ var _this$props2 = this.props,
536
+ radiusPixels = _this$props2.radiusPixels,
537
+ colorDomain = _this$props2.colorDomain,
538
+ aggregation = _this$props2.aggregation;
539
+ var _this$state6 = this.state,
540
+ weightsTransform = _this$state6.weightsTransform,
541
+ worldBounds = _this$state6.worldBounds,
542
+ textureSize = _this$state6.textureSize,
543
+ weightsTexture = _this$state6.weightsTexture,
544
+ weightsScale = _this$state6.weightsScale;
545
+ this.state.isWeightMapDirty = false;
546
+
547
+ var commonBounds = this._worldToCommonBounds(worldBounds, {
548
+ useLayerCoordinateSystem: true
549
+ });
550
+
551
+ if (colorDomain && aggregation === 'SUM') {
552
+ var viewport = this.context.viewport;
553
+ var metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
554
+ this.state.colorDomain = colorDomain.map(function (x) {
555
+ return x * metersPerPixel * weightsScale;
456
556
  });
557
+ } else {
558
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
457
559
  }
458
- }, {
459
- key: "updateShaders",
460
- value: function updateShaders(shaderOptions) {
461
- this._createWeightsTransform(shaderOptions);
462
- }
463
- }, {
464
- key: "_updateMaxWeightValue",
465
- value: function _updateMaxWeightValue() {
466
- var maxWeightTransform = this.state.maxWeightTransform;
467
- maxWeightTransform.run({
560
+
561
+ var uniforms = {
562
+ radiusPixels: radiusPixels,
563
+ commonBounds: commonBounds,
564
+ textureWidth: textureSize,
565
+ weightsScale: weightsScale
566
+ };
567
+ weightsTransform.update({
568
+ elementCount: this.getNumInstances()
569
+ });
570
+ (0, _core.withParameters)(this.context.gl, {
571
+ clearColor: [0, 0, 0, 0]
572
+ }, function () {
573
+ weightsTransform.run({
574
+ uniforms: uniforms,
468
575
  parameters: {
469
576
  blend: true,
470
577
  depthTest: false,
471
578
  blendFunc: [1, 1],
472
- blendEquation: 32776
473
- }
474
- });
475
- }
476
- }, {
477
- key: "_updateBounds",
478
- value: function _updateBounds() {
479
- var forceUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
480
- var viewport = this.context.viewport;
481
- var viewportCorners = [viewport.unproject([0, 0]), viewport.unproject([viewport.width, 0]), viewport.unproject([viewport.width, viewport.height]), viewport.unproject([0, viewport.height])].map(function (p) {
482
- return p.map(Math.fround);
579
+ blendEquation: 32774
580
+ },
581
+ clearRenderTarget: true,
582
+ attributes: _this2.getAttributes(),
583
+ moduleSettings: _this2.getModuleSettings()
483
584
  });
484
- var visibleWorldBounds = (0, _heatmapLayerUtils.getBounds)(viewportCorners);
485
- var newState = {
486
- visibleWorldBounds: visibleWorldBounds,
487
- viewportCorners: viewportCorners
488
- };
489
- var boundsChanged = false;
490
-
491
- if (forceUpdate || !this.state.worldBounds || !(0, _heatmapLayerUtils.boundsContain)(this.state.worldBounds, visibleWorldBounds)) {
492
- var scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
493
-
494
- var worldBounds = this._commonToWorldBounds(scaledCommonBounds);
495
-
496
- if (this.props.coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT) {
497
- worldBounds[1] = Math.max(worldBounds[1], -85.051129);
498
- worldBounds[3] = Math.min(worldBounds[3], 85.051129);
499
- worldBounds[0] = Math.max(worldBounds[0], -360);
500
- worldBounds[2] = Math.min(worldBounds[2], 360);
501
- }
585
+ });
502
586
 
503
- var normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
587
+ this._updateMaxWeightValue();
504
588
 
505
- newState.worldBounds = worldBounds;
506
- newState.normalizedCommonBounds = normalizedCommonBounds;
507
- boundsChanged = true;
508
- }
589
+ weightsTexture.setParameters((_weightsTexture$setPa = {}, (0, _defineProperty2.default)(_weightsTexture$setPa, 10240, 9729), (0, _defineProperty2.default)(_weightsTexture$setPa, 10241, 9729), _weightsTexture$setPa));
590
+ };
509
591
 
510
- this.setState(newState);
511
- return boundsChanged;
512
- }
513
- }, {
514
- key: "_updateTextureRenderingBounds",
515
- value: function _updateTextureRenderingBounds() {
516
- var _this$state5 = this.state,
517
- triPositionBuffer = _this$state5.triPositionBuffer,
518
- triTexCoordBuffer = _this$state5.triTexCoordBuffer,
519
- normalizedCommonBounds = _this$state5.normalizedCommonBounds,
520
- viewportCorners = _this$state5.viewportCorners;
521
- var viewport = this.context.viewport;
522
- triPositionBuffer.subData((0, _heatmapLayerUtils.packVertices)(viewportCorners, 3));
523
- var textureBounds = viewportCorners.map(function (p) {
524
- return (0, _heatmapLayerUtils.getTextureCoordinates)(viewport.projectPosition(p), normalizedCommonBounds);
525
- });
526
- triTexCoordBuffer.subData((0, _heatmapLayerUtils.packVertices)(textureBounds, 2));
527
- }
528
- }, {
529
- key: "_updateColorTexture",
530
- value: function _updateColorTexture(opts) {
531
- var colorRange = opts.props.colorRange;
532
- var colorTexture = this.state.colorTexture;
533
- var colors = (0, _colorUtils.colorRangeToFlatArray)(colorRange, false, Uint8Array);
534
-
535
- if (colorTexture) {
536
- colorTexture.setImageData({
537
- data: colors,
538
- width: colorRange.length
539
- });
540
- } else {
541
- colorTexture = new _core.Texture2D(this.context.gl, _objectSpread({
542
- data: colors,
543
- width: colorRange.length,
544
- height: 1
545
- }, TEXTURE_OPTIONS));
546
- }
592
+ _proto._debouncedUpdateWeightmap = function _debouncedUpdateWeightmap() {
593
+ var fromTimer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
594
+ var updateTimer = this.state.updateTimer;
595
+ var debounceTimeout = this.props.debounceTimeout;
547
596
 
548
- this.setState({
549
- colorTexture: colorTexture
550
- });
551
- }
552
- }, {
553
- key: "_updateWeightmap",
554
- value: function _updateWeightmap() {
555
- var _this2 = this,
556
- _weightsTexture$setPa;
557
-
558
- var _this$props2 = this.props,
559
- radiusPixels = _this$props2.radiusPixels,
560
- colorDomain = _this$props2.colorDomain,
561
- aggregation = _this$props2.aggregation;
562
- var _this$state6 = this.state,
563
- weightsTransform = _this$state6.weightsTransform,
564
- worldBounds = _this$state6.worldBounds,
565
- textureSize = _this$state6.textureSize,
566
- weightsTexture = _this$state6.weightsTexture,
567
- weightsScale = _this$state6.weightsScale;
568
- this.state.isWeightMapDirty = false;
569
-
570
- var commonBounds = this._worldToCommonBounds(worldBounds, {
571
- useLayerCoordinateSystem: true
572
- });
597
+ if (fromTimer) {
598
+ updateTimer = null;
573
599
 
574
- if (colorDomain && aggregation === 'SUM') {
575
- var viewport = this.context.viewport;
576
- var metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
577
- this.state.colorDomain = colorDomain.map(function (x) {
578
- return x * metersPerPixel * weightsScale;
579
- });
580
- } else {
581
- this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
582
- }
600
+ this._updateBounds(true);
601
+
602
+ this._updateTextureRenderingBounds();
583
603
 
584
- var uniforms = {
585
- radiusPixels: radiusPixels,
586
- commonBounds: commonBounds,
587
- textureWidth: textureSize,
588
- weightsScale: weightsScale
589
- };
590
- weightsTransform.update({
591
- elementCount: this.getNumInstances()
604
+ this.setState({
605
+ isWeightMapDirty: true
592
606
  });
593
- (0, _core.withParameters)(this.context.gl, {
594
- clearColor: [0, 0, 0, 0]
595
- }, function () {
596
- weightsTransform.run({
597
- uniforms: uniforms,
598
- parameters: {
599
- blend: true,
600
- depthTest: false,
601
- blendFunc: [1, 1],
602
- blendEquation: 32774
603
- },
604
- clearRenderTarget: true,
605
- attributes: _this2.getAttributes(),
606
- moduleSettings: _this2.getModuleSettings()
607
- });
607
+ } else {
608
+ this.setState({
609
+ isWeightMapDirty: false
608
610
  });
609
-
610
- this._updateMaxWeightValue();
611
-
612
- weightsTexture.setParameters((_weightsTexture$setPa = {}, (0, _defineProperty2.default)(_weightsTexture$setPa, 10240, 9729), (0, _defineProperty2.default)(_weightsTexture$setPa, 10241, 9729), _weightsTexture$setPa));
611
+ clearTimeout(updateTimer);
612
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
613
613
  }
614
- }, {
615
- key: "_debouncedUpdateWeightmap",
616
- value: function _debouncedUpdateWeightmap() {
617
- var fromTimer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
618
- var updateTimer = this.state.updateTimer;
619
- var debounceTimeout = this.props.debounceTimeout;
620
-
621
- if (fromTimer) {
622
- updateTimer = null;
623
-
624
- this._updateBounds(true);
625
-
626
- this._updateTextureRenderingBounds();
627
-
628
- this.setState({
629
- isWeightMapDirty: true
630
- });
631
- } else {
632
- this.setState({
633
- isWeightMapDirty: false
634
- });
635
- clearTimeout(updateTimer);
636
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
637
- }
638
614
 
639
- this.setState({
640
- updateTimer: updateTimer
641
- });
615
+ this.setState({
616
+ updateTimer: updateTimer
617
+ });
618
+ };
619
+
620
+ _proto._worldToCommonBounds = function _worldToCommonBounds(worldBounds) {
621
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
622
+ var _opts$useLayerCoordin = opts.useLayerCoordinateSystem,
623
+ useLayerCoordinateSystem = _opts$useLayerCoordin === void 0 ? false : _opts$useLayerCoordin;
624
+
625
+ var _worldBounds = (0, _slicedToArray2.default)(worldBounds, 4),
626
+ minLong = _worldBounds[0],
627
+ minLat = _worldBounds[1],
628
+ maxLong = _worldBounds[2],
629
+ maxLat = _worldBounds[3];
630
+
631
+ var viewport = this.context.viewport;
632
+ var textureSize = this.state.textureSize;
633
+ var coordinateSystem = this.props.coordinateSystem;
634
+ var offsetMode = useLayerCoordinateSystem && (coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === _core2.COORDINATE_SYSTEM.METER_OFFSETS);
635
+ var offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
636
+ var size = textureSize * RESOLUTION / viewport.scale;
637
+ var bottomLeftCommon;
638
+ var topRightCommon;
639
+
640
+ if (useLayerCoordinateSystem && !offsetMode) {
641
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
642
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
643
+ } else {
644
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
645
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
642
646
  }
643
- }, {
644
- key: "_worldToCommonBounds",
645
- value: function _worldToCommonBounds(worldBounds) {
646
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
647
- var _opts$useLayerCoordin = opts.useLayerCoordinateSystem,
648
- useLayerCoordinateSystem = _opts$useLayerCoordin === void 0 ? false : _opts$useLayerCoordin;
649
-
650
- var _worldBounds = (0, _slicedToArray2.default)(worldBounds, 4),
651
- minLong = _worldBounds[0],
652
- minLat = _worldBounds[1],
653
- maxLong = _worldBounds[2],
654
- maxLat = _worldBounds[3];
655
647
 
656
- var viewport = this.context.viewport;
657
- var textureSize = this.state.textureSize;
658
- var coordinateSystem = this.props.coordinateSystem;
659
- var offsetMode = useLayerCoordinateSystem && (coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === _core2.COORDINATE_SYSTEM.METER_OFFSETS);
660
- var offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
661
- var size = textureSize * RESOLUTION / viewport.scale;
662
- var bottomLeftCommon;
663
- var topRightCommon;
664
-
665
- if (useLayerCoordinateSystem && !offsetMode) {
666
- bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
667
- topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
668
- } else {
669
- bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
670
- topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
671
- }
648
+ return (0, _heatmapLayerUtils.scaleToAspectRatio)([bottomLeftCommon[0] - offsetOriginCommon[0], bottomLeftCommon[1] - offsetOriginCommon[1], topRightCommon[0] - offsetOriginCommon[0], topRightCommon[1] - offsetOriginCommon[1]], size, size);
649
+ };
672
650
 
673
- return (0, _heatmapLayerUtils.scaleToAspectRatio)([bottomLeftCommon[0] - offsetOriginCommon[0], bottomLeftCommon[1] - offsetOriginCommon[1], topRightCommon[0] - offsetOriginCommon[0], topRightCommon[1] - offsetOriginCommon[1]], size, size);
674
- }
675
- }, {
676
- key: "_commonToWorldBounds",
677
- value: function _commonToWorldBounds(commonBounds) {
678
- var _commonBounds = (0, _slicedToArray2.default)(commonBounds, 4),
679
- xMin = _commonBounds[0],
680
- yMin = _commonBounds[1],
681
- xMax = _commonBounds[2],
682
- yMax = _commonBounds[3];
651
+ _proto._commonToWorldBounds = function _commonToWorldBounds(commonBounds) {
652
+ var _commonBounds = (0, _slicedToArray2.default)(commonBounds, 4),
653
+ xMin = _commonBounds[0],
654
+ yMin = _commonBounds[1],
655
+ xMax = _commonBounds[2],
656
+ yMax = _commonBounds[3];
657
+
658
+ var viewport = this.context.viewport;
659
+ var bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
660
+ var topRightWorld = viewport.unprojectPosition([xMax, yMax]);
661
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
662
+ };
683
663
 
684
- var viewport = this.context.viewport;
685
- var bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
686
- var topRightWorld = viewport.unprojectPosition([xMax, yMax]);
687
- return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
688
- }
689
- }]);
690
664
  return HeatmapLayer;
691
665
  }(_aggregationLayer.default);
692
666
 
693
667
  exports.default = HeatmapLayer;
694
- (0, _defineProperty2.default)(HeatmapLayer, "layerName", 'HeatmapLayer');
695
- (0, _defineProperty2.default)(HeatmapLayer, "defaultProps", defaultProps);
668
+ HeatmapLayer.layerName = 'HeatmapLayer';
669
+ HeatmapLayer.defaultProps = defaultProps;
696
670
  //# sourceMappingURL=heatmap-layer.js.map