@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.
Files changed (76) hide show
  1. package/README.md +494 -63
  2. package/package.json +22 -12
  3. package/src/core/index.js +478 -0
  4. package/src/rubiksCube/index.js +3 -0
  5. package/src/rubiksCube/rubiksCubeController.js +111 -0
  6. package/src/rubiksCube3D/centerPiece.js +79 -0
  7. package/src/rubiksCube3D/cornerPiece.js +114 -0
  8. package/src/rubiksCube3D/cubeConfig.js +87 -0
  9. package/src/rubiksCube3D/cubeSettings.js +30 -0
  10. package/src/rubiksCube3D/edgePiece.js +51 -0
  11. package/src/rubiksCube3D/index.js +3 -0
  12. package/src/rubiksCube3D/rubiksCube3D.js +383 -0
  13. package/src/rubiksCube3D/sticker.js +38 -0
  14. package/src/state/index.js +4 -0
  15. package/src/state/rubiksCubeState.js +471 -0
  16. package/src/state/slice.js +236 -0
  17. package/src/state/stickerState.js +185 -0
  18. package/src/{cameraState.js → webComponent/cameraState.js} +17 -25
  19. package/src/webComponent/constants.js +67 -0
  20. package/src/{debouncer.js → webComponent/debouncer.js} +1 -1
  21. package/src/webComponent/index.js +7 -0
  22. package/src/webComponent/rubiksCubeElement.js +379 -0
  23. package/src/{settings.js → webComponent/settings.js} +47 -22
  24. package/tests/common.js +10 -0
  25. package/tests/core.test.js +56 -0
  26. package/tests/rubiksCube.solves.test.js +41 -0
  27. package/tests/rubiksCube3D.solves.test.js +185 -0
  28. package/tests/rubiksCubeState.solves.test.js +35 -0
  29. package/tests/setup.js +36 -0
  30. package/tests/testScrambles.js +194 -0
  31. package/types/core/index.d.ts +451 -0
  32. package/types/rubiksCube/index.d.ts +3 -0
  33. package/types/rubiksCube/rubiksCubeController.d.ts +62 -0
  34. package/types/rubiksCube3D/centerPiece.d.ts +27 -0
  35. package/types/rubiksCube3D/cornerPiece.d.ts +38 -0
  36. package/types/rubiksCube3D/cubeConfig.d.ts +32 -0
  37. package/types/rubiksCube3D/cubeSettings.d.ts +33 -0
  38. package/types/rubiksCube3D/edgePiece.d.ts +18 -0
  39. package/types/rubiksCube3D/index.d.ts +3 -0
  40. package/types/rubiksCube3D/rubiksCube3D.d.ts +120 -0
  41. package/types/rubiksCube3D/sticker.d.ts +18 -0
  42. package/types/state/index.d.ts +5 -0
  43. package/types/state/rubiksCubeState.d.ts +108 -0
  44. package/types/state/slice.d.ts +46 -0
  45. package/types/state/stickerState.d.ts +34 -0
  46. package/types/webComponent/cameraState.d.ts +22 -0
  47. package/types/webComponent/constants.d.ts +57 -0
  48. package/types/webComponent/index.d.ts +6 -0
  49. package/types/webComponent/rubiksCubeElement.d.ts +89 -0
  50. package/types/{settings.d.ts → webComponent/settings.d.ts} +9 -8
  51. package/src/core.js +0 -127
  52. package/src/cube/cube.js +0 -324
  53. package/src/cube/cubeRotation.js +0 -79
  54. package/src/cube/cubeSettings.js +0 -18
  55. package/src/cube/cubeState.js +0 -192
  56. package/src/cube/slice.js +0 -143
  57. package/src/index.js +0 -496
  58. package/src/schema.js +0 -22
  59. package/src/threejs/materials.js +0 -54
  60. package/src/threejs/pieces.js +0 -100
  61. package/src/threejs/stickers.js +0 -40
  62. package/types/cameraState.d.ts +0 -19
  63. package/types/core.d.ts +0 -125
  64. package/types/cube/cube.d.ts +0 -102
  65. package/types/cube/cubeRotation.d.ts +0 -33
  66. package/types/cube/cubeSettings.d.ts +0 -17
  67. package/types/cube/cubeState.d.ts +0 -16
  68. package/types/cube/slice.d.ts +0 -15
  69. package/types/index.d.ts +0 -65
  70. package/types/schema.d.ts +0 -11
  71. package/types/threejs/materials.d.ts +0 -21
  72. package/types/threejs/pieces.d.ts +0 -28
  73. package/types/threejs/stickers.d.ts +0 -6
  74. /package/src/{globals.ts → webComponent/globals.ts} +0 -0
  75. /package/types/{debouncer.d.ts → webComponent/debouncer.d.ts} +0 -0
  76. /package/types/{globals.d.ts → webComponent/globals.d.ts} +0 -0
@@ -1,54 +0,0 @@
1
- // @ts-check
2
- import { MeshStandardMaterial, MeshBasicMaterial } from 'three';
3
- import { FaceColours, Faces } from '../core';
4
- /** @typedef {{type: "sticker", face: import('../core').Face , color: import('../core').FaceColour}} StickerUserData */
5
- /** @typedef {{type: "core" }} CoreUserData */
6
- export default class Materials {
7
- static front = new MeshStandardMaterial({
8
- color: '#2cbf13',
9
- metalness: 0,
10
- roughness: 0.4,
11
- /** @type {StickerUserData} */
12
- userData: { type: 'sticker', face: Faces.front, color: FaceColours.front },
13
- });
14
- static back = new MeshStandardMaterial({
15
- color: 'blue',
16
- metalness: 0,
17
- roughness: 0.4,
18
- /** @type {StickerUserData} */
19
- userData: { type: 'sticker', face: Faces.back, color: FaceColours.back },
20
- });
21
- static up = new MeshStandardMaterial({
22
- color: 'white',
23
- metalness: 0,
24
- roughness: 0.4,
25
- /** @type {StickerUserData} */
26
- userData: { type: 'sticker', face: Faces.up, color: FaceColours.up },
27
- });
28
- static down = new MeshStandardMaterial({
29
- color: 'yellow',
30
- metalness: 0,
31
- roughness: 0.4,
32
- /** @type {StickerUserData} */
33
- userData: { type: 'sticker', face: Faces.down, color: FaceColours.down },
34
- });
35
- static left = new MeshStandardMaterial({
36
- color: '#fc9a05',
37
- metalness: 0,
38
- roughness: 0.4,
39
- /** @type {StickerUserData} */
40
- userData: { type: 'sticker', face: Faces.left, color: FaceColours.left },
41
- });
42
- static right = new MeshStandardMaterial({
43
- color: 'red',
44
- metalness: 0,
45
- roughness: 0.4,
46
- /** @type {StickerUserData} */
47
- userData: { type: 'sticker', face: Faces.right, color: FaceColours.right },
48
- });
49
- static core = new MeshBasicMaterial({
50
- color: 'black',
51
- /** @type {CoreUserData} */
52
- userData: { type: 'core' },
53
- });
54
- }
@@ -1,100 +0,0 @@
1
- // @ts-check
2
- import { Group, BoxGeometry, Mesh, SphereGeometry, Material } from 'three';
3
- import Stickers from './stickers';
4
- import Materials from './materials';
5
-
6
- /**
7
- * @param {Material} frontMaterial
8
- * @param {Material} rightMaterial
9
- * @param {Material} topMaterial
10
- * @param {Material} coreMaterial
11
- * @returns {Group}
12
- */
13
- export function createCornerGroup(frontMaterial, rightMaterial, topMaterial, coreMaterial) {
14
- const group = new Group();
15
- const boxGeom = new BoxGeometry(1, 1, 1);
16
- const boxMesh = new Mesh(boxGeom, coreMaterial);
17
- boxMesh.userData = { type: 'piece' };
18
- group.add(boxMesh);
19
-
20
- // front
21
- const frontSticker = new Mesh(Stickers.corner, frontMaterial);
22
- frontSticker.userData = { type: 'sticker' };
23
- frontSticker.position.set(0, 0, 0.5);
24
- frontSticker.rotation.set(0, 0, 0);
25
- group.add(frontSticker);
26
-
27
- //right
28
- const rightSticker = new Mesh(Stickers.corner, rightMaterial);
29
- rightSticker.userData = { type: 'sticker' };
30
- rightSticker.position.set(0.5, 0, 0);
31
- rightSticker.rotation.set(Math.PI / 2, Math.PI / 2, 0);
32
- group.add(rightSticker);
33
-
34
- //white/yellow
35
- const topSticker = new Mesh(Stickers.corner, topMaterial);
36
- topSticker.userData = { type: 'sticker' };
37
- topSticker.position.set(0, 0.5, 0);
38
- topSticker.rotation.set(-Math.PI / 2, 0, -Math.PI / 2);
39
- group.add(topSticker);
40
-
41
- return group;
42
- }
43
-
44
- /**
45
- * @param {Material} frontMaterial
46
- * @param {Material} topMaterial
47
- * @param {Material} coreMaterial
48
- * @returns {Group}
49
- */
50
- export function createEdgeGroup(frontMaterial, topMaterial, coreMaterial) {
51
- const group = new Group();
52
- const boxGeom = new BoxGeometry(1, 1, 1);
53
- const boxMesh = new Mesh(boxGeom, coreMaterial);
54
- boxMesh.userData = { type: 'piece' };
55
- group.add(boxMesh);
56
-
57
- // front
58
- const frontSticker = new Mesh(Stickers.edge, frontMaterial);
59
- frontSticker.userData = { type: 'sticker' };
60
- frontSticker.position.set(0, 0, 0.5);
61
- frontSticker.rotation.set(0, 0, 0);
62
- group.add(frontSticker);
63
-
64
- // top
65
- const topSticker = new Mesh(Stickers.edge, topMaterial);
66
- topSticker.userData = { type: 'sticker' };
67
- topSticker.position.set(0, 0.5, 0);
68
- topSticker.rotation.set(-Math.PI / 2, 0, Math.PI);
69
- group.add(topSticker);
70
-
71
- return group;
72
- }
73
-
74
- /**
75
- * @param {Material} frontMaterial
76
- * @param {Material} coreMaterial
77
- * @returns {Group}
78
- */
79
- export function createCenterGroup(frontMaterial, coreMaterial) {
80
- const group = new Group();
81
- const boxGeom = new BoxGeometry(1, 1, 1);
82
- const boxMesh = new Mesh(boxGeom, coreMaterial);
83
- boxMesh.userData = { type: 'piece' };
84
- group.add(boxMesh);
85
-
86
- const frontSticker = new Mesh(Stickers.center, frontMaterial);
87
- frontSticker.userData = { type: 'sticker' };
88
- frontSticker.position.set(0, 0, 0.5);
89
- frontSticker.rotation.set(0, 0, 0);
90
- group.add(frontSticker);
91
-
92
- return group;
93
- }
94
-
95
- /**
96
- * @returns {Mesh}
97
- */
98
- export function createCoreMesh() {
99
- return new Mesh(new SphereGeometry(1.53), Materials.core);
100
- }
@@ -1,40 +0,0 @@
1
- // @ts-check
2
- import { SVGLoader } from 'three/examples/jsm/Addons.js';
3
- import { ExtrudeGeometry } from 'three';
4
-
5
- const loader = new SVGLoader();
6
- const cornerSVG = loader.parse(`
7
- <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://boxy-svg.com">
8
- <path d="M 25 0 H 500 V 500 H 0 V 25 A 25 25 0 0 1 25 0 Z" bx:shape="rect 0 0 500 500 25 0 0 0 1@a864c1ee"/>
9
- </svg>
10
- `);
11
- const edgeSVG = loader.parse(`
12
- <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
13
- <path d="M 150 0 L 350 0 C 450 0 500 50 500 120 L 500 500 L 0 500 L 0 120 C 0 50 50 0 150 0 Z"></path>
14
- </svg>
15
- `);
16
- const centerSVG = loader.parse(`
17
- <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
18
- <path d="M 120 0 L 380 0 C 450 0 500 50 500 120 L 500 380 C 500 450 450 500 380 500 L 120 500 C 50 500 0 450 0 380 L 0 120 C 0 50 50 0 120 0 Z"></path>
19
- </svg>
20
- `);
21
-
22
- export default class Stickers {
23
- static center = new ExtrudeGeometry(SVGLoader.createShapes(centerSVG.paths[0])[0], {
24
- depth: 15,
25
- })
26
- .scale(0.002, 0.002, 0.002)
27
- .translate(-0.5, -0.5, 0);
28
-
29
- static edge = new ExtrudeGeometry(SVGLoader.createShapes(edgeSVG.paths[0])[0], {
30
- depth: 15,
31
- })
32
- .scale(0.002, 0.002, 0.002)
33
- .translate(-0.5, -0.5, 0);
34
-
35
- static corner = new ExtrudeGeometry(SVGLoader.createShapes(cornerSVG.paths[0])[0], {
36
- depth: 15,
37
- })
38
- .scale(0.002, 0.002, 0.002)
39
- .translate(-0.5, -0.5, 0);
40
- }
@@ -1,19 +0,0 @@
1
- export class CameraState {
2
- /**
3
- * @param {boolean} up
4
- * @param {boolean} right
5
- */
6
- constructor(up?: boolean, right?: boolean);
7
- /** @type {boolean} */
8
- Up: boolean;
9
- /** @type {boolean} */
10
- Right: boolean;
11
- /**
12
- * @param {import("./core").PeekType} peekType
13
- */
14
- peekCamera(peekType: import("./core").PeekType): void;
15
- /**
16
- * @returns {import("./core").PeekState}
17
- */
18
- toPeekState(): import("./core").PeekState;
19
- }
package/types/core.d.ts DELETED
@@ -1,125 +0,0 @@
1
- /**
2
- * @typedef {typeof Movements[keyof typeof Movements]} Movement
3
- */
4
- export const Movements: Readonly<{
5
- R: "R";
6
- R2: "R2";
7
- RP: "R'";
8
- L: "L";
9
- L2: "L2";
10
- LP: "L'";
11
- U: "U";
12
- U2: "U2";
13
- UP: "U'";
14
- D: "D";
15
- D2: "D2";
16
- DP: "D'";
17
- F: "F";
18
- F2: "F2";
19
- FP: "F'";
20
- B: "B";
21
- B2: "B2";
22
- BP: "B'";
23
- r: "r";
24
- r2: "r2";
25
- rP: "r'";
26
- l: "l";
27
- l2: "l2";
28
- lP: "l'";
29
- u: "u";
30
- u2: "u2";
31
- uP: "u'";
32
- d: "d";
33
- d2: "d2";
34
- dP: "d'";
35
- f: "f";
36
- f2: "f2";
37
- fP: "f'";
38
- b: "b";
39
- b2: "b2";
40
- bP: "b'";
41
- M: "M";
42
- M2: "M2";
43
- MP: "M'";
44
- E: "E";
45
- E2: "E2";
46
- EP: "E'";
47
- S: "S";
48
- S2: "S2";
49
- SP: "S'";
50
- }>;
51
- /**
52
- * @typedef {typeof Rotations[keyof typeof Rotations]} Rotation
53
- */
54
- export const Rotations: Readonly<{
55
- x: "x";
56
- x2: "x2";
57
- xP: "x'";
58
- y: "y";
59
- y2: "y2";
60
- yP: "y'";
61
- z: "z";
62
- z2: "z2";
63
- zP: "z'";
64
- }>;
65
- /**
66
- * @typedef {typeof Axi[keyof typeof Axi]} Axis
67
- */
68
- export const Axi: Readonly<{
69
- x: "x";
70
- y: "y";
71
- z: "z";
72
- }>;
73
- /**
74
- * @typedef {typeof Faces [keyof typeof Faces]} Face
75
- */
76
- export const Faces: Readonly<{
77
- up: "U";
78
- down: "D";
79
- left: "L";
80
- right: "R";
81
- front: "F";
82
- back: "B";
83
- }>;
84
- /**
85
- * @typedef {typeof FaceColours [keyof typeof FaceColours]} FaceColour
86
- */
87
- export const FaceColours: Readonly<{
88
- up: "white";
89
- down: "yellow";
90
- left: "orange";
91
- right: "red";
92
- front: "green";
93
- back: "blue";
94
- }>;
95
- /**
96
- * @typedef {typeof PeekTypes [keyof typeof PeekTypes]} PeekType
97
- */
98
- export const PeekTypes: Readonly<{
99
- Horizontal: "horizontal";
100
- Vertical: "vertical";
101
- Right: "right";
102
- Left: "left";
103
- Up: "up";
104
- Down: "down";
105
- RightUp: "rightUp";
106
- RightDown: "rightDown";
107
- LeftUp: "leftUp";
108
- LeftDown: "leftDown";
109
- }>;
110
- /**
111
- * @typedef {typeof PeekStates [keyof typeof PeekStates]} PeekState
112
- */
113
- export const PeekStates: Readonly<{
114
- RightUp: "rightUp";
115
- RightDown: "rightDown";
116
- LeftUp: "leftUp";
117
- LeftDown: "leftDown";
118
- }>;
119
- export type Movement = (typeof Movements)[keyof typeof Movements];
120
- export type Rotation = (typeof Rotations)[keyof typeof Rotations];
121
- export type Axis = (typeof Axi)[keyof typeof Axi];
122
- export type Face = (typeof Faces)[keyof typeof Faces];
123
- export type FaceColour = (typeof FaceColours)[keyof typeof FaceColours];
124
- export type PeekType = (typeof PeekTypes)[keyof typeof PeekTypes];
125
- export type PeekState = (typeof PeekStates)[keyof typeof PeekStates];
@@ -1,102 +0,0 @@
1
- /** @typedef {{ up: import('../core').Face[][], down: import('../core').Face[][], front: import('../core').Face[][], back: import('../core').Face[][], left: import('../core').Face[][], right: import('../core').Face[][] }} StickerState*/
2
- export default class Cube {
3
- /**
4
- * @param {CubeSettings} cubeSettings
5
- */
6
- constructor(cubeSettings: CubeSettings);
7
- /** @type {CubeSettings} */
8
- cubeSettings: CubeSettings;
9
- /** @type {Group} */
10
- group: Group;
11
- /** @type {Group} */
12
- rotationGroup: Group;
13
- /** @type {CubeRotation[]} */
14
- rotationQueue: CubeRotation[];
15
- /** @type {CubeRotation | undefined} */
16
- currentRotation: CubeRotation | undefined;
17
- /** @type {number | undefined} */
18
- _matchSpeed: number | undefined;
19
- /** @type {number} */
20
- _lastGap: number;
21
- /** @type {StickerState} */
22
- currentState: StickerState;
23
- /**
24
- * adds threejs objects to group
25
- */
26
- init(): Group<import("three").Object3DEventMap>;
27
- /**
28
- * update the cube and continue any rotations
29
- */
30
- update(): void;
31
- /**
32
- * Updates the gap of the pieces. To be used when the cube is not rotating
33
- * @returns {void}
34
- */
35
- updateGap(): void;
36
- /**
37
- *
38
- * calculates the current speed of the current rotation in ms.
39
- * calculation is dependent on animation style and animation speed settings
40
- * - exponential: speeds up rotations depending on the queue length
41
- * - next: an animation speed of 0 when there is another animation in the queue
42
- * - match: will match the speed of rotations to the frequency of key presses.
43
- * - fixed: will return a constant value
44
- * @returns {number}
45
- */
46
- getRotationSpeed(): number;
47
- /**
48
- * Complete the current rotation and reset the cube
49
- * @param {(state:string) => boolean} completedCallback
50
- * @returns {void}
51
- */
52
- reset(completedCallback: (state: string) => boolean): void;
53
- /**
54
- * Adds pieces in the rotationGroup back into the main group.
55
- * @returns {void}
56
- */
57
- clearRotationGroup(): void;
58
- /**
59
- * @param {string} eventId
60
- * @param {import('../core').Rotation} rotation
61
- * @param {((state: string) => void )} completedCallback
62
- * @param {((reason: string) => void )} failedCallback
63
- */
64
- rotation(eventId: string, rotation: import("../core").Rotation, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void)): void;
65
- /**
66
- * @param {string} eventId
67
- * @param {import('../core').Movement} movement
68
- * @param {((state: string) => void )} completedCallback
69
- * @param {((reason: string) => void )} failedCallback
70
- */
71
- movement(eventId: string, movement: import("../core").Movement, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void)): void;
72
- /**
73
- * @param {import('./slice').Slice} slice
74
- * @returns {Object3D[]}
75
- */
76
- getRotationLayer(slice: import("./slice").Slice): Object3D[];
77
- /**
78
- * @returns {string}
79
- */
80
- get kociembaState(): string;
81
- /**
82
- * @param {StickerState} stickerState
83
- * @returns {string}
84
- */
85
- toKociemba(stickerState: StickerState): string;
86
- /**
87
- * @returns {StickerState}
88
- */
89
- getStickerState(): StickerState;
90
- }
91
- export type StickerState = {
92
- up: import("../core").Face[][];
93
- down: import("../core").Face[][];
94
- front: import("../core").Face[][];
95
- back: import("../core").Face[][];
96
- left: import("../core").Face[][];
97
- right: import("../core").Face[][];
98
- };
99
- import CubeSettings from './cubeSettings';
100
- import { Group } from 'three';
101
- import { CubeRotation } from './cubeRotation';
102
- import { Object3D } from 'three';
@@ -1,33 +0,0 @@
1
- export class CubeRotation {
2
- /**
3
- * @param {string} eventId
4
- * @param {import('./slice').Slice} slice
5
- * @param {((state: string) => void )} completedCallback
6
- * @param {((reason: string) => void )} failedCallback
7
- */
8
- constructor(eventId: string, slice: import("./slice").Slice, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void));
9
- /** @type {((state: string) => void )} */
10
- completedCallback: ((state: string) => void);
11
- /** @type {((reason: string) => void )} */
12
- failedCallback: ((reason: string) => void);
13
- /** @type {string} */
14
- eventId: string;
15
- /** @type {import('./slice').Slice} */
16
- slice: import("./slice").Slice;
17
- /** @type {"pending" | "initialised" | "inProgress" | "complete" | "disposed"} */
18
- status: "pending" | "initialised" | "inProgress" | "complete" | "disposed";
19
- /** @type {number} */
20
- timestampMs: number;
21
- /** @type {number | undefined} */
22
- _lastUpdatedTimeMs: number | undefined;
23
- /** @type {number} */
24
- _rotationPercentage: number;
25
- initialise(): void;
26
- /**
27
- *
28
- * @param {Group} rotationGroup
29
- * @param {number} speedMs
30
- */
31
- update(rotationGroup: Group, speedMs: number): void;
32
- }
33
- import { Group } from 'three';
@@ -1,17 +0,0 @@
1
- /** @typedef {"exponential" | "next" | "fixed" | "match"} AnimationStyle */
2
- export default class CubeSettings {
3
- /**
4
- *
5
- * @param {number} pieceGap
6
- * @param {number} animationSpeed
7
- * @param {AnimationStyle} animationStyle
8
- */
9
- constructor(pieceGap: number, animationSpeed: number, animationStyle: AnimationStyle);
10
- /** @type {number} pieceGap */
11
- pieceGap: number;
12
- /** @type {number} pieceGap */
13
- animationSpeedMs: number;
14
- /** @type {AnimationStyle} pieceGap */
15
- animationStyle: AnimationStyle;
16
- }
17
- export type AnimationStyle = "exponential" | "next" | "fixed" | "match";
@@ -1,16 +0,0 @@
1
- export type vector = {
2
- x: number;
3
- y: number;
4
- z: number;
5
- };
6
- export type state = {
7
- position: vector;
8
- rotation: vector;
9
- type: "corner" | "edge" | "center";
10
- group: Group;
11
- };
12
- /**
13
- * @return {state[]}
14
- */
15
- export function createCubeState(): state[];
16
- import { Group } from 'three';
@@ -1,15 +0,0 @@
1
- /**
2
- * @param {import("../core").Movement} movement
3
- * @returns {Slice}
4
- */
5
- export default function GetMovementSlice(movement: import("../core").Movement): Slice;
6
- /**
7
- * @param {import("../core").Rotation} rotation
8
- * @returns {Slice}
9
- */
10
- export function GetRotationSlice(rotation: import("../core").Rotation): Slice;
11
- export type Slice = {
12
- axis: import("../core").Axis;
13
- layers: (-1 | 0 | 1)[];
14
- direction: 1 | -1 | 2 | -2;
15
- };
package/types/index.d.ts DELETED
@@ -1,65 +0,0 @@
1
- /// <reference path="globals.d.ts" preserve="true" />
2
- export class RubiksCubeElement extends HTMLElement {
3
- /**
4
- * @param {string} tagName the name of the tag to register the web component under
5
- */
6
- static register(tagName?: string): void;
7
- static get observedAttributes(): ("piece-gap" | "animation-speed-ms" | "animation-style" | "camera-speed-ms" | "camera-radius" | "camera-field-of-view" | "camera-peek-angle-horizontal" | "camera-peek-angle-vertical")[];
8
- /** @private @type {HTMLCanvasElement} */
9
- private canvas;
10
- /** @private @type {Settings} */
11
- private settings;
12
- /** @private @type {CubeSettings} */
13
- private cubeSettings;
14
- /**
15
- * @param {string} name
16
- * @param {string} oldVal
17
- * @param {string} newVal
18
- * */
19
- attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
20
- connectedCallback(): void;
21
- /** @private */
22
- private animateCameraSetting;
23
- /** @private */
24
- private updateCameraFOV;
25
- /** @import {Movement} from './core' */
26
- /** @internal @typedef {{eventId: string, move: Movement}} MovementEvent */
27
- /** @internal @typedef {{eventId: string, move: Movement, state: string}} MovementCompleteEventData */
28
- /** @internal @typedef {{eventId: string, move: Movement, reason: string}} MovementFailedEventData */
29
- /**
30
- * @param {Movement} move
31
- * @returns {Promise<string>}
32
- */
33
- move(move: Movement): Promise<string>;
34
- /** @import {Rotation} from './core' */
35
- /** @internal @typedef {{eventId: string, rotation: Rotation}} RotationEventData */
36
- /** @internal @typedef {{eventId: string, rotation: Rotation, state: string, }} RotationCompleteEventData*/
37
- /** @internal @typedef {{eventId: string, rotation: Rotation, reason: string, }} RotationFailedEventData*/
38
- /**
39
- * @param {Rotation} rotation
40
- * @returns {Promise<string>}
41
- */
42
- rotate(rotation: Rotation): Promise<string>;
43
- /** @internal @typedef {{state: string }} ResetCompleteEventData */
44
- /**
45
- * @returns {Promise<string>}
46
- */
47
- reset(): Promise<string>;
48
- /** @import {PeekType} from './core' */
49
- /** @internal @typedef {{eventId: string, peekType: PeekType}} CameraPeekEventData */
50
- /** @import {PeekState} from './core' */
51
- /** @internal @typedef {{eventId: string, peekState: PeekState }} CameraPeekCompleteEventData */
52
- /**
53
- * This function changes the camera position to one of four states depending on the arguments passed.
54
- *
55
- * @param {PeekType} peekType
56
- * @returns {Promise<PeekState>}
57
- */
58
- peek(peekType: PeekType): Promise<PeekState>;
59
- /** @private */
60
- private init;
61
- }
62
- import type { Movement } from './core';
63
- import type { Rotation } from './core';
64
- import type { PeekType } from './core';
65
- import type { PeekState } from './core';
package/types/schema.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export namespace AttributeNames {
2
- let pieceGap: "piece-gap";
3
- let animationSpeed: "animation-speed-ms";
4
- let animationStyle: "animation-style";
5
- let cameraSpeed: "camera-speed-ms";
6
- let cameraRadius: "camera-radius";
7
- let cameraFieldOfView: "camera-field-of-view";
8
- let cameraPeekAngleHorizontal: "camera-peek-angle-horizontal";
9
- let cameraPeekAngleVertical: "camera-peek-angle-vertical";
10
- }
11
- export type AttributeName = (typeof AttributeNames)[keyof typeof AttributeNames];
@@ -1,21 +0,0 @@
1
- /** @typedef {{type: "sticker", face: import('../core').Face , color: import('../core').FaceColour}} StickerUserData */
2
- /** @typedef {{type: "core" }} CoreUserData */
3
- export default class Materials {
4
- static front: MeshStandardMaterial;
5
- static back: MeshStandardMaterial;
6
- static up: MeshStandardMaterial;
7
- static down: MeshStandardMaterial;
8
- static left: MeshStandardMaterial;
9
- static right: MeshStandardMaterial;
10
- static core: MeshBasicMaterial;
11
- }
12
- export type StickerUserData = {
13
- type: "sticker";
14
- face: import("../core").Face;
15
- color: import("../core").FaceColour;
16
- };
17
- export type CoreUserData = {
18
- type: "core";
19
- };
20
- import { MeshStandardMaterial } from 'three';
21
- import { MeshBasicMaterial } from 'three';
@@ -1,28 +0,0 @@
1
- /**
2
- * @param {Material} frontMaterial
3
- * @param {Material} rightMaterial
4
- * @param {Material} topMaterial
5
- * @param {Material} coreMaterial
6
- * @returns {Group}
7
- */
8
- export function createCornerGroup(frontMaterial: Material, rightMaterial: Material, topMaterial: Material, coreMaterial: Material): Group;
9
- /**
10
- * @param {Material} frontMaterial
11
- * @param {Material} topMaterial
12
- * @param {Material} coreMaterial
13
- * @returns {Group}
14
- */
15
- export function createEdgeGroup(frontMaterial: Material, topMaterial: Material, coreMaterial: Material): Group;
16
- /**
17
- * @param {Material} frontMaterial
18
- * @param {Material} coreMaterial
19
- * @returns {Group}
20
- */
21
- export function createCenterGroup(frontMaterial: Material, coreMaterial: Material): Group;
22
- /**
23
- * @returns {Mesh}
24
- */
25
- export function createCoreMesh(): Mesh;
26
- import { Material } from 'three';
27
- import { Group } from 'three';
28
- import { Mesh } from 'three';
@@ -1,6 +0,0 @@
1
- export default class Stickers {
2
- static center: ExtrudeGeometry;
3
- static edge: ExtrudeGeometry;
4
- static corner: ExtrudeGeometry;
5
- }
6
- import { ExtrudeGeometry } from 'three';
File without changes