@deck.gl/aggregation-layers 9.4.0-alpha.1 → 9.4.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/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
- package/dist/dist.dev.js +642 -38
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-cell-layer.js +3 -2
- package/dist/grid-layer/grid-cell-layer.js.map +1 -1
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js +114 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer-uniforms.js +14 -0
- package/dist/grid-layer/grid-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +59 -12
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/max.wgsl.js +48 -0
- package/dist/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +3 -2
- package/dist/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.js +64 -0
- package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.js +2 -2
- package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
- package/dist/index.cjs +13268 -1488
- package/dist/index.cjs.map +3 -4
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
- package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
- package/dist.min.js +545 -35
- package/dist.webgl-only/common/aggregation-layer.js +68 -0
- package/dist.webgl-only/common/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/common/aggregator/aggregator.js +5 -0
- package/dist.webgl-only/common/aggregator/aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js +69 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js +141 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +22 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js +24 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +222 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js +203 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +225 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
- package/dist.webgl-only/common/aggregator/index.js +6 -0
- package/dist.webgl-only/common/aggregator/index.js.map +1 -0
- package/dist.webgl-only/common/types.js +5 -0
- package/dist.webgl-only/common/types.js.map +1 -0
- package/dist.webgl-only/common/utils/bounds-utils.js +21 -0
- package/dist.webgl-only/common/utils/bounds-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/color-utils.js +65 -0
- package/dist.webgl-only/common/utils/color-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/prop-utils.js +13 -0
- package/dist.webgl-only/common/utils/prop-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/scale-utils.js +181 -0
- package/dist.webgl-only/common/utils/scale-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-layer.js +282 -0
- package/dist.webgl-only/contour-layer/contour-layer.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-utils.js +60 -0
- package/dist.webgl-only/contour-layer/contour-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js +341 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares.js +151 -0
- package/dist.webgl-only/contour-layer/marching-squares.js.map +1 -0
- package/dist.webgl-only/contour-layer/value-reader.js +47 -0
- package/dist.webgl-only/contour-layer/value-reader.js.map +1 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js +95 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js +26 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer.js +362 -0
- package/dist.webgl-only/grid-layer/grid-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js +140 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js +36 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js +67 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js +513 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js +13 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js +18 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js +34 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js +25 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js +28 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js +49 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js +90 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js +24 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js +360 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js +70 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js.map +1 -0
- package/dist.webgl-only/index.cjs +15625 -0
- package/dist.webgl-only/index.cjs.map +6 -0
- package/dist.webgl-only/index.js +11 -0
- package/dist.webgl-only/index.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js +16 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js +88 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js +16 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js +22 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js +31 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js +194 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js.map +1 -0
- package/package.json +14 -5
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
- package/src/grid-layer/grid-cell-layer.ts +3 -2
- package/src/grid-layer/grid-cell-layer.wgsl.ts +114 -0
- package/src/grid-layer/grid-layer-uniforms.ts +15 -0
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
- package/src/heatmap-layer/heatmap-layer.ts +67 -13
- package/src/heatmap-layer/max.wgsl.ts +48 -0
- package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
- package/src/heatmap-layer/triangle-layer.ts +3 -2
- package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
- package/src/heatmap-layer/weights.wgsl.ts +64 -0
- package/src/hexagon-layer/hexagon-cell-layer.ts +2 -3
- package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
- package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export { default as ScreenGridLayer } from "./screen-grid-layer/screen-grid-layer.js";
|
|
5
|
+
export { default as HexagonLayer } from "./hexagon-layer/hexagon-layer.js";
|
|
6
|
+
export { default as ContourLayer } from "./contour-layer/contour-layer.js";
|
|
7
|
+
export { default as GridLayer } from "./grid-layer/grid-layer.js";
|
|
8
|
+
export { default as HeatmapLayer } from "./heatmap-layer/heatmap-layer.js";
|
|
9
|
+
export { default as _AggregationLayer } from "./common/aggregation-layer.js";
|
|
10
|
+
export { WebGLAggregator, CPUAggregator } from "./common/aggregator/index.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,iDAA8C;AACjF,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AACtE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,mCAAgC;AAC7D,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,yCAAsC;AAEtE,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,sCAAmC;AACxE,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,qCAAkC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const uniformBlock = /* glsl */ `\
|
|
5
|
+
layout(std140) uniform binOptionsUniforms {
|
|
6
|
+
float cellSizePixels;
|
|
7
|
+
} binOptions;
|
|
8
|
+
`;
|
|
9
|
+
export const binOptionsUniforms = {
|
|
10
|
+
name: 'binOptions',
|
|
11
|
+
vs: uniformBlock,
|
|
12
|
+
uniformTypes: {
|
|
13
|
+
cellSizePixels: 'f32'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=bin-options-uniforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin-options-uniforms.js","sourceRoot":"","sources":["../../src/screen-grid-layer/bin-options-uniforms.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,YAAY,GAAG,UAAU,CAAC;;;;CAI/B,CAAC;AAMF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,YAAY;IAClB,EAAE,EAAE,YAAY;IAChB,YAAY,EAAE;QACZ,cAAc,EAAE,KAAK;KACtB;CAC0C,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Model, Geometry } from '@luma.gl/engine';
|
|
5
|
+
import { Layer, color, picking } from '@deck.gl/core';
|
|
6
|
+
import { createColorRangeTexture, updateColorRangeTexture } from "../common/utils/color-utils.js";
|
|
7
|
+
import source from "./screen-grid-cell-layer.wgsl.js";
|
|
8
|
+
import vs from "./screen-grid-layer-vertex.glsl.js";
|
|
9
|
+
import fs from "./screen-grid-layer-fragment.glsl.js";
|
|
10
|
+
import { screenGridUniforms } from "./screen-grid-layer-uniforms.js";
|
|
11
|
+
class ScreenGridCellLayer extends Layer {
|
|
12
|
+
getShaders() {
|
|
13
|
+
return super.getShaders({ source, vs, fs, modules: [color, picking, screenGridUniforms] });
|
|
14
|
+
}
|
|
15
|
+
initializeState() {
|
|
16
|
+
this.getAttributeManager().addInstanced({
|
|
17
|
+
instancePositions: {
|
|
18
|
+
size: 2,
|
|
19
|
+
type: 'float32',
|
|
20
|
+
accessor: 'getBin'
|
|
21
|
+
},
|
|
22
|
+
instanceWeights: {
|
|
23
|
+
size: 1,
|
|
24
|
+
type: 'float32',
|
|
25
|
+
accessor: 'getWeight'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.state.model = this._getModel();
|
|
29
|
+
}
|
|
30
|
+
updateState(params) {
|
|
31
|
+
super.updateState(params);
|
|
32
|
+
const { props, oldProps, changeFlags } = params;
|
|
33
|
+
const model = this.state.model;
|
|
34
|
+
if (oldProps.colorRange !== props.colorRange) {
|
|
35
|
+
this.state.colorTexture?.destroy();
|
|
36
|
+
this.state.colorTexture = createColorRangeTexture(this.context.device, props.colorRange, props.colorScaleType);
|
|
37
|
+
const screenGridProps = { colorRange: this.state.colorTexture };
|
|
38
|
+
model.shaderInputs.setProps({ screenGrid: screenGridProps });
|
|
39
|
+
}
|
|
40
|
+
else if (oldProps.colorScaleType !== props.colorScaleType) {
|
|
41
|
+
updateColorRangeTexture(this.state.colorTexture, props.colorScaleType);
|
|
42
|
+
}
|
|
43
|
+
if (oldProps.cellMarginPixels !== props.cellMarginPixels ||
|
|
44
|
+
oldProps.cellSizePixels !== props.cellSizePixels ||
|
|
45
|
+
changeFlags.viewportChanged) {
|
|
46
|
+
const { width, height } = this.context.viewport;
|
|
47
|
+
const { cellSizePixels: gridSize, cellMarginPixels } = this.props;
|
|
48
|
+
const cellSize = Math.max(gridSize - cellMarginPixels, 0);
|
|
49
|
+
const screenGridProps = {
|
|
50
|
+
gridSizeClipspace: [(gridSize / width) * 2, (gridSize / height) * 2],
|
|
51
|
+
cellSizeClipspace: [(cellSize / width) * 2, (cellSize / height) * 2]
|
|
52
|
+
};
|
|
53
|
+
model.shaderInputs.setProps({ screenGrid: screenGridProps });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
finalizeState(context) {
|
|
57
|
+
super.finalizeState(context);
|
|
58
|
+
this.state.colorTexture?.destroy();
|
|
59
|
+
}
|
|
60
|
+
draw({ uniforms }) {
|
|
61
|
+
const colorDomain = this.props.colorDomain();
|
|
62
|
+
const model = this.state.model;
|
|
63
|
+
const screenGridProps = { colorDomain };
|
|
64
|
+
model.shaderInputs.setProps({ screenGrid: screenGridProps });
|
|
65
|
+
model.draw(this.context.renderPass);
|
|
66
|
+
}
|
|
67
|
+
// Private Methods
|
|
68
|
+
_getModel() {
|
|
69
|
+
return new Model(this.context.device, {
|
|
70
|
+
...this.getShaders(),
|
|
71
|
+
id: this.props.id,
|
|
72
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts(),
|
|
73
|
+
geometry: new Geometry({
|
|
74
|
+
topology: 'triangle-strip',
|
|
75
|
+
attributes: {
|
|
76
|
+
positions: {
|
|
77
|
+
value: new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]),
|
|
78
|
+
size: 2
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
isInstanced: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
ScreenGridCellLayer.layerName = 'ScreenGridCellLayer';
|
|
87
|
+
export default ScreenGridCellLayer;
|
|
88
|
+
//# sourceMappingURL=screen-grid-cell-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-cell-layer.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-cell-layer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAA0B,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,uBAAuB,EAAE,uBAAuB,EAAC,uCAAoC;AAC7F,OAAO,MAAM,yCAAsC;AACnD,OAAO,EAAE,2CAAwC;AACjD,OAAO,EAAE,6CAA0C;AACnD,OAAO,EAAkB,kBAAkB,EAAC,wCAAqC;AAYjF,MAAqB,mBAAiD,SAAQ,KAE7E;IAQC,UAAU;QACR,OAAO,KAAK,CAAC,UAAU,CAAC,EAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAC,CAAC,CAAC;IAC3F,CAAC;IAED,eAAe;QACb,IAAI,CAAC,mBAAmB,EAAG,CAAC,YAAY,CAAC;YACvC,iBAAiB,EAAE;gBACjB,IAAI,EAAE,CAAC;gBACP,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,QAAQ;aACnB;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,CAAC;gBACP,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,WAAW;aACtB;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;I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C;gBACrB,QAAQ,EAAE,gBAAgB;gBAC1B,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,KAAK,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;wBACjD,IAAI,EAAE,CAAC;qBACR;iBACF;aACF,CAAC;YACF,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;;AAjGM,6BAAS,GAAG,qBAAqB,CAAC;eAHtB,mBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-cell-layer.wgsl.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,eAAe,UAAU,MAuEvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/* fragment shader for the grid-layer */
|
|
5
|
+
export default /* glsl */ `\
|
|
6
|
+
#version 300 es
|
|
7
|
+
#define SHADER_NAME screen-grid-layer-fragment-shader
|
|
8
|
+
precision highp float;
|
|
9
|
+
in vec4 vColor;
|
|
10
|
+
out vec4 fragColor;
|
|
11
|
+
void main(void) {
|
|
12
|
+
fragColor = vColor;
|
|
13
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
//# sourceMappingURL=screen-grid-layer-fragment.glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-layer-fragment.glsl.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,wCAAwC;AACxC,eAAe,UAAU;;;;;;;;;;EAevB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const uniformBlockWGSL = null;
|
|
5
|
+
const uniformBlock = /* glsl */ `\
|
|
6
|
+
layout(std140) uniform screenGridUniforms {
|
|
7
|
+
vec2 cellSizeClipspace;
|
|
8
|
+
vec2 gridSizeClipspace;
|
|
9
|
+
vec2 colorDomain;
|
|
10
|
+
} screenGrid;
|
|
11
|
+
`;
|
|
12
|
+
export const screenGridUniforms = {
|
|
13
|
+
name: 'screenGrid',
|
|
14
|
+
source: uniformBlockWGSL,
|
|
15
|
+
vs: uniformBlock,
|
|
16
|
+
uniformTypes: {
|
|
17
|
+
cellSizeClipspace: 'vec2<f32>',
|
|
18
|
+
gridSizeClipspace: 'vec2<f32>',
|
|
19
|
+
colorDomain: 'vec2<f32>'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=screen-grid-layer-uniforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-layer-uniforms.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer-uniforms.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAKpC,MAAM,gBAAgB,QAUpB;AAEF,MAAM,YAAY,GAAG,UAAU,CAAC;;;;;;CAM/B,CAAC;AASF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,gBAAgB;IACxB,EAAE,EAAE,YAAY;IAChB,YAAY,EAAE;QACZ,iBAAiB,EAAE,WAAW;QAC9B,iBAAiB,EAAE,WAAW;QAC9B,WAAW,EAAE,WAAW;KACzB;CAC+C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export default /* glsl */ `\
|
|
5
|
+
#version 300 es
|
|
6
|
+
#define SHADER_NAME screen-grid-layer-vertex-shader
|
|
7
|
+
#define RANGE_COUNT 6
|
|
8
|
+
in vec2 positions;
|
|
9
|
+
in vec2 instancePositions;
|
|
10
|
+
in float instanceWeights;
|
|
11
|
+
uniform sampler2D colorRange;
|
|
12
|
+
out vec4 vColor;
|
|
13
|
+
vec4 interp(float value, vec2 domain, sampler2D range) {
|
|
14
|
+
float r = (value - domain.x) / (domain.y - domain.x);
|
|
15
|
+
return texture(range, vec2(r, 0.5));
|
|
16
|
+
}
|
|
17
|
+
void main(void) {
|
|
18
|
+
if (isnan(instanceWeights)) {
|
|
19
|
+
gl_Position = vec4(0.);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
vec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace;
|
|
23
|
+
pos.x = pos.x - 1.0;
|
|
24
|
+
pos.y = 1.0 - pos.y;
|
|
25
|
+
gl_Position = vec4(pos, 0., 1.);
|
|
26
|
+
vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
|
|
27
|
+
vColor.a *= layer.opacity;
|
|
28
|
+
picking_setPickingColorFromInstanceID();
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=screen-grid-layer-vertex.glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-layer-vertex.glsl.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,eAAe,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCvB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { project32 } from '@deck.gl/core';
|
|
5
|
+
import { WebGLAggregator, CPUAggregator } from "../common/aggregator/index.js";
|
|
6
|
+
import AggregationLayer from "../common/aggregation-layer.js";
|
|
7
|
+
import ScreenGridCellLayer from "./screen-grid-cell-layer.js";
|
|
8
|
+
import { binOptionsUniforms } from "./bin-options-uniforms.js";
|
|
9
|
+
import { defaultColorRange } from "../common/utils/color-utils.js";
|
|
10
|
+
const defaultProps = {
|
|
11
|
+
cellSizePixels: { type: 'number', value: 100, min: 1 },
|
|
12
|
+
cellMarginPixels: { type: 'number', value: 2, min: 0 },
|
|
13
|
+
colorRange: defaultColorRange,
|
|
14
|
+
colorScaleType: 'linear',
|
|
15
|
+
getPosition: { type: 'accessor', value: (d) => d.position },
|
|
16
|
+
getWeight: { type: 'accessor', value: 1 },
|
|
17
|
+
gpuAggregation: true,
|
|
18
|
+
aggregation: 'SUM'
|
|
19
|
+
};
|
|
20
|
+
/** Aggregates data into histogram bins and renders them as a grid. */
|
|
21
|
+
class ScreenGridLayer extends AggregationLayer {
|
|
22
|
+
getAggregatorType() {
|
|
23
|
+
return this.props.gpuAggregation && WebGLAggregator.isSupported(this.context.device)
|
|
24
|
+
? 'gpu'
|
|
25
|
+
: 'cpu';
|
|
26
|
+
}
|
|
27
|
+
createAggregator(type) {
|
|
28
|
+
if (type === 'cpu' || !WebGLAggregator.isSupported(this.context.device)) {
|
|
29
|
+
return new CPUAggregator({
|
|
30
|
+
dimensions: 2,
|
|
31
|
+
getBin: {
|
|
32
|
+
sources: ['positions'],
|
|
33
|
+
getValue: ({ positions }, index, opts) => {
|
|
34
|
+
const viewport = this.context.viewport;
|
|
35
|
+
const p = viewport.project(positions);
|
|
36
|
+
const cellSizePixels = opts.cellSizePixels;
|
|
37
|
+
if (p[0] < 0 || p[0] >= viewport.width || p[1] < 0 || p[1] >= viewport.height) {
|
|
38
|
+
// Not on screen
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return [Math.floor(p[0] / cellSizePixels), Math.floor(p[1] / cellSizePixels)];
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
getValue: [{ sources: ['counts'], getValue: ({ counts }) => counts }]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return new WebGLAggregator(this.context.device, {
|
|
48
|
+
dimensions: 2,
|
|
49
|
+
channelCount: 1,
|
|
50
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts({ isInstanced: false }),
|
|
51
|
+
...super.getShaders({
|
|
52
|
+
modules: [project32, binOptionsUniforms],
|
|
53
|
+
vs: `
|
|
54
|
+
in vec3 positions;
|
|
55
|
+
in vec3 positions64Low;
|
|
56
|
+
in float counts;
|
|
57
|
+
|
|
58
|
+
void getBin(out ivec2 binId) {
|
|
59
|
+
vec4 pos = project_position_to_clipspace(positions, positions64Low, vec3(0.0));
|
|
60
|
+
vec2 screenCoords = vec2(pos.x / pos.w + 1.0, 1.0 - pos.y / pos.w) / 2.0 * project.viewportSize.xy / project.devicePixelRatio;
|
|
61
|
+
vec2 gridCoords = floor(screenCoords / binOptions.cellSizePixels);
|
|
62
|
+
binId = ivec2(gridCoords);
|
|
63
|
+
}
|
|
64
|
+
void getValue(out float weight) {
|
|
65
|
+
weight = counts;
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
initializeState() {
|
|
72
|
+
super.initializeState();
|
|
73
|
+
const attributeManager = this.getAttributeManager();
|
|
74
|
+
attributeManager.add({
|
|
75
|
+
positions: {
|
|
76
|
+
size: 3,
|
|
77
|
+
accessor: 'getPosition',
|
|
78
|
+
type: 'float64',
|
|
79
|
+
fp64: this.use64bitPositions()
|
|
80
|
+
},
|
|
81
|
+
// this attribute is used in gpu aggregation path only
|
|
82
|
+
counts: { size: 1, accessor: 'getWeight' }
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
shouldUpdateState({ changeFlags }) {
|
|
86
|
+
return changeFlags.somethingChanged;
|
|
87
|
+
}
|
|
88
|
+
updateState(params) {
|
|
89
|
+
const aggregatorChanged = super.updateState(params);
|
|
90
|
+
const { props, oldProps, changeFlags } = params;
|
|
91
|
+
const { cellSizePixels, aggregation } = props;
|
|
92
|
+
if (aggregatorChanged ||
|
|
93
|
+
changeFlags.dataChanged ||
|
|
94
|
+
changeFlags.updateTriggersChanged ||
|
|
95
|
+
changeFlags.viewportChanged ||
|
|
96
|
+
aggregation !== oldProps.aggregation ||
|
|
97
|
+
cellSizePixels !== oldProps.cellSizePixels) {
|
|
98
|
+
const { width, height } = this.context.viewport;
|
|
99
|
+
const { aggregator } = this.state;
|
|
100
|
+
if (aggregator instanceof WebGLAggregator) {
|
|
101
|
+
aggregator.setProps({
|
|
102
|
+
binIdRange: [
|
|
103
|
+
[0, Math.ceil(width / cellSizePixels)],
|
|
104
|
+
[0, Math.ceil(height / cellSizePixels)]
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
aggregator.setProps({
|
|
109
|
+
pointCount: this.getNumInstances(),
|
|
110
|
+
operations: [aggregation],
|
|
111
|
+
binOptions: {
|
|
112
|
+
cellSizePixels
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (changeFlags.viewportChanged) {
|
|
117
|
+
// Rerun aggregation on viewport change
|
|
118
|
+
this.state.aggregator.setNeedsUpdate();
|
|
119
|
+
}
|
|
120
|
+
return aggregatorChanged;
|
|
121
|
+
}
|
|
122
|
+
onAttributeChange(id) {
|
|
123
|
+
const { aggregator } = this.state;
|
|
124
|
+
switch (id) {
|
|
125
|
+
case 'positions':
|
|
126
|
+
aggregator.setNeedsUpdate();
|
|
127
|
+
break;
|
|
128
|
+
case 'counts':
|
|
129
|
+
aggregator.setNeedsUpdate(0);
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
// This should not happen
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
renderLayers() {
|
|
136
|
+
const { aggregator } = this.state;
|
|
137
|
+
const CellLayerClass = this.getSubLayerClass('cells', ScreenGridCellLayer);
|
|
138
|
+
const binAttribute = aggregator.getBins();
|
|
139
|
+
const weightAttribute = aggregator.getResult(0);
|
|
140
|
+
return new CellLayerClass(this.props, this.getSubLayerProps({
|
|
141
|
+
id: 'cell-layer'
|
|
142
|
+
}), {
|
|
143
|
+
data: {
|
|
144
|
+
length: aggregator.binCount,
|
|
145
|
+
attributes: {
|
|
146
|
+
getBin: binAttribute,
|
|
147
|
+
getWeight: weightAttribute
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
// Data has changed shallowly, but we likely don't need to update the attributes
|
|
151
|
+
dataComparator: (data, oldData) => data.length === oldData.length,
|
|
152
|
+
updateTriggers: {
|
|
153
|
+
getBin: [binAttribute],
|
|
154
|
+
getWeight: [weightAttribute]
|
|
155
|
+
},
|
|
156
|
+
parameters: {
|
|
157
|
+
depthWriteEnabled: false,
|
|
158
|
+
...this.props.parameters
|
|
159
|
+
},
|
|
160
|
+
// Evaluate domain at draw() time
|
|
161
|
+
colorDomain: () => this.props.colorDomain || aggregator.getResultDomain(0),
|
|
162
|
+
// Extensions are already handled by the GPUAggregator, do not pass it down
|
|
163
|
+
extensions: []
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
getPickingInfo(params) {
|
|
167
|
+
const info = params.info;
|
|
168
|
+
const { index } = info;
|
|
169
|
+
if (index >= 0) {
|
|
170
|
+
const bin = this.state.aggregator.getBin(index);
|
|
171
|
+
let object;
|
|
172
|
+
if (bin) {
|
|
173
|
+
object = {
|
|
174
|
+
col: bin.id[0],
|
|
175
|
+
row: bin.id[1],
|
|
176
|
+
value: bin.value[0],
|
|
177
|
+
count: bin.count
|
|
178
|
+
};
|
|
179
|
+
if (bin.pointIndices) {
|
|
180
|
+
object.pointIndices = bin.pointIndices;
|
|
181
|
+
object.points = Array.isArray(this.props.data)
|
|
182
|
+
? bin.pointIndices.map(i => this.props.data[i])
|
|
183
|
+
: [];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
info.object = object;
|
|
187
|
+
}
|
|
188
|
+
return info;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
ScreenGridLayer.layerName = 'ScreenGridLayer';
|
|
192
|
+
ScreenGridLayer.defaultProps = defaultProps;
|
|
193
|
+
export default ScreenGridLayer;
|
|
194
|
+
//# sourceMappingURL=screen-grid-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-grid-layer.js","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAML,SAAS,EAMV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,eAAe,EAAE,aAAa,EAAuB,sCAAmC;AAChG,OAAO,gBAAgB,uCAAoC;AAC3D,OAAO,mBAAmB,oCAAiC;AAC3D,OAAO,EAAa,kBAAkB,EAAC,kCAA+B;AACtE,OAAO,EAAC,iBAAiB,EAAC,uCAAoC;AAE9D,MAAM,YAAY,GAAuC;IACvD,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAC;IACpD,gBAAgB,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;IACpD,UAAU,EAAE,iBAAiB;IAC7B,cAAc,EAAE,QAAQ;IACxB,WAAW,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAC;IAC9D,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC;IAEvC,cAAc,EAAE,IAAI;IACpB,WAAW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AAC;QACrB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,MAAmD,CAAC;YACxD,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG;oBACP,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACd,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oBACd,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;oBACnB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB,CAAC;gBACF,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;oBACrB,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;oBACvC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;wBAC5C,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,IAAI,CAAC,KAAK,CAAC,IAAgB,CAAC,CAAC,CAAC,CAAC;wBAC5D,CAAC,CAAC,EAAE,CAAC;gBACT,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;;AAhMM,yBAAS,GAAG,iBAAiB,CAAC;AAC9B,4BAAY,GAAG,YAAY,CAAC;eALhB,eAAe"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.4.0-
|
|
6
|
+
"version": "9.4.0-beta.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -17,18 +17,27 @@
|
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/visgl/deck.gl.git"
|
|
19
19
|
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/visgl/deck.gl/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://deck.gl",
|
|
20
24
|
"types": "dist/index.d.ts",
|
|
21
25
|
"main": "dist/index.cjs",
|
|
22
26
|
"module": "dist/index.js",
|
|
23
27
|
"exports": {
|
|
24
28
|
".": {
|
|
25
29
|
"types": "./dist/index.d.ts",
|
|
30
|
+
"visgl:webgl-only": {
|
|
31
|
+
"import": "./dist.webgl-only/index.js",
|
|
32
|
+
"require": "./dist.webgl-only/index.cjs"
|
|
33
|
+
},
|
|
26
34
|
"import": "./dist/index.js",
|
|
27
35
|
"require": "./dist/index.cjs"
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"files": [
|
|
31
39
|
"dist",
|
|
40
|
+
"dist.webgl-only",
|
|
32
41
|
"src",
|
|
33
42
|
"dist.min.js"
|
|
34
43
|
],
|
|
@@ -38,7 +47,7 @@
|
|
|
38
47
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
39
48
|
},
|
|
40
49
|
"dependencies": {
|
|
41
|
-
"@luma.gl/shadertools": "^9.
|
|
50
|
+
"@luma.gl/shadertools": "^9.4.0-beta.3",
|
|
42
51
|
"@math.gl/core": "^4.1.0",
|
|
43
52
|
"@math.gl/web-mercator": "^4.1.0",
|
|
44
53
|
"d3-hexbin": "^0.2.1"
|
|
@@ -46,8 +55,8 @@
|
|
|
46
55
|
"peerDependencies": {
|
|
47
56
|
"@deck.gl/core": "~9.3.0-beta.2",
|
|
48
57
|
"@deck.gl/layers": "~9.3.0-beta.2",
|
|
49
|
-
"@luma.gl/core": "~9.
|
|
50
|
-
"@luma.gl/engine": "~9.
|
|
58
|
+
"@luma.gl/core": "~9.4.0-beta.3",
|
|
59
|
+
"@luma.gl/engine": "~9.4.0-beta.3"
|
|
51
60
|
},
|
|
52
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "5b00a0ced09284c2a642c8ffc56748629f5e796b"
|
|
53
62
|
}
|
|
@@ -112,6 +112,7 @@ export class WebGLAggregationTransform {
|
|
|
112
112
|
transform.run({
|
|
113
113
|
id: 'gpu-aggregation-domain',
|
|
114
114
|
framebuffer: target,
|
|
115
|
+
discard: false,
|
|
115
116
|
parameters: {
|
|
116
117
|
viewport: [0, 0, 2, 1]
|
|
117
118
|
},
|
|
@@ -243,11 +244,8 @@ void main() {
|
|
|
243
244
|
blendAlphaOperation: 'max'
|
|
244
245
|
},
|
|
245
246
|
defines: {
|
|
246
|
-
// @ts-expect-error TODO fix luma type
|
|
247
247
|
NUM_DIMS: props.dimensions,
|
|
248
|
-
// @ts-expect-error TODO fix luma type
|
|
249
248
|
NUM_CHANNELS: props.channelCount,
|
|
250
|
-
// @ts-expect-error TODO fix luma type
|
|
251
249
|
SAMPLER_WIDTH: TEXTURE_WIDTH
|
|
252
250
|
},
|
|
253
251
|
varyings: ['binIds', 'values'],
|
|
@@ -248,7 +248,6 @@ void main() {
|
|
|
248
248
|
const model = new Model(device, {
|
|
249
249
|
bufferLayout: props.bufferLayout,
|
|
250
250
|
modules: [...(props.modules || []), binSorterUniforms],
|
|
251
|
-
// @ts-expect-error TODO fix luma type
|
|
252
251
|
defines: {...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount},
|
|
253
252
|
isInstanced: false,
|
|
254
253
|
vs,
|
|
@@ -7,6 +7,7 @@ import {UpdateParameters, Color} from '@deck.gl/core';
|
|
|
7
7
|
import {ColumnLayer} from '@deck.gl/layers';
|
|
8
8
|
import {CubeGeometry} from '@luma.gl/engine';
|
|
9
9
|
import {createColorRangeTexture, updateColorRangeTexture} from '../common/utils/color-utils';
|
|
10
|
+
import source from './grid-cell-layer.wgsl';
|
|
10
11
|
import vs from './grid-cell-layer-vertex.glsl';
|
|
11
12
|
import {GridProps, gridUniforms} from './grid-layer-uniforms';
|
|
12
13
|
import type {ScaleType} from '../common/types';
|
|
@@ -37,7 +38,7 @@ export class GridCellLayer<ExtraPropsT extends {} = {}> extends ColumnLayer<
|
|
|
37
38
|
getShaders() {
|
|
38
39
|
const shaders = super.getShaders();
|
|
39
40
|
shaders.modules.push(gridUniforms);
|
|
40
|
-
return {...shaders, vs};
|
|
41
|
+
return {...shaders, source, vs};
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
initializeState() {
|
|
@@ -97,7 +98,7 @@ export class GridCellLayer<ExtraPropsT extends {} = {}> extends ColumnLayer<
|
|
|
97
98
|
|
|
98
99
|
protected _updateGeometry() {
|
|
99
100
|
const geometry = new CubeGeometry();
|
|
100
|
-
this.
|
|
101
|
+
this._setFillGeometry(geometry);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
draw({uniforms}) {
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default /* wgsl */ `\
|
|
6
|
+
struct Attributes {
|
|
7
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
8
|
+
@location(0) positions: vec3<f32>,
|
|
9
|
+
@location(1) normals: vec3<f32>,
|
|
10
|
+
@location(2) instancePositions: vec2<f32>,
|
|
11
|
+
@location(3) instanceColorValues: f32,
|
|
12
|
+
@location(4) instanceElevationValues: f32,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
struct Varyings {
|
|
16
|
+
@builtin(position) position: vec4<f32>,
|
|
17
|
+
@location(0) color: vec4<f32>,
|
|
18
|
+
@location(1) pickingColor: vec3<f32>,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
|
|
22
|
+
let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
|
|
23
|
+
return mix(range.x, range.y, ratio);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
27
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
28
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@vertex
|
|
32
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
33
|
+
var output: Varyings;
|
|
34
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
35
|
+
output.pickingColor = geometry.pickingColor;
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
attributes.instanceColorValues != attributes.instanceColorValues ||
|
|
39
|
+
attributes.instanceColorValues < grid.colorDomain.z ||
|
|
40
|
+
attributes.instanceColorValues > grid.colorDomain.w ||
|
|
41
|
+
attributes.instanceElevationValues < grid.elevationDomain.z ||
|
|
42
|
+
attributes.instanceElevationValues > grid.elevationDomain.w
|
|
43
|
+
) {
|
|
44
|
+
output.position = vec4<f32>(0.0);
|
|
45
|
+
output.color = vec4<f32>(0.0);
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let commonPosition =
|
|
50
|
+
(attributes.instancePositions +
|
|
51
|
+
(attributes.positions.xy + vec2<f32>(1.0)) * 0.5 * column.coverage) *
|
|
52
|
+
grid.sizeCommon +
|
|
53
|
+
grid.originCommon -
|
|
54
|
+
project.commonOrigin.xy;
|
|
55
|
+
geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
|
|
56
|
+
geometry.normal = project_normal(attributes.normals);
|
|
57
|
+
|
|
58
|
+
if (column.extruded > 0.5) {
|
|
59
|
+
var elevation = interpolate(
|
|
60
|
+
attributes.instanceElevationValues,
|
|
61
|
+
grid.elevationDomain.xy,
|
|
62
|
+
grid.elevationRange
|
|
63
|
+
);
|
|
64
|
+
elevation = project_size_float(elevation);
|
|
65
|
+
geometry.position.z = (attributes.positions.z + 1.0) * 0.5 * elevation;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
output.position = project_common_position_to_clipspace(geometry.position);
|
|
69
|
+
var colorValue = sampleColorRange(attributes.instanceColorValues, grid.colorDomain.xy);
|
|
70
|
+
if (column.extruded > 0.5) {
|
|
71
|
+
colorValue = vec4<f32>(
|
|
72
|
+
lighting_getLightColor2(
|
|
73
|
+
colorValue.rgb,
|
|
74
|
+
project.cameraPosition,
|
|
75
|
+
geometry.position.xyz,
|
|
76
|
+
geometry.normal
|
|
77
|
+
),
|
|
78
|
+
colorValue.a
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
82
|
+
return output;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@fragment
|
|
86
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
87
|
+
if (picking.isActive > 0.5) {
|
|
88
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
89
|
+
discard;
|
|
90
|
+
}
|
|
91
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var color = varyings.color;
|
|
95
|
+
if (picking.isHighlightActive > 0.5) {
|
|
96
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
97
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
98
|
+
let highlightAlpha = picking.highlightColor.a;
|
|
99
|
+
let blendedAlpha = highlightAlpha + color.a * (1.0 - highlightAlpha);
|
|
100
|
+
if (blendedAlpha > 0.0) {
|
|
101
|
+
let highlightRatio = highlightAlpha / blendedAlpha;
|
|
102
|
+
color = vec4<f32>(
|
|
103
|
+
mix(color.rgb, picking.highlightColor.rgb, highlightRatio),
|
|
104
|
+
blendedAlpha
|
|
105
|
+
);
|
|
106
|
+
} else {
|
|
107
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return deckgl_premultiplied_alpha(color);
|
|
113
|
+
}
|
|
114
|
+
`;
|