bevy_webcam

Crates.iobevy_webcam
lib.rsbevy_webcam
version0.4.0
created_at2025-07-08 02:31:47.801304+00
updated_at2026-01-15 18:25:45.9509+00
descriptionbevy webcam plugin
homepagehttps://github.com/mosure/bevy_webcam
repositoryhttps://github.com/mosure/bevy_webcam
max_upload_size
id1741977
size167,337
Mitchell Mosure (mosure)

documentation

README

bevy_webcam 📷

GitHub License crates.io

bevy camera input, using the nokhwa crate

usage

app.add_plugins((
    DefaultPlugins,
    BevyWebcamPlugin::default(),
));
app.add_systems(
    Update,
    setup_ui,
);

// ...

fn setup_ui(
    mut commands: Commands,
    stream: Res<WebcamStream>,
) {
    commands.spawn(Camera2d);

    commands.spawn((
        ImageNode {
            image: stream.frame.clone(),
            ..default()
        },
        Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            ..default()
        },
    ));
}

features

  • native camera capture via nokhwa's native backends
  • threaded frame decoding on native targets, so the Bevy Update stage stays responsive
  • wasm32 (browser) capture via the DOM MediaStreamTrackProcessor feeding pixels into the exported frame_input binding

platform notes

  • Native: frames are decoded on a dedicated worker thread and sent to the main Bevy world through a channel before being uploaded to the GPU.
  • Wasm: www/index.html acquires the webcam stream with getUserMedia, processes frames with MediaStreamTrackProcessor, and forwards RGBA pixels into the wasm module via frame_input. The Bevy plugin simply consumes those frames each Update, so there is no blocking nokhwa path on the browser.
  • Camera selection on web: the browser decides which device backs the stream the user grants; the CameraIndex setting currently applies to native builds only.
Commit count: 0

cargo fmt