feat: implement snapshot capture and storage for robot configurations
CI/CD / test-and-build (push) Has been cancelled
CI/CD / deploy (push) Has been cancelled

This commit is contained in:
Najjar\NajjarV02
2026-04-13 18:00:12 +04:00
parent 05b540997e
commit dc42aeb72a
5 changed files with 142 additions and 20 deletions
+12
View File
@@ -11,6 +11,7 @@ import {
} from '@react-three/drei';
import { useThree } from '@react-three/fiber';
import { RobotModel } from './RobotModel';
import { snapshotStore } from '@/store/useSnapshotStore';
import type { WebGLRenderer, Scene, Camera } from 'three';
function Loader() {
@@ -70,6 +71,17 @@ export function RobotCanvas() {
glRef.current = gl;
sceneRef.current = scene;
cameraRef.current = camera;
// Register a programmatic capture function for the checkout snapshot
snapshotStore.getState().registerCapture(() => {
if (!glRef.current || !sceneRef.current || !cameraRef.current) return null;
try {
glRef.current.render(sceneRef.current, cameraRef.current);
return glRef.current.domElement.toDataURL('image/jpeg', 0.75);
} catch {
return null;
}
});
}, []);
const handleShare = useCallback(async () => {