Skip to content

Optimize dimension tool snapping to nearby components#727

Draft
seveibar wants to merge 2 commits intomainfrom
codex/render-snappoints-near-cursor-only
Draft

Optimize dimension tool snapping to nearby components#727
seveibar wants to merge 2 commits intomainfrom
codex/render-snappoints-near-cursor-only

Conversation

@seveibar
Copy link
Copy Markdown
Contributor

Motivation

  • Limit snapping computation and marker rendering to components near the user cursor to reduce work and improve responsiveness of the dimensioning tool.

Description

  • Add SNAP_SEARCH_RADIUS_PX and helper isPointNearBoundingBox to determine proximity between the cursor and an element's bounding box.
  • Replace separate bounding-box and primitive-point passes with a single memoized elementSnapData map containing merged per-element bounds and per-primitive snap points.
  • Convert SNAP_SEARCH_RADIUS_PX into world space using the current transform scale as searchRadiusInWorld and filter elements by proximity to cursorRwPoint before building snappingPoints.
  • Track cursor world position with setCursorRwPoint during onMouseMove so snapping and rendered snap markers are localized to nearby elements.

Testing

  • Ran bun test tests/lib and all tests passed (22 pass, 0 fail).
  • Ran bunx tsc --noEmit and the TypeScript check succeeded.
  • Ran bun run format and formatting completed successfully.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pcb-viewer Ready Ready Preview, Comment Mar 26, 2026 3:00am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant