Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

World overlays and the pointer

Current contract for 3D overlays on the client (boxes, lines, voxel outlines, ghost blocks, text, markers, images, gizmos, the cursor highlight, chunk borders, debug layers), for picking them, and for the platform’s cursor and pointer surfaces. Mods reach overlays through manifold:render/world-overlay and the SDK’s manifold_mod_substrate::overlay. Design: Enki B §5 and §6 (docs/superpowers/specs/2026-09-27-enki-b-mod-platform-contract-design.md) (and its “As built” issues 38 and 53). Source: crates/manifold-client-state/src/overlay/, crates/manifold-overlay-protocol/ (the guest payloads), crates/manifold-overlay-draw/ (the resolved draw list, re-exported as manifold_overlay_protocol::draw; the renderer depends on it alone, so not on the engine), crates/manifold-render/src/overlay.rs, crates/manifold-wasm-host-core/src/capability/world_overlay.rs, crates/manifold-host-core/src/platform_ports/world_overlay.rs, crates/manifold-client-state/src/pointer.rs, crates/manifold-client-state/src/bridged_specs.rs, crates/manifold-client-api/.

The rule

Every 3D overlay is content in one client scene, OverlayScene, owned by either a mod or a platform layer, and the renderer draws it in one pass. Nothing calls the renderer to draw lines of its own, so turning one overlay on never overwrites another. Overlays are presentation: client only, never replicated, never on the wire. Showing another player’s selection is the mod’s decision, carried on its own channel.

OwnerContentBudgetWritten through
Mod(id)Retained nodes and registered imagesPer mod: 4,096 nodes, 262,144 line points, 2,097,152 voxel cells, 256 images and 64 MiB of decoded imagesworld-overlay.apply (op batches, OverlayScene::apply_encoded)
Platform(layer)Retained nodes (native tools), or immediate content rebuilt every frameExemptThe Rust API (OverlayScene::apply)

The immediate platform layers are manifold:cursor_highlight (from CursorTarget), manifold:chunk_borders (F3), manifold:anim_hitboxes (/anim debug hitboxes and /anim debug modifiers), manifold:telegraphs (Talos B telegraphs) and manifold:ai_overlay (Talos G paths, sight, hearing and arcs). Each domain still generates its own lines; the overlay draws them as its layer. A new native layer adds a PlatformLayer constant and an arm in overlay::platform::emit_layer.

Shapes, ops and budgets

A node is a shape in its own local space, placed by a transform (translation in f64, rotation, scale), with a style (edge colour, optional fill, width in pixels, depth mode), a visible flag, a pickable flag and a draw order. Colours are a literal (Srgba8, Linear) or a theme token of the Manifold look (docs/manifold-look.md) (Brass, Error, …), resolved through the OverlayTheme client resource.

ShapeContentDrawn as
Boxlocal min and max12 edges, and 6 faces with a fill
Linesa strip or a segment listscreen-space quads of the edge width
VoxelOutlinea cell bitset over inclusive bounds, or a cell listthe set’s merged exterior edges (an edge is drawn where the four cells around it are not a flat surface)
GhostBlocksa cell buffer (Enki B §0 layout, 2- or 4-byte values, a skip value) over bounds, or a cell listthe filled cells’ exterior faces, greedily merged per slice, shaded per face (top 1.0, bottom 0.5, x 0.8, z 0.65) in the fill colour
Textan anchor and a LabelDocumenta world label
Markeran anchor, an icon address, a size in pixelsa world label holding only the icon
Imagea registered image, a size in blocks, a facing (Fixed in the node’s XY plane, BillboardY, Billboard), opacity, nearest or linear filtering, a UV rectanglea textured quad
Gizmoa GizmoSpecengine-driven handles (Gizmos)

Voxel shapes are meshed once, when a batch sets them, in node-local space; resolution only places the mesh each frame. Their coordinates are limited to ±2³⁰.

Images. RegisterImage { id, source } decodes the image once, with the same pure-Rust image decoder on both hosts, so a malformed file fails the same way everywhere: PNG or JPEG, at most 4 MiB encoded (more is refused with BudgetExceeded) and 2,048 px per side. A source that cannot be read or decoded registers the 8×8 checker placeholder rather than failing the batch, and an Image node naming no registered image draws the checker too. Asset(path) reads the mod’s own asset bundle through the calling instance (wasmtime’s asset source, the browser’s preloaded archive); Local(path) waits for the local-files store (Enki B §7) and registers the placeholder meanwhile; Encoded(bytes) decodes the bytes the mod holds. ReleaseImage frees one; Clear removes nodes, not images.

A batch is Vec<OverlayOp>: RegisterImage, ReleaseImage, Create, SetTransform, SetShape, SetStyle, SetVisible, SetPickable, SetOrder, Remove, Clear. An op’s variant index is its kind, which supports-op takes (every host implements all eleven). A batch applies entirely or not at all. A malformed op (duplicate or unknown id or image, non-finite or inverted geometry, a width outside 0.5–64 px, a segment list with an odd point count, a buffer of the wrong length, an invalid label document) refuses the batch with Invalid; a batch that would leave a mod over a budget is refused with BudgetExceeded. Nothing is dropped silently.

Resolution and the pass

Once per frame, after model poses, each host calls overlay::resolve_frame(world, &PlatformFrame { chunk_borders }, &mut list) and Renderer::update_overlay(&list). Resolution lowers nodes in draw order (order, then owner, then id; the immediate layers draw at order 0, ahead of retained order-0 nodes) into an OverlayDrawList: line segments, fill triangles and image quads, bucketed by depth mode, plus the textures the quads name. It reads the interpolated camera (billboards face its eye, gizmo handles keep their pixel size) and the picking state (a dragged gizmo and its attached nodes draw at the proposal, the active handle highlighted). Text and markers are not draw-list content: resolve_world_labels adds them to the frame’s world labels (WorldLabelSource::Overlay), at any distance up to the label limit, their draw order as priority; an Occluded node keeps line-of-sight occlusion, the other depth modes show through blocks.

The renderer’s overlay pass runs after post and before egui, on the presentation (unjittered) camera, exactly where the old line pass ran, on native wgpu and browser WebGPU alike:

  • Lines are instanced screen-space quads width_px wide with square caps, clipped at the near plane before expansion. WebGPU has no line width, so this is the only line path.
  • Depth modes: Occluded tests against scene depth (reversed-Z Greater); Always skips the test; XRay draws normally and then where hidden (Less) at 35% alpha. Nothing writes depth.
  • Fills blend with straight alpha before the images and edges of the same bucket.
  • Images sample their texture (sRGB, no mips) with nearest or linear filtering per quad and their opacity. The pass keeps one texture per registered image while a list names it and drops it when none does.

Picking

overlay::raycast_world(world, owner, Ray { origin, dir, max }, RayOptions { include_overlays, include_entities }) is world-overlay.raycast. It returns the first RayHit: a block (its position, face normal and value) within max blocks (up to 4,096, not limited to gameplay reach); with include_overlays, one of the caller’s own pickable, visible nodes (a box by its faces, a voxel shape by its bounds; lines, text, markers and images are never hit); with include_entities, an entity: an animated instance by its posed hit boxes (the /anim hit test) or a remote player by a 0.6 × 1.8 × 0.6 body box at its feet, reported with the client’s entity handle and its durable id (0 when it has none). The nearest wins; at equal distance an overlay wins, then an entity, then a block. A ray that starts inside a box hits where it leaves.

Engine picking. OverlayInteractionSystem runs every frame in frame:simulate, after CursorTargetSystem casts the pointer ray. While the pointer gate leaves the pointer over the viewport it finds what the ray is over: the nearest gizmo handle of any node (handles draw over everything), else the nearest pickable node, an occluded one only when no block is nearer. Only the nodes of the mod whose exclusive input context is effective are candidates while one is (input spec §10.8); platform owners always are. The owner of what the pointer is over is told (OverlayInteraction, drained per owner by take-events):

EventWhen
Hover { id, handle, point }The pointer moves onto one of the owner’s nodes or handles; id none when it leaves the owner’s nodes
Click { id, button, phase: Press, modifiers, point }A button goes down on one of the owner’s pickable nodes
Click { …, phase: Release, … }That button goes up, wherever the pointer is
GizmoDrag { id, phase, handle, proposed }A handle drag: Start, an Update for each new proposal (successive updates coalesce in the queue), End with the final proposal on release, Cancel if the gizmo vanishes
Overflow { dropped }Last in a drain when the owner’s queue (256 events) dropped the newest

Buttons and modifiers are the pointer view’s bits (manifold_client_api’s button and modifier). Held buttons come from the input evaluator each frame.

Capture. While a handle is under the pointer with no button held (a press would start a drag), and for the whole drag, the system keeps the engine’s manifold:overlay.capture context on the input stack (input spec §10.2): an Engine UI layer above every mod context whose pointer sink takes the mouse buttons only (PointerScope::Buttons), so the wheel and mouse look still reach the contexts below. No mod action sees a press there, and the pointer gate clears buttons_to_mods for pointer_view readers. The context is popped once the drag ends (released, or cancelled because the gizmo vanished) and the pointer is off the handles. A drag starts only from a press evaluated while the context was effective: a press in the very frame the pointer reaches a handle belongs to the contexts below and starts no drag, so a press is never both the engine’s and a mod’s.

Gizmos

A Gizmo node’s transform is what its handles move. GizmoSpec holds the handle set, the space (the world’s axes or the node’s), the snapping steps (translate, rotate in degrees, scale; 0 is free), a coarse modifier with its own translate and rotate steps, a free modifier that disables snapping, the handles’ constant size in pixels, an optional local extent and the nodes it carries (attached, at most 64).

HandlesDrag
AXESAn arrow per axis: the translation moves along it to where the pointer ray passes closest
PLANESA square per axis pair: moves in that plane
CENTREMoves in the plane facing the view at the press
RINGSA ring per axis: rotates about it, through the gizmo’s centre
SCALEA node per axis: scales the node’s axis by the ratio of the pointer’s distance along it
FACESA square on each face of extent: moves that face, the opposite face fixed (a scale and translation of the node), never past one step

Handles centre on the extent’s centre, or the origin without one. The engine hit-tests and drags them every frame, snaps each delta to the step, and proposes the gizmo node’s transform; the gizmo and its attached nodes draw at the proposal (each attached point mapped back through the start transform and out through the proposal) until the owner sets the transforms it accepts. GizmoSpec::box_faces(extent, attached) is a box selection’s resize handles (whole blocks). Gizmo maths is presentation and uses plain floats.

Platform cursor surfaces

These bridged resources are registered by the platform (manifold_client_state::bridged_specs::client_bridged_specs), never by a game, so any mod reads them whichever game is loaded. Their guest views are public in manifold-client-api (catalogs in manifold-server-api):

IdViewSource
manifold:cursor_target_viewCursorTargetViewThe crosshair’s block within reach (CursorTarget.hit): what break and place act on
manifold:water_target_viewWaterTargetViewThe first fluid cell along the crosshair
manifold:block_action_handlesBlockActionHandlesViewResolved break, place and interact handles
voxel_factory:block_catalogBlockCatalogViewBlock names and basic properties by raw id
manifold:fluid_catalogFluidCatalogViewEach block’s fluid source
manifold:pointer_viewPointerViewThe pointer ray, the block under it, and the pointer’s state

A guard test fails if the flagship registers any of them.

Pointer view. CursorTargetSystem casts the pointer ray every frame beside the crosshair: through the cursor while it is free and inside the window (inverting the renderer’s projection), else through the screen centre, up to POINTER_PICK_DISTANCE (256 blocks). It records the hit’s position, face normal and value in PointerTarget. pointer::pointer_view is the one consumer API: it combines the target with the tick’s wheel and cursor position, the physical buttons (PointerButtons) and the input stack’s PointerGate (over_viewport, buttons_to_mods). The input runtime writes both on both hosts. evaluate_input_frame writes the gate after every evaluation: the frontend base, or an effective engine-band context that sinks the pointer everywhere (manifold:ui for menus and BUI windows, the console, engine tools, rebind capture), closes it; the gizmo capture takes only buttons_to_mods; text entry sinks only the keyboard and mods’ Game and Tool contexts never close it. Without an input runtime there is no gate and the pointer reads closed. InputCollectionSystem folds each frame’s raw button edges and TickInputBuilderSystem publishes PointerButtons when the tick closes, with the evaluator’s held buttons and modifiers.

Not built yet

  • Ghost blocks are tinted with the style colour, not textured from the block atlas (Enki B §5.5): the pass has no atlas binding yet. The shape and its buffer are final; only the shading changes.
  • Images decode on the calling thread at registration (bounded by the 4 MiB and 2,048 px limits), not on the rayon pool.
  • Local image sources wait for the local-files store (Enki B §7).
  • PointerView.wheel is still the camera-zoom action’s notches ([0, dy]), not the raw wheel. The exclusive enki:editor context and capture are Enki’s, on I0b’s mod contexts (input spec §10.8).