Skip to content

Commit

Permalink
fix cad models rendering at wrong position
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Sep 25, 2024
1 parent 9e015c5 commit 13f681f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 24 additions & 0 deletions lib/components/base-components/NormalComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,30 @@ export class NormalComponent<
}
}

_getPcbCircuitJsonBounds(): {
center: { x: number; y: number }
bounds: { left: number; top: number; right: number; bottom: number }
width: number
height: number
} {
const { db } = this.root!
if (!this.pcb_component_id) return super._getPcbCircuitJsonBounds()

const pcb_component = db.pcb_component.get(this.pcb_component_id)!

return {
center: { x: pcb_component.center.x, y: pcb_component.center.y },
bounds: {
left: pcb_component.center.x - pcb_component.width / 2,
top: pcb_component.center.y - pcb_component.height / 2,
right: pcb_component.center.x + pcb_component.width / 2,
bottom: pcb_component.center.y + pcb_component.height / 2,
},
width: pcb_component.width,
height: pcb_component.height,
}
}

doInitialCadModelRender(): void {
const { db } = this.root!
const { boardThickness = 0 } = this.root?._getBoard() ?? {}
Expand Down
24 changes: 0 additions & 24 deletions lib/components/normal-components/Chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,4 @@ export class Chip<PinLabels extends string = never> extends NormalComponent<

this.pcb_component_id = pcb_component.pcb_component_id
}

_getPcbCircuitJsonBounds(): {
center: { x: number; y: number }
bounds: { left: number; top: number; right: number; bottom: number }
width: number
height: number
} {
const { db } = this.root!
if (!this.pcb_component_id) return super._getPcbCircuitJsonBounds()

const pcb_component = db.pcb_component.get(this.pcb_component_id)!

return {
center: { x: pcb_component.center.x, y: pcb_component.center.y },
bounds: {
left: pcb_component.center.x - pcb_component.width / 2,
top: pcb_component.center.y - pcb_component.height / 2,
right: pcb_component.center.x + pcb_component.width / 2,
bottom: pcb_component.center.y + pcb_component.height / 2,
},
width: pcb_component.width,
height: pcb_component.height,
}
}
}

0 comments on commit 13f681f

Please sign in to comment.