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

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

38.7 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
algorithmNamefunctionThe name of one of the method's algorithms, as a person would say it: "Three corners round", 「コーナーの三点交換」.
applySolvefunctionA cube after these steps.
CliResulttypeWhat the command line came to: the exit code, and what goes to standard output and standard error.
CliSurroundingstypeWhat the command line is told about where it runs.
CliWordstypeThe command line's words: its help, its refusals and what it reports.
ClothtypeA cloth's name.
clothVarsfunctionA cloth as CSS variables; nothing for a name that is not a cloth, so the defaults stay.
COMMIT_ANGLEconstantThe point of no return, in degrees, where none is given: let go short of it and the layer goes back.
countsAsMovefunctionWhether a move counts towards a solve's moves: a turn of the whole cube in the hand does not.
countSolveMovesfunctionHow many of the steps count as moves: every turn, and no turn of the whole cube.
CUBE_FACE_ORDERconstantThe faces in the order a state is written: up, right, front, down, left, back.
CUBE_OPTION_GROUPSconstantThe order the groups are shown in, with what each is called.
CUBE_OPTIONSconstantEvery choice the package offers, grouped, with what each is called in each way of making a cube.
CUBE_OPTIONS_LEFT_OUTconstantWhat is not a choice, by the way of making a cube that has it and its name there, each with why: a function, a value that is itself the state, a list that needs a program to write.
CUBE_SCALE_INTERACTIVEconstantWhat a cube drawn at each scale is, apart from its width: a small one is for looking at, so it is not turned by a hand or a key unless asked.
CUBE_SCALE_PXconstantHow wide each is, in pixels: a cube is as tall as it is wide.
CUBE_SCALESconstantHOW BIG A CUBE IS DRAWN, as a setting: small for a list or a picker, medium, and large.
CUBE_THEMESconstantLooks that come with the package.
CubeAxistypeAn axis of the cube: 0 is x (to the right), 1 is y (up) and 2 is z (towards the viewer).
CubeFacetypeA face's letter: U, R, F, D, L or B.
CubeFaceLettertypeA face as the notation names it.
CubeMakertypeThe three ways a cube is made.
CubeMovetypeOne turn: a layer, or the whole cube, turned about an axis by one, two or three quarter turns.
cubeNetfunctionThe cube unfolded flat, as lines of text: the top above the front, the left, front, right and back in a row, and the bottom below.
CubeOptiontypeOne choice.
CubeScaletypeOne of the three.
cubeSlotsfunctionEvery sticker slot of a cube of this size, in the order its state is written, and the way back from a slot to its place.
cubeSolvedfunctionSOLVED: every face one colour.
CubeThemetypeHow a cube looks: its six colours, its plastic, and the shape of a sticker.
CubeTurnstypeOne, two or three quarter turns, counter-clockwise seen from the axis's positive end.
CubeViewclassA cube on the screen.
CubeViewEventstypeWhat a cube tells the listeners on adds: a turn a person made, with the stickers after it; and the view turned, in degrees.
CubeViewOptionstypeEverything a cube on the screen can be told when it is made.
cubeWidthPxfunctionThe width in pixels a cube is drawn at: width when it is a number above zero, and otherwise the scale's.
CubeWordstypeTHE WORDS THE CUBE ITSELF SAYS, in English and Japanese: what a screen reader calls it, whether it is solved, the names of the steps of a solve and what each is for, and the names of the method's algorithms.
decodeCubeMovesfunctionThe moves written in a code, or null where any of it is not a move.
DEFAULT_COLOURSconstantThe standard colours, by the letter a solved face carries: white up, red right, green front, yellow down, orange left, blue back.
DEFAULT_PLASTICconstantThe colour of the plastic between the stickers, where none is given.
DRAG_CLEAR_RATIOconstantHow much more one layer must go the pointer's way than the other to be picked before that.
DRAG_DECIDE_PXconstantHow far it goes before a drag that could be either of two layers picks the likelier anyway.
DRAG_START_PXconstantHow far the pointer goes, in pixels, before a drag picks a layer at all.
dragAnglefunctionThe angle, in degrees, a picked layer has been dragged to: forwards is positive, and it stops at a half turn either way.
dragHintfunctionThe drag that makes this turn, from the way the cube is looked at now (view, as viewMatrix makes it).
DragHinttypeWhat to drag to make a turn of one layer, or of several about one axis as one (a wide turn).
DragPicktypeThe layer a drag has picked: its axis and layer, and the way across the screen (a unit vector, x right and y down) that turns it forwards by the right-hand rule.
encodeCubeMovesfunctionMoves written three characters each, such as x23y02z*1: compact, and readable without knowing the cube's size.
FACE_FRAMESconstantWhich way each face looks, and its rows and columns as the face is seen from outside, in the order above.
FACE_PROPERTIESconstantThe CSS custom property that colours each face, where no colour is given in code: set it on the cube's element or any ancestor.
faceMovefunctionA face turned, depth layers in from it (1 is the face itself), on a cube of this size; null where the cube has no such layer.
faceOfNormalfunctionThe face whose outward normal this is.
faceOfSlotfunctionThe face letter a solved cube shows at this slot.
fillfunctionA line of a table with its braces filled in: fill("A {n}×{n} cube", { n: 3 }) is "A 3×3 cube".
FLICK_ANGLEconstantThe least a flick must have turned the layer, in degrees.
FLICK_SPEEDconstantA flick: the layer still turning this fast the drag's own way, in degrees a millisecond, when the pointer lets go.
fromJSONfunctionThe solves in a JSON export, or null where the text is not one: not JSON, not this format, or a later one.
fromTextfunctionA solve read back from plain lines, or null where they are not one.
FULL_SCRAMBLE_LENGTHSconstantThe lengths official competitions scramble each size to, near enough: what a "full" scramble means here.
GuideclassA guide through a list of moves or the method's steps, for a cube of side n starting from state.
GUIDE_CSSconstantThe guide's stylesheet, put in the page once.
GuideHandletypeA guide beside a cube, on the page.
GuideHeardtypeWhat a guide made of a turn it was told of: the movement finished, part of it made, a detour, or a detour taken back by hand.
GuidePanelOptionstypeHow a guide beside a cube is set up: what it walks, and how it speaks.
GuideSourcetypeWhat a guide walks: moves as written ("R U R' U'", wide turns and rotations read as parseSolve reads them), or as moves, each a movement; or the layer-by-layer method, step by step from the cube as it is (2×2 and 3×3).
GuideSteptypeThe movement a guide asks for now.
HINT_MIN_FACINGconstantHow squarely a face must face the viewer for an arrow to be drawn on it: the cosine of its angle to the eye.
HINT_MIN_FOLLOWconstantHow closely a drag along the arrow must go the way the layer turns: the cosine between them.
HintArrowtypeThe arrow a hint draws, in the cube's doubled units (a sticker is 2 across), lying on a face.
isClothfunctionWhether a text names a cloth.
isCubeScalefunctionWhether a value is one of the three scales.
isCubeStatefunctionWhether a string is a state of a cube this size: the right length, and the right number of every colour.
joinTurnsfunctionTurns of one layer in a row written as one, and any that come to nothing left out: "U' U2" is "U", "U' U" is nothing.
keepScramblingfunctionKeep a cube turning.
KeepScramblingHandletypeWhat a running loop can be told.
KeepScramblingOptionstypeHow it is run.
KeyReadingtypeWhat a key means: a turn, a depth for the next face letter, or nothing.
KYUUBU_CLOTHSconstantTHE CLOTHS A PLAYER'S STAGE MAY BE LAID IN: the same five the whole family offers, and itsutsu.com's boards: green, blue, red, black and wood.
KyuubuLanguagetypeThe two languages the package speaks.
KyuubuStringstypeEvery word the package says: the cube's and the command line's.
languageOffunctionThe language a tag names, as far as the package speaks it: anything beginning "ja" is Japanese, and the rest is English.
layerOffunctionThe layer, 0 to n − 1 from the axis's negative side, that a cubie centre sits in.
Mat3typeA 3×3 matrix, rows of three.
MAX_CLI_COUNTconstantThe most scrambles the command line makes at once.
MAX_CLI_LENGTHconstantThe longest scramble the command line will make.
MAX_RECORD_MOVESconstantThe most turns one record may hold, scramble and solve each.
MAX_RECORD_SEEDconstantThe longest seed kept with a solve.
MAX_RECORD_SIZEconstantThe largest cube a record may be of: the package is made and tested for 2×2 to 7×7.
MAX_RECORDSconstantThe most solves read from one file.
MAX_REPLAY_STEPSconstantThe longest solve a replay takes, in steps.
middleMovefunctionThe middle layer of an odd cube, turned as M, E or S; null on an even cube, which has none.
MIN_RECORD_SIZEconstantThe smallest cube a record may be of.
mountGuidefunctionA guide drawn in an element, for the cube in view: the view shows the hint, and a person makes each movement on it.
mountMoveListfunctionA list of moves drawn in an element.
MOVE_LIST_CSSconstantThe list's stylesheet, put in the page once.
moveFitsfunctionWhether a move can be made on a cube of this size.
moveForDragfunctionThe turn a drag across a sticker means: the layer that carries it most nearly the way the pointer went, that way.
moveForReleasefunctionThe move a release makes: the picked layer turned by those quarters, or null for none.
moveForWheelfunctionThe turn the wheel means over a sticker.
MoveListGrouptypeA run of moves under a heading: a scramble, a solution.
MoveListHandletypeA list on the page.
MoveListItemtypeOne move of a list: its code, what it turns in words (worked out from the code when left out), and the name a screen reader gives its button (the code and the words when left out).
MoveListOptionstypeHow a list is set up.
movementSaysfunctionA movement in plain words, for a cube held with its front towards you: "Turn the right face away from you.", 「右の面を奥に回します。」.
movementTextfunctionA movement in notation: one layer as moveNotation writes it; several layers from a face inwards, about one axis and as far, as a wide turn (Rw, 3Rw'); anything else as its moves one after another.
moveNamefunctionWhat a move turns, in a few plain words, in English or Japanese; null for anything that is not a move in standard form.
moveNotationfunctionA move as a person writes it, for a cube of this size.
movesForReleasefunctionEvery layer a release turns: the picked layer, and the one beside it where the drag took a seam, each by those quarters; none for none.
movesNotationfunctionMoves as a person writes them, a space between each.
nextTurnfunctionOne random layer, a quarter or a half turn either way, never about the axis the last one used, so it never undoes or joins it.
NotationFaulttypeWhy a line of notation could not be read, and where.
OptionGrouptypeWhat the choices are gathered under, in the order a page shows them.
OptionKindtypeHow a choice is made: a number in a range, on or off, one of a few, a colour, or text (moves are text with notation in it).
paceSecondsfunctionSeconds for a pace given as a number or a name; the default for anything else.
parseMovefunctionOne move read back from the notation, for a cube of this size, or null where it is not one: R, R', R2, 2R', M2, x'.
parseMovesfunctionA line of notation read back, or null where any of it is not a move on this cube.
parseSolvefunctionA solve, or a scramble, read from the way it is written, for a cube of this size.
parseSolveMovefunctionOne written step read for a cube of this size, or why it is not one.
pastCommitfunctionWhether a dragged layer is past the point of no return: letting go now, at rest, makes a move.
permutationOffunctionWhere every sticker goes under one turn: to[i] is the slot the sticker in slot i lands on.
pickDragfunctionThe layer a drag across a sticker means, once it can be told: null while the pointer has not gone far enough, or while the two layers that carry the sticker are too nearly as likely as each other.
planReplayfunctionA scramble and a solve read, checked and timed.
prefersReducedMotionfunctionWhether this device asks for less motion.
quartersForReleasefunctionWhat letting go makes of a dragged layer: the quarter turns it snaps to, from −2 to 2, where 0 is back where it was and no move at all.
quarterTurnfunctionA quarter turn counter-clockwise, seen from the axis's positive end.
randomScramblefunctionA scramble of length turns, each of one layer chosen at random, never two in a row about the same axis, so no turn undoes or joins the one before it and the count is the count.
readKeyfunctionWhat a key means on a cube of side n, given the depth a digit before it set (1 where none did).
readSolveLinkfunctionA solve read out of a link to alg.cubing.net, the page most reconstructions are shared by, so that a person can paste the address and not copy two boxes by hand.
RECORD_FORMATconstantThe version of the JSON's shape.
ReplayclassA planned solve played on a cube: play, pause, a step either way, anywhere by seek, faster or slower, once or over and over.
REPLAY_LOOP_REST_MSconstantHow long a looped replay rests on the solved cube before it begins again, in milliseconds.
REPLAY_SCRAMBLE_STEP_MSconstantHow long each turn of the scramble takes when the replay walks through it, in milliseconds.
REPLAY_SCRUB_MSconstantHow long each turn made by moving the slider takes, in milliseconds.
REPLAY_SCRUB_TURNSconstantHow many turns moving the slider shows one by one: a longer jump goes straight to this many steps short of where it is going, and turns the rest.
REPLAY_SPEEDSconstantThe speeds a replay offers: the solve's own pace, half, a quarter and a tenth of it.
REPLAY_STEP_MSconstantHow long a step takes when the solve gives no time of its own, in milliseconds.
ReplayClocktypeThe clock a replay runs by; the page's own unless a test gives another.
ReplayCubetypeThe part of a cube's view a replay needs: CubeView is one.
ReplayFaulttypeWhy a replay could not be planned: which text would not read, and where.
ReplayOptionstypeHow a replay is set up.
ReplayPlantypeA solve ready to be played: read, checked and timed.
ReplaySourcetypeWhat a replay is made from.
ReplayStatustypeWhat a replay tells whoever is showing it.
rotationHintfunctionWHICH WAY TO TURN THE WHOLE CUBE: no drag on a sticker makes it (a key or a button does: x, y, z), so there is no sticker to take hold of, but the way it goes can still be drawn.
rotationKeysfunctionThe key or keys that make a turn of the whole cube: X, Shift+X, X X.
runClifunctionThe whole command line.
SCRAMBLE_DEFAULT_PACEconstantThe pace when none is given: one turn a second.
SCRAMBLE_PACESconstantHow often it turns, in seconds, by name.
SCRAMBLE_SHORTESTconstantThe shortest wait it allows, in seconds: faster is a blur, and a page that asks for it gets this.
ScrambledtypeWhat the loop turns: the cube on the screen has all of it.
ScrambleOptionstypeHow a scramble is made.
ScramblePacetypeOne of those names.
ScramblePagetypeThe part of a page the loop listens to: a Document is one.
scrubPathfunctionWhat moving the slider from one position of a solve to another turns: the steps between, forwards when going on and each one undone, last first, when going back.
ScrubPathtypeThe turns that take a cube from one position of a solve to another, for a slider that turns the cube as it moves.
SeamtypeA seam a hand has taken hold of: a turn about this axis would carry the layer the sticker is in and the one beside it, together.
SEAM_BANDconstantHow near a seam between two layers a touch lands to take both: this share of a sticker's width on each side of the line between them, so that the middle of a sticker, and a little more than half of its width, is still the one layer.
seamsAtfunctionThe seams a touch at this place on a sticker is taking hold of, nearest first: where it lands within SEAM_BAND of a sticker's width of the line that parts the sticker's layer from the one beside it, along either of the two directions the sticker can be turned across.
seededRandomfunctionA SEEDED RANDOM SOURCE: the same seed gives the same numbers, in the same order, on every device and in every version from 1.1.0 on.
SOLVABLE_SIZESconstantThe sizes the method is written for.
SOLVE_ALGORITHMSconstantThe algorithms the method uses, by name.
SolveAlgorithmtypeThe name of one of the method's algorithms: a key of SOLVE_ALGORITHMS.
solvedCubefunctionA solved cube of this size.
SolveLinktypeA solve as a link carries it: its scramble, its moves, and its title where it has one.
SolveMovetypeOne thing a solver did: a turn, a wide turn or a turn of the whole cube.
solveMovesfunctionEvery layer a list of steps turns, in order: what turnAll takes.
SolveParttypeA part of a step: turns to line something up, or one of the method's algorithms.
SolveReadingtypeWhat reading a solve gives: its steps, or the first thing that could not be read.
SolveRecordtypeOne solve: the cube's size, the scramble that mixed it, and the turns made after.
SolveStagetypeThe stages of the method, in the order they are done.
SolveSteptypeOne step of a solve: its stage, the turns that do it, and the parts they come in.
solveStepsfunctionThe layer-by-layer solve of a 2×2 or 3×3 in this state, as steps a person can follow, or null for a size the method is not written for.
SolveSummarytypeWhat a record comes to, worked out from its turns.
solveTextfunctionThe steps written out in standard form, a space between each.
stageNamefunctionThe name of a step of the solve, as a person would say it: "White cross", 「白のクロス」.
stageSaysfunctionWhat a step of the solve is for, in a sentence: "Make a yellow cross on the top."
StickerSlottypeWhere one sticker slot sits: its cubie's centre and the direction it faces.
STRINGSconstantThe package's words in both languages.
summarizefunctionA record's scramble and turns in notation, the cube before and after, whether it ended solved, and its count of moves.
toCSVfunctionA list of solves as CSV, for a spreadsheet: a header, then a row a solve, with lines ended CRLF as RFC 4180 has them.
toJSONfunctionOne solve or many, as JSON: { "format": 1, "generator": "kyuubu 1.1.0", "solves": [ … ] }.
toTextfunctionA solve as a few plain lines, to paste in a chat or a note:
turnAllfunctionThe state after every turn in order.
turnCubefunctionThe state after one turn.
undoAllfunctionA list of moves undone, last first.
undoOffunctionThe move that takes this one back.
Vec3typeA point in the cube's doubled coordinates: a cubie's centre is a whole even or odd step from the middle, by the cube's size.
VERSIONconstantThe package's version, as in package.json.
viewMatrixfunctionThe way the viewer looks at the cube: turned about the model's y (yaw), then tipped about the screen's x (pitch), in degrees.
wholeMovefunctionThe whole cube turned in the hand, as x, y or z.
WORDSconstantThe cube's words in both languages.

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