@deck.gl/extensions 9.0.0-beta.1 → 9.0.0-beta.10
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.js +80 -0
- package/{typed → dist}/brushing/shader-module.d.ts +1 -1
- package/{typed → dist}/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +92 -0
- package/{typed → dist}/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +117 -0
- package/{typed → dist}/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +193 -0
- package/dist/collision-filter/collision-filter-extension.js +49 -0
- package/{typed → dist}/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +25 -0
- package/{typed → dist}/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +87 -0
- package/dist/data-filter/aggregator.d.ts.map +1 -0
- package/dist/{esm/data-filter → data-filter}/aggregator.js +40 -41
- package/{typed → dist}/data-filter/data-filter-extension.d.ts +38 -6
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -0
- package/dist/data-filter/data-filter-extension.js +249 -0
- package/{typed → dist}/data-filter/shader-module.d.ts +1 -1
- package/dist/data-filter/shader-module.d.ts.map +1 -0
- package/dist/data-filter/shader-module.js +179 -0
- package/dist/dist.dev.js +2203 -10630
- package/{typed → dist}/fill-style/fill-style-extension.d.ts +2 -30
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -0
- package/dist/fill-style/fill-style-extension.js +116 -0
- package/{typed/fill-style/shaders.glsl.d.ts → dist/fill-style/shader-module.d.ts} +1 -1
- package/dist/fill-style/shader-module.d.ts.map +1 -0
- package/dist/fill-style/shader-module.js +96 -0
- package/dist/fp64/fp64-extension.js +35 -0
- package/dist/fp64/project64.glsl.js +81 -0
- package/dist/fp64/project64.js +50 -0
- package/dist/index.cjs +2756 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/{typed → dist}/mask/mask-effect.d.ts +1 -1
- package/dist/mask/mask-effect.d.ts.map +1 -0
- package/dist/mask/mask-effect.js +194 -0
- package/dist/mask/mask-extension.js +57 -0
- package/{typed → dist}/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +44 -0
- package/{typed → dist}/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +77 -0
- package/dist/path-style/path-style-extension.js +111 -0
- package/dist/path-style/shaders.glsl.js +86 -0
- package/{typed → dist}/terrain/height-map-builder.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -0
- package/dist/terrain/height-map-builder.js +104 -0
- package/{typed → dist}/terrain/shader-module.d.ts +2 -2
- package/dist/terrain/shader-module.d.ts.map +1 -0
- package/dist/terrain/shader-module.js +137 -0
- package/{typed → dist}/terrain/terrain-cover.d.ts +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -0
- package/dist/terrain/terrain-cover.js +187 -0
- package/{typed → dist}/terrain/terrain-effect.d.ts +2 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -0
- package/dist/terrain/terrain-effect.js +184 -0
- package/dist/terrain/terrain-extension.js +44 -0
- package/{typed → dist}/terrain/terrain-pass.d.ts +2 -2
- package/dist/terrain/terrain-pass.d.ts.map +1 -0
- package/dist/terrain/terrain-pass.js +61 -0
- package/{typed → dist}/terrain/terrain-picking-pass.d.ts +1 -1
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -0
- package/dist/terrain/terrain-picking-pass.js +66 -0
- package/dist/terrain/utils.js +21 -0
- package/{typed → dist}/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +50 -0
- package/dist/utils/projection-utils.js +153 -0
- 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 +898 -1257
- package/package.json +19 -16
- package/src/brushing/shader-module.ts +4 -3
- package/src/clip/clip-extension.ts +10 -9
- package/src/collision-filter/collision-filter-effect.ts +12 -8
- package/src/collision-filter/collision-filter-pass.ts +1 -3
- 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 +147 -30
- package/src/data-filter/shader-module.ts +38 -9
- package/src/fill-style/fill-style-extension.ts +4 -5
- package/src/fill-style/{shaders.glsl.ts → shader-module.ts} +6 -5
- package/src/mask/mask-effect.ts +0 -1
- package/src/mask/mask-pass.ts +1 -3
- package/src/mask/shader-module.ts +7 -6
- package/src/terrain/shader-module.ts +14 -13
- package/src/terrain/terrain-effect.ts +12 -5
- package/src/terrain/terrain-pass.ts +2 -5
- package/src/terrain/terrain-picking-pass.ts +1 -3
- package/src/terrain/utils.ts +1 -1
- package/src/utils/debug.ts +1 -2
- package/src/utils/syntax-tags.ts +5 -0
- package/dist/es5/brushing/brushing-extension.js +0 -108
- package/dist/es5/brushing/brushing-extension.js.map +0 -1
- package/dist/es5/brushing/shader-module.js +0 -50
- package/dist/es5/brushing/shader-module.js.map +0 -1
- package/dist/es5/clip/clip-extension.js +0 -98
- package/dist/es5/clip/clip-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-effect.js +0 -294
- package/dist/es5/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-extension.js +0 -109
- package/dist/es5/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-pass.js +0 -79
- package/dist/es5/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/es5/collision-filter/shader-module.js +0 -39
- package/dist/es5/collision-filter/shader-module.js.map +0 -1
- package/dist/es5/data-filter/aggregator.js +0 -79
- package/dist/es5/data-filter/aggregator.js.map +0 -1
- package/dist/es5/data-filter/data-filter-extension.js +0 -236
- package/dist/es5/data-filter/data-filter-extension.js.map +0 -1
- package/dist/es5/data-filter/shader-module.js +0 -122
- package/dist/es5/data-filter/shader-module.js.map +0 -1
- package/dist/es5/fill-style/fill-style-extension.js +0 -190
- package/dist/es5/fill-style/fill-style-extension.js.map +0 -1
- package/dist/es5/fill-style/shaders.glsl.js +0 -59
- package/dist/es5/fill-style/shaders.glsl.js.map +0 -1
- package/dist/es5/fp64/fp64-extension.js +0 -55
- package/dist/es5/fp64/fp64-extension.js.map +0 -1
- package/dist/es5/fp64/project64.glsl.js +0 -9
- package/dist/es5/fp64/project64.glsl.js.map +0 -1
- package/dist/es5/fp64/project64.js +0 -52
- package/dist/es5/fp64/project64.js.map +0 -1
- package/dist/es5/index.js +0 -88
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/mask/mask-effect.js +0 -279
- package/dist/es5/mask/mask-effect.js.map +0 -1
- package/dist/es5/mask/mask-extension.js +0 -113
- package/dist/es5/mask/mask-extension.js.map +0 -1
- package/dist/es5/mask/mask-pass.js +0 -106
- package/dist/es5/mask/mask-pass.js.map +0 -1
- package/dist/es5/mask/shader-module.js +0 -38
- package/dist/es5/mask/shader-module.js.map +0 -1
- package/dist/es5/path-style/path-style-extension.js +0 -169
- package/dist/es5/path-style/path-style-extension.js.map +0 -1
- package/dist/es5/path-style/shaders.glsl.js +0 -25
- package/dist/es5/path-style/shaders.glsl.js.map +0 -1
- package/dist/es5/terrain/height-map-builder.js +0 -111
- package/dist/es5/terrain/height-map-builder.js.map +0 -1
- package/dist/es5/terrain/shader-module.js +0 -86
- package/dist/es5/terrain/shader-module.js.map +0 -1
- package/dist/es5/terrain/terrain-cover.js +0 -256
- package/dist/es5/terrain/terrain-cover.js.map +0 -1
- package/dist/es5/terrain/terrain-effect.js +0 -326
- package/dist/es5/terrain/terrain-effect.js.map +0 -1
- package/dist/es5/terrain/terrain-extension.js +0 -94
- package/dist/es5/terrain/terrain-extension.js.map +0 -1
- package/dist/es5/terrain/terrain-pass.js +0 -121
- package/dist/es5/terrain/terrain-pass.js.map +0 -1
- package/dist/es5/terrain/terrain-picking-pass.js +0 -124
- package/dist/es5/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/es5/terrain/utils.js +0 -35
- package/dist/es5/terrain/utils.js.map +0 -1
- package/dist/es5/utils/debug.js +0 -71
- package/dist/es5/utils/debug.js.map +0 -1
- package/dist/es5/utils/projection-utils.js +0 -168
- package/dist/es5/utils/projection-utils.js.map +0 -1
- package/dist/esm/brushing/brushing-extension.js +0 -68
- package/dist/esm/brushing/brushing-extension.js.map +0 -1
- package/dist/esm/brushing/shader-module.js +0 -103
- package/dist/esm/brushing/shader-module.js.map +0 -1
- package/dist/esm/clip/clip-extension.js +0 -86
- package/dist/esm/clip/clip-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-effect.js +0 -246
- package/dist/esm/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-extension.js +0 -75
- package/dist/esm/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +0 -32
- package/dist/esm/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/esm/collision-filter/shader-module.js +0 -104
- package/dist/esm/collision-filter/shader-module.js.map +0 -1
- package/dist/esm/data-filter/aggregator.js.map +0 -1
- package/dist/esm/data-filter/data-filter-extension.js +0 -189
- package/dist/esm/data-filter/data-filter-extension.js.map +0 -1
- package/dist/esm/data-filter/shader-module.js +0 -164
- package/dist/esm/data-filter/shader-module.js.map +0 -1
- package/dist/esm/fill-style/fill-style-extension.js +0 -156
- package/dist/esm/fill-style/fill-style-extension.js.map +0 -1
- package/dist/esm/fill-style/shaders.glsl.js +0 -108
- package/dist/esm/fill-style/shaders.glsl.js.map +0 -1
- package/dist/esm/fp64/fp64-extension.js +0 -20
- package/dist/esm/fp64/fp64-extension.js.map +0 -1
- package/dist/esm/fp64/project64.glsl.js +0 -82
- package/dist/esm/fp64/project64.glsl.js.map +0 -1
- package/dist/esm/fp64/project64.js +0 -43
- package/dist/esm/fp64/project64.js.map +0 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/mask/mask-effect.js +0 -228
- package/dist/esm/mask/mask-effect.js.map +0 -1
- package/dist/esm/mask/mask-extension.js +0 -83
- package/dist/esm/mask/mask-extension.js.map +0 -1
- package/dist/esm/mask/mask-pass.js +0 -58
- package/dist/esm/mask/mask-pass.js.map +0 -1
- package/dist/esm/mask/shader-module.js +0 -84
- package/dist/esm/mask/shader-module.js.map +0 -1
- package/dist/esm/path-style/path-style-extension.js +0 -130
- package/dist/esm/path-style/path-style-extension.js.map +0 -1
- package/dist/esm/path-style/shaders.glsl.js +0 -84
- package/dist/esm/path-style/shaders.glsl.js.map +0 -1
- package/dist/esm/terrain/height-map-builder.js +0 -86
- package/dist/esm/terrain/height-map-builder.js.map +0 -1
- package/dist/esm/terrain/shader-module.js +0 -127
- package/dist/esm/terrain/shader-module.js.map +0 -1
- package/dist/esm/terrain/terrain-cover.js +0 -212
- package/dist/esm/terrain/terrain-cover.js.map +0 -1
- package/dist/esm/terrain/terrain-effect.js +0 -219
- package/dist/esm/terrain/terrain-effect.js.map +0 -1
- package/dist/esm/terrain/terrain-extension.js +0 -59
- package/dist/esm/terrain/terrain-extension.js.map +0 -1
- package/dist/esm/terrain/terrain-pass.js +0 -71
- package/dist/esm/terrain/terrain-pass.js.map +0 -1
- package/dist/esm/terrain/terrain-picking-pass.js +0 -73
- package/dist/esm/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/esm/terrain/utils.js +0 -19
- package/dist/esm/terrain/utils.js.map +0 -1
- package/dist/esm/utils/debug.js +0 -61
- package/dist/esm/utils/debug.js.map +0 -1
- package/dist/esm/utils/projection-utils.js +0 -134
- package/dist/esm/utils/projection-utils.js.map +0 -1
- package/typed/data-filter/aggregator.d.ts.map +0 -1
- package/typed/data-filter/data-filter-extension.d.ts.map +0 -1
- package/typed/data-filter/shader-module.d.ts.map +0 -1
- package/typed/fill-style/fill-style-extension.d.ts.map +0 -1
- package/typed/fill-style/shaders.glsl.d.ts.map +0 -1
- package/typed/index.d.ts +0 -19
- package/typed/index.d.ts.map +0 -1
- package/typed/mask/mask-effect.d.ts.map +0 -1
- package/typed/terrain/height-map-builder.d.ts.map +0 -1
- package/typed/terrain/shader-module.d.ts.map +0 -1
- package/typed/terrain/terrain-cover.d.ts.map +0 -1
- package/typed/terrain/terrain-effect.d.ts.map +0 -1
- package/typed/terrain/terrain-pass.d.ts.map +0 -1
- package/typed/terrain/terrain-picking-pass.d.ts.map +0 -1
- /package/{typed → dist}/brushing/brushing-extension.d.ts +0 -0
- /package/{typed → dist}/brushing/brushing-extension.d.ts.map +0 -0
- /package/{typed → dist}/clip/clip-extension.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-effect.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts.map +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-pass.d.ts +0 -0
- /package/{typed → dist}/collision-filter/shader-module.d.ts +0 -0
- /package/{typed → dist}/data-filter/aggregator.d.ts +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-pass.d.ts +0 -0
- /package/{typed → dist}/mask/shader-module.d.ts +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts.map +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts.map +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts.map +0 -0
- /package/{typed → dist}/terrain/utils.d.ts +0 -0
- /package/{typed → dist}/terrain/utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/debug.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts.map +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
2
2
|
import type {DataFilterExtensionProps} from './data-filter-extension';
|
|
3
|
+
import {glsl} from '../utils/syntax-tags';
|
|
3
4
|
|
|
4
5
|
/*
|
|
5
6
|
* data filter shader module
|
|
6
7
|
*/
|
|
7
|
-
const vs = `
|
|
8
|
+
const vs = glsl`
|
|
8
9
|
uniform DATAFILTER_TYPE filter_min;
|
|
9
10
|
uniform DATAFILTER_TYPE filter_softMin;
|
|
10
11
|
uniform DATAFILTER_TYPE filter_softMax;
|
|
@@ -12,13 +13,16 @@ uniform DATAFILTER_TYPE filter_max;
|
|
|
12
13
|
uniform bool filter_useSoftMargin;
|
|
13
14
|
uniform bool filter_enabled;
|
|
14
15
|
uniform bool filter_transformSize;
|
|
16
|
+
uniform ivec4 filter_categoryBitMask;
|
|
15
17
|
|
|
16
18
|
#ifdef NON_INSTANCED_MODEL
|
|
17
19
|
#define DATAFILTER_ATTRIB filterValues
|
|
18
20
|
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
|
|
21
|
+
#define DATACATEGORY_ATTRIB filterCategoryValues
|
|
19
22
|
#else
|
|
20
23
|
#define DATAFILTER_ATTRIB instanceFilterValues
|
|
21
24
|
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
|
|
25
|
+
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
|
|
22
26
|
#endif
|
|
23
27
|
|
|
24
28
|
in DATAFILTER_TYPE DATAFILTER_ATTRIB;
|
|
@@ -28,6 +32,7 @@ in DATAFILTER_TYPE DATAFILTER_ATTRIB;
|
|
|
28
32
|
uniform DATAFILTER_TYPE filter_min64High;
|
|
29
33
|
uniform DATAFILTER_TYPE filter_max64High;
|
|
30
34
|
#endif
|
|
35
|
+
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
|
|
31
36
|
|
|
32
37
|
out float dataFilter_value;
|
|
33
38
|
|
|
@@ -43,7 +48,7 @@ float dataFilter_reduceValue(vec3 value) {
|
|
|
43
48
|
float dataFilter_reduceValue(vec4 value) {
|
|
44
49
|
return min(min(value.x, value.y), min(value.z, value.w));
|
|
45
50
|
}
|
|
46
|
-
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
|
|
51
|
+
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
|
|
47
52
|
if (filter_enabled) {
|
|
48
53
|
if (filter_useSoftMargin) {
|
|
49
54
|
dataFilter_value = dataFilter_reduceValue(
|
|
@@ -55,13 +60,36 @@ void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFrom
|
|
|
55
60
|
step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
|
|
56
61
|
);
|
|
57
62
|
}
|
|
63
|
+
|
|
64
|
+
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
|
|
65
|
+
int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
|
|
66
|
+
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
|
|
67
|
+
ivec2 dataFilter_masks = ivec2(
|
|
68
|
+
filter_categoryBitMask[int(category.x / 32.0)],
|
|
69
|
+
filter_categoryBitMask[int(category.y / 32.0) + 2]
|
|
70
|
+
);
|
|
71
|
+
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
|
|
72
|
+
ivec3 dataFilter_masks = filter_categoryBitMask.xyz;
|
|
73
|
+
#else // Four 32-bit masks
|
|
74
|
+
ivec4 dataFilter_masks = filter_categoryBitMask;
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
// Shift mask and extract relevant bits
|
|
78
|
+
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) / pow(DATACATEGORY_TYPE(2.0), mod(category, 32.0));
|
|
79
|
+
dataFilter_bits = mod(floor(dataFilter_bits), 2.0);
|
|
80
|
+
|
|
81
|
+
#if DATACATEGORY_CHANNELS == 1
|
|
82
|
+
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
|
|
83
|
+
#else
|
|
84
|
+
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
|
|
85
|
+
#endif
|
|
58
86
|
} else {
|
|
59
87
|
dataFilter_value = 1.0;
|
|
60
88
|
}
|
|
61
89
|
}
|
|
62
90
|
`;
|
|
63
91
|
|
|
64
|
-
const fs = `
|
|
92
|
+
const fs = glsl`
|
|
65
93
|
uniform bool filter_transformColor;
|
|
66
94
|
in float dataFilter_value;
|
|
67
95
|
`;
|
|
@@ -134,30 +162,31 @@ function getUniforms64(opts?: DataFilterModuleSettings | {}): Record<string, any
|
|
|
134
162
|
}
|
|
135
163
|
|
|
136
164
|
const inject = {
|
|
137
|
-
'vs:#main-start': `
|
|
165
|
+
'vs:#main-start': glsl`
|
|
138
166
|
#ifdef DATAFILTER_DOUBLE
|
|
139
167
|
dataFilter_setValue(
|
|
140
168
|
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
|
|
141
|
-
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
|
|
169
|
+
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
|
|
170
|
+
DATACATEGORY_ATTRIB
|
|
142
171
|
);
|
|
143
172
|
#else
|
|
144
|
-
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
|
|
173
|
+
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
|
|
145
174
|
#endif
|
|
146
175
|
`,
|
|
147
176
|
|
|
148
|
-
'vs:#main-end': `
|
|
177
|
+
'vs:#main-end': glsl`
|
|
149
178
|
if (dataFilter_value == 0.0) {
|
|
150
179
|
gl_Position = vec4(0.);
|
|
151
180
|
}
|
|
152
181
|
`,
|
|
153
182
|
|
|
154
|
-
'vs:DECKGL_FILTER_SIZE': `
|
|
183
|
+
'vs:DECKGL_FILTER_SIZE': glsl`
|
|
155
184
|
if (filter_transformSize) {
|
|
156
185
|
size = size * dataFilter_value;
|
|
157
186
|
}
|
|
158
187
|
`,
|
|
159
188
|
|
|
160
|
-
'fs:DECKGL_FILTER_COLOR': `
|
|
189
|
+
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
161
190
|
if (dataFilter_value == 0.0) discard;
|
|
162
191
|
if (filter_transformColor) {
|
|
163
192
|
color.a *= dataFilter_value;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {LayerExtension} from '@deck.gl/core';
|
|
2
2
|
|
|
3
|
-
import {patternShaders} from './
|
|
3
|
+
import {patternShaders} from './shader-module';
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
Layer,
|
|
7
7
|
LayerContext,
|
|
8
|
+
DefaultProps,
|
|
8
9
|
Accessor,
|
|
9
10
|
AccessorFunction,
|
|
10
11
|
TextureSource,
|
|
@@ -12,15 +13,13 @@ import type {
|
|
|
12
13
|
} from '@deck.gl/core';
|
|
13
14
|
import type {Texture} from '@luma.gl/core';
|
|
14
15
|
|
|
15
|
-
const defaultProps = {
|
|
16
|
+
const defaultProps: DefaultProps<FillStyleExtensionProps> = {
|
|
16
17
|
fillPatternEnabled: true,
|
|
17
18
|
fillPatternAtlas: {
|
|
18
19
|
type: 'image',
|
|
19
20
|
value: null,
|
|
20
21
|
async: true,
|
|
21
|
-
parameters: {
|
|
22
|
-
minFilter: 'linear'
|
|
23
|
-
}
|
|
22
|
+
parameters: {lodMaxClamp: 0}
|
|
24
23
|
},
|
|
25
24
|
fillPatternMapping: {type: 'object', value: {}, async: true},
|
|
26
25
|
fillPatternMask: true,
|
|
@@ -3,11 +3,12 @@ import {project, fp64LowPart} from '@deck.gl/core';
|
|
|
3
3
|
import type {Viewport, ProjectUniforms} from '@deck.gl/core';
|
|
4
4
|
|
|
5
5
|
import type {Texture} from '@luma.gl/core';
|
|
6
|
+
import {glsl} from '../utils/syntax-tags';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
* fill pattern shader module
|
|
9
10
|
*/
|
|
10
|
-
const patternVs = `
|
|
11
|
+
const patternVs = glsl`
|
|
11
12
|
#ifdef NON_INSTANCED_MODEL
|
|
12
13
|
#define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames
|
|
13
14
|
#define FILL_PATTERN_SCALE_ATTRIB fillPatternScales
|
|
@@ -30,7 +31,7 @@ out vec4 fill_patternBounds;
|
|
|
30
31
|
out vec4 fill_patternPlacement;
|
|
31
32
|
`;
|
|
32
33
|
|
|
33
|
-
const patternFs = `
|
|
34
|
+
const patternFs = glsl`
|
|
34
35
|
uniform bool fill_patternEnabled;
|
|
35
36
|
uniform bool fill_patternMask;
|
|
36
37
|
uniform sampler2D fill_patternTexture;
|
|
@@ -45,11 +46,11 @@ const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
|
45
46
|
`;
|
|
46
47
|
|
|
47
48
|
const inject = {
|
|
48
|
-
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
49
|
+
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
49
50
|
fill_uv = geometry.position.xy;
|
|
50
51
|
`,
|
|
51
52
|
|
|
52
|
-
'vs:DECKGL_FILTER_COLOR': `
|
|
53
|
+
'vs:DECKGL_FILTER_COLOR': glsl`
|
|
53
54
|
if (fill_patternEnabled) {
|
|
54
55
|
fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);
|
|
55
56
|
fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;
|
|
@@ -57,7 +58,7 @@ const inject = {
|
|
|
57
58
|
}
|
|
58
59
|
`,
|
|
59
60
|
|
|
60
|
-
'fs:DECKGL_FILTER_COLOR': `
|
|
61
|
+
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
61
62
|
if (fill_patternEnabled) {
|
|
62
63
|
vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;
|
|
63
64
|
vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;
|
package/src/mask/mask-effect.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {Layer, Viewport, Effect, PreRenderOptions, CoordinateSystem, log} from '@deck.gl/core';
|
|
2
2
|
import type {Device, Texture} from '@luma.gl/core';
|
|
3
|
-
// import {readPixelsToArray} from '@luma.gl/webgl-legacy';
|
|
4
3
|
import {equals} from '@math.gl/core';
|
|
5
4
|
import MaskPass from './mask-pass';
|
|
6
5
|
import {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';
|
package/src/mask/mask-pass.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {Device, Framebuffer, Texture} from '@luma.gl/core';
|
|
2
|
-
import {withGLParameters} from '@luma.gl/webgl';
|
|
3
2
|
import {GL} from '@luma.gl/constants';
|
|
4
3
|
import {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
|
|
5
4
|
|
|
@@ -42,8 +41,7 @@ export default class MaskPass extends LayersPass {
|
|
|
42
41
|
colorMask[options.channel] = true;
|
|
43
42
|
const clearColor = [255, 255, 255, 255];
|
|
44
43
|
|
|
45
|
-
return
|
|
46
|
-
this.device,
|
|
44
|
+
return this.device.withParametersWebGL(
|
|
47
45
|
{
|
|
48
46
|
blend: true,
|
|
49
47
|
blendFunc: [GL.ZERO, GL.ONE],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
2
2
|
import {project} from '@deck.gl/core';
|
|
3
3
|
import type {Texture} from '@luma.gl/core';
|
|
4
|
+
import {glsl} from '../utils/syntax-tags';
|
|
4
5
|
|
|
5
|
-
const vs = `
|
|
6
|
+
const vs = glsl`
|
|
6
7
|
uniform vec4 mask_bounds;
|
|
7
8
|
uniform bool mask_maskByInstance;
|
|
8
9
|
vec2 mask_getCoords(vec4 position) {
|
|
@@ -10,7 +11,7 @@ vec2 mask_getCoords(vec4 position) {
|
|
|
10
11
|
}
|
|
11
12
|
`;
|
|
12
13
|
|
|
13
|
-
const fs = `
|
|
14
|
+
const fs = glsl`
|
|
14
15
|
uniform sampler2D mask_texture;
|
|
15
16
|
uniform int mask_channel;
|
|
16
17
|
uniform bool mask_enabled;
|
|
@@ -40,10 +41,10 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
40
41
|
`;
|
|
41
42
|
|
|
42
43
|
const inject = {
|
|
43
|
-
'vs:#decl': `
|
|
44
|
+
'vs:#decl': glsl`
|
|
44
45
|
out vec2 mask_texCoords;
|
|
45
46
|
`,
|
|
46
|
-
'vs:#main-end': `
|
|
47
|
+
'vs:#main-end': glsl`
|
|
47
48
|
vec4 mask_common_position;
|
|
48
49
|
if (mask_maskByInstance) {
|
|
49
50
|
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
@@ -52,10 +53,10 @@ out vec2 mask_texCoords;
|
|
|
52
53
|
}
|
|
53
54
|
mask_texCoords = mask_getCoords(mask_common_position);
|
|
54
55
|
`,
|
|
55
|
-
'fs:#decl': `
|
|
56
|
+
'fs:#decl': glsl`
|
|
56
57
|
in vec2 mask_texCoords;
|
|
57
58
|
`,
|
|
58
|
-
'fs:#main-start': `
|
|
59
|
+
'fs:#main-start': glsl`
|
|
59
60
|
if (mask_enabled) {
|
|
60
61
|
bool mask = mask_isInBounds(mask_texCoords);
|
|
61
62
|
|
|
@@ -6,6 +6,7 @@ import {project} from '@deck.gl/core';
|
|
|
6
6
|
import type {Texture} from '@luma.gl/core';
|
|
7
7
|
import type {Bounds} from '../utils/projection-utils';
|
|
8
8
|
import type {TerrainCover} from './terrain-cover';
|
|
9
|
+
import {glsl} from '../utils/syntax-tags';
|
|
9
10
|
|
|
10
11
|
/** Module parameters expected by the terrain shader module */
|
|
11
12
|
export type TerrainModuleSettings = {
|
|
@@ -43,20 +44,20 @@ export const terrainModule = {
|
|
|
43
44
|
name: 'terrain',
|
|
44
45
|
dependencies: [project],
|
|
45
46
|
inject: {
|
|
46
|
-
'vs:#decl':
|
|
47
|
+
'vs:#decl':
|
|
48
|
+
glsl`
|
|
47
49
|
uniform float terrain_mode;
|
|
48
50
|
uniform sampler2D terrain_map;
|
|
49
51
|
uniform vec4 terrain_bounds;
|
|
50
52
|
out vec3 commonPos;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'vs:#main-start': `
|
|
53
|
+
` + TERRAIN_MODE_CONSTANTS,
|
|
54
|
+
'vs:#main-start': glsl`
|
|
54
55
|
if (terrain_mode == TERRAIN_MODE_SKIP) {
|
|
55
56
|
gl_Position = vec4(0.0);
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
`,
|
|
59
|
-
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
60
|
+
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
60
61
|
commonPos = geometry.position.xyz;
|
|
61
62
|
if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
62
63
|
vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
|
|
@@ -75,20 +76,20 @@ if (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
`,
|
|
78
|
-
'fs:#decl':
|
|
79
|
+
'fs:#decl':
|
|
80
|
+
glsl`
|
|
79
81
|
uniform float terrain_mode;
|
|
80
82
|
uniform sampler2D terrain_map;
|
|
81
83
|
uniform vec4 terrain_bounds;
|
|
82
84
|
in vec3 commonPos;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'fs:#main-start': `
|
|
85
|
+
` + TERRAIN_MODE_CONSTANTS,
|
|
86
|
+
'fs:#main-start': glsl`
|
|
86
87
|
if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
87
88
|
fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
`,
|
|
91
|
-
'fs:DECKGL_FILTER_COLOR': `
|
|
92
|
+
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
92
93
|
if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
93
94
|
vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
|
|
94
95
|
vec4 pixel = texture(terrain_map, texCoords);
|
|
@@ -118,7 +119,7 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
118
119
|
|
|
119
120
|
let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;
|
|
120
121
|
// height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty
|
|
121
|
-
let sampler = dummyHeightMap as Texture;
|
|
122
|
+
let sampler: Texture | undefined = dummyHeightMap as Texture;
|
|
122
123
|
// height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null
|
|
123
124
|
let bounds: number[] | null = null;
|
|
124
125
|
if (drawToTerrainHeightMap) {
|
|
@@ -131,10 +132,10 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
131
132
|
} else if (terrainCover) {
|
|
132
133
|
// This is a terrain layer
|
|
133
134
|
const isPicking = opts.picking?.isActive;
|
|
134
|
-
|
|
135
|
-
sampler = isPicking
|
|
135
|
+
const fbo = isPicking
|
|
136
136
|
? terrainCover.getPickingFramebuffer()
|
|
137
137
|
: terrainCover.getRenderFramebuffer();
|
|
138
|
+
sampler = fbo?.colorAttachments[0].texture;
|
|
138
139
|
if (isPicking) {
|
|
139
140
|
// Never render the layer itself in picking pass
|
|
140
141
|
mode = TERRAIN_MODE.SKIP;
|
|
@@ -65,7 +65,8 @@ export class TerrainEffect implements Effect {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const {viewports
|
|
68
|
+
const {viewports} = opts;
|
|
69
|
+
const isPicking = opts.pass.startsWith('picking');
|
|
69
70
|
this.isPicking = isPicking;
|
|
70
71
|
this.isDrapingEnabled = true;
|
|
71
72
|
|
|
@@ -92,12 +93,11 @@ export class TerrainEffect implements Effect {
|
|
|
92
93
|
this._updateTerrainCovers(terrainLayers, drapeLayers, viewport, opts);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
getModuleParameters(layer: Layer): TerrainModuleSettings {
|
|
96
|
+
getModuleParameters(layer: Layer): Omit<TerrainModuleSettings, 'picking'> {
|
|
96
97
|
const {terrainDrawMode} = layer.state;
|
|
97
98
|
|
|
98
99
|
return {
|
|
99
|
-
|
|
100
|
-
heightMap: this.heightMap?.getRenderFramebuffer(),
|
|
100
|
+
heightMap: this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture || null,
|
|
101
101
|
heightMapBounds: this.heightMap?.bounds,
|
|
102
102
|
dummyHeightMap: this.dummyHeightMap!,
|
|
103
103
|
terrainCover: this.isDrapingEnabled ? this.terrainCovers.get(layer.id) : null,
|
|
@@ -121,6 +121,8 @@ export class TerrainEffect implements Effect {
|
|
|
121
121
|
terrainCover.delete();
|
|
122
122
|
}
|
|
123
123
|
this.terrainCovers.clear();
|
|
124
|
+
|
|
125
|
+
getShaderAssembler().removeDefaultModule(terrainModule);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
private _updateHeightMap(terrainLayers: Layer[], viewport: Viewport, opts: PreRenderOptions) {
|
|
@@ -201,7 +203,12 @@ export class TerrainEffect implements Effect {
|
|
|
201
203
|
devicePixelRatio: 1
|
|
202
204
|
}
|
|
203
205
|
});
|
|
204
|
-
|
|
206
|
+
|
|
207
|
+
if (!this.isPicking) {
|
|
208
|
+
// IsDirty refers to the normal fbo, not the picking fbo.
|
|
209
|
+
// Only mark it as not dirty if the normal fbo was updated.
|
|
210
|
+
terrainCover.isDirty = false;
|
|
211
|
+
}
|
|
205
212
|
}
|
|
206
213
|
} catch (err) {
|
|
207
214
|
terrainLayer.raiseError(err as Error, `Error rendering terrain cover ${terrainCover.id}`);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {withGLParameters} from '@luma.gl/webgl';
|
|
2
1
|
import {GL} from '@luma.gl/constants';
|
|
3
2
|
import {Layer, Viewport, _LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
|
|
4
3
|
import type {HeightMapBuilder} from './height-map-builder';
|
|
@@ -33,8 +32,7 @@ export class TerrainPass extends LayersPass {
|
|
|
33
32
|
|
|
34
33
|
target.resize(viewport);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
this.device,
|
|
35
|
+
this.device.withParametersWebGL(
|
|
38
36
|
{
|
|
39
37
|
clearColor: [0, 0, 0, 0],
|
|
40
38
|
blend: true,
|
|
@@ -66,8 +64,7 @@ export class TerrainPass extends LayersPass {
|
|
|
66
64
|
const layers = terrainCover.filterLayers(opts.layers!);
|
|
67
65
|
target.resize(viewport);
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
this.device,
|
|
67
|
+
this.device.withParametersWebGL(
|
|
71
68
|
{
|
|
72
69
|
clearColor: [0, 0, 0, 0],
|
|
73
70
|
depthTest: false
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
LayersPassRenderOptions,
|
|
5
5
|
_PickLayersPass as PickLayersPass
|
|
6
6
|
} from '@deck.gl/core';
|
|
7
|
-
import {withGLParameters} from '@luma.gl/webgl';
|
|
8
7
|
import type {TerrainCover} from './terrain-cover';
|
|
9
8
|
|
|
10
9
|
export type TerrainPickingPassRenderOptions = LayersPassRenderOptions & {
|
|
@@ -54,8 +53,7 @@ export class TerrainPickingPass extends PickLayersPass {
|
|
|
54
53
|
}
|
|
55
54
|
target.resize(viewport);
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
this.device,
|
|
56
|
+
this.device.withParametersWebGL(
|
|
59
57
|
{
|
|
60
58
|
depthTest: false
|
|
61
59
|
},
|
package/src/terrain/utils.ts
CHANGED
package/src/utils/debug.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* global document */
|
|
2
2
|
|
|
3
3
|
import {Framebuffer} from '@luma.gl/core';
|
|
4
|
-
import {readPixelsToArray} from '@luma.gl/webgl';
|
|
5
4
|
|
|
6
5
|
/** Debug utility to draw FBO contents onto screen */
|
|
7
6
|
// eslint-disable-next-line
|
|
@@ -9,7 +8,7 @@ export const debugFBO = function (
|
|
|
9
8
|
fbo: Framebuffer,
|
|
10
9
|
{minimap, opaque}: {minimap?: boolean; opaque?: boolean} = {}
|
|
11
10
|
) {
|
|
12
|
-
const color =
|
|
11
|
+
const color = fbo.device.readPixelsToArrayWebGL(fbo);
|
|
13
12
|
let canvas = document.getElementById('fbo-canvas') as HTMLCanvasElement;
|
|
14
13
|
const canvasHeight = (minimap ? 2 : 1) * fbo.height;
|
|
15
14
|
if (!canvas) {
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
|
-
var _core = require("@deck.gl/core");
|
|
19
|
-
|
|
20
|
-
var _shaderModule = _interopRequireDefault(require("./shader-module"));
|
|
21
|
-
|
|
22
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
23
|
-
|
|
24
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
25
|
-
|
|
26
|
-
var defaultProps = {
|
|
27
|
-
getBrushingTarget: {
|
|
28
|
-
type: 'accessor',
|
|
29
|
-
value: [0, 0]
|
|
30
|
-
},
|
|
31
|
-
brushingTarget: 'source',
|
|
32
|
-
brushingEnabled: true,
|
|
33
|
-
brushingRadius: 10000
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
var BrushingExtension = function (_LayerExtension) {
|
|
37
|
-
(0, _inherits2.default)(BrushingExtension, _LayerExtension);
|
|
38
|
-
|
|
39
|
-
var _super = _createSuper(BrushingExtension);
|
|
40
|
-
|
|
41
|
-
function BrushingExtension() {
|
|
42
|
-
(0, _classCallCheck2.default)(this, BrushingExtension);
|
|
43
|
-
return _super.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var _proto = BrushingExtension.prototype;
|
|
47
|
-
|
|
48
|
-
_proto.getShaders = function getShaders() {
|
|
49
|
-
return {
|
|
50
|
-
modules: [_shaderModule.default]
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
_proto.initializeState = function initializeState(context, extension) {
|
|
55
|
-
var _this = this;
|
|
56
|
-
|
|
57
|
-
var attributeManager = this.getAttributeManager();
|
|
58
|
-
|
|
59
|
-
if (attributeManager) {
|
|
60
|
-
attributeManager.add({
|
|
61
|
-
brushingTargets: {
|
|
62
|
-
size: 2,
|
|
63
|
-
accessor: 'getBrushingTarget',
|
|
64
|
-
shaderAttributes: {
|
|
65
|
-
brushingTargets: {
|
|
66
|
-
divisor: 0
|
|
67
|
-
},
|
|
68
|
-
instanceBrushingTargets: {
|
|
69
|
-
divisor: 1
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var onMouseMove = function onMouseMove() {
|
|
77
|
-
var _this$getCurrentLayer;
|
|
78
|
-
|
|
79
|
-
(_this$getCurrentLayer = _this.getCurrentLayer()) === null || _this$getCurrentLayer === void 0 ? void 0 : _this$getCurrentLayer.setNeedsRedraw();
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
this.state.onMouseMove = onMouseMove;
|
|
83
|
-
|
|
84
|
-
if (context.deck) {
|
|
85
|
-
context.deck.eventManager.on({
|
|
86
|
-
pointermove: onMouseMove,
|
|
87
|
-
pointerleave: onMouseMove
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
_proto.finalizeState = function finalizeState(context, extension) {
|
|
93
|
-
if (context.deck) {
|
|
94
|
-
var onMouseMove = this.state.onMouseMove;
|
|
95
|
-
context.deck.eventManager.off({
|
|
96
|
-
pointermove: onMouseMove,
|
|
97
|
-
pointerleave: onMouseMove
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
return BrushingExtension;
|
|
103
|
-
}(_core.LayerExtension);
|
|
104
|
-
|
|
105
|
-
exports.default = BrushingExtension;
|
|
106
|
-
BrushingExtension.defaultProps = defaultProps;
|
|
107
|
-
BrushingExtension.extensionName = 'BrushingExtension';
|
|
108
|
-
//# sourceMappingURL=brushing-extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/brushing/brushing-extension.ts"],"names":["defaultProps","getBrushingTarget","type","value","brushingTarget","brushingEnabled","brushingRadius","BrushingExtension","getShaders","modules","shaderModule","initializeState","context","extension","attributeManager","getAttributeManager","add","brushingTargets","size","accessor","shaderAttributes","divisor","instanceBrushingTargets","onMouseMove","getCurrentLayer","setNeedsRedraw","state","deck","eventManager","on","pointermove","pointerleave","finalizeState","off","LayerExtension","extensionName"],"mappings":";;;;;;;;;;;;;;;;;AAoBA;;AACA;;;;;;AAIA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,iBAAiB,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;AAA1B,GADA;AAGnBC,EAAAA,cAAc,EAAE,QAHG;AAInBC,EAAAA,eAAe,EAAE,IAJE;AAKnBC,EAAAA,cAAc,EAAE;AALG,CAArB;;IA8BqBC,iB;;;;;;;;;;;;SAInBC,U,GAAA,sBAAkB;AAChB,WAAO;AACLC,MAAAA,OAAO,EAAE,CAACC,qBAAD;AADJ,KAAP;AAGD,G;;SAEDC,e,GAAA,yBAAqDC,OAArD,EAA4EC,SAA5E,EAA6F;AAAA;;AAC3F,QAAMC,gBAAgB,GAAG,KAAKC,mBAAL,EAAzB;;AACA,QAAID,gBAAJ,EAAsB;AACpBA,MAAAA,gBAAgB,CAACE,GAAjB,CAAqB;AACnBC,QAAAA,eAAe,EAAE;AACfC,UAAAA,IAAI,EAAE,CADS;AAEfC,UAAAA,QAAQ,EAAE,mBAFK;AAGfC,UAAAA,gBAAgB,EAAE;AAChBH,YAAAA,eAAe,EAAE;AACfI,cAAAA,OAAO,EAAE;AADM,aADD;AAIhBC,YAAAA,uBAAuB,EAAE;AACvBD,cAAAA,OAAO,EAAE;AADc;AAJT;AAHH;AADE,OAArB;AAcD;;AAGD,QAAME,WAAW,GAAG,SAAdA,WAAc,GAAM;AAAA;;AACxB,+BAAA,KAAI,CAACC,eAAL,kFAAwBC,cAAxB;AACD,KAFD;;AAIA,SAAKC,KAAL,CAAWH,WAAX,GAAyBA,WAAzB;;AACA,QAAIX,OAAO,CAACe,IAAZ,EAAkB;AAEhBf,MAAAA,OAAO,CAACe,IAAR,CAAaC,YAAb,CAA0BC,EAA1B,CAA6B;AAC3BC,QAAAA,WAAW,EAAEP,WADc;AAE3BQ,QAAAA,YAAY,EAAER;AAFa,OAA7B;AAID;AACF,G;;SAEDS,a,GAAA,uBAAmDpB,OAAnD,EAA0EC,SAA1E,EAA2F;AAEzF,QAAID,OAAO,CAACe,IAAZ,EAAkB;AAChB,UAAMJ,WAAW,GAAG,KAAKG,KAAL,CAAWH,WAA/B;AAEAX,MAAAA,OAAO,CAACe,IAAR,CAAaC,YAAb,CAA0BK,GAA1B,CAA8B;AAC5BH,QAAAA,WAAW,EAAEP,WADe;AAE5BQ,QAAAA,YAAY,EAAER;AAFc,OAA9B;AAID;AACF,G;;;EAtD4CW,oB;;;AAA1B3B,iB,CACZP,Y,GAAeA,Y;AADHO,iB,CAEZ4B,a,GAAgB,mB","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {LayerExtension} from '@deck.gl/core';\nimport shaderModule from './shader-module';\n\nimport type {Layer, LayerContext, Accessor} from '@deck.gl/core';\n\nconst defaultProps = {\n getBrushingTarget: {type: 'accessor', value: [0, 0]},\n\n brushingTarget: 'source',\n brushingEnabled: true,\n brushingRadius: 10000\n};\n\nexport type BrushingExtensionProps<DataT = any> = {\n /**\n * Called to retrieve an arbitrary position for each object that it will be filtered by.\n * Only effective if `brushingTarget` is set to `custom`.\n */\n getBrushingTarget?: Accessor<DataT, [number, number]>;\n /**\n * Enable/disable brushing. If brushing is disabled, all objects are rendered.\n * @default true\n */\n brushingEnabled?: boolean;\n /**\n * The position used to filter each object by.\n */\n brushingTarget?: 'source' | 'target' | 'source_target' | 'custom';\n /** The brushing radius centered at the pointer, in meters. If a data object is within this circle, it is rendered; otherwise it is hidden.\n * @default 10000\n */\n brushingRadius?: number;\n};\n\n/** Adds GPU-based data brushing functionalities to layers. It allows the layer to show/hide objects based on the current pointer position. */\nexport default class BrushingExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'BrushingExtension';\n\n getShaders(): any {\n return {\n modules: [shaderModule]\n };\n }\n\n initializeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n brushingTargets: {\n size: 2,\n accessor: 'getBrushingTarget',\n shaderAttributes: {\n brushingTargets: {\n divisor: 0\n },\n instanceBrushingTargets: {\n divisor: 1\n }\n }\n }\n });\n }\n\n // Trigger redraw when mouse moves\n const onMouseMove = () => {\n this.getCurrentLayer()?.setNeedsRedraw();\n };\n // TODO - expose this in a better way\n this.state.onMouseMove = onMouseMove;\n if (context.deck) {\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.on({\n pointermove: onMouseMove,\n pointerleave: onMouseMove\n });\n }\n }\n\n finalizeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n // Remove event listeners\n if (context.deck) {\n const onMouseMove = this.state.onMouseMove as () => void;\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.off({\n pointermove: onMouseMove,\n pointerleave: onMouseMove\n });\n }\n }\n}\n"],"file":"brushing-extension.js"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _core = require("@deck.gl/core");
|
|
9
|
-
|
|
10
|
-
var vs = "\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n in vec2 brushingTargets;\n #else\n in vec2 instanceBrushingTargets;\n #endif\n\n out float brushing_isVisible;\n\n bool brushing_isPointInRange(vec2 position) {\n if (!brushing_enabled) {\n return true;\n }\n vec2 source_commonspace = project_position(position);\n vec2 target_commonspace = project_position(brushing_mousePos);\n float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);\n\n return distance <= brushing_radius;\n }\n\n bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {\n return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);\n }\n\n void brushing_setVisible(bool visible) {\n brushing_isVisible = float(visible);\n }\n";
|
|
11
|
-
var fs = "\n uniform bool brushing_enabled;\n in float brushing_isVisible;\n";
|
|
12
|
-
var TARGET = {
|
|
13
|
-
source: 0,
|
|
14
|
-
target: 1,
|
|
15
|
-
custom: 2,
|
|
16
|
-
source_target: 3
|
|
17
|
-
};
|
|
18
|
-
var inject = {
|
|
19
|
-
'vs:DECKGL_FILTER_GL_POSITION': "\n vec2 brushingTarget;\n vec2 brushingSource;\n if (brushing_target == 3) {\n brushingTarget = geometry.worldPositionAlt.xy;\n brushingSource = geometry.worldPosition.xy;\n } else if (brushing_target == 0) {\n brushingTarget = geometry.worldPosition.xy;\n } else if (brushing_target == 1) {\n brushingTarget = geometry.worldPositionAlt.xy;\n } else {\n #ifdef NON_INSTANCED_MODEL\n brushingTarget = brushingTargets;\n #else\n brushingTarget = instanceBrushingTargets;\n #endif\n }\n bool visible;\n if (brushing_target == 3) {\n visible = brushing_arePointsInRange(brushingSource, brushingTarget);\n } else {\n visible = brushing_isPointInRange(brushingTarget);\n }\n brushing_setVisible(visible);\n ",
|
|
20
|
-
'fs:DECKGL_FILTER_COLOR': "\n if (brushing_enabled && brushing_isVisible < 0.5) {\n discard;\n }\n "
|
|
21
|
-
};
|
|
22
|
-
var _default = {
|
|
23
|
-
name: 'brushing',
|
|
24
|
-
dependencies: [_core.project],
|
|
25
|
-
vs: vs,
|
|
26
|
-
fs: fs,
|
|
27
|
-
inject: inject,
|
|
28
|
-
getUniforms: function getUniforms(opts) {
|
|
29
|
-
if (!opts || !('viewport' in opts)) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var _opts$brushingEnabled = opts.brushingEnabled,
|
|
34
|
-
brushingEnabled = _opts$brushingEnabled === void 0 ? true : _opts$brushingEnabled,
|
|
35
|
-
_opts$brushingRadius = opts.brushingRadius,
|
|
36
|
-
brushingRadius = _opts$brushingRadius === void 0 ? 10000 : _opts$brushingRadius,
|
|
37
|
-
_opts$brushingTarget = opts.brushingTarget,
|
|
38
|
-
brushingTarget = _opts$brushingTarget === void 0 ? 'source' : _opts$brushingTarget,
|
|
39
|
-
mousePosition = opts.mousePosition,
|
|
40
|
-
viewport = opts.viewport;
|
|
41
|
-
return {
|
|
42
|
-
brushing_enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
|
|
43
|
-
brushing_radius: brushingRadius,
|
|
44
|
-
brushing_target: TARGET[brushingTarget] || 0,
|
|
45
|
-
brushing_mousePos: mousePosition ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y]) : [0, 0]
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.default = _default;
|
|
50
|
-
//# sourceMappingURL=shader-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/brushing/shader-module.ts"],"names":["vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","project","getUniforms","opts","brushingEnabled","brushingRadius","brushingTarget","mousePosition","viewport","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":";;;;;;;AAqBA;;AAWA,IAAMA,EAAE,w6BAAR;AAkCA,IAAMC,EAAE,yEAAR;AAKA,IAAMC,MAAM,GAAG;AACbC,EAAAA,MAAM,EAAE,CADK;AAEbC,EAAAA,MAAM,EAAE,CAFK;AAGbC,EAAAA,MAAM,EAAE,CAHK;AAIbC,EAAAA,aAAa,EAAE;AAJF,CAAf;AAOA,IAAMC,MAAM,GAAG;AACb,6zBADa;AA2Bb;AA3Ba,CAAf;eAkCe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbV,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,EAAE,EAAFA,EAJa;AAKbM,EAAAA,MAAM,EAANA,MALa;AAMbI,EAAAA,WAAW,EAAE,qBAACC,IAAD,EAA6D;AACxE,QAAI,CAACA,IAAD,IAAS,EAAE,cAAcA,IAAhB,CAAb,EAAoC;AAClC,aAAO,EAAP;AACD;;AACD,gCAMIA,IANJ,CACEC,eADF;AAAA,QACEA,eADF,sCACoB,IADpB;AAAA,+BAMID,IANJ,CAEEE,cAFF;AAAA,QAEEA,cAFF,qCAEmB,KAFnB;AAAA,+BAMIF,IANJ,CAGEG,cAHF;AAAA,QAGEA,cAHF,qCAGmB,QAHnB;AAAA,QAIEC,aAJF,GAMIJ,IANJ,CAIEI,aAJF;AAAA,QAKEC,QALF,GAMIL,IANJ,CAKEK,QALF;AAOA,WAAO;AACLC,MAAAA,gBAAgB,EAAEC,OAAO,CACvBN,eAAe,IAAIG,aAAnB,IAAoCC,QAAQ,CAACG,aAAT,CAAuBJ,aAAvB,CADb,CADpB;AAILK,MAAAA,eAAe,EAAEP,cAJZ;AAKLQ,MAAAA,eAAe,EAAEpB,MAAM,CAACa,cAAD,CAAN,IAA0B,CALtC;AAMLQ,MAAAA,iBAAiB,EAAEP,aAAa,GAC5BC,QAAQ,CAACO,SAAT,CAAmB,CAACR,aAAa,CAACS,CAAd,GAAkBR,QAAQ,CAACQ,CAA5B,EAA+BT,aAAa,CAACU,CAAd,GAAkBT,QAAQ,CAACS,CAA1D,CAAnB,CAD4B,GAE5B,CAAC,CAAD,EAAI,CAAJ;AARC,KAAP;AAUD;AA3BY,C","sourcesContent":["// Copyright (c) 2015-2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n/* eslint-disable camelcase */\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\nimport type {Viewport} from '@deck.gl/core';\n\nimport type {BrushingExtensionProps} from './brushing-extension';\n\ntype BrushingModuleSettings = {\n // From layer context\n viewport: Viewport;\n mousePosition?: {x: number; y: number};\n} & BrushingExtensionProps;\n\nconst vs = `\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n in vec2 brushingTargets;\n #else\n in vec2 instanceBrushingTargets;\n #endif\n\n out float brushing_isVisible;\n\n bool brushing_isPointInRange(vec2 position) {\n if (!brushing_enabled) {\n return true;\n }\n vec2 source_commonspace = project_position(position);\n vec2 target_commonspace = project_position(brushing_mousePos);\n float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);\n\n return distance <= brushing_radius;\n }\n\n bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {\n return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);\n }\n\n void brushing_setVisible(bool visible) {\n brushing_isVisible = float(visible);\n }\n`;\n\nconst fs = `\n uniform bool brushing_enabled;\n in float brushing_isVisible;\n`;\n\nconst TARGET = {\n source: 0,\n target: 1,\n custom: 2,\n source_target: 3\n};\n\nconst inject = {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n vec2 brushingTarget;\n vec2 brushingSource;\n if (brushing_target == 3) {\n brushingTarget = geometry.worldPositionAlt.xy;\n brushingSource = geometry.worldPosition.xy;\n } else if (brushing_target == 0) {\n brushingTarget = geometry.worldPosition.xy;\n } else if (brushing_target == 1) {\n brushingTarget = geometry.worldPositionAlt.xy;\n } else {\n #ifdef NON_INSTANCED_MODEL\n brushingTarget = brushingTargets;\n #else\n brushingTarget = instanceBrushingTargets;\n #endif\n }\n bool visible;\n if (brushing_target == 3) {\n visible = brushing_arePointsInRange(brushingSource, brushingTarget);\n } else {\n visible = brushing_isPointInRange(brushingTarget);\n }\n brushing_setVisible(visible);\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (brushing_enabled && brushing_isVisible < 0.5) {\n discard;\n }\n `\n};\n\nexport default {\n name: 'brushing',\n dependencies: [project],\n vs,\n fs,\n inject,\n getUniforms: (opts?: BrushingModuleSettings | {}): Record<string, any> => {\n if (!opts || !('viewport' in opts)) {\n return {};\n }\n const {\n brushingEnabled = true,\n brushingRadius = 10000,\n brushingTarget = 'source',\n mousePosition,\n viewport\n } = opts;\n return {\n brushing_enabled: Boolean(\n brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)\n ),\n brushing_radius: brushingRadius,\n brushing_target: TARGET[brushingTarget] || 0,\n brushing_mousePos: mousePosition\n ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])\n : [0, 0]\n };\n }\n} as ShaderModule<BrushingModuleSettings>;\n"],"file":"shader-module.js"}
|