@deck.gl/extensions 9.0.35 → 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/brushing/brushing-extension.d.ts +1 -0
- package/dist/brushing/brushing-extension.d.ts.map +1 -1
- package/dist/brushing/brushing-extension.js +15 -19
- package/dist/brushing/shader-module.d.ts +8 -2
- package/dist/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +74 -50
- package/dist/clip/clip-extension.d.ts +5 -2
- package/dist/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +36 -42
- package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
- package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +27 -13
- package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
- package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-extension.js +5 -6
- package/dist/collision-filter/collision-filter-pass.d.ts +7 -3
- package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +8 -3
- package/dist/collision-filter/shader-module.d.ts +3 -2
- package/dist/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +74 -52
- package/dist/data-filter/aggregator.d.ts +4 -10
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +14 -8
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +40 -38
- package/dist/data-filter/shader-module.d.ts +11 -4
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +189 -131
- package/dist/dist.dev.js +2699 -2028
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +11 -4
- package/dist/fill-style/shader-module.d.ts +64 -6
- package/dist/fill-style/shader-module.d.ts.map +1 -1
- package/dist/fill-style/shader-module.js +73 -51
- package/dist/fp64/fp64-extension.d.ts +1 -0
- package/dist/fp64/fp64-extension.d.ts.map +1 -1
- package/dist/fp64/fp64-extension.js +7 -19
- package/dist/fp64/project64.d.ts +2 -2
- package/dist/fp64/project64.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.d.ts +1 -1
- package/dist/fp64/project64.glsl.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.js +18 -21
- package/dist/fp64/project64.js +24 -24
- package/dist/index.cjs +1017 -523
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/mask/mask-effect.d.ts +5 -3
- package/dist/mask/mask-effect.d.ts.map +1 -1
- package/dist/mask/mask-effect.js +12 -5
- package/dist/mask/mask-extension.d.ts +1 -1
- package/dist/mask/mask-extension.d.ts.map +1 -1
- package/dist/mask/mask-extension.js +13 -8
- package/dist/mask/mask-pass.d.ts +38 -38
- package/dist/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +3 -0
- package/dist/mask/shader-module.d.ts +60 -3
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +73 -46
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +20 -24
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +11 -7
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +3 -0
- package/dist/terrain/shader-module.d.ts +60 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +69 -61
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +3 -0
- package/dist/terrain/terrain-effect.d.ts +4 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.js +31 -18
- package/dist/terrain/terrain-extension.d.ts.map +1 -1
- package/dist/terrain/terrain-extension.js +3 -0
- package/dist/terrain/terrain-pass.d.ts +43 -38
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +10 -0
- package/dist/terrain/terrain-picking-pass.d.ts +5 -0
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +10 -0
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +3 -0
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +3 -1
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +3 -0
- package/dist.min.js +1102 -817
- package/package.json +8 -8
- package/src/brushing/brushing-extension.ts +17 -20
- package/src/brushing/shader-module.ts +58 -47
- package/src/clip/clip-extension.ts +38 -40
- package/src/collision-filter/collision-filter-effect.ts +31 -20
- package/src/collision-filter/collision-filter-extension.ts +6 -7
- package/src/collision-filter/collision-filter-pass.ts +9 -3
- package/src/collision-filter/shader-module.ts +40 -22
- package/src/data-filter/aggregator.ts +23 -11
- package/src/data-filter/data-filter-extension.ts +68 -48
- package/src/data-filter/shader-module.ts +144 -84
- package/src/fill-style/fill-style-extension.ts +13 -5
- package/src/fill-style/shader-module.ts +84 -52
- package/src/fp64/fp64-extension.ts +8 -19
- package/src/fp64/project64.glsl.ts +18 -21
- package/src/fp64/project64.ts +27 -28
- package/src/index.ts +5 -0
- package/src/mask/mask-effect.ts +17 -7
- package/src/mask/mask-extension.ts +16 -9
- package/src/mask/mask-pass.ts +4 -0
- package/src/mask/shader-module.ts +63 -27
- package/src/path-style/path-style-extension.ts +27 -28
- package/src/path-style/shaders.glsl.ts +13 -7
- package/src/terrain/height-map-builder.ts +4 -0
- package/src/terrain/shader-module.ts +62 -44
- package/src/terrain/terrain-cover.ts +4 -0
- package/src/terrain/terrain-effect.ts +36 -19
- package/src/terrain/terrain-extension.ts +4 -0
- package/src/terrain/terrain-pass.ts +12 -0
- package/src/terrain/terrain-picking-pass.ts +12 -0
- package/src/terrain/utils.ts +4 -0
- package/src/utils/debug.ts +4 -0
- package/src/utils/projection-utils.ts +4 -0
- package/dist/utils/syntax-tags.d.ts +0 -6
- package/dist/utils/syntax-tags.d.ts.map +0 -1
- package/dist/utils/syntax-tags.js +0 -5
- package/src/utils/syntax-tags.ts +0 -5
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Plug-and-play functionalities for deck.gl layers",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.0.
|
|
6
|
+
"version": "9.1.0-beta.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@luma.gl/constants": "
|
|
42
|
-
"@luma.gl/shadertools": "
|
|
43
|
-
"@math.gl/core": "^4.
|
|
41
|
+
"@luma.gl/constants": "^9.1.0-beta.11",
|
|
42
|
+
"@luma.gl/shadertools": "^9.1.0-beta.11",
|
|
43
|
+
"@math.gl/core": "^4.1.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@deck.gl/core": "
|
|
47
|
-
"@luma.gl/core": "
|
|
48
|
-
"@luma.gl/engine": "
|
|
46
|
+
"@deck.gl/core": "9.0.0-alpha.0",
|
|
47
|
+
"@luma.gl/core": "^9.1.0-beta.11",
|
|
48
|
+
"@luma.gl/engine": "^9.1.0-beta.11"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a86fb154cf323eacc3f56ef087f636fb9f6c30b6"
|
|
51
51
|
}
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
20
4
|
|
|
21
5
|
import {LayerExtension} from '@deck.gl/core';
|
|
22
|
-
import shaderModule from './shader-module';
|
|
6
|
+
import shaderModule, {BrushingModuleProps} from './shader-module';
|
|
23
7
|
|
|
24
8
|
import type {Layer, LayerContext, Accessor} from '@deck.gl/core';
|
|
25
9
|
|
|
@@ -101,4 +85,17 @@ export default class BrushingExtension extends LayerExtension {
|
|
|
101
85
|
});
|
|
102
86
|
}
|
|
103
87
|
}
|
|
88
|
+
|
|
89
|
+
draw(this: Layer<BrushingExtensionProps>, params: any, extension: this) {
|
|
90
|
+
const {viewport, mousePosition} = params.context;
|
|
91
|
+
const {brushingEnabled, brushingRadius, brushingTarget} = this.props;
|
|
92
|
+
const brushingProps: BrushingModuleProps = {
|
|
93
|
+
viewport,
|
|
94
|
+
mousePosition,
|
|
95
|
+
brushingEnabled,
|
|
96
|
+
brushingRadius,
|
|
97
|
+
brushingTarget
|
|
98
|
+
};
|
|
99
|
+
this.setShaderModuleProps({brushing: brushingProps});
|
|
100
|
+
}
|
|
104
101
|
}
|
|
@@ -1,55 +1,50 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
20
5
|
/* eslint-disable camelcase */
|
|
21
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
22
7
|
import {project} from '@deck.gl/core';
|
|
23
8
|
import type {Viewport} from '@deck.gl/core';
|
|
24
9
|
|
|
25
10
|
import type {BrushingExtensionProps} from './brushing-extension';
|
|
26
|
-
import {glsl} from '../utils/syntax-tags';
|
|
27
11
|
|
|
28
|
-
type
|
|
12
|
+
export type BrushingModuleProps = {
|
|
29
13
|
// From layer context
|
|
30
14
|
viewport: Viewport;
|
|
31
15
|
mousePosition?: {x: number; y: number};
|
|
32
16
|
} & BrushingExtensionProps;
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
type BrushingModuleUniforms = {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
target?: number;
|
|
21
|
+
mousePos?: [number, number];
|
|
22
|
+
radius?: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const uniformBlock = /* glsl */ `\
|
|
26
|
+
uniform brushingUniforms {
|
|
27
|
+
bool enabled;
|
|
28
|
+
highp int target;
|
|
29
|
+
vec2 mousePos;
|
|
30
|
+
float radius;
|
|
31
|
+
} brushing;
|
|
32
|
+
`;
|
|
39
33
|
|
|
34
|
+
const vertex = /* glsl */ `
|
|
40
35
|
in vec2 brushingTargets;
|
|
41
36
|
|
|
42
37
|
out float brushing_isVisible;
|
|
43
38
|
|
|
44
39
|
bool brushing_isPointInRange(vec2 position) {
|
|
45
|
-
if (!
|
|
40
|
+
if (!brushing.enabled) {
|
|
46
41
|
return true;
|
|
47
42
|
}
|
|
48
43
|
vec2 source_commonspace = project_position(position);
|
|
49
|
-
vec2 target_commonspace = project_position(
|
|
50
|
-
float distance = length((target_commonspace - source_commonspace) /
|
|
44
|
+
vec2 target_commonspace = project_position(brushing.mousePos);
|
|
45
|
+
float distance = length((target_commonspace - source_commonspace) / project.commonUnitsPerMeter.xy);
|
|
51
46
|
|
|
52
|
-
return distance <=
|
|
47
|
+
return distance <= brushing.radius;
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
|
|
@@ -61,11 +56,20 @@ const vs = glsl`
|
|
|
61
56
|
}
|
|
62
57
|
`;
|
|
63
58
|
|
|
64
|
-
const
|
|
65
|
-
|
|
59
|
+
const vs = `
|
|
60
|
+
${uniformBlock}
|
|
61
|
+
${vertex}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const fragment = /* glsl */ `
|
|
66
65
|
in float brushing_isVisible;
|
|
67
66
|
`;
|
|
68
67
|
|
|
68
|
+
const fs = `
|
|
69
|
+
${uniformBlock}
|
|
70
|
+
${fragment}
|
|
71
|
+
`;
|
|
72
|
+
|
|
69
73
|
const TARGET = {
|
|
70
74
|
source: 0,
|
|
71
75
|
target: 1,
|
|
@@ -74,21 +78,21 @@ const TARGET = {
|
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
const inject = {
|
|
77
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
81
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
78
82
|
vec2 brushingTarget;
|
|
79
83
|
vec2 brushingSource;
|
|
80
|
-
if (
|
|
84
|
+
if (brushing.target == 3) {
|
|
81
85
|
brushingTarget = geometry.worldPositionAlt.xy;
|
|
82
86
|
brushingSource = geometry.worldPosition.xy;
|
|
83
|
-
} else if (
|
|
87
|
+
} else if (brushing.target == 0) {
|
|
84
88
|
brushingTarget = geometry.worldPosition.xy;
|
|
85
|
-
} else if (
|
|
89
|
+
} else if (brushing.target == 1) {
|
|
86
90
|
brushingTarget = geometry.worldPositionAlt.xy;
|
|
87
91
|
} else {
|
|
88
92
|
brushingTarget = brushingTargets;
|
|
89
93
|
}
|
|
90
94
|
bool visible;
|
|
91
|
-
if (
|
|
95
|
+
if (brushing.target == 3) {
|
|
92
96
|
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
|
|
93
97
|
} else {
|
|
94
98
|
visible = brushing_isPointInRange(brushingTarget);
|
|
@@ -97,7 +101,7 @@ const inject = {
|
|
|
97
101
|
`,
|
|
98
102
|
|
|
99
103
|
'fs:DECKGL_FILTER_COLOR': `
|
|
100
|
-
if (
|
|
104
|
+
if (brushing.enabled && brushing_isVisible < 0.5) {
|
|
101
105
|
discard;
|
|
102
106
|
}
|
|
103
107
|
`
|
|
@@ -109,7 +113,7 @@ export default {
|
|
|
109
113
|
vs,
|
|
110
114
|
fs,
|
|
111
115
|
inject,
|
|
112
|
-
getUniforms: (opts?:
|
|
116
|
+
getUniforms: (opts?: BrushingModuleProps | {}): BrushingModuleUniforms => {
|
|
113
117
|
if (!opts || !('viewport' in opts)) {
|
|
114
118
|
return {};
|
|
115
119
|
}
|
|
@@ -121,14 +125,21 @@ export default {
|
|
|
121
125
|
viewport
|
|
122
126
|
} = opts;
|
|
123
127
|
return {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
|
|
129
|
+
radius: brushingRadius,
|
|
130
|
+
target: TARGET[brushingTarget] || 0,
|
|
131
|
+
mousePos: mousePosition
|
|
132
|
+
? (viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y]) as [
|
|
133
|
+
number,
|
|
134
|
+
number
|
|
135
|
+
])
|
|
131
136
|
: [0, 0]
|
|
132
137
|
};
|
|
138
|
+
},
|
|
139
|
+
uniformTypes: {
|
|
140
|
+
enabled: 'i32',
|
|
141
|
+
target: 'i32',
|
|
142
|
+
mousePos: 'vec2<f32>',
|
|
143
|
+
radius: 'f32'
|
|
133
144
|
}
|
|
134
|
-
} as ShaderModule<
|
|
145
|
+
} as ShaderModule<BrushingModuleProps, BrushingModuleUniforms, {}>;
|
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
20
4
|
|
|
21
5
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
22
6
|
import {LayerExtension} from '@deck.gl/core';
|
|
23
7
|
|
|
24
8
|
import type {Layer} from '@deck.gl/core';
|
|
25
|
-
import {glsl} from '../utils/syntax-tags';
|
|
26
9
|
|
|
27
10
|
const defaultProps = {
|
|
28
11
|
clipBounds: [0, 0, 1, 1],
|
|
@@ -41,34 +24,43 @@ export type ClipExtensionProps = {
|
|
|
41
24
|
clipByInstance?: boolean;
|
|
42
25
|
};
|
|
43
26
|
|
|
44
|
-
const shaderFunction = glsl`
|
|
45
|
-
uniform
|
|
27
|
+
const shaderFunction = /* glsl */ `
|
|
28
|
+
uniform clipUniforms {
|
|
29
|
+
vec4 bounds;
|
|
30
|
+
} clip;
|
|
46
31
|
|
|
47
32
|
bool clip_isInBounds(vec2 position) {
|
|
48
|
-
return position.x >=
|
|
33
|
+
return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];
|
|
49
34
|
}
|
|
50
35
|
`;
|
|
51
36
|
|
|
37
|
+
export type ClipModuleProps = {
|
|
38
|
+
bounds: [number, number, number, number];
|
|
39
|
+
};
|
|
40
|
+
|
|
52
41
|
/*
|
|
53
42
|
* The vertex-shader version clips geometries by their anchor position
|
|
54
43
|
* e.g. ScatterplotLayer - show if the center of a circle is within bounds
|
|
55
44
|
*/
|
|
56
|
-
const shaderModuleVs: ShaderModule = {
|
|
57
|
-
name: 'clip
|
|
58
|
-
vs: shaderFunction
|
|
45
|
+
const shaderModuleVs: ShaderModule<ClipModuleProps> = {
|
|
46
|
+
name: 'clip',
|
|
47
|
+
vs: shaderFunction,
|
|
48
|
+
uniformTypes: {
|
|
49
|
+
bounds: 'vec4<f32>'
|
|
50
|
+
}
|
|
59
51
|
};
|
|
60
52
|
|
|
61
53
|
const injectionVs = {
|
|
62
|
-
'vs:#decl': glsl`
|
|
54
|
+
'vs:#decl': /* glsl */ `
|
|
63
55
|
out float clip_isVisible;
|
|
64
56
|
`,
|
|
65
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
57
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
66
58
|
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
|
|
67
59
|
`,
|
|
68
|
-
'fs:#decl': glsl`
|
|
60
|
+
'fs:#decl': /* glsl */ `
|
|
69
61
|
in float clip_isVisible;
|
|
70
62
|
`,
|
|
71
|
-
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
63
|
+
'fs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
72
64
|
if (clip_isVisible < 0.5) discard;
|
|
73
65
|
`
|
|
74
66
|
};
|
|
@@ -77,22 +69,25 @@ in float clip_isVisible;
|
|
|
77
69
|
* The fragment-shader version clips pixels at the bounds
|
|
78
70
|
* e.g. PolygonLayer - show the part of the polygon that intersect with the bounds
|
|
79
71
|
*/
|
|
80
|
-
const shaderModuleFs: ShaderModule = {
|
|
81
|
-
name: 'clip
|
|
82
|
-
fs: shaderFunction
|
|
72
|
+
const shaderModuleFs: ShaderModule<ClipModuleProps> = {
|
|
73
|
+
name: 'clip',
|
|
74
|
+
fs: shaderFunction,
|
|
75
|
+
uniformTypes: {
|
|
76
|
+
bounds: 'vec4<f32>'
|
|
77
|
+
}
|
|
83
78
|
};
|
|
84
79
|
|
|
85
80
|
const injectionFs = {
|
|
86
|
-
'vs:#decl': glsl`
|
|
81
|
+
'vs:#decl': /* glsl */ `
|
|
87
82
|
out vec2 clip_commonPosition;
|
|
88
83
|
`,
|
|
89
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
84
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
90
85
|
clip_commonPosition = geometry.position.xy;
|
|
91
86
|
`,
|
|
92
|
-
'fs:#decl': glsl`
|
|
87
|
+
'fs:#decl': /* glsl */ `
|
|
93
88
|
in vec2 clip_commonPosition;
|
|
94
89
|
`,
|
|
95
|
-
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
90
|
+
'fs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
96
91
|
if (!clip_isInBounds(clip_commonPosition)) discard;
|
|
97
92
|
`
|
|
98
93
|
};
|
|
@@ -126,20 +121,23 @@ export default class ClipExtension extends LayerExtension {
|
|
|
126
121
|
}
|
|
127
122
|
|
|
128
123
|
/* eslint-disable camelcase */
|
|
129
|
-
draw(this: Layer<Required<ClipExtensionProps
|
|
124
|
+
draw(this: Layer<Required<ClipExtensionProps>>): void {
|
|
130
125
|
const {clipBounds} = this.props;
|
|
126
|
+
const clipProps = {} as ClipModuleProps;
|
|
131
127
|
if (this.state.clipByInstance) {
|
|
132
|
-
|
|
128
|
+
clipProps.bounds = clipBounds;
|
|
133
129
|
} else {
|
|
134
130
|
const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
|
|
135
131
|
const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
|
|
136
132
|
|
|
137
|
-
|
|
133
|
+
clipProps.bounds = [
|
|
138
134
|
Math.min(corner0[0], corner1[0]),
|
|
139
135
|
Math.min(corner0[1], corner1[1]),
|
|
140
136
|
Math.max(corner0[0], corner1[0]),
|
|
141
137
|
Math.max(corner0[1], corner1[1])
|
|
142
138
|
];
|
|
143
139
|
}
|
|
140
|
+
|
|
141
|
+
this.setShaderModuleProps({clip: clipProps});
|
|
144
142
|
}
|
|
145
143
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Device, Framebuffer, Texture} from '@luma.gl/core';
|
|
2
6
|
import {equals} from '@math.gl/core';
|
|
3
7
|
import {_deepEqual as deepEqual} from '@deck.gl/core';
|
|
@@ -6,10 +10,8 @@ import CollisionFilterPass from './collision-filter-pass';
|
|
|
6
10
|
import {MaskPreRenderStats} from '../mask/mask-effect';
|
|
7
11
|
// import {debugFBO} from '../utils/debug';
|
|
8
12
|
|
|
9
|
-
type CollisionFilterExtensionProps
|
|
10
|
-
|
|
11
|
-
collisionGroup: string;
|
|
12
|
-
};
|
|
13
|
+
import type {CollisionFilterExtensionProps} from './collision-filter-extension';
|
|
14
|
+
import type {CollisionModuleProps} from './shader-module';
|
|
13
15
|
|
|
14
16
|
// Factor by which to downscale Collision FBO relative to canvas
|
|
15
17
|
const DOWNSCALE = 2;
|
|
@@ -155,11 +157,16 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
155
157
|
viewports: viewport ? [viewport] : [],
|
|
156
158
|
onViewportActive,
|
|
157
159
|
views,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
shaderModuleProps: {
|
|
161
|
+
collision: {
|
|
162
|
+
enabled: true,
|
|
163
|
+
// To avoid feedback loop forming between Framebuffer and active Texture.
|
|
164
|
+
dummyCollisionMap: this.dummyCollisionMap
|
|
165
|
+
},
|
|
166
|
+
project: {
|
|
167
|
+
// @ts-expect-error TODO - assuming WebGL context
|
|
168
|
+
devicePixelRatio: collisionFBO.device.canvasContext.getDevicePixelRatio() / DOWNSCALE
|
|
169
|
+
}
|
|
163
170
|
}
|
|
164
171
|
});
|
|
165
172
|
}
|
|
@@ -175,7 +182,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
175
182
|
): Record<string, RenderInfo> {
|
|
176
183
|
const channelMap = {};
|
|
177
184
|
for (const layer of collisionLayers) {
|
|
178
|
-
const
|
|
185
|
+
const collisionGroup = layer.props.collisionGroup!;
|
|
179
186
|
let channelInfo = channelMap[collisionGroup];
|
|
180
187
|
if (!channelInfo) {
|
|
181
188
|
channelInfo = {collisionGroup, layers: [], layerBounds: [], allLayersLoaded: true};
|
|
@@ -206,13 +213,21 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
206
213
|
return channelMap;
|
|
207
214
|
}
|
|
208
215
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
dummyCollisionMap: Texture;
|
|
216
|
+
getShaderModuleProps(layer: Layer): {
|
|
217
|
+
collision: CollisionModuleProps;
|
|
212
218
|
} {
|
|
213
|
-
const {collisionGroup} = (layer as Layer<CollisionFilterExtensionProps>)
|
|
219
|
+
const {collisionGroup, collisionEnabled} = (layer as Layer<CollisionFilterExtensionProps>)
|
|
220
|
+
.props;
|
|
214
221
|
const {collisionFBOs, dummyCollisionMap} = this;
|
|
215
|
-
|
|
222
|
+
const collisionFBO = collisionFBOs[collisionGroup!];
|
|
223
|
+
const enabled = collisionEnabled && Boolean(collisionFBO);
|
|
224
|
+
return {
|
|
225
|
+
collision: {
|
|
226
|
+
enabled,
|
|
227
|
+
collisionFBO,
|
|
228
|
+
dummyCollisionMap: dummyCollisionMap!
|
|
229
|
+
}
|
|
230
|
+
};
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
cleanup(): void {
|
|
@@ -248,11 +263,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
248
263
|
format: 'depth16unorm',
|
|
249
264
|
width,
|
|
250
265
|
height,
|
|
251
|
-
mipmaps: false
|
|
252
|
-
|
|
253
|
-
// TODO fix getWebGLTextureParameters() in luma to avoid passing deprecated parameters
|
|
254
|
-
dataFormat: 6402, // gl.DEPTH_COMPONENT
|
|
255
|
-
type: 5125 // gl.UNSIGNED_INT
|
|
266
|
+
mipmaps: false
|
|
256
267
|
});
|
|
257
268
|
this.collisionFBOs[collisionGroup] = device.createFramebuffer({
|
|
258
269
|
id: `collision-${collisionGroup}`,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Accessor, Layer, LayerContext, LayerExtension} from '@deck.gl/core';
|
|
2
6
|
import collision from './shader-module';
|
|
3
7
|
import CollisionFilterEffect from './collision-filter-effect';
|
|
@@ -42,13 +46,8 @@ export default class CollisionFilterExtension extends LayerExtension {
|
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/* eslint-disable camelcase */
|
|
45
|
-
draw(this: Layer<CollisionFilterExtensionProps>, {
|
|
46
|
-
|
|
47
|
-
const {collisionFBO, drawToCollisionMap} = moduleParameters;
|
|
48
|
-
const enabled = collisionEnabled && Boolean(collisionFBO);
|
|
49
|
-
uniforms.collision_enabled = enabled;
|
|
50
|
-
|
|
51
|
-
if (drawToCollisionMap) {
|
|
49
|
+
draw(this: Layer<CollisionFilterExtensionProps>, {shaderModuleProps}: any) {
|
|
50
|
+
if (shaderModuleProps.collision?.drawToCollisionMap) {
|
|
52
51
|
// Override any props with those defined in collisionTestProps
|
|
53
52
|
// @ts-ignore
|
|
54
53
|
this.props = this.clone(this.props.collisionTestProps).props;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Framebuffer} from '@luma.gl/core';
|
|
2
6
|
import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';
|
|
3
7
|
|
|
@@ -16,15 +20,17 @@ export default class CollisionFilterPass extends LayersPass {
|
|
|
16
20
|
return {...layer.props.parameters, blend: false, depthRange: [0, 1], depthTest: true};
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
getShaderModuleProps() {
|
|
20
24
|
// Draw picking colors into collision FBO
|
|
21
25
|
return {
|
|
22
|
-
|
|
26
|
+
collision: {
|
|
27
|
+
drawToCollisionMap: true
|
|
28
|
+
},
|
|
23
29
|
picking: {
|
|
24
30
|
isActive: 1,
|
|
25
31
|
isAttribute: false
|
|
26
32
|
},
|
|
27
|
-
|
|
33
|
+
lighting: {enabled: false}
|
|
28
34
|
};
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Framebuffer, Texture, TextureView} from '@luma.gl/core';
|
|
2
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
3
7
|
import {project} from '@deck.gl/core';
|
|
4
|
-
import {glsl} from '../utils/syntax-tags';
|
|
5
8
|
|
|
6
|
-
const vs = glsl`
|
|
9
|
+
const vs = /* glsl */ `
|
|
7
10
|
in float collisionPriorities;
|
|
8
11
|
|
|
9
12
|
uniform sampler2D collision_texture;
|
|
10
|
-
|
|
11
|
-
uniform
|
|
13
|
+
|
|
14
|
+
uniform collisionUniforms {
|
|
15
|
+
bool sort;
|
|
16
|
+
bool enabled;
|
|
17
|
+
} collision;
|
|
12
18
|
|
|
13
19
|
vec2 collision_getCoords(vec4 position) {
|
|
14
20
|
vec4 collision_clipspace = project_common_position_to_clipspace(position);
|
|
@@ -23,7 +29,7 @@ float collision_match(vec2 tex, vec3 pickingColor) {
|
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
26
|
-
if (!
|
|
32
|
+
if (!collision.enabled) {
|
|
27
33
|
return 1.0;
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -32,7 +38,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
32
38
|
// This reduces the flicker present when objects are shown/hidden
|
|
33
39
|
const int N = 2;
|
|
34
40
|
float accumulator = 0.0;
|
|
35
|
-
vec2 step = vec2(1.0 /
|
|
41
|
+
vec2 step = vec2(1.0 / project.viewportSize);
|
|
36
42
|
|
|
37
43
|
const float floatN = float(N);
|
|
38
44
|
vec2 delta = -floatN * step;
|
|
@@ -51,16 +57,16 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
51
57
|
`;
|
|
52
58
|
|
|
53
59
|
const inject = {
|
|
54
|
-
'vs:#decl': glsl`
|
|
60
|
+
'vs:#decl': /* glsl */ `
|
|
55
61
|
float collision_fade = 1.0;
|
|
56
62
|
`,
|
|
57
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
58
|
-
if (
|
|
63
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
64
|
+
if (collision.sort) {
|
|
59
65
|
float collisionPriority = collisionPriorities;
|
|
60
66
|
position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
if (
|
|
69
|
+
if (collision.enabled) {
|
|
64
70
|
vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
65
71
|
vec2 collision_texCoords = collision_getCoords(collision_common_position);
|
|
66
72
|
collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
|
|
@@ -70,40 +76,52 @@ const inject = {
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
`,
|
|
73
|
-
'vs:DECKGL_FILTER_COLOR': glsl`
|
|
79
|
+
'vs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
74
80
|
color.a *= collision_fade;
|
|
75
81
|
`
|
|
76
82
|
};
|
|
77
83
|
|
|
78
|
-
type
|
|
84
|
+
export type CollisionModuleProps = {
|
|
85
|
+
enabled: boolean;
|
|
79
86
|
collisionFBO?: Framebuffer;
|
|
80
87
|
drawToCollisionMap?: boolean;
|
|
81
88
|
dummyCollisionMap?: Texture;
|
|
82
89
|
};
|
|
83
90
|
|
|
84
91
|
/* eslint-disable camelcase */
|
|
85
|
-
type CollisionUniforms = {
|
|
92
|
+
type CollisionUniforms = {
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
sort?: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type CollisionBindings = {
|
|
98
|
+
collision_texture?: TextureView | Texture;
|
|
99
|
+
};
|
|
86
100
|
|
|
87
101
|
const getCollisionUniforms = (
|
|
88
|
-
opts:
|
|
89
|
-
|
|
90
|
-
): CollisionUniforms => {
|
|
102
|
+
opts: CollisionModuleProps | {}
|
|
103
|
+
): CollisionBindings & CollisionUniforms => {
|
|
91
104
|
if (!opts || !('dummyCollisionMap' in opts)) {
|
|
92
105
|
return {};
|
|
93
106
|
}
|
|
94
|
-
const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;
|
|
107
|
+
const {enabled, collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;
|
|
95
108
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
enabled: enabled && !drawToCollisionMap,
|
|
110
|
+
sort: Boolean(drawToCollisionMap),
|
|
98
111
|
collision_texture:
|
|
99
112
|
!drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap
|
|
100
113
|
};
|
|
101
114
|
};
|
|
102
115
|
|
|
116
|
+
// @ts-ignore
|
|
103
117
|
export default {
|
|
104
118
|
name: 'collision',
|
|
105
119
|
dependencies: [project],
|
|
106
120
|
vs,
|
|
107
121
|
inject,
|
|
108
|
-
getUniforms: getCollisionUniforms
|
|
109
|
-
|
|
122
|
+
getUniforms: getCollisionUniforms,
|
|
123
|
+
uniformTypes: {
|
|
124
|
+
sort: 'i32',
|
|
125
|
+
enabled: 'i32'
|
|
126
|
+
}
|
|
127
|
+
} as ShaderModule<CollisionModuleProps>;
|