Skip to content

Commit eab2c19

Browse files
committed
fix(viewer): fly camera disables Genesis default keybinds (W/A/S/D conflict)
Genesis' default_controls bind W/A/S/D (world-frame / camera-rotation / save-image / wireframe), which collide with fly-mode WASD. Genesis only auto-disables default keybinds when the ImGui overlay is on, so without imgui the defaults fired alongside fly movement. Force enable_default_keybinds=False in ViewerOptions whenever fly_camera is on, so fly owns the keyboard regardless of the overlay.
1 parent 5be90e8 commit eab2c19

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎src/genelab/scene/interactive_scene.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def _viewer_option_kwargs(sim_cfg: "SimulationCfg", *, enable_gui: bool) -> dict
4848
kwargs["camera_pos"] = sim_cfg.camera_pos
4949
if sim_cfg.camera_lookat is not None:
5050
kwargs["camera_lookat"] = sim_cfg.camera_lookat
51+
if sim_cfg.fly_camera:
52+
# Genesis' default controls bind W/A/S/D (world-frame / camera-rotation / save-image /
53+
# wireframe), which collide with fly-mode WASD. Genesis only auto-disables them when the
54+
# ImGui overlay is on; turning them off here lets fly own the keyboard either way.
55+
kwargs["enable_default_keybinds"] = False
5156
return kwargs
5257

5358

‎tests/test_interactive_scene.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def test_camera_framing_forwarded_to_viewer_options() -> None:
9292
assert bare["enable_gui"] is True
9393

9494

95+
def test_fly_camera_disables_genesis_default_keybinds() -> None:
96+
# Genesis' default controls bind W/A/S/D (world-frame, camera-rotation, save-image, wireframe)
97+
# — which collide with fly-mode WASD whenever the ImGui overlay is off (with the overlay on,
98+
# Genesis already disables them). Forcing them off when fly_camera is on makes fly own the
99+
# keyboard regardless of the overlay; when fly_camera is off, Genesis keeps its defaults.
100+
from genelab.scene.interactive_scene import _viewer_option_kwargs
101+
102+
flying = _viewer_option_kwargs(SimulationCfg(vis=True, fly_camera=True), enable_gui=False)
103+
assert flying["enable_default_keybinds"] is False
104+
105+
no_fly = _viewer_option_kwargs(SimulationCfg(vis=True, fly_camera=False), enable_gui=False)
106+
assert "enable_default_keybinds" not in no_fly
107+
108+
95109
def test_terrain_scene_collapses_env_grid(genesis_runtime: Any) -> None:
96110
"""Regression: a height-field terrain is one shared mesh spanning all envs, with per-env
97111
spawn origins spread across it. Genesis's ``env_spacing`` grid replicates+offsets the

0 commit comments

Comments
 (0)