@tscircuit/3d-viewer 0.0.410 → 0.0.412

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 +159 -32
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -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.409",
26579
+ version: "0.0.411",
26580
26580
  main: "./dist/index.js",
26581
26581
  module: "./dist/index.js",
26582
26582
  type: "module",
@@ -26623,7 +26623,7 @@ 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.781",
26626
+ "@tscircuit/core": "^0.0.783",
26627
26627
  "@tscircuit/props": "^0.0.360",
26628
26628
  "@tscircuit/checks": "^0.0.85",
26629
26629
  "@tscircuit/math-utils": "^0.0.27",
@@ -26646,7 +26646,7 @@ var package_default = {
26646
26646
  "react-use-gesture": "^9.1.3",
26647
26647
  semver: "^7.7.0",
26648
26648
  "strip-ansi": "^7.1.0",
26649
- tscircuit: "^0.0.742",
26649
+ tscircuit: "^0.0.746",
26650
26650
  tsup: "^8.3.6",
26651
26651
  typescript: "^5.7.3",
26652
26652
  vite: "^7.1.5",
@@ -28486,6 +28486,99 @@ var BoardGeomBuilder = class {
28486
28486
  this.padGeoms = this.padGeoms.map(
28487
28487
  (pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, cyGeom))
28488
28488
  );
28489
+ } else if (hole.hole_shape === "pill") {
28490
+ const holeWidth = hole.hole_width;
28491
+ const holeHeight = hole.hole_height;
28492
+ const holeRadius = Math.min(holeWidth, holeHeight) / 2;
28493
+ const rectLength = Math.abs(holeWidth - holeHeight);
28494
+ let pillHole;
28495
+ if (holeWidth > holeHeight) {
28496
+ pillHole = (0, import_booleans3.union)(
28497
+ (0, import_primitives6.cuboid)({
28498
+ center: [hole.x, hole.y, 0],
28499
+ size: [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
28500
+ }),
28501
+ (0, import_primitives6.cylinder)({
28502
+ center: [hole.x - rectLength / 2, hole.y, 0],
28503
+ radius: holeRadius,
28504
+ height: this.ctx.pcbThickness * 1.5
28505
+ }),
28506
+ (0, import_primitives6.cylinder)({
28507
+ center: [hole.x + rectLength / 2, hole.y, 0],
28508
+ radius: holeRadius,
28509
+ height: this.ctx.pcbThickness * 1.5
28510
+ })
28511
+ );
28512
+ } else {
28513
+ pillHole = (0, import_booleans3.union)(
28514
+ (0, import_primitives6.cuboid)({
28515
+ center: [hole.x, hole.y, 0],
28516
+ size: [holeWidth, rectLength, this.ctx.pcbThickness * 1.5]
28517
+ }),
28518
+ (0, import_primitives6.cylinder)({
28519
+ center: [hole.x, hole.y - rectLength / 2, 0],
28520
+ radius: holeRadius,
28521
+ height: this.ctx.pcbThickness * 1.5
28522
+ }),
28523
+ (0, import_primitives6.cylinder)({
28524
+ center: [hole.x, hole.y + rectLength / 2, 0],
28525
+ radius: holeRadius,
28526
+ height: this.ctx.pcbThickness * 1.5
28527
+ })
28528
+ );
28529
+ }
28530
+ this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
28531
+ this.padGeoms = this.padGeoms.map(
28532
+ (pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, pillHole))
28533
+ );
28534
+ } else if (hole.hole_shape === "rotated_pill") {
28535
+ const holeWidth = hole.hole_width;
28536
+ const holeHeight = hole.hole_height;
28537
+ const holeRadius = Math.min(holeWidth, holeHeight) / 2;
28538
+ const rectLength = Math.abs(holeWidth - holeHeight);
28539
+ let pillHole;
28540
+ if (holeWidth > holeHeight) {
28541
+ pillHole = (0, import_booleans3.union)(
28542
+ (0, import_primitives6.cuboid)({
28543
+ center: [0, 0, 0],
28544
+ size: [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
28545
+ }),
28546
+ (0, import_primitives6.cylinder)({
28547
+ center: [-rectLength / 2, 0, 0],
28548
+ radius: holeRadius,
28549
+ height: this.ctx.pcbThickness * 1.5
28550
+ }),
28551
+ (0, import_primitives6.cylinder)({
28552
+ center: [rectLength / 2, 0, 0],
28553
+ radius: holeRadius,
28554
+ height: this.ctx.pcbThickness * 1.5
28555
+ })
28556
+ );
28557
+ } else {
28558
+ pillHole = (0, import_booleans3.union)(
28559
+ (0, import_primitives6.cuboid)({
28560
+ center: [0, 0, 0],
28561
+ size: [holeWidth, rectLength, this.ctx.pcbThickness * 1.5]
28562
+ }),
28563
+ (0, import_primitives6.cylinder)({
28564
+ center: [0, -rectLength / 2, 0],
28565
+ radius: holeRadius,
28566
+ height: this.ctx.pcbThickness * 1.5
28567
+ }),
28568
+ (0, import_primitives6.cylinder)({
28569
+ center: [0, rectLength / 2, 0],
28570
+ radius: holeRadius,
28571
+ height: this.ctx.pcbThickness * 1.5
28572
+ })
28573
+ );
28574
+ }
28575
+ const rotationRadians = hole.ccw_rotation * Math.PI / 180;
28576
+ pillHole = (0, import_transforms4.rotateZ)(rotationRadians, pillHole);
28577
+ pillHole = (0, import_transforms4.translate)([hole.x, hole.y, 0], pillHole);
28578
+ this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
28579
+ this.padGeoms = this.padGeoms.map(
28580
+ (pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, pillHole))
28581
+ );
28489
28582
  }
28490
28583
  }
28491
28584
  processPad(pad2) {
@@ -29348,34 +29441,6 @@ function createPlatedHoleDrill({
29348
29441
  return drill.translate([x, y, 0]);
29349
29442
  }
29350
29443
 
29351
- // src/utils/manifold/process-non-plated-holes.ts
29352
- function isCircleHole(hole) {
29353
- return (hole.shape === "circle" || hole.hole_shape === "circle") && typeof hole.hole_diameter === "number";
29354
- }
29355
- function processNonPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
29356
- const nonPlatedHoleBoardDrills = [];
29357
- const pcbHoles = su7(circuitJson).pcb_hole.list();
29358
- pcbHoles.forEach((hole) => {
29359
- if (isCircleHole(hole)) {
29360
- const translatedDrill = createCircleHoleDrill({
29361
- Manifold,
29362
- x: hole.x,
29363
- y: hole.y,
29364
- diameter: hole.hole_diameter,
29365
- thickness: pcbThickness,
29366
- segments: SMOOTH_CIRCLE_SEGMENTS
29367
- });
29368
- manifoldInstancesForCleanup.push(translatedDrill);
29369
- nonPlatedHoleBoardDrills.push(translatedDrill);
29370
- }
29371
- });
29372
- return { nonPlatedHoleBoardDrills };
29373
- }
29374
-
29375
- // src/utils/manifold/process-plated-holes.ts
29376
- import { su as su8 } from "@tscircuit/circuit-json-util";
29377
- import * as THREE19 from "three";
29378
-
29379
29444
  // src/utils/pad-geoms.ts
29380
29445
  var RECT_PAD_SEGMENTS2 = 64;
29381
29446
  function createRoundedRectPrism({
@@ -29451,7 +29516,69 @@ function createPadManifoldOp({
29451
29516
  return null;
29452
29517
  }
29453
29518
 
29519
+ // src/utils/manifold/process-non-plated-holes.ts
29520
+ function isCircleHole(hole) {
29521
+ return (hole.shape === "circle" || hole.hole_shape === "circle") && typeof hole.hole_diameter === "number";
29522
+ }
29523
+ function isPillHole(hole) {
29524
+ return (hole.shape === "pill" || hole.hole_shape === "pill") && typeof hole.hole_width === "number" && typeof hole.hole_height === "number";
29525
+ }
29526
+ function isRotatedPillHole(hole) {
29527
+ return (hole.shape === "rotated_pill" || hole.hole_shape === "rotated_pill") && typeof hole.hole_width === "number" && typeof hole.hole_height === "number" && typeof hole.ccw_rotation === "number";
29528
+ }
29529
+ function processNonPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
29530
+ const nonPlatedHoleBoardDrills = [];
29531
+ const pcbHoles = su7(circuitJson).pcb_hole.list();
29532
+ const createPillOp = (width10, height10, depth) => {
29533
+ const pillOp = createRoundedRectPrism({
29534
+ Manifold,
29535
+ width: width10,
29536
+ height: height10,
29537
+ thickness: depth,
29538
+ borderRadius: Math.min(width10, height10) / 2
29539
+ });
29540
+ manifoldInstancesForCleanup.push(pillOp);
29541
+ return pillOp;
29542
+ };
29543
+ pcbHoles.forEach((hole) => {
29544
+ if (isCircleHole(hole)) {
29545
+ const translatedDrill = createCircleHoleDrill({
29546
+ Manifold,
29547
+ x: hole.x,
29548
+ y: hole.y,
29549
+ diameter: hole.hole_diameter,
29550
+ thickness: pcbThickness,
29551
+ segments: SMOOTH_CIRCLE_SEGMENTS
29552
+ });
29553
+ manifoldInstancesForCleanup.push(translatedDrill);
29554
+ nonPlatedHoleBoardDrills.push(translatedDrill);
29555
+ } else if (isPillHole(hole)) {
29556
+ const holeW = hole.hole_width;
29557
+ const holeH = hole.hole_height;
29558
+ const drillDepth = pcbThickness * 1.2;
29559
+ const pillDrillOp = createPillOp(holeW, holeH, drillDepth);
29560
+ const translatedPillDrill = pillDrillOp.translate([hole.x, hole.y, 0]);
29561
+ manifoldInstancesForCleanup.push(translatedPillDrill);
29562
+ nonPlatedHoleBoardDrills.push(translatedPillDrill);
29563
+ } else if (isRotatedPillHole(hole)) {
29564
+ const holeW = hole.hole_width;
29565
+ const holeH = hole.hole_height;
29566
+ const drillDepth = pcbThickness * 1.2;
29567
+ let pillDrillOp = createPillOp(holeW, holeH, drillDepth);
29568
+ const rotatedOp = pillDrillOp.rotate([0, 0, hole.ccw_rotation]);
29569
+ manifoldInstancesForCleanup.push(rotatedOp);
29570
+ pillDrillOp = rotatedOp;
29571
+ const translatedPillDrill = pillDrillOp.translate([hole.x, hole.y, 0]);
29572
+ manifoldInstancesForCleanup.push(translatedPillDrill);
29573
+ nonPlatedHoleBoardDrills.push(translatedPillDrill);
29574
+ }
29575
+ });
29576
+ return { nonPlatedHoleBoardDrills };
29577
+ }
29578
+
29454
29579
  // src/utils/manifold/process-plated-holes.ts
29580
+ import { su as su8 } from "@tscircuit/circuit-json-util";
29581
+ import * as THREE19 from "three";
29455
29582
  var COPPER_COLOR = new THREE19.Color(...colors.copper);
29456
29583
  var PLATED_HOLE_LIP_HEIGHT = 0.05;
29457
29584
  function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
@@ -31246,7 +31373,7 @@ async function load3DModel(url) {
31246
31373
 
31247
31374
  // src/utils/render-component.tsx
31248
31375
  async function renderComponent(component, scene) {
31249
- const url = component.model_obj_url ?? component.model_wrl_url ?? component.model_stl_url ?? component.model_gltf_url;
31376
+ const url = component.model_obj_url ?? component.model_wrl_url ?? component.model_stl_url ?? component.model_glb_url ?? component.model_gltf_url;
31250
31377
  if (url) {
31251
31378
  const model = await load3DModel(url);
31252
31379
  if (model) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.410",
3
+ "version": "0.0.412",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
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.781",
50
+ "@tscircuit/core": "^0.0.783",
51
51
  "@tscircuit/props": "^0.0.360",
52
52
  "@tscircuit/checks": "^0.0.85",
53
53
  "@tscircuit/math-utils": "^0.0.27",
@@ -70,7 +70,7 @@
70
70
  "react-use-gesture": "^9.1.3",
71
71
  "semver": "^7.7.0",
72
72
  "strip-ansi": "^7.1.0",
73
- "tscircuit": "^0.0.742",
73
+ "tscircuit": "^0.0.746",
74
74
  "tsup": "^8.3.6",
75
75
  "typescript": "^5.7.3",
76
76
  "vite": "^7.1.5",