import { useTrajectoryRecorder } from "mujoco-react";
function RecordButton() {
const recorder = useTrajectoryRecorder({
fields: ["qpos", "qvel", "ctrl"],
});
return (
<div>
{recorder.recording ? (
<button onClick={() => {
const frames = recorder.stop();
console.log(`Recorded ${frames.length} frames`);
}}>
Stop ({recorder.frameCount} frames)
</button>
) : (
<button onClick={recorder.start}>Record</button>
)}
<button onClick={recorder.downloadJSON}>Export JSON</button>
<button onClick={recorder.downloadCSV}>Export CSV</button>
</div>
);
}