Spaces:
Sleeping
Sleeping
add rotator
Browse files- src/components/rotator.tsx +18 -0
- src/components/rubiks-cube.tsx +2 -10
src/components/rotator.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { FacingDirection } from "./consts";
|
| 2 |
+
import { RotationPanel } from "./rotation-panel";
|
| 3 |
+
|
| 4 |
+
type RotatorProps = {
|
| 5 |
+
facingDirection: FacingDirection;
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
export const Rotator = ({ facingDirection }: RotatorProps) => {
|
| 9 |
+
return (
|
| 10 |
+
<>
|
| 11 |
+
<RotationPanel direction="clockwise" facingDirection={facingDirection} />
|
| 12 |
+
<RotationPanel
|
| 13 |
+
direction="counter-clockwise"
|
| 14 |
+
facingDirection={facingDirection}
|
| 15 |
+
/>
|
| 16 |
+
</>
|
| 17 |
+
);
|
| 18 |
+
};
|
src/components/rubiks-cube.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { Fragment } from "react";
|
|
| 2 |
import { CubePiece } from "./cube-piece";
|
| 3 |
import { RotationPanel } from "./rotation-panel";
|
| 4 |
import { FacingDirection } from "./consts";
|
|
|
|
| 5 |
|
| 6 |
const CUBE_POSITIONS: Array<[number, number, number]> = [];
|
| 7 |
for (let x = -0.5; x <= 0.5; x++) {
|
|
@@ -27,16 +28,7 @@ export const RubiksCube = ({ roughness }: RubiksCubeProps) => {
|
|
| 27 |
/>
|
| 28 |
))}
|
| 29 |
{["front", "back", "left", "right", "top", "bottom"].map((face) => (
|
| 30 |
-
<
|
| 31 |
-
<RotationPanel
|
| 32 |
-
direction="clockwise"
|
| 33 |
-
facingDirection={face as FacingDirection}
|
| 34 |
-
/>
|
| 35 |
-
<RotationPanel
|
| 36 |
-
direction="counter-clockwise"
|
| 37 |
-
facingDirection={face as FacingDirection}
|
| 38 |
-
/>
|
| 39 |
-
</Fragment>
|
| 40 |
))}
|
| 41 |
</group>
|
| 42 |
);
|
|
|
|
| 2 |
import { CubePiece } from "./cube-piece";
|
| 3 |
import { RotationPanel } from "./rotation-panel";
|
| 4 |
import { FacingDirection } from "./consts";
|
| 5 |
+
import { Rotator } from "./rotator";
|
| 6 |
|
| 7 |
const CUBE_POSITIONS: Array<[number, number, number]> = [];
|
| 8 |
for (let x = -0.5; x <= 0.5; x++) {
|
|
|
|
| 28 |
/>
|
| 29 |
))}
|
| 30 |
{["front", "back", "left", "right", "top", "bottom"].map((face) => (
|
| 31 |
+
<Rotator key={face} facingDirection={face as FacingDirection} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
))}
|
| 33 |
</group>
|
| 34 |
);
|