'use client'; import { Button, ButtonGroup } from '@heroui/button'; import { Card, CardBody } from '@heroui/card'; import { Checkbox } from '@heroui/checkbox'; import { Slider } from '@heroui/slider'; import { useRef, useState } from 'react'; import { useControlContext } from '@/contexts/control-context'; import { Actions } from './consts'; import { rotationController } from './rotation-controller'; import { StateModal, StateModalRef } from './state-modal'; export const UIControls = () => { const stateModalRef = useRef(null); const [isControlsOpen, setIsControlsOpen] = useState(true); const { rubiksCubeRef, showRotationIndicators, setShowRotationIndicators, setBackground, cubeRoughness, setCubeRoughness, cubeSpeed, setCubeSpeed, } = useControlContext(); const scramble = () => { const scrambleSteps = Array.from({ length: 20 }, () => Actions[Math.floor(Math.random() * Actions.length)]); rubiksCubeRef?.current?.rotate(scrambleSteps); }; const reset = () => { rubiksCubeRef?.current?.reset(); }; const showState = () => { const state = rotationController.getState(); stateModalRef.current?.open(state); }; const solve = () => { alert('Working on it!'); }; const train = () => { alert('Working on it!'); }; return (
Controls
Rotation Indicators
Background
setCubeRoughness(value as number)} minValue={0.2} maxValue={1} step={0.01} /> setCubeSpeed(value as number)} minValue={1} maxValue={10} step={1} />
Train your own model!
); };