@deck.gl/extensions 9.0.0-beta.5 → 9.0.0-beta.7
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/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +52 -57
- package/dist/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +6 -6
- package/dist/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +46 -56
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +11 -14
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +2 -5
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +70 -78
- package/dist/dist.dev.js +799 -1007
- package/dist/fill-style/fill-style-extension.js +1 -1
- package/dist/fill-style/{shaders.glsl.d.ts → shader-module.d.ts} +1 -1
- package/dist/fill-style/shader-module.d.ts.map +1 -0
- package/dist/fill-style/{shaders.glsl.js → shader-module.js} +27 -33
- package/dist/fp64/project64.glsl.js +41 -60
- package/dist/index.cjs +363 -430
- package/dist/index.cjs.map +4 -4
- package/dist/mask/mask-pass.js +2 -2
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +33 -37
- package/dist/path-style/shaders.glsl.js +42 -47
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +30 -32
- package/dist/terrain/terrain-pass.js +2 -2
- package/dist/terrain/utils.js +2 -2
- package/dist/utils/syntax-tags.d.ts +6 -0
- package/dist/utils/syntax-tags.d.ts.map +1 -0
- package/dist/utils/syntax-tags.js +5 -0
- package/dist.min.js +862 -1120
- package/package.json +8 -12
- package/src/brushing/shader-module.ts +4 -3
- package/src/clip/clip-extension.ts +10 -9
- package/src/collision-filter/shader-module.ts +6 -4
- package/src/data-filter/aggregator.ts +8 -13
- package/src/data-filter/data-filter-extension.ts +2 -5
- package/src/data-filter/shader-module.ts +7 -6
- package/src/fill-style/fill-style-extension.ts +1 -1
- package/src/fill-style/{shaders.glsl.ts → shader-module.ts} +6 -5
- package/src/mask/shader-module.ts +7 -6
- package/src/terrain/shader-module.ts +11 -10
- package/src/terrain/utils.ts +1 -1
- package/src/utils/syntax-tags.ts +5 -0
- package/dist/fill-style/shaders.glsl.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/brushing/shader-module.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAC,sBAAsB,EAAC,gCAA6B;
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/brushing/shader-module.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAC,sBAAsB,EAAC,gCAA6B;AAGjE,KAAK,sBAAsB,GAAG;IAE5B,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,CAAC,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CACxC,GAAG,sBAAsB,CAAC;;AAkF3B,wBA4B0C"}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
import { project } from '@deck.gl/core';
|
|
2
|
+
import { glsl } from "../utils/syntax-tags.js";
|
|
2
3
|
const vs = `
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
void brushing_setVisible(bool visible) {
|
|
32
|
-
brushing_isVisible = float(visible);
|
|
33
|
-
}
|
|
4
|
+
uniform bool brushing_enabled;
|
|
5
|
+
uniform int brushing_target;
|
|
6
|
+
uniform vec2 brushing_mousePos;
|
|
7
|
+
uniform float brushing_radius;
|
|
8
|
+
#ifdef NON_INSTANCED_MODEL
|
|
9
|
+
in vec2 brushingTargets;
|
|
10
|
+
#else
|
|
11
|
+
in vec2 instanceBrushingTargets;
|
|
12
|
+
#endif
|
|
13
|
+
out float brushing_isVisible;
|
|
14
|
+
bool brushing_isPointInRange(vec2 position) {
|
|
15
|
+
if (!brushing_enabled) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
vec2 source_commonspace = project_position(position);
|
|
19
|
+
vec2 target_commonspace = project_position(brushing_mousePos);
|
|
20
|
+
float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
|
|
21
|
+
return distance <= brushing_radius;
|
|
22
|
+
}
|
|
23
|
+
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
|
|
24
|
+
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
|
|
25
|
+
}
|
|
26
|
+
void brushing_setVisible(bool visible) {
|
|
27
|
+
brushing_isVisible = float(visible);
|
|
28
|
+
}
|
|
34
29
|
`;
|
|
35
30
|
const fs = `
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
uniform bool brushing_enabled;
|
|
32
|
+
in float brushing_isVisible;
|
|
38
33
|
`;
|
|
39
34
|
const TARGET = {
|
|
40
35
|
source: 0,
|
|
@@ -44,30 +39,30 @@ const TARGET = {
|
|
|
44
39
|
};
|
|
45
40
|
const inject = {
|
|
46
41
|
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
42
|
+
vec2 brushingTarget;
|
|
43
|
+
vec2 brushingSource;
|
|
44
|
+
if (brushing_target == 3) {
|
|
45
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
46
|
+
brushingSource = geometry.worldPosition.xy;
|
|
47
|
+
} else if (brushing_target == 0) {
|
|
48
|
+
brushingTarget = geometry.worldPosition.xy;
|
|
49
|
+
} else if (brushing_target == 1) {
|
|
50
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
51
|
+
} else {
|
|
52
|
+
#ifdef NON_INSTANCED_MODEL
|
|
53
|
+
brushingTarget = brushingTargets;
|
|
54
|
+
#else
|
|
55
|
+
brushingTarget = instanceBrushingTargets;
|
|
56
|
+
#endif
|
|
57
|
+
}
|
|
58
|
+
bool visible;
|
|
59
|
+
if (brushing_target == 3) {
|
|
60
|
+
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
|
|
61
|
+
} else {
|
|
62
|
+
visible = brushing_isPointInRange(brushingTarget);
|
|
63
|
+
}
|
|
64
|
+
brushing_setVisible(visible);
|
|
65
|
+
`,
|
|
71
66
|
'fs:DECKGL_FILTER_COLOR': `
|
|
72
67
|
if (brushing_enabled && brushing_isVisible < 0.5) {
|
|
73
68
|
discard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-extension.d.ts","sourceRoot":"","sources":["../../src/clip/clip-extension.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"clip-extension.d.ts","sourceRoot":"","sources":["../../src/clip/clip-extension.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAQzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AA0DF,uEAAuE;AACvE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc;IACvD,MAAM,CAAC,YAAY;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAmB;IAEvC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC;;;;;;;;;IAwB1C,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAC,QAAQ,EAAC,EAAE,GAAG,GAAG,IAAI;CAgBvE"}
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
import { LayerExtension } from '@deck.gl/core';
|
|
21
|
+
import { glsl } from "../utils/syntax-tags.js";
|
|
21
22
|
const defaultProps = {
|
|
22
23
|
clipBounds: [0, 0, 1, 1],
|
|
23
24
|
clipByInstance: undefined
|
|
24
25
|
};
|
|
25
26
|
const shaderFunction = `
|
|
26
27
|
uniform vec4 clip_bounds;
|
|
27
|
-
|
|
28
28
|
bool clip_isInBounds(vec2 position) {
|
|
29
|
-
|
|
29
|
+
return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
32
32
|
/*
|
|
@@ -42,13 +42,13 @@ const injectionVs = {
|
|
|
42
42
|
out float clip_isVisible;
|
|
43
43
|
`,
|
|
44
44
|
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
45
|
-
|
|
45
|
+
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
|
|
46
46
|
`,
|
|
47
47
|
'fs:#decl': `
|
|
48
48
|
in float clip_isVisible;
|
|
49
49
|
`,
|
|
50
50
|
'fs:DECKGL_FILTER_COLOR': `
|
|
51
|
-
|
|
51
|
+
if (clip_isVisible < 0.5) discard;
|
|
52
52
|
`
|
|
53
53
|
};
|
|
54
54
|
/*
|
|
@@ -64,13 +64,13 @@ const injectionFs = {
|
|
|
64
64
|
out vec2 clip_commonPosition;
|
|
65
65
|
`,
|
|
66
66
|
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
67
|
-
|
|
67
|
+
clip_commonPosition = geometry.position.xy;
|
|
68
68
|
`,
|
|
69
69
|
'fs:#decl': `
|
|
70
70
|
in vec2 clip_commonPosition;
|
|
71
71
|
`,
|
|
72
72
|
'fs:DECKGL_FILTER_COLOR': `
|
|
73
|
-
|
|
73
|
+
if (!clip_isInBounds(clip_commonPosition)) discard;
|
|
74
74
|
`
|
|
75
75
|
};
|
|
76
76
|
/** Adds support for clipping rendered layers by rectangular bounds. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collision-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collision-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAoFvD,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;;AAsBF,wBAM2C"}
|
|
@@ -1,81 +1,70 @@
|
|
|
1
1
|
import { project } from '@deck.gl/core';
|
|
2
|
+
import { glsl } from "../utils/syntax-tags.js";
|
|
2
3
|
const vs = `
|
|
3
4
|
#ifdef NON_INSTANCED_MODEL
|
|
4
5
|
in float collisionPriorities;
|
|
5
6
|
#else
|
|
6
7
|
in float instanceCollisionPriorities;
|
|
7
8
|
#endif
|
|
8
|
-
|
|
9
9
|
uniform sampler2D collision_texture;
|
|
10
10
|
uniform bool collision_sort;
|
|
11
11
|
uniform bool collision_enabled;
|
|
12
|
-
|
|
13
12
|
vec2 collision_getCoords(vec4 position) {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
vec4 collision_clipspace = project_common_position_to_clipspace(position);
|
|
14
|
+
return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
float collision_match(vec2 tex, vec3 pickingColor) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
vec4 collision_pickingColor = texture(collision_texture, tex);
|
|
18
|
+
float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));
|
|
19
|
+
float e = 0.001;
|
|
20
|
+
return step(delta, e);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
delta.y += step.y;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
float W = 2.0 * floatN + 1.0;
|
|
49
|
-
return pow(accumulator / (W * W), 2.2);
|
|
23
|
+
if (!collision_enabled) {
|
|
24
|
+
return 1.0;
|
|
25
|
+
}
|
|
26
|
+
const int N = 2;
|
|
27
|
+
float accumulator = 0.0;
|
|
28
|
+
vec2 step = vec2(1.0 / project_uViewportSize);
|
|
29
|
+
const float floatN = float(N);
|
|
30
|
+
vec2 delta = -floatN * step;
|
|
31
|
+
for(int i = -N; i <= N; i++) {
|
|
32
|
+
delta.x = -step.x * floatN;
|
|
33
|
+
for(int j = -N; j <= N; j++) {
|
|
34
|
+
accumulator += collision_match(texCoords + delta, pickingColor);
|
|
35
|
+
delta.x += step.x;
|
|
36
|
+
}
|
|
37
|
+
delta.y += step.y;
|
|
38
|
+
}
|
|
39
|
+
float W = 2.0 * floatN + 1.0;
|
|
40
|
+
return pow(accumulator / (W * W), 2.2);
|
|
50
41
|
}
|
|
51
42
|
`;
|
|
52
43
|
const inject = {
|
|
53
44
|
'vs:#decl': `
|
|
54
|
-
|
|
45
|
+
float collision_fade = 1.0;
|
|
55
46
|
`,
|
|
56
47
|
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
`,
|
|
48
|
+
if (collision_sort) {
|
|
49
|
+
#ifdef NON_INSTANCED_MODEL
|
|
50
|
+
float collisionPriority = collisionPriorities;
|
|
51
|
+
#else
|
|
52
|
+
float collisionPriority = instanceCollisionPriorities;
|
|
53
|
+
#endif
|
|
54
|
+
position.z = -0.001 * collisionPriority * position.w;
|
|
55
|
+
}
|
|
56
|
+
if (collision_enabled) {
|
|
57
|
+
vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
58
|
+
vec2 collision_texCoords = collision_getCoords(collision_common_position);
|
|
59
|
+
collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
|
|
60
|
+
if (collision_fade < 0.0001) {
|
|
61
|
+
position = vec4(0.0, 0.0, 2.0, 1.0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
76
65
|
'vs:DECKGL_FILTER_COLOR': `
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
color.a *= collision_fade;
|
|
67
|
+
`
|
|
79
68
|
};
|
|
80
69
|
const getCollisionUniforms = (opts, uniforms) => {
|
|
81
70
|
if (!opts || !('dummyCollisionMap' in opts)) {
|
|
@@ -84,6 +73,7 @@ const getCollisionUniforms = (opts, uniforms) => {
|
|
|
84
73
|
const { collisionFBO, drawToCollisionMap, dummyCollisionMap } = opts;
|
|
85
74
|
return {
|
|
86
75
|
collision_sort: Boolean(drawToCollisionMap),
|
|
76
|
+
// @ts-ignore (v9 not sure why this isn't allowed now)
|
|
87
77
|
collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap
|
|
88
78
|
};
|
|
89
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../src/data-filter/aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../src/data-filter/aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAiB,WAAW,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AA0DtC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE3D;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,GAAG,WAAW,CAmBnF;AAGD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,KAAK,CAe3F;AAED,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
|
@@ -49,15 +49,12 @@ void main() {
|
|
|
49
49
|
fragColor = vColor;
|
|
50
50
|
}
|
|
51
51
|
`;
|
|
52
|
+
const FLOAT_TARGET_FEATURES = [
|
|
53
|
+
'float32-renderable-webgl', // ability to render to float texture
|
|
54
|
+
'texture-blend-float-webgl' // ability to blend when rendering to float texture
|
|
55
|
+
];
|
|
52
56
|
export function supportsFloatTarget(device) {
|
|
53
|
-
|
|
54
|
-
const gl = device.gl;
|
|
55
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!
|
|
56
|
-
return Boolean(gl.getExtension('EXT_float_blend') &&
|
|
57
|
-
// WebGL 2
|
|
58
|
-
(gl.getExtension('EXT_color_buffer_float') ||
|
|
59
|
-
// WebGL 1
|
|
60
|
-
gl.getExtension('WEBGL_color_buffer_float')));
|
|
57
|
+
return FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
|
|
61
58
|
}
|
|
62
59
|
// A 1x1 framebuffer object that encodes the total count of filtered items
|
|
63
60
|
export function getFramebuffer(device, useFloatTarget) {
|
|
@@ -67,8 +64,8 @@ export function getFramebuffer(device, useFloatTarget) {
|
|
|
67
64
|
height: 1,
|
|
68
65
|
colorAttachments: [
|
|
69
66
|
device.createTexture({
|
|
70
|
-
format:
|
|
71
|
-
type:
|
|
67
|
+
format: 'rgba32float',
|
|
68
|
+
type: 5126,
|
|
72
69
|
mipmaps: false
|
|
73
70
|
})
|
|
74
71
|
]
|
|
@@ -77,7 +74,7 @@ export function getFramebuffer(device, useFloatTarget) {
|
|
|
77
74
|
return device.createFramebuffer({
|
|
78
75
|
width: 256,
|
|
79
76
|
height: 64,
|
|
80
|
-
colorAttachments: [device.createTexture({ format: 'rgba8unorm', type:
|
|
77
|
+
colorAttachments: [device.createTexture({ format: 'rgba8unorm', type: 5126, mipmaps: false })]
|
|
81
78
|
});
|
|
82
79
|
}
|
|
83
80
|
// Increments the counter based on dataFilter_value
|
|
@@ -90,7 +87,7 @@ export function getModel(device, shaderOptions, useFloatTarget) {
|
|
|
90
87
|
id: 'data-filter-aggregation-model',
|
|
91
88
|
vertexCount: 1,
|
|
92
89
|
isInstanced: false,
|
|
93
|
-
drawMode:
|
|
90
|
+
drawMode: 0,
|
|
94
91
|
vs: AGGREGATE_VS,
|
|
95
92
|
fs: AGGREGATE_FS,
|
|
96
93
|
...shaderOptions
|
|
@@ -98,7 +95,7 @@ export function getModel(device, shaderOptions, useFloatTarget) {
|
|
|
98
95
|
}
|
|
99
96
|
export const parameters = {
|
|
100
97
|
blend: true,
|
|
101
|
-
blendFunc: [
|
|
102
|
-
blendEquation: [
|
|
98
|
+
blendFunc: [1, 1, 1, 1],
|
|
99
|
+
blendEquation: [32774, 32774],
|
|
103
100
|
depthTest: false
|
|
104
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-filter-extension.d.ts","sourceRoot":"","sources":["../../src/data-filter/data-filter-extension.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-filter-extension.d.ts","sourceRoot":"","sources":["../../src/data-filter/data-filter-extension.ts"],"names":[],"mappings":"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"}
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
|
-
import { GL } from '@luma.gl/constants';
|
|
21
20
|
import { _deepEqual as deepEqual, LayerExtension, log } from '@deck.gl/core';
|
|
22
21
|
import { shaderModule, shaderModule64 } from "./shader-module.js";
|
|
23
22
|
import * as aggregator from "./aggregator.js";
|
|
@@ -70,7 +69,7 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
70
69
|
attributeManager.add({
|
|
71
70
|
filterValues: {
|
|
72
71
|
size: filterSize,
|
|
73
|
-
type: fp64 ?
|
|
72
|
+
type: fp64 ? 'float64' : 'float32',
|
|
74
73
|
accessor: 'getFilterValue',
|
|
75
74
|
shaderAttributes: {
|
|
76
75
|
filterValues: {
|
|
@@ -83,7 +82,6 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
83
82
|
},
|
|
84
83
|
filterCategoryValues: {
|
|
85
84
|
size: categorySize,
|
|
86
|
-
type: GL.FLOAT,
|
|
87
85
|
accessor: 'getFilterCategory',
|
|
88
86
|
transform: categorySize === 1
|
|
89
87
|
? d => extension._getCategoryKey.call(this, d, 0)
|
|
@@ -109,8 +107,7 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
109
107
|
filterIndices: {
|
|
110
108
|
size: useFloatTarget ? 1 : 2,
|
|
111
109
|
vertexOffset: 1,
|
|
112
|
-
type:
|
|
113
|
-
normalized: true,
|
|
110
|
+
type: 'unorm8',
|
|
114
111
|
accessor: (object, { index }) => {
|
|
115
112
|
const i = object && object.__source ? object.__source.index : index;
|
|
116
113
|
return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/data-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAC,wBAAwB,EAAC,mCAAgC;
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/data-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAC,wBAAwB,EAAC,mCAAgC;AA+FtE,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,GAAG,EAAE,CAAC;CACnB,GAAG,wBAAwB,CAAC;AAkG7B,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,wBAAwB,CAM/D,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,wBAAwB,CAMjE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { glsl } from "../utils/syntax-tags.js";
|
|
1
2
|
/*
|
|
2
3
|
* data filter shader module
|
|
3
4
|
*/
|
|
@@ -10,78 +11,69 @@ uniform bool filter_useSoftMargin;
|
|
|
10
11
|
uniform bool filter_enabled;
|
|
11
12
|
uniform bool filter_transformSize;
|
|
12
13
|
uniform ivec4 filter_categoryBitMask;
|
|
13
|
-
|
|
14
14
|
#ifdef NON_INSTANCED_MODEL
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
#define DATAFILTER_ATTRIB filterValues
|
|
16
|
+
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
|
|
17
|
+
#define DATACATEGORY_ATTRIB filterCategoryValues
|
|
18
18
|
#else
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
#define DATAFILTER_ATTRIB instanceFilterValues
|
|
20
|
+
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
|
|
21
|
+
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
|
|
22
22
|
#endif
|
|
23
|
-
|
|
24
23
|
in DATAFILTER_TYPE DATAFILTER_ATTRIB;
|
|
25
24
|
#ifdef DATAFILTER_DOUBLE
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
uniform DATAFILTER_TYPE filter_max64High;
|
|
25
|
+
in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;
|
|
26
|
+
uniform DATAFILTER_TYPE filter_min64High;
|
|
27
|
+
uniform DATAFILTER_TYPE filter_max64High;
|
|
30
28
|
#endif
|
|
31
29
|
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
|
|
32
|
-
|
|
33
30
|
out float dataFilter_value;
|
|
34
|
-
|
|
35
31
|
float dataFilter_reduceValue(float value) {
|
|
36
|
-
|
|
32
|
+
return value;
|
|
37
33
|
}
|
|
38
34
|
float dataFilter_reduceValue(vec2 value) {
|
|
39
|
-
|
|
35
|
+
return min(value.x, value.y);
|
|
40
36
|
}
|
|
41
37
|
float dataFilter_reduceValue(vec3 value) {
|
|
42
|
-
|
|
38
|
+
return min(min(value.x, value.y), value.z);
|
|
43
39
|
}
|
|
44
40
|
float dataFilter_reduceValue(vec4 value) {
|
|
45
|
-
|
|
41
|
+
return min(min(value.x, value.y), min(value.z, value.w));
|
|
46
42
|
}
|
|
47
43
|
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
#endif
|
|
82
|
-
} else {
|
|
83
|
-
dataFilter_value = 1.0;
|
|
84
|
-
}
|
|
44
|
+
if (filter_enabled) {
|
|
45
|
+
if (filter_useSoftMargin) {
|
|
46
|
+
dataFilter_value = dataFilter_reduceValue(
|
|
47
|
+
smoothstep(filter_min, filter_softMin, valueFromMin) *
|
|
48
|
+
(1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
dataFilter_value = dataFilter_reduceValue(
|
|
52
|
+
step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
#if DATACATEGORY_CHANNELS == 1
|
|
56
|
+
int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
|
|
57
|
+
#elif DATACATEGORY_CHANNELS == 2
|
|
58
|
+
ivec2 dataFilter_masks = ivec2(
|
|
59
|
+
filter_categoryBitMask[int(category.x / 32.0)],
|
|
60
|
+
filter_categoryBitMask[int(category.y / 32.0) + 2]
|
|
61
|
+
);
|
|
62
|
+
#elif DATACATEGORY_CHANNELS == 3
|
|
63
|
+
ivec3 dataFilter_masks = filter_categoryBitMask.xyz;
|
|
64
|
+
#else
|
|
65
|
+
ivec4 dataFilter_masks = filter_categoryBitMask;
|
|
66
|
+
#endif
|
|
67
|
+
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) / pow(DATACATEGORY_TYPE(2.0), mod(category, 32.0));
|
|
68
|
+
dataFilter_bits = mod(floor(dataFilter_bits), 2.0);
|
|
69
|
+
#if DATACATEGORY_CHANNELS == 1
|
|
70
|
+
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
|
|
71
|
+
#else
|
|
72
|
+
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
|
|
73
|
+
#endif
|
|
74
|
+
} else {
|
|
75
|
+
dataFilter_value = 1.0;
|
|
76
|
+
}
|
|
85
77
|
}
|
|
86
78
|
`;
|
|
87
79
|
const fs = `
|
|
@@ -144,32 +136,32 @@ function getUniforms64(opts) {
|
|
|
144
136
|
}
|
|
145
137
|
const inject = {
|
|
146
138
|
'vs:#main-start': `
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
139
|
+
#ifdef DATAFILTER_DOUBLE
|
|
140
|
+
dataFilter_setValue(
|
|
141
|
+
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
|
|
142
|
+
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
|
|
143
|
+
DATACATEGORY_ATTRIB
|
|
144
|
+
);
|
|
145
|
+
#else
|
|
146
|
+
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
|
|
147
|
+
#endif
|
|
148
|
+
`,
|
|
157
149
|
'vs:#main-end': `
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
if (dataFilter_value == 0.0) {
|
|
151
|
+
gl_Position = vec4(0.);
|
|
152
|
+
}
|
|
153
|
+
`,
|
|
162
154
|
'vs:DECKGL_FILTER_SIZE': `
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
155
|
+
if (filter_transformSize) {
|
|
156
|
+
size = size * dataFilter_value;
|
|
157
|
+
}
|
|
158
|
+
`,
|
|
167
159
|
'fs:DECKGL_FILTER_COLOR': `
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
160
|
+
if (dataFilter_value == 0.0) discard;
|
|
161
|
+
if (filter_transformColor) {
|
|
162
|
+
color.a *= dataFilter_value;
|
|
163
|
+
}
|
|
164
|
+
`
|
|
173
165
|
};
|
|
174
166
|
export const shaderModule = {
|
|
175
167
|
name: 'data-filter',
|