Skip to content

Return the viewport extent in scene units so zoom survives recompute - #89

Merged
bjmorgan merged 3 commits into
mainfrom
feature/viewport-zoom-recompute
Aug 17, 2026
Merged

Return the viewport extent in scene units so zoom survives recompute#89
bjmorgan merged 3 commits into
mainfrom
feature/viewport-zoom-recompute

Conversation

@bjmorgan

Copy link
Copy Markdown
Owner

_scene_extent returned the interactive viewport half-extent scaled by view.zoom, but the projected coordinates already carry view.zoom. When a frame-navigation redraw recomputed the extent with the current zoom baked in, the viewport and the coordinates scaled together and cancelled, silently resetting the interactive zoom.

Return the extent in scene units instead (drop the * view.zoom). The value's two consumers were already written to be correct with an unzoomed extent, so they need no change: the viewport axis limits (base_extent * 1.15) become a fixed window that the zoom-carrying coordinates grow within, and the pan step (base_extent / view.zoom) becomes a fraction of the visible scene extent, so pan steps stay proportional as you zoom rather than coarsening after a recompute.

view.zoom is now an absolute magnification, where 1 fits the scene, so a view opened at a magnification above one starts zoomed in rather than being absorbed into the opening fit. This also makes the interactive viewer consistent with the static render path, which already crops on a preset zoom.

_scene_extent is interactive-only and off the static render path, so the change is pinned by a unit test — the extent is now independent of view.zoom — rather than the golden harness.

Copilot AI lite review requested due to automatic review settings August 17, 2026 09:35

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Address review follow-ups on the viewport zoom fix:

- Add a non-circular test that the world-space pan step halves when the
  zoom doubles.  The existing pan tests ran only at zoom 1 (where the
  `/ view.zoom` is inert) and mirrored the production expression as
  their own oracle, so a `/ view.zoom` -> `* view.zoom` regression would
  have passed unnoticed.
- Document in `_scene_extent`'s docstring that the extent is in scene
  units and excludes `view.zoom` because the coordinates already carry
  it, so consumers must not re-apply it.
- Reword the `_KEY_PAN_FRACTION` comment: the step is a fraction of the
  viewport, not of the scene extent.
- Changelog: call it "zoom" to match the API.
Copilot AI review requested due to automatic review settings August 17, 2026 10:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bjmorgan
bjmorgan merged commit c6ed6b5 into main Aug 17, 2026
5 checks passed
@bjmorgan
bjmorgan deleted the feature/viewport-zoom-recompute branch August 17, 2026 10:19
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