import * as THREE from 'three';
import { useMemo } from "react";
import * as Constants from '../../../../types/world/worldConstants';
import { Tube } from '@react-three/drei';

interface ReferenceLineProps {
    points: [Point, Point];
}

function ReferenceLine({ points }: Readonly<ReferenceLineProps>) {
    const path = useMemo(() => {
        const [start, end] = points.map(p => new THREE.Vector3(...p.position));
        return new THREE.LineCurve3(start, end);
    }, [points]);

    return (
        <Tube
            args={[path, Constants.lineConfig.tubularSegments, Constants.lineConfig.radius, Constants.lineConfig.radialSegments, false]}
        >
            <meshStandardMaterial color={Constants.lineConfig.helperColor} />
        </Tube>
    );
}

export default ReferenceLine;