feat: implement snapshot capture and storage for robot configurations
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user