import { useRef } from "react"; import { useFrame, useThree } from "@react-three/fiber"; import { QuadraticBezierLine } from "@react-three/drei"; import { InferenceResult } from "../types"; import HeightMapImage from "./HeightMapImage"; import ImagePlane from "./ImagePlane"; interface SpectrogramViewerProps { paused: boolean; inferenceResults: InferenceResult[]; use_height_map?: boolean; } /** * Spectrogram drawing code. */ export default function SpectrogramViewer({ paused, inferenceResults, use_height_map = true, }: SpectrogramViewerProps) { const camera = useThree((state) => state.camera); const playheadRef = useRef(null); // Move the camera and playhead every frame. useFrame(() => { if (paused) { return; } const framerate = 120.0; camera.position.y -= 1 / framerate; playheadRef.current.position.y -= 1 / framerate; }); return ( {inferenceResults.map((value: InferenceResult, index: number) => { const height = 5 * (-1 - value.counter) - 2; if (use_height_map) { return ( ); } else { return ; } })} {/* TODO make into playhead component */} ); }