Skip to content

Add "Show Dimensions" overlay for selected splat bound#907

Merged
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:dim-dev
May 20, 2026
Merged

Add "Show Dimensions" overlay for selected splat bound#907
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:dim-dev

Conversation

@slimbuck

Copy link
Copy Markdown
Member

Summary

Adds a new "Show Dimensions" toggle to the View panel that overlays the world-space length of each axis of the selected splat's bounding box directly on the 3D viewport. Each axis label is rendered as SVG text aligned with — and offset to the outside of — the corresponding outer-silhouette edge of the box, so users can read the X/Y/Z extents at a glance while orbiting.

Implementation

  • New [src/ui/bound-dimensions-overlay.ts](src/ui/bound-dimensions-overlay.ts) creates a single SVG attached to canvasContainer.dom with three <text> children (one per axis). Each frame on prerender it projects the 8 world-space corners of the splat's local bound, picks the outermost parallel edge per axis (farthest screen-space midpoint from the projected box centroid), and positions each label at that edge's midpoint, rotated to match its on-screen direction with a perpendicular offset that always points away from the box centre. Labels auto-flip 180° to stay upright.
  • Behind-camera culling is done with a world-space dot product against the camera forward direction, so labels disappear cleanly when the box leaves the view frustum (rather than projecting to garbage screen coordinates).
  • A 1-pixel² tie tolerance on the edge-selection score prevents frame-to-frame flicker in orthographic mode, where opposite parallel edges are exactly equidistant from the box centre.
  • The "Show Dimensions" toggle is independent of "Show Bound" — users can show dimensions without the wireframe, or vice versa. State is wired through new camera.boundDimensions / camera.setBoundDimensions / camera.toggleBoundDimensions events in [src/editor.ts](src/editor.ts), defaults to false in [src/scene-config.ts](src/scene-config.ts), and round-trips via docSerialize.view / docDeserialize.view.
  • Labels are styled in [src/ui/scss/tool.scss](src/ui/scss/tool.scss) with a black stroke halo (paint-order: stroke) so they remain legible against any background.
  • Localized in all 9 locale files (panel.view-options.show-bound-dimensions).

Test plan

  • Load a splat, select it, toggle "Show Dimensions" on — three numeric labels appear, one per axis edge.
  • Orbit the camera in perspective mode — labels track the outer silhouette edges and stay upright.
  • Switch to orthographic mode — labels do not flicker between frames.
  • Apply translate / rotate / non-uniform scale to the splat — displayed dimensions update and match the visible wireframe extents.
  • Pan the splat partially / fully off-screen — labels hide cleanly per axis.
  • Toggle "Show Bound" off while "Show Dimensions" is on — labels remain visible without the wireframe.
  • Save and reload the document — toggle state persists.
  • Verify the new toggle string renders correctly in each locale.

@slimbuck slimbuck requested a review from Copilot May 20, 2026 17:17
@slimbuck slimbuck self-assigned this May 20, 2026
@slimbuck slimbuck added the enhancement New feature label May 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new viewport overlay that displays the world-space X/Y/Z extents of the currently selected splat’s bounding box, controlled by a new “Show Dimensions” toggle in the View panel and persisted via document serialization.

Changes:

  • Added BoundDimensionsOverlay (SVG-based) that projects bound edges to screen each prerender and labels the outer-silhouette edges per axis.
  • Added a new View panel toggle wired through new camera.boundDimensions events and persisted via docSerialize.view / docDeserialize.view.
  • Added styling for the overlay labels and localized the new toggle string across all supported locales.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
static/locales/de.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/en.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/es.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/fr.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/ja.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/ko.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/pt-BR.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/ru.json Adds localized string for the new “Show Dimensions” toggle.
static/locales/zh-CN.json Adds localized string for the new “Show Dimensions” toggle.
src/ui/view-panel.ts Adds the UI toggle and wires it to camera.boundDimensions events.
src/ui/scss/tool.scss Styles the overlay SVG text (halo stroke, font sizing).
src/ui/bound-dimensions-overlay.ts Implements the per-frame bound projection and label placement logic.
src/scene-config.ts Adds default config flag show.boundDimensions: false.
src/main.ts Instantiates the overlay during app startup.
src/editor.ts Adds boundDimensions event plumbing + view serialization/deserialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ui/bound-dimensions-overlay.ts
Comment thread src/main.ts
@slimbuck slimbuck marked this pull request as ready for review May 20, 2026 17:36
@slimbuck slimbuck requested a review from a team May 20, 2026 17:36
@slimbuck slimbuck merged commit a558e0c into playcanvas:main May 20, 2026
2 checks passed
@slimbuck slimbuck deleted the dim-dev branch May 20, 2026 17:36
Re-qi pushed a commit to Re-qi/ReSplat that referenced this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants