@tscircuit/3d-viewer 0.0.407 → 0.0.408

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 +101 -58
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26100,7 +26100,7 @@ import * as THREE13 from "three";
26100
26100
  // package.json
26101
26101
  var package_default = {
26102
26102
  name: "@tscircuit/3d-viewer",
26103
- version: "0.0.406",
26103
+ version: "0.0.407",
26104
26104
  main: "./dist/index.js",
26105
26105
  module: "./dist/index.js",
26106
26106
  type: "module",
@@ -28930,6 +28930,20 @@ function createPadManifoldOp({
28930
28930
  thickness: padBaseThickness,
28931
28931
  borderRadius: rectBorderRadius
28932
28932
  });
28933
+ } else if (pad2.shape === "rotated_rect") {
28934
+ const rectBorderRadius = extractRectBorderRadius(pad2);
28935
+ let padOp = createRoundedRectPrism({
28936
+ Manifold,
28937
+ width: pad2.width,
28938
+ height: pad2.height,
28939
+ thickness: padBaseThickness,
28940
+ borderRadius: rectBorderRadius
28941
+ });
28942
+ const rotation2 = pad2.ccw_rotation ?? 0;
28943
+ if (rotation2) {
28944
+ padOp = padOp.rotate([0, 0, rotation2]);
28945
+ }
28946
+ return padOp;
28933
28947
  } else if (pad2.shape === "circle" && pad2.radius) {
28934
28948
  return Manifold.cylinder(padBaseThickness, pad2.radius, -1, 32, true);
28935
28949
  }
@@ -28938,10 +28952,22 @@ function createPadManifoldOp({
28938
28952
 
28939
28953
  // src/utils/manifold/process-plated-holes.ts
28940
28954
  var COPPER_COLOR = new THREE19.Color(...colors.copper);
28955
+ var PLATED_HOLE_LIP_HEIGHT = 0.05;
28941
28956
  function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
28942
28957
  const platedHoleBoardDrills = [];
28943
28958
  const pcbPlatedHoles = su8(circuitJson).pcb_plated_hole.list();
28944
28959
  const platedHoleCopperGeoms = [];
28960
+ const createPillOp = (width10, height10, depth) => {
28961
+ const pillOp = createRoundedRectPrism({
28962
+ Manifold,
28963
+ width: width10,
28964
+ height: height10,
28965
+ thickness: depth,
28966
+ borderRadius: Math.min(width10, height10) / 2
28967
+ });
28968
+ manifoldInstancesForCleanup.push(pillOp);
28969
+ return pillOp;
28970
+ };
28945
28971
  pcbPlatedHoles.forEach((ph, index) => {
28946
28972
  if (ph.shape === "circle") {
28947
28973
  const translatedDrill = createPlatedHoleDrill({
@@ -28987,60 +29013,15 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
28987
29013
  color: COPPER_COLOR
28988
29014
  });
28989
29015
  } else if (ph.shape === "pill") {
28990
- const holeWidthRaw = ph.hole_width;
28991
- const holeHeightRaw = ph.hole_height;
28992
- const shouldRotate = holeHeightRaw > holeWidthRaw;
28993
- const holeW = shouldRotate ? holeHeightRaw : holeWidthRaw;
28994
- const holeH = shouldRotate ? holeWidthRaw : holeHeightRaw;
29016
+ const holeW = ph.hole_width;
29017
+ const holeH = ph.hole_height;
28995
29018
  const defaultPadExtension = 0.4;
28996
- const outerW = shouldRotate ? ph.outer_height ?? holeH + defaultPadExtension / 2 : ph.outer_width ?? holeW + defaultPadExtension / 2;
28997
- const outerH = shouldRotate ? ph.outer_width ?? holeW + defaultPadExtension / 2 : ph.outer_height ?? holeH + defaultPadExtension / 2;
28998
- const createPill = (width10, height10, depth) => {
28999
- const radius = height10 / 2;
29000
- const rectLength = width10 - height10;
29001
- let pillOp;
29002
- if (rectLength < 1e-9) {
29003
- pillOp = Manifold.cylinder(
29004
- depth,
29005
- radius,
29006
- radius,
29007
- SMOOTH_CIRCLE_SEGMENTS,
29008
- true
29009
- );
29010
- } else {
29011
- const rect = Manifold.cube(
29012
- [Math.max(0, rectLength), height10, depth],
29013
- true
29014
- );
29015
- const cap1 = Manifold.cylinder(
29016
- depth,
29017
- radius,
29018
- radius,
29019
- SMOOTH_CIRCLE_SEGMENTS,
29020
- true
29021
- ).translate([-rectLength / 2, 0, 0]);
29022
- const cap2 = Manifold.cylinder(
29023
- depth,
29024
- radius,
29025
- radius,
29026
- SMOOTH_CIRCLE_SEGMENTS,
29027
- true
29028
- ).translate([rectLength / 2, 0, 0]);
29029
- pillOp = Manifold.union([rect, cap1, cap2]);
29030
- manifoldInstancesForCleanup.push(rect, cap1, cap2);
29031
- }
29032
- manifoldInstancesForCleanup.push(pillOp);
29033
- return pillOp;
29034
- };
29019
+ const outerW = ph.outer_width ?? holeW + defaultPadExtension;
29020
+ const outerH = ph.outer_height ?? holeH + defaultPadExtension;
29035
29021
  const drillW = holeW + 2 * MANIFOLD_Z_OFFSET;
29036
29022
  const drillH = holeH + 2 * MANIFOLD_Z_OFFSET;
29037
29023
  const drillDepth = pcbThickness * 1.2;
29038
- let boardPillDrillOp = createPill(drillW, drillH, drillDepth);
29039
- if (shouldRotate) {
29040
- const rotatedOp = boardPillDrillOp.rotate([0, 0, 90]);
29041
- manifoldInstancesForCleanup.push(rotatedOp);
29042
- boardPillDrillOp = rotatedOp;
29043
- }
29024
+ let boardPillDrillOp = createPillOp(drillW, drillH, drillDepth);
29044
29025
  if (ph.ccw_rotation) {
29045
29026
  const rotatedOp = boardPillDrillOp.rotate([0, 0, ph.ccw_rotation]);
29046
29027
  manifoldInstancesForCleanup.push(rotatedOp);
@@ -29054,12 +29035,12 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29054
29035
  manifoldInstancesForCleanup.push(translatedBoardPillDrill);
29055
29036
  platedHoleBoardDrills.push(translatedBoardPillDrill);
29056
29037
  const copperPartThickness = pcbThickness + 2 * MANIFOLD_Z_OFFSET;
29057
- const outerCopperOpUnrotated = createPill(
29038
+ const outerCopperOpUnrotated = createPillOp(
29058
29039
  outerW,
29059
29040
  outerH,
29060
29041
  copperPartThickness
29061
29042
  );
29062
- const innerDrillOpUnrotated = createPill(
29043
+ const innerDrillOpUnrotated = createPillOp(
29063
29044
  holeW,
29064
29045
  holeH,
29065
29046
  copperPartThickness * 1.05
@@ -29069,11 +29050,6 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29069
29050
  innerDrillOpUnrotated
29070
29051
  );
29071
29052
  manifoldInstancesForCleanup.push(finalPlatedPartOp);
29072
- if (shouldRotate) {
29073
- const rotatedOp = finalPlatedPartOp.rotate([0, 0, 90]);
29074
- manifoldInstancesForCleanup.push(rotatedOp);
29075
- finalPlatedPartOp = rotatedOp;
29076
- }
29077
29053
  if (ph.ccw_rotation) {
29078
29054
  const rotatedOp = finalPlatedPartOp.rotate([0, 0, ph.ccw_rotation]);
29079
29055
  manifoldInstancesForCleanup.push(rotatedOp);
@@ -29089,6 +29065,73 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
29089
29065
  geometry: threeGeom,
29090
29066
  color: COPPER_COLOR
29091
29067
  });
29068
+ } else if (ph.shape === "pill_hole_with_rect_pad") {
29069
+ const holeW = ph.hole_width;
29070
+ const holeH = ph.hole_height;
29071
+ const padWidth = ph.rect_pad_width;
29072
+ const padHeight = ph.rect_pad_height;
29073
+ const rectBorderRadius = extractRectBorderRadius(ph);
29074
+ const padThickness = DEFAULT_SMT_PAD_THICKNESS;
29075
+ const drillW = holeW + 2 * MANIFOLD_Z_OFFSET;
29076
+ const drillH = holeH + 2 * MANIFOLD_Z_OFFSET;
29077
+ const drillDepth = pcbThickness * 1.2;
29078
+ let boardPillDrillOp = createPillOp(drillW, drillH, drillDepth);
29079
+ const translatedBoardPillDrill = boardPillDrillOp.translate([
29080
+ ph.x,
29081
+ ph.y,
29082
+ 0
29083
+ ]);
29084
+ manifoldInstancesForCleanup.push(translatedBoardPillDrill);
29085
+ platedHoleBoardDrills.push(translatedBoardPillDrill);
29086
+ let copperBarrelOp = createPillOp(
29087
+ holeW,
29088
+ holeH,
29089
+ pcbThickness + 2 * MANIFOLD_Z_OFFSET
29090
+ );
29091
+ let topPadOp = createRoundedRectPrism({
29092
+ Manifold,
29093
+ width: padWidth,
29094
+ height: padHeight,
29095
+ thickness: padThickness,
29096
+ borderRadius: rectBorderRadius
29097
+ });
29098
+ manifoldInstancesForCleanup.push(topPadOp);
29099
+ let bottomPadOp = createRoundedRectPrism({
29100
+ Manifold,
29101
+ width: padWidth,
29102
+ height: padHeight,
29103
+ thickness: padThickness,
29104
+ borderRadius: rectBorderRadius
29105
+ });
29106
+ manifoldInstancesForCleanup.push(bottomPadOp);
29107
+ const topPadZ = pcbThickness / 2 + padThickness / 2 + MANIFOLD_Z_OFFSET;
29108
+ const bottomPadZ = -pcbThickness / 2 - padThickness / 2 - MANIFOLD_Z_OFFSET;
29109
+ topPadOp = topPadOp.translate([0, 0, topPadZ]);
29110
+ manifoldInstancesForCleanup.push(topPadOp);
29111
+ bottomPadOp = bottomPadOp.translate([0, 0, bottomPadZ]);
29112
+ manifoldInstancesForCleanup.push(bottomPadOp);
29113
+ const copperUnionBeforeCut = Manifold.union([
29114
+ copperBarrelOp,
29115
+ topPadOp,
29116
+ bottomPadOp
29117
+ ]);
29118
+ manifoldInstancesForCleanup.push(copperUnionBeforeCut);
29119
+ const holeCutWidth = Math.max(holeW - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01);
29120
+ const holeCutHeight = Math.max(holeH - 2 * PLATED_HOLE_LIP_HEIGHT, 0.01);
29121
+ const holeCutDepth = pcbThickness + 2 * padThickness + 4 * MANIFOLD_Z_OFFSET;
29122
+ let holeCutOp = createPillOp(holeCutWidth, holeCutHeight, holeCutDepth);
29123
+ const finalPlatedPartOp = copperUnionBeforeCut.subtract(holeCutOp);
29124
+ manifoldInstancesForCleanup.push(finalPlatedPartOp);
29125
+ const translatedPlatedPart = finalPlatedPartOp.translate([ph.x, ph.y, 0]);
29126
+ manifoldInstancesForCleanup.push(translatedPlatedPart);
29127
+ const threeGeom = manifoldMeshToThreeGeometry(
29128
+ translatedPlatedPart.getMesh()
29129
+ );
29130
+ platedHoleCopperGeoms.push({
29131
+ key: `ph-${ph.pcb_plated_hole_id || index}`,
29132
+ geometry: threeGeom,
29133
+ color: COPPER_COLOR
29134
+ });
29092
29135
  } else if (ph.shape === "circular_hole_with_rect_pad") {
29093
29136
  const translatedDrill = createCircleHoleDrill({
29094
29137
  Manifold,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.407",
3
+ "version": "0.0.408",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",