Skip to content

arigl: third-person mouse look, and a Controls window for keys and mouse - #963

Merged
transfix merged 9 commits into
masterfrom
feat/arigl-mouse-look
Nov 2, 2026
Merged

transfix merged 9 commits into
masterfrom
feat/arigl-mouse-look

Conversation

@transfix

@transfix transfix commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

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)

  • Mouse look (setMouseLookEnabled, settings.mouse_look), in Orbit:
    • A click on the scene captures the pointer. That click is not passed on (takeClick).
    • While captured, the mouse turns the orbit with no button held, the same way a drag does.
    • Releasing the pointer happens on Free the mouse, a new rebindable camera key (keys.release_pointer, Escape by default); the browser's own Escape also works.
    • Once released, drags orbit as before, and the next click on the scene captures again.
    • Turning mouse look off releases the pointer. A settings write is enough; update() handles it.
  • Real pointer capture on every window type:
    • cvcGL's SDL window uses SDL's relative mouse mode. SDL lets go while the window has no focus. The interactor moves VTK's event position by each motion's delta, so VTK observers see ordinary deltas.
    • In the browser it uses the page's pointer lock on VTK's canvas (EM_JS). The motion comes from the document's movementX/Y, because VTK's positions stand still while locked. Escape, a lost focus or a refused request releases the capture.
    • VTK's own windows keep the hide-and-warp approach.
    • Fly mode gets all of this too.
  • settings.invert_yaw.
  • Orbit floor (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 elevation range (orbit.min_elevation / max_elevation), for hosts that want one. arigl no longer uses it.
  • On-screen cue (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:

  • The avatar faces where the camera aims and walks that way.
  • The camera looks past the avatar's right shoulder at a point 4 m ahead of it (at most a third of the camera's distance), so the crosshair marks where you aim, downrange. The camera still turns about the avatar, which always faces where it looks. The pivot eases in and out over 0.2 s as mouse look turns on and off. The room's framing distance is kept.
  • Turning sends at most 20 intent proposals a second; a key change still proposes at once. Your own avatar turns with the camera every frame between proposals (only its facing, so the walk you predict stays the one the relay runs).

In either look:

  • The ground under the avatar is the camera's floor, so you can look straight up without the eye going underground.
  • While the eye is inside the avatar, the avatar is hidden (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_local ran subscriptions_for_path for 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_path and 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 by ImGuiOverlay from WantCaptureMouse. 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>_tip and 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...):

  • A host's pointer and camera settings appear above the key bindings (AppRuntime::set_host_mouse(MouseControls)): Drag to look / Mouse look, sensitivity, invert up/down, invert left/right, Camera distance, and a note.
  • arigl binds these rows to its camera's settings.* and orbit.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:

keys state key (under the scene prefix) default
the camera's fly keys, Orbit / fly, Free the mouse viewers.main.camera.keys.<action> W A S D, Space, Left Ctrl, Left Shift, Tab, Escape
the avatar's walk keys (were hard-coded) viewers.main.avatar.keys.<action> W or Up, S or Down, A or Left, D or Right

Tests

  • cvcgl_camera has a new section M with 19 checks:
    • off: no turn without a drag, and clicks are reported;
    • a click captures, and is not reported;
    • turning with no button held; invert yaw;
    • both elevation limits;
    • Escape frees the pointer; the release key can be rebound;
    • turning mouse look off from state frees the pointer.
  • Section N, 8 checks on the orbit floor: level keeps the full distance; looking up holds the eye just above the floor and slides it along its line of sight; straight up stays above the floor; coming back down restores the distance; the orbit distance is never changed; with no floor, the eye goes under.
  • New 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.
  • On Windows (shared GL build), all pass: cvcgl_camera, ariadne_runtime_test 246/246, cvcgl_viewport, cvcgl_sdl_input, cvcgl_sdl_attach.
  • In the browser: I built cyprty wasm from 6a014a1 (the deployed Conference: avatar poses as compact per-viewer snapshots at up to 60 Hz #951) plus this PR on catx-03, and ran it against a local relay.
    • The in-app browser refuses pointer lock outright (WrongDocumentError; it's embedded), so for this test I stubbed only requestPointerLock to grant it. Everything else is real.
    • A click on the scene captured the pointer: the crosshair appeared and the hint went away.
    • movementX events turned the view.
    • W walked where the camera aimed. On the relay, two 2 s walks with 360 px of rightward motion between them headed −108.3° and then 161.7°: exactly 90° clockwise, 4.0 m each.
    • Escape freed the pointer; the hint came back and motion stopped turning the view.
    • The test also showed that Chromium refuses with a rejected promise and no pointerlockerror event. A refusal is now counted once however it is reported (449813d).
    • The lock logic (granted, ended by the browser, the embedded-page refusal, a refusal outside a click retried in the next click, a second refusal, letting go first) passed 10 of 10 checks in a harness page that runs the exact EM_JS body.
  • Turning, measured (second round). Headless Chrome on the GPU (~50 fps) ran this branch's wasm against a local relay whose debug line now shows each participant's facing and intent yaw. A page script stubbed the lock and sent movementX and W.
    • Standing turns reached the relay as they happened: 120° → 30° → −60°.
    • Each turn while walking changed the walk: −60° → −150° → 120°.
    • Slow 4 s and 8 s sweeps showed up at the relay while they were happening.
    • Temporary timers in the room step found the 80 ms proposal. After the state fix: proposals 0.3 ms, frames 22-27 ms in every phase.
  • New 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.
  • Windows, this round: state_sync_adapter (8), link forwarding (13), cluster shard (28), distributed session (19), holon (37), holon_sync (19), room_relay_integration (16), state_transport_ws (39): all pass.
  • Pointer lock, third round. The harness page now has 17 checks, all passing; 7 are new, for the press taking the lock. In headless Chrome with a strict lock stub (granted only inside a press, refused from the frame):
    • the first press took the lock: 1 request, 0 refused;
    • a simulated Esc freed it, and the next press took it again;
    • every turn reached the relay as before.
  • Third round on Windows: cvcgl_camera, ariadne_runtime_test 246/246, RoomAvatar (short values and their tips) all pass, 72/72 in the filtered ctest run.
  • Not verified: a real pointer lock in a stand-alone browser (this round's fix targets exactly that; please try it). The new tooltips have not been seen on screen yet. Please try ?look=mouse in Chrome or Firefox.

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
transfix merged commit 2c5d973 into master Nov 2, 2026
27 checks passed
@transfix
transfix deleted the feat/arigl-mouse-look branch November 2, 2026 07:39
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant