-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.js
191 lines (180 loc) · 4.24 KB
/
constants.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import * as THREE from 'three';
/************** CONSTANTS **************/
export const PIECE_SIZE = 3;
export const ORIGIN = new THREE.Vector3(0, 0, 0);
export const X_AXIS = new THREE.Vector3(1, 0, 0);
export const Y_AXIS = new THREE.Vector3(0, 1, 0);
export const Z_AXIS = new THREE.Vector3(0, 0, 1);
export const NEG_X_AXIS = new THREE.Vector3(-1, 0, 0);
export const NEG_Y_AXIS = new THREE.Vector3(0, -1, 0);
export const NEG_Z_AXIS = new THREE.Vector3(0, 0, -1);
export const layerAxis = {
// layer moves
'U': Y_AXIS,
'R': X_AXIS,
'F': Z_AXIS,
'L': NEG_X_AXIS,
'D': NEG_Y_AXIS,
'B': NEG_Z_AXIS,
// slice moves
'M': NEG_X_AXIS,
'E': NEG_Y_AXIS,
'S': Z_AXIS,
};
export const rotationAxis = {
'x': X_AXIS,
'y': Y_AXIS,
'z': Z_AXIS
};
export const rotationLayers = {
// first list contains layers to be rotated clockwise
// second list contains layers to be rotated counter clockwise
'x': [['R'], ['M', 'L']],
'y': [['U'], ['E', 'D']],
'z': [['F', 'S'], ['B']],
}
// pieces of layers
export const layerPieceCoordinates = {
'U': [
[-1, 1, -1], [0, 1, -1], [1, 1, -1],
[-1, 1, 0], [0, 1, 0], [1, 1, 0],
[-1, 1, 1], [0, 1, 1], [1, 1, 1]
],
'D': [
[-1, -1, -1], [0, -1, -1], [1, -1, -1],
[-1, -1, 0], [0, -1, 0], [1, -1, 0],
[-1, -1, 1], [0, -1, 1], [1, -1, 1]
],
'R': [
[1, -1, -1], [1, 0, -1], [1, 1, -1],
[1, -1, 0], [1, 0, 0], [1, 1, 0],
[1, -1, 1], [1, 0, 1], [1, 1, 1]
],
'L': [
[-1, -1, -1], [-1, 0, -1], [-1, 1, -1],
[-1, -1, 0], [-1, 0, 0], [-1, 1, 0],
[-1, -1, 1], [-1, 0, 1], [-1, 1, 1]
],
'F': [
[-1, 1, 1], [0, 1, 1], [1, 1, 1],
[-1, 0, 1], [0, 0, 1], [1, 0, 1],
[-1, -1, 1], [0, -1, 1], [1, -1, 1]
],
'B': [
[-1, 1, -1], [0, 1, -1], [1, 1, -1],
[-1, 0, -1], [0, 0, -1], [1, 0, -1],
[-1, -1, -1], [0, -1, -1], [1, -1, -1]
],
'M': [
[0, -1, -1], [0, 0, -1], [0, 1, -1],
[0, -1, 0], [0, 0, 0], [0, 1, 0],
[0, -1, 1], [0, 0, 1], [0, 1, 1]
],
'E': [
[-1, 0, -1], [0, 0, -1], [1, 0, -1],
[-1, 0, 0], [0, 0, 0], [1, 0, 0],
[-1, 0, 1], [0, 0, 1], [1, 0, 1]
],
'S': [
[-1, 1, 0], [0, 1, 0], [1, 1, 0],
[-1, 0, 0], [0, 0, 0], [1, 0, 0],
[-1, -1, 0], [0, -1, 0], [1, -1, 0]
],
}
export const layerCornerRotations = {
'U': [
[0, 2, 0],
[2, 2, 0],
[2, 2, 2],
[0, 2, 2]
],
'R': [
[2, 2, 2],
[2, 2, 0],
[2, 0, 0],
[2, 0, 2]
],
'L': [
[0, 0, 0],
[0, 2, 0],
[0, 2, 2],
[0, 0, 2]
],
'D': [
[0, 0, 0],
[0, 0, 2],
[2, 0, 2],
[2, 0, 0]
],
'F': [
[0, 2, 2],
[2, 2, 2],
[2, 0, 2],
[0, 0, 2]
],
'B': [
[2, 2, 0],
[0, 2, 0],
[0, 0, 0],
[2, 0, 0]
],
// corner rotations for slice layers are just slice edge rotations
'M': [
[1, 0, 0],
[1, 2, 0],
[1, 2, 2],
[1, 0, 2]
],
'E': [
[0, 1, 0],
[0, 1, 2],
[2, 1, 2],
[2, 1, 0]
],
'S': [
[0, 2, 1],
[2, 2, 1],
[2, 0, 1],
[0, 0, 1]
],
};
export const layerEdgeRotations = {
'U': [
[1, 2, 0], [2, 2, 1], [1, 2, 2], [0, 2, 1]
],
'R': [
[2, 2, 1], [2, 1, 0], [2, 0, 1], [2, 1, 2]
],
'F': [
[1, 2, 2], [2, 1, 2], [1, 0, 2], [0, 1, 2]
],
'B': [
[1, 2, 0], [0, 1, 0], [1, 0, 0], [2, 1, 0]
],
'D': [
[1, 0, 0], [0, 0, 1], [1, 0, 2], [2, 0, 1]
],
'L': [
[0, 2, 1], [0, 1, 2], [0, 0, 1], [0, 1, 0]
],
// Edge rotations for slice layers is just center rotations
'M': [
[1, 2, 1], [1, 1, 2], [1, 0, 1], [1, 1, 0]
],
'E': [
[1, 1, 0], [0, 1, 1], [1, 1, 2], [2, 1, 1]
],
'S': [
[1, 2, 1], [2, 1, 1], [1, 0, 1], [0, 1, 1]
],
}
// Rubik's colors matrix
export const rubiksColorsHex = [
0xb71234, // R
0xff5800, // L
0xffffff, // U
0xffd500, // D
0x009b48, // F
0x0046ad // B
];
export const insideColor = 0x000000;