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
| Name | Type | Description |
|---|---|---|
width | number | |
height | number | |
q | Quat | |
zoom | number | |
scale | number | Pixels to a unit of the solid's own, before perspective. |
eye | number | The distance of the eye from the middle, in the solid's units. |
sx | Float64Array<ArrayBufferLike> | Each corner on the picture, and how far it is toward the viewer. |
sy | Float64Array<ArrayBufferLike> | |
sz | Float64Array<ArrayBufferLike> | |
cx | Float64Array<ArrayBufferLike> | Each cell's middle on the picture, and how far toward the viewer. |
cy | Float64Array<ArrayBufferLike> | |
cz | Float64Array<ArrayBufferLike> | |
facing | Float64Array<ArrayBufferLike> | How squarely each cell faces the viewer: the turned normal's z, from -1 to 1. |
nx | Float64Array<ArrayBufferLike> | Each cell's turned normal. |
ny | Float64Array<ArrayBufferLike> | |
visible | Uint8Array<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 |
near | Int32Array<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 | number | |
shown | Uint8Array<ArrayBufferLike> | 1 for a cell in |
order | Int32Array<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 |
seen | Uint8Array<ArrayBufferLike> | Whether each cell is seen (1) or hidden behind another part (2), found the first time it is asked (0 until then): see |
cellPixels | number | 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)