@deck.gl/extensions 9.0.0-beta.4 → 9.0.0-beta.6
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 +2 -1
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +13 -7
- 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 +297 -302
- 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 +374 -432
- 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 +364 -431
- package/package.json +8 -8
- 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 +18 -8
- 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
|
};
|
|
@@ -77,7 +77,7 @@ type DataFilterExtensionOptions = {
|
|
|
77
77
|
countItems?: boolean;
|
|
78
78
|
};
|
|
79
79
|
/** Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties. */
|
|
80
|
-
export default class DataFilterExtension extends LayerExtension<DataFilterExtensionOptions
|
|
80
|
+
export default class DataFilterExtension extends LayerExtension<Required<DataFilterExtensionOptions>> {
|
|
81
81
|
static defaultProps: {
|
|
82
82
|
getFilterValue: {
|
|
83
83
|
type: string;
|
|
@@ -100,6 +100,7 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
100
100
|
filterTransformColor: boolean;
|
|
101
101
|
};
|
|
102
102
|
static extensionName: string;
|
|
103
|
+
constructor(opts: DataFilterExtensionOptions);
|
|
103
104
|
getShaders(this: Layer<DataFilterExtensionProps>, extension: this): any;
|
|
104
105
|
initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this): void;
|
|
105
106
|
updateState(this: Layer<DataFilterExtensionProps>, { props, oldProps, changeFlags }: UpdateParameters<Layer<DataFilterExtensionProps>>, extension: this): void;
|
|
@@ -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";
|
|
@@ -32,6 +31,12 @@ const defaultProps = {
|
|
|
32
31
|
filterTransformSize: true,
|
|
33
32
|
filterTransformColor: true
|
|
34
33
|
};
|
|
34
|
+
const defaultOptions = {
|
|
35
|
+
categorySize: 1,
|
|
36
|
+
filterSize: 1,
|
|
37
|
+
fp64: false,
|
|
38
|
+
countItems: false
|
|
39
|
+
};
|
|
35
40
|
const DATA_TYPE_FROM_SIZE = {
|
|
36
41
|
1: 'float',
|
|
37
42
|
2: 'vec2',
|
|
@@ -42,14 +47,17 @@ const DATA_TYPE_FROM_SIZE = {
|
|
|
42
47
|
export default class DataFilterExtension extends LayerExtension {
|
|
43
48
|
static { this.defaultProps = defaultProps; }
|
|
44
49
|
static { this.extensionName = 'DataFilterExtension'; }
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
super({ ...defaultOptions, ...opts });
|
|
52
|
+
}
|
|
45
53
|
getShaders(extension) {
|
|
46
54
|
const { categorySize, filterSize, fp64 } = extension.opts;
|
|
47
55
|
return {
|
|
48
56
|
modules: [fp64 ? shaderModule64 : shaderModule],
|
|
49
57
|
defines: {
|
|
50
|
-
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize
|
|
58
|
+
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
|
|
51
59
|
DATACATEGORY_CHANNELS: categorySize,
|
|
52
|
-
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize
|
|
60
|
+
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
|
|
53
61
|
DATAFILTER_DOUBLE: Boolean(fp64)
|
|
54
62
|
}
|
|
55
63
|
};
|
|
@@ -61,7 +69,7 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
61
69
|
attributeManager.add({
|
|
62
70
|
filterValues: {
|
|
63
71
|
size: filterSize,
|
|
64
|
-
type: fp64 ?
|
|
72
|
+
type: fp64 ? 'float64' : 'float32',
|
|
65
73
|
accessor: 'getFilterValue',
|
|
66
74
|
shaderAttributes: {
|
|
67
75
|
filterValues: {
|
|
@@ -74,7 +82,6 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
74
82
|
},
|
|
75
83
|
filterCategoryValues: {
|
|
76
84
|
size: categorySize,
|
|
77
|
-
type: GL.FLOAT,
|
|
78
85
|
accessor: 'getFilterCategory',
|
|
79
86
|
transform: categorySize === 1
|
|
80
87
|
? d => extension._getCategoryKey.call(this, d, 0)
|
|
@@ -100,8 +107,7 @@ export default class DataFilterExtension extends LayerExtension {
|
|
|
100
107
|
filterIndices: {
|
|
101
108
|
size: useFloatTarget ? 1 : 2,
|
|
102
109
|
vertexOffset: 1,
|
|
103
|
-
type:
|
|
104
|
-
normalized: true,
|
|
110
|
+
type: 'unorm8',
|
|
105
111
|
accessor: (object, { index }) => {
|
|
106
112
|
const i = object && object.__source ? object.__source.index : index;
|
|
107
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"}
|