Skip to main content

drive_surface_pointer

Function drive_surface_pointer 

Source
pub fn drive_surface_pointer(
    surfaces: Res<'_, Surfaces>,
    state: ResMut<'_, SurfaceVirtualPointer>,
    windows: Query<'_, '_, &Window>,
    cameras: Query<'_, '_, (&Camera, &RenderTarget, &GlobalTransform)>,
    pointer_meshes: Query<'_, '_, &SurfacePointer>,
    mesh3ds: Query<'_, '_, &Mesh3d>,
    meshes: Res<'_, Assets<Mesh>>,
    buttons: Res<'_, ButtonInput<MouseButton>>,
    ray_cast: MeshRayCast<'_, '_>,
    input: MessageWriter<'_, PointerInput>,
)
Expand description

Ray-cast the main camera through the cursor at the SurfacePointer meshes and drive the virtual pointer to the hit UV (mapped into the surface’s texture pixels), so Bevy’s UI picking backend hit-tests the offscreen subtree. Emits PointerInput move/press/release events for the SurfaceVirtualPointer.

Scheduled before bevy_picking’s input processing so the pointer’s new location is consumed the same frame.