@deck.gl/aggregation-layers 8.6.0-beta.1 → 8.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/dist.dev.js +243 -243
  2. package/dist/es5/aggregation-layer.js +109 -163
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +240 -260
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +65 -86
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js +181 -106
  9. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  10. package/dist/es5/contour-layer/marching-squares.js +56 -59
  11. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +85 -121
  13. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js +93 -119
  15. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -167
  17. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  18. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +319 -322
  19. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  20. package/dist/es5/grid-aggregation-layer.js +202 -230
  21. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  22. package/dist/es5/grid-layer/grid-layer.js +61 -91
  23. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  24. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +24 -59
  25. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  26. package/dist/es5/heatmap-layer/heatmap-layer.js +515 -533
  27. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  28. package/dist/es5/heatmap-layer/triangle-layer.js +64 -91
  29. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  30. package/dist/es5/hexagon-layer/hexagon-aggregator.js +59 -77
  31. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  32. package/dist/es5/hexagon-layer/hexagon-layer.js +121 -164
  33. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  34. package/dist/es5/index.js +12 -12
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +168 -193
  36. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js +235 -250
  38. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  39. package/dist/es5/utils/aggregation-operation-utils.js +16 -31
  40. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  41. package/dist/es5/utils/bin-sorter.js +118 -198
  42. package/dist/es5/utils/bin-sorter.js.map +1 -1
  43. package/dist/es5/utils/color-utils.js +8 -10
  44. package/dist/es5/utils/color-utils.js.map +1 -1
  45. package/dist/es5/utils/cpu-aggregator.js +323 -342
  46. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  47. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +20 -18
  48. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
  50. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  51. package/dist/es5/utils/grid-aggregation-utils.js +50 -44
  52. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  53. package/dist/es5/utils/prop-utils.js +2 -2
  54. package/dist/es5/utils/prop-utils.js.map +1 -1
  55. package/dist/es5/utils/resource-utils.js +32 -39
  56. package/dist/es5/utils/resource-utils.js.map +1 -1
  57. package/dist/es5/utils/scale-utils.js +36 -66
  58. package/dist/es5/utils/scale-utils.js.map +1 -1
  59. package/package.json +2 -2
@@ -7,12 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
10
  var _core = require("@luma.gl/core");
17
11
 
18
12
  var _shadertools = require("@luma.gl/shadertools");
@@ -35,91 +29,75 @@ var _transformMeanVs = _interopRequireDefault(require("./transform-mean-vs.glsl"
35
29
 
36
30
  var _resourceUtils = require("./../resource-utils.js");
37
31
 
38
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
39
-
40
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
41
-
42
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
43
-
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
-
48
- var BUFFER_NAMES = ['aggregationBuffer', 'maxMinBuffer', 'minBuffer', 'maxBuffer'];
49
- var ARRAY_BUFFER_MAP = {
32
+ const BUFFER_NAMES = ['aggregationBuffer', 'maxMinBuffer', 'minBuffer', 'maxBuffer'];
33
+ const ARRAY_BUFFER_MAP = {
50
34
  maxData: 'maxBuffer',
51
35
  minData: 'minBuffer',
52
36
  maxMinData: 'maxMinBuffer'
53
37
  };
54
- var REQUIRED_FEATURES = [_core.FEATURES.WEBGL2, _core.FEATURES.COLOR_ATTACHMENT_RGBA32F, _core.FEATURES.BLEND_EQUATION_MINMAX, _core.FEATURES.FLOAT_BLEND, _core.FEATURES.TEXTURE_FLOAT];
55
-
56
- var GPUGridAggregator = function () {
57
- (0, _createClass2.default)(GPUGridAggregator, null, [{
58
- key: "getAggregationData",
59
- value: function getAggregationData(_ref) {
60
- var aggregationData = _ref.aggregationData,
61
- maxData = _ref.maxData,
62
- minData = _ref.minData,
63
- maxMinData = _ref.maxMinData,
64
- pixelIndex = _ref.pixelIndex;
65
- var index = pixelIndex * _gpuGridAggregatorConstants.PIXEL_SIZE;
66
- var results = {};
67
-
68
- if (aggregationData) {
69
- results.cellCount = aggregationData[index + 3];
70
- results.cellWeight = aggregationData[index];
71
- }
72
-
73
- if (maxMinData) {
74
- results.maxCellWieght = maxMinData[0];
75
- results.minCellWeight = maxMinData[3];
76
- } else {
77
- if (maxData) {
78
- results.maxCellWieght = maxData[0];
79
- results.totalCount = maxData[3];
80
- }
38
+ const REQUIRED_FEATURES = [_core.FEATURES.WEBGL2, _core.FEATURES.COLOR_ATTACHMENT_RGBA32F, _core.FEATURES.BLEND_EQUATION_MINMAX, _core.FEATURES.FLOAT_BLEND, _core.FEATURES.TEXTURE_FLOAT];
39
+
40
+ class GPUGridAggregator {
41
+ static getAggregationData({
42
+ aggregationData,
43
+ maxData,
44
+ minData,
45
+ maxMinData,
46
+ pixelIndex
47
+ }) {
48
+ const index = pixelIndex * _gpuGridAggregatorConstants.PIXEL_SIZE;
49
+ const results = {};
50
+
51
+ if (aggregationData) {
52
+ results.cellCount = aggregationData[index + 3];
53
+ results.cellWeight = aggregationData[index];
54
+ }
81
55
 
82
- if (minData) {
83
- results.minCellWeight = minData[0];
84
- results.totalCount = maxData[3];
85
- }
56
+ if (maxMinData) {
57
+ results.maxCellWieght = maxMinData[0];
58
+ results.minCellWeight = maxMinData[3];
59
+ } else {
60
+ if (maxData) {
61
+ results.maxCellWieght = maxData[0];
62
+ results.totalCount = maxData[3];
86
63
  }
87
64
 
88
- return results;
65
+ if (minData) {
66
+ results.minCellWeight = minData[0];
67
+ results.totalCount = maxData[3];
68
+ }
89
69
  }
90
- }, {
91
- key: "getCellData",
92
- value: function getCellData(_ref2) {
93
- var countsData = _ref2.countsData,
94
- _ref2$size = _ref2.size,
95
- size = _ref2$size === void 0 ? 1 : _ref2$size;
96
- var numCells = countsData.length / 4;
97
- var cellWeights = new Float32Array(numCells * size);
98
- var cellCounts = new Uint32Array(numCells);
99
-
100
- for (var i = 0; i < numCells; i++) {
101
- for (var sizeIndex = 0; sizeIndex < size; sizeIndex++) {
102
- cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
103
- }
104
70
 
105
- cellCounts[i] = countsData[i * 4 + 3];
71
+ return results;
72
+ }
73
+
74
+ static getCellData({
75
+ countsData,
76
+ size = 1
77
+ }) {
78
+ const numCells = countsData.length / 4;
79
+ const cellWeights = new Float32Array(numCells * size);
80
+ const cellCounts = new Uint32Array(numCells);
81
+
82
+ for (let i = 0; i < numCells; i++) {
83
+ for (let sizeIndex = 0; sizeIndex < size; sizeIndex++) {
84
+ cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
106
85
  }
107
86
 
108
- return {
109
- cellCounts: cellCounts,
110
- cellWeights: cellWeights
111
- };
112
- }
113
- }, {
114
- key: "isSupported",
115
- value: function isSupported(gl) {
116
- return (0, _core.hasFeatures)(gl, REQUIRED_FEATURES);
87
+ cellCounts[i] = countsData[i * 4 + 3];
117
88
  }
118
- }]);
119
89
 
120
- function GPUGridAggregator(gl) {
121
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
122
- (0, _classCallCheck2.default)(this, GPUGridAggregator);
90
+ return {
91
+ cellCounts,
92
+ cellWeights
93
+ };
94
+ }
95
+
96
+ static isSupported(gl) {
97
+ return (0, _core.hasFeatures)(gl, REQUIRED_FEATURES);
98
+ }
99
+
100
+ constructor(gl, opts = {}) {
123
101
  this.id = opts.id || 'gpu-grid-aggregator';
124
102
  this.gl = gl;
125
103
  this.state = {
@@ -142,544 +120,564 @@ var GPUGridAggregator = function () {
142
120
  }
143
121
  }
144
122
 
145
- (0, _createClass2.default)(GPUGridAggregator, [{
146
- key: "delete",
147
- value: function _delete() {
148
- var gridAggregationModel = this.gridAggregationModel,
149
- allAggregationModel = this.allAggregationModel,
150
- meanTransform = this.meanTransform;
151
- var _this$state = this.state,
152
- textures = _this$state.textures,
153
- framebuffers = _this$state.framebuffers,
154
- maxMinFramebuffers = _this$state.maxMinFramebuffers,
155
- minFramebuffers = _this$state.minFramebuffers,
156
- maxFramebuffers = _this$state.maxFramebuffers,
157
- meanTextures = _this$state.meanTextures,
158
- resources = _this$state.resources;
159
- gridAggregationModel === null || gridAggregationModel === void 0 ? void 0 : gridAggregationModel.delete();
160
- allAggregationModel === null || allAggregationModel === void 0 ? void 0 : allAggregationModel.delete();
161
- meanTransform === null || meanTransform === void 0 ? void 0 : meanTransform.delete();
162
- deleteResources([framebuffers, textures, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, resources]);
123
+ delete() {
124
+ const {
125
+ gridAggregationModel,
126
+ allAggregationModel,
127
+ meanTransform
128
+ } = this;
129
+ const {
130
+ textures,
131
+ framebuffers,
132
+ maxMinFramebuffers,
133
+ minFramebuffers,
134
+ maxFramebuffers,
135
+ meanTextures,
136
+ resources
137
+ } = this.state;
138
+ gridAggregationModel === null || gridAggregationModel === void 0 ? void 0 : gridAggregationModel.delete();
139
+ allAggregationModel === null || allAggregationModel === void 0 ? void 0 : allAggregationModel.delete();
140
+ meanTransform === null || meanTransform === void 0 ? void 0 : meanTransform.delete();
141
+ deleteResources([framebuffers, textures, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, resources]);
142
+ }
143
+
144
+ run(opts = {}) {
145
+ this.setState({
146
+ results: {}
147
+ });
148
+
149
+ const aggregationParams = this._normalizeAggregationParams(opts);
150
+
151
+ if (!this._hasGPUSupport) {
152
+ _core2.log.log(1, 'GPUGridAggregator: not supported')();
163
153
  }
164
- }, {
165
- key: "run",
166
- value: function run() {
167
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
168
- this.setState({
169
- results: {}
170
- });
171
154
 
172
- var aggregationParams = this._normalizeAggregationParams(opts);
155
+ return this._runAggregation(aggregationParams);
156
+ }
173
157
 
174
- if (!this._hasGPUSupport) {
175
- _core2.log.log(1, 'GPUGridAggregator: not supported')();
176
- }
158
+ getData(weightId) {
159
+ const data = {};
160
+ const results = this.state.results;
177
161
 
178
- return this._runAggregation(aggregationParams);
162
+ if (!results[weightId].aggregationData) {
163
+ results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
179
164
  }
180
- }, {
181
- key: "getData",
182
- value: function getData(weightId) {
183
- var data = {};
184
- var results = this.state.results;
185
-
186
- if (!results[weightId].aggregationData) {
187
- results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
188
- }
189
165
 
190
- data.aggregationData = results[weightId].aggregationData;
166
+ data.aggregationData = results[weightId].aggregationData;
191
167
 
192
- for (var arrayName in ARRAY_BUFFER_MAP) {
193
- var bufferName = ARRAY_BUFFER_MAP[arrayName];
168
+ for (const arrayName in ARRAY_BUFFER_MAP) {
169
+ const bufferName = ARRAY_BUFFER_MAP[arrayName];
194
170
 
195
- if (results[weightId][arrayName] || results[weightId][bufferName]) {
196
- results[weightId][arrayName] = results[weightId][arrayName] || results[weightId][bufferName].getData();
197
- data[arrayName] = results[weightId][arrayName];
198
- }
171
+ if (results[weightId][arrayName] || results[weightId][bufferName]) {
172
+ results[weightId][arrayName] = results[weightId][arrayName] || results[weightId][bufferName].getData();
173
+ data[arrayName] = results[weightId][arrayName];
199
174
  }
200
-
201
- return data;
202
- }
203
- }, {
204
- key: "updateShaders",
205
- value: function updateShaders() {
206
- var shaderOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
207
- this.setState({
208
- shaderOptions: shaderOptions,
209
- modelDirty: true
210
- });
211
175
  }
212
- }, {
213
- key: "_normalizeAggregationParams",
214
- value: function _normalizeAggregationParams(opts) {
215
- var aggregationParams = _objectSpread(_objectSpread({}, _gpuGridAggregatorConstants.DEFAULT_RUN_PARAMS), opts);
216
176
 
217
- var weights = aggregationParams.weights;
177
+ return data;
178
+ }
218
179
 
219
- if (weights) {
220
- aggregationParams.weights = normalizeWeightParams(weights);
221
- }
180
+ updateShaders(shaderOptions = {}) {
181
+ this.setState({
182
+ shaderOptions,
183
+ modelDirty: true
184
+ });
185
+ }
222
186
 
223
- return aggregationParams;
224
- }
225
- }, {
226
- key: "setState",
227
- value: function setState(updateObject) {
228
- Object.assign(this.state, updateObject);
187
+ _normalizeAggregationParams(opts) {
188
+ const aggregationParams = { ..._gpuGridAggregatorConstants.DEFAULT_RUN_PARAMS,
189
+ ...opts
190
+ };
191
+ const {
192
+ weights
193
+ } = aggregationParams;
194
+
195
+ if (weights) {
196
+ aggregationParams.weights = normalizeWeightParams(weights);
229
197
  }
230
- }, {
231
- key: "_getAggregateData",
232
- value: function _getAggregateData(opts) {
233
- var results = {};
234
- var _this$state2 = this.state,
235
- textures = _this$state2.textures,
236
- framebuffers = _this$state2.framebuffers,
237
- maxMinFramebuffers = _this$state2.maxMinFramebuffers,
238
- minFramebuffers = _this$state2.minFramebuffers,
239
- maxFramebuffers = _this$state2.maxFramebuffers,
240
- resources = _this$state2.resources;
241
- var weights = opts.weights;
242
-
243
- for (var id in weights) {
244
- results[id] = {};
245
- var _weights$id = weights[id],
246
- needMin = _weights$id.needMin,
247
- needMax = _weights$id.needMax,
248
- combineMaxMin = _weights$id.combineMaxMin;
249
- results[id].aggregationTexture = textures[id];
250
- results[id].aggregationBuffer = (0, _core.readPixelsToBuffer)(framebuffers[id], {
251
- target: weights[id].aggregationBuffer,
198
+
199
+ return aggregationParams;
200
+ }
201
+
202
+ setState(updateObject) {
203
+ Object.assign(this.state, updateObject);
204
+ }
205
+
206
+ _getAggregateData(opts) {
207
+ const results = {};
208
+ const {
209
+ textures,
210
+ framebuffers,
211
+ maxMinFramebuffers,
212
+ minFramebuffers,
213
+ maxFramebuffers,
214
+ resources
215
+ } = this.state;
216
+ const {
217
+ weights
218
+ } = opts;
219
+
220
+ for (const id in weights) {
221
+ results[id] = {};
222
+ const {
223
+ needMin,
224
+ needMax,
225
+ combineMaxMin
226
+ } = weights[id];
227
+ results[id].aggregationTexture = textures[id];
228
+ results[id].aggregationBuffer = (0, _core.readPixelsToBuffer)(framebuffers[id], {
229
+ target: weights[id].aggregationBuffer,
230
+ sourceType: 5126
231
+ });
232
+
233
+ if (needMin && needMax && combineMaxMin) {
234
+ results[id].maxMinBuffer = (0, _core.readPixelsToBuffer)(maxMinFramebuffers[id], {
235
+ target: weights[id].maxMinBuffer,
252
236
  sourceType: 5126
253
237
  });
254
-
255
- if (needMin && needMax && combineMaxMin) {
256
- results[id].maxMinBuffer = (0, _core.readPixelsToBuffer)(maxMinFramebuffers[id], {
257
- target: weights[id].maxMinBuffer,
238
+ results[id].maxMinTexture = resources["".concat(id, "-maxMinTexture")];
239
+ } else {
240
+ if (needMin) {
241
+ results[id].minBuffer = (0, _core.readPixelsToBuffer)(minFramebuffers[id], {
242
+ target: weights[id].minBuffer,
258
243
  sourceType: 5126
259
244
  });
260
- results[id].maxMinTexture = resources["".concat(id, "-maxMinTexture")];
261
- } else {
262
- if (needMin) {
263
- results[id].minBuffer = (0, _core.readPixelsToBuffer)(minFramebuffers[id], {
264
- target: weights[id].minBuffer,
265
- sourceType: 5126
266
- });
267
- results[id].minTexture = resources["".concat(id, "-minTexture")];
268
- }
245
+ results[id].minTexture = resources["".concat(id, "-minTexture")];
246
+ }
269
247
 
270
- if (needMax) {
271
- results[id].maxBuffer = (0, _core.readPixelsToBuffer)(maxFramebuffers[id], {
272
- target: weights[id].maxBuffer,
273
- sourceType: 5126
274
- });
275
- results[id].maxTexture = resources["".concat(id, "-maxTexture")];
276
- }
248
+ if (needMax) {
249
+ results[id].maxBuffer = (0, _core.readPixelsToBuffer)(maxFramebuffers[id], {
250
+ target: weights[id].maxBuffer,
251
+ sourceType: 5126
252
+ });
253
+ results[id].maxTexture = resources["".concat(id, "-maxTexture")];
277
254
  }
278
255
  }
256
+ }
279
257
 
280
- this._trackGPUResultBuffers(results, weights);
258
+ this._trackGPUResultBuffers(results, weights);
281
259
 
282
- return results;
283
- }
284
- }, {
285
- key: "_renderAggregateData",
286
- value: function _renderAggregateData(opts) {
287
- var cellSize = opts.cellSize,
288
- projectPoints = opts.projectPoints,
289
- attributes = opts.attributes,
290
- moduleSettings = opts.moduleSettings,
291
- numCol = opts.numCol,
292
- numRow = opts.numRow,
293
- weights = opts.weights,
294
- translation = opts.translation,
295
- scaling = opts.scaling;
296
- var _this$state3 = this.state,
297
- maxMinFramebuffers = _this$state3.maxMinFramebuffers,
298
- minFramebuffers = _this$state3.minFramebuffers,
299
- maxFramebuffers = _this$state3.maxFramebuffers;
300
- var gridSize = [numCol, numRow];
301
- var parameters = {
302
- blend: true,
303
- depthTest: false,
304
- blendFunc: [1, 1]
305
- };
306
- var uniforms = {
307
- cellSize: cellSize,
308
- gridSize: gridSize,
309
- projectPoints: projectPoints,
310
- translation: translation,
311
- scaling: scaling
312
- };
260
+ return results;
261
+ }
313
262
 
314
- for (var id in weights) {
315
- var _weights$id2 = weights[id],
316
- needMin = _weights$id2.needMin,
317
- needMax = _weights$id2.needMax;
318
- var combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
319
-
320
- this._renderToWeightsTexture({
321
- id: id,
322
- parameters: parameters,
323
- moduleSettings: moduleSettings,
324
- uniforms: uniforms,
325
- gridSize: gridSize,
326
- attributes: attributes,
327
- weights: weights
328
- });
263
+ _renderAggregateData(opts) {
264
+ const {
265
+ cellSize,
266
+ projectPoints,
267
+ attributes,
268
+ moduleSettings,
269
+ numCol,
270
+ numRow,
271
+ weights,
272
+ translation,
273
+ scaling
274
+ } = opts;
275
+ const {
276
+ maxMinFramebuffers,
277
+ minFramebuffers,
278
+ maxFramebuffers
279
+ } = this.state;
280
+ const gridSize = [numCol, numRow];
281
+ const parameters = {
282
+ blend: true,
283
+ depthTest: false,
284
+ blendFunc: [1, 1]
285
+ };
286
+ const uniforms = {
287
+ cellSize,
288
+ gridSize,
289
+ projectPoints,
290
+ translation,
291
+ scaling
292
+ };
329
293
 
330
- if (combineMaxMin) {
294
+ for (const id in weights) {
295
+ const {
296
+ needMin,
297
+ needMax
298
+ } = weights[id];
299
+ const combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
300
+
301
+ this._renderToWeightsTexture({
302
+ id,
303
+ parameters,
304
+ moduleSettings,
305
+ uniforms,
306
+ gridSize,
307
+ attributes,
308
+ weights
309
+ });
310
+
311
+ if (combineMaxMin) {
312
+ this._renderToMaxMinTexture({
313
+ id,
314
+ parameters: { ...parameters,
315
+ blendEquation: _gpuGridAggregatorConstants.MAX_MIN_BLEND_EQUATION
316
+ },
317
+ gridSize,
318
+ minOrMaxFb: maxMinFramebuffers[id],
319
+ clearParams: {
320
+ clearColor: [0, 0, 0, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT]
321
+ },
322
+ combineMaxMin
323
+ });
324
+ } else {
325
+ if (needMin) {
331
326
  this._renderToMaxMinTexture({
332
- id: id,
333
- parameters: _objectSpread(_objectSpread({}, parameters), {}, {
334
- blendEquation: _gpuGridAggregatorConstants.MAX_MIN_BLEND_EQUATION
335
- }),
336
- gridSize: gridSize,
337
- minOrMaxFb: maxMinFramebuffers[id],
327
+ id,
328
+ parameters: { ...parameters,
329
+ blendEquation: _gpuGridAggregatorConstants.MIN_BLEND_EQUATION
330
+ },
331
+ gridSize,
332
+ minOrMaxFb: minFramebuffers[id],
338
333
  clearParams: {
339
- clearColor: [0, 0, 0, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT]
334
+ clearColor: [_gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, 0]
340
335
  },
341
- combineMaxMin: combineMaxMin
336
+ combineMaxMin
342
337
  });
343
- } else {
344
- if (needMin) {
345
- this._renderToMaxMinTexture({
346
- id: id,
347
- parameters: _objectSpread(_objectSpread({}, parameters), {}, {
348
- blendEquation: _gpuGridAggregatorConstants.MIN_BLEND_EQUATION
349
- }),
350
- gridSize: gridSize,
351
- minOrMaxFb: minFramebuffers[id],
352
- clearParams: {
353
- clearColor: [_gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, 0]
354
- },
355
- combineMaxMin: combineMaxMin
356
- });
357
- }
338
+ }
358
339
 
359
- if (needMax) {
360
- this._renderToMaxMinTexture({
361
- id: id,
362
- parameters: _objectSpread(_objectSpread({}, parameters), {}, {
363
- blendEquation: _gpuGridAggregatorConstants.MAX_BLEND_EQUATION
364
- }),
365
- gridSize: gridSize,
366
- minOrMaxFb: maxFramebuffers[id],
367
- clearParams: {
368
- clearColor: [0, 0, 0, 0]
369
- },
370
- combineMaxMin: combineMaxMin
371
- });
372
- }
340
+ if (needMax) {
341
+ this._renderToMaxMinTexture({
342
+ id,
343
+ parameters: { ...parameters,
344
+ blendEquation: _gpuGridAggregatorConstants.MAX_BLEND_EQUATION
345
+ },
346
+ gridSize,
347
+ minOrMaxFb: maxFramebuffers[id],
348
+ clearParams: {
349
+ clearColor: [0, 0, 0, 0]
350
+ },
351
+ combineMaxMin
352
+ });
373
353
  }
374
354
  }
375
355
  }
376
- }, {
377
- key: "_renderToMaxMinTexture",
378
- value: function _renderToMaxMinTexture(opts) {
379
- var id = opts.id,
380
- parameters = opts.parameters,
381
- gridSize = opts.gridSize,
382
- minOrMaxFb = opts.minOrMaxFb,
383
- combineMaxMin = opts.combineMaxMin,
384
- _opts$clearParams = opts.clearParams,
385
- clearParams = _opts$clearParams === void 0 ? {} : _opts$clearParams;
386
- var framebuffers = this.state.framebuffers;
387
- var gl = this.gl,
388
- allAggregationModel = this.allAggregationModel;
389
- (0, _core.withParameters)(gl, _objectSpread(_objectSpread({}, clearParams), {}, {
390
- framebuffer: minOrMaxFb,
391
- viewport: [0, 0, gridSize[0], gridSize[1]]
392
- }), function () {
393
- gl.clear(16384);
394
- allAggregationModel.draw({
395
- parameters: parameters,
396
- uniforms: {
397
- uSampler: framebuffers[id].texture,
398
- gridSize: gridSize,
399
- combineMaxMin: combineMaxMin
400
- }
401
- });
356
+ }
357
+
358
+ _renderToMaxMinTexture(opts) {
359
+ const {
360
+ id,
361
+ parameters,
362
+ gridSize,
363
+ minOrMaxFb,
364
+ combineMaxMin,
365
+ clearParams = {}
366
+ } = opts;
367
+ const {
368
+ framebuffers
369
+ } = this.state;
370
+ const {
371
+ gl,
372
+ allAggregationModel
373
+ } = this;
374
+ (0, _core.withParameters)(gl, { ...clearParams,
375
+ framebuffer: minOrMaxFb,
376
+ viewport: [0, 0, gridSize[0], gridSize[1]]
377
+ }, () => {
378
+ gl.clear(16384);
379
+ allAggregationModel.draw({
380
+ parameters,
381
+ uniforms: {
382
+ uSampler: framebuffers[id].texture,
383
+ gridSize,
384
+ combineMaxMin
385
+ }
402
386
  });
403
- }
404
- }, {
405
- key: "_renderToWeightsTexture",
406
- value: function _renderToWeightsTexture(opts) {
407
- var id = opts.id,
408
- parameters = opts.parameters,
409
- moduleSettings = opts.moduleSettings,
410
- uniforms = opts.uniforms,
411
- gridSize = opts.gridSize,
412
- weights = opts.weights;
413
- var _this$state4 = this.state,
414
- framebuffers = _this$state4.framebuffers,
415
- equations = _this$state4.equations,
416
- weightAttributes = _this$state4.weightAttributes;
417
- var gl = this.gl,
418
- gridAggregationModel = this.gridAggregationModel;
419
- var operation = weights[id].operation;
420
- var clearColor = operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MIN ? [_gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, 0] : [0, 0, 0, 0];
421
- (0, _core.withParameters)(gl, {
422
- framebuffer: framebuffers[id],
423
- viewport: [0, 0, gridSize[0], gridSize[1]],
424
- clearColor: clearColor
425
- }, function () {
426
- gl.clear(16384);
427
- var attributes = {
428
- weights: weightAttributes[id]
429
- };
430
- gridAggregationModel.draw({
431
- parameters: _objectSpread(_objectSpread({}, parameters), {}, {
432
- blendEquation: equations[id]
433
- }),
434
- moduleSettings: moduleSettings,
435
- uniforms: uniforms,
436
- attributes: attributes
437
- });
387
+ });
388
+ }
389
+
390
+ _renderToWeightsTexture(opts) {
391
+ const {
392
+ id,
393
+ parameters,
394
+ moduleSettings,
395
+ uniforms,
396
+ gridSize,
397
+ weights
398
+ } = opts;
399
+ const {
400
+ framebuffers,
401
+ equations,
402
+ weightAttributes
403
+ } = this.state;
404
+ const {
405
+ gl,
406
+ gridAggregationModel
407
+ } = this;
408
+ const {
409
+ operation
410
+ } = weights[id];
411
+ const clearColor = operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MIN ? [_gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, 0] : [0, 0, 0, 0];
412
+ (0, _core.withParameters)(gl, {
413
+ framebuffer: framebuffers[id],
414
+ viewport: [0, 0, gridSize[0], gridSize[1]],
415
+ clearColor
416
+ }, () => {
417
+ gl.clear(16384);
418
+ const attributes = {
419
+ weights: weightAttributes[id]
420
+ };
421
+ gridAggregationModel.draw({
422
+ parameters: { ...parameters,
423
+ blendEquation: equations[id]
424
+ },
425
+ moduleSettings,
426
+ uniforms,
427
+ attributes
438
428
  });
429
+ });
430
+
431
+ if (operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MEAN) {
432
+ const {
433
+ meanTextures,
434
+ textures
435
+ } = this.state;
436
+ const transformOptions = {
437
+ _sourceTextures: {
438
+ aggregationValues: meanTextures[id]
439
+ },
440
+ _targetTexture: textures[id],
441
+ elementCount: textures[id].width * textures[id].height
442
+ };
439
443
 
440
- if (operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MEAN) {
441
- var _this$state5 = this.state,
442
- meanTextures = _this$state5.meanTextures,
443
- textures = _this$state5.textures;
444
- var transformOptions = {
445
- _sourceTextures: {
446
- aggregationValues: meanTextures[id]
447
- },
448
- _targetTexture: textures[id],
449
- elementCount: textures[id].width * textures[id].height
450
- };
444
+ if (this.meanTransform) {
445
+ this.meanTransform.update(transformOptions);
446
+ } else {
447
+ this.meanTransform = getMeanTransform(gl, transformOptions);
448
+ }
451
449
 
452
- if (this.meanTransform) {
453
- this.meanTransform.update(transformOptions);
454
- } else {
455
- this.meanTransform = getMeanTransform(gl, transformOptions);
450
+ this.meanTransform.run({
451
+ parameters: {
452
+ blend: false,
453
+ depthTest: false
456
454
  }
457
-
458
- this.meanTransform.run({
459
- parameters: {
460
- blend: false,
461
- depthTest: false
462
- }
463
- });
464
- framebuffers[id].attach((0, _defineProperty2.default)({}, 36064, textures[id]));
465
- }
455
+ });
456
+ framebuffers[id].attach({
457
+ [36064]: textures[id]
458
+ });
466
459
  }
467
- }, {
468
- key: "_runAggregation",
469
- value: function _runAggregation(opts) {
470
- this._updateModels(opts);
460
+ }
471
461
 
472
- this._setupFramebuffers(opts);
462
+ _runAggregation(opts) {
463
+ this._updateModels(opts);
473
464
 
474
- this._renderAggregateData(opts);
465
+ this._setupFramebuffers(opts);
475
466
 
476
- var results = this._getAggregateData(opts);
467
+ this._renderAggregateData(opts);
477
468
 
478
- this.setState({
479
- results: results
480
- });
481
- return results;
482
- }
483
- }, {
484
- key: "_setupFramebuffers",
485
- value: function _setupFramebuffers(opts) {
486
- var _this$state6 = this.state,
487
- textures = _this$state6.textures,
488
- framebuffers = _this$state6.framebuffers,
489
- maxMinFramebuffers = _this$state6.maxMinFramebuffers,
490
- minFramebuffers = _this$state6.minFramebuffers,
491
- maxFramebuffers = _this$state6.maxFramebuffers,
492
- meanTextures = _this$state6.meanTextures,
493
- equations = _this$state6.equations;
494
- var weights = opts.weights;
495
- var numCol = opts.numCol,
496
- numRow = opts.numRow;
497
- var framebufferSize = {
469
+ const results = this._getAggregateData(opts);
470
+
471
+ this.setState({
472
+ results
473
+ });
474
+ return results;
475
+ }
476
+
477
+ _setupFramebuffers(opts) {
478
+ const {
479
+ textures,
480
+ framebuffers,
481
+ maxMinFramebuffers,
482
+ minFramebuffers,
483
+ maxFramebuffers,
484
+ meanTextures,
485
+ equations
486
+ } = this.state;
487
+ const {
488
+ weights
489
+ } = opts;
490
+ const {
491
+ numCol,
492
+ numRow
493
+ } = opts;
494
+ const framebufferSize = {
495
+ width: numCol,
496
+ height: numRow
497
+ };
498
+
499
+ for (const id in weights) {
500
+ const {
501
+ needMin,
502
+ needMax,
503
+ combineMaxMin,
504
+ operation
505
+ } = weights[id];
506
+ textures[id] = weights[id].aggregationTexture || textures[id] || (0, _resourceUtils.getFloatTexture)(this.gl, {
507
+ id: "".concat(id, "-texture"),
498
508
  width: numCol,
499
509
  height: numRow
500
- };
510
+ });
511
+ textures[id].resize(framebufferSize);
512
+ let texture = textures[id];
501
513
 
502
- for (var id in weights) {
503
- var _weights$id3 = weights[id],
504
- needMin = _weights$id3.needMin,
505
- needMax = _weights$id3.needMax,
506
- combineMaxMin = _weights$id3.combineMaxMin,
507
- operation = _weights$id3.operation;
508
- textures[id] = weights[id].aggregationTexture || textures[id] || (0, _resourceUtils.getFloatTexture)(this.gl, {
509
- id: "".concat(id, "-texture"),
514
+ if (operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MEAN) {
515
+ meanTextures[id] = meanTextures[id] || (0, _resourceUtils.getFloatTexture)(this.gl, {
516
+ id: "".concat(id, "-mean-texture"),
510
517
  width: numCol,
511
518
  height: numRow
512
519
  });
513
- textures[id].resize(framebufferSize);
514
- var texture = textures[id];
515
-
516
- if (operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MEAN) {
517
- meanTextures[id] = meanTextures[id] || (0, _resourceUtils.getFloatTexture)(this.gl, {
518
- id: "".concat(id, "-mean-texture"),
519
- width: numCol,
520
- height: numRow
521
- });
522
- meanTextures[id].resize(framebufferSize);
523
- texture = meanTextures[id];
524
- }
520
+ meanTextures[id].resize(framebufferSize);
521
+ texture = meanTextures[id];
522
+ }
525
523
 
526
- if (framebuffers[id]) {
527
- framebuffers[id].attach((0, _defineProperty2.default)({}, 36064, texture));
528
- } else {
529
- framebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
530
- id: "".concat(id, "-fb"),
531
- width: numCol,
532
- height: numRow,
533
- texture: texture
534
- });
535
- }
524
+ if (framebuffers[id]) {
525
+ framebuffers[id].attach({
526
+ [36064]: texture
527
+ });
528
+ } else {
529
+ framebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
530
+ id: "".concat(id, "-fb"),
531
+ width: numCol,
532
+ height: numRow,
533
+ texture
534
+ });
535
+ }
536
536
 
537
- framebuffers[id].resize(framebufferSize);
538
- equations[id] = _gpuGridAggregatorConstants.EQUATION_MAP[operation] || _gpuGridAggregatorConstants.EQUATION_MAP.SUM;
537
+ framebuffers[id].resize(framebufferSize);
538
+ equations[id] = _gpuGridAggregatorConstants.EQUATION_MAP[operation] || _gpuGridAggregatorConstants.EQUATION_MAP.SUM;
539
539
 
540
- if (needMin || needMax) {
541
- if (needMin && needMax && combineMaxMin) {
542
- if (!maxMinFramebuffers[id]) {
543
- texture = weights[id].maxMinTexture || this._getMinMaxTexture("".concat(id, "-maxMinTexture"));
544
- maxMinFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
545
- id: "".concat(id, "-maxMinFb"),
546
- texture: texture
540
+ if (needMin || needMax) {
541
+ if (needMin && needMax && combineMaxMin) {
542
+ if (!maxMinFramebuffers[id]) {
543
+ texture = weights[id].maxMinTexture || this._getMinMaxTexture("".concat(id, "-maxMinTexture"));
544
+ maxMinFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
545
+ id: "".concat(id, "-maxMinFb"),
546
+ texture
547
+ });
548
+ }
549
+ } else {
550
+ if (needMin) {
551
+ if (!minFramebuffers[id]) {
552
+ texture = weights[id].minTexture || this._getMinMaxTexture("".concat(id, "-minTexture"));
553
+ minFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
554
+ id: "".concat(id, "-minFb"),
555
+ texture
547
556
  });
548
557
  }
549
- } else {
550
- if (needMin) {
551
- if (!minFramebuffers[id]) {
552
- texture = weights[id].minTexture || this._getMinMaxTexture("".concat(id, "-minTexture"));
553
- minFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
554
- id: "".concat(id, "-minFb"),
555
- texture: texture
556
- });
557
- }
558
- }
558
+ }
559
559
 
560
- if (needMax) {
561
- if (!maxFramebuffers[id]) {
562
- texture = weights[id].maxTexture || this._getMinMaxTexture("".concat(id, "-maxTexture"));
563
- maxFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
564
- id: "".concat(id, "-maxFb"),
565
- texture: texture
566
- });
567
- }
560
+ if (needMax) {
561
+ if (!maxFramebuffers[id]) {
562
+ texture = weights[id].maxTexture || this._getMinMaxTexture("".concat(id, "-maxTexture"));
563
+ maxFramebuffers[id] = (0, _resourceUtils.getFramebuffer)(this.gl, {
564
+ id: "".concat(id, "-maxFb"),
565
+ texture
566
+ });
568
567
  }
569
568
  }
570
569
  }
571
570
  }
572
571
  }
573
- }, {
574
- key: "_getMinMaxTexture",
575
- value: function _getMinMaxTexture(name) {
576
- var resources = this.state.resources;
577
-
578
- if (!resources[name]) {
579
- resources[name] = (0, _resourceUtils.getFloatTexture)(this.gl, {
580
- id: "resourceName"
581
- });
582
- }
572
+ }
583
573
 
584
- return resources[name];
585
- }
586
- }, {
587
- key: "_setupModels",
588
- value: function _setupModels() {
589
- var _this$gridAggregation;
590
-
591
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
592
- _ref3$numCol = _ref3.numCol,
593
- numCol = _ref3$numCol === void 0 ? 0 : _ref3$numCol,
594
- _ref3$numRow = _ref3.numRow,
595
- numRow = _ref3$numRow === void 0 ? 0 : _ref3$numRow;
596
-
597
- var gl = this.gl;
598
- var shaderOptions = this.state.shaderOptions;
599
- (_this$gridAggregation = this.gridAggregationModel) === null || _this$gridAggregation === void 0 ? void 0 : _this$gridAggregation.delete();
600
- this.gridAggregationModel = getAggregationModel(gl, shaderOptions);
601
-
602
- if (!this.allAggregationModel) {
603
- var instanceCount = numCol * numRow;
604
- this.allAggregationModel = getAllAggregationModel(gl, instanceCount);
605
- }
574
+ _getMinMaxTexture(name) {
575
+ const {
576
+ resources
577
+ } = this.state;
578
+
579
+ if (!resources[name]) {
580
+ resources[name] = (0, _resourceUtils.getFloatTexture)(this.gl, {
581
+ id: "resourceName"
582
+ });
606
583
  }
607
- }, {
608
- key: "_setupWeightAttributes",
609
- value: function _setupWeightAttributes(opts) {
610
- var weightAttributes = this.state.weightAttributes;
611
- var weights = opts.weights;
612
-
613
- for (var id in weights) {
614
- weightAttributes[id] = opts.attributes[id];
615
- }
584
+
585
+ return resources[name];
586
+ }
587
+
588
+ _setupModels({
589
+ numCol = 0,
590
+ numRow = 0
591
+ } = {}) {
592
+ var _this$gridAggregation;
593
+
594
+ const {
595
+ gl
596
+ } = this;
597
+ const {
598
+ shaderOptions
599
+ } = this.state;
600
+ (_this$gridAggregation = this.gridAggregationModel) === null || _this$gridAggregation === void 0 ? void 0 : _this$gridAggregation.delete();
601
+ this.gridAggregationModel = getAggregationModel(gl, shaderOptions);
602
+
603
+ if (!this.allAggregationModel) {
604
+ const instanceCount = numCol * numRow;
605
+ this.allAggregationModel = getAllAggregationModel(gl, instanceCount);
616
606
  }
617
- }, {
618
- key: "_trackGPUResultBuffers",
619
- value: function _trackGPUResultBuffers(results, weights) {
620
- var resources = this.state.resources;
607
+ }
621
608
 
622
- for (var id in results) {
623
- if (results[id]) {
624
- var _iterator = _createForOfIteratorHelper(BUFFER_NAMES),
625
- _step;
609
+ _setupWeightAttributes(opts) {
610
+ const {
611
+ weightAttributes
612
+ } = this.state;
613
+ const {
614
+ weights
615
+ } = opts;
626
616
 
627
- try {
628
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
629
- var bufferName = _step.value;
617
+ for (const id in weights) {
618
+ weightAttributes[id] = opts.attributes[id];
619
+ }
620
+ }
630
621
 
631
- if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
632
- var name = "gpu-result-".concat(id, "-").concat(bufferName);
622
+ _trackGPUResultBuffers(results, weights) {
623
+ const {
624
+ resources
625
+ } = this.state;
633
626
 
634
- if (resources[name]) {
635
- resources[name].delete();
636
- }
627
+ for (const id in results) {
628
+ if (results[id]) {
629
+ for (const bufferName of BUFFER_NAMES) {
630
+ if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
631
+ const name = "gpu-result-".concat(id, "-").concat(bufferName);
637
632
 
638
- resources[name] = results[id][bufferName];
639
- }
633
+ if (resources[name]) {
634
+ resources[name].delete();
640
635
  }
641
- } catch (err) {
642
- _iterator.e(err);
643
- } finally {
644
- _iterator.f();
636
+
637
+ resources[name] = results[id][bufferName];
645
638
  }
646
639
  }
647
640
  }
648
641
  }
649
- }, {
650
- key: "_updateModels",
651
- value: function _updateModels(opts) {
652
- var vertexCount = opts.vertexCount,
653
- attributes = opts.attributes,
654
- numCol = opts.numCol,
655
- numRow = opts.numRow;
656
- var modelDirty = this.state.modelDirty;
657
-
658
- if (modelDirty) {
659
- this._setupModels(opts);
660
-
661
- this.setState({
662
- modelDirty: false
663
- });
664
- }
642
+ }
665
643
 
666
- this._setupWeightAttributes(opts);
644
+ _updateModels(opts) {
645
+ const {
646
+ vertexCount,
647
+ attributes,
648
+ numCol,
649
+ numRow
650
+ } = opts;
651
+ const {
652
+ modelDirty
653
+ } = this.state;
667
654
 
668
- this.gridAggregationModel.setVertexCount(vertexCount);
669
- this.gridAggregationModel.setAttributes(attributes);
670
- this.allAggregationModel.setInstanceCount(numCol * numRow);
655
+ if (modelDirty) {
656
+ this._setupModels(opts);
657
+
658
+ this.setState({
659
+ modelDirty: false
660
+ });
671
661
  }
672
- }]);
673
- return GPUGridAggregator;
674
- }();
662
+
663
+ this._setupWeightAttributes(opts);
664
+
665
+ this.gridAggregationModel.setVertexCount(vertexCount);
666
+ this.gridAggregationModel.setAttributes(attributes);
667
+ this.allAggregationModel.setInstanceCount(numCol * numRow);
668
+ }
669
+
670
+ }
675
671
 
676
672
  exports.default = GPUGridAggregator;
677
673
 
678
674
  function normalizeWeightParams(weights) {
679
- var result = {};
675
+ const result = {};
680
676
 
681
- for (var id in weights) {
682
- result[id] = _objectSpread(_objectSpread({}, _gpuGridAggregatorConstants.DEFAULT_WEIGHT_PARAMS), weights[id]);
677
+ for (const id in weights) {
678
+ result[id] = { ..._gpuGridAggregatorConstants.DEFAULT_WEIGHT_PARAMS,
679
+ ...weights[id]
680
+ };
683
681
  }
684
682
 
685
683
  return result;
@@ -687,24 +685,25 @@ function normalizeWeightParams(weights) {
687
685
 
688
686
  function deleteResources(resources) {
689
687
  resources = Array.isArray(resources) ? resources : [resources];
690
- resources.forEach(function (obj) {
691
- for (var name in obj) {
688
+ resources.forEach(obj => {
689
+ for (const name in obj) {
692
690
  obj[name].delete();
693
691
  }
694
692
  });
695
693
  }
696
694
 
697
695
  function getAggregationModel(gl, shaderOptions) {
698
- var shaders = (0, _core2._mergeShaders)({
696
+ const shaders = (0, _core2._mergeShaders)({
699
697
  vs: _aggregateToGridVs.default,
700
698
  fs: _aggregateToGridFs.default,
701
699
  modules: [_shadertools.fp64arithmetic, _core2.project32]
702
700
  }, shaderOptions);
703
- return new _core.Model(gl, _objectSpread({
701
+ return new _core.Model(gl, {
704
702
  id: 'Gird-Aggregation-Model',
705
703
  vertexCount: 1,
706
- drawMode: 0
707
- }, shaders));
704
+ drawMode: 0,
705
+ ...shaders
706
+ });
708
707
  }
709
708
 
710
709
  function getAllAggregationModel(gl, instanceCount) {
@@ -716,7 +715,7 @@ function getAllAggregationModel(gl, instanceCount) {
716
715
  vertexCount: 1,
717
716
  drawMode: 0,
718
717
  isInstanced: true,
719
- instanceCount: instanceCount,
718
+ instanceCount,
720
719
  attributes: {
721
720
  position: [0, 0]
722
721
  }
@@ -724,9 +723,10 @@ function getAllAggregationModel(gl, instanceCount) {
724
723
  }
725
724
 
726
725
  function getMeanTransform(gl, opts) {
727
- return new _core.Transform(gl, _objectSpread({
726
+ return new _core.Transform(gl, {
728
727
  vs: _transformMeanVs.default,
729
- _targetTextureVarying: 'meanValues'
730
- }, opts));
728
+ _targetTextureVarying: 'meanValues',
729
+ ...opts
730
+ });
731
731
  }
732
732
  //# sourceMappingURL=gpu-grid-aggregator.js.map