Skip to the content

Meikyuu迷宮

Generate seeded mazes and arrow puzzles, follow numbered levels, and play on flat grids or three-dimensional surfaces.

Meikyuu is the Japanese word 迷宮 for labyrinth. About the name

Contents

Reference · Surface maze rules and geometry

SolidFrametype

Where a solid is, as a picture of a given size: the turn, the zoom, and every corner and cell as it lands.

Import it

import type { SolidFrame } from "@johnmorrisdotca/meikyuu/3d";

Definition

type SolidFrame = {
    width: number;
    height: number;
    q: Quat;
    zoom: number;
    scale: number;
    readonly eye: number;
    readonly sx: Float64Array;
    readonly sy: Float64Array;
    readonly sz: Float64Array;
    readonly cx: Float64Array;
    readonly cy: Float64Array;
    readonly cz: Float64Array;
    readonly facing: Float64Array;
    readonly nx: Float64Array;
    readonly ny: Float64Array;
    readonly visible: Uint8Array;
    readonly near: Int32Array;
    count: number;
    readonly shown: Uint8Array;
    readonly order: Int32Array;
    readonly seen: Uint8Array;
    cellPixels: number;
};

Members

NameTypeDescription
widthnumber
heightnumber
qQuat
zoomnumber
scalenumber

Pixels to a unit of the solid's own, before perspective.

eyenumber

The distance of the eye from the middle, in the solid's units.

sxFloat64Array<ArrayBufferLike>

Each corner on the picture, and how far it is toward the viewer.

syFloat64Array<ArrayBufferLike>
szFloat64Array<ArrayBufferLike>
cxFloat64Array<ArrayBufferLike>

Each cell's middle on the picture, and how far toward the viewer.

cyFloat64Array<ArrayBufferLike>
czFloat64Array<ArrayBufferLike>
facingFloat64Array<ArrayBufferLike>

How squarely each cell faces the viewer: the turned normal's z, from -1 to 1.

nxFloat64Array<ArrayBufferLike>

Each cell's turned normal.

nyFloat64Array<ArrayBufferLike>
visibleUint8Array<ArrayBufferLike>

1 for a cell on the near side (it faces the eye). On a solid that is not convex it may still be hidden by another part: see cellSeen.

nearInt32Array<ArrayBufferLike>

The cells on the near side that are in the picture (not wholly out of it, where it is zoomed in), the first count of them.

countnumber
shownUint8Array<ArrayBufferLike>

1 for a cell in near: on the near side and in the picture. A cell on the near side and out of the picture (visible but not shown) is not painted, picked or looked up.

orderInt32Array<ArrayBufferLike>

For a solid that is not convex: the cells on the near side from the farthest to the nearest, the order to paint them in (the first count of them; empty for a convex solid, which needs none).

seenUint8Array<ArrayBufferLike>

Whether each cell is seen (1) or hidden behind another part (2), found the first time it is asked (0 until then): see cellSeen.

cellPixelsnumber

About how many pixels across a cell is on the near side, for stepping along a drag.

Examples

import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
import type { Quat, SolidFrame, SolidRecipe } from "@johnmorrisdotca/meikyuu/3d";
import { buildSolidMaze, createFrame, projectFrame } from "@johnmorrisdotca/meikyuu/3d";

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 solid = buildSolidMaze(solidRecipe);
const solidGrid = solid.grid;
const q: Quat = [0,0,0,1];
const frame = projectFrame(createFrame(solidGrid),solidGrid,q,1,640,480);
const value: SolidFrame = frame;
console.log(value);
{
  width: 640,
  height: 480,
  q: [ 0, 0, 0, 1 ],
  zoom: 1,
  scale: 203.89162987847007,
  eye: 10.392304845413264,
  sx: Float64Array(26) [
     505.9943182593414,  505.9943182593414,
     523.8916298784701,  523.8916298784701,
     505.9943182593414,  523.8916298784701,
                 545.6,              545.6,
                 545.6, 134.00568174065856,
    134.00568174065856, 116.10837012152993,
    116.10837012152993, 134.00568174065856,
    116.10837012152993,               94.4,
                  94.4,               94.4,
                   320,                320,
                   320,                320,
                   320,                320,
                   320,                320
  ],
  sy: Float64Array(26) [
     54.00568174065856,                240,
                   240,  36.10837012152993,
     425.9943182593414,  443.8916298784701,
                   240, 14.400000000000006,
                 465.6,  54.00568174065856,
                   240,                240,
     36.10837012152993,  425.9943182593414,
     443.8916298784701,                240,
    14.400000000000006,              465.6,
     443.8916298784701,  425.9943182593414,
                 465.6,  36.10837012152993,
     54.00568174065856, 14.400000000000006,
                   240,                240
  ],
  sz: Float64Array(26) [
    -1, -1,  0,  0, -1,  0,  1, 1,
     1, -1, -1,  0,  0, -1,  0, 1,
     1,  1,  0, -1,  1,  0, -1, 1,
     1, -1
  ],
  cx: Float64Array(24) [
     514.5321952697184,  514.5321952697184,
     534.1971973404861,  534.1971973404861,
    125.46780473028167, 125.46780473028167,
    105.80280265951384, 105.80280265951384,
    222.73390236514084, 212.90140132975694,
     417.2660976348592, 427.09859867024306,
    222.73390236514084, 212.90140132975694,
     417.2660976348592, 427.09859867024306,
                 207.2,              432.8,
                 207.2,              432.8,
     227.0028408703293,  412.9971591296707,
     227.0028408703293,  412.9971591296707
  ],
  cy: Float64Array(24) [
    142.73390236514084,  337.2660976348592,
    132.90140132975694, 347.09859867024306,
    142.73390236514084,  337.2660976348592,
    132.90140132975694, 347.09859867024306,
    434.53219526971833,  454.1971973404861,
    434.53219526971833,  454.1971973404861,
     45.46780473028167, 25.802802659513844,
     45.46780473028167, 25.802802659513844,
                 127.2,              127.2,
                 352.8,              352.8,
     147.0028408703293,  147.0028408703293,
     332.9971591296707,  332.9971591296707
  ],
  cz: Float64Array(24) [
    -0.5, -0.5,  0.5, 0.5, -0.5, -0.5,
     0.5,  0.5, -0.5, 0.5, -0.5,  0.5,
    -0.5,  0.5, -0.5, 0.5,    1,    1,
       1,    1,   -1,  -1,   -1,   -1
  ],
  facing: Float64Array(24) [
    0, 0, 0, 0,  0,  0,  0,  0,
    0, 0, 0, 0,  0,  0,  0,  0,
    1, 1, 1, 1, -1, -1, -1, -1
  ],
  nx: Float64Array(24) [
    1, 1, 1, 1, -1, -1, -1, -1,
    0, 0, 0, 0,  0,  0,  0,  0,
    0, 0, 0, 0,  0,  0,  0,  0
  ],
  ny: Float64Array(24) [
    0, 0, 0, 0,  0,  0,  0,  0,
    1, 1, 1, 1, -1, -1, -1, -1,
    0, 0, 0, 0,  0,  0,  0,  0
  ],
  visible: Uint8Array(24) [
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 1, 1, 1, 0, 0, 0, 0
  ],
  near: Int32Array(24) [
    16, 17, 18, 19, 0, 0, 0, 0,
     0,  0,  0,  0, 0, 0, 0, 0,
     0,  0,  0,  0, 0, 0, 0, 0
  ],
  count: 4,
  shown: Uint8Array(24) [
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 1, 1, 1, 0, 0, 0, 0
  ],
  order: Int32Array(0) [],
  seen: Uint8Array(0) [],
  cellPixels: 225.60000000000002
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/meikyuu 3.2.0.