import React, { useRef } from 'react'; import { useStudioStore } from '../store/useStudioStore'; import './RightPanel.css'; const SliderRow: React.FC<{ label: string; value: number; min: number; max: number; step?: number; onChange: (v: number) => void; }> = ({ label, value, min, max, step = 0.01, onChange }) => (
onChange(parseFloat(e.target.value))} /> {value.toFixed(2)}
); const Vec3Row: React.FC<{ label: string; value: [number, number, number]; step?: number; onChange: (v: [number, number, number]) => void; }> = ({ label, value, step = 0.1, onChange }) => (
{(['X', 'Y', 'Z'] as const).map((axis, i) => (
{axis} { const v: [number, number, number] = [...value] as any; v[i] = parseFloat(e.target.value) || 0; onChange(v); }} />
))}
); const RightPanel: React.FC = () => { const { mode, objects, selectedId, updateObject, ambientIntensity, directionalIntensity, bgColor, showGrid, showAxes, bloomIntensity, postProcessing, skyboxType, skyboxUrl, setAmbientIntensity, setDirectionalIntensity, setBgColor, setShowGrid, setShowAxes, setBloomIntensity, setPostProcessing, setSkybox, } = useStudioStore(); const skyFileRef = useRef(null); const texFileRef = useRef(null); const selectedObj = objects.find(o => o.id === selectedId); const update = (patch: any) => { if (selectedId) updateObject(selectedId, patch); }; return (
{/* Object Properties */} {selectedObj && (
{selectedObj.name}
update({ position: v })} /> update({ rotation: v })} /> update({ scale: v })} />
update({ color: e.target.value })} className="color-input" /> {selectedObj.color}
update({ metalness: v })} /> update({ roughness: v })} /> update({ envMapIntensity: v })} />
{selectedObj.textureUrl && ( )} { const file = e.target.files?.[0]; if (file) update({ textureUrl: URL.createObjectURL(file) }); }} />
)} {/* Scene / Rendering */}
LIGHTING & SCENE
setBgColor(e.target.value)} className="color-input" />
{postProcessing && ( )}
{/* Skybox */}
SKYBOX
{(['none', 'gradient', 'uploaded'] as const).map((t) => ( ))}
{skyboxType === 'uploaded' && ( )} { const file = e.target.files?.[0]; if (file) setSkybox('uploaded', URL.createObjectURL(file)); }} />
{/* Animation panel */} {selectedObj && selectedObj.animations.length > 0 && mode === 'animate' && (
ANIMATION
{selectedObj.animations.map((anim, i) => (
update({ selectedAnimIndex: i })} > {anim.name} {anim.duration.toFixed(1)}s
))}
update({ animSpeed: v })} />
)}
); }; export default RightPanel;