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 · React components

KyuubuHandletype

What a parent can ask of the cube on the screen.

Import it

import type { KyuubuHandle } from "@johnmorrisdotca/kyuubu/react";

Definition

type KyuubuHandle = {
    turn: (move: CubeMove, options?: {
        report?: boolean;
        animate?: boolean;
    }) => void;
    setState: (state: string) => void;
    resetLook: () => void;
    setTheme: (theme: CubeTheme) => void;
    state: () => string;
    scramble: (moves: readonly CubeMove[], options?: {
        animate?: boolean;
    }) => void;
    showHint: (moves: CubeMove | readonly CubeMove[] | null) => void;
};

Members

NameTypeDescription
turn(move: CubeMove, options?: { report?: boolean; animate?: boolean; }) => void

Turn a layer, animated; told to onTurn only when report is set.

setState(state: string) => void

Put the stickers as given, at once.

resetLook() => void

Back to the way it was first seen.

setTheme(theme: CubeTheme) => void

Change its colours, its plastic or the shape of its stickers, without redrawing it.

state() => string

The stickers once every turn asked for is done.

scramble(moves: readonly CubeMove[], options?: { animate?: boolean; }) => void

Scramble the cube with these turns: the last few turn quickly and the rest are made at once, unless animate is false or the cube was made with animateScramble: false.

showHint(moves: CubeMove | readonly CubeMove[] | null) => void

Show on the cube how to make these moves (the layer lit, an arrow the way to drag), or nothing with null. The hint prop does the same.

Examples

import type { KyuubuHandle } from "@johnmorrisdotca/kyuubu/react";

import { createRef } from "react";

const handle = createRef<KyuubuHandle>();
handle.current?.resetLook();
console.log(handle.current?.state());

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