@deck.gl/aggregation-layers 9.0.34 → 9.1.0-beta.1
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/common/aggregation-layer.d.ts +30 -0
- package/dist/common/aggregation-layer.d.ts.map +1 -0
- package/dist/common/aggregation-layer.js +69 -0
- package/dist/common/aggregator/aggregator.d.ts +76 -0
- package/dist/common/aggregator/aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/aggregator.js +4 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/aggregate.js +66 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +139 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/sort-bins.js +43 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
- package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +55 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +20 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +17 -0
- package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
- package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/utils.js +24 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +215 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +201 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +223 -0
- package/dist/common/aggregator/index.d.ts +6 -0
- package/dist/common/aggregator/index.d.ts.map +1 -0
- package/dist/common/aggregator/index.js +5 -0
- package/dist/common/types.d.ts +11 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +4 -0
- package/dist/common/utils/bounds-utils.d.ts +10 -0
- package/dist/common/utils/bounds-utils.d.ts.map +1 -0
- package/dist/common/utils/bounds-utils.js +20 -0
- package/dist/common/utils/color-utils.d.ts +10 -0
- package/dist/common/utils/color-utils.d.ts.map +1 -0
- package/dist/common/utils/color-utils.js +65 -0
- package/dist/common/utils/prop-utils.d.ts.map +1 -0
- package/dist/common/utils/prop-utils.js +12 -0
- package/dist/common/utils/scale-utils.d.ts +46 -0
- package/dist/common/utils/scale-utils.d.ts.map +1 -0
- package/dist/common/utils/scale-utils.js +180 -0
- package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
- package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/contour-layer/bin-options-uniforms.js +17 -0
- package/dist/contour-layer/contour-layer.d.ts +42 -50
- package/dist/contour-layer/contour-layer.d.ts.map +1 -1
- package/dist/contour-layer/contour-layer.js +232 -192
- package/dist/contour-layer/contour-utils.d.ts +36 -15
- package/dist/contour-layer/contour-utils.d.ts.map +1 -1
- package/dist/contour-layer/contour-utils.js +24 -29
- package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
- package/dist/contour-layer/marching-squares-codes.js +3 -0
- package/dist/contour-layer/marching-squares.d.ts +22 -6
- package/dist/contour-layer/marching-squares.d.ts.map +1 -1
- package/dist/contour-layer/marching-squares.js +71 -68
- package/dist/contour-layer/value-reader.d.ts +10 -0
- package/dist/contour-layer/value-reader.d.ts.map +1 -0
- package/dist/contour-layer/value-reader.js +46 -0
- package/dist/dist.dev.js +4842 -4081
- package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
- package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/grid-layer/bin-options-uniforms.js +17 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
- package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer.js +93 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.js +23 -0
- package/dist/grid-layer/grid-layer.d.ts +175 -13
- package/dist/grid-layer/grid-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer.js +342 -46
- package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
- package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
- package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +6 -21
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +32 -0
- package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
- package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-utils.js +3 -0
- package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +43 -33
- package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/max-fs.glsl.js +3 -0
- package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/max-vs.glsl.js +6 -4
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +5 -23
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js +22 -0
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +10 -30
- package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +17 -30
- package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/weights-fs.glsl.js +3 -0
- package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
- package/dist/heatmap-layer/weights-vs.glsl.js +6 -7
- package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
- package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/hexagon-layer/bin-options-uniforms.js +17 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.js +94 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +21 -0
- package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
- package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer.js +307 -123
- package/dist/hexagon-layer/hexbin.d.ts +17 -0
- package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
- package/dist/hexagon-layer/hexbin.js +69 -0
- package/dist/index.cjs +3025 -2946
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +7 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -27
- package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
- package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
- package/dist/screen-grid-layer/bin-options-uniforms.js +15 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +52 -134
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +4 -24
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +19 -0
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +21 -62
- package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
- package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer.js +157 -174
- package/dist.min.js +401 -382
- package/package.json +10 -9
- package/src/common/aggregation-layer.ts +107 -0
- package/src/common/aggregator/aggregator.ts +88 -0
- package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
- package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
- package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
- package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
- package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
- package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
- package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
- package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
- package/src/common/aggregator/index.ts +10 -0
- package/src/{types.ts → common/types.ts} +10 -4
- package/src/common/utils/bounds-utils.ts +34 -0
- package/src/common/utils/color-utils.ts +86 -0
- package/src/common/utils/prop-utils.ts +13 -0
- package/src/common/utils/scale-utils.ts +236 -0
- package/src/contour-layer/bin-options-uniforms.ts +26 -0
- package/src/contour-layer/contour-layer.ts +300 -265
- package/src/contour-layer/contour-utils.ts +68 -39
- package/src/contour-layer/marching-squares-codes.ts +4 -0
- package/src/contour-layer/marching-squares.ts +93 -82
- package/src/contour-layer/value-reader.ts +65 -0
- package/src/grid-layer/bin-options-uniforms.ts +26 -0
- package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
- package/src/grid-layer/grid-cell-layer.ts +141 -0
- package/src/grid-layer/grid-layer-uniforms.ts +37 -0
- package/src/grid-layer/grid-layer.ts +614 -73
- package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
- package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
- package/src/heatmap-layer/heatmap-layer.ts +59 -36
- package/src/heatmap-layer/max-fs.glsl.ts +4 -0
- package/src/heatmap-layer/max-vs.glsl.ts +7 -4
- package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
- package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
- package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
- package/src/heatmap-layer/triangle-layer.ts +26 -31
- package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
- package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
- package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
- package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
- package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
- package/src/hexagon-layer/hexagon-layer.ts +454 -186
- package/src/hexagon-layer/hexbin.ts +79 -0
- package/src/index.ts +21 -34
- package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
- package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
- package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
- package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
- package/dist/aggregation-layer.d.ts.map +0 -1
- package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
- package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
- package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
- package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
- package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
- package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
- package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
- package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
- package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
- package/dist/grid-aggregation-layer.d.ts +0 -67
- package/dist/grid-aggregation-layer.d.ts.map +0 -1
- package/dist/grid-aggregation-layer.js +0 -173
- package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
- package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
- package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
- package/dist/types.d.ts +0 -12
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -1
- package/dist/utils/aggregation-operation-utils.d.ts +0 -19
- package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
- package/dist/utils/aggregation-operation-utils.js +0 -94
- package/dist/utils/bin-sorter.d.ts +0 -52
- package/dist/utils/bin-sorter.d.ts.map +0 -1
- package/dist/utils/bin-sorter.js +0 -167
- package/dist/utils/color-utils.d.ts +0 -3
- package/dist/utils/color-utils.d.ts.map +0 -1
- package/dist/utils/color-utils.js +0 -53
- package/dist/utils/cpu-aggregator.d.ts +0 -169
- package/dist/utils/cpu-aggregator.d.ts.map +0 -1
- package/dist/utils/cpu-aggregator.js +0 -421
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
- package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
- package/dist/utils/grid-aggregation-utils.d.ts +0 -30
- package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
- package/dist/utils/grid-aggregation-utils.js +0 -114
- package/dist/utils/prop-utils.d.ts.map +0 -1
- package/dist/utils/prop-utils.js +0 -28
- package/dist/utils/resource-utils.d.ts +0 -14
- package/dist/utils/resource-utils.d.ts.map +0 -1
- package/dist/utils/resource-utils.js +0 -38
- package/dist/utils/scale-utils.d.ts +0 -15
- package/dist/utils/scale-utils.d.ts.map +0 -1
- package/dist/utils/scale-utils.js +0 -184
- package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
- package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
- package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
- package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
- package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
- package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
- package/src/grid-aggregation-layer.ts +0 -243
- package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
- package/src/utils/aggregation-operation-utils.ts +0 -118
- package/src/utils/bin-sorter.ts +0 -218
- package/src/utils/color-utils.ts +0 -57
- package/src/utils/cpu-aggregator.ts +0 -503
- package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
- package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
- package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
- package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
- package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
- package/src/utils/grid-aggregation-utils.ts +0 -147
- package/src/utils/prop-utils.ts +0 -29
- package/src/utils/resource-utils.ts +0 -53
- package/src/utils/scale-utils.js +0 -219
- /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
|
@@ -1,690 +0,0 @@
|
|
|
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
|
-
|
|
21
|
-
import type {Device, DeviceFeature} from '@luma.gl/core';
|
|
22
|
-
import {Model, TextureTransform} from '@luma.gl/engine';
|
|
23
|
-
import {fp64arithmetic} from '@luma.gl/shadertools';
|
|
24
|
-
import {GL} from '@luma.gl/constants';
|
|
25
|
-
import {project32, _mergeShaders as mergeShaders, getShaderAssembler} from '@deck.gl/core';
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
DEFAULT_RUN_PARAMS,
|
|
29
|
-
MAX_32_BIT_FLOAT,
|
|
30
|
-
MIN_BLEND_EQUATION,
|
|
31
|
-
MAX_BLEND_EQUATION,
|
|
32
|
-
MAX_MIN_BLEND_EQUATION,
|
|
33
|
-
EQUATION_MAP,
|
|
34
|
-
DEFAULT_WEIGHT_PARAMS,
|
|
35
|
-
PIXEL_SIZE
|
|
36
|
-
} from './gpu-grid-aggregator-constants';
|
|
37
|
-
import {AGGREGATION_OPERATION} from '../aggregation-operation-utils';
|
|
38
|
-
|
|
39
|
-
import AGGREGATE_TO_GRID_VS from './aggregate-to-grid-vs.glsl';
|
|
40
|
-
import AGGREGATE_TO_GRID_FS from './aggregate-to-grid-fs.glsl';
|
|
41
|
-
import AGGREGATE_ALL_VS from './aggregate-all-vs.glsl';
|
|
42
|
-
import AGGREGATE_ALL_FS from './aggregate-all-fs.glsl';
|
|
43
|
-
import TRANSFORM_MEAN_VS from './transform-mean-vs.glsl';
|
|
44
|
-
import {getFloatTexture, getFramebuffer} from './../resource-utils';
|
|
45
|
-
|
|
46
|
-
const BUFFER_NAMES = ['aggregationBuffer', 'maxMinBuffer', 'minBuffer', 'maxBuffer'];
|
|
47
|
-
const ARRAY_BUFFER_MAP = {
|
|
48
|
-
maxData: 'maxBuffer',
|
|
49
|
-
minData: 'minBuffer',
|
|
50
|
-
maxMinData: 'maxMinBuffer'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const REQUIRED_FEATURES: DeviceFeature[] = [
|
|
54
|
-
'float32-renderable-webgl',
|
|
55
|
-
'texture-blend-float-webgl'
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
export type GPUGridAggregatorProps = {
|
|
59
|
-
id?: string;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export default class GPUGridAggregator {
|
|
63
|
-
// Decode and return aggregation data of given pixel.
|
|
64
|
-
static getAggregationData({
|
|
65
|
-
aggregationData,
|
|
66
|
-
maxData,
|
|
67
|
-
minData,
|
|
68
|
-
maxMinData,
|
|
69
|
-
pixelIndex
|
|
70
|
-
}: {
|
|
71
|
-
aggregationData?: Float32Array;
|
|
72
|
-
maxData?: Float32Array;
|
|
73
|
-
minData?: Float32Array;
|
|
74
|
-
maxMinData?: Float32Array;
|
|
75
|
-
pixelIndex: number;
|
|
76
|
-
}) {
|
|
77
|
-
const index = pixelIndex * PIXEL_SIZE;
|
|
78
|
-
const results: {cellCount?; cellWeight?; maxCellWieght?; minCellWeight?; totalCount?} = {};
|
|
79
|
-
if (aggregationData) {
|
|
80
|
-
results.cellCount = aggregationData[index + 3];
|
|
81
|
-
results.cellWeight = aggregationData[index];
|
|
82
|
-
}
|
|
83
|
-
if (maxMinData) {
|
|
84
|
-
results.maxCellWieght = maxMinData[0];
|
|
85
|
-
results.minCellWeight = maxMinData[3];
|
|
86
|
-
} else {
|
|
87
|
-
if (maxData) {
|
|
88
|
-
results.maxCellWieght = maxData[0];
|
|
89
|
-
results.totalCount = maxData[3];
|
|
90
|
-
}
|
|
91
|
-
if (minData) {
|
|
92
|
-
results.minCellWeight = minData[0];
|
|
93
|
-
results.totalCount = minData[3];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return results;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Decodes and retuns counts and weights of all cells
|
|
100
|
-
static getCellData({countsData, size = 1}) {
|
|
101
|
-
const numCells = countsData.length / 4;
|
|
102
|
-
const cellWeights = new Float32Array(numCells * size);
|
|
103
|
-
const cellCounts = new Uint32Array(numCells);
|
|
104
|
-
for (let i = 0; i < numCells; i++) {
|
|
105
|
-
// weights in RGB channels
|
|
106
|
-
for (let sizeIndex = 0; sizeIndex < size; sizeIndex++) {
|
|
107
|
-
cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
|
|
108
|
-
}
|
|
109
|
-
// count in Alpha channel
|
|
110
|
-
cellCounts[i] = countsData[i * 4 + 3];
|
|
111
|
-
}
|
|
112
|
-
return {cellCounts, cellWeights};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
static isSupported(device: Device) {
|
|
116
|
-
return REQUIRED_FEATURES.every(feature => device.features.has(feature));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// DEBUG ONLY
|
|
120
|
-
// static logData({aggregationBuffer, minBuffer, maxBuffer, maxMinBuffer, limit = 10}) {
|
|
121
|
-
// if (aggregationBuffer) {
|
|
122
|
-
// console.log('Aggregation Data:');
|
|
123
|
-
// const agrData = aggregationBuffer.getData();
|
|
124
|
-
// for (let index = 0; index < agrData.length && limit > 0; index += 4) {
|
|
125
|
-
// if (agrData[index + 3] > 0) {
|
|
126
|
-
// console.log(
|
|
127
|
-
// `index: ${index} weights: ${agrData[index]} ${agrData[index + 1]} ${
|
|
128
|
-
// agrData[index + 2]
|
|
129
|
-
// } count: ${agrData[index + 3]}`
|
|
130
|
-
// );
|
|
131
|
-
// limit--;
|
|
132
|
-
// }
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// const obj = {minBuffer, maxBuffer, maxMinBuffer};
|
|
136
|
-
// for (const key in obj) {
|
|
137
|
-
// if (obj[key]) {
|
|
138
|
-
// const data = obj[key].getData();
|
|
139
|
-
// console.log(`${key} data : R: ${data[0]} G: ${data[1]} B: ${data[2]} A: ${data[3]}`);
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
|
-
// }
|
|
143
|
-
|
|
144
|
-
state = {
|
|
145
|
-
// per weight GPU resources
|
|
146
|
-
weightAttributes: {},
|
|
147
|
-
textures: {},
|
|
148
|
-
meanTextures: {},
|
|
149
|
-
buffers: {},
|
|
150
|
-
framebuffers: {},
|
|
151
|
-
maxMinFramebuffers: {},
|
|
152
|
-
minFramebuffers: {},
|
|
153
|
-
maxFramebuffers: {},
|
|
154
|
-
equations: {},
|
|
155
|
-
|
|
156
|
-
shaderOptions: {},
|
|
157
|
-
modelDirty: false,
|
|
158
|
-
|
|
159
|
-
// common resources to be deleted
|
|
160
|
-
resources: {},
|
|
161
|
-
|
|
162
|
-
// results
|
|
163
|
-
results: {}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
id: string;
|
|
167
|
-
device: Device;
|
|
168
|
-
_hasGPUSupport: boolean;
|
|
169
|
-
|
|
170
|
-
gridAggregationModel;
|
|
171
|
-
allAggregationModel;
|
|
172
|
-
meanTransform;
|
|
173
|
-
|
|
174
|
-
constructor(device: Device, props: GPUGridAggregatorProps = {}) {
|
|
175
|
-
this.id = props.id || 'gpu-grid-aggregator';
|
|
176
|
-
this.device = device;
|
|
177
|
-
|
|
178
|
-
const REQUIRED_FEATURES: DeviceFeature[] = [
|
|
179
|
-
'float32-renderable-webgl' // render to float texture
|
|
180
|
-
];
|
|
181
|
-
|
|
182
|
-
this._hasGPUSupport = REQUIRED_FEATURES.every(feature => device.features.has(feature));
|
|
183
|
-
if (this._hasGPUSupport) {
|
|
184
|
-
this._setupModels();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Delete owned resources.
|
|
189
|
-
delete() {
|
|
190
|
-
const {gridAggregationModel, allAggregationModel, meanTransform} = this;
|
|
191
|
-
const {
|
|
192
|
-
textures,
|
|
193
|
-
framebuffers,
|
|
194
|
-
maxMinFramebuffers,
|
|
195
|
-
minFramebuffers,
|
|
196
|
-
maxFramebuffers,
|
|
197
|
-
meanTextures,
|
|
198
|
-
resources
|
|
199
|
-
} = this.state;
|
|
200
|
-
|
|
201
|
-
gridAggregationModel?.destroy();
|
|
202
|
-
allAggregationModel?.destroy();
|
|
203
|
-
meanTransform?.destroy();
|
|
204
|
-
|
|
205
|
-
deleteResources([
|
|
206
|
-
framebuffers,
|
|
207
|
-
textures,
|
|
208
|
-
maxMinFramebuffers,
|
|
209
|
-
minFramebuffers,
|
|
210
|
-
maxFramebuffers,
|
|
211
|
-
meanTextures,
|
|
212
|
-
resources
|
|
213
|
-
]);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Perform aggregation and retun the results
|
|
217
|
-
run(opts = {}) {
|
|
218
|
-
// reset results
|
|
219
|
-
this.setState({results: {}});
|
|
220
|
-
const aggregationParams = this._normalizeAggregationParams(opts);
|
|
221
|
-
return this._runAggregation(aggregationParams);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Reads aggregation data into JS Array object
|
|
225
|
-
// For WebGL1, data is available in JS Array objects already.
|
|
226
|
-
// For WebGL2, data is read from Buffer objects and cached for subsequent queries.
|
|
227
|
-
getData(weightId) {
|
|
228
|
-
const data: {
|
|
229
|
-
aggregationData?: Float32Array;
|
|
230
|
-
maxData?: Float32Array;
|
|
231
|
-
minData?: Float32Array;
|
|
232
|
-
maxMinData?: Float32Array;
|
|
233
|
-
} = {};
|
|
234
|
-
const results = this.state.results;
|
|
235
|
-
if (!results[weightId].aggregationData) {
|
|
236
|
-
// cache the results if reading from the buffer (WebGL2 path)
|
|
237
|
-
results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
|
|
238
|
-
}
|
|
239
|
-
data.aggregationData = results[weightId].aggregationData;
|
|
240
|
-
|
|
241
|
-
// Check for optional results
|
|
242
|
-
for (const arrayName in ARRAY_BUFFER_MAP) {
|
|
243
|
-
const bufferName = ARRAY_BUFFER_MAP[arrayName];
|
|
244
|
-
|
|
245
|
-
if (results[weightId][arrayName] || results[weightId][bufferName]) {
|
|
246
|
-
// cache the result
|
|
247
|
-
results[weightId][arrayName] =
|
|
248
|
-
results[weightId][arrayName] || results[weightId][bufferName].getData();
|
|
249
|
-
data[arrayName] = results[weightId][arrayName];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return data;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
updateShaders(shaderOptions = {}) {
|
|
256
|
-
this.setState({shaderOptions, modelDirty: true});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// PRIVATE
|
|
260
|
-
|
|
261
|
-
_normalizeAggregationParams(opts) {
|
|
262
|
-
const aggregationParams = {...DEFAULT_RUN_PARAMS, ...opts};
|
|
263
|
-
const {weights} = aggregationParams;
|
|
264
|
-
if (weights) {
|
|
265
|
-
aggregationParams.weights = normalizeWeightParams(weights);
|
|
266
|
-
}
|
|
267
|
-
return aggregationParams;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Update priveate state
|
|
271
|
-
setState(updateObject) {
|
|
272
|
-
Object.assign(this.state, updateObject);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// GPU Aggregation methods
|
|
276
|
-
|
|
277
|
-
_getAggregateData(opts) {
|
|
278
|
-
const results = {};
|
|
279
|
-
const {
|
|
280
|
-
textures,
|
|
281
|
-
framebuffers,
|
|
282
|
-
maxMinFramebuffers,
|
|
283
|
-
minFramebuffers,
|
|
284
|
-
maxFramebuffers,
|
|
285
|
-
resources
|
|
286
|
-
} = this.state;
|
|
287
|
-
const {weights} = opts;
|
|
288
|
-
|
|
289
|
-
for (const id in weights) {
|
|
290
|
-
results[id] = {};
|
|
291
|
-
const {needMin, needMax, combineMaxMin} = weights[id];
|
|
292
|
-
results[id].aggregationTexture = textures[id];
|
|
293
|
-
results[id].aggregationBuffer = this.device.readPixelsToBufferWebGL(framebuffers[id], {
|
|
294
|
-
target: weights[id].aggregationBuffer, // update if a buffer is provided
|
|
295
|
-
sourceType: GL.FLOAT
|
|
296
|
-
});
|
|
297
|
-
if (needMin && needMax && combineMaxMin) {
|
|
298
|
-
results[id].maxMinBuffer = this.device.readPixelsToBufferWebGL(maxMinFramebuffers[id], {
|
|
299
|
-
target: weights[id].maxMinBuffer, // update if a buffer is provided
|
|
300
|
-
sourceType: GL.FLOAT
|
|
301
|
-
});
|
|
302
|
-
results[id].maxMinTexture = resources[`${id}-maxMinTexture`];
|
|
303
|
-
} else {
|
|
304
|
-
if (needMin) {
|
|
305
|
-
results[id].minBuffer = this.device.readPixelsToBufferWebGL(minFramebuffers[id], {
|
|
306
|
-
target: weights[id].minBuffer, // update if a buffer is provided
|
|
307
|
-
sourceType: GL.FLOAT
|
|
308
|
-
});
|
|
309
|
-
results[id].minTexture = resources[`${id}-minTexture`];
|
|
310
|
-
}
|
|
311
|
-
if (needMax) {
|
|
312
|
-
results[id].maxBuffer = this.device.readPixelsToBufferWebGL(maxFramebuffers[id], {
|
|
313
|
-
target: weights[id].maxBuffer, // update if a buffer is provided
|
|
314
|
-
sourceType: GL.FLOAT
|
|
315
|
-
});
|
|
316
|
-
results[id].maxTexture = resources[`${id}-maxTexture`];
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
this._trackGPUResultBuffers(results, weights);
|
|
321
|
-
return results;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
_renderAggregateData(opts) {
|
|
325
|
-
const {
|
|
326
|
-
cellSize,
|
|
327
|
-
projectPoints,
|
|
328
|
-
attributes,
|
|
329
|
-
moduleSettings,
|
|
330
|
-
numCol,
|
|
331
|
-
numRow,
|
|
332
|
-
weights,
|
|
333
|
-
translation,
|
|
334
|
-
scaling
|
|
335
|
-
} = opts;
|
|
336
|
-
const {maxMinFramebuffers, minFramebuffers, maxFramebuffers} = this.state;
|
|
337
|
-
|
|
338
|
-
const gridSize = [numCol, numRow];
|
|
339
|
-
const parameters = {
|
|
340
|
-
blend: true,
|
|
341
|
-
depthTest: false,
|
|
342
|
-
blendFunc: [GL.ONE, GL.ONE]
|
|
343
|
-
};
|
|
344
|
-
const uniforms = {
|
|
345
|
-
cellSize,
|
|
346
|
-
gridSize,
|
|
347
|
-
projectPoints,
|
|
348
|
-
translation,
|
|
349
|
-
scaling
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
for (const id in weights) {
|
|
353
|
-
const {needMin, needMax} = weights[id];
|
|
354
|
-
const combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
|
|
355
|
-
this._renderToWeightsTexture({
|
|
356
|
-
id,
|
|
357
|
-
parameters,
|
|
358
|
-
moduleSettings,
|
|
359
|
-
uniforms,
|
|
360
|
-
gridSize,
|
|
361
|
-
attributes,
|
|
362
|
-
weights
|
|
363
|
-
});
|
|
364
|
-
if (combineMaxMin) {
|
|
365
|
-
this._renderToMaxMinTexture({
|
|
366
|
-
id,
|
|
367
|
-
parameters: {...parameters, blendEquation: MAX_MIN_BLEND_EQUATION},
|
|
368
|
-
gridSize,
|
|
369
|
-
minOrMaxFb: maxMinFramebuffers[id],
|
|
370
|
-
clearParams: {clearColor: [0, 0, 0, MAX_32_BIT_FLOAT]},
|
|
371
|
-
combineMaxMin
|
|
372
|
-
});
|
|
373
|
-
} else {
|
|
374
|
-
if (needMin) {
|
|
375
|
-
this._renderToMaxMinTexture({
|
|
376
|
-
id,
|
|
377
|
-
parameters: {...parameters, blendEquation: MIN_BLEND_EQUATION},
|
|
378
|
-
gridSize,
|
|
379
|
-
minOrMaxFb: minFramebuffers[id],
|
|
380
|
-
clearParams: {clearColor: [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0]},
|
|
381
|
-
combineMaxMin
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
if (needMax) {
|
|
385
|
-
this._renderToMaxMinTexture({
|
|
386
|
-
id,
|
|
387
|
-
parameters: {...parameters, blendEquation: MAX_BLEND_EQUATION},
|
|
388
|
-
gridSize,
|
|
389
|
-
minOrMaxFb: maxFramebuffers[id],
|
|
390
|
-
clearParams: {clearColor: [0, 0, 0, 0]},
|
|
391
|
-
combineMaxMin
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// render all aggregated grid-cells to generate Min, Max or MaxMin data texture
|
|
399
|
-
_renderToMaxMinTexture(opts) {
|
|
400
|
-
const {id, gridSize, minOrMaxFb, combineMaxMin, clearParams = {}} = opts;
|
|
401
|
-
const {framebuffers} = this.state;
|
|
402
|
-
const {allAggregationModel} = this;
|
|
403
|
-
|
|
404
|
-
this.device.withParametersWebGL(
|
|
405
|
-
{
|
|
406
|
-
...clearParams,
|
|
407
|
-
framebuffer: minOrMaxFb,
|
|
408
|
-
viewport: [0, 0, gridSize[0], gridSize[1]]
|
|
409
|
-
},
|
|
410
|
-
() => {
|
|
411
|
-
this.device.clearWebGL({color: true});
|
|
412
|
-
|
|
413
|
-
// allAggregationModel.setParameters(parameters);
|
|
414
|
-
allAggregationModel.setUniforms({gridSize, combineMaxMin});
|
|
415
|
-
allAggregationModel.setBindings({uSampler: framebuffers[id].texture});
|
|
416
|
-
allAggregationModel.draw();
|
|
417
|
-
// TODO - we need to create a render pass for the aggregation
|
|
418
|
-
// allAggregationModel.draw(renderPass);
|
|
419
|
-
}
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// render all data points to aggregate weights
|
|
424
|
-
_renderToWeightsTexture(opts) {
|
|
425
|
-
const {id, parameters, moduleSettings, uniforms, gridSize, weights} = opts;
|
|
426
|
-
const {framebuffers, equations, weightAttributes} = this.state;
|
|
427
|
-
const {gridAggregationModel} = this;
|
|
428
|
-
const {operation} = weights[id];
|
|
429
|
-
|
|
430
|
-
const clearColor =
|
|
431
|
-
operation === AGGREGATION_OPERATION.MIN
|
|
432
|
-
? [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0]
|
|
433
|
-
: [0, 0, 0, 0];
|
|
434
|
-
this.device.withParametersWebGL(
|
|
435
|
-
{
|
|
436
|
-
framebuffer: framebuffers[id],
|
|
437
|
-
viewport: [0, 0, gridSize[0], gridSize[1]],
|
|
438
|
-
clearColor
|
|
439
|
-
},
|
|
440
|
-
() => {
|
|
441
|
-
this.device.clearWebGL({color: true});
|
|
442
|
-
|
|
443
|
-
const attributes = {weights: weightAttributes[id]};
|
|
444
|
-
gridAggregationModel.draw({
|
|
445
|
-
parameters: {...parameters, blendEquation: equations[id]},
|
|
446
|
-
moduleSettings,
|
|
447
|
-
uniforms,
|
|
448
|
-
attributes
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
);
|
|
452
|
-
|
|
453
|
-
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
454
|
-
const {meanTextures, textures} = this.state;
|
|
455
|
-
const transformOptions = {
|
|
456
|
-
_sourceTextures: {aggregationValues: meanTextures[id]}, // contains aggregated data
|
|
457
|
-
_targetTexture: textures[id], // store mean values,
|
|
458
|
-
elementCount: textures[id].width * textures[id].height
|
|
459
|
-
};
|
|
460
|
-
if (this.meanTransform) {
|
|
461
|
-
this.meanTransform.update(transformOptions);
|
|
462
|
-
} else {
|
|
463
|
-
this.meanTransform = getMeanTransform(this.device, transformOptions);
|
|
464
|
-
}
|
|
465
|
-
this.meanTransform.run({
|
|
466
|
-
parameters: {
|
|
467
|
-
blend: false,
|
|
468
|
-
depthTest: false
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
// update framebuffer with mean results so device.readPixelsToBufferWebGL returns mean values
|
|
473
|
-
framebuffers[id].attach({[GL.COLOR_ATTACHMENT0]: textures[id]});
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
_runAggregation(opts) {
|
|
478
|
-
this._updateModels(opts);
|
|
479
|
-
this._setupFramebuffers(opts);
|
|
480
|
-
this._renderAggregateData(opts);
|
|
481
|
-
const results = this._getAggregateData(opts);
|
|
482
|
-
this.setState({results});
|
|
483
|
-
return results;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// set up framebuffer for each weight
|
|
487
|
-
/* eslint-disable complexity, max-depth, max-statements*/
|
|
488
|
-
_setupFramebuffers(opts) {
|
|
489
|
-
const {
|
|
490
|
-
textures,
|
|
491
|
-
framebuffers,
|
|
492
|
-
maxMinFramebuffers,
|
|
493
|
-
minFramebuffers,
|
|
494
|
-
maxFramebuffers,
|
|
495
|
-
meanTextures,
|
|
496
|
-
equations
|
|
497
|
-
} = this.state;
|
|
498
|
-
const {weights} = opts;
|
|
499
|
-
const {numCol, numRow} = opts;
|
|
500
|
-
const framebufferSize = {width: numCol, height: numRow};
|
|
501
|
-
for (const id in weights) {
|
|
502
|
-
const {needMin, needMax, combineMaxMin, operation} = weights[id];
|
|
503
|
-
textures[id] =
|
|
504
|
-
weights[id].aggregationTexture ||
|
|
505
|
-
textures[id] ||
|
|
506
|
-
getFloatTexture(this.device, {id: `${id}-texture`, width: numCol, height: numRow});
|
|
507
|
-
textures[id].resize(framebufferSize);
|
|
508
|
-
let texture = textures[id];
|
|
509
|
-
if (operation === AGGREGATION_OPERATION.MEAN) {
|
|
510
|
-
// For MEAN, we first aggregatet into a temp texture
|
|
511
|
-
meanTextures[id] =
|
|
512
|
-
meanTextures[id] ||
|
|
513
|
-
getFloatTexture(this.device, {id: `${id}-mean-texture`, width: numCol, height: numRow});
|
|
514
|
-
meanTextures[id].resize(framebufferSize);
|
|
515
|
-
texture = meanTextures[id];
|
|
516
|
-
}
|
|
517
|
-
if (framebuffers[id]) {
|
|
518
|
-
framebuffers[id].attach({[GL.COLOR_ATTACHMENT0]: texture});
|
|
519
|
-
} else {
|
|
520
|
-
framebuffers[id] = getFramebuffer(this.device, {
|
|
521
|
-
id: `${id}-fb`,
|
|
522
|
-
width: numCol,
|
|
523
|
-
height: numRow,
|
|
524
|
-
texture
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
framebuffers[id].resize(framebufferSize);
|
|
528
|
-
equations[id] = EQUATION_MAP[operation] || EQUATION_MAP[AGGREGATION_OPERATION.SUM];
|
|
529
|
-
// For min/max framebuffers will use default size 1X1
|
|
530
|
-
if (needMin || needMax) {
|
|
531
|
-
if (needMin && needMax && combineMaxMin) {
|
|
532
|
-
if (!maxMinFramebuffers[id]) {
|
|
533
|
-
texture = weights[id].maxMinTexture || this._getMinMaxTexture(`${id}-maxMinTexture`);
|
|
534
|
-
maxMinFramebuffers[id] = getFramebuffer(this.device, {id: `${id}-maxMinFb`, texture});
|
|
535
|
-
}
|
|
536
|
-
} else {
|
|
537
|
-
if (needMin) {
|
|
538
|
-
if (!minFramebuffers[id]) {
|
|
539
|
-
texture = weights[id].minTexture || this._getMinMaxTexture(`${id}-minTexture`);
|
|
540
|
-
minFramebuffers[id] = getFramebuffer(this.device, {
|
|
541
|
-
id: `${id}-minFb`,
|
|
542
|
-
texture
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
if (needMax) {
|
|
547
|
-
if (!maxFramebuffers[id]) {
|
|
548
|
-
texture = weights[id].maxTexture || this._getMinMaxTexture(`${id}-maxTexture`);
|
|
549
|
-
maxFramebuffers[id] = getFramebuffer(this.device, {
|
|
550
|
-
id: `${id}-maxFb`,
|
|
551
|
-
texture
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
/* eslint-enable complexity, max-depth, max-statements */
|
|
560
|
-
|
|
561
|
-
_getMinMaxTexture(name) {
|
|
562
|
-
const {resources} = this.state;
|
|
563
|
-
if (!resources[name]) {
|
|
564
|
-
resources[name] = getFloatTexture(this.device, {id: 'resourceName'});
|
|
565
|
-
}
|
|
566
|
-
return resources[name];
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
_setupModels({numCol = 0, numRow = 0} = {}) {
|
|
570
|
-
const {shaderOptions} = this.state;
|
|
571
|
-
this.gridAggregationModel?.destroy();
|
|
572
|
-
this.gridAggregationModel = getAggregationModel(this.device, shaderOptions);
|
|
573
|
-
if (!this.allAggregationModel) {
|
|
574
|
-
const instanceCount = numCol * numRow;
|
|
575
|
-
this.allAggregationModel = getAllAggregationModel(this.device, instanceCount);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// set up buffers for all weights
|
|
580
|
-
_setupWeightAttributes(opts) {
|
|
581
|
-
const {weightAttributes} = this.state;
|
|
582
|
-
const {weights} = opts;
|
|
583
|
-
for (const id in weights) {
|
|
584
|
-
weightAttributes[id] = opts.attributes[id];
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
/** GPU Aggregation results are provided in Buffers, if new Buffer objects are created track them for later deletion. */
|
|
589
|
-
/* eslint-disable max-depth */
|
|
590
|
-
_trackGPUResultBuffers(results, weights) {
|
|
591
|
-
const {resources} = this.state;
|
|
592
|
-
for (const id in results) {
|
|
593
|
-
if (results[id]) {
|
|
594
|
-
for (const bufferName of BUFFER_NAMES) {
|
|
595
|
-
if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
|
|
596
|
-
// No result buffer is provided in weights object, `device.readPixelsToBufferWebGL` has created a new Buffer object
|
|
597
|
-
// collect the new buffer for garabge collection
|
|
598
|
-
const name = `gpu-result-${id}-${bufferName}`;
|
|
599
|
-
if (resources[name]) {
|
|
600
|
-
resources[name].delete();
|
|
601
|
-
}
|
|
602
|
-
resources[name] = results[id][bufferName];
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
/* eslint-enable max-depth */
|
|
609
|
-
|
|
610
|
-
_updateModels(opts) {
|
|
611
|
-
const {vertexCount, attributes, numCol, numRow} = opts;
|
|
612
|
-
const {modelDirty} = this.state;
|
|
613
|
-
|
|
614
|
-
if (modelDirty) {
|
|
615
|
-
this._setupModels(opts);
|
|
616
|
-
this.setState({modelDirty: false});
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// this maps color/elevation to weight name.
|
|
620
|
-
this._setupWeightAttributes(opts);
|
|
621
|
-
|
|
622
|
-
this.gridAggregationModel.setVertexCount(vertexCount);
|
|
623
|
-
this.gridAggregationModel.setAttributes(attributes);
|
|
624
|
-
|
|
625
|
-
this.allAggregationModel.setInstanceCount(numCol * numRow);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// HELPER METHODS
|
|
630
|
-
|
|
631
|
-
function normalizeWeightParams(weights) {
|
|
632
|
-
const result = {};
|
|
633
|
-
for (const id in weights) {
|
|
634
|
-
result[id] = {...DEFAULT_WEIGHT_PARAMS, ...weights[id]};
|
|
635
|
-
}
|
|
636
|
-
return result;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
function deleteResources(resources) {
|
|
640
|
-
resources = Array.isArray(resources) ? resources : [resources];
|
|
641
|
-
resources.forEach(obj => {
|
|
642
|
-
for (const name in obj) {
|
|
643
|
-
obj[name].delete();
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
function getAggregationModel(device: Device, shaderOptions) {
|
|
649
|
-
const shaders = mergeShaders(
|
|
650
|
-
{
|
|
651
|
-
vs: AGGREGATE_TO_GRID_VS,
|
|
652
|
-
fs: AGGREGATE_TO_GRID_FS,
|
|
653
|
-
modules: [fp64arithmetic, project32]
|
|
654
|
-
},
|
|
655
|
-
shaderOptions
|
|
656
|
-
);
|
|
657
|
-
|
|
658
|
-
return new Model(device, {
|
|
659
|
-
id: 'Grid-Aggregation-Model',
|
|
660
|
-
vertexCount: 1,
|
|
661
|
-
drawMode: GL.POINTS,
|
|
662
|
-
shaderAssembler: getShaderAssembler(),
|
|
663
|
-
...shaders
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
function getAllAggregationModel(device: Device, instanceCount: number): Model {
|
|
668
|
-
return new Model(device, {
|
|
669
|
-
id: 'All-Aggregation-Model',
|
|
670
|
-
vs: AGGREGATE_ALL_VS,
|
|
671
|
-
fs: AGGREGATE_ALL_FS,
|
|
672
|
-
modules: [fp64arithmetic],
|
|
673
|
-
vertexCount: 1,
|
|
674
|
-
topology: 'point-list',
|
|
675
|
-
isInstanced: true,
|
|
676
|
-
instanceCount,
|
|
677
|
-
attributes: {
|
|
678
|
-
// @ts-expect-error
|
|
679
|
-
position: [0, 0]
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function getMeanTransform(device: Device, opts) {
|
|
685
|
-
return new TextureTransform(device, {
|
|
686
|
-
vs: TRANSFORM_MEAN_VS,
|
|
687
|
-
_targetTextureVarying: 'meanValues',
|
|
688
|
-
...opts
|
|
689
|
-
});
|
|
690
|
-
}
|