本文へ移動

Kyuubuキューブ

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

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

目次

リファレンス · 直方体の描画

CuboidViewクラス

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

A cuboid on the screen. new CuboidView(element, { dims: [2, 3, 3] }) draws it in the element, which it fills, so the element needs a size; destroy() takes it away again with every listener. A turn the puzzle cannot make throws a RangeError, as turnCuboid does.

インポート

import { CuboidView } from "@johnmorrisdotca/kyuubu/cuboid/draw";

定義

class CuboidView
new CuboidView(host: HTMLElement, options: CuboidViewOptions): CuboidView

引数

名前型説明
hostHTMLElement

The DOM host with a size and position.

optionsCuboidViewOptions

View or replay options.

メンバー

名前型説明
statestring

The stickers as they will be once every turn asked for has finished.

dimsCuboidDims

The puzzle's width, height and depth.

busyboolean

Whether a turn is on its way or a layer is held.

looking{ yaw: number; pitch: number; }

The way the puzzle is looked at now, in degrees.

setTheme(theme: CubeTheme): void

Change how the puzzle looks, at once and without redrawing it. What is left out of theme stays as it is.

setLocale(locale: KyuubuLanguage): void

The language of the puzzle's accessible name. A label given when it was made is left as it is.

setInteractive(interactive: boolean): void

Whether a person can turn it now.

setTurnMs(ms: number): void

How long a quarter turn takes, in milliseconds, from now on.

setState(state: string, dims?: CuboidDims): void

Put the stickers as given, at once, dropping any turn still to come. Another dims draws another puzzle.

turn(move: CuboidMove, { report, animate, ms }?: { report?: boolean; animate?: boolean; ms?: number; }): void

Turn a layer, animated after any turns already on their way. Told to onTurn only when report says so. A turn the puzzle cannot make throws a RangeError.

turnTogether(moves: readonly CuboidMove[], options?: { animate?: boolean; ms?: number; }): void

The same as turn, one move: for a replay, which plays steps made of several layers on a cube.

on<K extends keyof CuboidViewEvents>(type: K, listener: CuboidViewEvents[K]): () => void

Listen for a turn a person made (turn) or the view turned (look). Returns the call that stops listening.

setLook(yaw: number, pitch: number): void

Turn the view to look at the puzzle from here. The pitch stays between −90 and 90 degrees.

resetLook(): void

Back to the way the puzzle was first looked at.

redraw(): void

Build the 3D layers again, as a browser that let go of them needs.

destroy(): void

Take the puzzle off the page, with every listener it added.

hostHTMLElement

The element the puzzle was made in.

例

import { CuboidView } from "@johnmorrisdotca/kyuubu/cuboid/draw";

const host = document.createElement("div");
host.style.cssText = "width:300px;height:300px;position:relative";
document.body.append(host);
const cube = new CuboidView(host, { dims: [2, 3, 3], interactive: true });
console.log(cube.state);
// Call cube.destroy() when the host is removed.

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

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