riffusion-app/components/ThreeCanvas.tsx

40 lines
855 B
TypeScript
Raw Permalink Normal View History

import { Canvas } from "@react-three/fiber";
import { InferenceResult } from "../types";
import SpectrogramViewer from "./SpectrogramViewer";
2022-11-26 12:26:19 -07:00
import { PerspectiveCamera } from "@react-three/drei";
2022-11-23 22:46:32 -07:00
interface CanvasProps {
paused: boolean;
inferenceResults: InferenceResult[];
getTime: () => number;
2022-11-23 22:46:32 -07:00
}
2022-11-20 14:39:15 -07:00
/**
* React three fiber canvas with spectrogram drawing.
*/
export default function ThreeCanvas({
paused,
inferenceResults,
getTime,
}: CanvasProps) {
return (
2022-11-26 12:26:19 -07:00
<Canvas>
2022-11-20 14:39:15 -07:00
<ambientLight intensity={2} />
<pointLight position={[40, 40, 40]} />
2022-11-26 12:26:19 -07:00
<PerspectiveCamera
makeDefault
position={[0, 0, 8]}
rotation={[0.4, 0, 0]}
fov={70}
/>
<SpectrogramViewer
paused={paused}
inferenceResults={inferenceResults}
getTime={getTime}
2022-11-23 22:46:32 -07:00
/>
2022-11-20 14:39:15 -07:00
</Canvas>
);
}