Available on crate feature
raster only.Expand description
Camera + perspective projection + painter’s depth sort (Task 2).
Pipeline (PHASE-R-MAP §3, deck topology-deck.html cam.ry/cam.rx
model, mined from tui-3d-renderer/src/raster.rs::prepare_position +
src/clip.rs, but pure f64 and rotate-Y-then-X per the deck):
- Camera space:
v' = RotX(rx) · RotY(ry) · v, thenz' += dist. - Near-plane clip FIRST: reject the whole primitive if any vertex has
z' <= NEAR_EPS(never divide by a near-zero/negativez'). - Perspective divide with focal length
f = 1 / tan(fov*pi/360), aspect-corrected for braille subcell space (cols*2xrows*4). - Viewport remap to subcell coordinates;
depth = v'.z(smaller = nearer).
Structs§
- Camera
- Camera model: rotate about Y then X, camera distance, vertical FOV
(degrees) — mirrors the deck’s
cam.ry/cam.rx. - Projected
- A vertex projected to subcell screen space;
depthis camera-space z after rotation+translation (before the perspective divide), smaller = nearer.scaleis the local perspective magnification in target units per world unit at this vertex’s depth — the Rust analogue of the deck’sproj()returnings = fov/z3alongsidex/y(topology-deck.html :273-277), which every disc the deck draws uses for its radius (2.1*p.s/300,:308;2.6*top.s/300,:325;2.4*p.s/300,:357;√(c+v)*.62*top.s/300,:412). Measured on the vertical axis (d sy / d world-y), which is the isotropic one in braille subcell space (a 2x4 subcell of a 1:2 terminal cell is square).
Constants§
- NEAR_
EPS - Near-plane epsilon: a vertex at/behind the camera (
z' <= NEAR_EPS) makes its whole primitive rejected rather than risking a near-zero or negative perspective divide (Power-of-10 rule 4;tui-3d/src/clip.rs).
Functions§
- depth_
sort - Stable painter’s depth sort: farthest-first, keyed on each primitive’s centroid camera-space depth. Stable so equal-depth primitives keep scene (insertion) order — no draw-order nondeterminism. Bounded: one pass over each finite slice.
- depth_
sort_ nodes - Stable painter’s depth sort for node discs: farthest-first on each
node’s own center depth. Separate from
depth_sortso the existing(faces, struts)signature (and its golden-pinned behaviour) is untouched; nodes are drawn after faces/struts in both raster tiers so an annotation dot at exactly equal depth wins its subcell. Bounded: one pass over a finite slice. - face_
is_ clipped trueif any vertex of the face is at/behind the near plane.- node_
is_ clipped trueif the node’s center is at/behind the near plane (the whole disc is rejected — a node is a point primitive, never split).- project
- Project a single 3D point into subcell screen space under
cam, for acols x rowscharacter grid (braille 2x4 subcells per cell). ReturnsNoneif the vertex is at/behind the near plane (z' <= NEAR_EPS). - strut_
is_ clipped trueif either endpoint of the strut is at/behind the near plane.