Application prototype #14

Merged
glen merged 101 commits from app-proto into main 2024-10-21 23:38:28 +00:00
Showing only changes of commit aceac5e5c4 - Show all commits

View File

@ -170,6 +170,8 @@ fn main() {
let pitch_down = create_signal(0.0);
let yaw_right = create_signal(0.0);
let yaw_left = create_signal(0.0);
let roll_ccw = create_signal(0.0);
let roll_cw = create_signal(0.0);
// controls for general example
let gen_controls = create_node_ref();
@ -385,15 +387,18 @@ fn main() {
let pitch_down_val = pitch_down.get();
let yaw_right_val = yaw_right.get();
let yaw_left_val = yaw_left.get();
let roll_ccw_val = roll_ccw.get();
let roll_cw_val = roll_cw.get();
let turntable_val = turntable.get();
// update the construction's orientation
let ang_vel = {
let pitch = pitch_up_val - pitch_down_val;
let yaw = yaw_right_val - yaw_left_val;
let roll = roll_ccw_val - roll_cw_val;
let ang_vel_from_keyboard =
if pitch != 0.0 || yaw != 0.0 {
NAV_SPEED * Vector3::new(-pitch, yaw, 0.0).normalize()
if pitch != 0.0 || yaw != 0.0 || roll != 0.0 {
NAV_SPEED * Vector3::new(-pitch, yaw, roll).normalize()
} else {
Vector3::zeros()
};
@ -485,6 +490,8 @@ fn main() {
|| pitch_down_val != 0.0
|| yaw_left_val != 0.0
|| yaw_right_val != 0.0
|| roll_cw_val != 0.0
|| roll_ccw_val != 0.0
|| turntable_val
);
} else {
@ -500,6 +507,8 @@ fn main() {
match event.key().as_str() {
"ArrowUp" => pitch_up.set(value),
"ArrowDown" => pitch_down.set(value),
"ArrowRight" if event.shift_key() => roll_cw.set(value),
"ArrowLeft" if event.shift_key() => roll_ccw.set(value),
"ArrowRight" => yaw_right.set(value),
"ArrowLeft" => yaw_left.set(value),
_ => navigating = false
@ -538,13 +547,33 @@ fn main() {
width=600,
height=600,
tabindex=0,
on:keydown=move |event: KeyboardEvent| { set_nav_signal(event, 1.0); },
on:keyup=move |event: KeyboardEvent| { set_nav_signal(event, 0.0); },
on:keydown=move |event: KeyboardEvent| {
if event.key() == "Shift" {
roll_cw.set(yaw_right.get());
roll_ccw.set(yaw_left.get());
yaw_right.set(0.0);
yaw_left.set(0.0);
} else {
set_nav_signal(event, 1.0);
}
},
on:keyup=move |event: KeyboardEvent| {
if event.key() == "Shift" {
yaw_right.set(roll_cw.get());
yaw_left.set(roll_ccw.get());
roll_cw.set(0.0);
roll_ccw.set(0.0);
} else {
set_nav_signal(event, 0.0);
}
},
on:blur=move |_| {
pitch_up.set(0.0);
pitch_down.set(0.0);
yaw_right.set(0.0);
yaw_left.set(0.0);
roll_ccw.set(0.0);
roll_cw.set(0.0);
}
)
div(ref=gen_controls) {