Reference · Cube engine and views
Replayclass
A planned solve played on a cube: play, pause, a step either way, anywhere
by seek, faster or slower, once or over and over.
Import it
import { Replay } from "@johnmorrisdotca/kyuubu";
Definition
class Replay
new Replay(cube: ReplayCube, plan: ReplayPlan, options?: ReplayOptions): Replay
Parameters
| Name | Type | Description |
|---|---|---|
cube | ReplayCube | The host’s cube state and turning interface. |
plan | ReplayPlan | The validated replay plan. |
options (optional) | ReplayOptions | View or replay options. |
Members
| Name | Type | Description |
|---|---|---|
plan | ReplayPlan | |
status | ReplayStatus | Where it is and what it is doing. |
play | (): void | Run from where it is; from the beginning when it is at the end. |
pause | (): void | Stop where it is. |
restart | (): void | Back to the scrambled cube, and wait there: the solve as it was before its first move, until it is played. |
step | (by: 1 | -1): void | One step on, or one back, and stop there. A step on is turned, and a step
back is turned the other way, each as long as the other: the cube shows
the move being made and taken back, never a jump. At the scrambled cube a
step back stays there ( |
walk | (by: 1 | -1): void | One move on or back along the scramble and the solve together, turned: |
seek | (position: number, { animate }?: { animate?: boolean; }): void | Straight to the cube as it was after this many steps; it goes on running if
it was. With |
seekScramble | (position: number): void | Straight to the cube as it was after this many steps of the scramble, the whole of it being the scrambled cube the solve starts from; it goes on running if it was, on through the rest of the scramble and the solve. |
setSpeed | (speed: number): void | Faster or slower from the next step: 1 is the solve's own pace, 0.5 half of it. |
setLoop | (loop: boolean): void | Whether it begins again when it ends. |
destroy | (): void | Stop, and leave the cube as it is. |
Examples
import { Replay, cubeSolved, planReplay, turnAll } from "@johnmorrisdotca/kyuubu";
const result = planReplay({ scramble: "R", solution: "R'" });
if (result.ok) {
let state = result.plan.start;
const replay = new Replay({ setState: (next) => { state = next; }, turnTogether: (moves) => { state = turnAll(state, 3, moves); } }, result.plan);
replay.seek(result.plan.steps.length);
console.log(cubeSolved(state, 3));
replay.destroy();
}trueWhat it prints (run when this page was built)