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