Spaces:
Sleeping
Sleeping
add top bottom
Browse files
src/components/rotation-panel.tsx
CHANGED
|
@@ -16,12 +16,16 @@ export const RotationPanel = ({ direction, face }: RotationPanelProps) => {
|
|
| 16 |
back: clockwise ? [-0.5, 0, -1.01] : [0.5, 0, -1.01],
|
| 17 |
left: clockwise ? [-1.01, 0, 0.5] : [-1.01, 0, -0.5],
|
| 18 |
right: clockwise ? [1.01, 0, -0.5] : [1.01, 0, 0.5],
|
|
|
|
|
|
|
| 19 |
};
|
| 20 |
const rotation: Record<string, [number, number, number]> = {
|
| 21 |
front: [0, 0, 0],
|
| 22 |
back: [0, Math.PI, 0],
|
| 23 |
left: [0, -Math.PI / 2, 0],
|
| 24 |
right: [0, Math.PI / 2, 0],
|
|
|
|
|
|
|
| 25 |
};
|
| 26 |
return (
|
| 27 |
<mesh position={position[face]} rotation={rotation[face]}>
|
|
|
|
| 16 |
back: clockwise ? [-0.5, 0, -1.01] : [0.5, 0, -1.01],
|
| 17 |
left: clockwise ? [-1.01, 0, 0.5] : [-1.01, 0, -0.5],
|
| 18 |
right: clockwise ? [1.01, 0, -0.5] : [1.01, 0, 0.5],
|
| 19 |
+
top: clockwise ? [0.5, 1.01, 0] : [-0.5, 1.01, 0],
|
| 20 |
+
bottom: clockwise ? [0.5, -1.01, 0] : [-0.5, -1.01, 0],
|
| 21 |
};
|
| 22 |
const rotation: Record<string, [number, number, number]> = {
|
| 23 |
front: [0, 0, 0],
|
| 24 |
back: [0, Math.PI, 0],
|
| 25 |
left: [0, -Math.PI / 2, 0],
|
| 26 |
right: [0, Math.PI / 2, 0],
|
| 27 |
+
top: [-Math.PI / 2, 0, 0],
|
| 28 |
+
bottom: [Math.PI / 2, 0, 0],
|
| 29 |
};
|
| 30 |
return (
|
| 31 |
<mesh position={position[face]} rotation={rotation[face]}>
|
src/components/rubiks-cube.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import { CubePiece } from "./cube-piece";
|
| 2 |
import { RotationPanel } from "./rotation-panel";
|
| 3 |
|
|
@@ -24,14 +25,22 @@ export const RubiksCube = ({ roughness }: RubiksCubeProps) => {
|
|
| 24 |
roughness={roughness}
|
| 25 |
/>
|
| 26 |
))}
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
</group>
|
| 36 |
);
|
| 37 |
};
|
|
|
|
| 1 |
+
import { Fragment } from "react";
|
| 2 |
import { CubePiece } from "./cube-piece";
|
| 3 |
import { RotationPanel } from "./rotation-panel";
|
| 4 |
|
|
|
|
| 25 |
roughness={roughness}
|
| 26 |
/>
|
| 27 |
))}
|
| 28 |
+
{["front", "back", "left", "right", "top", "bottom"].map((face) => (
|
| 29 |
+
<Fragment key={face}>
|
| 30 |
+
<RotationPanel
|
| 31 |
+
direction="clockwise"
|
| 32 |
+
face={
|
| 33 |
+
face as "front" | "back" | "left" | "right" | "top" | "bottom"
|
| 34 |
+
}
|
| 35 |
+
/>
|
| 36 |
+
<RotationPanel
|
| 37 |
+
direction="counter-clockwise"
|
| 38 |
+
face={
|
| 39 |
+
face as "front" | "back" | "left" | "right" | "top" | "bottom"
|
| 40 |
+
}
|
| 41 |
+
/>
|
| 42 |
+
</Fragment>
|
| 43 |
+
))}
|
| 44 |
</group>
|
| 45 |
);
|
| 46 |
};
|