import React from "react"; import { useStore } from "../store/store.ts"; import { ControlSlider } from "./ControlSlider.tsx"; export const ModelControls: React.FC = () => { const selectedModelId = useStore((state) => state.selectedModelId); const models = useStore((state) => state.models); const updateModel = useStore((state) => state.updateModel); const removeModel = useStore((state) => state.removeModel); const selectModel = useStore((state) => state.selectModel); const selectedModel = models.find((model) => model.id === selectedModelId); if (!selectedModel) { return null; } const handlePositionChange = (axis: "x" | "y" | "z", value: string) => { const numericValue = parseFloat(value) || 0; updateModel(selectedModel.id, { position: { ...selectedModel.position, [axis]: numericValue, }, }); }; const handleRotationChange = (axis: "x" | "y" | "z", value: string) => { const numericValue = parseFloat(value) || 0; updateModel(selectedModel.id, { rotation: { ...selectedModel.rotation, [axis]: numericValue, }, }); }; const handleHueShiftChange = ( color: "red" | "green" | "blue", value: string, ) => { const numericValue = parseFloat(value) || 0; updateModel(selectedModel.id, { hueShift: { ...selectedModel.hueShift, [color]: numericValue, }, }); }; const handleDelete = () => { removeModel(selectedModel.id); selectModel(null); }; return (

{selectedModel.name}

Position

handlePositionChange("x", value)} /> handlePositionChange("y", value)} /> handlePositionChange("z", value)} />

Rotation

handleRotationChange("x", value)} /> handleRotationChange("y", value)} /> handleRotationChange("z", value)} />

Hue Shift

handleHueShiftChange("red", value)} /> handleHueShiftChange("green", value)} /> handleHueShiftChange("blue", value)} />
); };