MuJoCo Studio: Support Ctrl+Option+Left Click Drag for perturbation

Support Ctrl+Option+Left Click Drag (maps to Ctrl+Alt+Left Click Drag in the application) to apply point force perturbations (translation) on the robot in the WebGL live viewer. This matches the Mac experience in the native MuJoCo simulate app and provides a fallback for Mac users where Right Click is difficult to trigger.

PiperOrigin-RevId: 919767954
Change-Id: I4a1d1c05784a8257d13f64f738af5b4841a615b3
This commit is contained in:
Baruch Tabanpour
2026-05-22 11:14:11 -07:00
committed by Copybara-Service
parent 5c21c8d28b
commit 466d068089
+8 -2
View File
@@ -461,14 +461,20 @@ void App::HandleMouseEvents() {
if (perturb_.select > 0) {
mjtMouse action = mjMOUSE_NONE;
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
action = io.KeyShift ? mjMOUSE_ROTATE_H : mjMOUSE_ROTATE_V;
if (io.KeyAlt) {
action = io.KeyShift ? mjMOUSE_MOVE_H : mjMOUSE_MOVE_V;
} else {
action = io.KeyShift ? mjMOUSE_ROTATE_H : mjMOUSE_ROTATE_V;
}
} else if (ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
action = io.KeyShift ? mjMOUSE_MOVE_H : mjMOUSE_MOVE_V;
} else if (ImGui::IsMouseDown(ImGuiMouseButton_Middle)) {
action = mjMOUSE_ZOOM;
}
const mjtPertBit active =
action == mjMOUSE_MOVE_V ? mjPERT_TRANSLATE : mjPERT_ROTATE;
(action == mjMOUSE_MOVE_V || action == mjMOUSE_MOVE_H)
? mjPERT_TRANSLATE
: mjPERT_ROTATE;
if (active != perturb_.active) {
platform::InitPerturb(model(), data(), &camera_, &perturb_, active);
}