@deck.gl/extensions 8.8.0-alpha.5 → 8.8.0-beta.2
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/dist.dev.js +480 -1335
- package/dist/es5/brushing/brushing.js +19 -15
- package/dist/es5/brushing/brushing.js.map +1 -1
- package/dist/es5/brushing/shader-module.js +1 -1
- package/dist/es5/brushing/shader-module.js.map +1 -1
- package/dist/es5/clip/clip.js +4 -2
- package/dist/es5/clip/clip.js.map +1 -1
- package/dist/es5/data-filter/aggregator.js +1 -1
- package/dist/es5/data-filter/aggregator.js.map +1 -1
- package/dist/es5/data-filter/data-filter.js +9 -9
- package/dist/es5/data-filter/data-filter.js.map +1 -1
- package/dist/es5/data-filter/shader-module.js +22 -13
- package/dist/es5/data-filter/shader-module.js.map +1 -1
- package/dist/es5/fill-style/fill-style.js +13 -11
- package/dist/es5/fill-style/fill-style.js.map +1 -1
- package/dist/es5/fill-style/shaders.glsl.js +8 -6
- package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
- package/dist/es5/fp64/fp64.js +4 -2
- package/dist/es5/fp64/fp64.js.map +1 -1
- package/dist/es5/fp64/project64.glsl.js +1 -1
- package/dist/es5/fp64/project64.js +2 -5
- package/dist/es5/fp64/project64.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mask/mask.js +7 -4
- package/dist/es5/mask/mask.js.map +1 -1
- package/dist/es5/mask/shader-module.js +6 -7
- package/dist/es5/mask/shader-module.js.map +1 -1
- package/dist/es5/path-style/path-style.js +5 -5
- package/dist/es5/path-style/path-style.js.map +1 -1
- package/dist/es5/path-style/shaders.glsl.js +1 -1
- package/dist/es5/path-style/shaders.glsl.js.map +1 -1
- package/dist/esm/brushing/brushing.js +20 -15
- package/dist/esm/brushing/brushing.js.map +1 -1
- package/dist/esm/brushing/shader-module.js +1 -1
- package/dist/esm/brushing/shader-module.js.map +1 -1
- package/dist/esm/clip/clip.js +5 -2
- package/dist/esm/clip/clip.js.map +1 -1
- package/dist/esm/data-filter/aggregator.js +1 -1
- package/dist/esm/data-filter/aggregator.js.map +1 -1
- package/dist/esm/data-filter/data-filter.js +6 -3
- package/dist/esm/data-filter/data-filter.js.map +1 -1
- package/dist/esm/data-filter/shader-module.js +21 -21
- package/dist/esm/data-filter/shader-module.js.map +1 -1
- package/dist/esm/fill-style/fill-style.js +18 -13
- package/dist/esm/fill-style/fill-style.js.map +1 -1
- package/dist/esm/fill-style/shaders.glsl.js +6 -2
- package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
- package/dist/esm/fp64/fp64.js +4 -2
- package/dist/esm/fp64/fp64.js.map +1 -1
- package/dist/esm/fp64/project64.glsl.js +1 -1
- package/dist/esm/fp64/project64.glsl.js.map +1 -1
- package/dist/esm/fp64/project64.js +2 -3
- package/dist/esm/fp64/project64.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mask/mask.js +7 -4
- package/dist/esm/mask/mask.js.map +1 -1
- package/dist/esm/mask/shader-module.js +6 -6
- package/dist/esm/mask/shader-module.js.map +1 -1
- package/dist/esm/path-style/path-style.js +6 -5
- package/dist/esm/path-style/path-style.js.map +1 -1
- package/dist/esm/path-style/shaders.glsl.js +1 -1
- package/dist/esm/path-style/shaders.glsl.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +5 -3
- package/src/brushing/{brushing.js → brushing.ts} +45 -17
- package/src/brushing/{shader-module.js → shader-module.ts} +13 -3
- package/src/clip/{clip.js → clip.ts} +26 -9
- package/src/data-filter/{aggregator.js → aggregator.ts} +12 -8
- package/src/data-filter/{data-filter.js → data-filter.ts} +90 -13
- package/src/data-filter/{shader-module.js → shader-module.ts} +36 -27
- package/src/fill-style/{fill-style.js → fill-style.ts} +83 -19
- package/src/fill-style/{shaders.glsl.js → shaders.glsl.ts} +24 -4
- package/src/fp64/{fp64.js → fp64.ts} +6 -3
- package/src/fp64/{project64.glsl.js → project64.glsl.ts} +0 -0
- package/src/fp64/{project64.js → project64.ts} +16 -5
- package/src/index.ts +8 -0
- package/src/mask/{mask.js → mask.ts} +25 -8
- package/src/mask/shader-module.ts +86 -0
- package/src/path-style/{path-style.js → path-style.ts} +65 -14
- package/src/path-style/{shaders.glsl.js → shaders.glsl.ts} +0 -0
- package/typed/brushing/brushing.d.ts +37 -16
- package/typed/brushing/brushing.d.ts.map +1 -1
- package/typed/brushing/brushing.js +83 -0
- package/typed/brushing/shader-module.d.ts +9 -24
- package/typed/brushing/shader-module.d.ts.map +1 -1
- package/typed/brushing/shader-module.js +116 -0
- package/typed/clip/clip.d.ts +27 -10
- package/typed/clip/clip.d.ts.map +1 -1
- package/typed/clip/clip.js +114 -0
- package/typed/data-filter/aggregator.d.ts +10 -9
- package/typed/data-filter/aggregator.d.ts.map +1 -1
- package/typed/data-filter/aggregator.js +98 -0
- package/typed/data-filter/data-filter.d.ts +87 -29
- package/typed/data-filter/data-filter.d.ts.map +1 -1
- package/typed/data-filter/data-filter.js +159 -0
- package/typed/data-filter/shader-module.d.ts +7 -24
- package/typed/data-filter/shader-module.d.ts.map +1 -1
- package/typed/data-filter/shader-module.js +152 -0
- package/typed/fill-style/fill-style.d.ts +74 -41
- package/typed/fill-style/fill-style.d.ts.map +1 -1
- package/typed/fill-style/fill-style.js +152 -0
- package/typed/fill-style/shaders.glsl.d.ts +8 -33
- package/typed/fill-style/shaders.glsl.d.ts.map +1 -1
- package/typed/fill-style/shaders.glsl.js +95 -0
- package/typed/fp64/fp64.d.ts +6 -6
- package/typed/fp64/fp64.d.ts.map +1 -1
- package/typed/fp64/fp64.js +34 -0
- package/typed/fp64/project64.d.ts +5 -9
- package/typed/fp64/project64.d.ts.map +1 -1
- package/typed/fp64/project64.glsl.d.ts +1 -1
- package/typed/fp64/project64.glsl.d.ts.map +1 -1
- package/typed/fp64/project64.glsl.js +100 -0
- package/typed/fp64/project64.js +50 -0
- package/typed/index.d.ts +6 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/index.js +9 -0
- package/typed/mask/mask.d.ts +21 -9
- package/typed/mask/mask.d.ts.map +1 -1
- package/typed/mask/mask.js +48 -0
- package/typed/mask/shader-module.d.ts +6 -20
- package/typed/mask/shader-module.d.ts.map +1 -1
- package/{src → typed}/mask/shader-module.js +16 -21
- package/typed/path-style/path-style.d.ts +63 -27
- package/typed/path-style/path-style.d.ts.map +1 -1
- package/typed/path-style/path-style.js +107 -0
- package/typed/path-style/shaders.glsl.d.ts +6 -7
- package/typed/path-style/shaders.glsl.d.ts.map +1 -1
- package/typed/path-style/shaders.glsl.js +93 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {project} from '@deck.gl/core';
|
|
2
|
+
import type {_ShaderModule as ShaderModule} from '@deck.gl/core';
|
|
3
|
+
import type {Texture2D} from '@luma.gl/webgl';
|
|
4
|
+
|
|
5
|
+
const vs = `
|
|
6
|
+
uniform vec4 mask_bounds;
|
|
7
|
+
uniform bool mask_maskByInstance;
|
|
8
|
+
vec2 mask_getCoords(vec4 position) {
|
|
9
|
+
return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const fs = `
|
|
14
|
+
uniform sampler2D mask_texture;
|
|
15
|
+
uniform int mask_channel;
|
|
16
|
+
uniform bool mask_enabled;
|
|
17
|
+
bool mask_isInBounds(vec2 texCoords) {
|
|
18
|
+
if (!mask_enabled) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
vec4 maskColor = texture2D(mask_texture, texCoords);
|
|
22
|
+
float maskValue = 1.0;
|
|
23
|
+
if (mask_channel == 0) {
|
|
24
|
+
maskValue = maskColor.r;
|
|
25
|
+
} else if (mask_channel == 1) {
|
|
26
|
+
maskValue = maskColor.g;
|
|
27
|
+
} else if (mask_channel == 2) {
|
|
28
|
+
maskValue = maskColor.b;
|
|
29
|
+
} else if (mask_channel == 3) {
|
|
30
|
+
maskValue = maskColor.a;
|
|
31
|
+
}
|
|
32
|
+
return maskValue < 0.5;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const inject = {
|
|
37
|
+
'vs:#decl': `
|
|
38
|
+
varying vec2 mask_texCoords;
|
|
39
|
+
`,
|
|
40
|
+
'vs:#main-end': `
|
|
41
|
+
vec4 mask_common_position;
|
|
42
|
+
if (mask_maskByInstance) {
|
|
43
|
+
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
44
|
+
} else {
|
|
45
|
+
mask_common_position = geometry.position;
|
|
46
|
+
}
|
|
47
|
+
mask_texCoords = mask_getCoords(mask_common_position);
|
|
48
|
+
`,
|
|
49
|
+
'fs:#decl': `
|
|
50
|
+
varying vec2 mask_texCoords;
|
|
51
|
+
`,
|
|
52
|
+
'fs:#main-start': `
|
|
53
|
+
if (mask_enabled) {
|
|
54
|
+
bool mask = mask_isInBounds(mask_texCoords);
|
|
55
|
+
|
|
56
|
+
// Debug: show extent of render target
|
|
57
|
+
// gl_FragColor = vec4(mask_texCoords, 0.0, 1.0);
|
|
58
|
+
gl_FragColor = texture2D(mask_texture, mask_texCoords);
|
|
59
|
+
|
|
60
|
+
if (!mask) discard;
|
|
61
|
+
}
|
|
62
|
+
`
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type MaskModuleSettings = {
|
|
66
|
+
maskMap?: Texture2D;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/* eslint-disable camelcase */
|
|
70
|
+
const getMaskUniforms = (opts?: MaskModuleSettings | {}): Record<string, any> => {
|
|
71
|
+
if (opts && 'maskMap' in opts) {
|
|
72
|
+
return {
|
|
73
|
+
mask_texture: opts.maskMap
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
name: 'mask',
|
|
81
|
+
dependencies: [project],
|
|
82
|
+
vs,
|
|
83
|
+
fs,
|
|
84
|
+
inject,
|
|
85
|
+
getUniforms: getMaskUniforms
|
|
86
|
+
} as ShaderModule<MaskModuleSettings>;
|
|
@@ -22,6 +22,8 @@ import {LayerExtension, _mergeShaders as mergeShaders} from '@deck.gl/core';
|
|
|
22
22
|
import {dashShaders, offsetShaders} from './shaders.glsl';
|
|
23
23
|
import {dist} from 'gl-matrix/vec3';
|
|
24
24
|
|
|
25
|
+
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
26
|
+
|
|
25
27
|
const defaultProps = {
|
|
26
28
|
getDashArray: {type: 'accessor', value: [0, 0]},
|
|
27
29
|
getOffset: {type: 'accessor', value: 0},
|
|
@@ -29,16 +31,66 @@ const defaultProps = {
|
|
|
29
31
|
dashGapPickable: false
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
+
export type PathStyleExtensionProps<DataT = any> = {
|
|
35
|
+
/**
|
|
36
|
+
* Accessor for the dash array to draw each path with: `[dashSize, gapSize]` relative to the width of the path.
|
|
37
|
+
* Requires the `dash` option to be on.
|
|
38
|
+
*/
|
|
39
|
+
getDashArray?: Accessor<DataT, [number, number]>;
|
|
40
|
+
/**
|
|
41
|
+
* Accessor for the offset to draw each path with, relative to the width of the path.
|
|
42
|
+
* Negative offset is to the left hand side, and positive offset is to the right hand side.
|
|
43
|
+
* @default 0
|
|
44
|
+
*/
|
|
45
|
+
getOffset?: Accessor<DataT, number>;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, adjust gaps for the dashes to align at both ends.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
dashJustified?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If `true`, gaps between solid strokes are pickable. If `false`, only the solid strokes are pickable.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
dashGapPickable?: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type PathStyleExtensionOptions = {
|
|
59
|
+
/**
|
|
60
|
+
* Add capability to render dashed lines.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
dash: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Add capability to offset lines.
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
offset: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Improve dash rendering quality in certain circumstances. Note that this option introduces additional performance overhead.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
highPrecisionDash: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Adds selected features to the `PathLayer` and composite layers that render the `PathLayer`. */
|
|
77
|
+
export default class PathStyleExtension extends LayerExtension<PathStyleExtensionOptions> {
|
|
78
|
+
static defaultProps = defaultProps;
|
|
79
|
+
static extensionName = 'PathStyleExtension';
|
|
80
|
+
|
|
81
|
+
constructor({
|
|
82
|
+
dash = false,
|
|
83
|
+
offset = false,
|
|
84
|
+
highPrecisionDash = false
|
|
85
|
+
}: Partial<PathStyleExtensionOptions> = {}) {
|
|
34
86
|
super({dash: dash || highPrecisionDash, offset, highPrecisionDash});
|
|
35
87
|
}
|
|
36
88
|
|
|
37
|
-
isEnabled(layer) {
|
|
38
|
-
return layer.state
|
|
89
|
+
isEnabled(layer: Layer<PathStyleExtensionProps>): boolean {
|
|
90
|
+
return 'pathTesselator' in layer.state;
|
|
39
91
|
}
|
|
40
92
|
|
|
41
|
-
getShaders(extension) {
|
|
93
|
+
getShaders(this: Layer<PathStyleExtensionProps>, extension: this): any {
|
|
42
94
|
if (!extension.isEnabled(this)) {
|
|
43
95
|
return null;
|
|
44
96
|
}
|
|
@@ -55,15 +107,13 @@ export default class PathStyleExtension extends LayerExtension {
|
|
|
55
107
|
return result;
|
|
56
108
|
}
|
|
57
109
|
|
|
58
|
-
initializeState(context, extension) {
|
|
110
|
+
initializeState(this: Layer<PathStyleExtensionProps>, context: LayerContext, extension: this) {
|
|
59
111
|
const attributeManager = this.getAttributeManager();
|
|
60
112
|
if (!attributeManager || !extension.isEnabled(this)) {
|
|
61
113
|
// This extension only works with the PathLayer
|
|
62
114
|
return;
|
|
63
115
|
}
|
|
64
116
|
|
|
65
|
-
extension.enabled = true;
|
|
66
|
-
|
|
67
117
|
if (extension.opts.dash) {
|
|
68
118
|
attributeManager.addInstanced({
|
|
69
119
|
instanceDashArrays: {size: 2, accessor: 'getDashArray'}
|
|
@@ -85,12 +135,16 @@ export default class PathStyleExtension extends LayerExtension {
|
|
|
85
135
|
}
|
|
86
136
|
}
|
|
87
137
|
|
|
88
|
-
updateState(
|
|
138
|
+
updateState(
|
|
139
|
+
this: Layer<PathStyleExtensionProps>,
|
|
140
|
+
params: UpdateParameters<Layer<PathStyleExtensionProps>>,
|
|
141
|
+
extension: this
|
|
142
|
+
) {
|
|
89
143
|
if (!extension.isEnabled(this)) {
|
|
90
144
|
return;
|
|
91
145
|
}
|
|
92
146
|
|
|
93
|
-
const uniforms = {};
|
|
147
|
+
const uniforms: any = {};
|
|
94
148
|
|
|
95
149
|
if (extension.opts.dash) {
|
|
96
150
|
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
@@ -100,7 +154,7 @@ export default class PathStyleExtension extends LayerExtension {
|
|
|
100
154
|
this.state.model.setUniforms(uniforms);
|
|
101
155
|
}
|
|
102
156
|
|
|
103
|
-
getDashOffsets(path) {
|
|
157
|
+
getDashOffsets(this: Layer<PathStyleExtensionProps>, path: number[] | number[][]): number[] {
|
|
104
158
|
const result = [0];
|
|
105
159
|
const positionSize = this.props.positionFormat === 'XY' ? 2 : 3;
|
|
106
160
|
const isNested = Array.isArray(path[0]);
|
|
@@ -121,6 +175,3 @@ export default class PathStyleExtension extends LayerExtension {
|
|
|
121
175
|
return result;
|
|
122
176
|
}
|
|
123
177
|
}
|
|
124
|
-
|
|
125
|
-
PathStyleExtension.extensionName = 'PathStyleExtension';
|
|
126
|
-
PathStyleExtension.defaultProps = defaultProps;
|
|
File without changes
|
|
@@ -1,19 +1,40 @@
|
|
|
1
|
-
declare class BrushingExtension extends LayerExtension {
|
|
2
|
-
useConstantTargetPositions(attribute: any): void;
|
|
3
|
-
}
|
|
4
|
-
declare namespace BrushingExtension {
|
|
5
|
-
export const extensionName: string;
|
|
6
|
-
export { defaultProps };
|
|
7
|
-
}
|
|
8
|
-
export default BrushingExtension;
|
|
9
1
|
import { LayerExtension } from '@deck.gl/core/typed';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import type { Layer, LayerContext, Accessor } from '@deck.gl/core/typed';
|
|
3
|
+
export declare type BrushingExtensionProps<DataT = any> = {
|
|
4
|
+
/**
|
|
5
|
+
* Called to retrieve an arbitrary position for each object that it will be filtered by.
|
|
6
|
+
* Only effective if `brushingTarget` is set to `custom`.
|
|
7
|
+
*/
|
|
8
|
+
getBrushingTarget?: Accessor<DataT, [number, number]>;
|
|
9
|
+
/**
|
|
10
|
+
* Enable/disable brushing. If brushing is disabled, all objects are rendered.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
brushingEnabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The position used to filter each object by.
|
|
16
|
+
*/
|
|
17
|
+
brushingTarget?: 'source' | 'target' | 'source_target' | 'custom';
|
|
18
|
+
/** The brushing radius centered at the pointer, in meters. If a data object is within this circle, it is rendered; otherwise it is hidden.
|
|
19
|
+
* @default 10000
|
|
20
|
+
*/
|
|
21
|
+
brushingRadius?: number;
|
|
22
|
+
};
|
|
23
|
+
/** Adds GPU-based data brushing functionalities to layers. It allows the layer to show/hide objects based on the current pointer position. */
|
|
24
|
+
export default class BrushingExtension extends LayerExtension {
|
|
25
|
+
static defaultProps: {
|
|
26
|
+
getBrushingTarget: {
|
|
27
|
+
type: string;
|
|
28
|
+
value: number[];
|
|
29
|
+
};
|
|
30
|
+
brushingTarget: string;
|
|
31
|
+
brushingEnabled: boolean;
|
|
32
|
+
brushingRadius: number;
|
|
33
|
+
};
|
|
34
|
+
static extensionName: string;
|
|
35
|
+
getShaders(): any;
|
|
36
|
+
initializeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this): void;
|
|
37
|
+
finalizeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this): void;
|
|
38
|
+
useConstantTargetPositions(attribute: any): void;
|
|
18
39
|
}
|
|
19
40
|
//# sourceMappingURL=brushing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brushing.d.ts","sourceRoot":"","sources":["../../src/brushing/brushing.
|
|
1
|
+
{"version":3,"file":"brushing.d.ts","sourceRoot":"","sources":["../../src/brushing/brushing.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAUjE,oBAAY,sBAAsB,CAAC,KAAK,GAAG,GAAG,IAAI;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,eAAe,GAAG,QAAQ,CAAC;IAClE;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,8IAA8I;AAC9I,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,cAAc;IAC3D,MAAM,CAAC,YAAY;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAuB;IAE3C,UAAU,IAAI,GAAG;IAMjB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IAsC3F,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IAWzF,0BAA0B,CAAC,SAAS,KAAA;CAKrC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
21
|
+
import shaderModule from './shader-module';
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
getBrushingTarget: { type: 'accessor', value: [0, 0] },
|
|
24
|
+
brushingTarget: 'source',
|
|
25
|
+
brushingEnabled: true,
|
|
26
|
+
brushingRadius: 10000
|
|
27
|
+
};
|
|
28
|
+
export default class BrushingExtension extends LayerExtension {
|
|
29
|
+
getShaders(extension) {
|
|
30
|
+
return {
|
|
31
|
+
modules: [shaderModule]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
initializeState(context, extension) {
|
|
35
|
+
const attributeManager = this.getAttributeManager();
|
|
36
|
+
if (attributeManager) {
|
|
37
|
+
attributeManager.add({
|
|
38
|
+
brushingTargets: {
|
|
39
|
+
size: 2,
|
|
40
|
+
accessor: 'getBrushingTarget',
|
|
41
|
+
// Hack: extension's defaultProps is not merged with the layer's defaultProps,
|
|
42
|
+
// So we can't use the standard accessor when the prop is undefined
|
|
43
|
+
update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,
|
|
44
|
+
shaderAttributes: {
|
|
45
|
+
brushingTargets: {
|
|
46
|
+
divisor: 0
|
|
47
|
+
},
|
|
48
|
+
instanceBrushingTargets: {
|
|
49
|
+
divisor: 1
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Trigger redraw when mouse moves
|
|
56
|
+
// TODO - expose this in a better way
|
|
57
|
+
extension.onMouseMove = () => {
|
|
58
|
+
this.getCurrentLayer().setNeedsRedraw();
|
|
59
|
+
};
|
|
60
|
+
if (this.context.deck) {
|
|
61
|
+
this.context.deck.eventManager.on({
|
|
62
|
+
pointermove: extension.onMouseMove,
|
|
63
|
+
pointerleave: extension.onMouseMove
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
finalizeState(extension) {
|
|
68
|
+
// Remove event listeners
|
|
69
|
+
if (this.context.deck) {
|
|
70
|
+
this.context.deck.eventManager.off({
|
|
71
|
+
pointermove: extension.onMouseMove,
|
|
72
|
+
pointerleave: extension.onMouseMove
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
useConstantTargetPositions(attribute) {
|
|
77
|
+
attribute.constant = true;
|
|
78
|
+
attribute.value = new Float32Array(2);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
BrushingExtension.extensionName = 'BrushingExtension';
|
|
83
|
+
BrushingExtension.defaultProps = defaultProps;
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
brushing_enabled?: undefined;
|
|
9
|
-
brushing_radius?: undefined;
|
|
10
|
-
brushing_target?: undefined;
|
|
11
|
-
brushing_mousePos?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
brushing_enabled: boolean;
|
|
14
|
-
brushing_radius: any;
|
|
15
|
-
brushing_target: any;
|
|
16
|
-
brushing_mousePos: any;
|
|
1
|
+
import type { Viewport, _ShaderModule as ShaderModule } from '@deck.gl/core/typed';
|
|
2
|
+
import type { BrushingExtensionProps } from './brushing';
|
|
3
|
+
declare type BrushingModuleSettings = {
|
|
4
|
+
viewport: Viewport;
|
|
5
|
+
mousePosition?: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
17
8
|
};
|
|
18
|
-
}
|
|
9
|
+
} & BrushingExtensionProps;
|
|
10
|
+
declare const _default: ShaderModule<BrushingModuleSettings>;
|
|
19
11
|
export default _default;
|
|
20
|
-
import { project } from '@deck.gl/core/typed';
|
|
21
|
-
declare const 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 attribute vec2 brushingTargets;\n #else\n attribute vec2 instanceBrushingTargets;\n #endif\n\n varying 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";
|
|
22
|
-
declare const fs: "\n uniform bool brushing_enabled;\n varying float brushing_isVisible;\n";
|
|
23
|
-
declare const inject: {
|
|
24
|
-
'vs:DECKGL_FILTER_GL_POSITION': string;
|
|
25
|
-
'fs:DECKGL_FILTER_COLOR': string;
|
|
26
|
-
};
|
|
27
12
|
//# sourceMappingURL=shader-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/brushing/shader-module.
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/brushing/shader-module.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAC,QAAQ,EAAE,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAE3E,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAEvD,aAAK,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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright (c) 2015-2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import { project } from '@deck.gl/core';
|
|
21
|
+
const vs = `
|
|
22
|
+
uniform bool brushing_enabled;
|
|
23
|
+
uniform int brushing_target;
|
|
24
|
+
uniform vec2 brushing_mousePos;
|
|
25
|
+
uniform float brushing_radius;
|
|
26
|
+
|
|
27
|
+
#ifdef NON_INSTANCED_MODEL
|
|
28
|
+
attribute vec2 brushingTargets;
|
|
29
|
+
#else
|
|
30
|
+
attribute vec2 instanceBrushingTargets;
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
varying float brushing_isVisible;
|
|
34
|
+
|
|
35
|
+
bool brushing_isPointInRange(vec2 position) {
|
|
36
|
+
if (!brushing_enabled) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
vec2 source_commonspace = project_position(position);
|
|
40
|
+
vec2 target_commonspace = project_position(brushing_mousePos);
|
|
41
|
+
float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
|
|
42
|
+
|
|
43
|
+
return distance <= brushing_radius;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
|
|
47
|
+
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void brushing_setVisible(bool visible) {
|
|
51
|
+
brushing_isVisible = float(visible);
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const fs = `
|
|
55
|
+
uniform bool brushing_enabled;
|
|
56
|
+
varying float brushing_isVisible;
|
|
57
|
+
`;
|
|
58
|
+
const TARGET = {
|
|
59
|
+
source: 0,
|
|
60
|
+
target: 1,
|
|
61
|
+
custom: 2,
|
|
62
|
+
source_target: 3
|
|
63
|
+
};
|
|
64
|
+
const inject = {
|
|
65
|
+
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
66
|
+
vec2 brushingTarget;
|
|
67
|
+
vec2 brushingSource;
|
|
68
|
+
if (brushing_target == 3) {
|
|
69
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
70
|
+
brushingSource = geometry.worldPosition.xy;
|
|
71
|
+
} else if (brushing_target == 0) {
|
|
72
|
+
brushingTarget = geometry.worldPosition.xy;
|
|
73
|
+
} else if (brushing_target == 1) {
|
|
74
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
75
|
+
} else {
|
|
76
|
+
#ifdef NON_INSTANCED_MODEL
|
|
77
|
+
brushingTarget = brushingTargets;
|
|
78
|
+
#else
|
|
79
|
+
brushingTarget = instanceBrushingTargets;
|
|
80
|
+
#endif
|
|
81
|
+
}
|
|
82
|
+
bool visible;
|
|
83
|
+
if (brushing_target == 3) {
|
|
84
|
+
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
|
|
85
|
+
} else {
|
|
86
|
+
visible = brushing_isPointInRange(brushingTarget);
|
|
87
|
+
}
|
|
88
|
+
brushing_setVisible(visible);
|
|
89
|
+
`,
|
|
90
|
+
'fs:DECKGL_FILTER_COLOR': `
|
|
91
|
+
if (brushing_enabled && brushing_isVisible < 0.5) {
|
|
92
|
+
discard;
|
|
93
|
+
}
|
|
94
|
+
`
|
|
95
|
+
};
|
|
96
|
+
export default {
|
|
97
|
+
name: 'brushing',
|
|
98
|
+
dependencies: [project],
|
|
99
|
+
vs,
|
|
100
|
+
fs,
|
|
101
|
+
inject,
|
|
102
|
+
getUniforms: opts => {
|
|
103
|
+
if (!opts || !opts.viewport) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
const { brushingEnabled = true, brushingRadius = 10000, brushingTarget = 'source', mousePosition, viewport } = opts;
|
|
107
|
+
return {
|
|
108
|
+
brushing_enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
|
|
109
|
+
brushing_radius: brushingRadius,
|
|
110
|
+
brushing_target: TARGET[brushingTarget] || 0,
|
|
111
|
+
brushing_mousePos: mousePosition
|
|
112
|
+
? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])
|
|
113
|
+
: [0, 0]
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
package/typed/clip/clip.d.ts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
}
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { LayerExtension, _ShaderModule as ShaderModule } from '@deck.gl/core/typed';
|
|
2
|
+
import type { Layer } from '@deck.gl/core/typed';
|
|
3
|
+
export declare type ClipExtensionProps = {
|
|
4
|
+
/** Rectangular bounds to be used for clipping the rendered region, in `[left, bottom, right, top]`.
|
|
5
|
+
* @default [0, 0, 1, 1]
|
|
6
|
+
*/
|
|
7
|
+
clipBounds?: [number, number, number, number];
|
|
8
|
+
/**
|
|
9
|
+
* Controls whether an object is clipped by its anchor (e.g. icon, point) or by its geometry (e.g. path, polygon).
|
|
10
|
+
* If not specified, it is automatically deduced from the layer.
|
|
11
|
+
*/
|
|
12
|
+
clipByInstance?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Adds support for clipping rendered layers by rectangular bounds. */
|
|
15
|
+
export default class ClipExtension extends LayerExtension {
|
|
16
|
+
static defaultProps: any;
|
|
17
|
+
static extensionName: string;
|
|
18
|
+
getShaders(this: Layer<ClipExtensionProps>): {
|
|
19
|
+
modules: ShaderModule<any>[];
|
|
20
|
+
inject: {
|
|
21
|
+
'vs:#decl': string;
|
|
22
|
+
'vs:DECKGL_FILTER_GL_POSITION': string;
|
|
23
|
+
'fs:#decl': string;
|
|
24
|
+
'fs:DECKGL_FILTER_COLOR': string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
draw(this: Layer<ClipExtensionProps>, { uniforms }: any): void;
|
|
11
28
|
}
|
|
12
29
|
//# sourceMappingURL=clip.d.ts.map
|
package/typed/clip/clip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../src/clip/clip.
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../src/clip/clip.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,cAAc,EAAE,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAMzC,oBAAY,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,EAAE,GAAG,CAAgB;IACxC,MAAM,CAAC,aAAa,SAAmB;IAEvC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC;;;;;;;;;IAyB1C,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,EAAC,QAAQ,EAAC,EAAE,GAAG,GAAG,IAAI;CAgB7D"}
|