Skip to main content

pick

Function pick 

Source
pub fn pick(
    world: &World,
    camera: &Camera,
    ndc_x: f32,
    ndc_y: f32,
) -> Option<Entity>
Expand description

Casts a ray from the camera through the mouse’s normalized-device-coordinate position and returns the nearest entity it intersects, if any.

Model entities are tested against their actual mesh triangles (ray/triangle intersection against each mesh’s local-space geometry, transformed into world space), so picking follows the model’s real silhouette rather than a loose bounding volume. Sprite entities still use a bounding-sphere test, since a sprite is already just a flat quad. Camera entities (no Renderable at all) use a fixed-radius bounding-sphere test around their gizmo instead.