Reference · Playable surface mazes
SolidMounttype
The mounted surface maze, game, rotation/zoom controls, native progress and cleanup handle.
Import it
import type { SolidMount } from "@johnmorrisdotca/meikyuu/3d/play";
Definition
type SolidMount = {
readonly host: HTMLElement;
recipe: () => SolidRecipe;
maze: () => SolidMaze;
mazeGame: () => MazeGame<SolidMaze>;
load: (recipe: string | SolidRecipe) => boolean;
set: (changes: MazeLook & {
tap?: boolean;
sound?: boolean;
hints?: boolean;
banner?: boolean;
language?: MeikyuuLanguage;
stones?: StoneOption;
edgeTurn?: boolean;
}) => void;
undo: () => void;
restart: () => void;
hint: () => void;
turn: (by: "left" | "right" | "up" | "down" | {
right?: number;
down?: number;
}) => void;
faceMe: (cell?: number) => void;
zoomIn: () => void;
zoomOut: () => void;
fit: () => void;
turnMode: (on?: boolean) => boolean;
edgeTurn: (on?: boolean) => boolean;
view: (to?: {
q?: Quat;
zoom?: number;
}) => {
q: Quat;
zoom: number;
};
place: (cell: number) => SolidCellPlace;
between: (a: number, b: number) => {
x: number;
y: number;
} | null;
pick: (x: number, y: number) => number;
stoneMode: (on?: boolean) => boolean;
stones: () => readonly number[];
stonesLeft: () => number | null;
stone: (cell: number) => StoneVerdict;
clearStones: () => void;
run: () => string;
restore: (code: string) => boolean;
destroy: () => void;
};
Members
| Name | Type | Description |
|---|---|---|
host | HTMLElement | |
recipe | () => SolidRecipe | |
maze | () => SolidMaze | |
mazeGame | () => MazeGame<SolidMaze> | |
load | (recipe: string | SolidRecipe) => boolean | Play another maze. Returns false for a recipe that is none. |
set | (changes: MazeLook & { tap?: boolean; sound?: boolean; hints?: boolean; banner?: boolean; language?: MeikyuuLanguage; stones?: StoneOption; edgeTurn?: boolean; }) => void | |
undo | () => void | |
restart | () => void | |
hint | () => void | |
turn | (by: "left" | "right" | "up" | "down" | { right?: number; down?: number; }) => void | Turn the solid a step: left, right, up or down, or by radians ( |
faceMe | (cell?: number) => void | Bring a cell round to face you; the end of the line by default, or the start before there is a line. |
zoomIn | () => void | |
zoomOut | () => void | |
fit | () => void | Back to the zoom that fits the box. |
turnMode | (on?: boolean) => boolean | Whether every one-finger drag turns the solid; with an argument, turn that on or off. |
edgeTurn | (on?: boolean) => boolean | Whether the solid turns by itself near the edge of the side in view; with an argument, turn that on or off. |
view | (to?: { q?: Quat; zoom?: number; }) => { q: Quat; zoom: number; } | How the solid is turned now (a quaternion |
place | (cell: number) => SolidCellPlace | Where a cell is now, on the picture. |
between | (a: number, b: number) => { x: number; y: number; } | null | Where the edge between two cells that are beside each other is now, in the middle, on the picture (the line crosses from one to the other there), or null for two that are not. |
pick | (x: number, y: number) => number | The cell at a point of the box (pixels from its top left), or -1. |
stoneMode | (on?: boolean) => boolean | |
stones | () => readonly number[] | |
stonesLeft | () => number | null | |
stone | (cell: number) => StoneVerdict | |
clearStones | () => void | |
run | () => string | |
restore | (code: string) => boolean | |
destroy | () => void |
Examples
import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
import type { SolidRecipe } from "@johnmorrisdotca/meikyuu/3d";
import type { SolidMount } from "@johnmorrisdotca/meikyuu/3d/play";
import { mountSolid } from "@johnmorrisdotca/meikyuu/3d/play";
const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const grid = maze.grid;
const solidRecipe: SolidRecipe = {kind:"cube",n:2,algorithm:"backtracker",seed:42};
const host = document.createElement("div");
document.body.append(host);
const player: SolidMount | null = mountSolid(host,{recipe:solidRecipe});
console.log(player?.maze().grid.cells);
player?.destroy();