@tscircuit/3d-viewer 0.0.223 → 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 +71 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1278,7 +1278,7 @@ var require_rotateY = __commonJS({
1278
1278
  var require_rotateZ = __commonJS({
1279
1279
  "node_modules/@jscad/modeling/src/maths/vec3/rotateZ.js"(exports, module) {
1280
1280
  "use strict";
1281
- var rotateZ = (out, vector, origin, radians) => {
1281
+ var rotateZ2 = (out, vector, origin, radians) => {
1282
1282
  const p = [];
1283
1283
  const r = [];
1284
1284
  p[0] = vector[0] - origin[0];
@@ -1290,7 +1290,7 @@ var require_rotateZ = __commonJS({
1290
1290
  out[2] = vector[2];
1291
1291
  return out;
1292
1292
  };
1293
- module.exports = rotateZ;
1293
+ module.exports = rotateZ2;
1294
1294
  }
1295
1295
  });
1296
1296
 
@@ -1832,7 +1832,7 @@ var require_rotateZ2 = __commonJS({
1832
1832
  "node_modules/@jscad/modeling/src/maths/mat4/rotateZ.js"(exports, module) {
1833
1833
  "use strict";
1834
1834
  var { sin: sin2, cos: cos2 } = require_trigonometry();
1835
- var rotateZ = (out, matrix, radians) => {
1835
+ var rotateZ2 = (out, matrix, radians) => {
1836
1836
  const s = sin2(radians);
1837
1837
  const c = cos2(radians);
1838
1838
  const a00 = matrix[0];
@@ -1863,7 +1863,7 @@ var require_rotateZ2 = __commonJS({
1863
1863
  out[7] = a13 * c - a03 * s;
1864
1864
  return out;
1865
1865
  };
1866
- module.exports = rotateZ;
1866
+ module.exports = rotateZ2;
1867
1867
  }
1868
1868
  });
1869
1869
 
@@ -7680,12 +7680,12 @@ var require_rotate3 = __commonJS({
7680
7680
  };
7681
7681
  var rotateX = (angle, ...objects) => rotate2([angle, 0, 0], objects);
7682
7682
  var rotateY = (angle, ...objects) => rotate2([0, angle, 0], objects);
7683
- var rotateZ = (angle, ...objects) => rotate2([0, 0, angle], objects);
7683
+ var rotateZ2 = (angle, ...objects) => rotate2([0, 0, angle], objects);
7684
7684
  module.exports = {
7685
7685
  rotate: rotate2,
7686
7686
  rotateX,
7687
7687
  rotateY,
7688
- rotateZ
7688
+ rotateZ: rotateZ2
7689
7689
  };
7690
7690
  }
7691
7691
  });
@@ -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.222",
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") {
@@ -18067,6 +18120,17 @@ var BoardGeomBuilder = class {
18067
18120
  })
18068
18121
  );
18069
18122
  this.padGeoms.push(padGeom);
18123
+ } else if (pad.shape === "rotated_rect") {
18124
+ let basePadGeom = (0, import_primitives5.cuboid)({
18125
+ // Create at origin for rotation, then translate
18126
+ center: [0, 0, 0],
18127
+ size: [pad.width, pad.height, M]
18128
+ });
18129
+ const rotationRadians = pad.ccw_rotation * Math.PI / 180;
18130
+ basePadGeom = (0, import_transforms3.rotateZ)(rotationRadians, basePadGeom);
18131
+ const positionedPadGeom = (0, import_transforms3.translate)([pad.x, pad.y, zPos], basePadGeom);
18132
+ const padGeom = (0, import_colors4.colorize)(colors.copper, positionedPadGeom);
18133
+ this.padGeoms.push(padGeom);
18070
18134
  } else if (pad.shape === "circle") {
18071
18135
  const padGeom = (0, import_colors4.colorize)(
18072
18136
  colors.copper,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.223",
3
+ "version": "0.0.225",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",