import { useRef } from "react"; import { useFrame, useThree } from "@react-three/fiber"; import { QuadraticBezierLine, Plane } from "@react-three/drei"; import { InferenceResult } from "../types"; import HeightMapImage from "./HeightMapImage"; import ImagePlane from "./ImagePlane"; interface SpectrogramViewerProps { paused: boolean; inferenceResults: InferenceResult[]; getTime: () => number; use_height_map?: boolean; audioLength: number; } /** * Spectrogram drawing code. */ export default function SpectrogramViewer({ paused, inferenceResults, getTime, audioLength, use_height_map = true, }: SpectrogramViewerProps) { const camera = useThree((state) => state.camera); const playheadRef = useRef(null); // Move the camera based on the clock useFrame(() => { const time = getTime(); const velocity = -1.0; // [m/s] const position = velocity * time; // [m] camera.position.y = position; playheadRef.current.position.y = camera.position.y; }); return ( {inferenceResults.map((value: InferenceResult, index: number) => { const height = audioLength * (-0.48 - value.counter); if (use_height_map) { return ( ); } else { return ; } })} {/* TODO make into playhead component */} {/* */} ); }