Skip to content

feat: [Remote rendering 3.2c] attribute camera changes to the input that caused them - #124

Merged
margalva merged 22 commits into
mainfrom
feat/3.2c-add-camera-gesture-tracker
Sep 22, 2026
Merged

margalva merged 22 commits into
mainfrom
feat/3.2c-add-camera-gesture-tracker

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Addresses #20

Context

This is the third of 4 PRs for user story 3.2 (#20) of the phased implementation plan (ADR here) for adding remote rendering in VISOR.

After PRs 3.2a (#110) and 3.2b (#111) the server holds the camera and reads it on save_state, but only the load_state path writes it. For the record to stay current the browser needs to report camera changes back, and for the server to accept those reports the client needs to distinguish a user gesture from a camera change the server pushed; otherwise, every server-side camera update is echoed back as a gesture. This PR tags (on the client side only) each camera change event with its origin, user input or programmatic:

  • CameraGestureTracker tags a camera event gesture only while a mouse button is held on canvas, or within 300ms of a wheel event or a z/r keydown, and settles 300ms after the last event. Anything else is programmatic. (see the CameraGestureTracker docstring )
  • It settles 300ms after the last camera event and reports the origin once per settle.
  • IRenderer gains addCameraSettledListener; both renderers implement it.
  • VtkScene constructs the tracker and forwards camera events to it.

Nothing subscribes to the settle yet, so runtime behaviour is unchanged; the subscriber and the trigger to the server are implemented in 3.2d.

Testing

Manual tests of this PR need the wiring added in 3.2d, so the two need to be tested together.


Copilot summary

This pull request introduces a new mechanism for debouncing and attributing camera change events to either user gestures or programmatic actions. The main addition is the CameraGestureTracker, which tracks user input and reports when the camera has "settled" after a change, along with the origin of that change. This enables more accurate server-side camera state recording and improves the clarity of user-initiated vs. programmatic camera changes. The implementation includes new tests, interface changes, and integration into both the renderer and scene classes.

Key changes:

Camera gesture tracking and debounce logic

  • Added CameraGestureTracker (wasm/CameraGestureTracker.js) to debounce raw camera events and attribute each settle window to either a user gesture or a programmatic change, with detailed handling of user input and event timing.
  • Comprehensive Jest tests for CameraGestureTracker, verifying debounce timing, input attribution, and teardown behavior.

API and type changes

  • Introduced a new CameraOrigin type ('gesture' | 'programmatic') and documented its semantics in IRenderer.ts.
  • Added addCameraSettledListener to the IRenderer interface, providing a callback that fires once per settle window with the origin of the change.

Renderer and scene integration

  • Implemented addCameraSettledListener as a no-op in NullRenderer and as a proxy to the underlying scene in WasmRenderer. [1] [2]
  • Integrated CameraGestureTracker into VtkScene, ensuring proper listener management and teardown during scene rebuilds to avoid stale reports. [1] [2]

@github-actions github-actions Bot added test Work associated with testing added enhancement New feature or request labels Sep 16, 2026
@LKasianAnsys
LKasianAnsys changed the base branch from main to feat/3.2b-save-state-reads-from-server-camera September 16, 2026 20:04
@github-actions github-actions Bot removed the test Work associated with testing label Sep 16, 2026
@LKasianAnsys LKasianAnsys changed the title feat: 3.2c add camera gesture tracker feat: [Remote rendering 3.2c] add camera gesture tracker Sep 16, 2026
@LKasianAnsys
LKasianAnsys changed the base branch from feat/3.2b-save-state-reads-from-server-camera to main September 16, 2026 21:22
@github-actions github-actions Bot added the test Work associated with testing label Sep 16, 2026
@LKasianAnsys
LKasianAnsys changed the base branch from main to feat/3.2b-save-state-reads-from-server-camera September 16, 2026 21:29
@github-actions github-actions Bot removed the test Work associated with testing label Sep 16, 2026
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 3.2c] add camera gesture tracker feat: [Remote rendering 3.2c] attribute camera changes to the input that caused them Sep 16, 2026
@LKasianAnsys LKasianAnsys self-assigned this Sep 16, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2b-save-state-reads-from-server-camera branch from ab48dec to ebb70a9 Compare September 21, 2026 20:09
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2c-add-camera-gesture-tracker branch from 5da4a63 to b149c50 Compare September 21, 2026 20:09
ansBAkula
ansBAkula previously approved these changes Sep 22, 2026

@ansBAkula ansBAkula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. Thanks.

Base automatically changed from feat/3.2b-save-state-reads-from-server-camera to main September 22, 2026 16:05
@LKasianAnsys
LKasianAnsys dismissed ansBAkula’s stale review September 22, 2026 16:05

The base branch was changed.

@github-actions github-actions Bot added the test Work associated with testing label Sep 22, 2026
@github-actions github-actions Bot removed the test Work associated with testing label Sep 22, 2026
@margalva
margalva merged commit 0428c6f into main Sep 22, 2026
15 checks passed
@LKasianAnsys
LKasianAnsys deleted the feat/3.2c-add-camera-gesture-tracker branch September 22, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

added enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants