add 2d selection and delete
This commit is contained in:
@@ -276,4 +276,40 @@ export const useComparisonProduct = create<ComparisonProductState>()(
|
||||
});
|
||||
},
|
||||
}))
|
||||
);
|
||||
|
||||
interface SelectedPointsState {
|
||||
selectedPoints: THREE.Object3D[];
|
||||
setSelectedPoints: (points: THREE.Object3D[]) => void;
|
||||
addSelectedPoint: (point: THREE.Object3D) => void;
|
||||
removeSelectedPoint: (uuid: string) => void;
|
||||
clearSelectedPoints: () => void;
|
||||
}
|
||||
|
||||
export const useSelectedPoints = create<SelectedPointsState>()(
|
||||
immer((set) => ({
|
||||
selectedPoints: [],
|
||||
setSelectedPoints: (points) => {
|
||||
set((state) => {
|
||||
state.selectedPoints = points;
|
||||
});
|
||||
},
|
||||
addSelectedPoint: (point) => {
|
||||
set((state) => {
|
||||
if (!state.selectedPoints.find(p => p.uuid === point.uuid)) {
|
||||
state.selectedPoints.push(point);
|
||||
}
|
||||
});
|
||||
},
|
||||
removeSelectedPoint: (uuid) => {
|
||||
set((state) => {
|
||||
state.selectedPoints = state.selectedPoints.filter(p => p.uuid !== uuid);
|
||||
});
|
||||
},
|
||||
clearSelectedPoints: () => {
|
||||
set((state) => {
|
||||
state.selectedPoints = [];
|
||||
});
|
||||
},
|
||||
}))
|
||||
);
|
||||
Reference in New Issue
Block a user