@houstonp/rubiks-cube 2.0.0 → 3.0.0
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 +494 -63
- package/package.json +22 -12
- package/src/core/index.js +478 -0
- package/src/rubiksCube/index.js +3 -0
- package/src/rubiksCube/rubiksCubeController.js +111 -0
- package/src/rubiksCube3D/centerPiece.js +79 -0
- package/src/rubiksCube3D/cornerPiece.js +114 -0
- package/src/rubiksCube3D/cubeConfig.js +87 -0
- package/src/rubiksCube3D/cubeSettings.js +30 -0
- package/src/rubiksCube3D/edgePiece.js +51 -0
- package/src/rubiksCube3D/index.js +3 -0
- package/src/rubiksCube3D/rubiksCube3D.js +383 -0
- package/src/rubiksCube3D/sticker.js +38 -0
- package/src/state/index.js +4 -0
- package/src/state/rubiksCubeState.js +471 -0
- package/src/state/slice.js +236 -0
- package/src/state/stickerState.js +185 -0
- package/src/{cameraState.js → webComponent/cameraState.js} +17 -25
- package/src/webComponent/constants.js +67 -0
- package/src/{debouncer.js → webComponent/debouncer.js} +1 -1
- package/src/webComponent/index.js +7 -0
- package/src/webComponent/rubiksCubeElement.js +379 -0
- package/src/{settings.js → webComponent/settings.js} +47 -22
- package/tests/common.js +10 -0
- package/tests/core.test.js +56 -0
- package/tests/rubiksCube.solves.test.js +41 -0
- package/tests/rubiksCube3D.solves.test.js +185 -0
- package/tests/rubiksCubeState.solves.test.js +35 -0
- package/tests/setup.js +36 -0
- package/tests/testScrambles.js +194 -0
- package/types/core/index.d.ts +451 -0
- package/types/rubiksCube/index.d.ts +3 -0
- package/types/rubiksCube/rubiksCubeController.d.ts +62 -0
- package/types/rubiksCube3D/centerPiece.d.ts +27 -0
- package/types/rubiksCube3D/cornerPiece.d.ts +38 -0
- package/types/rubiksCube3D/cubeConfig.d.ts +32 -0
- package/types/rubiksCube3D/cubeSettings.d.ts +33 -0
- package/types/rubiksCube3D/edgePiece.d.ts +18 -0
- package/types/rubiksCube3D/index.d.ts +3 -0
- package/types/rubiksCube3D/rubiksCube3D.d.ts +120 -0
- package/types/rubiksCube3D/sticker.d.ts +18 -0
- package/types/state/index.d.ts +5 -0
- package/types/state/rubiksCubeState.d.ts +108 -0
- package/types/state/slice.d.ts +46 -0
- package/types/state/stickerState.d.ts +34 -0
- package/types/webComponent/cameraState.d.ts +22 -0
- package/types/webComponent/constants.d.ts +57 -0
- package/types/webComponent/index.d.ts +6 -0
- package/types/webComponent/rubiksCubeElement.d.ts +89 -0
- package/types/{settings.d.ts → webComponent/settings.d.ts} +9 -8
- package/src/core.js +0 -127
- package/src/cube/cube.js +0 -324
- package/src/cube/cubeRotation.js +0 -79
- package/src/cube/cubeSettings.js +0 -18
- package/src/cube/cubeState.js +0 -192
- package/src/cube/slice.js +0 -143
- package/src/index.js +0 -496
- package/src/schema.js +0 -22
- package/src/threejs/materials.js +0 -54
- package/src/threejs/pieces.js +0 -100
- package/src/threejs/stickers.js +0 -40
- package/types/cameraState.d.ts +0 -19
- package/types/core.d.ts +0 -125
- package/types/cube/cube.d.ts +0 -102
- package/types/cube/cubeRotation.d.ts +0 -33
- package/types/cube/cubeSettings.d.ts +0 -17
- package/types/cube/cubeState.d.ts +0 -16
- package/types/cube/slice.d.ts +0 -15
- package/types/index.d.ts +0 -65
- package/types/schema.d.ts +0 -11
- package/types/threejs/materials.d.ts +0 -21
- package/types/threejs/pieces.d.ts +0 -28
- package/types/threejs/stickers.d.ts +0 -6
- /package/src/{globals.ts → webComponent/globals.ts} +0 -0
- /package/types/{debouncer.d.ts → webComponent/debouncer.d.ts} +0 -0
- /package/types/{globals.d.ts → webComponent/globals.d.ts} +0 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reverses the direction of a movement or rotation
|
|
3
|
+
* @template {Movement | Rotation} T
|
|
4
|
+
* @param {T} action
|
|
5
|
+
* @returns {T}
|
|
6
|
+
* */
|
|
7
|
+
export function reverse<T extends Movement | Rotation>(action: T): T;
|
|
8
|
+
/**
|
|
9
|
+
* Translates notation meant for a 3x3 into notation a big cube. This is so that 3x3 algorithms can be used on a big cube if desired. eg. for a 6x6 r -> 5r
|
|
10
|
+
* @template {Movement | Rotation} T
|
|
11
|
+
* @param {T} action
|
|
12
|
+
* @param {CubeType} cubeType
|
|
13
|
+
* @returns {T}
|
|
14
|
+
* */
|
|
15
|
+
export function translate<T extends Movement | Rotation>(action: T, cubeType: CubeType): T;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {string} rotation
|
|
19
|
+
*/
|
|
20
|
+
export function IsRotation(rotation: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {string} movement
|
|
24
|
+
* @return {boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function isMovement(movement: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {typeof Movements.Single[keyof typeof Movements.Single]} SingleMove
|
|
29
|
+
* @typedef {typeof Movements.Wide[keyof typeof Movements.Wide]} WideMove
|
|
30
|
+
* @typedef {typeof Movements.Two[keyof typeof Movements.Two]} TwoMove
|
|
31
|
+
* @typedef {typeof Movements.Three[keyof typeof Movements.Three]} ThreeMove
|
|
32
|
+
* @typedef {typeof Movements.Four[keyof typeof Movements.Four]} FourMove
|
|
33
|
+
* @typedef {typeof Movements.Five[keyof typeof Movements.Five]} FiveMove
|
|
34
|
+
* @typedef {typeof Movements.Six[keyof typeof Movements.Six]} SixMove
|
|
35
|
+
* @typedef {SingleMove | WideMove | TwoMove | ThreeMove | FourMove | FiveMove | SixMove} Movement
|
|
36
|
+
*/
|
|
37
|
+
export const Movements: Readonly<{
|
|
38
|
+
Single: Readonly<{
|
|
39
|
+
R: "R";
|
|
40
|
+
R2: "R2";
|
|
41
|
+
RP: "R'";
|
|
42
|
+
L: "L";
|
|
43
|
+
L2: "L2";
|
|
44
|
+
LP: "L'";
|
|
45
|
+
U: "U";
|
|
46
|
+
U2: "U2";
|
|
47
|
+
UP: "U'";
|
|
48
|
+
D: "D";
|
|
49
|
+
D2: "D2";
|
|
50
|
+
DP: "D'";
|
|
51
|
+
F: "F";
|
|
52
|
+
F2: "F2";
|
|
53
|
+
FP: "F'";
|
|
54
|
+
B: "B";
|
|
55
|
+
B2: "B2";
|
|
56
|
+
BP: "B'";
|
|
57
|
+
M: "M";
|
|
58
|
+
M2: "M2";
|
|
59
|
+
MP: "M'";
|
|
60
|
+
E: "E";
|
|
61
|
+
E2: "E2";
|
|
62
|
+
EP: "E'";
|
|
63
|
+
S: "S";
|
|
64
|
+
S2: "S2";
|
|
65
|
+
SP: "S'";
|
|
66
|
+
}>;
|
|
67
|
+
Wide: Readonly<{
|
|
68
|
+
Rw: "Rw";
|
|
69
|
+
Rw2: "Rw2";
|
|
70
|
+
RwP: "Rw'";
|
|
71
|
+
r: "r";
|
|
72
|
+
r2: "r2";
|
|
73
|
+
rP: "r'";
|
|
74
|
+
Lw: "Lw";
|
|
75
|
+
Lw2: "Lw2";
|
|
76
|
+
LwP: "Lw'";
|
|
77
|
+
l: "l";
|
|
78
|
+
l2: "l2";
|
|
79
|
+
lP: "l'";
|
|
80
|
+
Fw: "Fw";
|
|
81
|
+
Fw2: "Fw2";
|
|
82
|
+
FwP: "Fw'";
|
|
83
|
+
f: "f";
|
|
84
|
+
f2: "f2";
|
|
85
|
+
fP: "f'";
|
|
86
|
+
Bw: "Bw";
|
|
87
|
+
Bw2: "Bw2";
|
|
88
|
+
BwP: "Bw'";
|
|
89
|
+
b: "b";
|
|
90
|
+
b2: "b2";
|
|
91
|
+
bP: "b'";
|
|
92
|
+
Uw: "Uw";
|
|
93
|
+
Uw2: "Uw2";
|
|
94
|
+
UwP: "Uw'";
|
|
95
|
+
u: "u";
|
|
96
|
+
u2: "u2";
|
|
97
|
+
uP: "u'";
|
|
98
|
+
Dw: "Dw";
|
|
99
|
+
Dw2: "Dw2";
|
|
100
|
+
DwP: "Dw'";
|
|
101
|
+
d: "d";
|
|
102
|
+
d2: "d2";
|
|
103
|
+
dP: "d'";
|
|
104
|
+
}>;
|
|
105
|
+
Two: Readonly<{
|
|
106
|
+
Rw: "2Rw";
|
|
107
|
+
Rw2: "2Rw2";
|
|
108
|
+
RwP: "2Rw'";
|
|
109
|
+
r: "2r";
|
|
110
|
+
r2: "2r2";
|
|
111
|
+
rP: "2r'";
|
|
112
|
+
R: "2R";
|
|
113
|
+
R2: "2R2";
|
|
114
|
+
RP: "2R'";
|
|
115
|
+
Lw: "2Lw";
|
|
116
|
+
Lw2: "2Lw2";
|
|
117
|
+
LwP: "2Lw'";
|
|
118
|
+
l: "2l";
|
|
119
|
+
l2: "2l2";
|
|
120
|
+
lP: "2l'";
|
|
121
|
+
L: "2L";
|
|
122
|
+
L2: "2L2";
|
|
123
|
+
LP: "2L'";
|
|
124
|
+
Fw: "2Fw";
|
|
125
|
+
Fw2: "2Fw2";
|
|
126
|
+
FwP: "2Fw'";
|
|
127
|
+
f: "2f";
|
|
128
|
+
f2: "2f2";
|
|
129
|
+
fP: "2f'";
|
|
130
|
+
F: "2F";
|
|
131
|
+
F2: "2F2";
|
|
132
|
+
FP: "2F'";
|
|
133
|
+
Bw: "2Bw";
|
|
134
|
+
Bw2: "2Bw2";
|
|
135
|
+
BwP: "2Bw'";
|
|
136
|
+
b: "2b";
|
|
137
|
+
b2: "2b2";
|
|
138
|
+
bP: "2b'";
|
|
139
|
+
B: "2B";
|
|
140
|
+
B2: "2B2";
|
|
141
|
+
BP: "2B'";
|
|
142
|
+
Uw: "2Uw";
|
|
143
|
+
Uw2: "2Uw2";
|
|
144
|
+
UwP: "2Uw'";
|
|
145
|
+
u: "2u";
|
|
146
|
+
u2: "2u2";
|
|
147
|
+
uP: "2u'";
|
|
148
|
+
U: "2U";
|
|
149
|
+
U2: "2U2";
|
|
150
|
+
UP: "2U'";
|
|
151
|
+
Dw: "2Dw";
|
|
152
|
+
Dw2: "2Dw2";
|
|
153
|
+
DwP: "2Dw'";
|
|
154
|
+
d: "2d";
|
|
155
|
+
d2: "2d2";
|
|
156
|
+
dP: "2d'";
|
|
157
|
+
D: "2D";
|
|
158
|
+
D2: "2D2";
|
|
159
|
+
DP: "2D'";
|
|
160
|
+
}>;
|
|
161
|
+
Three: Readonly<{
|
|
162
|
+
Rw: "3Rw";
|
|
163
|
+
Rw2: "3Rw2";
|
|
164
|
+
RwP: "3Rw'";
|
|
165
|
+
r: "3r";
|
|
166
|
+
r2: "3r2";
|
|
167
|
+
rP: "3r'";
|
|
168
|
+
R: "3R";
|
|
169
|
+
R2: "3R2";
|
|
170
|
+
RP: "3R'";
|
|
171
|
+
Lw: "3Lw";
|
|
172
|
+
Lw2: "3Lw2";
|
|
173
|
+
LwP: "3Lw'";
|
|
174
|
+
l: "3l";
|
|
175
|
+
l2: "3l2";
|
|
176
|
+
lP: "3l'";
|
|
177
|
+
L: "3L";
|
|
178
|
+
L2: "3L2";
|
|
179
|
+
LP: "3L'";
|
|
180
|
+
Fw: "3Fw";
|
|
181
|
+
Fw2: "3Fw2";
|
|
182
|
+
FwP: "3Fw'";
|
|
183
|
+
f: "3f";
|
|
184
|
+
f2: "3f2";
|
|
185
|
+
fP: "3f'";
|
|
186
|
+
F: "3F";
|
|
187
|
+
F2: "3F2";
|
|
188
|
+
FP: "3F'";
|
|
189
|
+
Bw: "3Bw";
|
|
190
|
+
Bw2: "3Bw2";
|
|
191
|
+
BwP: "3Bw'";
|
|
192
|
+
b: "3b";
|
|
193
|
+
b2: "3b2";
|
|
194
|
+
bP: "3b'";
|
|
195
|
+
B: "3B";
|
|
196
|
+
B2: "3B2";
|
|
197
|
+
BP: "3B'";
|
|
198
|
+
Uw: "3Uw";
|
|
199
|
+
Uw2: "3Uw2";
|
|
200
|
+
UwP: "3Uw'";
|
|
201
|
+
u: "3u";
|
|
202
|
+
u2: "3u2";
|
|
203
|
+
uP: "3u'";
|
|
204
|
+
U: "3U";
|
|
205
|
+
U2: "3U2";
|
|
206
|
+
UP: "3U'";
|
|
207
|
+
Dw: "3Dw";
|
|
208
|
+
Dw2: "3Dw2";
|
|
209
|
+
DwP: "3Dw'";
|
|
210
|
+
d: "3d";
|
|
211
|
+
d2: "3d2";
|
|
212
|
+
dP: "3d'";
|
|
213
|
+
D: "3D";
|
|
214
|
+
D2: "3D2";
|
|
215
|
+
DP: "3D'";
|
|
216
|
+
}>;
|
|
217
|
+
Four: Readonly<{
|
|
218
|
+
Rw: "4Rw";
|
|
219
|
+
Rw2: "4Rw2";
|
|
220
|
+
RwP: "4Rw'";
|
|
221
|
+
r: "4r";
|
|
222
|
+
r2: "4r2";
|
|
223
|
+
rP: "4r'";
|
|
224
|
+
R: "4R";
|
|
225
|
+
R2: "4R2";
|
|
226
|
+
RP: "4R'";
|
|
227
|
+
Lw: "4Lw";
|
|
228
|
+
Lw2: "4Lw2";
|
|
229
|
+
LwP: "4Lw'";
|
|
230
|
+
l: "4l";
|
|
231
|
+
l2: "4l2";
|
|
232
|
+
lP: "4l'";
|
|
233
|
+
L: "4L";
|
|
234
|
+
L2: "4L2";
|
|
235
|
+
LP: "4L'";
|
|
236
|
+
Fw: "4Fw";
|
|
237
|
+
Fw2: "4Fw2";
|
|
238
|
+
FwP: "4Fw'";
|
|
239
|
+
f: "4f";
|
|
240
|
+
f2: "4f2";
|
|
241
|
+
fP: "4f'";
|
|
242
|
+
F: "4F";
|
|
243
|
+
F2: "4F2";
|
|
244
|
+
FP: "4F'";
|
|
245
|
+
Bw: "4Bw";
|
|
246
|
+
Bw2: "4Bw2";
|
|
247
|
+
BwP: "4Bw'";
|
|
248
|
+
b: "4b";
|
|
249
|
+
b2: "4b2";
|
|
250
|
+
bP: "4b'";
|
|
251
|
+
B: "4B";
|
|
252
|
+
B2: "4B2";
|
|
253
|
+
BP: "4B'";
|
|
254
|
+
Uw: "4Uw";
|
|
255
|
+
Uw2: "4Uw2";
|
|
256
|
+
UwP: "4Uw'";
|
|
257
|
+
u: "4u";
|
|
258
|
+
u2: "4u2";
|
|
259
|
+
uP: "4u'";
|
|
260
|
+
U: "4U";
|
|
261
|
+
U2: "4U2";
|
|
262
|
+
UP: "4U'";
|
|
263
|
+
Dw: "4Dw";
|
|
264
|
+
Dw2: "4Dw2";
|
|
265
|
+
DwP: "4Dw'";
|
|
266
|
+
d: "4d";
|
|
267
|
+
d2: "4d2";
|
|
268
|
+
dP: "4d'";
|
|
269
|
+
D: "4D";
|
|
270
|
+
D2: "4D2";
|
|
271
|
+
DP: "4D'";
|
|
272
|
+
}>;
|
|
273
|
+
Five: Readonly<{
|
|
274
|
+
Rw: "5Rw";
|
|
275
|
+
Rw2: "5Rw2";
|
|
276
|
+
RwP: "5Rw'";
|
|
277
|
+
r: "5r";
|
|
278
|
+
r2: "5r2";
|
|
279
|
+
rP: "5r'";
|
|
280
|
+
R: "5R";
|
|
281
|
+
R2: "5R2";
|
|
282
|
+
RP: "5R'";
|
|
283
|
+
Lw: "5Lw";
|
|
284
|
+
Lw2: "5Lw2";
|
|
285
|
+
LwP: "5Lw'";
|
|
286
|
+
l: "5l";
|
|
287
|
+
l2: "5l2";
|
|
288
|
+
lP: "5l'";
|
|
289
|
+
L: "5L";
|
|
290
|
+
L2: "5L2";
|
|
291
|
+
LP: "5L'";
|
|
292
|
+
Fw: "5Fw";
|
|
293
|
+
Fw2: "5Fw2";
|
|
294
|
+
FwP: "5Fw'";
|
|
295
|
+
f: "5f";
|
|
296
|
+
f2: "5f2";
|
|
297
|
+
fP: "5f'";
|
|
298
|
+
F: "5F";
|
|
299
|
+
F2: "5F2";
|
|
300
|
+
FP: "5F'";
|
|
301
|
+
Bw: "5Bw";
|
|
302
|
+
Bw2: "5Bw2";
|
|
303
|
+
BwP: "5Bw'";
|
|
304
|
+
b: "5b";
|
|
305
|
+
b2: "5b2";
|
|
306
|
+
bP: "5b'";
|
|
307
|
+
B: "5B";
|
|
308
|
+
B2: "5B2";
|
|
309
|
+
BP: "5B'";
|
|
310
|
+
Uw: "5Uw";
|
|
311
|
+
Uw2: "5Uw2";
|
|
312
|
+
UwP: "5Uw'";
|
|
313
|
+
u: "5u";
|
|
314
|
+
u2: "5u2";
|
|
315
|
+
uP: "5u'";
|
|
316
|
+
U: "5U";
|
|
317
|
+
U2: "5U2";
|
|
318
|
+
UP: "5U'";
|
|
319
|
+
Dw: "5Dw";
|
|
320
|
+
Dw2: "5Dw2";
|
|
321
|
+
DwP: "5Dw'";
|
|
322
|
+
d: "5d";
|
|
323
|
+
d2: "5d2";
|
|
324
|
+
dP: "5d'";
|
|
325
|
+
D: "5D";
|
|
326
|
+
D2: "5D2";
|
|
327
|
+
DP: "5D'";
|
|
328
|
+
}>;
|
|
329
|
+
Six: Readonly<{
|
|
330
|
+
Rw: "6Rw";
|
|
331
|
+
Rw2: "6Rw2";
|
|
332
|
+
RwP: "6Rw'";
|
|
333
|
+
r: "6r";
|
|
334
|
+
r2: "6r2";
|
|
335
|
+
rP: "6r'";
|
|
336
|
+
R: "6R";
|
|
337
|
+
R2: "6R2";
|
|
338
|
+
RP: "6R'";
|
|
339
|
+
Lw: "6Lw";
|
|
340
|
+
Lw2: "6Lw2";
|
|
341
|
+
LwP: "6Lw'";
|
|
342
|
+
l: "6l";
|
|
343
|
+
l2: "6l2";
|
|
344
|
+
lP: "6l'";
|
|
345
|
+
L: "6L";
|
|
346
|
+
L2: "6L2";
|
|
347
|
+
LP: "6L'";
|
|
348
|
+
Fw: "6Fw";
|
|
349
|
+
Fw2: "6Fw2";
|
|
350
|
+
FwP: "6Fw'";
|
|
351
|
+
f: "6f";
|
|
352
|
+
f2: "6f2";
|
|
353
|
+
fP: "6f'";
|
|
354
|
+
F: "6F";
|
|
355
|
+
F2: "6F2";
|
|
356
|
+
FP: "6F'";
|
|
357
|
+
Bw: "6Bw";
|
|
358
|
+
Bw2: "6Bw2";
|
|
359
|
+
BwP: "6Bw'";
|
|
360
|
+
b: "6b";
|
|
361
|
+
b2: "6b2";
|
|
362
|
+
bP: "6b'";
|
|
363
|
+
B: "6B";
|
|
364
|
+
B2: "6B2";
|
|
365
|
+
BP: "6B'";
|
|
366
|
+
Uw: "6Uw";
|
|
367
|
+
Uw2: "6Uw2";
|
|
368
|
+
UwP: "6Uw'";
|
|
369
|
+
u: "6u";
|
|
370
|
+
u2: "6u2";
|
|
371
|
+
uP: "6u'";
|
|
372
|
+
U: "6U";
|
|
373
|
+
U2: "6U2";
|
|
374
|
+
UP: "6U'";
|
|
375
|
+
Dw: "6Dw";
|
|
376
|
+
Dw2: "6Dw2";
|
|
377
|
+
DwP: "6Dw'";
|
|
378
|
+
d: "6d";
|
|
379
|
+
d2: "6d2";
|
|
380
|
+
dP: "6d'";
|
|
381
|
+
D: "6D";
|
|
382
|
+
D2: "6D2";
|
|
383
|
+
DP: "6D'";
|
|
384
|
+
}>;
|
|
385
|
+
/**
|
|
386
|
+
* Build a layer-range move for big-cube notation. e.g. Movements.Range(2, 4, Movements.Wide.Rw) returns '2-4Rw',
|
|
387
|
+
* meaning "rotate layers 2 through 4 from the right face." Accepts wide moves (`Movements.Wide.*`), face
|
|
388
|
+
* moves (`Movements.Single.{R,L,U,D,F,B}` and modifiers), and slice moves (`Movements.Single.{M,E,S}` and
|
|
389
|
+
* modifiers). Already-prefixed moves (`2R`, `2-4Rw`) are rejected.
|
|
390
|
+
* @param {number} lower
|
|
391
|
+
* @param {number} upper
|
|
392
|
+
* @param {WideMove | SingleMove} baseMove
|
|
393
|
+
* @returns {Movement}
|
|
394
|
+
*/
|
|
395
|
+
Range: (lower: number, upper: number, baseMove: WideMove | SingleMove) => Movement;
|
|
396
|
+
}>;
|
|
397
|
+
/**
|
|
398
|
+
* @typedef {typeof Rotations[keyof typeof Rotations]} Rotation
|
|
399
|
+
*/
|
|
400
|
+
export const Rotations: Readonly<{
|
|
401
|
+
x: "x";
|
|
402
|
+
x2: "x2";
|
|
403
|
+
xP: "x'";
|
|
404
|
+
y: "y";
|
|
405
|
+
y2: "y2";
|
|
406
|
+
yP: "y'";
|
|
407
|
+
z: "z";
|
|
408
|
+
z2: "z2";
|
|
409
|
+
zP: "z'";
|
|
410
|
+
}>;
|
|
411
|
+
/**
|
|
412
|
+
* @typedef {typeof Faces [keyof typeof Faces]} Face
|
|
413
|
+
*/
|
|
414
|
+
export const Faces: Readonly<{
|
|
415
|
+
U: "U";
|
|
416
|
+
D: "D";
|
|
417
|
+
L: "L";
|
|
418
|
+
R: "R";
|
|
419
|
+
F: "F";
|
|
420
|
+
B: "B";
|
|
421
|
+
}>;
|
|
422
|
+
/**
|
|
423
|
+
* @typedef {typeof CubeTypes [keyof typeof CubeTypes]} CubeType
|
|
424
|
+
*/
|
|
425
|
+
export const CubeTypes: Readonly<{
|
|
426
|
+
Two: "Two";
|
|
427
|
+
Three: "Three";
|
|
428
|
+
Four: "Four";
|
|
429
|
+
Five: "Five";
|
|
430
|
+
Six: "Six";
|
|
431
|
+
Seven: "Seven";
|
|
432
|
+
}>;
|
|
433
|
+
export const LayerCount: Readonly<{
|
|
434
|
+
Two: 2;
|
|
435
|
+
Three: 3;
|
|
436
|
+
Four: 4;
|
|
437
|
+
Five: 5;
|
|
438
|
+
Six: 6;
|
|
439
|
+
Seven: 7;
|
|
440
|
+
}>;
|
|
441
|
+
export type SingleMove = (typeof Movements.Single)[keyof typeof Movements.Single];
|
|
442
|
+
export type WideMove = (typeof Movements.Wide)[keyof typeof Movements.Wide];
|
|
443
|
+
export type TwoMove = (typeof Movements.Two)[keyof typeof Movements.Two];
|
|
444
|
+
export type ThreeMove = (typeof Movements.Three)[keyof typeof Movements.Three];
|
|
445
|
+
export type FourMove = (typeof Movements.Four)[keyof typeof Movements.Four];
|
|
446
|
+
export type FiveMove = (typeof Movements.Five)[keyof typeof Movements.Five];
|
|
447
|
+
export type SixMove = (typeof Movements.Six)[keyof typeof Movements.Six];
|
|
448
|
+
export type Movement = SingleMove | WideMove | TwoMove | ThreeMove | FourMove | FiveMove | SixMove;
|
|
449
|
+
export type Rotation = (typeof Rotations)[keyof typeof Rotations];
|
|
450
|
+
export type Face = (typeof Faces)[keyof typeof Faces];
|
|
451
|
+
export type CubeType = (typeof CubeTypes)[keyof typeof CubeTypes];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export default class RubiksCubeController {
|
|
2
|
+
/**
|
|
3
|
+
* @param {CubeType} cubeType
|
|
4
|
+
* @param {RubiksCubeViewInterface} view
|
|
5
|
+
* */
|
|
6
|
+
constructor(cubeType: CubeType, view: RubiksCubeViewInterface);
|
|
7
|
+
state: RubiksCubeState;
|
|
8
|
+
view: RubiksCubeViewInterface;
|
|
9
|
+
/**
|
|
10
|
+
* @param {Movement} movement
|
|
11
|
+
* @param {AnimationOptions} [options]
|
|
12
|
+
* @returns {Promise<string>}
|
|
13
|
+
*/
|
|
14
|
+
movement(movement: Movement, options?: AnimationOptions): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* @param {Rotation} rotation
|
|
17
|
+
* @param {AnimationOptions} [options]
|
|
18
|
+
* @returns {Promise<string>}
|
|
19
|
+
*/
|
|
20
|
+
rotation(rotation: Rotation, options?: AnimationOptions): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* @param {(Rotation | Movement)[]} actions
|
|
23
|
+
* @param {AnimationOptions} [options]
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
do(actions: (Rotation | Movement)[], options?: AnimationOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
reset(): string;
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} kociembaState
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
setState(kociembaState: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
getState(): string;
|
|
40
|
+
/**
|
|
41
|
+
* @param {CubeType} cubeType
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
setType(cubeType: CubeType): string;
|
|
45
|
+
}
|
|
46
|
+
export type AnimationOptions = {
|
|
47
|
+
translate?: boolean;
|
|
48
|
+
animationSpeedMs?: number;
|
|
49
|
+
reverse?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type RubiksCubeViewInterface = {
|
|
52
|
+
slice: (arg0: Slice, arg1: any | undefined) => Promise<void>;
|
|
53
|
+
setState: (arg0: StickerState) => void;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
setType: (arg0: CubeType) => void;
|
|
56
|
+
};
|
|
57
|
+
import { RubiksCubeState } from '../state';
|
|
58
|
+
import type { Movement } from '../core';
|
|
59
|
+
import type { Rotation } from '../core';
|
|
60
|
+
import type { CubeType } from '../core';
|
|
61
|
+
import type { Slice } from '../state/slice';
|
|
62
|
+
import type { StickerState } from '../state/stickerState';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @import {Vector3Like} from 'three' */
|
|
2
|
+
/** @typedef {{ positon: Vector3Like, rotation: Vector3Like }} CenterPieceUserData */
|
|
3
|
+
export class CenterPiece extends Object3D<import("three").Object3DEventMap> {
|
|
4
|
+
constructor();
|
|
5
|
+
frontSticker: CenterSticker;
|
|
6
|
+
/** @type {Mesh<PlaneGeometry, MeshStandardMaterial> | null} */
|
|
7
|
+
logo: Mesh<PlaneGeometry, MeshStandardMaterial> | null;
|
|
8
|
+
get stickers(): CenterSticker[];
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} logoPath
|
|
11
|
+
*/
|
|
12
|
+
addLogo(logoPath: string): void;
|
|
13
|
+
removeLogo(): void;
|
|
14
|
+
}
|
|
15
|
+
export class CenterSticker extends Sticker {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
export type CenterPieceUserData = {
|
|
19
|
+
positon: Vector3Like;
|
|
20
|
+
rotation: Vector3Like;
|
|
21
|
+
};
|
|
22
|
+
import { Object3D } from 'three';
|
|
23
|
+
import { Mesh } from 'three';
|
|
24
|
+
import { PlaneGeometry } from 'three';
|
|
25
|
+
import { MeshStandardMaterial } from 'three';
|
|
26
|
+
import { Sticker } from './sticker';
|
|
27
|
+
import type { Vector3Like } from 'three';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @import {Vector3Like} from 'three' */
|
|
2
|
+
/** @import {Face} from "../core" */
|
|
3
|
+
/** @typedef {{ positon: Vector3Like, rotation: Vector3Like }} CornerPieceUserData */
|
|
4
|
+
/**
|
|
5
|
+
* @param {Material} frontMaterial
|
|
6
|
+
* @param {Material} rightMaterial
|
|
7
|
+
* @param {Material} topMaterial
|
|
8
|
+
* @param {Material} coreMaterial
|
|
9
|
+
* @returns {Group}
|
|
10
|
+
*/
|
|
11
|
+
export class CornerPiece extends Object3D<import("three").Object3DEventMap> {
|
|
12
|
+
constructor();
|
|
13
|
+
frontSticker: CornerSticker;
|
|
14
|
+
rightSticker: CornerSticker;
|
|
15
|
+
topSticker: CornerSticker;
|
|
16
|
+
get stickers(): CornerSticker[];
|
|
17
|
+
/**
|
|
18
|
+
* @param {Face} face
|
|
19
|
+
* @param {string} logoPath
|
|
20
|
+
*/
|
|
21
|
+
addLogo(face: Face, logoPath: string): void;
|
|
22
|
+
logo: Mesh<PlaneGeometry, MeshStandardMaterial, import("three").Object3DEventMap>;
|
|
23
|
+
removeLogo(): void;
|
|
24
|
+
}
|
|
25
|
+
export class CornerSticker extends Sticker {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export type CornerPieceUserData = {
|
|
29
|
+
positon: Vector3Like;
|
|
30
|
+
rotation: Vector3Like;
|
|
31
|
+
};
|
|
32
|
+
import { Object3D } from 'three';
|
|
33
|
+
import type { Face } from "../core";
|
|
34
|
+
import { PlaneGeometry } from 'three';
|
|
35
|
+
import { MeshStandardMaterial } from 'three';
|
|
36
|
+
import { Mesh } from 'three';
|
|
37
|
+
import { Sticker } from './sticker';
|
|
38
|
+
import type { Vector3Like } from 'three';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @import {CubeType, Face} from '../core' */
|
|
2
|
+
/** @import {ColorRepresentation} from 'three' */
|
|
3
|
+
/**
|
|
4
|
+
* @typedef CubeConfig
|
|
5
|
+
* @property {number[]} layers
|
|
6
|
+
* @property {number} pieceSize
|
|
7
|
+
* @property {number} coreSize
|
|
8
|
+
* @property {number} outerLayerMultiplier
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @param {CubeType} cubeType
|
|
12
|
+
* @return {CubeConfig}
|
|
13
|
+
*/
|
|
14
|
+
export function getCubeConfig(cubeType: CubeType): CubeConfig;
|
|
15
|
+
export namespace FaceColors {
|
|
16
|
+
let B: string;
|
|
17
|
+
let D: string;
|
|
18
|
+
let F: string;
|
|
19
|
+
let L: string;
|
|
20
|
+
let R: string;
|
|
21
|
+
let U: string;
|
|
22
|
+
}
|
|
23
|
+
export function ColorToFace(color: ColorRepresentation): Face;
|
|
24
|
+
export type CubeConfig = {
|
|
25
|
+
layers: number[];
|
|
26
|
+
pieceSize: number;
|
|
27
|
+
coreSize: number;
|
|
28
|
+
outerLayerMultiplier: number;
|
|
29
|
+
};
|
|
30
|
+
import type { CubeType } from '../core';
|
|
31
|
+
import type { ColorRepresentation } from 'three';
|
|
32
|
+
import type { Face } from '../core';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @import {CubeType} from '../core' */
|
|
2
|
+
/**
|
|
3
|
+
* @typedef RubiksCube3DSettingsOptions
|
|
4
|
+
* @property {CubeType} [cubeType]
|
|
5
|
+
* @property {number} [pieceGap]
|
|
6
|
+
* @property {number} [animationSpeedMs]
|
|
7
|
+
* @property {gsap.EaseString | gsap.EaseFunction} [animationStyle]
|
|
8
|
+
* @property {string | null} [logo]
|
|
9
|
+
*/
|
|
10
|
+
export default class RubiksCube3DSettings {
|
|
11
|
+
/**
|
|
12
|
+
* @param {RubiksCube3DSettingsOptions} [options]
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: RubiksCube3DSettingsOptions);
|
|
15
|
+
/** @type {CubeType} */
|
|
16
|
+
cubeType: CubeType;
|
|
17
|
+
/** @type {number} */
|
|
18
|
+
pieceGap: number;
|
|
19
|
+
/** @type {number} */
|
|
20
|
+
animationSpeedMs: number;
|
|
21
|
+
/** @type {gsap.EaseString | gsap.EaseFunction} */
|
|
22
|
+
animationStyle: gsap.EaseString | gsap.EaseFunction;
|
|
23
|
+
/** @type {string | null} */
|
|
24
|
+
logo: string | null;
|
|
25
|
+
}
|
|
26
|
+
export type RubiksCube3DSettingsOptions = {
|
|
27
|
+
cubeType?: CubeType;
|
|
28
|
+
pieceGap?: number;
|
|
29
|
+
animationSpeedMs?: number;
|
|
30
|
+
animationStyle?: gsap.EaseString | gsap.EaseFunction;
|
|
31
|
+
logo?: string | null;
|
|
32
|
+
};
|
|
33
|
+
import type { CubeType } from '../core';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @import {Vector3Like} from 'three' */
|
|
2
|
+
/** @typedef {{ positon: Vector3Like, rotation: Vector3Like }} EdgePieceUserData*/
|
|
3
|
+
export class EdgePiece extends Object3D<import("three").Object3DEventMap> {
|
|
4
|
+
constructor();
|
|
5
|
+
frontSticker: EdgeSticker;
|
|
6
|
+
topSticker: EdgeSticker;
|
|
7
|
+
get stickers(): EdgeSticker[];
|
|
8
|
+
}
|
|
9
|
+
export class EdgeSticker extends Sticker {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export type EdgePieceUserData = {
|
|
13
|
+
positon: Vector3Like;
|
|
14
|
+
rotation: Vector3Like;
|
|
15
|
+
};
|
|
16
|
+
import { Object3D } from 'three';
|
|
17
|
+
import { Sticker } from './sticker';
|
|
18
|
+
import type { Vector3Like } from 'three';
|