Skip to the content

Kyuubuキューブ

Turn CSS 3D cubes by touch, keys or notation, reproduce a scramble from a seed, and follow a solve one named step at a time.

Kyuubu (キューブ) is the Japanese spelling of cube. About the name

Contents

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

NameTypeDescription
cubeReplayCube

The host’s cube state and turning interface.

planReplayPlan

The validated replay plan.

options (optional)ReplayOptions

View or replay options.

Members

NameTypeDescription
planReplayPlan
statusReplayStatus

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 (seekScramble goes into the scramble); once gone back into the scramble, steps walk it.

walk(by: 1 | -1): void

One move on or back along the scramble and the solve together, turned: step, except that a step back from the scrambled cube turns the scramble's last move undone, so that Back can go on into the scramble.

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 animate, the turns between where it was and where it goes are shown, forwards going on and each undone going back (scrubPath), so a slider turns the cube the right way as it moves; a jump of many steps catches up at once. A solve gone back into the scramble is not animated.

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();
}
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kyuubu 1.14.1.