Spaces:
Sleeping
Sleeping
File size: 934 Bytes
a6e23da 7f7b2cc aa1b508 ec43676 a6e23da ec43676 a6e23da ec43676 a6e23da ca23eb9 a6e23da 40a6d5e aa1b508 40a6d5e ec43676 a6e23da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import { CubePiece } from "./cube-piece";
import { FacingDirection } from "./consts";
import { Rotator } from "./rotator";
import { CubesProvider } from "@/contexts/cubes-context";
const CUBE_POSITIONS: Array<[number, number, number]> = [];
for (let x = -0.5; x <= 0.5; x += 1) {
for (let y = -0.5; y <= 0.5; y += 1) {
for (let z = -0.5; z <= 0.5; z += 1) {
CUBE_POSITIONS.push([x, y, z]);
}
}
}
type RubiksCubeProps = {
roughness: number;
};
export const RubiksCube = ({ roughness }: RubiksCubeProps) => {
return (
<CubesProvider>
{CUBE_POSITIONS.map((position) => (
<CubePiece
key={position.join(",")}
initialPosition={position}
roughness={roughness}
/>
))}
{["front", "back", "left", "right", "top", "bottom"].map((face) => (
<Rotator key={face} facingDirection={face as FacingDirection} />
))}
</CubesProvider>
);
};
|