Skip to content

fix(camera): make wheel zoom steps reciprocal - #347

Merged
draedful merged 1 commit into
mainfrom
codex/fix-camera-zoom-formula
Sep 21, 2026
Merged

draedful merged 1 commit into
mainfrom
codex/fix-camera-zoom-formula

Conversation

@draedful

@draedful draedful commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

The previous wheel zoom formula used currentScale * (1 - dScale). Equal zoom-in and zoom-out wheel steps therefore used (1 + d) and (1 - d) factors and did not return to the original scale.

This changes wheel zoom to apply the signed delta in log-scale space with currentScale * exp(-dScale). Relative zoom speed remains configurable through SPEED and STEP, while opposite steps become reciprocal.

Changes

  • use an exponential scale multiplier in Camera.handleZoom;
  • document the relative/log-scale semantics of SPEED and STEP;
  • add an E2E regression test for equal zoom-in and zoom-out steps.

Validation

  • npm run lint
  • npm run test:unit -- --runInBand
  • npm run test:e2e -- camera-control.spec.ts — 7 passed
  • npm run e2e:build
  • Prettier check and git diff --check

Summary by Sourcery

Make wheel zoom steps reciprocal by applying camera scale changes in log-scale space.

Bug Fixes:

  • Make equal wheel zoom-in and zoom-out steps return the camera to its original scale.

Enhancements:

  • Define camera zoom speed and step settings in relative/log-scale terms and apply zoom changes consistently across scales.

Documentation:

  • Document the relative zoom speed and log-scale step semantics for camera settings.

Tests:

  • Add an end-to-end regression test covering reversible equal zoom steps.

@sourcery-ai

sourcery-ai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

Wheel zoom now applies signed deltas in log-scale space via an exponential multiplier, so equal opposite wheel steps return to the original scale while SPEED and STEP remain configurable. The configuration documentation is updated and an E2E regression test verifies reversibility.

File-Level Changes

Change Details Files
Replace linear wheel-scale adjustment with a log-scale exponential multiplier to make opposite zoom steps reciprocal.
  • Compute the next camera scale as the current scale multiplied by exp(-dScale).
  • Retain configurable relative zoom behavior through SPEED and STEP while preserving wheel direction handling.
src/services/camera/Camera.ts
Clarify the zoom configuration contract to describe relative and log-scale semantics.
  • Document SPEED as a relative zoom-speed multiplier.
  • Document STEP as the base log-scale zoom increment and reciprocal-step behavior.
  • Update the settings reference and camera constant type comments.
src/graphConfig.ts
docs/system/graph-settings.md
Add end-to-end coverage for reversible equal wheel zoom steps.
  • Zoom to a known scale, apply equal zoom-in and zoom-out wheel deltas, and verify the original scale is restored.
e2e/tests/camera-control.spec.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Preview is ready.

@draedful
draedful merged commit 7e89d6f into main Sep 21, 2026
7 checks passed
@draedful
draedful deleted the codex/fix-camera-zoom-formula branch September 21, 2026 13:12
@gravity-ui gravity-ui Bot mentioned this pull request Sep 21, 2026
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.

2 participants