本文へ移動

Kyuubuキューブ

CSS 3Dのキューブをタッチ、キー、回転記号で回します。シードでスクランブルを再現し、名前付きの手順で解き方を追えます。

「キューブ」は、英語のcubeを表す日本語の表記です。 名前について(英語)

目次

リファレンス · Reactコンポーネント

KyuubuHandle型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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

インポート

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

定義

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;
};

メンバー

名前型説明
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.

例

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

import { createRef } from "react";

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

ソースを見るGitHub で編集@johnmorrisdotca/kyuubu 1.14.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。