@deck.gl/aggregation-layers 8.6.4 → 8.6.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 (61) hide show
  1. package/dist/es5/aggregation-layer.js +163 -109
  2. package/dist/es5/aggregation-layer.js.map +1 -1
  3. package/dist/es5/contour-layer/contour-layer.js +260 -240
  4. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  5. package/dist/es5/contour-layer/contour-utils.js +86 -65
  6. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  7. package/dist/es5/contour-layer/marching-squares-codes.js +106 -181
  8. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  9. package/dist/es5/contour-layer/marching-squares.js +59 -56
  10. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  11. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +121 -85
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  13. package/dist/es5/cpu-grid-layer/grid-aggregator.js +119 -93
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  15. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +167 -131
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  17. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +322 -319
  18. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  19. package/dist/es5/grid-aggregation-layer.js +230 -202
  20. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  21. package/dist/es5/grid-layer/grid-layer.js +91 -61
  22. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  23. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +59 -24
  24. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  25. package/dist/es5/heatmap-layer/heatmap-layer.js +533 -515
  26. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  27. package/dist/es5/heatmap-layer/triangle-layer.js +91 -64
  28. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  29. package/dist/es5/hexagon-layer/hexagon-aggregator.js +77 -59
  30. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-layer.js +164 -121
  32. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  33. package/dist/es5/index.js +12 -12
  34. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +193 -168
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  36. package/dist/es5/screen-grid-layer/screen-grid-layer.js +250 -235
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  38. package/dist/es5/utils/aggregation-operation-utils.js +31 -16
  39. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  40. package/dist/es5/utils/bin-sorter.js +198 -118
  41. package/dist/es5/utils/bin-sorter.js.map +1 -1
  42. package/dist/es5/utils/color-utils.js +10 -8
  43. package/dist/es5/utils/color-utils.js.map +1 -1
  44. package/dist/es5/utils/cpu-aggregator.js +342 -323
  45. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  46. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +18 -20
  47. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  48. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  50. package/dist/es5/utils/grid-aggregation-utils.js +44 -50
  51. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  52. package/dist/es5/utils/prop-utils.js +2 -2
  53. package/dist/es5/utils/prop-utils.js.map +1 -1
  54. package/dist/es5/utils/resource-utils.js +39 -32
  55. package/dist/es5/utils/resource-utils.js.map +1 -1
  56. package/dist/es5/utils/scale-utils.js +66 -36
  57. package/dist/es5/utils/scale-utils.js.map +1 -1
  58. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  59. package/dist/esm/utils/cpu-aggregator.js.map +1 -1
  60. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  61. package/package.json +2 -2
@@ -7,6 +7,12 @@ 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
+
10
16
  var _core = require("@luma.gl/core");
11
17
 
12
18
  var _shadertools = require("@luma.gl/shadertools");
@@ -29,75 +35,91 @@ var _transformMeanVs = _interopRequireDefault(require("./transform-mean-vs.glsl"
29
35
 
30
36
  var _resourceUtils = require("./../resource-utils.js");
31
37
 
32
- const BUFFER_NAMES = ['aggregationBuffer', 'maxMinBuffer', 'minBuffer', 'maxBuffer'];
33
- const ARRAY_BUFFER_MAP = {
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 = {
34
50
  maxData: 'maxBuffer',
35
51
  minData: 'minBuffer',
36
52
  maxMinData: 'maxMinBuffer'
37
53
  };
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
- }
55
-
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];
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];
63
71
  }
64
72
 
65
- if (minData) {
66
- results.minCellWeight = minData[0];
67
- results.totalCount = maxData[3];
68
- }
69
- }
70
-
71
- return results;
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
+ }
73
81
 
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];
82
+ if (minData) {
83
+ results.minCellWeight = minData[0];
84
+ results.totalCount = maxData[3];
85
+ }
85
86
  }
86
87
 
87
- cellCounts[i] = countsData[i * 4 + 3];
88
+ return results;
88
89
  }
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
+ }
89
104
 
90
- return {
91
- cellCounts,
92
- cellWeights
93
- };
94
- }
105
+ cellCounts[i] = countsData[i * 4 + 3];
106
+ }
95
107
 
96
- static isSupported(gl) {
97
- return (0, _core.hasFeatures)(gl, REQUIRED_FEATURES);
98
- }
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);
117
+ }
118
+ }]);
99
119
 
100
- constructor(gl, opts = {}) {
120
+ function GPUGridAggregator(gl) {
121
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
122
+ (0, _classCallCheck2.default)(this, GPUGridAggregator);
101
123
  this.id = opts.id || 'gpu-grid-aggregator';
102
124
  this.gl = gl;
103
125
  this.state = {
@@ -120,564 +142,544 @@ class GPUGridAggregator {
120
142
  }
121
143
  }
122
144
 
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')();
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]);
153
163
  }
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
+ });
154
171
 
155
- return this._runAggregation(aggregationParams);
156
- }
172
+ var aggregationParams = this._normalizeAggregationParams(opts);
157
173
 
158
- getData(weightId) {
159
- const data = {};
160
- const results = this.state.results;
174
+ if (!this._hasGPUSupport) {
175
+ _core2.log.log(1, 'GPUGridAggregator: not supported')();
176
+ }
161
177
 
162
- if (!results[weightId].aggregationData) {
163
- results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
178
+ return this._runAggregation(aggregationParams);
164
179
  }
165
-
166
- data.aggregationData = results[weightId].aggregationData;
167
-
168
- for (const arrayName in ARRAY_BUFFER_MAP) {
169
- const bufferName = ARRAY_BUFFER_MAP[arrayName];
170
-
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];
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();
174
188
  }
175
- }
176
189
 
177
- return data;
178
- }
190
+ data.aggregationData = results[weightId].aggregationData;
179
191
 
180
- updateShaders(shaderOptions = {}) {
181
- this.setState({
182
- shaderOptions,
183
- modelDirty: true
184
- });
185
- }
192
+ for (var arrayName in ARRAY_BUFFER_MAP) {
193
+ var bufferName = ARRAY_BUFFER_MAP[arrayName];
186
194
 
187
- _normalizeAggregationParams(opts) {
188
- const aggregationParams = { ..._gpuGridAggregatorConstants.DEFAULT_RUN_PARAMS,
189
- ...opts
190
- };
191
- const {
192
- weights
193
- } = aggregationParams;
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
+ }
199
+ }
194
200
 
195
- if (weights) {
196
- aggregationParams.weights = normalizeWeightParams(weights);
201
+ return data;
197
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
+ }
212
+ }, {
213
+ key: "_normalizeAggregationParams",
214
+ value: function _normalizeAggregationParams(opts) {
215
+ var aggregationParams = _objectSpread(_objectSpread({}, _gpuGridAggregatorConstants.DEFAULT_RUN_PARAMS), opts);
198
216
 
199
- return aggregationParams;
200
- }
201
-
202
- setState(updateObject) {
203
- Object.assign(this.state, updateObject);
204
- }
217
+ var weights = aggregationParams.weights;
205
218
 
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
- });
219
+ if (weights) {
220
+ aggregationParams.weights = normalizeWeightParams(weights);
221
+ }
232
222
 
233
- if (needMin && needMax && combineMaxMin) {
234
- results[id].maxMinBuffer = (0, _core.readPixelsToBuffer)(maxMinFramebuffers[id], {
235
- target: weights[id].maxMinBuffer,
223
+ return aggregationParams;
224
+ }
225
+ }, {
226
+ key: "setState",
227
+ value: function setState(updateObject) {
228
+ Object.assign(this.state, updateObject);
229
+ }
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,
236
252
  sourceType: 5126
237
253
  });
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,
243
- sourceType: 5126
244
- });
245
- results[id].minTexture = resources["".concat(id, "-minTexture")];
246
- }
247
254
 
248
- if (needMax) {
249
- results[id].maxBuffer = (0, _core.readPixelsToBuffer)(maxFramebuffers[id], {
250
- target: weights[id].maxBuffer,
255
+ if (needMin && needMax && combineMaxMin) {
256
+ results[id].maxMinBuffer = (0, _core.readPixelsToBuffer)(maxMinFramebuffers[id], {
257
+ target: weights[id].maxMinBuffer,
251
258
  sourceType: 5126
252
259
  });
253
- results[id].maxTexture = resources["".concat(id, "-maxTexture")];
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
+ }
269
+
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
+ }
254
277
  }
255
278
  }
256
- }
257
279
 
258
- this._trackGPUResultBuffers(results, weights);
280
+ this._trackGPUResultBuffers(results, weights);
259
281
 
260
- return results;
261
- }
262
-
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
- };
293
-
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
- });
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
+ };
310
313
 
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
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
323
328
  });
324
- } else {
325
- if (needMin) {
326
- this._renderToMaxMinTexture({
327
- id,
328
- parameters: { ...parameters,
329
- blendEquation: _gpuGridAggregatorConstants.MIN_BLEND_EQUATION
330
- },
331
- gridSize,
332
- minOrMaxFb: minFramebuffers[id],
333
- clearParams: {
334
- clearColor: [_gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT, 0]
335
- },
336
- combineMaxMin
337
- });
338
- }
339
329
 
340
- if (needMax) {
330
+ if (combineMaxMin) {
341
331
  this._renderToMaxMinTexture({
342
- id,
343
- parameters: { ...parameters,
344
- blendEquation: _gpuGridAggregatorConstants.MAX_BLEND_EQUATION
345
- },
346
- gridSize,
347
- minOrMaxFb: maxFramebuffers[id],
332
+ id: id,
333
+ parameters: _objectSpread(_objectSpread({}, parameters), {}, {
334
+ blendEquation: _gpuGridAggregatorConstants.MAX_MIN_BLEND_EQUATION
335
+ }),
336
+ gridSize: gridSize,
337
+ minOrMaxFb: maxMinFramebuffers[id],
348
338
  clearParams: {
349
- clearColor: [0, 0, 0, 0]
339
+ clearColor: [0, 0, 0, _gpuGridAggregatorConstants.MAX_32_BIT_FLOAT]
350
340
  },
351
- combineMaxMin
341
+ combineMaxMin: combineMaxMin
352
342
  });
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
+ }
358
+
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
+ }
353
373
  }
354
374
  }
355
375
  }
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
- }
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
+ });
386
402
  });
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
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
+ });
428
438
  });
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
- };
443
439
 
444
- if (this.meanTransform) {
445
- this.meanTransform.update(transformOptions);
446
- } else {
447
- this.meanTransform = getMeanTransform(gl, transformOptions);
448
- }
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
+ };
449
451
 
450
- this.meanTransform.run({
451
- parameters: {
452
- blend: false,
453
- depthTest: false
452
+ if (this.meanTransform) {
453
+ this.meanTransform.update(transformOptions);
454
+ } else {
455
+ this.meanTransform = getMeanTransform(gl, transformOptions);
454
456
  }
455
- });
456
- framebuffers[id].attach({
457
- [36064]: textures[id]
458
- });
459
- }
460
- }
461
-
462
- _runAggregation(opts) {
463
- this._updateModels(opts);
464
-
465
- this._setupFramebuffers(opts);
466
457
 
467
- this._renderAggregateData(opts);
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
+ }
466
+ }
467
+ }, {
468
+ key: "_runAggregation",
469
+ value: function _runAggregation(opts) {
470
+ this._updateModels(opts);
468
471
 
469
- const results = this._getAggregateData(opts);
472
+ this._setupFramebuffers(opts);
470
473
 
471
- this.setState({
472
- results
473
- });
474
- return results;
475
- }
474
+ this._renderAggregateData(opts);
476
475
 
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
- };
476
+ var results = this._getAggregateData(opts);
498
477
 
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"),
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 = {
508
498
  width: numCol,
509
499
  height: numRow
510
- });
511
- textures[id].resize(framebufferSize);
512
- let texture = textures[id];
500
+ };
513
501
 
514
- if (operation === _aggregationOperationUtils.AGGREGATION_OPERATION.MEAN) {
515
- meanTextures[id] = meanTextures[id] || (0, _resourceUtils.getFloatTexture)(this.gl, {
516
- id: "".concat(id, "-mean-texture"),
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"),
517
510
  width: numCol,
518
511
  height: numRow
519
512
  });
520
- meanTextures[id].resize(framebufferSize);
521
- texture = meanTextures[id];
522
- }
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
+ }
523
525
 
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
- }
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
+ }
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
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
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
556
547
  });
557
548
  }
558
- }
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
+ }
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
566
- });
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
+ }
567
568
  }
568
569
  }
569
570
  }
570
571
  }
571
572
  }
572
- }
573
-
574
- _getMinMaxTexture(name) {
575
- const {
576
- resources
577
- } = this.state;
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
+ }
578
583
 
579
- if (!resources[name]) {
580
- resources[name] = (0, _resourceUtils.getFloatTexture)(this.gl, {
581
- id: "resourceName"
582
- });
584
+ return resources[name];
583
585
  }
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);
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
+ }
606
606
  }
607
- }
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
+ }
616
+ }
617
+ }, {
618
+ key: "_trackGPUResultBuffers",
619
+ value: function _trackGPUResultBuffers(results, weights) {
620
+ var resources = this.state.resources;
608
621
 
609
- _setupWeightAttributes(opts) {
610
- const {
611
- weightAttributes
612
- } = this.state;
613
- const {
614
- weights
615
- } = opts;
622
+ for (var id in results) {
623
+ if (results[id]) {
624
+ var _iterator = _createForOfIteratorHelper(BUFFER_NAMES),
625
+ _step;
616
626
 
617
- for (const id in weights) {
618
- weightAttributes[id] = opts.attributes[id];
619
- }
620
- }
627
+ try {
628
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
629
+ var bufferName = _step.value;
621
630
 
622
- _trackGPUResultBuffers(results, weights) {
623
- const {
624
- resources
625
- } = this.state;
631
+ if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
632
+ var name = "gpu-result-".concat(id, "-").concat(bufferName);
626
633
 
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);
634
+ if (resources[name]) {
635
+ resources[name].delete();
636
+ }
632
637
 
633
- if (resources[name]) {
634
- resources[name].delete();
638
+ resources[name] = results[id][bufferName];
639
+ }
635
640
  }
636
-
637
- resources[name] = results[id][bufferName];
641
+ } catch (err) {
642
+ _iterator.e(err);
643
+ } finally {
644
+ _iterator.f();
638
645
  }
639
646
  }
640
647
  }
641
648
  }
642
- }
643
-
644
- _updateModels(opts) {
645
- const {
646
- vertexCount,
647
- attributes,
648
- numCol,
649
- numRow
650
- } = opts;
651
- const {
652
- modelDirty
653
- } = this.state;
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
+ }
654
665
 
655
- if (modelDirty) {
656
- this._setupModels(opts);
666
+ this._setupWeightAttributes(opts);
657
667
 
658
- this.setState({
659
- modelDirty: false
660
- });
668
+ this.gridAggregationModel.setVertexCount(vertexCount);
669
+ this.gridAggregationModel.setAttributes(attributes);
670
+ this.allAggregationModel.setInstanceCount(numCol * numRow);
661
671
  }
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
- }
672
+ }]);
673
+ return GPUGridAggregator;
674
+ }();
671
675
 
672
676
  exports.default = GPUGridAggregator;
673
677
 
674
678
  function normalizeWeightParams(weights) {
675
- const result = {};
679
+ var result = {};
676
680
 
677
- for (const id in weights) {
678
- result[id] = { ..._gpuGridAggregatorConstants.DEFAULT_WEIGHT_PARAMS,
679
- ...weights[id]
680
- };
681
+ for (var id in weights) {
682
+ result[id] = _objectSpread(_objectSpread({}, _gpuGridAggregatorConstants.DEFAULT_WEIGHT_PARAMS), weights[id]);
681
683
  }
682
684
 
683
685
  return result;
@@ -685,25 +687,24 @@ function normalizeWeightParams(weights) {
685
687
 
686
688
  function deleteResources(resources) {
687
689
  resources = Array.isArray(resources) ? resources : [resources];
688
- resources.forEach(obj => {
689
- for (const name in obj) {
690
+ resources.forEach(function (obj) {
691
+ for (var name in obj) {
690
692
  obj[name].delete();
691
693
  }
692
694
  });
693
695
  }
694
696
 
695
697
  function getAggregationModel(gl, shaderOptions) {
696
- const shaders = (0, _core2._mergeShaders)({
698
+ var shaders = (0, _core2._mergeShaders)({
697
699
  vs: _aggregateToGridVs.default,
698
700
  fs: _aggregateToGridFs.default,
699
701
  modules: [_shadertools.fp64arithmetic, _core2.project32]
700
702
  }, shaderOptions);
701
- return new _core.Model(gl, {
703
+ return new _core.Model(gl, _objectSpread({
702
704
  id: 'Gird-Aggregation-Model',
703
705
  vertexCount: 1,
704
- drawMode: 0,
705
- ...shaders
706
- });
706
+ drawMode: 0
707
+ }, shaders));
707
708
  }
708
709
 
709
710
  function getAllAggregationModel(gl, instanceCount) {
@@ -715,7 +716,7 @@ function getAllAggregationModel(gl, instanceCount) {
715
716
  vertexCount: 1,
716
717
  drawMode: 0,
717
718
  isInstanced: true,
718
- instanceCount,
719
+ instanceCount: instanceCount,
719
720
  attributes: {
720
721
  position: [0, 0]
721
722
  }
@@ -723,10 +724,9 @@ function getAllAggregationModel(gl, instanceCount) {
723
724
  }
724
725
 
725
726
  function getMeanTransform(gl, opts) {
726
- return new _core.Transform(gl, {
727
+ return new _core.Transform(gl, _objectSpread({
727
728
  vs: _transformMeanVs.default,
728
- _targetTextureVarying: 'meanValues',
729
- ...opts
730
- });
729
+ _targetTextureVarying: 'meanValues'
730
+ }, opts));
731
731
  }
732
732
  //# sourceMappingURL=gpu-grid-aggregator.js.map