@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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Model, ModelProps } from '@luma.gl/engine';
|
|
2
|
+
import type { Device, Texture } from '@luma.gl/core';
|
|
3
|
+
import type { WebGLAggregatorProps } from "./webgl-aggregator.js";
|
|
4
|
+
import type { AggregationOperation } from "../aggregator.js";
|
|
5
|
+
export declare const TEXTURE_WIDTH = 1024;
|
|
6
|
+
/**
|
|
7
|
+
* This class manages the resources for performing the first step of aggregation
|
|
8
|
+
* Sort a list of data points into a number of bins
|
|
9
|
+
*/
|
|
10
|
+
export declare class WebGLBinSorter {
|
|
11
|
+
device: Device;
|
|
12
|
+
model: Model;
|
|
13
|
+
/**
|
|
14
|
+
* A packed texture in which each pixel represents a bin.
|
|
15
|
+
* The index of the pixel in the memory layout is the bin index.
|
|
16
|
+
* Alpha value is the count of data points that fall into this bin
|
|
17
|
+
* R,G,B values are the aggregated values of each channel:
|
|
18
|
+
* - Sum of all data points if operation is 'SUM', or 'MEAN'
|
|
19
|
+
* - Min of all data points if operation is 'MIN'
|
|
20
|
+
* - Max of all data points if operation is 'MAX'
|
|
21
|
+
*/
|
|
22
|
+
private binsFBO;
|
|
23
|
+
constructor(device: Device, props: WebGLAggregatorProps);
|
|
24
|
+
get texture(): Texture | null;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
getBinValues(index: number): Float32Array | null;
|
|
27
|
+
setDimensions(binCount: number, binIdRange: [number, number][]): void;
|
|
28
|
+
setModelProps(props: Pick<ModelProps, 'vertexCount' | 'uniforms' | 'attributes' | 'constantAttributes'> & {
|
|
29
|
+
shaderModuleProps?: Record<string, any>;
|
|
30
|
+
}): void;
|
|
31
|
+
/** Update aggregation */
|
|
32
|
+
update(
|
|
33
|
+
/** The aggregation operation for each channel. Use null to skip update. */
|
|
34
|
+
operations: (AggregationOperation | null)[]): void;
|
|
35
|
+
/** Recalculate aggregation on the given channels using the given operation */
|
|
36
|
+
private _updateBins;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=webgl-bin-sorter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-bin-sorter.d.ts","sourceRoot":"","sources":["../../../../src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EAAC,MAAM,EAAe,OAAO,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAC,oBAAoB,EAAC,8BAA2B;AAC7D,OAAO,KAAK,EAAC,oBAAoB,EAAC,yBAAsB;AAOxD,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC;;;GAGG;AACH,qBAAa,cAAc;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IAEb;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,CAA4B;gBAE/B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;IAKvD,IAAI,OAAO,IAAI,OAAO,GAAG,IAAI,CAE5B;IAED,OAAO;IAMP,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAehD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAuB9D,aAAa,CACX,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,UAAU,GAAG,YAAY,GAAG,oBAAoB,CAAC,GAAG;QAC1F,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACzC;IAiBH,yBAAyB;IACzB,MAAM;IACJ,2EAA2E;IAC3E,UAAU,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAAC,EAAE;IAW7C,8EAA8E;IAC9E,OAAO,CAAC,WAAW;CAqCpB"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Model } from '@luma.gl/engine';
|
|
5
|
+
import { createRenderTarget } from "./utils.js";
|
|
6
|
+
import { binSorterUniforms } from "./bin-sorter-uniforms.js";
|
|
7
|
+
const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPU color mask RED, GREEN, BLUE, ALPHA
|
|
8
|
+
const MAX_FLOAT32 = 3e38;
|
|
9
|
+
const EMPTY_MASKS = { SUM: 0, MEAN: 0, MIN: 0, MAX: 0, COUNT: 0 };
|
|
10
|
+
export const TEXTURE_WIDTH = 1024;
|
|
11
|
+
/**
|
|
12
|
+
* This class manages the resources for performing the first step of aggregation
|
|
13
|
+
* Sort a list of data points into a number of bins
|
|
14
|
+
*/
|
|
15
|
+
export class WebGLBinSorter {
|
|
16
|
+
constructor(device, props) {
|
|
17
|
+
/**
|
|
18
|
+
* A packed texture in which each pixel represents a bin.
|
|
19
|
+
* The index of the pixel in the memory layout is the bin index.
|
|
20
|
+
* Alpha value is the count of data points that fall into this bin
|
|
21
|
+
* R,G,B values are the aggregated values of each channel:
|
|
22
|
+
* - Sum of all data points if operation is 'SUM', or 'MEAN'
|
|
23
|
+
* - Min of all data points if operation is 'MIN'
|
|
24
|
+
* - Max of all data points if operation is 'MAX'
|
|
25
|
+
*/
|
|
26
|
+
this.binsFBO = null;
|
|
27
|
+
this.device = device;
|
|
28
|
+
this.model = createModel(device, props);
|
|
29
|
+
}
|
|
30
|
+
get texture() {
|
|
31
|
+
return this.binsFBO ? this.binsFBO.colorAttachments[0].texture : null;
|
|
32
|
+
}
|
|
33
|
+
destroy() {
|
|
34
|
+
this.model.destroy();
|
|
35
|
+
this.binsFBO?.colorAttachments[0].texture.destroy();
|
|
36
|
+
this.binsFBO?.destroy();
|
|
37
|
+
}
|
|
38
|
+
getBinValues(index) {
|
|
39
|
+
if (!this.binsFBO) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const x = index % TEXTURE_WIDTH;
|
|
43
|
+
const y = Math.floor(index / TEXTURE_WIDTH);
|
|
44
|
+
const buffer = this.device.readPixelsToArrayWebGL(this.binsFBO, {
|
|
45
|
+
sourceX: x,
|
|
46
|
+
sourceY: y,
|
|
47
|
+
sourceWidth: 1,
|
|
48
|
+
sourceHeight: 1
|
|
49
|
+
}).buffer;
|
|
50
|
+
return new Float32Array(buffer);
|
|
51
|
+
}
|
|
52
|
+
setDimensions(binCount, binIdRange) {
|
|
53
|
+
const width = TEXTURE_WIDTH;
|
|
54
|
+
const height = Math.ceil(binCount / width);
|
|
55
|
+
// Only destroy existing texture if it is not large enough
|
|
56
|
+
if (!this.binsFBO) {
|
|
57
|
+
this.binsFBO = createRenderTarget(this.device, width, height);
|
|
58
|
+
}
|
|
59
|
+
else if (this.binsFBO.height < height) {
|
|
60
|
+
this.binsFBO.resize({ width, height });
|
|
61
|
+
}
|
|
62
|
+
const binSorterProps = {
|
|
63
|
+
binIdRange: [
|
|
64
|
+
binIdRange[0][0],
|
|
65
|
+
binIdRange[0][1],
|
|
66
|
+
binIdRange[1]?.[0] || 0,
|
|
67
|
+
binIdRange[1]?.[1] || 0
|
|
68
|
+
],
|
|
69
|
+
targetSize: [this.binsFBO.width, this.binsFBO.height]
|
|
70
|
+
};
|
|
71
|
+
this.model.shaderInputs.setProps({ binSorter: binSorterProps });
|
|
72
|
+
}
|
|
73
|
+
setModelProps(props) {
|
|
74
|
+
const model = this.model;
|
|
75
|
+
if (props.attributes) {
|
|
76
|
+
model.setAttributes(props.attributes);
|
|
77
|
+
}
|
|
78
|
+
if (props.constantAttributes) {
|
|
79
|
+
model.setConstantAttributes(props.constantAttributes);
|
|
80
|
+
}
|
|
81
|
+
if (props.vertexCount !== undefined) {
|
|
82
|
+
model.setVertexCount(props.vertexCount);
|
|
83
|
+
}
|
|
84
|
+
if (props.shaderModuleProps) {
|
|
85
|
+
model.shaderInputs.setProps(props.shaderModuleProps);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Update aggregation */
|
|
89
|
+
update(
|
|
90
|
+
/** The aggregation operation for each channel. Use null to skip update. */
|
|
91
|
+
operations) {
|
|
92
|
+
if (!this.binsFBO) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const masks = getMaskByOperation(operations);
|
|
96
|
+
this._updateBins('SUM', masks.SUM + masks.MEAN);
|
|
97
|
+
this._updateBins('MIN', masks.MIN);
|
|
98
|
+
this._updateBins('MAX', masks.MAX);
|
|
99
|
+
}
|
|
100
|
+
/** Recalculate aggregation on the given channels using the given operation */
|
|
101
|
+
_updateBins(operation,
|
|
102
|
+
/** GPU bit mask of one or more channels that should be updated */
|
|
103
|
+
colorMask) {
|
|
104
|
+
if (colorMask === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
colorMask |= COLOR_CHANNELS[3]; // Also renders to the alpha channel (point count)
|
|
108
|
+
const model = this.model;
|
|
109
|
+
const target = this.binsFBO;
|
|
110
|
+
const initialValue = operation === 'MAX' ? -MAX_FLOAT32 : operation === 'MIN' ? MAX_FLOAT32 : 0;
|
|
111
|
+
const renderPass = this.device.beginRenderPass({
|
|
112
|
+
id: `gpu-aggregation-${operation}`,
|
|
113
|
+
framebuffer: target,
|
|
114
|
+
parameters: {
|
|
115
|
+
viewport: [0, 0, target.width, target.height],
|
|
116
|
+
colorMask
|
|
117
|
+
},
|
|
118
|
+
clearColor: [initialValue, initialValue, initialValue, 0],
|
|
119
|
+
clearDepth: false,
|
|
120
|
+
clearStencil: false
|
|
121
|
+
});
|
|
122
|
+
model.setParameters({
|
|
123
|
+
blend: true,
|
|
124
|
+
blendColorSrcFactor: 'one',
|
|
125
|
+
blendColorDstFactor: 'one',
|
|
126
|
+
blendAlphaSrcFactor: 'one',
|
|
127
|
+
blendAlphaDstFactor: 'one',
|
|
128
|
+
blendColorOperation: operation === 'MAX' ? 'max' : operation === 'MIN' ? 'min' : 'add',
|
|
129
|
+
blendAlphaOperation: 'add'
|
|
130
|
+
});
|
|
131
|
+
model.draw(renderPass);
|
|
132
|
+
renderPass.end();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Convert a [channel -> operation] map to a [operation -> GPU color mask] map */
|
|
136
|
+
function getMaskByOperation(operations) {
|
|
137
|
+
const result = { ...EMPTY_MASKS };
|
|
138
|
+
for (let channel = 0; channel < operations.length; channel++) {
|
|
139
|
+
const op = operations[channel];
|
|
140
|
+
if (op) {
|
|
141
|
+
result[op] += COLOR_CHANNELS[channel];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
function createModel(device, props) {
|
|
147
|
+
let userVs = props.vs;
|
|
148
|
+
if (props.dimensions === 2) {
|
|
149
|
+
// If user provides 2d bin IDs, convert them to 1d indices for data packing
|
|
150
|
+
userVs += /* glsl */ `
|
|
151
|
+
void getBin(out int binId) {
|
|
152
|
+
ivec2 binId2;
|
|
153
|
+
getBin(binId2);
|
|
154
|
+
if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {
|
|
155
|
+
binId = -1;
|
|
156
|
+
} else {
|
|
157
|
+
binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
const vs = `\
|
|
163
|
+
#version 300 es
|
|
164
|
+
#define SHADER_NAME gpu-aggregation-sort-bins-vertex
|
|
165
|
+
|
|
166
|
+
${userVs}
|
|
167
|
+
|
|
168
|
+
out vec3 v_Value;
|
|
169
|
+
|
|
170
|
+
void main() {
|
|
171
|
+
int binIndex;
|
|
172
|
+
getBin(binIndex);
|
|
173
|
+
binIndex = binIndex - binSorter.binIdRange.x;
|
|
174
|
+
if (binIndex < 0) {
|
|
175
|
+
gl_Position = vec4(0.);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
int row = binIndex / binSorter.targetSize.x;
|
|
179
|
+
int col = binIndex - row * binSorter.targetSize.x;
|
|
180
|
+
vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;
|
|
181
|
+
gl_Position = vec4(position, 0.0, 1.0);
|
|
182
|
+
gl_PointSize = 1.0;
|
|
183
|
+
|
|
184
|
+
#if NUM_CHANNELS == 3
|
|
185
|
+
getValue(v_Value);
|
|
186
|
+
#elif NUM_CHANNELS == 2
|
|
187
|
+
getValue(v_Value.xy);
|
|
188
|
+
#else
|
|
189
|
+
getValue(v_Value.x);
|
|
190
|
+
#endif
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
const fs = /* glsl */ `\
|
|
194
|
+
#version 300 es
|
|
195
|
+
#define SHADER_NAME gpu-aggregation-sort-bins-fragment
|
|
196
|
+
|
|
197
|
+
precision highp float;
|
|
198
|
+
|
|
199
|
+
in vec3 v_Value;
|
|
200
|
+
out vec4 fragColor;
|
|
201
|
+
|
|
202
|
+
void main() {
|
|
203
|
+
fragColor.xyz = v_Value;
|
|
204
|
+
|
|
205
|
+
#ifdef MODULE_GEOMETRY
|
|
206
|
+
geometry.uv = vec2(0.);
|
|
207
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
208
|
+
#endif
|
|
209
|
+
|
|
210
|
+
fragColor.w = 1.0;
|
|
211
|
+
}
|
|
212
|
+
`;
|
|
213
|
+
const model = new Model(device, {
|
|
214
|
+
bufferLayout: props.bufferLayout,
|
|
215
|
+
modules: [...(props.modules || []), binSorterUniforms],
|
|
216
|
+
defines: { ...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount },
|
|
217
|
+
isInstanced: false,
|
|
218
|
+
vs,
|
|
219
|
+
fs,
|
|
220
|
+
topology: 'point-list'
|
|
221
|
+
});
|
|
222
|
+
return model;
|
|
223
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CPUAggregator } from "./cpu-aggregator/cpu-aggregator.js";
|
|
2
|
+
export { WebGLAggregator } from "./gpu-aggregator/webgl-aggregator.js";
|
|
3
|
+
export type { Aggregator, AggregatedBin, AggregationOperation, AggregationProps } from "./aggregator.js";
|
|
4
|
+
export type { CPUAggregatorProps } from "./cpu-aggregator/cpu-aggregator.js";
|
|
5
|
+
export type { WebGLAggregatorProps } from "./gpu-aggregator/webgl-aggregator.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/aggregator/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,2CAAwC;AAC9D,OAAO,EAAC,eAAe,EAAC,6CAA0C;AAElE,YAAY,EAAC,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,gBAAgB,EAAC,wBAAqB;AACpG,YAAY,EAAC,kBAAkB,EAAC,2CAAwC;AACxE,YAAY,EAAC,oBAAoB,EAAC,6CAA0C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Type assigned to e.g. getColorValue/getElevationValue props in aggregation layers (e.g. CPUGridLayer, HexagonLayer)*/
|
|
2
|
+
export type AggregateAccessor<DataT = any> = (
|
|
3
|
+
/** a list of objects whose positions fall inside this cell. */
|
|
4
|
+
objects: DataT[], objectInfo: {
|
|
5
|
+
/** the indices of `objects` in the original data. */
|
|
6
|
+
indices: number[];
|
|
7
|
+
/** the value of the `data` prop */
|
|
8
|
+
data: any;
|
|
9
|
+
}) => number;
|
|
10
|
+
export type ScaleType = 'linear' | 'quantize' | 'quantile' | 'ordinal';
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAIA,yHAAyH;AACzH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI;AAC3C,+DAA+D;AAC/D,OAAO,EAAE,KAAK,EAAE,EAChB,UAAU,EAAE;IACV,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mCAAmC;IACnC,IAAI,EAAE,GAAG,CAAC;CACX,KACE,MAAM,CAAC;AAEZ,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Utility to estimate binIdRange as expected by AggregatorProps */
|
|
2
|
+
export declare function getBinIdRange({ dataBounds, getBinId, padding }: {
|
|
3
|
+
/** Bounds of the input data */
|
|
4
|
+
dataBounds: [min: number[], max: number[]];
|
|
5
|
+
/** Given a data point, returns the bin id that it belongs to */
|
|
6
|
+
getBinId: (p: number[]) => number[];
|
|
7
|
+
/** Add a border around the result to avoid clipping */
|
|
8
|
+
padding?: number;
|
|
9
|
+
}): [number, number][];
|
|
10
|
+
//# sourceMappingURL=bounds-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounds-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/bounds-utils.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,QAAQ,EACR,OAAW,EACZ,EAAE;IACD,+BAA+B;IAC/B,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,gEAAgE;IAChE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAiBrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** Utility to estimate binIdRange as expected by AggregatorProps */
|
|
5
|
+
export function getBinIdRange({ dataBounds, getBinId, padding = 0 }) {
|
|
6
|
+
const corners = [
|
|
7
|
+
dataBounds[0],
|
|
8
|
+
dataBounds[1],
|
|
9
|
+
[dataBounds[0][0], dataBounds[1][1]],
|
|
10
|
+
[dataBounds[1][0], dataBounds[0][1]]
|
|
11
|
+
].map(p => getBinId(p));
|
|
12
|
+
const minX = Math.min(...corners.map(p => p[0])) - padding;
|
|
13
|
+
const minY = Math.min(...corners.map(p => p[1])) - padding;
|
|
14
|
+
const maxX = Math.max(...corners.map(p => p[0])) + padding + 1;
|
|
15
|
+
const maxY = Math.max(...corners.map(p => p[1])) + padding + 1;
|
|
16
|
+
return [
|
|
17
|
+
[minX, maxX],
|
|
18
|
+
[minY, maxY]
|
|
19
|
+
];
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Color } from '@deck.gl/core';
|
|
2
|
+
import type { Device, Texture } from '@luma.gl/core';
|
|
3
|
+
import type { NumericArray, TypedArray, TypedArrayConstructor } from '@math.gl/types';
|
|
4
|
+
import type { ScaleType } from "../types.js";
|
|
5
|
+
export declare const defaultColorRange: Color[];
|
|
6
|
+
export declare function colorRangeToFlatArray(colorRange: Color[] | NumericArray, normalize?: boolean, ArrayType?: TypedArrayConstructor): TypedArray;
|
|
7
|
+
export declare const COLOR_RANGE_FILTER: Record<ScaleType, 'linear' | 'nearest'>;
|
|
8
|
+
export declare function updateColorRangeTexture(texture: Texture, type: ScaleType): void;
|
|
9
|
+
export declare function createColorRangeTexture(device: Device, colorRange: Color[] | NumericArray, type?: ScaleType): Texture;
|
|
10
|
+
//# sourceMappingURL=color-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/color-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAC,SAAS,EAAC,oBAAiB;AAExC,eAAO,MAAM,iBAAiB,EAAE,KAAK,EAOpC,CAAC;AAGF,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,EAClC,SAAS,UAAQ,EACjB,SAAS,GAAE,qBAAoC,GAC9C,UAAU,CA0BZ;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,QAAQ,GAAG,SAAS,CAK7D,CAAC;AAEX,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,QAKxE;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,EAClC,IAAI,GAAE,SAAoB,GACzB,OAAO,CAgBT"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export const defaultColorRange = [
|
|
5
|
+
[255, 255, 178],
|
|
6
|
+
[254, 217, 118],
|
|
7
|
+
[254, 178, 76],
|
|
8
|
+
[253, 141, 60],
|
|
9
|
+
[240, 59, 32],
|
|
10
|
+
[189, 0, 38]
|
|
11
|
+
];
|
|
12
|
+
// Converts a colorRange array to a flat array with 4 components per color
|
|
13
|
+
export function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float32Array) {
|
|
14
|
+
let flatArray;
|
|
15
|
+
if (Number.isFinite(colorRange[0])) {
|
|
16
|
+
// its already a flat array.
|
|
17
|
+
flatArray = new ArrayType(colorRange);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// flatten it
|
|
21
|
+
flatArray = new ArrayType(colorRange.length * 4);
|
|
22
|
+
let index = 0;
|
|
23
|
+
for (let i = 0; i < colorRange.length; i++) {
|
|
24
|
+
const color = colorRange[i];
|
|
25
|
+
flatArray[index++] = color[0];
|
|
26
|
+
flatArray[index++] = color[1];
|
|
27
|
+
flatArray[index++] = color[2];
|
|
28
|
+
flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (normalize) {
|
|
32
|
+
for (let i = 0; i < flatArray.length; i++) {
|
|
33
|
+
flatArray[i] /= 255;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return flatArray;
|
|
37
|
+
}
|
|
38
|
+
export const COLOR_RANGE_FILTER = {
|
|
39
|
+
linear: 'linear',
|
|
40
|
+
quantile: 'nearest',
|
|
41
|
+
quantize: 'nearest',
|
|
42
|
+
ordinal: 'nearest'
|
|
43
|
+
};
|
|
44
|
+
export function updateColorRangeTexture(texture, type) {
|
|
45
|
+
texture.setSampler({
|
|
46
|
+
minFilter: COLOR_RANGE_FILTER[type],
|
|
47
|
+
magFilter: COLOR_RANGE_FILTER[type]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function createColorRangeTexture(device, colorRange, type = 'linear') {
|
|
51
|
+
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
|
|
52
|
+
return device.createTexture({
|
|
53
|
+
format: 'rgba8unorm',
|
|
54
|
+
mipmaps: false,
|
|
55
|
+
sampler: {
|
|
56
|
+
minFilter: COLOR_RANGE_FILTER[type],
|
|
57
|
+
magFilter: COLOR_RANGE_FILTER[type],
|
|
58
|
+
addressModeU: 'clamp-to-edge',
|
|
59
|
+
addressModeV: 'clamp-to-edge'
|
|
60
|
+
},
|
|
61
|
+
data: colors,
|
|
62
|
+
width: colors.length / 4,
|
|
63
|
+
height: 1
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/prop-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA,MAQ5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export function filterProps(props, filterKeys) {
|
|
5
|
+
const filteredProps = {};
|
|
6
|
+
for (const key in props) {
|
|
7
|
+
if (!filterKeys.includes(key)) {
|
|
8
|
+
filteredProps[key] = props[key];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return filteredProps;
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { BinaryAttribute } from '@deck.gl/core';
|
|
2
|
+
import type { ScaleType } from "../types.js";
|
|
3
|
+
type ScaleProps = {
|
|
4
|
+
scaleType: ScaleType;
|
|
5
|
+
/** Trim the lower end of the domain by this percentile. Set to `0` to disable. */
|
|
6
|
+
lowerPercentile: number;
|
|
7
|
+
/** Trim the upper end of the domain by this percentile. Set to `100` to disable. */
|
|
8
|
+
upperPercentile: number;
|
|
9
|
+
};
|
|
10
|
+
/** Applies a scale to BinaryAttribute */
|
|
11
|
+
export declare class AttributeWithScale {
|
|
12
|
+
/** Input values accessor. Has either a `value` (CPU aggregation) or a `buffer` (GPU aggregation) */
|
|
13
|
+
private readonly input;
|
|
14
|
+
private readonly inputLength;
|
|
15
|
+
private props;
|
|
16
|
+
private _percentile?;
|
|
17
|
+
private _ordinal?;
|
|
18
|
+
/** Output values accessor */
|
|
19
|
+
attribute: BinaryAttribute;
|
|
20
|
+
/** [min, max] of attribute values, or null if unknown */
|
|
21
|
+
domain: [number, number] | null;
|
|
22
|
+
/** Valid domain if lower/upper percentile are defined */
|
|
23
|
+
cutoff: [number, number] | null;
|
|
24
|
+
constructor(input: BinaryAttribute, inputLength: number);
|
|
25
|
+
private getScalePercentile;
|
|
26
|
+
private getScaleOrdinal;
|
|
27
|
+
/** Returns the [lowerCutoff, upperCutoff] of scaled values, or null if not applicable */
|
|
28
|
+
private getCutoff;
|
|
29
|
+
update(props: ScaleProps): this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Transform an array of values to ordinal indices
|
|
33
|
+
*/
|
|
34
|
+
export declare function applyScaleOrdinal(values: Float32Array): {
|
|
35
|
+
attribute: BinaryAttribute;
|
|
36
|
+
domain: number[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Transform an array of values to percentiles
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyScaleQuantile(values: Float32Array, rangeLength?: number): {
|
|
42
|
+
attribute: BinaryAttribute;
|
|
43
|
+
domain: number[];
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=scale-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/scale-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,SAAS,EAAC,oBAAiB;AAExC,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,kFAAkF;IAClF,eAAe,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,yCAAyC;AACzC,qBAAa,kBAAkB;IAC7B,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,KAAK,CAIX;IAGF,OAAO,CAAC,WAAW,CAAC,CAAiD;IACrE,OAAO,CAAC,QAAQ,CAAC,CAAiD;IAElE,6BAA6B;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,yDAAyD;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAQ;IACvC,yDAAyD;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAQ;gBAE3B,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM;IAOvD,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,eAAe;IAQvB,yFAAyF;IACzF,OAAO,CAAC,SAAS;IA4BjB,MAAM,CAAC,KAAK,EAAE,UAAU;CAiCzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG;IACvD,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqBA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,WAAW,SAAM,GAChB;IACD,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAgBA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** Applies a scale to BinaryAttribute */
|
|
5
|
+
export class AttributeWithScale {
|
|
6
|
+
constructor(input, inputLength) {
|
|
7
|
+
this.props = {
|
|
8
|
+
scaleType: 'linear',
|
|
9
|
+
lowerPercentile: 0,
|
|
10
|
+
upperPercentile: 100
|
|
11
|
+
};
|
|
12
|
+
/** [min, max] of attribute values, or null if unknown */
|
|
13
|
+
this.domain = null;
|
|
14
|
+
/** Valid domain if lower/upper percentile are defined */
|
|
15
|
+
this.cutoff = null;
|
|
16
|
+
this.input = input;
|
|
17
|
+
this.inputLength = inputLength;
|
|
18
|
+
// No processing is needed with the default scale
|
|
19
|
+
this.attribute = input;
|
|
20
|
+
}
|
|
21
|
+
getScalePercentile() {
|
|
22
|
+
if (!this._percentile) {
|
|
23
|
+
const value = getAttributeValue(this.input, this.inputLength);
|
|
24
|
+
this._percentile = applyScaleQuantile(value);
|
|
25
|
+
}
|
|
26
|
+
return this._percentile;
|
|
27
|
+
}
|
|
28
|
+
getScaleOrdinal() {
|
|
29
|
+
if (!this._ordinal) {
|
|
30
|
+
const value = getAttributeValue(this.input, this.inputLength);
|
|
31
|
+
this._ordinal = applyScaleOrdinal(value);
|
|
32
|
+
}
|
|
33
|
+
return this._ordinal;
|
|
34
|
+
}
|
|
35
|
+
/** Returns the [lowerCutoff, upperCutoff] of scaled values, or null if not applicable */
|
|
36
|
+
getCutoff({ scaleType, lowerPercentile, upperPercentile }) {
|
|
37
|
+
if (scaleType === 'quantile') {
|
|
38
|
+
return [lowerPercentile, upperPercentile - 1];
|
|
39
|
+
}
|
|
40
|
+
if (lowerPercentile > 0 || upperPercentile < 100) {
|
|
41
|
+
const { domain: thresholds } = this.getScalePercentile();
|
|
42
|
+
let lowValue = thresholds[Math.floor(lowerPercentile) - 1] ?? -Infinity;
|
|
43
|
+
let highValue = thresholds[Math.floor(upperPercentile) - 1] ?? Infinity;
|
|
44
|
+
if (scaleType === 'ordinal') {
|
|
45
|
+
const { domain: sortedUniqueValues } = this.getScaleOrdinal();
|
|
46
|
+
lowValue = sortedUniqueValues.findIndex(x => x >= lowValue);
|
|
47
|
+
highValue = sortedUniqueValues.findIndex(x => x > highValue) - 1;
|
|
48
|
+
if (highValue === -2) {
|
|
49
|
+
highValue = sortedUniqueValues.length - 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return [lowValue, highValue];
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
update(props) {
|
|
57
|
+
const oldProps = this.props;
|
|
58
|
+
if (props.scaleType !== oldProps.scaleType) {
|
|
59
|
+
switch (props.scaleType) {
|
|
60
|
+
case 'quantile': {
|
|
61
|
+
const { attribute } = this.getScalePercentile();
|
|
62
|
+
this.attribute = attribute;
|
|
63
|
+
this.domain = [0, 99];
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'ordinal': {
|
|
67
|
+
const { attribute, domain } = this.getScaleOrdinal();
|
|
68
|
+
this.attribute = attribute;
|
|
69
|
+
this.domain = [0, domain.length - 1];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
this.attribute = this.input;
|
|
74
|
+
this.domain = null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (props.scaleType !== oldProps.scaleType ||
|
|
78
|
+
props.lowerPercentile !== oldProps.lowerPercentile ||
|
|
79
|
+
props.upperPercentile !== oldProps.upperPercentile) {
|
|
80
|
+
this.cutoff = this.getCutoff(props);
|
|
81
|
+
}
|
|
82
|
+
this.props = props;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Transform an array of values to ordinal indices
|
|
88
|
+
*/
|
|
89
|
+
export function applyScaleOrdinal(values) {
|
|
90
|
+
const uniqueValues = new Set();
|
|
91
|
+
for (const x of values) {
|
|
92
|
+
if (Number.isFinite(x)) {
|
|
93
|
+
uniqueValues.add(x);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const sortedUniqueValues = Array.from(uniqueValues).sort();
|
|
97
|
+
const domainMap = new Map();
|
|
98
|
+
for (let i = 0; i < sortedUniqueValues.length; i++) {
|
|
99
|
+
domainMap.set(sortedUniqueValues[i], i);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
attribute: {
|
|
103
|
+
value: values.map(x => (Number.isFinite(x) ? domainMap.get(x) : NaN)),
|
|
104
|
+
type: 'float32',
|
|
105
|
+
size: 1
|
|
106
|
+
},
|
|
107
|
+
domain: sortedUniqueValues
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Transform an array of values to percentiles
|
|
112
|
+
*/
|
|
113
|
+
export function applyScaleQuantile(values, rangeLength = 100) {
|
|
114
|
+
const sortedValues = Array.from(values).filter(Number.isFinite).sort(ascending);
|
|
115
|
+
let i = 0;
|
|
116
|
+
const n = Math.max(1, rangeLength);
|
|
117
|
+
const thresholds = new Array(n - 1);
|
|
118
|
+
while (++i < n) {
|
|
119
|
+
thresholds[i - 1] = threshold(sortedValues, i / n);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
attribute: {
|
|
123
|
+
value: values.map(x => (Number.isFinite(x) ? bisectRight(thresholds, x) : NaN)),
|
|
124
|
+
type: 'float32',
|
|
125
|
+
size: 1
|
|
126
|
+
},
|
|
127
|
+
domain: thresholds
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function getAttributeValue(attribute, length) {
|
|
131
|
+
const elementStride = (attribute.stride ?? 4) / 4;
|
|
132
|
+
const elementOffset = (attribute.offset ?? 0) / 4;
|
|
133
|
+
let value = attribute.value;
|
|
134
|
+
if (!value) {
|
|
135
|
+
const bytes = attribute.buffer?.readSyncWebGL(0, elementStride * 4 * length);
|
|
136
|
+
if (bytes) {
|
|
137
|
+
value = new Float32Array(bytes.buffer);
|
|
138
|
+
attribute.value = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (elementStride === 1) {
|
|
142
|
+
return value.subarray(0, length);
|
|
143
|
+
}
|
|
144
|
+
const result = new Float32Array(length);
|
|
145
|
+
for (let i = 0; i < length; i++) {
|
|
146
|
+
result[i] = value[i * elementStride + elementOffset];
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function ascending(a, b) {
|
|
151
|
+
return a - b;
|
|
152
|
+
}
|
|
153
|
+
function threshold(domain, fraction) {
|
|
154
|
+
const domainLength = domain.length;
|
|
155
|
+
if (fraction <= 0 || domainLength < 2) {
|
|
156
|
+
return domain[0];
|
|
157
|
+
}
|
|
158
|
+
if (fraction >= 1) {
|
|
159
|
+
return domain[domainLength - 1];
|
|
160
|
+
}
|
|
161
|
+
const domainFraction = (domainLength - 1) * fraction;
|
|
162
|
+
const lowIndex = Math.floor(domainFraction);
|
|
163
|
+
const low = domain[lowIndex];
|
|
164
|
+
const high = domain[lowIndex + 1];
|
|
165
|
+
return low + (high - low) * (domainFraction - lowIndex);
|
|
166
|
+
}
|
|
167
|
+
function bisectRight(a, x) {
|
|
168
|
+
let lo = 0;
|
|
169
|
+
let hi = a.length;
|
|
170
|
+
while (lo < hi) {
|
|
171
|
+
const mid = (lo + hi) >>> 1;
|
|
172
|
+
if (a[mid] > x) {
|
|
173
|
+
hi = mid;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
lo = mid + 1;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return lo;
|
|
180
|
+
}
|