Repository navigation
arigl: third-person mouse look, and a Controls window for keys and mouse - #963
Merged
Merged
Conversation
A second way to look, beside drag to orbit and click to face: mouse look, the game camera. - CameraController::setMouseLookEnabled (settings.mouse_look): in Orbit, a click on the scene captures the pointer and the mouse then turns the orbit with no button held. Free the mouse (a new camera key, keys.release_pointer, Escape) gives the pointer back to the UI; the next click on the scene takes it again. The windows stay where they are. - Pointer capture is real on every window now: SDL's relative mouse mode on cvcGL's SDL window (let go while it has no focus), the page's pointer lock in the browser (its motion from the document's movementX/Y; Escape or a lost focus ends it), the old hide-and-warp on VTK's own windows. - Also new: settings.invert_yaw, and an orbit elevation range (orbit.min_elevation / max_elevation) that holds a third-person eye off the floor. A crosshair shows while the mouse aims, a hint while it does not. - In conference mode, under mouse look our avatar faces where the camera aims and walks that way. The pivot sits over its right shoulder. Turning proposes at most 20 intents a second (a key still proposes at once). - The Keys window is now the Controls window (Settings > Controls...): a host's mouse settings (AppRuntime::set_host_mouse, MouseControls: the look, sensitivity, invert up/down and left/right) above every key binding. - Every key arigl acts on is now a binding in the state tree, beside what reads it. The avatar's walk keys, which were hard-coded W/A/S/D and arrows, are <viewer>.avatar.keys.*, and the camera's Escape is keys.release_pointer. A touch screen keeps dragging. - $CVC_ARIGL_LOOK=mouse|drag, and cyprty's ?look=mouse, pick the starting look. Drag to look stays the default until mouse look has been tried.
The camera asks for the lock from the frame, just after the click that captures (VTK's wasm events are queued). Chromium grants that within the click's activation; a browser that grants it only inside the click's own handler refuses, so the request is made again in the next mouseup on the canvas, and only a second refusal lets the capture go.
…s it Tried in the browser: Chromium rejects the request of a page that can never lock (an embedded one) with WrongDocumentError and fires no pointerlockerror, so the retry, which listened only for the event, would have left the camera captured with no lock. A refusal now comes from the event, the rejected promise, or both, and counts once; one that can never be granted (WrongDocumentError, NotSupportedError) lets go at once, without waiting for a retry. The click-to-look hint moves to just under the middle of the view; at the bottom the conference's Avatar window covered it.
…for the eye
From trying mouse look:
- Mouse look no longer pulls the camera in to 4.5 m. It keeps the framing
the room starts with. The Controls window has a Camera distance slider
(MouseControls::distance), bound to the camera's orbit.distance, which
the wheel also changes.
- CameraController::setOrbitFloor (orbit.floor.{on,height,clearance}):
an orbit eye that would go under the floor slides in along its line of
sight toward the centre instead. The orbit distance is kept, so the
eye goes back out as the view comes down. arigl puts the floor at the
avatar's feet in either look, and drops mouse look's elevation limit:
the view can look straight up.
- room_view::set_self_visible: arigl hides our own avatar while the eye
is inside it (looking straight up from just above the floor) rather
than show its inside.
…ons nothing reads state_sync_adapter::dispatch_local called subscriptions_for_path for every local mutation under the attached subtree, then dropped the result: the router is not dispatched to yet. That lookup expands the path through every transparent link, and to find the links it lists every node in the app's tree (state::children is recursive) and looks each one up again. In a large app that is milliseconds per write. In the browser conference client, an avatar turn under mouse look is about ten writes (the intent's five leaves, touched then set), and it took 80 ms. Turning proposes up to 20 times a second, so frames went from 22 ms to 175 ms while the mouse moved. The lookup is gone from dispatch_local. Measured in headless Chrome on the same build, a proposal now takes 0.3 ms, and frames stay at 22-27 ms through continuous turning. subscriptions_for_path and its forwarding counter are unchanged for callers that ask.
…ogs each facing Under mouse look the avatar faces where the camera aims. The relay already heard each turn (at most 20 intents a second, a key at once), but our own prediction only turned when a proposal went out, so on your own screen the avatar turned in 50 ms steps. It now takes the camera's heading every frame. Only the facing changes between proposals, so the walk we predict stays the one the relay runs. While the document drives the avatar, it is left alone. - arisrv: the per-participant debug line (CVC_ARISRV_ROOM_DEBUG) now shows the pose's facing and the intent's yaw in degrees, so a turn in place can be seen at the relay. - holon_sync_test: ATurnInPlaceReachesTheRelayAndThePeer. With the live room's holons (Jolt), yaw-only intents turn A in its own prediction, at the relay and in B's view, and A does not walk. - ARIADNE.md: what turning does on your screen and for everyone else. In headless Chrome against a local relay, standing turns, turns while walking and slow sweeps all reached the relay as they happened. Each walk changed direction with the mouse.
… aims ahead Tried in Chrome, mouse look turned the view, but the cursor stayed visible and the turn stopped at the screen's edge. The page never held the pointer lock: the camera asked for it from the frame after the click (VTK queues its events), and Chrome can refuse a request made there. Only a second click would then retry it, and nothing asked for one. - cvcGL (browser): while mouse look waits for a press (on, in Orbit, the pointer not over a window), a press on the canvas takes the lock inside its own handler, where a browser grants it. The camera adopts a lock taken that way. A press over a window stays the UI's: CameraController::setPointerOverUi, which ImGuiOverlay sets each frame from WantCaptureMouse. The request from the frame is still made for a host that captures in code, and the console now says why the browser refused one. - CameraController::orbitDistance(). - arigl: under mouse look the camera looks past our right shoulder at a point 4 m ahead (at most a third of the orbit distance, so the camera stays behind us). The crosshair marks where we aim, downrange, instead of the spot beside our head. We face where the camera looks, so the camera still turns about us. The pivot eases in and out over 0.2 s as mouse look turns on and off. The lock logic passes 17 of 17 checks in a harness page that runs the exact EM_JS body, 7 of them new: a press takes the lock and the frame then asks nothing more; no request for a press that isn't armed, or for a right press; a press after a refusal from the frame takes it; one request while one is pending.
In a narrow window the explanations beside the values were cut off: "on, the same for everyone
(the re", "slow to what resting power sustai", and the ledger's third column ("resting power,
all the time", "speeding up, pushing", "carrying your weight along", ...).
- avatar_panel publishes each policy line as a short value ("840 N", "1.20 kW", "2.2 m/s",
"slow down"). What the line means is published beside it as policy.<line>_tip.
- conference_roster.ari: each policy row's label and value show that tip on hover. The ledger
is two columns: each note is the row's tooltip, and "balances (residual 0.000 J)" is the
"now" row's tooltip.
- room_avatar_test checks the short values and their tips.
# Conflicts: # src/arigl/main.cpp # src/arigl/web/cyprty.html
transfix
added a commit
that referenced
this pull request
Nov 2, 2026
* arigl on a phone: UI size in logical pixels, windows in view, the system keyboard VTK sizes the browser canvas in device pixels (CSS size x devicePixelRatio, about 3 on a phone), so the overlay's 2.0 touch scale drew ~11 CSS px text, and the "short side under 700 px" phone check never fired. - ImGuiOverlay: the UI size (ui.scale) is in logical pixels, times the display's pixel ratio (FontScaleMain x FontScaleDpi; devicePixelRatio, read each frame; setPixelRatio overrides). Touch starts at 1.25. Scale changes land at the next frame and carry the open windows along. Touch slop, drag threshold and title-bar-only moves follow touch mode. The show/hide button stays above every window but a popup. - ImGuiBackend: a document's px (window pos/size, tracks, columns, images, plots) scale with the UI, and persisted geometry is logical px. A window opens inside the view (a fitting one again once measured). - AppRuntime::set_host_ui_size: a "UI size" list at the top of the Controls window (titled Controls, as in #963); arigl binds it to the overlay's scale. - The browser system keyboard: while a finger activates an ImGui text field the overlay focuses a hidden <input> at its caret (in the touchend gesture, for iOS) and feeds ImGui what the keyboard does to it. - cyprty.html hides its key hints and footer under 600 px; ARIADNE.md 5.11. * UiSettings: don't hand its own writes back to the overlay The constructor seeds the defaults (UI size 1, no touch) and, being synchronous, handed them straight to ImGuiOverlay's apply callback, so a touch device's mode and UI size were lost before the first frame: the phone screenshots came up at 100%. Fence the seed and set() as ViewportLayout does; an outside edit (the Controls window's UI size) still reaches the overlay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a second way to look, alongside drag-to-orbit plus click-to-face: mouse look, the third-person game camera. Click the scene and the mouse aims; W walks where you aim; Escape gives the mouse back to the windows, which stay where they are. It also adds a generic Controls window for key bindings and mouse settings that every Ariadne host can use.
Camera (
CameraController)setMouseLookEnabled,settings.mouse_look), in Orbit:takeClick).keys.release_pointer, Escape by default); the browser's own Escape also works.update()handles it.EM_JS). The motion comes from the document'smovementX/Y, because VTK's positions stand still while locked. Escape, a lost focus or a refused request releases the capture.settings.invert_yaw.setOrbitFloor,orbit.floor.{on,height,clearance}): an orbit eye that would go under the floor slides in along its line of sight toward the centre instead. The orbit distance is kept, so the eye goes back out as the view comes down.orbit.min_elevation/max_elevation), for hosts that want one. arigl no longer uses it.ImGuiOverlay, drawn under the windows): a crosshair while the mouse aims, and a one-line hint while it does not.Conference (
arigl)Under mouse look:
In either look:
room_view::set_self_visible).Drag-to-look and click-to-face are unchanged and remain the default until mouse look has been tried.
$CVC_ARIGL_LOOK=mouse|drag(cyprty's?look=mouse) picks the starting look. Touch screens keep dragging.State: a local write no longer walks the whole tree
state_sync_adapter::dispatch_localransubscriptions_for_pathfor every local mutation and threw the result away (the router isn't dispatched to yet). Its transparent-link expansion lists every node in the app's tree and looks each one up again.In the browser client that cost 80 ms per turn proposal (about ten writes). Continuous turning dropped the page from ~45 fps to ~6-12 fps. With the lookup gone, a proposal takes 0.3 ms and frames stay at 22-27 ms while turning.
subscriptions_for_pathand its counter are unchanged for callers that ask.Browser pointer lock: taken in the press itself
Tried in Chrome, mouse look turned the view, but the cursor stayed visible and turning stopped at the screen's edge: the lock was never held. The camera asked for it from the frame after the click (VTK queues its events), Chrome can refuse that, and only a second click retried it.
Now, while mouse look waits for a press (on, in Orbit, the pointer not over a window), a press on the canvas takes the lock inside its own handler, and the camera adopts it. A press over a window stays the UI's:
CameraController::setPointerOverUi, set each frame byImGuiOverlayfromWantCaptureMouse. The console says why when a browser refuses.Avatar window: short values, tooltips for what they mean
The explanations beside the values were cut off in a narrow window. Each policy line is now a short value ("840 N", "2.2 m/s"), with its meaning published as
policy.<line>_tipand shown as the row's tooltip. The ledger's notes and the balance line are tooltips too, and the ledger is two columns.Controls window
The Keys window becomes the Controls window (Settings > Controls...):
AppRuntime::set_host_mouse(MouseControls)): Drag to look / Mouse look, sensitivity, invert up/down, invert left/right, Camera distance, and a note.settings.*andorbit.distance(the wheel moves the same value).Every key in the state tree
Every key arigl acts on is now a binding in the state tree, next to whatever reads it, and is listed in the Controls window:
viewers.main.camera.keys.<action>viewers.main.avatar.keys.<action>Tests
cvcgl_camerahas a new section M with 19 checks:AriadneAppRuntime.ControlsWindowShowsTheHostsMouseSettings: the rows (Camera distance included), their order, and that writes land where the camera reads them. The Keys tests are renamed to Controls.cvcgl_camera,ariadne_runtime_test246/246,cvcgl_viewport,cvcgl_sdl_input,cvcgl_sdl_attach.WrongDocumentError; it's embedded), so for this test I stubbed onlyrequestPointerLockto grant it. Everything else is real.movementXevents turned the view.pointerlockerrorevent. A refusal is now counted once however it is reported (449813d).EM_JSbody.movementXand W.HolonSyncTest.ATurnInPlaceReachesTheRelayAndThePeer: with the live room's holons (Jolt), yaw-only intents turn A in its own prediction, at the relay and in B's view, and A does not walk.cvcgl_camera,ariadne_runtime_test246/246,RoomAvatar(short values and their tips) all pass, 72/72 in the filtered ctest run.?look=mousein Chrome or Firefox.