Skip to content

Conversation

@rushabhcodes
Copy link

This pull request adds a new utility for calculating optimal camera positions for 3D circuit board rendering, integrates it into the snapshot generation workflow, and introduces comprehensive tests to ensure correct behavior. The main focus is to automatically determine the best camera angle and distance based on the board and component layout in the circuit JSON, improving the accuracy and reliability of 3D previews.

Camera position calculation utility

  • Added calculateCameraPosition in lib/shared/calculate-camera-position.ts, which computes the ideal camera position and target for rendering a circuit board in 3D, considering board and component dimensions, positions, and supports both numeric and string dimension formats.

Integration into snapshot workflow

  • Updated lib/shared/snapshot-project.ts to use the new camera position calculation, replacing hardcoded camera settings with dynamic values derived from the circuit JSON, resulting in more accurate 3D snapshots. [1] [2]

Testing

  • Added tests/lib/shared/calculate-camera-position.test.ts to thoroughly test the camera position calculation utility with various board/component scenarios and dimension formats, ensuring correctness and robustness.

Copilot AI review requested due to automatic review settings December 9, 2025 08:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a dynamic camera position calculation utility for 3D circuit board rendering. Instead of using hardcoded camera positions, the system now automatically determines optimal camera angles and distances based on the actual board and component dimensions from the circuit JSON.

Key Changes:

  • Added calculateCameraPosition utility that computes camera position and target based on board/component layout
  • Integrated the utility into the snapshot generation workflow to replace hardcoded camera settings
  • Added comprehensive test coverage for various scenarios including boards, components, and string dimension formats

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lib/shared/calculate-camera-position.ts New utility function that calculates optimal camera position and look-at target based on circuit board and component dimensions, with support for both numeric and string dimension formats
lib/shared/snapshot-project.ts Updated to use dynamic camera position calculation instead of hardcoded values, improving 3D snapshot accuracy
tests/lib/shared/calculate-camera-position.test.ts Added test suite covering empty circuits, board-only scenarios, components without boards, and string dimension parsing

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

Copy link
Member

@imrishabh18 imrishabh18 left a comment

Choose a reason for hiding this comment

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

Can you add the 3d snapshots in the test for this? It's hard to know how it will look

@rushabhcodes
Copy link
Author

@imrishabh18 did i do something wrong, why did it fail

@ShiboSoftwareDev
Copy link
Contributor

probably an uncaught error

@rushabhcodes
Copy link
Author

@ShiboSoftwareDev @seveibar
Done
I also did some test locally

Before

Large board Medium board Small board
large board old medium board old small board old

After

Large board Medium board Small board
large board new medium board new small board new

@rushabhcodes rushabhcodes marked this pull request as draft December 9, 2025 15:28
@rushabhcodes rushabhcodes marked this pull request as ready for review December 9, 2025 15:28
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@github-actions
Copy link
Contributor

This PR was closed because it has been inactive for 1 day since being marked as stale.

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.

3 participants