diff --git a/docs/api-reference/extensions/brushing-extension.md b/docs/api-reference/extensions/brushing-extension.md index c992b2f6936..416d8e0bfad 100644 --- a/docs/api-reference/extensions/brushing-extension.md +++ b/docs/api-reference/extensions/brushing-extension.md @@ -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 range. - `'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. diff --git a/modules/extensions/src/brushing/shader-module.js b/modules/extensions/src/brushing/shader-module.js index 15f1b19fb6c..037c79e32e2 100644 --- a/modules/extensions/src/brushing/shader-module.js +++ b/modules/extensions/src/brushing/shader-module.js @@ -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); } @@ -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; @@ -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': `