@@ -18,21 +18,21 @@ fn main() {
18
18
println ! (
19
19
"
20
20
Controls:
21
- MOUSE - Move camera orientation
22
- LClick - Enable mouse movement
23
- WSAD - forward/back/strafe left/right
24
- LShift - 'run'
25
- E - up
26
- Q - down
27
- L - animate light direction
28
- U - toggle shadows
29
- C - cycle through cameras
30
- 5/6 - decrease/increase shadow projection width
31
- 7/8 - decrease/increase shadow projection height
32
- 9/0 - decrease/increase shadow projection near/far
33
-
34
- Space - Play/Pause animation
35
- Enter - Cycle through animations
21
+ MOUSE - Move camera orientation
22
+ LClick/M - Enable mouse movement
23
+ WSAD - forward/back/strafe left/right
24
+ LShift - 'run'
25
+ E - up
26
+ Q - down
27
+ L - animate light direction
28
+ U - toggle shadows
29
+ C - cycle through cameras
30
+ 5/6 - decrease/increase shadow projection width
31
+ 7/8 - decrease/increase shadow projection height
32
+ 9/0 - decrease/increase shadow projection near/far
33
+
34
+ Space - Play/Pause animation
35
+ Enter - Cycle through animations
36
36
"
37
37
) ;
38
38
App :: new ( )
@@ -404,7 +404,8 @@ struct CameraController {
404
404
pub key_up : KeyCode ,
405
405
pub key_down : KeyCode ,
406
406
pub key_run : KeyCode ,
407
- pub key_enable_mouse : MouseButton ,
407
+ pub mouse_key_enable_mouse : MouseButton ,
408
+ pub keyboard_key_enable_mouse : KeyCode ,
408
409
pub walk_speed : f32 ,
409
410
pub run_speed : f32 ,
410
411
pub friction : f32 ,
@@ -426,7 +427,8 @@ impl Default for CameraController {
426
427
key_up : KeyCode :: E ,
427
428
key_down : KeyCode :: Q ,
428
429
key_run : KeyCode :: LShift ,
429
- key_enable_mouse : MouseButton :: Left ,
430
+ mouse_key_enable_mouse : MouseButton :: Left ,
431
+ keyboard_key_enable_mouse : KeyCode :: M ,
430
432
walk_speed : 5.0 ,
431
433
run_speed : 15.0 ,
432
434
friction : 0.5 ,
@@ -442,6 +444,7 @@ fn camera_controller(
442
444
mut mouse_events : EventReader < MouseMotion > ,
443
445
mouse_button_input : Res < Input < MouseButton > > ,
444
446
key_input : Res < Input < KeyCode > > ,
447
+ mut move_toggled : Local < bool > ,
445
448
mut query : Query < ( & mut Transform , & mut CameraController ) , With < Camera > > ,
446
449
) {
447
450
let dt = time. delta_seconds ( ) ;
@@ -477,6 +480,9 @@ fn camera_controller(
477
480
if key_input. pressed ( options. key_down ) {
478
481
axis_input. y -= 1.0 ;
479
482
}
483
+ if key_input. just_pressed ( options. keyboard_key_enable_mouse ) {
484
+ * move_toggled = !* move_toggled;
485
+ }
480
486
481
487
// Apply movement update
482
488
if axis_input != Vec3 :: ZERO {
@@ -501,7 +507,7 @@ fn camera_controller(
501
507
502
508
// Handle mouse input
503
509
let mut mouse_delta = Vec2 :: ZERO ;
504
- if mouse_button_input. pressed ( options. key_enable_mouse ) {
510
+ if mouse_button_input. pressed ( options. mouse_key_enable_mouse ) || * move_toggled {
505
511
for mouse_event in mouse_events. iter ( ) {
506
512
mouse_delta += mouse_event. delta ;
507
513
}
0 commit comments