Skip to main content

Module annotation

Module annotation 

Source
Expand description

World-space annotation labels and screen-projection utilities. World-space annotation labels that project 3D positions to 2D screen coordinates.

§Purpose

Callers can pin text labels to arbitrary 3D world positions (peak pressure values, boundary condition names, measurement callouts) that are reprojected to screen space each frame. Rendering is handled by the caller via egui (or any 2D drawing API) so there is no wgpu pipeline involved.

§Typical usage

// Build a label once (or each frame if the data changes).
let mut label = AnnotationLabel::default();
label.world_pos = glam::Vec3::new(2.0, 3.0, 0.0);
label.text = "Peak pressure: 101.3 kPa".to_string();
label.leader_end = Some(glam::Vec3::new(1.0, 1.0, 0.0));

// Each frame, project to screen.
let view = camera.view_matrix();
let proj = camera.proj_matrix();
if let Some(screen_pos) = world_to_screen(label.world_pos, &view, &proj, viewport_size) {
    // Draw with your 2D API here.
}

Structs§

AnnotationLabel
A text label pinned to a 3D world position.

Functions§

world_to_screen
Projects a 3D world-space position to 2D screen-space coordinates.
world_to_screen_from_frame
Convenience wrapper that extracts camera matrices and viewport size from a FrameData.