cube-state-engine 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CUBE STATE ENGINE
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A core state manager designed to integrate with custom 3D cube models. This engine makes it easy to track and update the cube's state after every move, providing contextual information such as whether the cube is solved.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
| Method | Description | Return Type |
|
|
10
|
+
| ----------------------------- | -------------------------------------------------------------------------- | ----------- |
|
|
11
|
+
| `isSolved()` | Checks if the cube is solved. | `boolean` |
|
|
12
|
+
| `state()` | Returns the current state of the cube as an object representing each face. | `object` |
|
|
13
|
+
| `rotateU(clockwise: boolean)` | Rotates the **Upper** face clockwise or counterclockwise. | `void` |
|
|
14
|
+
| `rotateF(clockwise: boolean)` | Rotates the **Front** face clockwise or counterclockwise. | `void` |
|
|
15
|
+
| `rotateD(clockwise: boolean)` | Rotates the **Down** face clockwise or counterclockwise. | `void` |
|
|
16
|
+
| `rotateX(clockwise: boolean)` | Rotates the cube along the **X-axis** clockwise or counterclockwise. | `void` |
|
|
17
|
+
| `rotateY(clockwise: boolean)` | Rotates the cube along the **Y-axis** clockwise or counterclockwise. | `void` |
|
|
18
|
+
| `rotateL(clockwise: boolean)` | Rotates the **Left** face clockwise or counterclockwise. | `void` |
|
|
19
|
+
| `rotateR(clockwise: boolean)` | Rotates the **Right** face clockwise or counterclockwise. | `void` |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Cube State Structure
|
|
24
|
+
|
|
25
|
+
The `state()` method returns the current state of the cube as an object with six properties, each representing a face:
|
|
26
|
+
|
|
27
|
+
| Face | Description | Structure |
|
|
28
|
+
| ------- | ---------------------------- | ------------ |
|
|
29
|
+
| `UPPER` | The top face of the cube. | `string[][]` |
|
|
30
|
+
| `LEFT` | The left face of the cube. | `string[][]` |
|
|
31
|
+
| `FRONT` | The front face of the cube. | `string[][]` |
|
|
32
|
+
| `RIGHT` | The right face of the cube. | `string[][]` |
|
|
33
|
+
| `BACK` | The back face of the cube. | `string[][]` |
|
|
34
|
+
| `DOWN` | The bottom face of the cube. | `string[][]` |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Example Usage
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import { CubeEngine } from "cube-state-engine";
|
|
42
|
+
|
|
43
|
+
// Initialize the engine
|
|
44
|
+
const cube = new CubeEngine();
|
|
45
|
+
|
|
46
|
+
// Check if the cube is solved
|
|
47
|
+
console.log(cube.isSolved()); // true
|
|
48
|
+
|
|
49
|
+
// Rotate the upper face clockwise
|
|
50
|
+
cube.rotateU(true);
|
|
51
|
+
|
|
52
|
+
// Get the current cube state
|
|
53
|
+
console.log(cube.state());
|
|
54
|
+
|
|
55
|
+
// Rotate the cube along the Y-axis
|
|
56
|
+
cube.rotateY(false);
|
|
57
|
+
```
|