Repository navigation
Web app: 3D mouse navigation through the Gamepad API (#1336) - #1473
Conversation
) The web app now reads a 3Dconnexion device through navigator.getGamepads() and moves the view the way the desktop app does. The platform-independent navigation moves to crates/ui-egui/src/space_mouse.rs, shared by both apps. 3DxWare's emulated mouse wheel is dropped while the cap moves. The preference row reads "3D mouse" now that Linux and the browser have it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @CamWight, this is great work, and the measurements with a real SpaceMouse in Edge and Firefox (with the virtual-joystick profile) are exactly what I needed to trust it. Moving the device-independent part into One thing before I merge: since #1462, every page's camera input goes through the shared
A test that the cap leaves the view unturned on the flat pattern page would cover the |
…NavCaps (tangency-labs#1336) The 3D mouse now only reads the device, maps the axes, applies the dead zone and drops the emulated wheel; navigate_frame hands the frame's motion to the page showing the camera. navigation::device, which handle calls for its page, applies it with the page's NavCaps and height: the cap pans and zooms every page and turns the view only where the page may orbit, and not while a sketch is edited. hand_rolled_camera_input_is_rejected no longer exempts space_mouse.rs, scans the web app too, and reads CRLF checkouts as LF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # crates/ui-egui/src/navigation.rs
|
Thanks, good call. Done in eb6bc35:
|
Fixes #1336.
Change
The web app read no 3D mouse at all. All it got was 3DxWare's mouse-wheel emulation for browsers: a small, jerky zoom and nothing else.
It now reads the cap through the browser's Gamepad API and moves the view the way the desktop app does.
Shared code. The platform-independent part of the desktop's 3D mouse code moves to
crates/ui-egui/src/space_mouse.rs, with its tests:navigate_frame, which is the old per-frametickbody. That covers the preferences, the start page, the speed,begin_external_navigationand the repaint, plus the open-file-picker check the desktop made at its call site. It hands the frame's motion to the page that shows the camera.DriverMapping::applynow usesget_mut, because the mapping's fields are public now.Through the shared navigation (from the review):
navigation::device, whichhandlecalls for its page, applies the motion with the page'sNavCapsand the page's own height.hand_rolled_camera_input_is_rejectedno longer exemptsspace_mouse.rs, and it scans the web app too. It also reads CRLF checkouts as LF, so the split before a file's own tests works on Windows.The web app (
apps/solidcraft-web/src/space_mouse.rs):navigator.getGamepads()and takes a 3Dconnexion device if one is listed, else 3DxWare's virtual joystick.Name (Vendor: 046d Product: c62b)and Firefox's046d-c62b-Name.256f(3Dconnexion) counts with any product: the browser lists only its 3D mice as gamepads.046d(Logitech) counts only with 3Dconnexion's products from usb.ids. Logitech gamepads and wheels share that vendor id, and a pedal resting at -1 would spin the view forever.beef:046dis 3DxWare's virtual joystick.3DxWare's emulated wheel is dropped while the cap moves and for 150 ms after. Pinch zoom (
Zoomevents) is dropped the same way.Waking from idle. The browser sends no event when a gamepad moves.
gamepadconnectedlistener redraws once the cap is first moved on the page.The preference row read "3D mouse (Windows)" (Linux has worked since 3D mouse on Linux (hidraw) and devices that report all six axes in report 1 #343). It now reads "3D mouse" in every catalog that has the message, under the same id, as
docs/localization.mdasks.Docs. Getting started gains "3D mouse in the browser", covering:
The README points there.
Firefox lists only joysticks and gamepads, not 3D mice (Mozilla bug 1226575). Its Windows backend accepts only the HID usages Joystick and Game Pad (
kUsagePagesindom/gamepad/windows/WindowsGamepad.cpp), and a SpaceMouse is a Multi-axis Controller. It does list 3DxWare's virtual joystick, and a 3DxWare profile for Firefox can route the six axes there. The docs give that profile. It also stops the emulated wheel in Firefox.Validation
Measured with a real device (Windows 11, SpaceMouse Pro
046d:c62b, 3DxWare 10.9.8, Edge 155, Firefox 157):Tests:
crates/ui-egui/src/space_mouse.rs(10): the desktop's moved tests unchanged, plus:crates/ui-egui/src/navigation.rs(2 new):handle, the cap pans and zooms a flat page and never turns it, and turns the model and render pages;apps/solidcraft-web/src/space_mouse.rs(6):apps/solidcraft/src/space_mouse.rs(12): the desktop's decode and profile tests, plus a new one: each frame moves the view through the loaded 3DxWare mapping.Planted faults: 21, all caught after two test fixes. The first run caught 16 of 18. The two that survived (the speed clamp, and the desktop's frame ignoring the loaded mapping) led to the new speed test and the desktop frame test, and they're caught now, along with two more clamp variants. Six more faults went into the navigation change from the review, and all six were caught.
Desktop: behaviour unchanged. The Windows mapping when there's no 3DxWare profile is the same before and after; it's wrong on
maintoo (#1380).wasm: the web crate builds for
wasm32-unknown-unknownand is clean under clippy-D warningsthere.Gate:
cargo xtask ci's steps on Windows, onmainat 2bfec25.-D warnings(workspace and ui-egui), wasm and the web offline test pass.mainon this PC:control_render_export_respects_upstream_file_scope: this PC's%TEMP%is an 8.3 path (NAME~1).startup_steps_survive_a_rebase_and_running_ends_startup: checked onmain's build.fillet_beside_a_modelled_thread_finishes: a timing test under full load; it passes on its own.robustness_goldens: they give the same values onmainhere.mainmerged up to 843c548.mainmerged up to 843c548 (an earlier run shared a build folder with another branch, so it didn't count):robustness_goldenswere skipped locally: they fail the same way onmainhere and take an hour, and CI runs them.agent_chattests, which hit this PC's 8.3%TEMP%path (as in Windows: render-export file-scope test fails with an 8.3 TEMP path #1385);apply_off_thread_tests::ok_computes_off_the_window_thread_saying_so_then_applies, timing under load;hostile_params_never_panic, which fails onmaintoo:sketch.cutpanics on non-object parameters, sketch.cut panics when its parameters aren't a JSON object (hostile_params_never_panic fails on main since #1500) #1536.Screenshots of the behavior (when observable)
A still can't show the cap moving the view: the measurements above stand in for that. Preferences › Navigation in the web app, with the row that now reads "3D mouse":
Integration status
mainis merged in up to 843c548, with one conflict innavigation.rs(the newmiddle_double_clicksignature, kept). Before the PR opened, it was rebased after #1233 merged. The two conflicts, in the web app'sCargo.tomlfeatures andmain.rsmodules, keep both sides:MediaQueryListandGamepad,mod installandmod space_mouse. Nothing was force-pushed.Open PRs that touch the same files without touching these lines:
prefs.rsandcrates/ui-egui/src/lib.rs: Export the current 3D view as 2D DXF with optional hidden lines #1449, Show optional X/Y/Z distances in measurement overlays #1422, Preferences: choose the interface font (#1290) #1408, AI assistant sidebar: Anthropic, OpenAI-compatible endpoints and external agents #1271, Add optional ambient occlusion and graphics quality presets #1135 and In-app agent chat: your own coding agents over ACP, plus OpenAI-compatible endpoints #1102.crates/ui-egui/src/lib.rsonly: ui: review candidate physical material cards without assignment #1344, dev: familiar modelling workspace #1317 and library: transport PBR and engineering cards without lossy copies #1086.#1380 (the desktop's mapping on Windows without a profile, and 3DxWare's wheel on the desktop) builds on the shared module here and follows in its own PR.
🤖 Generated with Claude Code