Skip to content

Commit

Permalink
update filename with the current workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Salam-Dalloul committed Oct 2, 2024
1 parent d551e27 commit 605c595
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import ZoomOutIcon from "@mui/icons-material/ZoomOut";
import { Box, Divider, IconButton, Popover, Typography } from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import { useRef, useState } from "react";
import { useSelectedWorkspace } from "../../../hooks/useSelectedWorkspace.ts";
import { vars } from "../../../theme/variables.ts";
import CustomFormControlLabel from "./CustomFormControlLabel.tsx";
import { Recorder } from "./Recorder.ts";

const { gray500 } = vars;

function SceneControls({ cameraControlRef, isWireframe, setIsWireframe, recorderRef, handleScreenshot }) {
const workspace = useSelectedWorkspace();
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
const rotateAnimationRef = useRef<number | null>(null);
const [isRotating, setIsRotating] = useState(false);
Expand Down Expand Up @@ -69,7 +71,7 @@ function SceneControls({ cameraControlRef, isWireframe, setIsWireframe, recorder
const stopRecording = async () => {
if (recorderRef.current) {
recorderRef.current.stopRecording({ type: "video/webm" });
recorderRef.current.download("CanvasRecording.webm", { type: "video/webm" });
recorderRef.current.download(workspace.name + ".webm", { type: "video/webm" });
recorderRef.current = null;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function downloadScreenshot(
canvasRef: React.RefObject<HTMLCanvasElement>,
sceneRef: React.RefObject<THREE.Scene>,
cameraRef: React.RefObject<THREE.PerspectiveCamera>,
filename?: string,
) {
if (!sceneRef.current || !cameraRef.current || !canvasRef.current) return;

Expand All @@ -50,7 +51,7 @@ export function downloadScreenshot(
if (blob) {
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "screenshot.png";
link.download = filename || "screenshot.png";
link.click();
URL.revokeObjectURL(link.href);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ThreeDViewer() {
}, [selectedDataset, workspace.availableNeurons, workspace.visibilities]);

const handleScreenshot = () => {
downloadScreenshot(canvasRef, sceneRef, cameraRef);
downloadScreenshot(canvasRef, sceneRef, cameraRef, workspace.name);
};

const onCreated = (state) => {
Expand Down

0 comments on commit 605c595

Please sign in to comment.