import type { CSSProperties } from "react"; import * as THREE from "three"; import { measureKeyForHandle, type TransformOverlayProps, type TransformOverlayState, } from "@/components/workplane/transformOverlayTypes"; export { getElevationMeasureKey, measureKeyForHandle, type DimensionMark, type EditingDimension, type EditingRotation, type PinnedRotationWheelView, type RotationAxis, type RotationPlaneView, type RotationReadout, type RotationWheelView, type TransformHandleKind, type TransformOverlayState, } from "@/components/workplane/transformOverlayTypes"; export function TransformOverlay({ box, measureKey, editingDimension, editingRotation, rotationReadout, showRotationWheel, hideSelectionChrome, hideDimensionMarks, rotationWheelAxis, pinnedRotationWheelView, onBeginTransform, onMoveTransform, onFinishTransform, onHoverMeasure, onPinMeasure, onBeginDimensionEdit, onBeginLiftEdit, onEditingDimensionChange, onCommitDimensionEdit, onCancelDimensionEdit, onBeginRotationEdit, onEditingRotationChange, onCommitRotationEdit, onCancelRotationEdit, }: TransformOverlayProps) { const marks = measureKey ? (box.dimensions[measureKey] ?? []) : []; const visibleMarks = (hideDimensionMarks ? [] : marks).filter((mark) => mark.key !== editingDimension?.key); const handleMeasureKey = (handle: TransformOverlayState["handles"][number]) => measureKeyForHandle(handle.kind, handle.key, box); const protractorTicks = Array.from({ length: 16 }, (_, index) => { const degrees = index * 22.5 - 90; const radians = THREE.MathUtils.degToRad(degrees); const major = index % 2 === 0; const outer = 94; const inner = major ? 80 : 86; return { key: `tick-${index}`, major, x1: Math.cos(radians) * inner, y1: Math.sin(radians) * inner, x2: Math.cos(radians) * outer, y2: Math.sin(radians) * outer, }; }); const activeAngle = rotationReadout?.angle ?? 0; const activeRadians = THREE.MathUtils.degToRad(activeAngle - 90); const activeLine = { x: Math.cos(activeRadians) * 92, y: Math.sin(activeRadians) * 92, }; const pinnedWheel = pinnedRotationWheelView?.axis === rotationWheelAxis ? pinnedRotationWheelView : null; const plane = pinnedWheel?.plane ?? box.rotationPlanes[rotationWheelAxis]; const wheel = pinnedWheel?.wheel ?? box.rotationWheels[rotationWheelAxis] ?? box.rotationWheel; return ( ); }