Repository navigation
Show a scale bar in the 3D view with the orthographic camera - #447
Merged
Merged
Conversation
Add a "Show scale bar" render setting. With the orthographic camera on, an overlay in the bottom-right corner of the viewport shows a bar of a round length (1, 2, 5 x 10^n) labelled with the length unit of the script's units style (Å, σ, nm, ...). It reads the camera every animation frame, so it follows zoom, resize and camera changes. It is hidden in perspective mode, where no single length scale applies, and the unit is left out until LAMMPS has reported the unit style. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
andeplane
marked this pull request as ready for review
October 16, 2026 06:59
Brings the scale bar PR up to date with main's refactors (EngineRegistry, split store/screen modules, shared design tokens, prettier/ESLint in CI). Conflicts: - src/containers/View.tsx: main moved the simulation box/wall overlays into useSimulationBoxOverlays, dropped the styled Wrapper for a plain div and the THREE namespace import. Kept main's structure; re-added the unitStyle selector, the scale bar imports (OrthographicCamera as a named three import) and the <ScaleBar> overlay inside the new wrapper div. The visualizer now comes from the EngineRegistry via useEngineState. - src/containers/View.test.tsx: kept main's EngineRegistry type import and dropped the unused Modifier import; kept the PR's UnitStyle import. ScaleBar.tsx now styles the overlay with the shell's media tokens (--media-control-bg, --media-control-border, --media-text, --radius) instead of hard-coded colors, matching the other viewport controls. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
andeplane
pushed a commit
that referenced
this pull request
Oct 16, 2026
Resolved the View.tsx import conflict by keeping both the pan remap and the scale bar imports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
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.
Requested by Anders Hafreager · project thread
Before: the 3D view gave no sense of how large molecules or the simulation box are.
After: with the orthographic camera and the new "Show scale bar (orthographic camera)" setting on, a bar in the bottom-right corner shows a round length (1, 2 or 5 × 10ⁿ) labelled with the script's length unit (Å for real/metal, σ for lj, and so on). It follows zoom, resize and camera switches, and is hidden in perspective mode or when the setting is off. The setting is off by default.
How: a pointer-transparent HTML overlay polls the active camera every animation frame and computes length per pixel as frustum height ÷ zoom ÷ viewport height. omovi has no public camera getter, so
View.tsxreadsvisualizer["camera"]in one commented place. The unit comes from the unit style LAMMPS already reports (simulationStatus.unitStyle) viaUNIT_SYSTEMS; until LAMMPS prints it, the label is just the number so it's never wrong. The overlay uses the shell's media-control design tokens like the other viewport controls. Unit tests cover the rounding and per-pixel math, the overlay, the show/hide rules, the unit label and the new setting. Checked in headless Chromium on the 2D LJ fluid example: the bar appears with the orthographic camera, read "2 σ" when zoomed in, rescales on zoom and resize, and disappears in perspective mode.Closes #77
🤖 Generated with Claude Code
https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN