@deck.gl/extensions 9.0.40 → 9.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brushing/brushing-extension.d.ts +1 -0
- package/dist/brushing/brushing-extension.d.ts.map +1 -1
- package/dist/brushing/brushing-extension.js +16 -19
- package/dist/brushing/brushing-extension.js.map +1 -0
- package/dist/brushing/shader-module.d.ts +8 -2
- package/dist/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +75 -50
- package/dist/brushing/shader-module.js.map +1 -0
- package/dist/clip/clip-extension.d.ts +5 -2
- package/dist/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +37 -42
- package/dist/clip/clip-extension.js.map +1 -0
- package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
- package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +28 -13
- package/dist/collision-filter/collision-filter-effect.js.map +1 -0
- package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
- package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-extension.js +6 -6
- package/dist/collision-filter/collision-filter-extension.js.map +1 -0
- package/dist/collision-filter/collision-filter-pass.d.ts +9 -5
- package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +15 -4
- package/dist/collision-filter/collision-filter-pass.js.map +1 -0
- package/dist/collision-filter/shader-module.d.ts +3 -2
- package/dist/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +75 -52
- package/dist/collision-filter/shader-module.js.map +1 -0
- package/dist/data-filter/aggregator.d.ts +4 -10
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +15 -8
- package/dist/data-filter/aggregator.js.map +1 -0
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +49 -39
- package/dist/data-filter/data-filter-extension.js.map +1 -0
- package/dist/data-filter/shader-module.d.ts +12 -5
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +190 -131
- package/dist/data-filter/shader-module.js.map +1 -0
- package/dist/dist.dev.js +2720 -2037
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +12 -4
- package/dist/fill-style/fill-style-extension.js.map +1 -0
- package/dist/fill-style/shader-module.d.ts +64 -6
- package/dist/fill-style/shader-module.d.ts.map +1 -1
- package/dist/fill-style/shader-module.js +74 -51
- package/dist/fill-style/shader-module.js.map +1 -0
- package/dist/fp64/fp64-extension.d.ts +1 -0
- package/dist/fp64/fp64-extension.d.ts.map +1 -1
- package/dist/fp64/fp64-extension.js +8 -19
- package/dist/fp64/fp64-extension.js.map +1 -0
- package/dist/fp64/project64.d.ts +2 -2
- package/dist/fp64/project64.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.d.ts +1 -1
- package/dist/fp64/project64.glsl.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.js +19 -21
- package/dist/fp64/project64.glsl.js.map +1 -0
- package/dist/fp64/project64.js +25 -24
- package/dist/fp64/project64.js.map +1 -0
- package/dist/index.cjs +1034 -528
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/mask/mask-effect.d.ts +5 -3
- package/dist/mask/mask-effect.d.ts.map +1 -1
- package/dist/mask/mask-effect.js +13 -5
- package/dist/mask/mask-effect.js.map +1 -0
- package/dist/mask/mask-extension.d.ts +1 -1
- package/dist/mask/mask-extension.d.ts.map +1 -1
- package/dist/mask/mask-extension.js +14 -8
- package/dist/mask/mask-extension.js.map +1 -0
- package/dist/mask/mask-pass.d.ts +2 -43
- package/dist/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +5 -1
- package/dist/mask/mask-pass.js.map +1 -0
- package/dist/mask/shader-module.d.ts +60 -3
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +74 -46
- package/dist/mask/shader-module.js.map +1 -0
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +21 -24
- package/dist/path-style/path-style-extension.js.map +1 -0
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +12 -7
- package/dist/path-style/shaders.glsl.js.map +1 -0
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +4 -0
- package/dist/terrain/height-map-builder.js.map +1 -0
- package/dist/terrain/shader-module.d.ts +60 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +70 -61
- package/dist/terrain/shader-module.js.map +1 -0
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +4 -0
- package/dist/terrain/terrain-cover.js.map +1 -0
- package/dist/terrain/terrain-effect.d.ts +4 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.js +32 -18
- package/dist/terrain/terrain-effect.js.map +1 -0
- package/dist/terrain/terrain-extension.d.ts.map +1 -1
- package/dist/terrain/terrain-extension.js +4 -0
- package/dist/terrain/terrain-extension.js.map +1 -0
- package/dist/terrain/terrain-pass.d.ts +6 -41
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +12 -1
- package/dist/terrain/terrain-pass.js.map +1 -0
- package/dist/terrain/terrain-picking-pass.d.ts +7 -1
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +12 -1
- package/dist/terrain/terrain-picking-pass.js.map +1 -0
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +4 -0
- package/dist/terrain/utils.js.map +1 -0
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +4 -1
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +4 -0
- package/dist/utils/projection-utils.js.map +1 -0
- package/dist.min.js +1102 -817
- package/package.json +8 -8
- package/src/brushing/brushing-extension.ts +17 -20
- package/src/brushing/shader-module.ts +58 -47
- package/src/clip/clip-extension.ts +38 -40
- package/src/collision-filter/collision-filter-effect.ts +31 -20
- package/src/collision-filter/collision-filter-extension.ts +6 -7
- package/src/collision-filter/collision-filter-pass.ts +17 -6
- package/src/collision-filter/shader-module.ts +40 -22
- package/src/data-filter/aggregator.ts +23 -11
- package/src/data-filter/data-filter-extension.ts +76 -49
- package/src/data-filter/shader-module.ts +150 -90
- package/src/fill-style/fill-style-extension.ts +13 -5
- package/src/fill-style/shader-module.ts +84 -52
- package/src/fp64/fp64-extension.ts +8 -19
- package/src/fp64/project64.glsl.ts +18 -21
- package/src/fp64/project64.ts +27 -28
- package/src/index.ts +5 -0
- package/src/mask/mask-effect.ts +17 -7
- package/src/mask/mask-extension.ts +16 -9
- package/src/mask/mask-pass.ts +17 -3
- package/src/mask/shader-module.ts +63 -27
- package/src/path-style/path-style-extension.ts +27 -28
- package/src/path-style/shaders.glsl.ts +13 -7
- package/src/terrain/height-map-builder.ts +4 -0
- package/src/terrain/shader-module.ts +62 -44
- package/src/terrain/terrain-cover.ts +4 -0
- package/src/terrain/terrain-effect.ts +36 -19
- package/src/terrain/terrain-extension.ts +4 -0
- package/src/terrain/terrain-pass.ts +19 -3
- package/src/terrain/terrain-picking-pass.ts +15 -2
- package/src/terrain/utils.ts +4 -0
- package/src/utils/debug.ts +4 -0
- package/src/utils/projection-utils.ts +4 -0
- package/dist/utils/syntax-tags.d.ts +0 -6
- package/dist/utils/syntax-tags.d.ts.map +0 -1
- package/dist/utils/syntax-tags.js +0 -5
- package/src/utils/syntax-tags.ts +0 -5
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Framebuffer, Texture, TextureView} from '@luma.gl/core';
|
|
2
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
3
7
|
import {project} from '@deck.gl/core';
|
|
4
|
-
import {glsl} from '../utils/syntax-tags';
|
|
5
8
|
|
|
6
|
-
const vs = glsl`
|
|
9
|
+
const vs = /* glsl */ `
|
|
7
10
|
in float collisionPriorities;
|
|
8
11
|
|
|
9
12
|
uniform sampler2D collision_texture;
|
|
10
|
-
|
|
11
|
-
uniform
|
|
13
|
+
|
|
14
|
+
uniform collisionUniforms {
|
|
15
|
+
bool sort;
|
|
16
|
+
bool enabled;
|
|
17
|
+
} collision;
|
|
12
18
|
|
|
13
19
|
vec2 collision_getCoords(vec4 position) {
|
|
14
20
|
vec4 collision_clipspace = project_common_position_to_clipspace(position);
|
|
@@ -23,7 +29,7 @@ float collision_match(vec2 tex, vec3 pickingColor) {
|
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
26
|
-
if (!
|
|
32
|
+
if (!collision.enabled) {
|
|
27
33
|
return 1.0;
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -32,7 +38,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
32
38
|
// This reduces the flicker present when objects are shown/hidden
|
|
33
39
|
const int N = 2;
|
|
34
40
|
float accumulator = 0.0;
|
|
35
|
-
vec2 step = vec2(1.0 /
|
|
41
|
+
vec2 step = vec2(1.0 / project.viewportSize);
|
|
36
42
|
|
|
37
43
|
const float floatN = float(N);
|
|
38
44
|
vec2 delta = -floatN * step;
|
|
@@ -51,16 +57,16 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
51
57
|
`;
|
|
52
58
|
|
|
53
59
|
const inject = {
|
|
54
|
-
'vs:#decl': glsl`
|
|
60
|
+
'vs:#decl': /* glsl */ `
|
|
55
61
|
float collision_fade = 1.0;
|
|
56
62
|
`,
|
|
57
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
58
|
-
if (
|
|
63
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
64
|
+
if (collision.sort) {
|
|
59
65
|
float collisionPriority = collisionPriorities;
|
|
60
66
|
position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
if (
|
|
69
|
+
if (collision.enabled) {
|
|
64
70
|
vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
65
71
|
vec2 collision_texCoords = collision_getCoords(collision_common_position);
|
|
66
72
|
collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
|
|
@@ -70,40 +76,52 @@ const inject = {
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
`,
|
|
73
|
-
'vs:DECKGL_FILTER_COLOR': glsl`
|
|
79
|
+
'vs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
74
80
|
color.a *= collision_fade;
|
|
75
81
|
`
|
|
76
82
|
};
|
|
77
83
|
|
|
78
|
-
type
|
|
84
|
+
export type CollisionModuleProps = {
|
|
85
|
+
enabled: boolean;
|
|
79
86
|
collisionFBO?: Framebuffer;
|
|
80
87
|
drawToCollisionMap?: boolean;
|
|
81
88
|
dummyCollisionMap?: Texture;
|
|
82
89
|
};
|
|
83
90
|
|
|
84
91
|
/* eslint-disable camelcase */
|
|
85
|
-
type CollisionUniforms = {
|
|
92
|
+
type CollisionUniforms = {
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
sort?: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type CollisionBindings = {
|
|
98
|
+
collision_texture?: TextureView | Texture;
|
|
99
|
+
};
|
|
86
100
|
|
|
87
101
|
const getCollisionUniforms = (
|
|
88
|
-
opts:
|
|
89
|
-
|
|
90
|
-
): CollisionUniforms => {
|
|
102
|
+
opts: CollisionModuleProps | {}
|
|
103
|
+
): CollisionBindings & CollisionUniforms => {
|
|
91
104
|
if (!opts || !('dummyCollisionMap' in opts)) {
|
|
92
105
|
return {};
|
|
93
106
|
}
|
|
94
|
-
const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;
|
|
107
|
+
const {enabled, collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;
|
|
95
108
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
enabled: enabled && !drawToCollisionMap,
|
|
110
|
+
sort: Boolean(drawToCollisionMap),
|
|
98
111
|
collision_texture:
|
|
99
112
|
!drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap
|
|
100
113
|
};
|
|
101
114
|
};
|
|
102
115
|
|
|
116
|
+
// @ts-ignore
|
|
103
117
|
export default {
|
|
104
118
|
name: 'collision',
|
|
105
119
|
dependencies: [project],
|
|
106
120
|
vs,
|
|
107
121
|
inject,
|
|
108
|
-
getUniforms: getCollisionUniforms
|
|
109
|
-
|
|
122
|
+
getUniforms: getCollisionUniforms,
|
|
123
|
+
uniformTypes: {
|
|
124
|
+
sort: 'i32',
|
|
125
|
+
enabled: 'i32'
|
|
126
|
+
}
|
|
127
|
+
} as ShaderModule<CollisionModuleProps>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Device, DeviceFeature, Framebuffer, RenderPipelineParameters} from '@luma.gl/core';
|
|
6
|
+
import {Model, ModelProps} from '@luma.gl/engine';
|
|
4
7
|
|
|
5
8
|
const AGGREGATE_VS = `\
|
|
6
9
|
#version 300 es
|
|
@@ -71,7 +74,6 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
71
74
|
colorAttachments: [
|
|
72
75
|
device.createTexture({
|
|
73
76
|
format: 'rgba32float',
|
|
74
|
-
type: GL.FLOAT,
|
|
75
77
|
mipmaps: false
|
|
76
78
|
})
|
|
77
79
|
]
|
|
@@ -80,12 +82,17 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
80
82
|
return device.createFramebuffer({
|
|
81
83
|
width: 256,
|
|
82
84
|
height: 64,
|
|
83
|
-
colorAttachments: [device.createTexture({format: 'rgba8unorm',
|
|
85
|
+
colorAttachments: [device.createTexture({format: 'rgba8unorm', mipmaps: false})]
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
// Increments the counter based on dataFilter_value
|
|
88
|
-
export function getModel(
|
|
90
|
+
export function getModel(
|
|
91
|
+
device: Device,
|
|
92
|
+
bufferLayout: ModelProps['bufferLayout'],
|
|
93
|
+
shaderOptions: any,
|
|
94
|
+
useFloatTarget: boolean
|
|
95
|
+
): Model {
|
|
89
96
|
shaderOptions.defines.NON_INSTANCED_MODEL = 1;
|
|
90
97
|
if (useFloatTarget) {
|
|
91
98
|
shaderOptions.defines.FLOAT_TARGET = 1;
|
|
@@ -95,16 +102,21 @@ export function getModel(device: Device, shaderOptions: any, useFloatTarget: boo
|
|
|
95
102
|
id: 'data-filter-aggregation-model',
|
|
96
103
|
vertexCount: 1,
|
|
97
104
|
isInstanced: false,
|
|
98
|
-
|
|
105
|
+
topology: 'point-list',
|
|
99
106
|
vs: AGGREGATE_VS,
|
|
100
107
|
fs: AGGREGATE_FS,
|
|
108
|
+
bufferLayout,
|
|
101
109
|
...shaderOptions
|
|
102
110
|
});
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
export const parameters = {
|
|
113
|
+
export const parameters: RenderPipelineParameters = {
|
|
106
114
|
blend: true,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
blendColorSrcFactor: 'one',
|
|
116
|
+
blendColorDstFactor: 'one',
|
|
117
|
+
blendAlphaSrcFactor: 'one',
|
|
118
|
+
blendAlphaDstFactor: 'one',
|
|
119
|
+
blendColorOperation: 'add',
|
|
120
|
+
blendAlphaOperation: 'add',
|
|
121
|
+
depthCompare: 'never'
|
|
110
122
|
} as const;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
import type {Framebuffer} from '@luma.gl/core';
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Buffer, Framebuffer} from '@luma.gl/core';
|
|
22
6
|
import type {Model} from '@luma.gl/engine';
|
|
23
7
|
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
24
8
|
import {_deepEqual as deepEqual, LayerExtension, log} from '@deck.gl/core';
|
|
25
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
CategoryBitMask,
|
|
11
|
+
DataFilterModuleProps,
|
|
12
|
+
Defines,
|
|
13
|
+
dataFilter,
|
|
14
|
+
dataFilter64
|
|
15
|
+
} from './shader-module';
|
|
26
16
|
import * as aggregator from './aggregator';
|
|
17
|
+
import {NumberArray4} from '@math.gl/core';
|
|
27
18
|
|
|
28
19
|
const defaultProps = {
|
|
29
20
|
getFilterValue: {type: 'accessor', value: 0},
|
|
@@ -124,6 +115,12 @@ const defaultOptions: Required<DataFilterExtensionOptions> = {
|
|
|
124
115
|
countItems: false
|
|
125
116
|
};
|
|
126
117
|
|
|
118
|
+
const CATEGORY_TYPE_FROM_SIZE = {
|
|
119
|
+
1: 'uint' as const,
|
|
120
|
+
2: 'uvec2' as const,
|
|
121
|
+
3: 'uvec3' as const,
|
|
122
|
+
4: 'uvec4' as const
|
|
123
|
+
};
|
|
127
124
|
const DATA_TYPE_FROM_SIZE = {
|
|
128
125
|
1: 'float' as const,
|
|
129
126
|
2: 'vec2' as const,
|
|
@@ -146,7 +143,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
146
143
|
const {categorySize, filterSize, fp64} = extension.opts;
|
|
147
144
|
const defines: Defines = {};
|
|
148
145
|
if (categorySize) {
|
|
149
|
-
defines.DATACATEGORY_TYPE =
|
|
146
|
+
defines.DATACATEGORY_TYPE = CATEGORY_TYPE_FROM_SIZE[categorySize];
|
|
150
147
|
defines.DATACATEGORY_CHANNELS = categorySize;
|
|
151
148
|
}
|
|
152
149
|
if (filterSize) {
|
|
@@ -154,7 +151,10 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
154
151
|
defines.DATAFILTER_DOUBLE = Boolean(fp64);
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
|
|
154
|
+
const module = fp64 ? dataFilter64 : dataFilter;
|
|
155
|
+
module.uniformTypes = module.uniformTypesFromOptions(extension.opts);
|
|
156
|
+
|
|
157
|
+
return {modules: [module], defines};
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this) {
|
|
@@ -179,6 +179,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
179
179
|
size: categorySize,
|
|
180
180
|
stepMode: 'dynamic',
|
|
181
181
|
accessor: 'getFilterCategory',
|
|
182
|
+
type: 'uint32',
|
|
182
183
|
transform:
|
|
183
184
|
categorySize === 1
|
|
184
185
|
? d => extension._getCategoryKey.call(this, d, 0)
|
|
@@ -195,7 +196,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
195
196
|
// The vertex shader checks if a vertex has the same "index" as the previous vertex
|
|
196
197
|
// so that we only write one count cross multiple vertices of the same object
|
|
197
198
|
attributeManager.add({
|
|
198
|
-
|
|
199
|
+
filterVertexIndices: {
|
|
199
200
|
size: useFloatTarget ? 1 : 2,
|
|
200
201
|
vertexOffset: 1,
|
|
201
202
|
type: 'unorm8',
|
|
@@ -217,6 +218,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
217
218
|
const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);
|
|
218
219
|
const filterModel = aggregator.getModel(
|
|
219
220
|
device,
|
|
221
|
+
attributeManager.getBufferLayouts({isInstanced: false}),
|
|
220
222
|
extension.getShaders.call(this, extension),
|
|
221
223
|
useFloatTarget
|
|
222
224
|
);
|
|
@@ -271,40 +273,65 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
271
273
|
const filterModel = this.state.filterModel as Model;
|
|
272
274
|
const filterNeedsUpdate = this.state.filterNeedsUpdate as boolean;
|
|
273
275
|
|
|
274
|
-
const {onFilteredItemsChange} = this.props;
|
|
275
|
-
|
|
276
276
|
if (!this.state.categoryBitMask) {
|
|
277
277
|
extension._updateCategoryBitMask.call(this, params, extension);
|
|
278
278
|
}
|
|
279
|
+
|
|
280
|
+
const {
|
|
281
|
+
onFilteredItemsChange,
|
|
282
|
+
extensions,
|
|
283
|
+
filterEnabled,
|
|
284
|
+
filterRange,
|
|
285
|
+
filterSoftRange,
|
|
286
|
+
filterTransformSize,
|
|
287
|
+
filterTransformColor,
|
|
288
|
+
filterCategories
|
|
289
|
+
} = this.props;
|
|
290
|
+
const dataFilterProps: DataFilterModuleProps = {
|
|
291
|
+
extensions,
|
|
292
|
+
filterEnabled,
|
|
293
|
+
filterRange,
|
|
294
|
+
filterSoftRange,
|
|
295
|
+
filterTransformSize,
|
|
296
|
+
filterTransformColor,
|
|
297
|
+
filterCategories
|
|
298
|
+
};
|
|
299
|
+
if (this.state.categoryBitMask) {
|
|
300
|
+
dataFilterProps.categoryBitMask = this.state.categoryBitMask as CategoryBitMask;
|
|
301
|
+
}
|
|
302
|
+
this.setShaderModuleProps({dataFilter: dataFilterProps});
|
|
303
|
+
|
|
279
304
|
/* eslint-disable-next-line camelcase */
|
|
280
|
-
params.uniforms.filter_categoryBitMask = this.state.categoryBitMask;
|
|
281
305
|
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
|
|
306
|
+
const attributeManager = this.getAttributeManager()!;
|
|
282
307
|
const {
|
|
283
|
-
attributes: {filterValues, filterCategoryValues,
|
|
284
|
-
} =
|
|
308
|
+
attributes: {filterValues, filterCategoryValues, filterVertexIndices}
|
|
309
|
+
} = attributeManager;
|
|
285
310
|
filterModel.setVertexCount(this.getNumInstances());
|
|
286
311
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
filterModel.updateModuleSettings(params.moduleParameters);
|
|
290
|
-
// @ts-expect-error filterValue and filterIndices should always have buffer value
|
|
291
|
-
filterModel.setAttributes({
|
|
312
|
+
// @ts-expect-error filterValue and filterVertexIndices should always have buffer value
|
|
313
|
+
const attributes: Record<string, Buffer> = {
|
|
292
314
|
...filterValues?.getValue(),
|
|
293
315
|
...filterCategoryValues?.getValue(),
|
|
294
|
-
...
|
|
316
|
+
...filterVertexIndices?.getValue()
|
|
317
|
+
};
|
|
318
|
+
filterModel.setAttributes(attributes);
|
|
319
|
+
filterModel.shaderInputs.setProps({
|
|
320
|
+
dataFilter: dataFilterProps
|
|
295
321
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
);
|
|
322
|
+
|
|
323
|
+
const viewport = [0, 0, filterFBO.width, filterFBO.height] as NumberArray4;
|
|
324
|
+
|
|
325
|
+
const renderPass = filterModel.device.beginRenderPass({
|
|
326
|
+
id: 'data-filter-aggregation',
|
|
327
|
+
framebuffer: filterFBO,
|
|
328
|
+
parameters: {viewport},
|
|
329
|
+
clearColor: [0, 0, 0, 0]
|
|
330
|
+
});
|
|
331
|
+
filterModel.setParameters(aggregator.parameters);
|
|
332
|
+
filterModel.draw(renderPass);
|
|
333
|
+
renderPass.end();
|
|
334
|
+
|
|
308
335
|
const color = filterModel.device.readPixelsToArrayWebGL(filterFBO);
|
|
309
336
|
let count = 0;
|
|
310
337
|
for (let i = 0; i < color.length; i++) {
|
|
@@ -338,7 +365,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
338
365
|
const {categorySize} = extension.opts;
|
|
339
366
|
if (!categorySize) return;
|
|
340
367
|
const {filterCategories} = this.props;
|
|
341
|
-
const categoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
368
|
+
const categoryBitMask: CategoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
342
369
|
const categoryFilters = (
|
|
343
370
|
categorySize === 1 ? [filterCategories] : filterCategories
|
|
344
371
|
) as FilterCategory[][];
|