@tscircuit/3d-viewer 0.0.412 → 0.0.414

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +362 -158
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -16636,8 +16636,8 @@ var pcb_fabrication_note_dimension = z93.object({
16636
16636
  pcb_group_id: z93.string().optional(),
16637
16637
  subcircuit_id: z93.string().optional(),
16638
16638
  layer: visible_layer,
16639
- from: point.or(z93.string()),
16640
- to: point.or(z93.string()),
16639
+ from: point,
16640
+ to: point,
16641
16641
  text: z93.string().optional(),
16642
16642
  offset: length.optional(),
16643
16643
  font: z93.literal("tscircuit2024").default("tscircuit2024"),
@@ -26576,7 +26576,7 @@ import * as THREE13 from "three";
26576
26576
  // package.json
26577
26577
  var package_default = {
26578
26578
  name: "@tscircuit/3d-viewer",
26579
- version: "0.0.411",
26579
+ version: "0.0.413",
26580
26580
  main: "./dist/index.js",
26581
26581
  module: "./dist/index.js",
26582
26582
  type: "module",
@@ -26623,8 +26623,8 @@ var package_default = {
26623
26623
  "@storybook/blocks": "9.0.0-alpha.17",
26624
26624
  "@storybook/react-vite": "^9.1.5",
26625
26625
  "@tscircuit/circuit-json-util": "^0.0.72",
26626
- "@tscircuit/core": "^0.0.783",
26627
- "@tscircuit/props": "^0.0.360",
26626
+ "@tscircuit/core": "^0.0.787",
26627
+ "@tscircuit/props": "^0.0.364",
26628
26628
  "@tscircuit/checks": "^0.0.85",
26629
26629
  "@tscircuit/math-utils": "^0.0.27",
26630
26630
  "@tscircuit/capacity-autorouter": "^0.0.131",
@@ -26636,7 +26636,7 @@ var package_default = {
26636
26636
  "@vitejs/plugin-react": "^4.3.4",
26637
26637
  "bun-match-svg": "^0.0.9",
26638
26638
  "bun-types": "1.2.1",
26639
- "circuit-json": "0.0.278",
26639
+ "circuit-json": "0.0.279",
26640
26640
  "circuit-to-svg": "^0.0.179",
26641
26641
  debug: "^4.4.0",
26642
26642
  "jscad-electronics": "^0.0.48",
@@ -27519,38 +27519,67 @@ var platedHole = (plated_hole, ctx, options = {}) => {
27519
27519
  return (0, import_colors2.colorize)(colors.copper, (0, import_booleans.subtract)(copperSolid, drill));
27520
27520
  }
27521
27521
  if (plated_hole.shape === "circular_hole_with_rect_pad") {
27522
+ const holeOffsetX = plated_hole.hole_offset_x || 0;
27523
+ const holeOffsetY = plated_hole.hole_offset_y || 0;
27522
27524
  const padWidth = plated_hole.rect_pad_width || plated_hole.hole_diameter;
27523
27525
  const padHeight = plated_hole.rect_pad_height || plated_hole.hole_diameter;
27524
27526
  const rectBorderRadius = extractRectBorderRadius(plated_hole);
27525
27527
  const copperSolid = maybeClip(
27526
27528
  (0, import_booleans.union)(
27527
- // Top rectangular pad
27529
+ // Top rectangular pad (thicker to ensure connection)
27528
27530
  createRectPadGeom({
27529
27531
  width: padWidth,
27530
27532
  height: padHeight,
27531
- thickness: platedHoleLipHeight,
27533
+ thickness: platedHoleLipHeight + 0.1,
27534
+ // Slightly thicker to ensure connection
27532
27535
  center: [
27533
27536
  plated_hole.x,
27534
27537
  plated_hole.y,
27535
- ctx.pcbThickness / 2 + platedHoleLipHeight / 2 + M
27538
+ ctx.pcbThickness / 2 + platedHoleLipHeight / 2 + M - 0.05
27539
+ // Adjusted for thickness
27536
27540
  ],
27537
27541
  borderRadius: rectBorderRadius
27538
27542
  }),
27539
- // Bottom rectangular pad
27543
+ // Bottom rectangular pad (thicker to ensure connection)
27540
27544
  createRectPadGeom({
27541
27545
  width: padWidth,
27542
27546
  height: padHeight,
27543
- thickness: platedHoleLipHeight,
27547
+ thickness: platedHoleLipHeight + 0.1,
27548
+ // Slightly thicker to ensure connection
27544
27549
  center: [
27545
27550
  plated_hole.x,
27546
27551
  plated_hole.y,
27547
- -ctx.pcbThickness / 2 - platedHoleLipHeight / 2 - M
27552
+ -ctx.pcbThickness / 2 - platedHoleLipHeight / 2 - M + 0.05
27553
+ // Adjusted for thickness
27548
27554
  ],
27549
27555
  borderRadius: rectBorderRadius
27550
27556
  }),
27551
- // Plated barrel around hole
27557
+ // Main copper fill between pads with rounded corners
27558
+ (() => {
27559
+ const height10 = ctx.pcbThickness - platedHoleLipHeight * 2 - M * 2 + 0.1;
27560
+ const rect2d = (0, import_primitives3.roundedRectangle)({
27561
+ size: [padWidth, padHeight],
27562
+ roundRadius: rectBorderRadius || 0,
27563
+ segments: RECT_PAD_SEGMENTS
27564
+ });
27565
+ const extruded = (0, import_extrusions2.extrudeLinear)({ height: height10 }, rect2d);
27566
+ return (0, import_transforms2.translate)(
27567
+ [
27568
+ plated_hole.x,
27569
+ plated_hole.y,
27570
+ -height10 / 2
27571
+ // Center vertically
27572
+ ],
27573
+ extruded
27574
+ );
27575
+ })(),
27576
+ // Plated barrel around hole (ensured connection with pads)
27552
27577
  (0, import_primitives3.cylinder)({
27553
- center: [plated_hole.x, plated_hole.y, 0],
27578
+ center: [
27579
+ plated_hole.x + (holeOffsetX || 0),
27580
+ plated_hole.y + (holeOffsetY || 0),
27581
+ 0
27582
+ ],
27554
27583
  radius: plated_hole.hole_diameter / 2,
27555
27584
  height: ctx.pcbThickness
27556
27585
  })
@@ -27558,11 +27587,35 @@ var platedHole = (plated_hole, ctx, options = {}) => {
27558
27587
  clipGeom
27559
27588
  );
27560
27589
  const drill = (0, import_primitives3.cylinder)({
27561
- center: [plated_hole.x, plated_hole.y, 0],
27590
+ center: [
27591
+ plated_hole.x + (holeOffsetX || 0),
27592
+ plated_hole.y + (holeOffsetY || 0),
27593
+ 0
27594
+ ],
27562
27595
  radius: Math.max(plated_hole.hole_diameter / 2 - M, 0.01),
27563
27596
  height: throughDrillHeight
27564
27597
  });
27565
- return (0, import_colors2.colorize)(colors.copper, (0, import_booleans.subtract)(copperSolid, drill));
27598
+ const barrel = (0, import_primitives3.cylinder)({
27599
+ center: [
27600
+ plated_hole.x + (holeOffsetX || 0),
27601
+ plated_hole.y + (holeOffsetY || 0),
27602
+ 0
27603
+ ],
27604
+ radius: plated_hole.hole_diameter / 2,
27605
+ height: ctx.pcbThickness
27606
+ });
27607
+ let finalCopper = (0, import_booleans.union)(
27608
+ (0, import_booleans.subtract)(copperSolid, barrel),
27609
+ // Subtract the barrel from the main shape
27610
+ barrel
27611
+ // Add the barrel back to ensure proper connection
27612
+ );
27613
+ if (options.clipGeom) {
27614
+ finalCopper = (0, import_booleans.subtract)(finalCopper, drill);
27615
+ finalCopper = (0, import_booleans.intersect)(finalCopper, options.clipGeom);
27616
+ return (0, import_colors2.colorize)(colors.copper, finalCopper);
27617
+ }
27618
+ return (0, import_colors2.colorize)(colors.copper, (0, import_booleans.subtract)(finalCopper, drill));
27566
27619
  }
27567
27620
  if (plated_hole.shape === "pill") {
27568
27621
  const shouldRotate = plated_hole.hole_height > plated_hole.hole_width;
@@ -27626,6 +27679,8 @@ var platedHole = (plated_hole, ctx, options = {}) => {
27626
27679
  return (0, import_colors2.colorize)(colors.copper, (0, import_booleans.subtract)(copperSolid, drill));
27627
27680
  }
27628
27681
  if (plated_hole.shape === "pill_hole_with_rect_pad") {
27682
+ const holeOffsetX = plated_hole.hole_offset_x || 0;
27683
+ const holeOffsetY = plated_hole.hole_offset_y || 0;
27629
27684
  const shouldRotate = plated_hole.hole_height > plated_hole.hole_width;
27630
27685
  const holeWidth = shouldRotate ? plated_hole.hole_height : plated_hole.hole_width;
27631
27686
  const holeHeight = shouldRotate ? plated_hole.hole_width : plated_hole.hole_height;
@@ -27634,64 +27689,140 @@ var platedHole = (plated_hole, ctx, options = {}) => {
27634
27689
  const padWidth = plated_hole.rect_pad_width || holeWidth + 0.2;
27635
27690
  const padHeight = plated_hole.rect_pad_height || holeHeight + 0.2;
27636
27691
  const rectBorderRadius = extractRectBorderRadius(plated_hole);
27637
- const mainRect = (0, import_primitives3.cuboid)({
27638
- center: [plated_hole.x, plated_hole.y, 0],
27639
- size: shouldRotate ? [holeHeight, rectLength, ctx.pcbThickness] : [rectLength, holeHeight, ctx.pcbThickness]
27640
- });
27641
- const leftCap = (0, import_primitives3.cylinder)({
27642
- center: shouldRotate ? [plated_hole.x, plated_hole.y - rectLength / 2, 0] : [plated_hole.x - rectLength / 2, plated_hole.y, 0],
27643
- radius: holeRadius,
27644
- height: ctx.pcbThickness
27645
- });
27646
- const rightCap = (0, import_primitives3.cylinder)({
27647
- center: shouldRotate ? [plated_hole.x, plated_hole.y + rectLength / 2, 0] : [plated_hole.x + rectLength / 2, plated_hole.y, 0],
27648
- radius: holeRadius,
27649
- height: ctx.pcbThickness
27650
- });
27651
- const topPad = createRectPadGeom({
27652
- width: padWidth,
27653
- height: padHeight,
27654
- thickness: platedHoleLipHeight,
27655
- center: [
27656
- plated_hole.x,
27657
- plated_hole.y,
27658
- ctx.pcbThickness / 2 + platedHoleLipHeight / 2 + M
27659
- ],
27660
- borderRadius: rectBorderRadius
27661
- });
27662
- const bottomPad = createRectPadGeom({
27692
+ const barrelMargin = 0.03;
27693
+ const barrel = (0, import_booleans.union)(
27694
+ (0, import_primitives3.cuboid)({
27695
+ center: [plated_hole.x + holeOffsetX, plated_hole.y + holeOffsetY, 0],
27696
+ size: shouldRotate ? [
27697
+ holeHeight + 2 * barrelMargin,
27698
+ rectLength + 2 * barrelMargin,
27699
+ ctx.pcbThickness + 0.2
27700
+ ] : [
27701
+ rectLength + 2 * barrelMargin,
27702
+ holeHeight + 2 * barrelMargin,
27703
+ ctx.pcbThickness + 0.2
27704
+ ]
27705
+ }),
27706
+ (0, import_primitives3.cylinder)({
27707
+ center: shouldRotate ? [
27708
+ plated_hole.x + holeOffsetX,
27709
+ plated_hole.y + holeOffsetY - rectLength / 2,
27710
+ 0
27711
+ ] : [
27712
+ plated_hole.x + holeOffsetX - rectLength / 2,
27713
+ plated_hole.y + holeOffsetY,
27714
+ 0
27715
+ ],
27716
+ radius: holeRadius + barrelMargin,
27717
+ height: ctx.pcbThickness + 0.2
27718
+ // extend slightly above/below PCB
27719
+ }),
27720
+ (0, import_primitives3.cylinder)({
27721
+ center: shouldRotate ? [
27722
+ plated_hole.x + holeOffsetX,
27723
+ plated_hole.y + holeOffsetY + rectLength / 2,
27724
+ 0
27725
+ ] : [
27726
+ plated_hole.x + holeOffsetX + rectLength / 2,
27727
+ plated_hole.y + holeOffsetY,
27728
+ 0
27729
+ ],
27730
+ radius: holeRadius + barrelMargin,
27731
+ height: ctx.pcbThickness + 0.2
27732
+ })
27733
+ );
27734
+ const holeCut = (0, import_booleans.union)(
27735
+ (0, import_primitives3.cuboid)({
27736
+ center: [plated_hole.x + holeOffsetX, plated_hole.y + holeOffsetY, 0],
27737
+ size: shouldRotate ? [holeHeight, rectLength, throughDrillHeight * 1.1] : [rectLength, holeHeight, throughDrillHeight * 1.1]
27738
+ }),
27739
+ (0, import_primitives3.cylinder)({
27740
+ center: shouldRotate ? [
27741
+ plated_hole.x + holeOffsetX,
27742
+ plated_hole.y + holeOffsetY - rectLength / 2,
27743
+ 0
27744
+ ] : [
27745
+ plated_hole.x + holeOffsetX - rectLength / 2,
27746
+ plated_hole.y + holeOffsetY,
27747
+ 0
27748
+ ],
27749
+ radius: holeRadius,
27750
+ height: throughDrillHeight * 1.1
27751
+ }),
27752
+ (0, import_primitives3.cylinder)({
27753
+ center: shouldRotate ? [
27754
+ plated_hole.x + holeOffsetX,
27755
+ plated_hole.y + holeOffsetY + rectLength / 2,
27756
+ 0
27757
+ ] : [
27758
+ plated_hole.x + holeOffsetX + rectLength / 2,
27759
+ plated_hole.y + holeOffsetY,
27760
+ 0
27761
+ ],
27762
+ radius: holeRadius,
27763
+ height: throughDrillHeight * 1.1
27764
+ })
27765
+ );
27766
+ const mainFill = createRectPadGeom({
27663
27767
  width: padWidth,
27664
27768
  height: padHeight,
27665
- thickness: platedHoleLipHeight,
27666
- center: [
27667
- plated_hole.x,
27668
- plated_hole.y,
27669
- -ctx.pcbThickness / 2 - platedHoleLipHeight / 2 - M
27670
- ],
27769
+ thickness: ctx.pcbThickness - 2 * platedHoleLipHeight - M * 2 + 0.1,
27770
+ center: [plated_hole.x, plated_hole.y, 0],
27671
27771
  borderRadius: rectBorderRadius
27672
27772
  });
27673
- const holeCut = (0, import_booleans.union)(
27773
+ const createPadWithHole = (zOffset) => {
27774
+ const pad2 = createRectPadGeom({
27775
+ width: padWidth,
27776
+ height: padHeight,
27777
+ thickness: platedHoleLipHeight + 0.1,
27778
+ center: [plated_hole.x, plated_hole.y, zOffset],
27779
+ borderRadius: rectBorderRadius
27780
+ });
27781
+ return (0, import_booleans.subtract)(pad2, holeCut);
27782
+ };
27783
+ const topPad = createPadWithHole(
27784
+ ctx.pcbThickness / 2 - platedHoleLipHeight / 2 + 0.05
27785
+ );
27786
+ const bottomPad = createPadWithHole(
27787
+ -ctx.pcbThickness / 2 + platedHoleLipHeight / 2 - 0.05
27788
+ );
27789
+ const filledArea = (0, import_booleans.subtract)(mainFill, holeCut);
27790
+ const barrelHoleCut = (0, import_booleans.union)(
27674
27791
  (0, import_primitives3.cuboid)({
27675
- center: [plated_hole.x, plated_hole.y, 0],
27676
- size: shouldRotate ? [holeHeight - platedHoleLipHeight, rectLength, throughDrillHeight] : [rectLength, holeHeight - platedHoleLipHeight, throughDrillHeight]
27792
+ center: [plated_hole.x + holeOffsetX, plated_hole.y + holeOffsetY, 0],
27793
+ size: shouldRotate ? [holeHeight - 2 * M, rectLength - 2 * M, throughDrillHeight * 1.1] : [rectLength - 2 * M, holeHeight - 2 * M, throughDrillHeight * 1.1]
27677
27794
  }),
27678
27795
  (0, import_primitives3.cylinder)({
27679
- center: shouldRotate ? [plated_hole.x, plated_hole.y - rectLength / 2, 0] : [plated_hole.x - rectLength / 2, plated_hole.y, 0],
27680
- radius: holeRadius - platedHoleLipHeight,
27681
- height: throughDrillHeight
27796
+ center: shouldRotate ? [
27797
+ plated_hole.x + holeOffsetX,
27798
+ plated_hole.y + holeOffsetY - rectLength / 2,
27799
+ 0
27800
+ ] : [
27801
+ plated_hole.x + holeOffsetX - rectLength / 2,
27802
+ plated_hole.y + holeOffsetY,
27803
+ 0
27804
+ ],
27805
+ radius: holeRadius - M,
27806
+ height: throughDrillHeight * 1.1
27682
27807
  }),
27683
27808
  (0, import_primitives3.cylinder)({
27684
- center: shouldRotate ? [plated_hole.x, plated_hole.y + rectLength / 2, 0] : [plated_hole.x + rectLength / 2, plated_hole.y, 0],
27685
- radius: holeRadius - platedHoleLipHeight,
27686
- height: throughDrillHeight
27809
+ center: shouldRotate ? [
27810
+ plated_hole.x + holeOffsetX,
27811
+ plated_hole.y + holeOffsetY + rectLength / 2,
27812
+ 0
27813
+ ] : [
27814
+ plated_hole.x + holeOffsetX + rectLength / 2,
27815
+ plated_hole.y + holeOffsetY,
27816
+ 0
27817
+ ],
27818
+ radius: holeRadius - M,
27819
+ height: throughDrillHeight * 1.1
27687
27820
  })
27688
27821
  );
27689
- const copperSolid = maybeClip(
27690
- (0, import_booleans.union)(mainRect, leftCap, rightCap, topPad, bottomPad),
27691
- clipGeom
27692
- );
27693
- const drill = holeCut;
27694
- return (0, import_colors2.colorize)(colors.copper, (0, import_booleans.subtract)(copperSolid, drill));
27822
+ const barrelWithHole = (0, import_booleans.subtract)(barrel, barrelHoleCut);
27823
+ const finalCopper = (0, import_booleans.union)(filledArea, barrelWithHole, topPad, bottomPad);
27824
+ let result = maybeClip(finalCopper, clipGeom);
27825
+ return (0, import_colors2.colorize)(colors.copper, result);
27695
27826
  } else {
27696
27827
  throw new Error(`Unsupported plated hole shape: ${plated_hole.shape}`);
27697
27828
  }
@@ -28421,13 +28552,28 @@ var BoardGeomBuilder = class {
28421
28552
  processPlatedHole(ph, opts = {}) {
28422
28553
  if (!this.boardGeom) return;
28423
28554
  if (ph.shape === "circle" || ph.shape === "circular_hole_with_rect_pad") {
28424
- const cyGeom = (0, import_primitives6.cylinder)({
28425
- center: [ph.x, ph.y, 0],
28426
- radius: ph.hole_diameter / 2 + M,
28427
- // Add margin for subtraction
28428
- height: this.ctx.pcbThickness * 1.5
28429
- // Ensure it cuts through
28430
- });
28555
+ let cyGeom = null;
28556
+ if (ph.shape === "circular_hole_with_rect_pad") {
28557
+ cyGeom = (0, import_primitives6.cylinder)({
28558
+ center: [
28559
+ ph.x + (ph.hole_offset_x || 0),
28560
+ ph.y + (ph.hole_offset_y || 0),
28561
+ 0
28562
+ ],
28563
+ radius: ph.hole_diameter / 2 + M,
28564
+ // Add margin for subtraction
28565
+ height: this.ctx.pcbThickness * 1.5
28566
+ // Ensure it cuts through
28567
+ });
28568
+ } else {
28569
+ cyGeom = (0, import_primitives6.cylinder)({
28570
+ center: [ph.x, ph.y, 0],
28571
+ radius: ph.hole_diameter / 2 + M,
28572
+ // Add margin for subtraction
28573
+ height: this.ctx.pcbThickness * 1.5
28574
+ // Ensure it cuts through
28575
+ });
28576
+ }
28431
28577
  if (!opts.dontCutBoard) {
28432
28578
  this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cyGeom);
28433
28579
  }
@@ -28444,22 +28590,62 @@ var BoardGeomBuilder = class {
28444
28590
  const holeHeight = shouldRotate ? ph.hole_width : ph.hole_height;
28445
28591
  const holeRadius = holeHeight / 2;
28446
28592
  const rectLength = Math.abs(holeWidth - holeHeight);
28447
- const pillHole = (0, import_booleans3.union)(
28448
- (0, import_primitives6.cuboid)({
28449
- center: [ph.x, ph.y, 0],
28450
- size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
28451
- }),
28452
- (0, import_primitives6.cylinder)({
28453
- center: shouldRotate ? [ph.x, ph.y - rectLength / 2, 0] : [ph.x - rectLength / 2, ph.y, 0],
28454
- radius: holeRadius,
28455
- height: this.ctx.pcbThickness * 1.5
28456
- }),
28457
- (0, import_primitives6.cylinder)({
28458
- center: shouldRotate ? [ph.x, ph.y + rectLength / 2, 0] : [ph.x + rectLength / 2, ph.y, 0],
28459
- radius: holeRadius,
28460
- height: this.ctx.pcbThickness * 1.5
28461
- })
28462
- );
28593
+ let pillHole;
28594
+ if (ph.shape === "pill_hole_with_rect_pad") {
28595
+ pillHole = (0, import_booleans3.union)(
28596
+ (0, import_primitives6.cuboid)({
28597
+ center: [
28598
+ ph.x + (ph.hole_offset_x || 0),
28599
+ ph.y + (ph.hole_offset_y || 0),
28600
+ 0
28601
+ ],
28602
+ size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
28603
+ }),
28604
+ (0, import_primitives6.cylinder)({
28605
+ center: shouldRotate ? [
28606
+ ph.x + (ph.hole_offset_x || 0),
28607
+ ph.y + (ph.hole_offset_y || 0) - rectLength / 2,
28608
+ 0
28609
+ ] : [
28610
+ ph.x + (ph.hole_offset_x || 0) - rectLength / 2,
28611
+ ph.y + (ph.hole_offset_y || 0),
28612
+ 0
28613
+ ],
28614
+ radius: holeRadius,
28615
+ height: this.ctx.pcbThickness * 1.5
28616
+ }),
28617
+ (0, import_primitives6.cylinder)({
28618
+ center: shouldRotate ? [
28619
+ ph.x + (ph.hole_offset_x || 0),
28620
+ ph.y + (ph.hole_offset_y || 0) + rectLength / 2,
28621
+ 0
28622
+ ] : [
28623
+ ph.x + (ph.hole_offset_x || 0) + rectLength / 2,
28624
+ ph.y + (ph.hole_offset_y || 0),
28625
+ 0
28626
+ ],
28627
+ radius: holeRadius,
28628
+ height: this.ctx.pcbThickness * 1.5
28629
+ })
28630
+ );
28631
+ } else {
28632
+ pillHole = (0, import_booleans3.union)(
28633
+ (0, import_primitives6.cuboid)({
28634
+ center: [ph.x, ph.y, 0],
28635
+ size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
28636
+ }),
28637
+ (0, import_primitives6.cylinder)({
28638
+ center: shouldRotate ? [ph.x, ph.y - rectLength / 2, 0] : [ph.x - rectLength / 2, ph.y, 0],
28639
+ radius: holeRadius,
28640
+ height: this.ctx.pcbThickness * 1.5
28641
+ }),
28642
+ (0, import_primitives6.cylinder)({
28643
+ center: shouldRotate ? [ph.x, ph.y + rectLength / 2, 0] : [ph.x + rectLength / 2, ph.y, 0],
28644
+ radius: holeRadius,
28645
+ height: this.ctx.pcbThickness * 1.5
28646
+ })
28647
+ );
28648
+ }
28463
28649
  if (!opts.dontCutBoard) {
28464
28650
  this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
28465
28651
  }
@@ -29703,6 +29889,8 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29703
29889
  } else if (ph.shape === "pill_hole_with_rect_pad") {
29704
29890
  const holeW = ph.hole_width;
29705
29891
  const holeH = ph.hole_height;
29892
+ const holeOffsetX = ph.hole_offset_x || 0;
29893
+ const holeOffsetY = ph.hole_offset_y || 0;
29706
29894
  const padWidth = ph.rect_pad_width;
29707
29895
  const padHeight = ph.rect_pad_height;
29708
29896
  const rectBorderRadius = extractRectBorderRadius(ph);
@@ -29710,7 +29898,9 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29710
29898
  const drillW = holeW + 2 * MANIFOLD_Z_OFFSET;
29711
29899
  const drillH = holeH + 2 * MANIFOLD_Z_OFFSET;
29712
29900
  const drillDepth = pcbThickness * 1.2;
29713
- let boardPillDrillOp = createPillOp(drillW, drillH, drillDepth);
29901
+ let boardPillDrillOp = createPillOp(drillW, drillH, drillDepth).translate(
29902
+ [holeOffsetX, holeOffsetY, 0]
29903
+ );
29714
29904
  const translatedBoardPillDrill = boardPillDrillOp.translate([
29715
29905
  ph.x,
29716
29906
  ph.y,
@@ -29718,51 +29908,59 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29718
29908
  ]);
29719
29909
  manifoldInstancesForCleanup.push(translatedBoardPillDrill);
29720
29910
  platedHoleBoardDrills.push(translatedBoardPillDrill);
29721
- let copperBarrelOp = createPillOp(
29722
- holeW,
29723
- holeH,
29724
- pcbThickness + 2 * MANIFOLD_Z_OFFSET
29725
- );
29726
- let topPadOp = createRoundedRectPrism({
29911
+ const mainFill = createRoundedRectPrism({
29727
29912
  Manifold,
29728
29913
  width: padWidth,
29729
29914
  height: padHeight,
29730
- thickness: padThickness,
29915
+ thickness: pcbThickness - 2 * padThickness + 0.1,
29916
+ // Fill between pads
29731
29917
  borderRadius: rectBorderRadius
29732
29918
  });
29733
- manifoldInstancesForCleanup.push(topPadOp);
29734
- let bottomPadOp = createRoundedRectPrism({
29919
+ manifoldInstancesForCleanup.push(mainFill);
29920
+ const topPad = createRoundedRectPrism({
29735
29921
  Manifold,
29736
29922
  width: padWidth,
29737
29923
  height: padHeight,
29738
- thickness: padThickness,
29924
+ thickness: padThickness + 0.1,
29739
29925
  borderRadius: rectBorderRadius
29740
- });
29741
- manifoldInstancesForCleanup.push(bottomPadOp);
29742
- const topPadZ = pcbThickness / 2 + padThickness / 2 + MANIFOLD_Z_OFFSET;
29743
- const bottomPadZ = -pcbThickness / 2 - padThickness / 2 - MANIFOLD_Z_OFFSET;
29744
- topPadOp = topPadOp.translate([0, 0, topPadZ]);
29745
- manifoldInstancesForCleanup.push(topPadOp);
29746
- bottomPadOp = bottomPadOp.translate([0, 0, bottomPadZ]);
29747
- manifoldInstancesForCleanup.push(bottomPadOp);
29748
- const copperUnionBeforeCut = Manifold.union([
29749
- copperBarrelOp,
29750
- topPadOp,
29751
- bottomPadOp
29926
+ }).translate([0, 0, pcbThickness / 2 - padThickness / 2 + 0.05]);
29927
+ const bottomPad = createRoundedRectPrism({
29928
+ Manifold,
29929
+ width: padWidth,
29930
+ height: padHeight,
29931
+ thickness: padThickness + 0.1,
29932
+ borderRadius: rectBorderRadius
29933
+ }).translate([0, 0, -pcbThickness / 2 + padThickness / 2 - 0.05]);
29934
+ manifoldInstancesForCleanup.push(topPad, bottomPad);
29935
+ const barrelPill = createPillOp(
29936
+ holeW,
29937
+ holeH,
29938
+ pcbThickness * 1.02
29939
+ // Slightly taller than board
29940
+ ).translate([holeOffsetX, holeOffsetY, 0]);
29941
+ manifoldInstancesForCleanup.push(barrelPill);
29942
+ const copperUnion = Manifold.union([
29943
+ mainFill,
29944
+ topPad,
29945
+ bottomPad,
29946
+ barrelPill
29752
29947
  ]);
29753
- manifoldInstancesForCleanup.push(copperUnionBeforeCut);
29754
- const holeCutWidth = Math.max(holeW - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01);
29755
- const holeCutHeight = Math.max(holeH - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01);
29756
- const holeCutDepth = pcbThickness + 2 * padThickness + 4 * MANIFOLD_Z_OFFSET;
29757
- let holeCutOp = createPillOp(holeCutWidth, holeCutHeight, holeCutDepth);
29758
- const finalPlatedPartOp = copperUnionBeforeCut.subtract(holeCutOp);
29759
- manifoldInstancesForCleanup.push(finalPlatedPartOp);
29760
- const translatedPlatedPart = finalPlatedPartOp.translate([ph.x, ph.y, 0]);
29761
- manifoldInstancesForCleanup.push(translatedPlatedPart);
29762
- let finalCopperOp = translatedPlatedPart;
29948
+ manifoldInstancesForCleanup.push(copperUnion);
29949
+ const holeCutOp = createPillOp(
29950
+ Math.max(holeW - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01),
29951
+ Math.max(holeH - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01),
29952
+ pcbThickness * 1.2
29953
+ // Ensure it cuts through
29954
+ ).translate([holeOffsetX, holeOffsetY, 0]);
29955
+ manifoldInstancesForCleanup.push(holeCutOp);
29956
+ const finalCopper = copperUnion.subtract(holeCutOp);
29957
+ manifoldInstancesForCleanup.push(finalCopper);
29958
+ const translatedCopper = finalCopper.translate([ph.x, ph.y, 0]);
29959
+ manifoldInstancesForCleanup.push(translatedCopper);
29960
+ let finalCopperOp = translatedCopper;
29763
29961
  if (boardClipVolume) {
29764
29962
  const clipped = Manifold.intersection([
29765
- translatedPlatedPart,
29963
+ translatedCopper,
29766
29964
  boardClipVolume
29767
29965
  ]);
29768
29966
  manifoldInstancesForCleanup.push(clipped);
@@ -29775,71 +29973,77 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29775
29973
  color: COPPER_COLOR
29776
29974
  });
29777
29975
  } else if (ph.shape === "circular_hole_with_rect_pad") {
29976
+ const holeOffsetX = ph.hole_offset_x || 0;
29977
+ const holeOffsetY = ph.hole_offset_y || 0;
29778
29978
  const translatedDrill = createCircleHoleDrill({
29779
29979
  Manifold,
29780
- x: ph.x,
29781
- y: ph.y,
29980
+ x: ph.x + holeOffsetX,
29981
+ // Apply hole offset
29982
+ y: ph.y + holeOffsetY,
29983
+ // Apply hole offset
29782
29984
  diameter: ph.hole_diameter,
29783
29985
  thickness: pcbThickness,
29784
29986
  segments: SMOOTH_CIRCLE_SEGMENTS
29785
29987
  });
29786
29988
  manifoldInstancesForCleanup.push(translatedDrill);
29787
29989
  platedHoleBoardDrills.push(translatedDrill);
29788
- const copperPartThickness = pcbThickness + 2 * MANIFOLD_Z_OFFSET;
29789
- const holeRadius = ph.hole_diameter / 2;
29790
- const barrelCylinder = Manifold.cylinder(
29791
- copperPartThickness,
29792
- holeRadius,
29793
- holeRadius,
29794
- SMOOTH_CIRCLE_SEGMENTS,
29795
- true
29796
- );
29797
- manifoldInstancesForCleanup.push(barrelCylinder);
29798
29990
  const padWidth = ph.rect_pad_width ?? ph.hole_diameter;
29799
29991
  const padHeight = ph.rect_pad_height ?? ph.hole_diameter;
29800
29992
  const rectBorderRadius = extractRectBorderRadius(ph);
29801
29993
  const padThickness = DEFAULT_SMT_PAD_THICKNESS;
29994
+ const holeRadius = ph.hole_diameter / 2;
29995
+ const mainFill = createRoundedRectPrism({
29996
+ Manifold,
29997
+ width: padWidth,
29998
+ height: padHeight,
29999
+ thickness: pcbThickness - 2 * padThickness + 0.1,
30000
+ // Fill between pads
30001
+ borderRadius: rectBorderRadius
30002
+ });
30003
+ manifoldInstancesForCleanup.push(mainFill);
29802
30004
  const topPad = createRoundedRectPrism({
29803
30005
  Manifold,
29804
30006
  width: padWidth,
29805
30007
  height: padHeight,
29806
- thickness: padThickness,
30008
+ thickness: padThickness + 0.1,
29807
30009
  borderRadius: rectBorderRadius
29808
- }).translate([
29809
- 0,
29810
- 0,
29811
- pcbThickness / 2 + padThickness / 2 + MANIFOLD_Z_OFFSET
29812
- ]);
30010
+ }).translate([0, 0, pcbThickness / 2 - padThickness / 2 + 0.05]);
29813
30011
  const bottomPad = createRoundedRectPrism({
29814
30012
  Manifold,
29815
30013
  width: padWidth,
29816
30014
  height: padHeight,
29817
- thickness: padThickness,
30015
+ thickness: padThickness + 0.1,
29818
30016
  borderRadius: rectBorderRadius
29819
- }).translate([
29820
- 0,
29821
- 0,
29822
- -pcbThickness / 2 - padThickness / 2 - MANIFOLD_Z_OFFSET
29823
- ]);
30017
+ }).translate([0, 0, -pcbThickness / 2 + padThickness / 2 - 0.05]);
29824
30018
  manifoldInstancesForCleanup.push(topPad, bottomPad);
29825
- const copperUnionUncut = Manifold.union([
29826
- barrelCylinder,
30019
+ const barrelCylinder = Manifold.cylinder(
30020
+ pcbThickness * 1.02,
30021
+ // Slightly taller than board
30022
+ holeRadius,
30023
+ holeRadius,
30024
+ SMOOTH_CIRCLE_SEGMENTS,
30025
+ true
30026
+ ).translate([holeOffsetX, holeOffsetY, 0]);
30027
+ manifoldInstancesForCleanup.push(barrelCylinder);
30028
+ const copperUnion = Manifold.union([
30029
+ mainFill,
29827
30030
  topPad,
29828
- bottomPad
30031
+ bottomPad,
30032
+ barrelCylinder
29829
30033
  ]);
29830
- manifoldInstancesForCleanup.push(copperUnionUncut);
29831
- const centerHoleRadius = Math.max(holeRadius - M, 0.01);
29832
- const centerHole = Manifold.cylinder(
29833
- copperPartThickness * 1.1,
29834
- centerHoleRadius,
29835
- centerHoleRadius,
30034
+ manifoldInstancesForCleanup.push(copperUnion);
30035
+ const holeDrill = Manifold.cylinder(
30036
+ pcbThickness * 1.2,
30037
+ // Ensure it cuts through
30038
+ Math.max(holeRadius - M, 0.01),
30039
+ Math.max(holeRadius - M, 0.01),
29836
30040
  SMOOTH_CIRCLE_SEGMENTS,
29837
30041
  true
29838
- );
29839
- manifoldInstancesForCleanup.push(centerHole);
29840
- const copperUnion = copperUnionUncut.subtract(centerHole);
29841
- manifoldInstancesForCleanup.push(copperUnion);
29842
- const translatedCopper = copperUnion.translate([ph.x, ph.y, 0]);
30042
+ ).translate([holeOffsetX, holeOffsetY, 0]);
30043
+ manifoldInstancesForCleanup.push(holeDrill);
30044
+ const finalCopper = copperUnion.subtract(holeDrill);
30045
+ manifoldInstancesForCleanup.push(finalCopper);
30046
+ const translatedCopper = finalCopper.translate([ph.x, ph.y, 0]);
29843
30047
  manifoldInstancesForCleanup.push(translatedCopper);
29844
30048
  let finalCopperOp = translatedCopper;
29845
30049
  if (boardClipVolume) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.412",
3
+ "version": "0.0.414",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -47,8 +47,8 @@
47
47
  "@storybook/blocks": "9.0.0-alpha.17",
48
48
  "@storybook/react-vite": "^9.1.5",
49
49
  "@tscircuit/circuit-json-util": "^0.0.72",
50
- "@tscircuit/core": "^0.0.783",
51
- "@tscircuit/props": "^0.0.360",
50
+ "@tscircuit/core": "^0.0.787",
51
+ "@tscircuit/props": "^0.0.364",
52
52
  "@tscircuit/checks": "^0.0.85",
53
53
  "@tscircuit/math-utils": "^0.0.27",
54
54
  "@tscircuit/capacity-autorouter": "^0.0.131",
@@ -60,7 +60,7 @@
60
60
  "@vitejs/plugin-react": "^4.3.4",
61
61
  "bun-match-svg": "^0.0.9",
62
62
  "bun-types": "1.2.1",
63
- "circuit-json": "0.0.278",
63
+ "circuit-json": "0.0.279",
64
64
  "circuit-to-svg": "^0.0.179",
65
65
  "debug": "^4.4.0",
66
66
  "jscad-electronics": "^0.0.48",