import { useThree } from '@react-three/fiber'; import type { SVGProps } from 'react'; import type { Vector2 } from 'three'; import { useCameraState } from '../vis/hooks'; import Overlay from '../vis/shared/Overlay'; import { dataToHtml } from '../vis/utils'; interface Props extends SVGProps { startPoint: Vector2; endPoint: Vector2; } function SelectionRect(props: Props) { const { startPoint, endPoint, fill = 'red', fillOpacity = 0.5, ...restSvgProps } = props; const { width, height } = useThree((state) => state.size); const htmlSelection = useCameraState( (...args) => ({ startPoint: dataToHtml(...args, startPoint), endPoint: dataToHtml(...args, endPoint), }), [startPoint, endPoint] ); const { x: x1, y: y1 } = htmlSelection.startPoint; const { x: x2, y: y2 } = htmlSelection.endPoint; return ( ); } export default SelectionRect;