@deck.gl/aggregation-layers 8.8.0-alpha.5 → 8.8.0-beta.2
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 +753 -640
- package/dist/es5/aggregation-layer.js +19 -7
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +5 -5
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-utils.js +1 -1
- package/dist/es5/contour-layer/contour-utils.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +5 -3
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.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 +8 -12
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +12 -12
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +25 -12
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +18 -9
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +5 -2
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +19 -7
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +7 -7
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +16 -5
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +26 -19
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +18 -8
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/utils/bin-sorter.js +9 -0
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/es5/utils/color-utils.js.map +1 -1
- package/dist/esm/aggregation-layer.js +12 -5
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +6 -3
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-utils.js +1 -1
- package/dist/esm/contour-layer/contour-utils.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.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/gpu-grid-layer/gpu-grid-cell-layer.js +8 -10
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-aggregation-layer.js +13 -5
- package/dist/esm/grid-aggregation-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +15 -8
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +5 -2
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +24 -14
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/bin-sorter.js +16 -0
- package/dist/esm/utils/bin-sorter.js.map +1 -1
- package/dist/esm/utils/color-utils.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +7 -5
- package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
- package/src/contour-layer/{contour-layer.js → contour-layer.ts} +97 -16
- package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
- package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
- package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
- package/src/cpu-grid-layer/cpu-grid-layer.ts +324 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +36 -19
- package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +125 -18
- package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
- package/src/grid-layer/{grid-layer.js → grid-layer.ts} +45 -14
- package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +15 -10
- package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +147 -32
- package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
- package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
- package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +194 -9
- package/src/index.ts +9 -0
- package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +33 -15
- package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +119 -16
- package/src/types.ts +10 -0
- package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
- package/src/utils/{color-utils.js → color-utils.ts} +1 -1
- package/typed/aggregation-layer.d.ts +38 -0
- package/typed/aggregation-layer.d.ts.map +1 -0
- package/typed/aggregation-layer.js +151 -0
- package/typed/contour-layer/contour-layer.d.ts +74 -0
- package/typed/contour-layer/contour-layer.d.ts.map +1 -0
- package/typed/contour-layer/contour-layer.js +234 -0
- package/typed/contour-layer/contour-utils.d.ts +18 -0
- package/typed/contour-layer/contour-utils.d.ts.map +1 -0
- package/typed/contour-layer/contour-utils.js +64 -0
- package/typed/contour-layer/marching-squares-codes.d.ts +32 -0
- package/typed/contour-layer/marching-squares-codes.d.ts.map +1 -0
- package/typed/contour-layer/marching-squares-codes.js +337 -0
- package/typed/contour-layer/marching-squares.d.ts +10 -0
- package/typed/contour-layer/marching-squares.d.ts.map +1 -0
- package/typed/contour-layer/marching-squares.js +147 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +152 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.js +129 -0
- package/typed/cpu-grid-layer/grid-aggregator.d.ts +23 -0
- package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -0
- package/typed/cpu-grid-layer/grid-aggregator.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +3 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +3 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +34 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +143 -0
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +96 -0
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
- package/typed/gpu-grid-layer/gpu-grid-layer.js +289 -0
- package/typed/grid-aggregation-layer.d.ts +32 -0
- package/typed/grid-aggregation-layer.d.ts.map +1 -0
- package/typed/grid-aggregation-layer.js +172 -0
- package/typed/grid-layer/grid-layer.d.ts +31 -0
- package/typed/grid-layer/grid-layer.d.ts.map +1 -0
- package/typed/grid-layer/grid-layer.js +60 -0
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +13 -0
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
- package/typed/heatmap-layer/heatmap-layer-utils.js +78 -0
- package/typed/heatmap-layer/heatmap-layer.d.ts +116 -0
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -0
- package/typed/heatmap-layer/heatmap-layer.js +478 -0
- package/typed/heatmap-layer/max-fs.glsl.d.ts +3 -0
- package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/max-fs.glsl.js +7 -0
- package/typed/heatmap-layer/max-vs.glsl.d.ts +3 -0
- package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/max-vs.glsl.js +12 -0
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +58 -0
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +3 -0
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +51 -0
- package/typed/heatmap-layer/triangle-layer.d.ts +27 -0
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -0
- package/typed/heatmap-layer/triangle-layer.js +67 -0
- package/typed/heatmap-layer/weights-fs.glsl.d.ts +3 -0
- package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/weights-fs.glsl.js +19 -0
- package/typed/heatmap-layer/weights-vs.glsl.d.ts +3 -0
- package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -0
- package/typed/heatmap-layer/weights-vs.glsl.js +23 -0
- package/typed/hexagon-layer/hexagon-aggregator.d.ts +24 -0
- package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -0
- package/typed/hexagon-layer/hexagon-aggregator.js +112 -0
- package/typed/hexagon-layer/hexagon-layer.d.ts +165 -0
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -0
- package/typed/hexagon-layer/hexagon-layer.js +171 -0
- package/typed/index.d.ts +20 -0
- package/typed/index.d.ts.map +1 -0
- package/typed/index.js +33 -0
- package/typed/package.json +6 -0
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +42 -0
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
- package/typed/screen-grid-layer/screen-grid-cell-layer.js +159 -0
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +3 -0
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -0
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +37 -0
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +3 -0
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -0
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +83 -0
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +95 -0
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
- package/typed/screen-grid-layer/screen-grid-layer.js +216 -0
- package/typed/types.d.ts +11 -0
- package/typed/types.d.ts.map +1 -0
- package/typed/types.js +1 -0
- package/typed/utils/aggregation-operation-utils.d.ts +13 -0
- package/typed/utils/aggregation-operation-utils.d.ts.map +1 -0
- package/typed/utils/aggregation-operation-utils.js +94 -0
- package/typed/utils/bin-sorter.d.ts +52 -0
- package/typed/utils/bin-sorter.d.ts.map +1 -0
- package/typed/utils/bin-sorter.js +167 -0
- package/typed/utils/color-utils.d.ts +3 -0
- package/typed/utils/color-utils.d.ts.map +1 -0
- package/typed/utils/color-utils.js +53 -0
- package/typed/utils/cpu-aggregator.d.ts +155 -0
- package/typed/utils/cpu-aggregator.d.ts.map +1 -0
- package/typed/utils/cpu-aggregator.js +417 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +3 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +3 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +3 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +31 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +3 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +77 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +36 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +66 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +562 -0
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +3 -0
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -0
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +36 -0
- package/typed/utils/grid-aggregation-utils.d.ts +24 -0
- package/typed/utils/grid-aggregation-utils.d.ts.map +1 -0
- package/typed/utils/grid-aggregation-utils.js +114 -0
- package/typed/utils/prop-utils.d.ts +2 -0
- package/typed/utils/prop-utils.d.ts.map +1 -0
- package/typed/utils/prop-utils.js +28 -0
- package/typed/utils/resource-utils.d.ts +4 -0
- package/typed/utils/resource-utils.d.ts.map +1 -0
- package/typed/utils/resource-utils.js +40 -0
- package/typed/utils/scale-utils.d.ts +15 -0
- package/typed/utils/scale-utils.d.ts.map +1 -0
- package/typed/utils/scale-utils.js +184 -0
- package/src/cpu-grid-layer/cpu-grid-layer.js +0 -153
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2018 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import GL from '@luma.gl/constants';
|
|
21
|
+
import { Model, Transform, FEATURES, hasFeatures, isWebGL2, readPixelsToBuffer, withParameters } from '@luma.gl/core';
|
|
22
|
+
import { fp64arithmetic } from '@luma.gl/shadertools';
|
|
23
|
+
import { log, project32, _mergeShaders as mergeShaders } from '@deck.gl/core';
|
|
24
|
+
import { DEFAULT_RUN_PARAMS, MAX_32_BIT_FLOAT, MIN_BLEND_EQUATION, MAX_BLEND_EQUATION, MAX_MIN_BLEND_EQUATION, EQUATION_MAP, DEFAULT_WEIGHT_PARAMS, PIXEL_SIZE } from './gpu-grid-aggregator-constants';
|
|
25
|
+
import { AGGREGATION_OPERATION } from '../aggregation-operation-utils';
|
|
26
|
+
import AGGREGATE_TO_GRID_VS from './aggregate-to-grid-vs.glsl';
|
|
27
|
+
import AGGREGATE_TO_GRID_FS from './aggregate-to-grid-fs.glsl';
|
|
28
|
+
import AGGREGATE_ALL_VS from './aggregate-all-vs.glsl';
|
|
29
|
+
import AGGREGATE_ALL_FS from './aggregate-all-fs.glsl';
|
|
30
|
+
import TRANSFORM_MEAN_VS from './transform-mean-vs.glsl';
|
|
31
|
+
import { getFloatTexture, getFramebuffer } from './../resource-utils.js';
|
|
32
|
+
const BUFFER_NAMES = ['aggregationBuffer', 'maxMinBuffer', 'minBuffer', 'maxBuffer'];
|
|
33
|
+
const ARRAY_BUFFER_MAP = {
|
|
34
|
+
maxData: 'maxBuffer',
|
|
35
|
+
minData: 'minBuffer',
|
|
36
|
+
maxMinData: 'maxMinBuffer'
|
|
37
|
+
};
|
|
38
|
+
const REQUIRED_FEATURES = [
|
|
39
|
+
FEATURES.WEBGL2,
|
|
40
|
+
FEATURES.COLOR_ATTACHMENT_RGBA32F,
|
|
41
|
+
FEATURES.BLEND_EQUATION_MINMAX,
|
|
42
|
+
FEATURES.FLOAT_BLEND,
|
|
43
|
+
FEATURES.TEXTURE_FLOAT
|
|
44
|
+
];
|
|
45
|
+
export default class GPUGridAggregator {
|
|
46
|
+
// Decode and return aggregation data of given pixel.
|
|
47
|
+
static getAggregationData({ aggregationData, maxData, minData, maxMinData, pixelIndex }) {
|
|
48
|
+
const index = pixelIndex * PIXEL_SIZE;
|
|
49
|
+
const results = {};
|
|
50
|
+
if (aggregationData) {
|
|
51
|
+
results.cellCount = aggregationData[index + 3];
|
|
52
|
+
results.cellWeight = aggregationData[index];
|
|
53
|
+
}
|
|
54
|
+
if (maxMinData) {
|
|
55
|
+
results.maxCellWieght = maxMinData[0];
|
|
56
|
+
results.minCellWeight = maxMinData[3];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (maxData) {
|
|
60
|
+
results.maxCellWieght = maxData[0];
|
|
61
|
+
results.totalCount = maxData[3];
|
|
62
|
+
}
|
|
63
|
+
if (minData) {
|
|
64
|
+
results.minCellWeight = minData[0];
|
|
65
|
+
results.totalCount = maxData[3];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return results;
|
|
69
|
+
}
|
|
70
|
+
// Decodes and retuns counts and weights of all cells
|
|
71
|
+
static getCellData({ countsData, size = 1 }) {
|
|
72
|
+
const numCells = countsData.length / 4;
|
|
73
|
+
const cellWeights = new Float32Array(numCells * size);
|
|
74
|
+
const cellCounts = new Uint32Array(numCells);
|
|
75
|
+
for (let i = 0; i < numCells; i++) {
|
|
76
|
+
// weights in RGB channels
|
|
77
|
+
for (let sizeIndex = 0; sizeIndex < size; sizeIndex++) {
|
|
78
|
+
cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
|
|
79
|
+
}
|
|
80
|
+
// count in Alpha channel
|
|
81
|
+
cellCounts[i] = countsData[i * 4 + 3];
|
|
82
|
+
}
|
|
83
|
+
return { cellCounts, cellWeights };
|
|
84
|
+
}
|
|
85
|
+
static isSupported(gl) {
|
|
86
|
+
return hasFeatures(gl, REQUIRED_FEATURES);
|
|
87
|
+
}
|
|
88
|
+
// DEBUG ONLY
|
|
89
|
+
// static logData({aggregationBuffer, minBuffer, maxBuffer, maxMinBuffer, limit = 10}) {
|
|
90
|
+
// if (aggregationBuffer) {
|
|
91
|
+
// console.log('Aggregation Data:');
|
|
92
|
+
// const agrData = aggregationBuffer.getData();
|
|
93
|
+
// for (let index = 0; index < agrData.length && limit > 0; index += 4) {
|
|
94
|
+
// if (agrData[index + 3] > 0) {
|
|
95
|
+
// console.log(
|
|
96
|
+
// `index: ${index} weights: ${agrData[index]} ${agrData[index + 1]} ${
|
|
97
|
+
// agrData[index + 2]
|
|
98
|
+
// } count: ${agrData[index + 3]}`
|
|
99
|
+
// );
|
|
100
|
+
// limit--;
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
// const obj = {minBuffer, maxBuffer, maxMinBuffer};
|
|
105
|
+
// for (const key in obj) {
|
|
106
|
+
// if (obj[key]) {
|
|
107
|
+
// const data = obj[key].getData();
|
|
108
|
+
// console.log(`${key} data : R: ${data[0]} G: ${data[1]} B: ${data[2]} A: ${data[3]}`);
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
constructor(gl, opts = {}) {
|
|
113
|
+
this.id = opts.id || 'gpu-grid-aggregator';
|
|
114
|
+
this.gl = gl;
|
|
115
|
+
this.state = {
|
|
116
|
+
// per weight GPU resources
|
|
117
|
+
weightAttributes: {},
|
|
118
|
+
textures: {},
|
|
119
|
+
meanTextures: {},
|
|
120
|
+
buffers: {},
|
|
121
|
+
framebuffers: {},
|
|
122
|
+
maxMinFramebuffers: {},
|
|
123
|
+
minFramebuffers: {},
|
|
124
|
+
maxFramebuffers: {},
|
|
125
|
+
equations: {},
|
|
126
|
+
// common resources to be deleted
|
|
127
|
+
resources: {},
|
|
128
|
+
// results
|
|
129
|
+
results: {}
|
|
130
|
+
};
|
|
131
|
+
this._hasGPUSupport =
|
|
132
|
+
isWebGL2(gl) && // gl_InstanceID usage in min/max calculation shaders
|
|
133
|
+
hasFeatures(this.gl, FEATURES.BLEND_EQUATION_MINMAX, // set min/max blend modes
|
|
134
|
+
FEATURES.COLOR_ATTACHMENT_RGBA32F, // render to float texture
|
|
135
|
+
FEATURES.TEXTURE_FLOAT // sample from a float texture
|
|
136
|
+
);
|
|
137
|
+
if (this._hasGPUSupport) {
|
|
138
|
+
this._setupModels();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Delete owned resources.
|
|
142
|
+
delete() {
|
|
143
|
+
const { gridAggregationModel, allAggregationModel, meanTransform } = this;
|
|
144
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, resources } = this.state;
|
|
145
|
+
gridAggregationModel?.delete();
|
|
146
|
+
allAggregationModel?.delete();
|
|
147
|
+
meanTransform?.delete();
|
|
148
|
+
deleteResources([
|
|
149
|
+
framebuffers,
|
|
150
|
+
textures,
|
|
151
|
+
maxMinFramebuffers,
|
|
152
|
+
minFramebuffers,
|
|
153
|
+
maxFramebuffers,
|
|
154
|
+
meanTextures,
|
|
155
|
+
resources
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
// Perform aggregation and retun the results
|
|
159
|
+
run(opts = {}) {
|
|
160
|
+
// reset results
|
|
161
|
+
this.setState({ results: {} });
|
|
162
|
+
const aggregationParams = this._normalizeAggregationParams(opts);
|
|
163
|
+
if (!this._hasGPUSupport) {
|
|
164
|
+
log.log(1, 'GPUGridAggregator: not supported')();
|
|
165
|
+
}
|
|
166
|
+
return this._runAggregation(aggregationParams);
|
|
167
|
+
}
|
|
168
|
+
// Reads aggregation data into JS Array object
|
|
169
|
+
// For WebGL1, data is available in JS Array objects already.
|
|
170
|
+
// For WebGL2, data is read from Buffer objects and cached for subsequent queries.
|
|
171
|
+
getData(weightId) {
|
|
172
|
+
const data = {};
|
|
173
|
+
const results = this.state.results;
|
|
174
|
+
if (!results[weightId].aggregationData) {
|
|
175
|
+
// cache the results if reading from the buffer (WebGL2 path)
|
|
176
|
+
results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
|
|
177
|
+
}
|
|
178
|
+
data.aggregationData = results[weightId].aggregationData;
|
|
179
|
+
// Check for optional results
|
|
180
|
+
for (const arrayName in ARRAY_BUFFER_MAP) {
|
|
181
|
+
const bufferName = ARRAY_BUFFER_MAP[arrayName];
|
|
182
|
+
if (results[weightId][arrayName] || results[weightId][bufferName]) {
|
|
183
|
+
// cache the result
|
|
184
|
+
results[weightId][arrayName] =
|
|
185
|
+
results[weightId][arrayName] || results[weightId][bufferName].getData();
|
|
186
|
+
data[arrayName] = results[weightId][arrayName];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return data;
|
|
190
|
+
}
|
|
191
|
+
updateShaders(shaderOptions = {}) {
|
|
192
|
+
this.setState({ shaderOptions, modelDirty: true });
|
|
193
|
+
}
|
|
194
|
+
// PRIVATE
|
|
195
|
+
_normalizeAggregationParams(opts) {
|
|
196
|
+
const aggregationParams = { ...DEFAULT_RUN_PARAMS, ...opts };
|
|
197
|
+
const { weights } = aggregationParams;
|
|
198
|
+
if (weights) {
|
|
199
|
+
aggregationParams.weights = normalizeWeightParams(weights);
|
|
200
|
+
}
|
|
201
|
+
return aggregationParams;
|
|
202
|
+
}
|
|
203
|
+
// Update priveate state
|
|
204
|
+
setState(updateObject) {
|
|
205
|
+
Object.assign(this.state, updateObject);
|
|
206
|
+
}
|
|
207
|
+
// GPU Aggregation methods
|
|
208
|
+
_getAggregateData(opts) {
|
|
209
|
+
const results = {};
|
|
210
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, resources } = this.state;
|
|
211
|
+
const { weights } = opts;
|
|
212
|
+
for (const id in weights) {
|
|
213
|
+
results[id] = {};
|
|
214
|
+
const { needMin, needMax, combineMaxMin } = weights[id];
|
|
215
|
+
results[id].aggregationTexture = textures[id];
|
|
216
|
+
results[id].aggregationBuffer = readPixelsToBuffer(framebuffers[id], {
|
|
217
|
+
target: weights[id].aggregationBuffer,
|
|
218
|
+
sourceType: GL.FLOAT
|
|
219
|
+
});
|
|
220
|
+
if (needMin && needMax && combineMaxMin) {
|
|
221
|
+
results[id].maxMinBuffer = readPixelsToBuffer(maxMinFramebuffers[id], {
|
|
222
|
+
target: weights[id].maxMinBuffer,
|
|
223
|
+
sourceType: GL.FLOAT
|
|
224
|
+
});
|
|
225
|
+
results[id].maxMinTexture = resources[`${id}-maxMinTexture`];
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
if (needMin) {
|
|
229
|
+
results[id].minBuffer = readPixelsToBuffer(minFramebuffers[id], {
|
|
230
|
+
target: weights[id].minBuffer,
|
|
231
|
+
sourceType: GL.FLOAT
|
|
232
|
+
});
|
|
233
|
+
results[id].minTexture = resources[`${id}-minTexture`];
|
|
234
|
+
}
|
|
235
|
+
if (needMax) {
|
|
236
|
+
results[id].maxBuffer = readPixelsToBuffer(maxFramebuffers[id], {
|
|
237
|
+
target: weights[id].maxBuffer,
|
|
238
|
+
sourceType: GL.FLOAT
|
|
239
|
+
});
|
|
240
|
+
results[id].maxTexture = resources[`${id}-maxTexture`];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
this._trackGPUResultBuffers(results, weights);
|
|
245
|
+
return results;
|
|
246
|
+
}
|
|
247
|
+
_renderAggregateData(opts) {
|
|
248
|
+
const { cellSize, projectPoints, attributes, moduleSettings, numCol, numRow, weights, translation, scaling } = opts;
|
|
249
|
+
const { maxMinFramebuffers, minFramebuffers, maxFramebuffers } = this.state;
|
|
250
|
+
const gridSize = [numCol, numRow];
|
|
251
|
+
const parameters = {
|
|
252
|
+
blend: true,
|
|
253
|
+
depthTest: false,
|
|
254
|
+
blendFunc: [GL.ONE, GL.ONE]
|
|
255
|
+
};
|
|
256
|
+
const uniforms = {
|
|
257
|
+
cellSize,
|
|
258
|
+
gridSize,
|
|
259
|
+
projectPoints,
|
|
260
|
+
translation,
|
|
261
|
+
scaling
|
|
262
|
+
};
|
|
263
|
+
for (const id in weights) {
|
|
264
|
+
const { needMin, needMax } = weights[id];
|
|
265
|
+
const combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
|
|
266
|
+
this._renderToWeightsTexture({
|
|
267
|
+
id,
|
|
268
|
+
parameters,
|
|
269
|
+
moduleSettings,
|
|
270
|
+
uniforms,
|
|
271
|
+
gridSize,
|
|
272
|
+
attributes,
|
|
273
|
+
weights
|
|
274
|
+
});
|
|
275
|
+
if (combineMaxMin) {
|
|
276
|
+
this._renderToMaxMinTexture({
|
|
277
|
+
id,
|
|
278
|
+
parameters: { ...parameters, blendEquation: MAX_MIN_BLEND_EQUATION },
|
|
279
|
+
gridSize,
|
|
280
|
+
minOrMaxFb: maxMinFramebuffers[id],
|
|
281
|
+
clearParams: { clearColor: [0, 0, 0, MAX_32_BIT_FLOAT] },
|
|
282
|
+
combineMaxMin
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (needMin) {
|
|
287
|
+
this._renderToMaxMinTexture({
|
|
288
|
+
id,
|
|
289
|
+
parameters: { ...parameters, blendEquation: MIN_BLEND_EQUATION },
|
|
290
|
+
gridSize,
|
|
291
|
+
minOrMaxFb: minFramebuffers[id],
|
|
292
|
+
clearParams: { clearColor: [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0] },
|
|
293
|
+
combineMaxMin
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (needMax) {
|
|
297
|
+
this._renderToMaxMinTexture({
|
|
298
|
+
id,
|
|
299
|
+
parameters: { ...parameters, blendEquation: MAX_BLEND_EQUATION },
|
|
300
|
+
gridSize,
|
|
301
|
+
minOrMaxFb: maxFramebuffers[id],
|
|
302
|
+
clearParams: { clearColor: [0, 0, 0, 0] },
|
|
303
|
+
combineMaxMin
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// render all aggregated grid-cells to generate Min, Max or MaxMin data texture
|
|
310
|
+
_renderToMaxMinTexture(opts) {
|
|
311
|
+
const { id, parameters, gridSize, minOrMaxFb, combineMaxMin, clearParams = {} } = opts;
|
|
312
|
+
const { framebuffers } = this.state;
|
|
313
|
+
const { gl, allAggregationModel } = this;
|
|
314
|
+
withParameters(gl, {
|
|
315
|
+
...clearParams,
|
|
316
|
+
framebuffer: minOrMaxFb,
|
|
317
|
+
viewport: [0, 0, gridSize[0], gridSize[1]]
|
|
318
|
+
}, () => {
|
|
319
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
320
|
+
allAggregationModel.draw({
|
|
321
|
+
parameters,
|
|
322
|
+
uniforms: {
|
|
323
|
+
uSampler: framebuffers[id].texture,
|
|
324
|
+
gridSize,
|
|
325
|
+
combineMaxMin
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
// render all data points to aggregate weights
|
|
331
|
+
_renderToWeightsTexture(opts) {
|
|
332
|
+
const { id, parameters, moduleSettings, uniforms, gridSize, weights } = opts;
|
|
333
|
+
const { framebuffers, equations, weightAttributes } = this.state;
|
|
334
|
+
const { gl, gridAggregationModel } = this;
|
|
335
|
+
const { operation } = weights[id];
|
|
336
|
+
const clearColor = operation === AGGREGATION_OPERATION.MIN
|
|
337
|
+
? [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0]
|
|
338
|
+
: [0, 0, 0, 0];
|
|
339
|
+
withParameters(gl, {
|
|
340
|
+
framebuffer: framebuffers[id],
|
|
341
|
+
viewport: [0, 0, gridSize[0], gridSize[1]],
|
|
342
|
+
clearColor
|
|
343
|
+
}, () => {
|
|
344
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
345
|
+
const attributes = { weights: weightAttributes[id] };
|
|
346
|
+
gridAggregationModel.draw({
|
|
347
|
+
parameters: { ...parameters, blendEquation: equations[id] },
|
|
348
|
+
moduleSettings,
|
|
349
|
+
uniforms,
|
|
350
|
+
attributes
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
354
|
+
const { meanTextures, textures } = this.state;
|
|
355
|
+
const transformOptions = {
|
|
356
|
+
_sourceTextures: { aggregationValues: meanTextures[id] },
|
|
357
|
+
_targetTexture: textures[id],
|
|
358
|
+
elementCount: textures[id].width * textures[id].height
|
|
359
|
+
};
|
|
360
|
+
if (this.meanTransform) {
|
|
361
|
+
this.meanTransform.update(transformOptions);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.meanTransform = getMeanTransform(gl, transformOptions);
|
|
365
|
+
}
|
|
366
|
+
this.meanTransform.run({
|
|
367
|
+
parameters: {
|
|
368
|
+
blend: false,
|
|
369
|
+
depthTest: false
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
// update framebuffer with mean results so readPixelsToBuffer returns mean values
|
|
373
|
+
framebuffers[id].attach({ [GL.COLOR_ATTACHMENT0]: textures[id] });
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
_runAggregation(opts) {
|
|
377
|
+
this._updateModels(opts);
|
|
378
|
+
this._setupFramebuffers(opts);
|
|
379
|
+
this._renderAggregateData(opts);
|
|
380
|
+
const results = this._getAggregateData(opts);
|
|
381
|
+
this.setState({ results });
|
|
382
|
+
return results;
|
|
383
|
+
}
|
|
384
|
+
// set up framebuffer for each weight
|
|
385
|
+
/* eslint-disable complexity, max-depth, max-statements*/
|
|
386
|
+
_setupFramebuffers(opts) {
|
|
387
|
+
const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, equations } = this.state;
|
|
388
|
+
const { weights } = opts;
|
|
389
|
+
const { numCol, numRow } = opts;
|
|
390
|
+
const framebufferSize = { width: numCol, height: numRow };
|
|
391
|
+
for (const id in weights) {
|
|
392
|
+
const { needMin, needMax, combineMaxMin, operation } = weights[id];
|
|
393
|
+
textures[id] =
|
|
394
|
+
weights[id].aggregationTexture ||
|
|
395
|
+
textures[id] ||
|
|
396
|
+
getFloatTexture(this.gl, { id: `${id}-texture`, width: numCol, height: numRow });
|
|
397
|
+
textures[id].resize(framebufferSize);
|
|
398
|
+
let texture = textures[id];
|
|
399
|
+
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
400
|
+
// For MEAN, we first aggregatet into a temp texture
|
|
401
|
+
meanTextures[id] =
|
|
402
|
+
meanTextures[id] ||
|
|
403
|
+
getFloatTexture(this.gl, { id: `${id}-mean-texture`, width: numCol, height: numRow });
|
|
404
|
+
meanTextures[id].resize(framebufferSize);
|
|
405
|
+
texture = meanTextures[id];
|
|
406
|
+
}
|
|
407
|
+
if (framebuffers[id]) {
|
|
408
|
+
framebuffers[id].attach({ [GL.COLOR_ATTACHMENT0]: texture });
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
framebuffers[id] = getFramebuffer(this.gl, {
|
|
412
|
+
id: `${id}-fb`,
|
|
413
|
+
width: numCol,
|
|
414
|
+
height: numRow,
|
|
415
|
+
texture
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
framebuffers[id].resize(framebufferSize);
|
|
419
|
+
equations[id] = EQUATION_MAP[operation] || EQUATION_MAP.SUM;
|
|
420
|
+
// For min/max framebuffers will use default size 1X1
|
|
421
|
+
if (needMin || needMax) {
|
|
422
|
+
if (needMin && needMax && combineMaxMin) {
|
|
423
|
+
if (!maxMinFramebuffers[id]) {
|
|
424
|
+
texture = weights[id].maxMinTexture || this._getMinMaxTexture(`${id}-maxMinTexture`);
|
|
425
|
+
maxMinFramebuffers[id] = getFramebuffer(this.gl, { id: `${id}-maxMinFb`, texture });
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
if (needMin) {
|
|
430
|
+
if (!minFramebuffers[id]) {
|
|
431
|
+
texture = weights[id].minTexture || this._getMinMaxTexture(`${id}-minTexture`);
|
|
432
|
+
minFramebuffers[id] = getFramebuffer(this.gl, {
|
|
433
|
+
id: `${id}-minFb`,
|
|
434
|
+
texture
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (needMax) {
|
|
439
|
+
if (!maxFramebuffers[id]) {
|
|
440
|
+
texture = weights[id].maxTexture || this._getMinMaxTexture(`${id}-maxTexture`);
|
|
441
|
+
maxFramebuffers[id] = getFramebuffer(this.gl, {
|
|
442
|
+
id: `${id}-maxFb`,
|
|
443
|
+
texture
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/* eslint-enable complexity, max-depth, max-statements */
|
|
452
|
+
_getMinMaxTexture(name) {
|
|
453
|
+
const { resources } = this.state;
|
|
454
|
+
if (!resources[name]) {
|
|
455
|
+
resources[name] = getFloatTexture(this.gl, { id: `resourceName` });
|
|
456
|
+
}
|
|
457
|
+
return resources[name];
|
|
458
|
+
}
|
|
459
|
+
_setupModels({ numCol = 0, numRow = 0 } = {}) {
|
|
460
|
+
const { gl } = this;
|
|
461
|
+
const { shaderOptions } = this.state;
|
|
462
|
+
this.gridAggregationModel?.delete();
|
|
463
|
+
this.gridAggregationModel = getAggregationModel(gl, shaderOptions);
|
|
464
|
+
if (!this.allAggregationModel) {
|
|
465
|
+
const instanceCount = numCol * numRow;
|
|
466
|
+
this.allAggregationModel = getAllAggregationModel(gl, instanceCount);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// set up buffers for all weights
|
|
470
|
+
_setupWeightAttributes(opts) {
|
|
471
|
+
const { weightAttributes } = this.state;
|
|
472
|
+
const { weights } = opts;
|
|
473
|
+
for (const id in weights) {
|
|
474
|
+
weightAttributes[id] = opts.attributes[id];
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// GPU Aggregation results are provided in Buffers, if new Buffer objects are created track them for later deletion.
|
|
478
|
+
/* eslint-disable max-depth */
|
|
479
|
+
_trackGPUResultBuffers(results, weights) {
|
|
480
|
+
const { resources } = this.state;
|
|
481
|
+
for (const id in results) {
|
|
482
|
+
if (results[id]) {
|
|
483
|
+
for (const bufferName of BUFFER_NAMES) {
|
|
484
|
+
if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
|
|
485
|
+
// No result buffer is provided in weights object, `readPixelsToBuffer` has created a new Buffer object
|
|
486
|
+
// collect the new buffer for garabge collection
|
|
487
|
+
const name = `gpu-result-${id}-${bufferName}`;
|
|
488
|
+
if (resources[name]) {
|
|
489
|
+
resources[name].delete();
|
|
490
|
+
}
|
|
491
|
+
resources[name] = results[id][bufferName];
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/* eslint-enable max-depth */
|
|
498
|
+
_updateModels(opts) {
|
|
499
|
+
const { vertexCount, attributes, numCol, numRow } = opts;
|
|
500
|
+
const { modelDirty } = this.state;
|
|
501
|
+
if (modelDirty) {
|
|
502
|
+
this._setupModels(opts);
|
|
503
|
+
this.setState({ modelDirty: false });
|
|
504
|
+
}
|
|
505
|
+
// this maps color/elevation to weight name.
|
|
506
|
+
this._setupWeightAttributes(opts);
|
|
507
|
+
this.gridAggregationModel.setVertexCount(vertexCount);
|
|
508
|
+
this.gridAggregationModel.setAttributes(attributes);
|
|
509
|
+
this.allAggregationModel.setInstanceCount(numCol * numRow);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
// HELPER METHODS
|
|
513
|
+
function normalizeWeightParams(weights) {
|
|
514
|
+
const result = {};
|
|
515
|
+
for (const id in weights) {
|
|
516
|
+
result[id] = { ...DEFAULT_WEIGHT_PARAMS, ...weights[id] };
|
|
517
|
+
}
|
|
518
|
+
return result;
|
|
519
|
+
}
|
|
520
|
+
function deleteResources(resources) {
|
|
521
|
+
resources = Array.isArray(resources) ? resources : [resources];
|
|
522
|
+
resources.forEach(obj => {
|
|
523
|
+
for (const name in obj) {
|
|
524
|
+
obj[name].delete();
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function getAggregationModel(gl, shaderOptions) {
|
|
529
|
+
const shaders = mergeShaders({
|
|
530
|
+
vs: AGGREGATE_TO_GRID_VS,
|
|
531
|
+
fs: AGGREGATE_TO_GRID_FS,
|
|
532
|
+
modules: [fp64arithmetic, project32]
|
|
533
|
+
}, shaderOptions);
|
|
534
|
+
return new Model(gl, {
|
|
535
|
+
id: 'Gird-Aggregation-Model',
|
|
536
|
+
vertexCount: 1,
|
|
537
|
+
drawMode: GL.POINTS,
|
|
538
|
+
...shaders
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function getAllAggregationModel(gl, instanceCount) {
|
|
542
|
+
return new Model(gl, {
|
|
543
|
+
id: 'All-Aggregation-Model',
|
|
544
|
+
vs: AGGREGATE_ALL_VS,
|
|
545
|
+
fs: AGGREGATE_ALL_FS,
|
|
546
|
+
modules: [fp64arithmetic],
|
|
547
|
+
vertexCount: 1,
|
|
548
|
+
drawMode: GL.POINTS,
|
|
549
|
+
isInstanced: true,
|
|
550
|
+
instanceCount,
|
|
551
|
+
attributes: {
|
|
552
|
+
position: [0, 0]
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function getMeanTransform(gl, opts) {
|
|
557
|
+
return new Transform(gl, {
|
|
558
|
+
vs: TRANSFORM_MEAN_VS,
|
|
559
|
+
_targetTextureVarying: 'meanValues',
|
|
560
|
+
...opts
|
|
561
|
+
});
|
|
562
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare var _default: "#define SHADER_NAME gpu-aggregation-transform-mean-vs\nattribute vec4 aggregationValues;\nvarying vec4 meanValues;\n\nvoid main()\n{\n // TODO: Use 64-bit division ?? not needed given this is aggregation ??\n bool isCellValid = bool(aggregationValues.w > 0.);\n // aggregationValues: XYZ contain aggregated values, W contains count\n meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0);\n meanValues.w = aggregationValues.w;\n\n // Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)\n gl_PointSize = 1.0;\n}\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=transform-mean-vs.glsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-mean-vs.glsl.d.ts","sourceRoot":"","sources":["../../../src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2018 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
export default `\
|
|
21
|
+
#define SHADER_NAME gpu-aggregation-transform-mean-vs
|
|
22
|
+
attribute vec4 aggregationValues;
|
|
23
|
+
varying vec4 meanValues;
|
|
24
|
+
|
|
25
|
+
void main()
|
|
26
|
+
{
|
|
27
|
+
// TODO: Use 64-bit division ?? not needed given this is aggregation ??
|
|
28
|
+
bool isCellValid = bool(aggregationValues.w > 0.);
|
|
29
|
+
// aggregationValues: XYZ contain aggregated values, W contains count
|
|
30
|
+
meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0);
|
|
31
|
+
meanValues.w = aggregationValues.w;
|
|
32
|
+
|
|
33
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
34
|
+
gl_PointSize = 1.0;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function getBoundingBox(attributes: any, vertexCount: any): {
|
|
2
|
+
xMin: any;
|
|
3
|
+
xMax: any;
|
|
4
|
+
yMin: any;
|
|
5
|
+
yMax: any;
|
|
6
|
+
};
|
|
7
|
+
export function alignToCell(inValue: any, cellSize: any): number;
|
|
8
|
+
/**
|
|
9
|
+
* Based on geometric center of sample points, calculate cellSize in lng/lat (degree) space
|
|
10
|
+
* @param {object} boundingBox - {xMin, yMin, xMax, yMax} contains bounding box of data
|
|
11
|
+
* @param {number} cellSize - grid cell size in meters
|
|
12
|
+
* @param {boolean, optional} converToDegrees - when true offsets are converted from meters to lng/lat (degree) space
|
|
13
|
+
* @returns {xOffset, yOffset} - cellSize size
|
|
14
|
+
*/
|
|
15
|
+
export function getGridOffset(boundingBox: object, cellSize: number, convertToMeters?: boolean): any;
|
|
16
|
+
export function getGridParams(boundingBox: any, cellSize: any, viewport: any, coordinateSystem: any): {
|
|
17
|
+
gridOffset: any;
|
|
18
|
+
translation: number[];
|
|
19
|
+
width: any;
|
|
20
|
+
height: any;
|
|
21
|
+
numCol: number;
|
|
22
|
+
numRow: number;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=grid-aggregation-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-aggregation-utils.d.ts","sourceRoot":"","sources":["../../src/utils/grid-aggregation-utils.js"],"names":[],"mappings":"AASA;;;;;EA4BC;AA4BD,iEAQC;AAED;;;;;;GAMG;AAEH,2CANW,MAAM,YACN,MAAM,kCAchB;AAED;;;;;;;EAiBC"}
|