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

moveForDragfunction

The turn a drag across a sticker means: the layer that carries it most nearly the way the pointer went, that way.

Import it

import { moveForDrag } from "@johnmorrisdotca/kyuubu";

Definition

function moveForDrag(slot: StickerSlot, n: number, view: Mat3, dx: number, dy: number): CubeMove

Parameters

NameTypeDescription
slotStickerSlot

The sticker’s centre and outward normal.

nnumber

The cube’s side length.

viewMat3

The view matrix, or mounted CubeView for a guide.

dxnumber

The horizontal pointer displacement in pixels.

dynumber

The vertical pointer displacement in pixels.

Returns

CubeMove

The turn a drag across a sticker means: the layer that carries it most nearly the way the pointer went, that way.

Examples

import { cubeSlots, moveForDrag, viewMatrix } from "@johnmorrisdotca/kyuubu";

const view = viewMatrix(-30, -20);
const slot = cubeSlots(3).slots[0]!;
console.log(moveForDrag(slot, 3, view, 40, 0));
{ axis: 2, layer: 0, turns: 3 }

What it prints (run when this page was built)

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