bevy_webcam 📷
bevy camera input, using the nokhwa crate
usage
app.add_plugins;
app.add_systems;
// ...
features
- native camera capture via
nokhwa's native backends - threaded frame decoding on native targets, so the Bevy
Updatestage stays responsive - wasm32 (browser) capture via the DOM
MediaStreamTrackProcessorfeeding pixels into the exportedframe_inputbinding
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.htmlacquires the webcam stream withgetUserMedia, processes frames withMediaStreamTrackProcessor, and forwards RGBA pixels into the wasm module viaframe_input. The Bevy plugin simply consumes those frames eachUpdate, so there is no blockingnokhwapath on the browser. - Camera selection on web: the browser decides which device backs the stream the user grants; the
CameraIndexsetting currently applies to native builds only.