@tscircuit/3d-viewer 0.0.224 → 0.0.225

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 +54 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16982,7 +16982,7 @@ import { Canvas, useFrame as useFrame2 } from "@react-three/fiber";
16982
16982
  // package.json
16983
16983
  var package_default = {
16984
16984
  name: "@tscircuit/3d-viewer",
16985
- version: "0.0.223",
16985
+ version: "0.0.224",
16986
16986
  main: "./dist/index.js",
16987
16987
  module: "./dist/index.js",
16988
16988
  type: "module",
@@ -17842,6 +17842,7 @@ var buildStateOrder = [
17842
17842
  "initializing",
17843
17843
  "processing_plated_holes",
17844
17844
  "processing_holes",
17845
+ "processing_cutouts",
17845
17846
  "processing_pads",
17846
17847
  "processing_traces",
17847
17848
  "processing_vias",
@@ -17860,6 +17861,7 @@ var BoardGeomBuilder = class {
17860
17861
  pcb_vias;
17861
17862
  silkscreenTexts;
17862
17863
  silkscreenPaths;
17864
+ pcb_cutouts;
17863
17865
  boardGeom = null;
17864
17866
  platedHoleGeoms = [];
17865
17867
  holeGeoms = [];
@@ -17901,6 +17903,7 @@ var BoardGeomBuilder = class {
17901
17903
  this.pcb_vias = su2(circuitJson).pcb_via.list();
17902
17904
  this.silkscreenTexts = su2(circuitJson).pcb_silkscreen_text.list();
17903
17905
  this.silkscreenPaths = su2(circuitJson).pcb_silkscreen_path.list();
17906
+ this.pcb_cutouts = su2(circuitJson).pcb_cutout.list();
17904
17907
  this.ctx = { pcbThickness: 1.2 };
17905
17908
  this.initializeBoard();
17906
17909
  }
@@ -17990,6 +17993,14 @@ var BoardGeomBuilder = class {
17990
17993
  this.goToNextState();
17991
17994
  }
17992
17995
  break;
17996
+ case "processing_cutouts":
17997
+ if (this.currentIndex < this.pcb_cutouts.length) {
17998
+ this.processCutout(this.pcb_cutouts[this.currentIndex]);
17999
+ this.currentIndex++;
18000
+ } else {
18001
+ this.goToNextState();
18002
+ }
18003
+ break;
17993
18004
  case "finalizing":
17994
18005
  this.finalize();
17995
18006
  this.state = "done";
@@ -17998,6 +18009,48 @@ var BoardGeomBuilder = class {
17998
18009
  }
17999
18010
  return this.state === "done";
18000
18011
  }
18012
+ processCutout(cutout) {
18013
+ if (!this.boardGeom) return;
18014
+ let cutoutGeom = null;
18015
+ const cutoutHeight = this.ctx.pcbThickness * 1.5;
18016
+ switch (cutout.shape) {
18017
+ case "rect":
18018
+ cutoutGeom = (0, import_primitives5.cuboid)({
18019
+ center: [cutout.center.x, cutout.center.y, 0],
18020
+ size: [cutout.width, cutout.height, cutoutHeight]
18021
+ });
18022
+ if (cutout.rotation) {
18023
+ const rotationRadians = cutout.rotation * Math.PI / 180;
18024
+ cutoutGeom = (0, import_transforms3.rotateZ)(rotationRadians, cutoutGeom);
18025
+ }
18026
+ break;
18027
+ case "circle":
18028
+ cutoutGeom = (0, import_primitives5.cylinder)({
18029
+ center: [cutout.center.x, cutout.center.y, 0],
18030
+ radius: cutout.radius,
18031
+ height: cutoutHeight
18032
+ });
18033
+ break;
18034
+ case "polygon":
18035
+ let pointsVec2 = cutout.points.map((p) => [p.x, p.y]);
18036
+ if (pointsVec2.length < 3) {
18037
+ console.warn(
18038
+ `PCB Cutout [${cutout.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`
18039
+ );
18040
+ break;
18041
+ }
18042
+ if (arePointsClockwise(pointsVec2)) {
18043
+ pointsVec2 = pointsVec2.reverse();
18044
+ }
18045
+ const polygon2d = (0, import_primitives5.polygon)({ points: pointsVec2 });
18046
+ cutoutGeom = (0, import_extrusions3.extrudeLinear)({ height: cutoutHeight }, polygon2d);
18047
+ cutoutGeom = (0, import_transforms3.translate)([0, 0, -cutoutHeight / 2], cutoutGeom);
18048
+ break;
18049
+ }
18050
+ if (cutoutGeom) {
18051
+ this.boardGeom = (0, import_booleans2.subtract)(this.boardGeom, cutoutGeom);
18052
+ }
18053
+ }
18001
18054
  processPlatedHole(ph, opts = {}) {
18002
18055
  if (!this.boardGeom) return;
18003
18056
  if (ph.shape === "circle") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.224",
3
+ "version": "0.0.225",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",