@deck.gl/aggregation-layers 8.10.0-alpha.7 → 9.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +9372 -356
- package/dist/es5/aggregation-layer.js +4 -6
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +13 -2
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +12 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/cpu-grid-layer/grid-aggregator.js +12 -8
- package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +27 -13
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +19 -10
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +7 -9
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +1 -1
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +3 -3
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +58 -55
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +22 -12
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +2 -0
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +23 -20
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +6 -6
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/es5/utils/cpu-aggregator.js +11 -7
- package/dist/es5/utils/cpu-aggregator.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +7 -2
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +83 -60
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
- package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
- package/dist/es5/utils/prop-utils.js.map +1 -1
- package/dist/es5/utils/resource-utils.js +12 -23
- package/dist/es5/utils/resource-utils.js.map +1 -1
- package/dist/esm/aggregation-layer.js +4 -5
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +7 -1
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -0
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/cpu-grid-layer/grid-aggregator.js +2 -1
- package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +19 -10
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +13 -10
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-aggregation-layer.js +4 -8
- package/dist/esm/grid-aggregation-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +1 -1
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +3 -3
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +40 -58
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +13 -7
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +1 -0
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +21 -24
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -8
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/utils/aggregation-operation-utils.js.map +1 -1
- package/dist/esm/utils/bin-sorter.js.map +1 -1
- package/dist/esm/utils/cpu-aggregator.js +11 -7
- package/dist/esm/utils/cpu-aggregator.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +4 -3
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +62 -51
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
- package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
- package/dist/esm/utils/grid-aggregation-utils.js.map +1 -1
- package/dist/esm/utils/prop-utils.js.map +1 -1
- package/dist/esm/utils/resource-utils.js +10 -17
- package/dist/esm/utils/resource-utils.js.map +1 -1
- package/dist.min.js +185 -30
- package/package.json +7 -5
- package/src/aggregation-layer.ts +7 -6
- package/src/contour-layer/contour-layer.ts +25 -9
- package/src/cpu-grid-layer/cpu-grid-layer.ts +8 -3
- package/src/cpu-grid-layer/{grid-aggregator.js → grid-aggregator.ts} +28 -4
- package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +38 -27
- package/src/gpu-grid-layer/gpu-grid-layer.ts +18 -12
- package/src/grid-aggregation-layer.ts +39 -13
- package/src/grid-layer/grid-layer.ts +2 -2
- package/src/heatmap-layer/heatmap-layer-utils.ts +10 -4
- package/src/heatmap-layer/heatmap-layer.ts +74 -67
- package/src/heatmap-layer/triangle-layer.ts +26 -22
- package/src/hexagon-layer/{hexagon-aggregator.js → hexagon-aggregator.ts} +5 -1
- package/src/hexagon-layer/hexagon-layer.ts +8 -5
- package/src/index.ts +0 -1
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +36 -33
- package/src/screen-grid-layer/screen-grid-layer.ts +12 -11
- package/src/utils/{aggregation-operation-utils.js → aggregation-operation-utils.ts} +8 -2
- package/src/utils/bin-sorter.ts +1 -1
- package/src/utils/{cpu-aggregator.js → cpu-aggregator.ts} +42 -30
- package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-constants.js → gpu-grid-aggregator-constants.ts} +4 -4
- package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
- package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator.js → gpu-grid-aggregator.ts} +123 -94
- package/src/utils/{grid-aggregation-utils.js → grid-aggregation-utils.ts} +1 -1
- package/src/utils/resource-utils.ts +59 -0
- package/typed/aggregation-layer.d.ts +4 -3
- package/typed/aggregation-layer.d.ts.map +1 -1
- package/typed/contour-layer/contour-layer.d.ts +19 -5
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +8 -3
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/grid-aggregator.d.ts +16 -4
- package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +18 -4
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +8 -3
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
- package/typed/grid-aggregation-layer.d.ts +39 -4
- package/typed/grid-aggregation-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.d.ts +2 -2
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +7 -5
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts +19 -6
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer.d.ts +10 -6
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-aggregator.d.ts +6 -3
- package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-layer.d.ts +5 -4
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/typed/index.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +10 -9
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +6 -4
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/typed/utils/aggregation-operation-utils.d.ts +18 -12
- package/typed/utils/aggregation-operation-utils.d.ts.map +1 -1
- package/typed/utils/bin-sorter.d.ts +1 -1
- package/typed/utils/bin-sorter.d.ts.map +1 -1
- package/typed/utils/cpu-aggregator.d.ts +28 -14
- package/typed/utils/cpu-aggregator.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +35 -33
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +29 -19
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +1 -1
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -1
- package/typed/utils/grid-aggregation-utils.d.ts +11 -5
- package/typed/utils/grid-aggregation-utils.d.ts.map +1 -1
- package/typed/utils/prop-utils.d.ts +1 -1
- package/typed/utils/prop-utils.d.ts.map +1 -1
- package/typed/utils/resource-utils.d.ts +13 -3
- package/typed/utils/resource-utils.d.ts.map +1 -1
- package/LICENSE +0 -19
- package/src/utils/resource-utils.js +0 -51
- /package/src/utils/gpu-grid-aggregation/{aggregate-all-fs.glsl.js → aggregate-all-fs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-all-vs.glsl.js → aggregate-all-vs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-fs.glsl.js → aggregate-to-grid-fs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-vs.glsl.js → aggregate-to-grid-vs.glsl.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-utils.js → gpu-grid-aggregator-utils.ts} +0 -0
- /package/src/utils/gpu-grid-aggregation/{transform-mean-vs.glsl.js → transform-mean-vs.glsl.ts} +0 -0
- /package/src/utils/{prop-utils.js → prop-utils.ts} +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/aggregation-layers",
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "9.0.0-alpha.4",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -31,15 +31,17 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
|
-
"@luma.gl/constants": "
|
|
35
|
-
"@luma.gl/
|
|
34
|
+
"@luma.gl/constants": "9.0.0-alpha.42",
|
|
35
|
+
"@luma.gl/core": "9.0.0-alpha.42",
|
|
36
|
+
"@luma.gl/shadertools": "9.0.0-alpha.42",
|
|
36
37
|
"@math.gl/web-mercator": "^4.0.0",
|
|
37
38
|
"d3-hexbin": "^0.2.1"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@deck.gl/core": "^8.0.0",
|
|
41
42
|
"@deck.gl/layers": "^8.0.0",
|
|
42
|
-
"@luma.gl/core": "
|
|
43
|
+
"@luma.gl/core": "9.0.0-alpha.42",
|
|
44
|
+
"@luma.gl/engine": "9.0.0-alpha.42"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "13ace64fc2cee08c133afc882fc307253489a4e4"
|
|
45
47
|
}
|
package/src/aggregation-layer.ts
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
UpdateParameters,
|
|
27
27
|
CompositeLayerProps
|
|
28
28
|
} from '@deck.gl/core';
|
|
29
|
-
import {cssToDeviceRatio} from '@luma.gl/core';
|
|
30
29
|
import {filterProps} from './utils/prop-utils';
|
|
31
30
|
|
|
32
31
|
export type AggregationLayerProps<DataT> = CompositeLayerProps & {
|
|
@@ -39,9 +38,10 @@ export default abstract class AggregationLayer<
|
|
|
39
38
|
> extends CompositeLayer<Required<AggregationLayer<DataT>> & ExtraPropsT> {
|
|
40
39
|
static layerName = 'AggregationLayer';
|
|
41
40
|
|
|
42
|
-
state!:
|
|
41
|
+
state!: {
|
|
43
42
|
ignoreProps?: Record<string, any>;
|
|
44
43
|
dimensions?: any;
|
|
44
|
+
changedAttributes?: Record<string, any>;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
initializeAggregationLayer(dimensions: any) {
|
|
@@ -76,19 +76,20 @@ export default abstract class AggregationLayer<
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
getAttributes() {
|
|
79
|
-
return this.getAttributeManager()!.
|
|
79
|
+
return this.getAttributeManager()!.getAttributes();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
getModuleSettings() {
|
|
83
83
|
// For regular layer draw this happens during draw cycle (_drawLayersInViewport) not during update cycle
|
|
84
84
|
// For aggregation layers this is called during updateState to update aggregation data
|
|
85
85
|
// NOTE: it is similar to LayerPass._getModuleParameters() but doesn't inlcude `effects` it is not needed for aggregation
|
|
86
|
-
const {viewport, mousePosition,
|
|
86
|
+
const {viewport, mousePosition, device} = this.context;
|
|
87
87
|
const moduleSettings = Object.assign(Object.create(this.props), {
|
|
88
88
|
viewport,
|
|
89
89
|
mousePosition,
|
|
90
90
|
pickingActive: 0,
|
|
91
|
-
|
|
91
|
+
// @ts-expect-error TODO - assuming WebGL context
|
|
92
|
+
devicePixelRatio: device.canvasContext.cssToDeviceRatio()
|
|
92
93
|
});
|
|
93
94
|
return moduleSettings;
|
|
94
95
|
}
|
|
@@ -168,7 +169,7 @@ export default abstract class AggregationLayer<
|
|
|
168
169
|
|
|
169
170
|
// override Composite layer private method to create AttributeManager instance
|
|
170
171
|
_getAttributeManager() {
|
|
171
|
-
return new AttributeManager(this.context.
|
|
172
|
+
return new AttributeManager(this.context.device, {
|
|
172
173
|
id: this.props.id,
|
|
173
174
|
stats: this.context.stats
|
|
174
175
|
});
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import GL from '@luma.gl/constants';
|
|
21
|
+
import {GL} from '@luma.gl/constants';
|
|
22
22
|
import {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';
|
|
23
23
|
import {generateContours} from './contour-utils';
|
|
24
24
|
import {
|
|
@@ -29,7 +29,8 @@ import {
|
|
|
29
29
|
log,
|
|
30
30
|
Position,
|
|
31
31
|
UpdateParameters,
|
|
32
|
-
DefaultProps
|
|
32
|
+
DefaultProps,
|
|
33
|
+
LayersList
|
|
33
34
|
} from '@deck.gl/core';
|
|
34
35
|
|
|
35
36
|
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
@@ -44,7 +45,7 @@ const DEFAULT_THRESHOLD = 1;
|
|
|
44
45
|
const defaultProps: DefaultProps<ContourLayerProps> = {
|
|
45
46
|
// grid aggregation
|
|
46
47
|
cellSize: {type: 'number', min: 1, max: 1000, value: 1000},
|
|
47
|
-
getPosition: {type: 'accessor', value: x => x.position},
|
|
48
|
+
getPosition: {type: 'accessor', value: (x: any) => x.position},
|
|
48
49
|
getWeight: {type: 'accessor', value: 1},
|
|
49
50
|
gpuAggregation: true,
|
|
50
51
|
aggregation: 'SUM',
|
|
@@ -73,7 +74,7 @@ const DIMENSIONS = {
|
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
/** All properties supported by ContourLayer. */
|
|
76
|
-
export type ContourLayerProps<DataT =
|
|
77
|
+
export type ContourLayerProps<DataT = unknown> = _ContourLayerProps<DataT> &
|
|
77
78
|
GridAggregationLayerProps<DataT>;
|
|
78
79
|
|
|
79
80
|
/** Properties added by ContourLayer. */
|
|
@@ -151,6 +152,21 @@ export default class ContourLayer<
|
|
|
151
152
|
static layerName = 'ContourLayer';
|
|
152
153
|
static defaultProps = defaultProps;
|
|
153
154
|
|
|
155
|
+
state!: GridAggregationLayer<DataT>['state'] & {
|
|
156
|
+
contourData: {
|
|
157
|
+
contourSegments: {
|
|
158
|
+
start: number[];
|
|
159
|
+
end: number[];
|
|
160
|
+
contour: any;
|
|
161
|
+
}[];
|
|
162
|
+
contourPolygons: {
|
|
163
|
+
vertices: number[][];
|
|
164
|
+
contour: any;
|
|
165
|
+
}[];
|
|
166
|
+
};
|
|
167
|
+
thresholdData: any;
|
|
168
|
+
};
|
|
169
|
+
|
|
154
170
|
initializeState(): void {
|
|
155
171
|
super.initializeAggregationLayer({
|
|
156
172
|
dimensions: DIMENSIONS
|
|
@@ -194,7 +210,7 @@ export default class ContourLayer<
|
|
|
194
210
|
}
|
|
195
211
|
}
|
|
196
212
|
|
|
197
|
-
renderLayers():
|
|
213
|
+
renderLayers(): LayersList {
|
|
198
214
|
const {contourSegments, contourPolygons} = this.state.contourData;
|
|
199
215
|
|
|
200
216
|
const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
|
|
@@ -238,14 +254,14 @@ export default class ContourLayer<
|
|
|
238
254
|
// Aggregation Overrides
|
|
239
255
|
|
|
240
256
|
/* eslint-disable max-statements, complexity */
|
|
241
|
-
updateAggregationState(opts) {
|
|
257
|
+
updateAggregationState(opts: UpdateParameters<this>) {
|
|
242
258
|
const {props, oldProps} = opts;
|
|
243
259
|
const {cellSize, coordinateSystem} = props;
|
|
244
260
|
const {viewport} = this.context;
|
|
245
261
|
const cellSizeChanged = oldProps.cellSize !== cellSize;
|
|
246
262
|
let gpuAggregation = props.gpuAggregation;
|
|
247
263
|
if (this.state.gpuAggregation !== props.gpuAggregation) {
|
|
248
|
-
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.
|
|
264
|
+
if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
|
|
249
265
|
log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
|
|
250
266
|
gpuAggregation = false;
|
|
251
267
|
}
|
|
@@ -311,7 +327,7 @@ export default class ContourLayer<
|
|
|
311
327
|
|
|
312
328
|
// Private (Aggregation)
|
|
313
329
|
|
|
314
|
-
private _updateAccessors(opts) {
|
|
330
|
+
private _updateAccessors(opts: UpdateParameters<this>) {
|
|
315
331
|
const {getWeight, aggregation, data} = opts.props;
|
|
316
332
|
const {count} = this.state.weights;
|
|
317
333
|
if (count) {
|
|
@@ -335,7 +351,7 @@ export default class ContourLayer<
|
|
|
335
351
|
const {count} = this.state.weights;
|
|
336
352
|
let {aggregationData} = count;
|
|
337
353
|
if (!aggregationData) {
|
|
338
|
-
aggregationData = count.aggregationBuffer
|
|
354
|
+
aggregationData = count.aggregationBuffer!.getData() as Float32Array;
|
|
339
355
|
count.aggregationData = aggregationData;
|
|
340
356
|
}
|
|
341
357
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import GL from '@luma.gl/constants';
|
|
21
|
+
import {GL} from '@luma.gl/constants';
|
|
22
22
|
import {GridCellLayer} from '@deck.gl/layers';
|
|
23
23
|
import {Accessor, AccessorFunction, Color, Position, Material, DefaultProps} from '@deck.gl/core';
|
|
24
24
|
|
|
@@ -62,7 +62,7 @@ const defaultProps: DefaultProps<CPUGridLayerProps> = {
|
|
|
62
62
|
// grid
|
|
63
63
|
cellSize: {type: 'number', min: 0, max: 1000, value: 1000},
|
|
64
64
|
coverage: {type: 'number', min: 0, max: 1, value: 1},
|
|
65
|
-
getPosition: {type: 'accessor', value: x => x.position},
|
|
65
|
+
getPosition: {type: 'accessor', value: (x: any) => x.position},
|
|
66
66
|
extruded: false,
|
|
67
67
|
|
|
68
68
|
// Optional material for 'lighting' shader module
|
|
@@ -73,7 +73,7 @@ const defaultProps: DefaultProps<CPUGridLayerProps> = {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
/** All properties supported by CPUGridLayer. */
|
|
76
|
-
export type CPUGridLayerProps<DataT =
|
|
76
|
+
export type CPUGridLayerProps<DataT = unknown> = _CPUGridLayerProps<DataT> &
|
|
77
77
|
AggregationLayerProps<DataT>;
|
|
78
78
|
|
|
79
79
|
/** Properties added by CPUGridLayer. */
|
|
@@ -244,6 +244,11 @@ export default class CPUGridLayer<
|
|
|
244
244
|
static layerName = 'CPUGridLayer';
|
|
245
245
|
static defaultProps = defaultProps;
|
|
246
246
|
|
|
247
|
+
state!: AggregationLayer<DataT>['state'] & {
|
|
248
|
+
cpuAggregator: CPUAggregator;
|
|
249
|
+
aggregatorState: CPUAggregator['state'];
|
|
250
|
+
};
|
|
251
|
+
|
|
247
252
|
initializeState(): void {
|
|
248
253
|
const cpuAggregator = new CPUAggregator({
|
|
249
254
|
getAggregator: props => props.gridAggregator,
|
|
@@ -21,6 +21,15 @@
|
|
|
21
21
|
import {createIterable} from '@deck.gl/core';
|
|
22
22
|
import {getGridOffset} from '../utils/grid-aggregation-utils';
|
|
23
23
|
|
|
24
|
+
export type GridHash = {
|
|
25
|
+
[key: string]: {
|
|
26
|
+
count: number;
|
|
27
|
+
points: unknown[];
|
|
28
|
+
lonIdx: number;
|
|
29
|
+
latIdx: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* Calculate density grid from an array of points
|
|
26
35
|
* @param {Object} props - object containing :
|
|
@@ -57,8 +66,15 @@ export function pointToDensityGridDataCPU(props, aggregationParams) {
|
|
|
57
66
|
* @param {function} getPosition - position accessor
|
|
58
67
|
* @returns {object} - grid hash and cell dimension
|
|
59
68
|
*/
|
|
60
|
-
/* eslint-disable max-statements, complexity */
|
|
61
|
-
function pointsToGridHashing(
|
|
69
|
+
/* eslint-disable-next-line max-statements, complexity */
|
|
70
|
+
function pointsToGridHashing(
|
|
71
|
+
props,
|
|
72
|
+
aggregationParams
|
|
73
|
+
): {
|
|
74
|
+
gridHash: GridHash;
|
|
75
|
+
gridOffset: {xOffset: number; yOffset: number};
|
|
76
|
+
offsets: [number, number];
|
|
77
|
+
} {
|
|
62
78
|
const {data = [], cellSize} = props;
|
|
63
79
|
const {attributes, viewport, projectPoints, numInstances} = aggregationParams;
|
|
64
80
|
const positions = attributes.positions.value;
|
|
@@ -69,7 +85,7 @@ function pointsToGridHashing(props, aggregationParams) {
|
|
|
69
85
|
const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);
|
|
70
86
|
|
|
71
87
|
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
|
|
72
|
-
return {gridHash: {}, gridOffset};
|
|
88
|
+
return {gridHash: {}, gridOffset, offsets: [0, 0]};
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
const {width, height} = viewport;
|
|
@@ -111,7 +127,15 @@ function pointsToGridHashing(props, aggregationParams) {
|
|
|
111
127
|
}
|
|
112
128
|
/* eslint-enable max-statements, complexity */
|
|
113
129
|
|
|
114
|
-
function getGridLayerDataFromGridHash({
|
|
130
|
+
function getGridLayerDataFromGridHash({
|
|
131
|
+
gridHash,
|
|
132
|
+
gridOffset,
|
|
133
|
+
offsets
|
|
134
|
+
}: {
|
|
135
|
+
gridHash: GridHash;
|
|
136
|
+
gridOffset: {xOffset: number; yOffset: number};
|
|
137
|
+
offsets: [number, number];
|
|
138
|
+
}) {
|
|
115
139
|
const data = new Array(Object.keys(gridHash).length);
|
|
116
140
|
let i = 0;
|
|
117
141
|
for (const key in gridHash) {
|
|
@@ -24,13 +24,14 @@ import {
|
|
|
24
24
|
project32,
|
|
25
25
|
gouraudLighting,
|
|
26
26
|
picking,
|
|
27
|
-
LayerContext,
|
|
28
27
|
LayerProps,
|
|
29
28
|
DefaultProps
|
|
30
29
|
} from '@deck.gl/core';
|
|
31
|
-
import
|
|
32
|
-
import {Model, CubeGeometry, Buffer} from '@luma.gl/core';
|
|
30
|
+
import {CubeGeometry} from '@luma.gl/engine';
|
|
33
31
|
import {fp64arithmetic} from '@luma.gl/shadertools';
|
|
32
|
+
import {Model} from '@luma.gl/engine';
|
|
33
|
+
import {Buffer} from '@luma.gl/core';
|
|
34
|
+
import {GL} from '@luma.gl/constants';
|
|
34
35
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
35
36
|
import type {_GPUGridLayerProps} from './gpu-grid-layer';
|
|
36
37
|
import vs from './gpu-grid-cell-layer-vertex.glsl';
|
|
@@ -63,7 +64,12 @@ const defaultProps: DefaultProps<_GPUGridCellLayerProps & LayerProps> = {
|
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
type _GPUGridCellLayerProps = _GPUGridLayerProps<any> & {
|
|
67
|
+
cellSize: number;
|
|
66
68
|
offset: number[];
|
|
69
|
+
coverage: number;
|
|
70
|
+
extruded: boolean;
|
|
71
|
+
elevationScale: number;
|
|
72
|
+
elevationRange: [number, number];
|
|
67
73
|
gridSize: number[];
|
|
68
74
|
gridOrigin: number[];
|
|
69
75
|
gridOffset: number[];
|
|
@@ -75,6 +81,10 @@ export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
|
75
81
|
static layerName = 'GPUGridCellLayer';
|
|
76
82
|
static defaultProps = defaultProps;
|
|
77
83
|
|
|
84
|
+
state!: {
|
|
85
|
+
model?: Model;
|
|
86
|
+
};
|
|
87
|
+
|
|
78
88
|
getShaders() {
|
|
79
89
|
return super.getShaders({
|
|
80
90
|
vs,
|
|
@@ -83,7 +93,7 @@ export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
initializeState(
|
|
96
|
+
initializeState(): void {
|
|
87
97
|
const attributeManager = this.getAttributeManager()!;
|
|
88
98
|
attributeManager.addInstanced({
|
|
89
99
|
colors: {
|
|
@@ -95,13 +105,13 @@ export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
|
95
105
|
noAlloc: true
|
|
96
106
|
}
|
|
97
107
|
});
|
|
98
|
-
const model = this._getModel(
|
|
108
|
+
const model = this._getModel();
|
|
99
109
|
this._setupUniformBuffer(model);
|
|
100
110
|
this.setState({model});
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
_getModel(
|
|
104
|
-
return new Model(
|
|
113
|
+
_getModel(): Model {
|
|
114
|
+
return new Model(this.context.device, {
|
|
105
115
|
...this.getShaders(),
|
|
106
116
|
id: this.props.id,
|
|
107
117
|
geometry: new CubeGeometry(),
|
|
@@ -123,30 +133,30 @@ export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
|
123
133
|
colorMaxMinBuffer,
|
|
124
134
|
elevationMaxMinBuffer
|
|
125
135
|
} = this.props;
|
|
136
|
+
const model = this.state.model!;
|
|
126
137
|
|
|
127
138
|
const gridOriginLow = [fp64LowPart(gridOrigin[0]), fp64LowPart(gridOrigin[1])];
|
|
128
139
|
const gridOffsetLow = [fp64LowPart(gridOffset[0]), fp64LowPart(gridOffset[1])];
|
|
129
140
|
const domainUniforms = this.getDomainUniforms();
|
|
130
141
|
const colorRange = colorRangeToFlatArray(this.props.colorRange);
|
|
131
142
|
this.bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.draw();
|
|
143
|
+
model.setUniforms(uniforms);
|
|
144
|
+
model.setUniforms(domainUniforms);
|
|
145
|
+
model.setUniforms({
|
|
146
|
+
cellSize,
|
|
147
|
+
offset,
|
|
148
|
+
extruded,
|
|
149
|
+
elevationScale,
|
|
150
|
+
coverage,
|
|
151
|
+
gridSize,
|
|
152
|
+
gridOrigin,
|
|
153
|
+
gridOriginLow,
|
|
154
|
+
gridOffset,
|
|
155
|
+
gridOffsetLow,
|
|
156
|
+
colorRange,
|
|
157
|
+
elevationRange
|
|
158
|
+
});
|
|
159
|
+
model.draw(this.context.renderPass);
|
|
150
160
|
this.unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
|
|
151
161
|
}
|
|
152
162
|
|
|
@@ -179,9 +189,10 @@ export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
private _setupUniformBuffer(model: Model): void {
|
|
182
|
-
|
|
183
|
-
const programHandle = model.
|
|
192
|
+
// @ts-expect-error TODO v9 This code is not portable to WebGPU
|
|
193
|
+
const programHandle = model.pipeline.handle;
|
|
184
194
|
|
|
195
|
+
const gl = this.context.gl as WebGL2RenderingContext;
|
|
185
196
|
const colorIndex = gl.getUniformBlockIndex(programHandle, 'ColorData');
|
|
186
197
|
const elevationIndex = gl.getUniformBlockIndex(programHandle, 'ElevationData');
|
|
187
198
|
gl.uniformBlockBinding(programHandle, colorIndex, COLOR_DATA_UBO_INDEX);
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
import GL from '@luma.gl/constants';
|
|
21
|
+
import {GL} from '@luma.gl/constants';
|
|
23
22
|
import {
|
|
24
23
|
Accessor,
|
|
25
24
|
AccessorFunction,
|
|
@@ -37,7 +36,7 @@ import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator
|
|
|
37
36
|
import {AGGREGATION_OPERATION} from '../utils/aggregation-operation-utils';
|
|
38
37
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
39
38
|
import GPUGridCellLayer from './gpu-grid-cell-layer';
|
|
40
|
-
import {pointToDensityGridDataCPU} from './../cpu-grid-layer/grid-aggregator';
|
|
39
|
+
import {pointToDensityGridDataCPU, GridHash} from './../cpu-grid-layer/grid-aggregator';
|
|
41
40
|
import GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';
|
|
42
41
|
import {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';
|
|
43
42
|
|
|
@@ -58,7 +57,7 @@ const defaultProps: DefaultProps<GPUGridLayerProps> = {
|
|
|
58
57
|
// grid
|
|
59
58
|
cellSize: {type: 'number', min: 1, max: 1000, value: 1000},
|
|
60
59
|
coverage: {type: 'number', min: 0, max: 1, value: 1},
|
|
61
|
-
getPosition: {type: 'accessor', value: x => x.position},
|
|
60
|
+
getPosition: {type: 'accessor', value: (x: any) => x.position},
|
|
62
61
|
extruded: false,
|
|
63
62
|
|
|
64
63
|
// Optional material for 'lighting' shader module
|
|
@@ -77,7 +76,7 @@ const DIMENSIONS = {
|
|
|
77
76
|
const POSITION_ATTRIBUTE_NAME = 'positions';
|
|
78
77
|
|
|
79
78
|
/** All properties supported by GPUGridLayer. */
|
|
80
|
-
export type GPUGridLayerProps<DataT =
|
|
79
|
+
export type GPUGridLayerProps<DataT = unknown> = _GPUGridLayerProps<DataT> &
|
|
81
80
|
GridAggregationLayerProps<DataT>;
|
|
82
81
|
|
|
83
82
|
/** Properties added by GPUGridLayer. */
|
|
@@ -176,8 +175,13 @@ export default class GPUGridLayer<
|
|
|
176
175
|
static layerName = 'GPUGridLayer';
|
|
177
176
|
static defaultProps = defaultProps;
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
state!: GridAggregationLayer<DataT>['state'] & {
|
|
179
|
+
isSupported: boolean;
|
|
180
|
+
gridHash?: GridHash;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
initializeState({device}: LayerContext): void {
|
|
184
|
+
const isSupported = GPUGridAggregator.isSupported(device);
|
|
181
185
|
if (!isSupported) {
|
|
182
186
|
log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
|
|
183
187
|
}
|
|
@@ -193,8 +197,9 @@ export default class GPUGridLayer<
|
|
|
193
197
|
needMin: true,
|
|
194
198
|
needMax: true,
|
|
195
199
|
combineMaxMin: true,
|
|
196
|
-
maxMinBuffer:
|
|
200
|
+
maxMinBuffer: device.createBuffer({
|
|
197
201
|
byteLength: 4 * 4,
|
|
202
|
+
// @ts-expect-error webgl-legacy
|
|
198
203
|
accessor: {size: 4, type: GL.FLOAT, divisor: 1}
|
|
199
204
|
})
|
|
200
205
|
},
|
|
@@ -202,8 +207,9 @@ export default class GPUGridLayer<
|
|
|
202
207
|
needMin: true,
|
|
203
208
|
needMax: true,
|
|
204
209
|
combineMaxMin: true,
|
|
205
|
-
maxMinBuffer:
|
|
210
|
+
maxMinBuffer: device.createBuffer({
|
|
206
211
|
byteLength: 4 * 4,
|
|
212
|
+
// @ts-expect-error
|
|
207
213
|
accessor: {size: 4, type: GL.FLOAT, divisor: 1}
|
|
208
214
|
})
|
|
209
215
|
}
|
|
@@ -273,7 +279,7 @@ export default class GPUGridLayer<
|
|
|
273
279
|
const {index} = info;
|
|
274
280
|
let object: any = null;
|
|
275
281
|
if (index >= 0) {
|
|
276
|
-
const
|
|
282
|
+
const gpuGridAggregator = this.state.gpuGridAggregator!;
|
|
277
283
|
const position = this.getPositionForIndex(index);
|
|
278
284
|
const colorInfo = GPUGridAggregator.getAggregationData({
|
|
279
285
|
pixelIndex: index,
|
|
@@ -380,8 +386,8 @@ export default class GPUGridLayer<
|
|
|
380
386
|
const {color, elevation} = this.state.weights;
|
|
381
387
|
[color, elevation].forEach(weight => {
|
|
382
388
|
const {aggregationBuffer, maxMinBuffer} = weight;
|
|
383
|
-
maxMinBuffer
|
|
384
|
-
aggregationBuffer?.
|
|
389
|
+
maxMinBuffer?.destroy();
|
|
390
|
+
aggregationBuffer?.destroy();
|
|
385
391
|
});
|
|
386
392
|
super.finalizeState(context);
|
|
387
393
|
}
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
+
import {GL} from '@luma.gl/constants';
|
|
22
|
+
import {LayerContext, log, UpdateParameters, Accessor} from '@deck.gl/core';
|
|
21
23
|
import AggregationLayer, {AggregationLayerProps} from './aggregation-layer';
|
|
22
24
|
import GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
23
|
-
import {Buffer} from '@luma.gl/core';
|
|
24
|
-
import {LayerContext, log, UpdateParameters} from '@deck.gl/core';
|
|
25
|
-
import GL from '@luma.gl/constants';
|
|
26
25
|
import BinSorter from './utils/bin-sorter';
|
|
27
26
|
import {pointToDensityGridDataCPU} from './cpu-grid-layer/grid-aggregator';
|
|
27
|
+
import type {Buffer} from '@luma.gl/core';
|
|
28
28
|
|
|
29
29
|
export type GridAggregationLayerProps<DataT> = AggregationLayerProps<DataT>;
|
|
30
30
|
|
|
@@ -35,20 +35,46 @@ export default abstract class GridAggregationLayer<
|
|
|
35
35
|
static layerName = 'GridAggregationLayer';
|
|
36
36
|
|
|
37
37
|
state!: AggregationLayer<DataT>['state'] & {
|
|
38
|
-
aggregationDataDirty?:
|
|
39
|
-
aggregationWeightsDirty?:
|
|
38
|
+
aggregationDataDirty?: boolean;
|
|
39
|
+
aggregationWeightsDirty?: boolean;
|
|
40
|
+
aggregationDirty?: boolean;
|
|
40
41
|
gpuAggregation?: any;
|
|
41
42
|
getValue?: () => any;
|
|
42
43
|
sortedBins?: BinSorter;
|
|
44
|
+
weights: {
|
|
45
|
+
[key: string]: {
|
|
46
|
+
aggregationBuffer?: Buffer;
|
|
47
|
+
maxMinBuffer?: Buffer;
|
|
48
|
+
aggregationData: Float32Array | null;
|
|
49
|
+
maxMinData: Float32Array;
|
|
50
|
+
maxData: Float32Array;
|
|
51
|
+
minData: Float32Array;
|
|
52
|
+
getWeight: Accessor<DataT, number>;
|
|
53
|
+
operation: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
cpuGridAggregator?: Function;
|
|
57
|
+
gpuGridAggregator?: GPUGridAggregator;
|
|
58
|
+
layerData: any;
|
|
59
|
+
numRow: number;
|
|
60
|
+
numCol: number;
|
|
61
|
+
gridOffset: {xOffset: number; yOffset: number};
|
|
62
|
+
posOffset: number[];
|
|
63
|
+
gridOrigin: number[];
|
|
64
|
+
translation: number[];
|
|
65
|
+
scaling: number[];
|
|
66
|
+
boundingBox: {xMin: number; yMin: number; xMax: number; yMax: number};
|
|
67
|
+
projectPoints?: (p: [number, number]) => [number, number];
|
|
43
68
|
};
|
|
44
69
|
|
|
45
70
|
initializeAggregationLayer({dimensions}) {
|
|
46
|
-
const {gl} = this.context;
|
|
47
71
|
super.initializeAggregationLayer(dimensions);
|
|
48
72
|
this.setState({
|
|
49
73
|
// CPU aggregation results
|
|
50
74
|
layerData: {},
|
|
51
|
-
gpuGridAggregator: new GPUGridAggregator(
|
|
75
|
+
gpuGridAggregator: new GPUGridAggregator(this.context.device, {
|
|
76
|
+
id: `${this.id}-gpu-aggregator`
|
|
77
|
+
}),
|
|
52
78
|
cpuGridAggregator: pointToDensityGridDataCPU
|
|
53
79
|
});
|
|
54
80
|
}
|
|
@@ -94,13 +120,13 @@ export default abstract class GridAggregationLayer<
|
|
|
94
120
|
|
|
95
121
|
updateShaders(shaders: any): void {
|
|
96
122
|
if (this.state.gpuAggregation) {
|
|
97
|
-
this.state.gpuGridAggregator
|
|
123
|
+
this.state.gpuGridAggregator!.updateShaders(shaders);
|
|
98
124
|
}
|
|
99
125
|
}
|
|
100
126
|
|
|
101
127
|
// Methods that can be overriden by subclasses for customizations
|
|
102
128
|
|
|
103
|
-
updateAggregationState(opts) {
|
|
129
|
+
updateAggregationState(opts: UpdateParameters<this>) {
|
|
104
130
|
// Sublayers should implement this method.
|
|
105
131
|
log.assert(false);
|
|
106
132
|
}
|
|
@@ -108,15 +134,15 @@ export default abstract class GridAggregationLayer<
|
|
|
108
134
|
allocateResources(numRow, numCol) {
|
|
109
135
|
if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
|
|
110
136
|
const dataBytes = numCol * numRow * 4 * 4;
|
|
111
|
-
const gl = this.context.gl;
|
|
112
137
|
const {weights} = this.state;
|
|
113
138
|
for (const name in weights) {
|
|
114
139
|
const weight = weights[name];
|
|
115
140
|
if (weight.aggregationBuffer) {
|
|
116
141
|
weight.aggregationBuffer.delete();
|
|
117
142
|
}
|
|
118
|
-
weight.aggregationBuffer =
|
|
143
|
+
weight.aggregationBuffer = this.context.device.createBuffer({
|
|
119
144
|
byteLength: dataBytes,
|
|
145
|
+
// @ts-expect-error legacy
|
|
120
146
|
accessor: {
|
|
121
147
|
size: 4,
|
|
122
148
|
type: GL.FLOAT,
|
|
@@ -159,7 +185,7 @@ export default abstract class GridAggregationLayer<
|
|
|
159
185
|
const vertexCount = this.getNumInstances();
|
|
160
186
|
|
|
161
187
|
if (!gpuAggregation) {
|
|
162
|
-
const result = cpuGridAggregator(props, {
|
|
188
|
+
const result = cpuGridAggregator!(props, {
|
|
163
189
|
gridOffset,
|
|
164
190
|
projectPoints,
|
|
165
191
|
attributes,
|
|
@@ -172,7 +198,7 @@ export default abstract class GridAggregationLayer<
|
|
|
172
198
|
});
|
|
173
199
|
} else {
|
|
174
200
|
const {weights} = this.state;
|
|
175
|
-
gpuGridAggregator
|
|
201
|
+
gpuGridAggregator!.run({
|
|
176
202
|
weights,
|
|
177
203
|
cellSize: [gridOffset.xOffset, gridOffset.yOffset],
|
|
178
204
|
numCol,
|
|
@@ -16,7 +16,7 @@ const defaultProps: DefaultProps<GridLayerProps> = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/** All properties supported by GridLayer. */
|
|
19
|
-
export type GridLayerProps<DataT =
|
|
19
|
+
export type GridLayerProps<DataT = unknown> = _GridLayerProps<DataT> & CompositeLayerProps;
|
|
20
20
|
|
|
21
21
|
/** Properties added by GridLayer. */
|
|
22
22
|
type _GridLayerProps<DataT> = CPUGridLayerProps<DataT> &
|
|
@@ -90,7 +90,7 @@ export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends
|
|
|
90
90
|
// cpu aggregation is requested
|
|
91
91
|
return false;
|
|
92
92
|
}
|
|
93
|
-
if (!GPUGridAggregator.isSupported(this.context.
|
|
93
|
+
if (!GPUGridAggregator.isSupported(this.context.device)) {
|
|
94
94
|
return false;
|
|
95
95
|
}
|
|
96
96
|
if (lowerPercentile !== 0 || upperPercentile !== 100) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import {Device} from '@luma.gl/core';
|
|
2
|
+
import {GL} from '@luma.gl/constants';
|
|
3
3
|
|
|
4
4
|
export function getBounds(points: number[][]): number[] {
|
|
5
5
|
// Now build bounding box in world space (aligned to world coordiante system)
|
|
@@ -79,11 +79,17 @@ export function getTextureCoordinates(point: number[], bounds: number[]) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// Returns format and type for creating texture objects
|
|
82
|
-
export function getTextureParams({
|
|
82
|
+
export function getTextureParams({
|
|
83
|
+
device,
|
|
84
|
+
floatTargetSupport
|
|
85
|
+
}: {
|
|
86
|
+
device: Device;
|
|
87
|
+
floatTargetSupport?: boolean;
|
|
88
|
+
}) {
|
|
83
89
|
return floatTargetSupport
|
|
84
90
|
? {
|
|
85
91
|
// format: should be RGBA32F on WebGL2 (float textures), RGBA in WebGL1 for float or non float textures
|
|
86
|
-
format:
|
|
92
|
+
format: device.info.type === 'webgl2' ? GL.RGBA32F : GL.RGBA,
|
|
87
93
|
type: GL.FLOAT
|
|
88
94
|
}
|
|
89
95
|
: {
|