Application prototype #14
@ -495,6 +495,21 @@ fn main() {
|
|||||||
start_animation_loop();
|
start_animation_loop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let set_nav_signal = move |event: KeyboardEvent, value: f64| {
|
||||||
|
let mut navigating = true;
|
||||||
|
match event.key().as_str() {
|
||||||
|
"ArrowUp" => pitch_up.set(value),
|
||||||
|
"ArrowDown" => pitch_down.set(value),
|
||||||
|
"ArrowRight" => yaw_right.set(value),
|
||||||
|
"ArrowLeft" => yaw_left.set(value),
|
||||||
|
_ => navigating = false
|
||||||
|
};
|
||||||
|
if navigating {
|
||||||
|
scene_changed.set(true);
|
||||||
|
event.prevent_default();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
div(id="app") {
|
div(id="app") {
|
||||||
div(class="tab-pane") {
|
div(class="tab-pane") {
|
||||||
@ -523,34 +538,8 @@ fn main() {
|
|||||||
width=600,
|
width=600,
|
||||||
height=600,
|
height=600,
|
||||||
tabindex=0,
|
tabindex=0,
|
||||||
on:keydown=move |event: KeyboardEvent| {
|
on:keydown=move |event: KeyboardEvent| { set_nav_signal(event, 1.0); },
|
||||||
let mut navigating = true;
|
on:keyup=move |event: KeyboardEvent| { set_nav_signal(event, 0.0); },
|
||||||
match event.key().as_str() {
|
|
||||||
"ArrowUp" => pitch_up.set(1.0),
|
|
||||||
"ArrowDown" => pitch_down.set(1.0),
|
|
||||||
"ArrowRight" => yaw_right.set(1.0),
|
|
||||||
"ArrowLeft" => yaw_left.set(1.0),
|
|
||||||
_ => navigating = false
|
|
||||||
};
|
|
||||||
if navigating {
|
|
||||||
scene_changed.set(true);
|
|
||||||
event.prevent_default();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
on:keyup=move |event: KeyboardEvent| {
|
|
||||||
let mut navigating = true;
|
|
||||||
match event.key().as_str() {
|
|
||||||
"ArrowUp" => pitch_up.set(0.0),
|
|
||||||
"ArrowDown" => pitch_down.set(0.0),
|
|
||||||
"ArrowRight" => yaw_right.set(0.0),
|
|
||||||
"ArrowLeft" => yaw_left.set(0.0),
|
|
||||||
_ => navigating = false
|
|
||||||
};
|
|
||||||
if navigating {
|
|
||||||
scene_changed.set(true);
|
|
||||||
event.prevent_default();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
on:blur=move |_| {
|
on:blur=move |_| {
|
||||||
pitch_up.set(0.0);
|
pitch_up.set(0.0);
|
||||||
pitch_down.set(0.0);
|
pitch_down.set(0.0);
|
||||||
|
Loading…
Reference in New Issue
Block a user