import { useMemo } from 'react'; import { useDockIr } from '../hooks/useDockIr.js'; const SVG_W = 120; const SVG_H = 110; const CX = SVG_W / 2; const DOCK_Y = 16; const ROVER_Y = 86; function lobePath(side = 'left') { if (side === 'left') { return `M ${CX} ${DOCK_Y} C ${CX - 12} ${DOCK_Y + 8} ${CX - 14} ${ROVER_Y - 16} ${CX - 4} ${ROVER_Y - 2} L ${CX} ${ROVER_Y - 4} Z`; } return `M ${CX} ${DOCK_Y} C ${CX + 12} ${DOCK_Y + 8} ${CX + 14} ${ROVER_Y - 16} ${CX + 4} ${ROVER_Y - 2} L ${CX} ${ROVER_Y - 4} Z`; } export default function DockAssistHUD({ sensors }) { const state = useDockIr(sensors); const palette = useMemo( () => ({ green: ['rgba(16,185,129,0.6)', 'rgba(16,185,129,0.45)', 'rgba(16,185,129,0)'], red: ['rgba(239,68,68,0.6)', 'rgba(239,68,68,0.45)', 'rgba(239,68,68,0)'], forceOutline: 'rgba(191,219,254,0.85)', roverBody: '#0f172a', roverFill: '#e5e7eb', }), [], ); if (!state.visible) return null; const nudge = state.balance * 6; const leftActive = state.left.red || state.left.green || state.left.force; const rightActive = state.right.red || state.right.green || state.right.force; const allAligned = state.left.red && state.left.green && state.right.red && state.right.green && state.forceDetected; return (
{/* Force field halo */} {/* Lobes */} {leftActive && rightActive ? ( ) : null} {/* Dock icon: simple rounded square with symmetric top corners */} {/* Force field emitter dot */} {/* Contacts */} {/* Rover cue */} {/* Nudge arrow */} {state.bias !== 'center' && ( )} {/* Thumbs up when fully aligned */} {allAligned ? ( 👍 ) : null}
); }