@houstonp/rubiks-cube 2.1.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 +304 -77
- package/package.json +18 -8
- package/src/{core.js → core/index.js} +72 -41
- package/src/rubiksCube/index.js +3 -0
- package/src/rubiksCube/rubiksCubeController.js +111 -0
- package/src/{three → rubiksCube3D}/centerPiece.js +37 -2
- package/src/{three → rubiksCube3D}/cornerPiece.js +56 -2
- package/src/rubiksCube3D/cubeConfig.js +87 -0
- package/src/rubiksCube3D/cubeSettings.js +30 -0
- package/src/{three → rubiksCube3D}/edgePiece.js +2 -1
- package/src/rubiksCube3D/index.js +3 -0
- package/src/rubiksCube3D/rubiksCube3D.js +383 -0
- package/src/{three → rubiksCube3D}/sticker.js +5 -4
- 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/{camera → webComponent}/cameraState.js +17 -25
- package/src/webComponent/constants.js +67 -0
- package/src/webComponent/index.js +7 -0
- package/src/webComponent/rubiksCubeElement.js +379 -0
- package/src/{settings.js → webComponent/settings.js} +36 -23
- package/tests/common.js +3 -20
- 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/testScrambles.js +194 -0
- package/types/{core.d.ts → core/index.d.ts} +45 -48
- 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/{three → rubiksCube3D}/edgePiece.d.ts +5 -3
- 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} +5 -8
- package/src/cube/animationSlice.js +0 -205
- package/src/cube/animationState.js +0 -96
- package/src/cube/cubeSettings.js +0 -19
- package/src/cube/cubeState.js +0 -337
- package/src/cube/stickerState.js +0 -188
- package/src/index.js +0 -621
- package/src/three/cube.js +0 -492
- package/tests/cube.five.test.js +0 -126
- package/tests/cube.four.test.js +0 -126
- package/tests/cube.seven.test.js +0 -126
- package/tests/cube.six.test.js +0 -126
- package/tests/cube.three.test.js +0 -151
- package/tests/cube.two.test.js +0 -125
- package/types/camera/cameraState.d.ts +0 -19
- package/types/cube/animationSlice.d.ts +0 -26
- package/types/cube/animationState.d.ts +0 -41
- package/types/cube/cubeSettings.d.ts +0 -17
- package/types/cube/cubeState.d.ts +0 -47
- package/types/cube/stickerState.d.ts +0 -21
- package/types/index.d.ts +0 -87
- package/types/three/centerPiece.d.ts +0 -15
- package/types/three/cornerPiece.d.ts +0 -24
- package/types/three/cube.d.ts +0 -130
- package/types/three/sticker.d.ts +0 -15
- /package/src/{debouncer.js → webComponent/debouncer.js} +0 -0
- /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
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @typedef {{axis: Axis, layers: number[], direction: number}} Slice */
|
|
2
|
-
/**
|
|
3
|
-
* @param {import('../core').Movement } outerBlockMovement
|
|
4
|
-
* @param {import('../core').CubeType} cubeType
|
|
5
|
-
* @param {boolean} prioritiseStandardMovement
|
|
6
|
-
* @returns {Slice | undefined}
|
|
7
|
-
*/
|
|
8
|
-
export function GetLayerSlice(outerBlockMovement: import("../core").Movement, cubeType: import("../core").CubeType, prioritiseStandardMovement?: boolean): Slice | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* @param {import("../core").Rotation} rotation
|
|
11
|
-
* @param {import('../core').CubeType} cubeType
|
|
12
|
-
* @returns {Slice | undefined}
|
|
13
|
-
*/
|
|
14
|
-
export function GetRotationSlice(rotation: import("../core").Rotation, cubeType: import("../core").CubeType): Slice | undefined;
|
|
15
|
-
/** @typedef {typeof Axi[keyof typeof Axi]} Axis */
|
|
16
|
-
export const Axi: Readonly<{
|
|
17
|
-
x: "x";
|
|
18
|
-
y: "y";
|
|
19
|
-
z: "z";
|
|
20
|
-
}>;
|
|
21
|
-
export type Slice = {
|
|
22
|
-
axis: Axis;
|
|
23
|
-
layers: number[];
|
|
24
|
-
direction: number;
|
|
25
|
-
};
|
|
26
|
-
export type Axis = (typeof Axi)[keyof typeof Axi];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** @typedef {AnimationStatus[keyof AnimationStatus]} AnimationStatusType */
|
|
2
|
-
export const AnimationStatus: Readonly<{
|
|
3
|
-
Pending: "pending";
|
|
4
|
-
Initialised: "initialised";
|
|
5
|
-
InProgress: "inProgress";
|
|
6
|
-
Complete: "complete";
|
|
7
|
-
Disposed: "disposed";
|
|
8
|
-
}>;
|
|
9
|
-
export class AnimationState {
|
|
10
|
-
/**
|
|
11
|
-
* @param {import('./animationSlice').Slice} slice
|
|
12
|
-
* @param {((state: string) => void )} completedCallback
|
|
13
|
-
* @param {((reason: string) => void )} failedCallback
|
|
14
|
-
*/
|
|
15
|
-
constructor(slice: import("./animationSlice").Slice, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void));
|
|
16
|
-
/** @type {((state: string) => void )} */
|
|
17
|
-
completedCallback: ((state: string) => void);
|
|
18
|
-
/** @type {((reason: string) => void )} */
|
|
19
|
-
failedCallback: ((reason: string) => void);
|
|
20
|
-
/** @type {import('./animationSlice').Slice} */
|
|
21
|
-
slice: import("./animationSlice").Slice;
|
|
22
|
-
/** @type {AnimationStatusType} */
|
|
23
|
-
status: AnimationStatusType;
|
|
24
|
-
/** @type {number} */
|
|
25
|
-
timestampMs: number;
|
|
26
|
-
/** @type {number | undefined} */
|
|
27
|
-
_lastUpdatedTimeMs: number | undefined;
|
|
28
|
-
/** @type {number} */
|
|
29
|
-
_rotationPercentage: number;
|
|
30
|
-
initialise(): void;
|
|
31
|
-
/** @param {string} state */
|
|
32
|
-
complete(state: string): void;
|
|
33
|
-
/** @param {string} reason */
|
|
34
|
-
abort(reason: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* @param {number} speedMs
|
|
37
|
-
* @returns {number} rotationIncrement
|
|
38
|
-
*/
|
|
39
|
-
update(speedMs: number): number;
|
|
40
|
-
}
|
|
41
|
-
export type AnimationStatusType = "pending" | "initialised" | "inProgress" | "complete" | "disposed";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default class CubeSettings {
|
|
2
|
-
/**
|
|
3
|
-
* @param {import('../core').CubeType} cubeType
|
|
4
|
-
* @param {number} pieceGap
|
|
5
|
-
* @param {number} animationSpeed
|
|
6
|
-
* @param {import('../core').AnimationStyle} animationStyle
|
|
7
|
-
*/
|
|
8
|
-
constructor(pieceGap: number, animationSpeed: number, animationStyle: import("../core").AnimationStyle, cubeType: import("../core").CubeType);
|
|
9
|
-
/** @type {number} pieceGap */
|
|
10
|
-
pieceGap: number;
|
|
11
|
-
/** @type {import("../core").CubeType} */
|
|
12
|
-
cubeType: import("../core").CubeType;
|
|
13
|
-
/** @type {number} pieceGap */
|
|
14
|
-
animationSpeedMs: number;
|
|
15
|
-
/** @type {import('../core').AnimationStyle} pieceGap */
|
|
16
|
-
animationStyle: import("../core").AnimationStyle;
|
|
17
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** @typedef {{cubeType: import('../core').CubeType, layers: number[], pieceSize: number, coreSize: number,initialStickerState: import('./stickerState').StickerState, outerLayerMultiplier: number, corners: state[], edges: state[], centers: state[]}} CubeInfo */
|
|
2
|
-
/**
|
|
3
|
-
* @param {import("../core").CubeType} cubeType
|
|
4
|
-
* @return {CubeInfo}
|
|
5
|
-
*/
|
|
6
|
-
export function getCubeInfo(cubeType: import("../core").CubeType): CubeInfo;
|
|
7
|
-
export namespace FaceColors {
|
|
8
|
-
let B: string;
|
|
9
|
-
let D: string;
|
|
10
|
-
let F: string;
|
|
11
|
-
let L: string;
|
|
12
|
-
let R: string;
|
|
13
|
-
let U: string;
|
|
14
|
-
}
|
|
15
|
-
export function ColorToFace(color: import("three").ColorRepresentation): import("../core").Face;
|
|
16
|
-
export function outlerLayerMultiplier(cubeType: import("../core").CubeType): number;
|
|
17
|
-
export function coreSize(cubeType: import("../core").CubeType): number;
|
|
18
|
-
export function getMiddleLayers(cubeType: import("../core").CubeType): number[];
|
|
19
|
-
export function getAllLayers(cubeType: import("../core").CubeType): number[];
|
|
20
|
-
export function pieceSize(cubeType: import("../core").CubeType): number;
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {{position: vector, rotation: vector}} state
|
|
23
|
-
*/
|
|
24
|
-
/** @type {state[]} */
|
|
25
|
-
export const corners: state[];
|
|
26
|
-
export function centers(layers: number[]): state[];
|
|
27
|
-
export function edges(layers: number[]): state[];
|
|
28
|
-
export type CubeInfo = {
|
|
29
|
-
cubeType: import("../core").CubeType;
|
|
30
|
-
layers: number[];
|
|
31
|
-
pieceSize: number;
|
|
32
|
-
coreSize: number;
|
|
33
|
-
initialStickerState: import("./stickerState").StickerState;
|
|
34
|
-
outerLayerMultiplier: number;
|
|
35
|
-
corners: state[];
|
|
36
|
-
edges: state[];
|
|
37
|
-
centers: state[];
|
|
38
|
-
};
|
|
39
|
-
export type vector = {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
z: number;
|
|
43
|
-
};
|
|
44
|
-
export type state = {
|
|
45
|
-
position: vector;
|
|
46
|
-
rotation: vector;
|
|
47
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {StickerState} stickerState
|
|
3
|
-
* @returns {string}
|
|
4
|
-
*/
|
|
5
|
-
export function toKociemba(stickerState: StickerState): string;
|
|
6
|
-
/**
|
|
7
|
-
* @param {string} kociembaString
|
|
8
|
-
* @param {import('../core').CubeType} cubeType
|
|
9
|
-
* @returns {StickerState | undefined} stickerState
|
|
10
|
-
*/
|
|
11
|
-
export function fromKociemba(kociembaString: string, cubeType: import("../core").CubeType): StickerState | undefined;
|
|
12
|
-
export function defaultStickerState(cubeType: import("../core").CubeType): StickerState;
|
|
13
|
-
export function getEmptyStickerState(cubeType: import("../core").CubeType): StickerState;
|
|
14
|
-
export type StickerState = {
|
|
15
|
-
up: import("../core").Face[][];
|
|
16
|
-
down: import("../core").Face[][];
|
|
17
|
-
front: import("../core").Face[][];
|
|
18
|
-
back: import("../core").Face[][];
|
|
19
|
-
left: import("../core").Face[][];
|
|
20
|
-
right: import("../core").Face[][];
|
|
21
|
-
};
|
package/types/index.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/// <reference path="globals.d.ts" preserve="true" />
|
|
2
|
-
export namespace AttributeNames {
|
|
3
|
-
let cubeType: "cube-type";
|
|
4
|
-
let pieceGap: "piece-gap";
|
|
5
|
-
let animationSpeed: "animation-speed-ms";
|
|
6
|
-
let animationStyle: "animation-style";
|
|
7
|
-
let cameraSpeed: "camera-speed-ms";
|
|
8
|
-
let cameraRadius: "camera-radius";
|
|
9
|
-
let cameraFieldOfView: "camera-field-of-view";
|
|
10
|
-
let cameraPeekAngleHorizontal: "camera-peek-angle-horizontal";
|
|
11
|
-
let cameraPeekAngleVertical: "camera-peek-angle-vertical";
|
|
12
|
-
}
|
|
13
|
-
export class RubiksCubeElement extends HTMLElement {
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} tagName the name of the tag to register the web component under
|
|
16
|
-
*/
|
|
17
|
-
static register(tagName?: string): void;
|
|
18
|
-
static get observedAttributes(): ("cube-type" | "piece-gap" | "animation-speed-ms" | "animation-style" | "camera-speed-ms" | "camera-radius" | "camera-field-of-view" | "camera-peek-angle-horizontal" | "camera-peek-angle-vertical")[];
|
|
19
|
-
/** @private @type {HTMLCanvasElement} */
|
|
20
|
-
private canvas;
|
|
21
|
-
/** @private @type {Settings} */
|
|
22
|
-
private settings;
|
|
23
|
-
/** @private @type {CubeSettings} */
|
|
24
|
-
private cubeSettings;
|
|
25
|
-
/**
|
|
26
|
-
* @param {string} name
|
|
27
|
-
* @param {string} oldVal
|
|
28
|
-
* @param {string} newVal
|
|
29
|
-
* */
|
|
30
|
-
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
31
|
-
connectedCallback(): void;
|
|
32
|
-
/** @private */
|
|
33
|
-
private animateCameraSetting;
|
|
34
|
-
/** @private */
|
|
35
|
-
private animateCameraRadius;
|
|
36
|
-
/** @private */
|
|
37
|
-
private updateCameraFOV;
|
|
38
|
-
/** @import {Movement} from './core' */
|
|
39
|
-
/** @internal @typedef {{eventId: string, move: Movement}} MovementEvent */
|
|
40
|
-
/** @internal @typedef {{eventId: string, move: Movement, state: string}} MovementCompleteEventData */
|
|
41
|
-
/** @internal @typedef {{eventId: string, move: Movement, reason: string}} MovementFailedEventData */
|
|
42
|
-
/**
|
|
43
|
-
* @param {Movement} move
|
|
44
|
-
* @returns {Promise<string>}
|
|
45
|
-
*/
|
|
46
|
-
move(move: Movement): Promise<string>;
|
|
47
|
-
/** @import {Rotation} from './core' */
|
|
48
|
-
/** @internal @typedef {{eventId: string, rotation: Rotation}} RotationEventData */
|
|
49
|
-
/** @internal @typedef {{eventId: string, rotation: Rotation, state: string, }} RotationCompleteEventData*/
|
|
50
|
-
/** @internal @typedef {{eventId: string, rotation: Rotation, reason: string, }} RotationFailedEventData*/
|
|
51
|
-
/**
|
|
52
|
-
* @param {Rotation} rotation
|
|
53
|
-
* @returns {Promise<string>}
|
|
54
|
-
*/
|
|
55
|
-
rotate(rotation: Rotation): Promise<string>;
|
|
56
|
-
/** @internal @typedef {{state: string }} ResetCompleteEventData */
|
|
57
|
-
/**
|
|
58
|
-
* @returns {Promise<string>}
|
|
59
|
-
*/
|
|
60
|
-
reset(): Promise<string>;
|
|
61
|
-
/** @import {PeekType} from './core' */
|
|
62
|
-
/** @internal @typedef {{eventId: string, peekType: PeekType}} CameraPeekEventData */
|
|
63
|
-
/** @import {PeekState} from './core' */
|
|
64
|
-
/** @internal @typedef {{eventId: string, peekState: PeekState }} CameraPeekCompleteEventData */
|
|
65
|
-
/**
|
|
66
|
-
* This function changes the camera position to one of four states depending on the arguments passed.
|
|
67
|
-
*
|
|
68
|
-
* @param {PeekType} peekType
|
|
69
|
-
* @returns {Promise<PeekState>}
|
|
70
|
-
*/
|
|
71
|
-
peek(peekType: PeekType): Promise<PeekState>;
|
|
72
|
-
/** @internal @typedef {{state: string }} SetStateEventData */
|
|
73
|
-
/** @internal @typedef {{state: string }} SetStateCompleteEventData */
|
|
74
|
-
/** @internal @typedef {{reason: string }} SetStateFailedEventData */
|
|
75
|
-
/**
|
|
76
|
-
* @param {string} kociembaState
|
|
77
|
-
* @returns {Promise<string>}
|
|
78
|
-
*/
|
|
79
|
-
setState(kociembaState: string): Promise<string>;
|
|
80
|
-
/** @private */
|
|
81
|
-
private init;
|
|
82
|
-
}
|
|
83
|
-
export type AttributeName = (typeof AttributeNames)[keyof typeof AttributeNames];
|
|
84
|
-
import type { Movement } from './core';
|
|
85
|
-
import type { Rotation } from './core';
|
|
86
|
-
import type { PeekType } from './core';
|
|
87
|
-
import type { PeekState } from './core';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** @typedef {{ positon: import('three').Vector3Like, rotation: import('three').Vector3Like }} CenterPieceUserData */
|
|
2
|
-
export class CenterPiece extends Object3D<import("three").Object3DEventMap> {
|
|
3
|
-
constructor();
|
|
4
|
-
frontSticker: CenterSticker;
|
|
5
|
-
get stickers(): CenterSticker[];
|
|
6
|
-
}
|
|
7
|
-
export class CenterSticker extends Sticker {
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
10
|
-
export type CenterPieceUserData = {
|
|
11
|
-
positon: import("three").Vector3Like;
|
|
12
|
-
rotation: import("three").Vector3Like;
|
|
13
|
-
};
|
|
14
|
-
import { Object3D } from 'three';
|
|
15
|
-
import { Sticker } from './sticker';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** @typedef {{ positon: import('three').Vector3Like, rotation: import('three').Vector3Like }} CornerPieceUserData */
|
|
2
|
-
/**
|
|
3
|
-
* @param {Material} frontMaterial
|
|
4
|
-
* @param {Material} rightMaterial
|
|
5
|
-
* @param {Material} topMaterial
|
|
6
|
-
* @param {Material} coreMaterial
|
|
7
|
-
* @returns {Group}
|
|
8
|
-
*/
|
|
9
|
-
export class CornerPiece extends Object3D<import("three").Object3DEventMap> {
|
|
10
|
-
constructor();
|
|
11
|
-
frontSticker: CornerSticker;
|
|
12
|
-
rightSticker: CornerSticker;
|
|
13
|
-
topSticker: CornerSticker;
|
|
14
|
-
get stickers(): CornerSticker[];
|
|
15
|
-
}
|
|
16
|
-
export class CornerSticker extends Sticker {
|
|
17
|
-
constructor();
|
|
18
|
-
}
|
|
19
|
-
export type CornerPieceUserData = {
|
|
20
|
-
positon: import("three").Vector3Like;
|
|
21
|
-
rotation: import("three").Vector3Like;
|
|
22
|
-
};
|
|
23
|
-
import { Object3D } from 'three';
|
|
24
|
-
import { Sticker } from './sticker';
|
package/types/three/cube.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export default class RubiksCube3D extends Object3D<import("three").Object3DEventMap> {
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
* @param {CubeSettings} cubeSettings
|
|
5
|
-
*/
|
|
6
|
-
constructor(cubeSettings: CubeSettings);
|
|
7
|
-
/** @type {CubeSettings} */
|
|
8
|
-
_cubeSettings: CubeSettings;
|
|
9
|
-
/** @type {number} */
|
|
10
|
-
_pieceGap: number;
|
|
11
|
-
/** @type {import('../core').CubeType} */
|
|
12
|
-
_cubeType: import("../core").CubeType;
|
|
13
|
-
/** @type {import('../cube/cubeState').CubeInfo} */
|
|
14
|
-
_cubeInfo: import("../cube/cubeState").CubeInfo;
|
|
15
|
-
/** @type {Group} */
|
|
16
|
-
_mainGroup: Group;
|
|
17
|
-
/** @type {Group} */
|
|
18
|
-
_rotationGroup: Group;
|
|
19
|
-
/** @type {AnimationState[]} */
|
|
20
|
-
_rotationQueue: AnimationState[];
|
|
21
|
-
/** @type {AnimationState | undefined} */
|
|
22
|
-
_currentRotation: AnimationState | undefined;
|
|
23
|
-
/** @type {number | undefined} */
|
|
24
|
-
_matchSpeed: number | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Creates the main group containing all the pieces of the cube in their default position and rotation. Should only be called once during initialization.
|
|
27
|
-
* @private
|
|
28
|
-
**/
|
|
29
|
-
private createCubeGroup;
|
|
30
|
-
/**
|
|
31
|
-
* Returns the sticker state of the cube. Can only be called when an Animation is not in progress as not all pieces would be in the main group.
|
|
32
|
-
* @private
|
|
33
|
-
* @returns {import('../cube/stickerState').StickerState}
|
|
34
|
-
*/
|
|
35
|
-
private getStickerState;
|
|
36
|
-
/**
|
|
37
|
-
* Sets the sticker state of the cube. Can only be called when an Animation is not in progress as not all pieces would be in the main group.
|
|
38
|
-
* @private
|
|
39
|
-
* @param {import('../cube/stickerState').StickerState} stickerState
|
|
40
|
-
*/
|
|
41
|
-
private setStickerState;
|
|
42
|
-
/**
|
|
43
|
-
* Returns the pieces that should be rotated for a given slice. If the slice has no layers, all pieces will be returned. Should only be called before an Animation is started.
|
|
44
|
-
* @private
|
|
45
|
-
* @param {import('../cube/animationSlice').Slice} slice
|
|
46
|
-
* @returns {Object3D[]}
|
|
47
|
-
*/
|
|
48
|
-
private getRotationLayer;
|
|
49
|
-
/**
|
|
50
|
-
* Updates the gap of the pieces. To be used when the cube is not rotating
|
|
51
|
-
* @private
|
|
52
|
-
* @param {number} pieceGap
|
|
53
|
-
* @returns {void}
|
|
54
|
-
*/
|
|
55
|
-
private updateGap;
|
|
56
|
-
/**
|
|
57
|
-
* @private
|
|
58
|
-
* @param {import('../core').CubeType} cubeType
|
|
59
|
-
*/
|
|
60
|
-
private updateCubeType;
|
|
61
|
-
/**
|
|
62
|
-
* finish current rotation and clear rotation queue
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
private stop;
|
|
66
|
-
/**
|
|
67
|
-
* Adds pieces in the rotationGroup back into the main group.
|
|
68
|
-
* Updates the position and rotation of the pieces according to their world position and rotation, then resets the rotation of the rotation group.
|
|
69
|
-
* Should only be called when a rotation is in progress.
|
|
70
|
-
* @private
|
|
71
|
-
* @returns {void}
|
|
72
|
-
*/
|
|
73
|
-
private clearRotationGroup;
|
|
74
|
-
/**
|
|
75
|
-
* Rotates the pieces in the rotation group according to the percentage of completion of the current animation. Should only be called when a rotation is in progress.
|
|
76
|
-
* @private
|
|
77
|
-
* @param {number} percentage
|
|
78
|
-
* @param {AnimationState} animationState
|
|
79
|
-
*/
|
|
80
|
-
private rotateGroupByPercent;
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* calculates the current speed of the current rotation in ms.
|
|
84
|
-
* calculation is dependent on animation style and animation speed settings
|
|
85
|
-
* - exponential: speeds up rotations depending on the queue length
|
|
86
|
-
* - next: an animation speed of 0 when there is another animation in the queue
|
|
87
|
-
* - match: will match the speed of rotations to the frequency of key presses.
|
|
88
|
-
* - fixed: will return a constant value
|
|
89
|
-
* @private
|
|
90
|
-
* @returns {number}
|
|
91
|
-
*/
|
|
92
|
-
private getRotationSpeed;
|
|
93
|
-
/**
|
|
94
|
-
* Update the cube and continue any rotations. If a rotation is in progress, it will be updated. If no rotation is in progress, the next rotation in the queue will be started.
|
|
95
|
-
* @public
|
|
96
|
-
*/
|
|
97
|
-
public update(): void;
|
|
98
|
-
/**
|
|
99
|
-
* resets the cube to the default state and clears any queued rotations. If a rotation is in progress, it will be completed instantly before the reset.
|
|
100
|
-
* @public
|
|
101
|
-
* @param {(state: string) => boolean} completedCallback
|
|
102
|
-
*/
|
|
103
|
-
public reset(completedCallback: (state: string) => boolean): void;
|
|
104
|
-
/**
|
|
105
|
-
* sets the state of the cube
|
|
106
|
-
* @public
|
|
107
|
-
* @param {string} state
|
|
108
|
-
* @param {(state: string) => boolean} completedCallback
|
|
109
|
-
* @param {(reason: string) => boolean} failedCallback
|
|
110
|
-
*/
|
|
111
|
-
public setState(state: string, completedCallback: (state: string) => boolean, failedCallback: (reason: string) => boolean): void;
|
|
112
|
-
/**
|
|
113
|
-
* @public
|
|
114
|
-
* @param {import('../core').Rotation} rotation
|
|
115
|
-
* @param {((state: string) => void )} completedCallback
|
|
116
|
-
* @param {((reason: string) => void )} failedCallback
|
|
117
|
-
*/
|
|
118
|
-
public rotate(rotation: import("../core").Rotation, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void)): void;
|
|
119
|
-
/**
|
|
120
|
-
* @public
|
|
121
|
-
* @param {import('../core').Movement} movement
|
|
122
|
-
* @param {((state: string) => void )} completedCallback
|
|
123
|
-
* @param {((reason: string) => void )} failedCallback
|
|
124
|
-
*/
|
|
125
|
-
public movement(movement: import("../core").Movement, completedCallback: ((state: string) => void), failedCallback: ((reason: string) => void)): void;
|
|
126
|
-
}
|
|
127
|
-
import { Object3D } from 'three';
|
|
128
|
-
import CubeSettings from '../cube/cubeSettings';
|
|
129
|
-
import { Group } from 'three';
|
|
130
|
-
import { AnimationState } from '../cube/animationState';
|
package/types/three/sticker.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export class Sticker extends Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, import("three").Material | import("three").Material[], import("three").Object3DEventMap> {
|
|
2
|
-
/**
|
|
3
|
-
* @param {import("three").BufferGeometry} geometry
|
|
4
|
-
*/
|
|
5
|
-
constructor(geometry: import("three").BufferGeometry);
|
|
6
|
-
/**
|
|
7
|
-
* @param {import('three').ColorRepresentation} color
|
|
8
|
-
*/
|
|
9
|
-
set color(color: import("three").ColorRepresentation);
|
|
10
|
-
/**
|
|
11
|
-
* @returns {import('three').ColorRepresentation} color
|
|
12
|
-
*/
|
|
13
|
-
get color(): import("three").ColorRepresentation;
|
|
14
|
-
}
|
|
15
|
-
import { Mesh } from 'three';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|