Skip to content

Commit

Permalink
fix(embeddings): lasso selects only visible points (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking authored Apr 5, 2023
1 parent 0fa2a9d commit dbb7f95
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/src/components/pointcloud/PointCloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ function Projection(props: ProjectionProps) {
(state) => state.pointGroupVisibility
);
const canvasTheme = usePointCloudContext((state) => state.canvasTheme);
const datasetVisibility = usePointCloudContext(
(state) => state.datasetVisibility
);

// AutoRotate the canvas on initial load
const [autoRotate, setAutoRotate] = useState<boolean>(true);
Expand Down Expand Up @@ -315,6 +318,21 @@ function Projection(props: ProjectionProps) {
});
}, [referenceData, eventIdToGroup, pointGroupVisibility]);

// Keep track of all the points in the view, minus the ones filtered out by visibility controls
const allVisiblePoints = useMemo(() => {
const visiblePrimaryPoints = datasetVisibility.primary
? filteredPrimaryData
: [];
const visibleReferencePoints = datasetVisibility.reference
? filteredReferenceData
: [];
const visiblePoints = [
...visiblePrimaryPoints,
...(visibleReferencePoints || []),
];
return visiblePoints;
}, [filteredPrimaryData, filteredReferenceData, datasetVisibility]);

// Context cannot be passed through multiple reconcilers. Bridge the context
const ContextBridge = useContextBridge(PointCloudContext);

Expand All @@ -337,7 +355,7 @@ function Projection(props: ProjectionProps) {
boundsZoomPaddingFactor={BOUNDS_3D_ZOOM_PADDING_FACTOR}
>
<LassoSelect
points={allPoints}
points={allVisiblePoints}
onChange={(selection) => {
setSelectedEventIds(
new Set(selection.map((s) => s.metaData.eventId))
Expand Down

0 comments on commit dbb7f95

Please sign in to comment.