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
| Name | Type | Description |
|---|---|---|
slot | StickerSlot | The sticker’s centre and outward normal. |
n | number | The cube’s side length. |
view | Mat3 | The view matrix, or mounted CubeView for a guide. |
dx | number | The horizontal pointer displacement in pixels. |
dy | number | 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)