Skip to content

Conversation

@RaghavArora14
Copy link
Contributor

@RaghavArora14 RaghavArora14 commented Oct 3, 2025

Fix bottom layer component placement in GLTF/GLB generation

Fixes #34 - Bottom layer components are now correctly positioned below the PCB board surface.

Changes

  • Enhanced positioning logic: Components with layer: "bottom" are placed below the board with proper clearance
  • Improved visibility: Added extra spacing and rotation for clear visual distinction
  • Comprehensive testing: Unit tests verify correct Y positioning, visual snapshot confirms proper placement
  • Clean implementation: Single helper function handles all layer-aware positioning logic

Technical Details

  • Bottom components: Y = -(boardThickness/2 + componentHeight/2 + 0.7mm)
  • Top components: Y = boardThickness/2 + componentHeight/2
  • Added 180° rotation for bottom components to enhance visual clarity
  • Applied consistently to both CAD components and generic PCB components

Validation

  • ✅ All 22 tests passing
  • ✅ Visual snapshot demonstrates correct bottom layer placement
  • ✅ Backwards compatible (components without layer default to "top")
  • ✅ CI-optimized test performance

Ready for review and merge.
image
image

Behavior

Component Layer Y Position Placement
"top" Positive Above PCB board
"bottom" Negative Below PCB board
undefined Positive Above PCB board (default)

The fix is demonstrated by the included snapshot test which shows components correctly distributed above and below the PCB board, instead of all components floating above it.

image

/claim #34
/fixes #34
closes #34

- Add getComponentYPosition helper function for layer-aware positioning
- Bottom layer components now placed below PCB board (Y < 0)
- Top layer components remain above PCB board (Y > 0)
- Backward compatible: components without layer default to top
- Add comprehensive unit and visual tests
- Resolve missing dependencies for test suite

Fixes tscircuit#34
@vercel
Copy link

vercel bot commented Oct 3, 2025

@RaghavArora14 is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

- Add extra clearance for bottom components to improve visibility
- Create comprehensive visual tests with multiple components
- Update test tolerance to account for enhanced positioning
- Optimize camera angles for better component visualization
- Reduce texture resolution from 256 to 128 for faster CI execution
- Add 15 second timeout to board texture test to prevent CI failures
- Fix code formatting issues with trailing whitespace
- Board texture test now completes in ~2 seconds instead of timing out
- Remove package-lock.json (auto-generated, should not be committed)
- Remove redundant bottom-layer-components test that didn't show clear visual difference
- Keep angled-view test that clearly demonstrates bottom layer component placement
- Maintain clean test suite with meaningful visual evidence
Keep only the angled-view test that clearly shows component placement
Remove unnecessary changes to test resolution and timeout
@RaghavArora14 RaghavArora14 force-pushed the fix/bottom-layer-component-placement branch from 46bd365 to 15cc039 Compare October 4, 2025 12:37
@seveibar
Copy link
Contributor

seveibar commented Oct 4, 2025

i think @MustafaMulla29 might have fixed this already

@RaghavArora14
Copy link
Contributor Author

RaghavArora14 commented Oct 4, 2025

Yes I think we published our prs around the same time

@RaghavArora14
Copy link
Contributor Author

@seveibar if there's anything from my pr you'd like to merge feel free to. Loved working on this issue

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GLTF/GLB Generation does not place bottom-layer components properly

2 participants