Skip to content

Commit

Permalink
Merge 389d749 into 47548ee
Browse files Browse the repository at this point in the history
  • Loading branch information
heshan0131 committed Jan 14, 2020
2 parents 47548ee + 389d749 commit 4b9e688
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/api-reference/extensions/brushing-extension.md
Expand Up @@ -87,6 +87,7 @@ The position used to filter each object by. One of the following:

- `'source'`: Use the primary position for each object. This can mean different things depending on the layer. It usually refers to the coordinates returned by `getPosition` or `getSourcePosition` accessors.
- `'target'`: Use the secondary position for each object. This may not be available in some layers. It usually refers to the coordinates returned by `getTargetPosition` accessors.
- `'source_target'`: Use both the primary position and secondary position for each object. Show objet if either is in brushing rance.
- `'custom'`: Some layers may not describe their data objects with one or two coordinates, for example `PathLayer` and `PolygonLayer`. Use this option with the `getBrushingTarget` prop to provide a custom position that each object should be filtered by.


Expand Down
21 changes: 18 additions & 3 deletions modules/extensions/src/brushing/shader-module.js
Expand Up @@ -44,6 +44,10 @@ const vs = `
return distance <= brushing_radius;
}
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
}
void brushing_setVisible(bool visible) {
brushing_isVisible = float(visible);
}
Expand All @@ -57,13 +61,18 @@ const fs = `
const TARGET = {
source: 0,
target: 1,
custom: 2
custom: 2,
source_target: 3
};

const inject = {
'vs:DECKGL_FILTER_GL_POSITION': `
vec2 brushingTarget;
if (brushing_target == 0) {
vec2 brushingSource;
if (brushing_target == 3) {
brushingTarget = geometry.worldPositionAlt.xy;
brushingSource = geometry.worldPosition.xy;
} else if (brushing_target == 0) {
brushingTarget = geometry.worldPosition.xy;
} else if (brushing_target == 1) {
brushingTarget = geometry.worldPositionAlt.xy;
Expand All @@ -74,7 +83,13 @@ const inject = {
brushingTarget = instanceBrushingTargets;
#endif
}
brushing_setVisible(brushing_isPointInRange(brushingTarget));
bool visible;
if (brushing_target == 3) {
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
} else {
visible = brushing_isPointInRange(brushingTarget);
}
brushing_setVisible(visible);
`,

'fs:DECKGL_FILTER_COLOR': `
Expand Down

0 comments on commit 4b9e688

Please sign in to comment.