Crates.io | bevy_guessture |
lib.rs | bevy_guessture |
version | 0.2.0 |
source | src |
created_at | 2024-02-23 01:46:31.746889 |
updated_at | 2024-07-20 04:12:28.964832 |
description | Bevy plugin wrapping the `guessture` crate's gesture recognition API. |
homepage | |
repository | https://github.com/jdm/bevy_guessture |
max_upload_size | |
id | 1149966 |
size | 106,866 |
This library integrates the guessture
library into the Bevy ecosystem. Its responsibilities include:
Bevy apps using bevy_guessture
are responsible for setting up gesture templates,
triggering recording windows, and initiating gesture matching with the recorded mouse path data.
There is an example app that demonstrates visual integration of gesture recognition, as well as
serializing gesture information as a loadable asset.
To get started, install the GuessturePlugin
in your app and prepare a set of guesture templates:
App::new()
.add_plugins(GuessturePlugin::default());
Then prepare a set of gesture templates:
fn setup(server: Res<AssetServer>) {
let _handle: Handle<GestureTemplates> = server.load("data.gestures");
}
To start recording a potential gesture, send the appropriate event:
fn start_record(mut record_events: EventWriter<GestureRecord>) {
record_events.send(GestureRecord::Start);
}
After later sending a GestureRecord::Stop
event, wait for a RecordedPath
event with the complete recording:
fn recorded_path(
mut events: EventReader<RecordedPath>,
mut state: ResMut<GestureState>,
) {
for event in events.read() {
let matched_template = find_matching_template_with_defaults(
&state.templates,
&event.path,
);
match matched_template {
Ok((template, score)) =>
println!("matched {} with score {}", template.name, score),
Err(err) =>
println!("failed to match: {:?}", err),
}
}
}
bevy_guessture | Bevy |
---|---|
main | 0.14 |
0.2 | 0.14 |
0.1 | 0.13 |