Skip to content

Fix packed-component CAD rotation in core so 3D models match post-pack footprint orientation#2064

Merged
rushabhcodes merged 3 commits intotscircuit:mainfrom
rushabhcodes:fix/packed-cad-rotation-alignment
Mar 20, 2026
Merged

Fix packed-component CAD rotation in core so 3D models match post-pack footprint orientation#2064
rushabhcodes merged 3 commits intotscircuit:mainfrom
rushabhcodes:fix/packed-cad-rotation-alignment

Conversation

@rushabhcodes
Copy link
Contributor

Summary

This PR fixes a subtle rotation mismatch in tscircuit/core where packed components could have correctly rotated PCB pads/footprints but incorrectly oriented CAD models in 3D output.

Problem

During CAD model insertion, z rotation was derived from pre-layout transforms.
For components moved/rotated by PCB packing (position_mode: "packed"), this could diverge from the actual post-pack pcb_component.rotation, causing CAD model misalignment relative to footprint pads.

Fix

  • Updated CAD rotation derivation in:
    • lib/components/base-components/NormalComponent/NormalComponent.ts
  • New behavior:
    • If component is position_mode === "packed", CAD model rotation uses post-pack pcb_component.rotation.
    • Otherwise, existing pre-layout transform-based rotation logic is preserved.

Why this is high impact

  • Core change (tscircuit/core) ✅
  • Subtle rendering/calculation bug fix (2D/3D rotation consistency) ✅
  • Improves correctness of generated 3D assembly views for auto-packed layouts.

Copilot AI review requested due to automatic review settings March 20, 2026 07:20
@vercel
Copy link

vercel bot commented Mar 20, 2026

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Mar 20, 2026 8:07am

Request Review

Comment on lines +1456 to +1459
const totalRotation =
pcbComponent?.position_mode === "packed"
? (pcbComponent.rotation ?? preLayoutRotation)
: preLayoutRotation
Copy link
Member

Choose a reason for hiding this comment

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

Why do you have explicitly check for the packed position mode? If rotation is present just use that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cant do that, pcb_component.rotation is often populated as 0 even when rotation is inherited from a parent group transform.

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

Fixes a rotation mismatch in tscircuit/core where PCB-packed components could end up with correctly rotated footprints/pads but incorrectly oriented 3D CAD models.

Changes:

  • Adjusts CAD Z-rotation derivation in NormalComponent.doInitialCadModelRender to prefer pcb_component.rotation over a pre-layout transform-derived rotation.

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

@rushabhcodes rushabhcodes merged commit 053950a into tscircuit:main Mar 20, 2026
12 checks passed
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.

4 participants