'use client' import { type AnyNode, type GuideNode, type ScanNode, useScene } from '@pascal-app/core' import { Box, Image as ImageIcon } from 'lucide-react' import { useCallback } from 'react' import useEditor from '@/store/use-editor' import { PanelWrapper } from './panel-wrapper' import { PanelSection } from '../controls/panel-section' import { SliderControl } from '../controls/slider-control' import { MetricControl } from '../controls/metric-control' import { ActionButton, ActionGroup } from '../controls/action-button' type ReferenceNode = ScanNode | GuideNode export function ReferencePanel() { const selectedReferenceId = useEditor((s) => s.selectedReferenceId) const setSelectedReferenceId = useEditor((s) => s.setSelectedReferenceId) const nodes = useScene((s) => s.nodes) const updateNode = useScene((s) => s.updateNode) const node = selectedReferenceId ? (nodes[selectedReferenceId as AnyNode['id']] as ReferenceNode | undefined) : undefined const handleUpdate = useCallback( (updates: Partial) => { if (!selectedReferenceId) return updateNode(selectedReferenceId as AnyNode['id'], updates) }, [selectedReferenceId, updateNode], ) const handleClose = useCallback(() => { setSelectedReferenceId(null) }, [setSelectedReferenceId]) if (!node || (node.type !== 'scan' && node.type !== 'guide')) return null const isScan = node.type === 'scan' return ( Xpos} value={Math.round(node.position[0] * 100) / 100} onChange={(value) => { const pos = [...node.position] as [number, number, number] pos[0] = value handleUpdate({ position: pos }) }} min={-50} max={50} precision={2} step={0.1} unit="m" /> Ypos} value={Math.round(node.position[1] * 100) / 100} onChange={(value) => { const pos = [...node.position] as [number, number, number] pos[1] = value handleUpdate({ position: pos }) }} min={-50} max={50} precision={2} step={0.1} unit="m" /> Zpos} value={Math.round(node.position[2] * 100) / 100} onChange={(value) => { const pos = [...node.position] as [number, number, number] pos[2] = value handleUpdate({ position: pos }) }} min={-50} max={50} precision={2} step={0.1} unit="m" /> Yrot} value={Math.round((node.rotation[1] * 180) / Math.PI)} onChange={(degrees) => { const radians = (degrees * Math.PI) / 180 handleUpdate({ rotation: [node.rotation[0], radians, node.rotation[2]], }) }} min={-180} max={180} precision={0} step={1} unit="°" />
handleUpdate({ rotation: [node.rotation[0], node.rotation[1] - Math.PI / 4, node.rotation[2]] })} /> handleUpdate({ rotation: [node.rotation[0], node.rotation[1] + Math.PI / 4, node.rotation[2]] })} />
XYZscale} value={Math.round(node.scale * 100) / 100} onChange={(value) => { if (value > 0) { handleUpdate({ scale: value }) } }} min={0.01} max={10} precision={2} step={0.1} /> handleUpdate({ opacity: v })} min={0} max={100} precision={0} step={1} unit="%" />
) }