@tscircuit/3d-viewer 0.0.423 → 0.0.424

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 +306 -152
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1053,7 +1053,7 @@ var require_rotateY = __commonJS({
1053
1053
  var require_rotateZ = __commonJS({
1054
1054
  "node_modules/@jscad/modeling/src/maths/vec3/rotateZ.js"(exports, module) {
1055
1055
  "use strict";
1056
- var rotateZ2 = (out, vector, origin, radians) => {
1056
+ var rotateZ3 = (out, vector, origin, radians) => {
1057
1057
  const p = [];
1058
1058
  const r = [];
1059
1059
  p[0] = vector[0] - origin[0];
@@ -1065,7 +1065,7 @@ var require_rotateZ = __commonJS({
1065
1065
  out[2] = vector[2];
1066
1066
  return out;
1067
1067
  };
1068
- module.exports = rotateZ2;
1068
+ module.exports = rotateZ3;
1069
1069
  }
1070
1070
  });
1071
1071
 
@@ -1129,13 +1129,13 @@ var require_squaredLength = __commonJS({
1129
1129
  var require_subtract = __commonJS({
1130
1130
  "node_modules/@jscad/modeling/src/maths/vec3/subtract.js"(exports, module) {
1131
1131
  "use strict";
1132
- var subtract4 = (out, a, b) => {
1132
+ var subtract5 = (out, a, b) => {
1133
1133
  out[0] = a[0] - b[0];
1134
1134
  out[1] = a[1] - b[1];
1135
1135
  out[2] = a[2] - b[2];
1136
1136
  return out;
1137
1137
  };
1138
- module.exports = subtract4;
1138
+ module.exports = subtract5;
1139
1139
  }
1140
1140
  });
1141
1141
 
@@ -1607,7 +1607,7 @@ var require_rotateZ2 = __commonJS({
1607
1607
  "node_modules/@jscad/modeling/src/maths/mat4/rotateZ.js"(exports, module) {
1608
1608
  "use strict";
1609
1609
  var { sin: sin2, cos: cos2 } = require_trigonometry();
1610
- var rotateZ2 = (out, matrix, radians) => {
1610
+ var rotateZ3 = (out, matrix, radians) => {
1611
1611
  const s = sin2(radians);
1612
1612
  const c = cos2(radians);
1613
1613
  const a00 = matrix[0];
@@ -1638,7 +1638,7 @@ var require_rotateZ2 = __commonJS({
1638
1638
  out[7] = a13 * c - a03 * s;
1639
1639
  return out;
1640
1640
  };
1641
- module.exports = rotateZ2;
1641
+ module.exports = rotateZ3;
1642
1642
  }
1643
1643
  });
1644
1644
 
@@ -1676,7 +1676,7 @@ var require_scale2 = __commonJS({
1676
1676
  var require_subtract2 = __commonJS({
1677
1677
  "node_modules/@jscad/modeling/src/maths/mat4/subtract.js"(exports, module) {
1678
1678
  "use strict";
1679
- var subtract4 = (out, a, b) => {
1679
+ var subtract5 = (out, a, b) => {
1680
1680
  out[0] = a[0] - b[0];
1681
1681
  out[1] = a[1] - b[1];
1682
1682
  out[2] = a[2] - b[2];
@@ -1695,7 +1695,7 @@ var require_subtract2 = __commonJS({
1695
1695
  out[15] = a[15] - b[15];
1696
1696
  return out;
1697
1697
  };
1698
- module.exports = subtract4;
1698
+ module.exports = subtract5;
1699
1699
  }
1700
1700
  });
1701
1701
 
@@ -1712,7 +1712,7 @@ var require_toString2 = __commonJS({
1712
1712
  var require_translate = __commonJS({
1713
1713
  "node_modules/@jscad/modeling/src/maths/mat4/translate.js"(exports, module) {
1714
1714
  "use strict";
1715
- var translate7 = (out, matrix, offsets) => {
1715
+ var translate8 = (out, matrix, offsets) => {
1716
1716
  const x = offsets[0];
1717
1717
  const y = offsets[1];
1718
1718
  const z126 = offsets[2];
@@ -1765,7 +1765,7 @@ var require_translate = __commonJS({
1765
1765
  }
1766
1766
  return out;
1767
1767
  };
1768
- module.exports = translate7;
1768
+ module.exports = translate8;
1769
1769
  }
1770
1770
  });
1771
1771
 
@@ -2205,12 +2205,12 @@ var require_squaredLength2 = __commonJS({
2205
2205
  var require_subtract3 = __commonJS({
2206
2206
  "node_modules/@jscad/modeling/src/maths/vec2/subtract.js"(exports, module) {
2207
2207
  "use strict";
2208
- var subtract4 = (out, a, b) => {
2208
+ var subtract5 = (out, a, b) => {
2209
2209
  out[0] = a[0] - b[0];
2210
2210
  out[1] = a[1] - b[1];
2211
2211
  return out;
2212
2212
  };
2213
- module.exports = subtract4;
2213
+ module.exports = subtract5;
2214
2214
  }
2215
2215
  });
2216
2216
 
@@ -2671,14 +2671,14 @@ var require_point_line_distance = __commonJS({
2671
2671
  "node_modules/@jscad/modeling/src/operations/hulls/quickhull/point-line-distance.js"(exports, module) {
2672
2672
  "use strict";
2673
2673
  var cross = require_cross();
2674
- var subtract4 = require_subtract();
2674
+ var subtract5 = require_subtract();
2675
2675
  var squaredLength = require_squaredLength();
2676
2676
  var distanceSquared = (p, a, b) => {
2677
2677
  const ab = [];
2678
2678
  const ap = [];
2679
2679
  const cr = [];
2680
- subtract4(ab, b, a);
2681
- subtract4(ap, p, a);
2680
+ subtract5(ab, b, a);
2681
+ subtract5(ap, p, a);
2682
2682
  const area = squaredLength(cross(cr, ap, ab));
2683
2683
  const s = squaredLength(ab);
2684
2684
  if (s === 0) {
@@ -2697,11 +2697,11 @@ var require_get_plane_normal = __commonJS({
2697
2697
  "use strict";
2698
2698
  var cross = require_cross();
2699
2699
  var normalize = require_normalize();
2700
- var subtract4 = require_subtract();
2700
+ var subtract5 = require_subtract();
2701
2701
  var planeNormal = (out, point1, point2, point32) => {
2702
2702
  const tmp = [0, 0, 0];
2703
- subtract4(out, point1, point2);
2704
- subtract4(tmp, point2, point32);
2703
+ subtract5(out, point1, point2);
2704
+ subtract5(tmp, point2, point32);
2705
2705
  cross(out, out, tmp);
2706
2706
  return normalize(out, out);
2707
2707
  };
@@ -2915,7 +2915,7 @@ var require_Face = __commonJS({
2915
2915
  var length2 = require_length();
2916
2916
  var normalize = require_normalize();
2917
2917
  var scale2 = require_scale();
2918
- var subtract4 = require_subtract();
2918
+ var subtract5 = require_subtract();
2919
2919
  var HalfEdge = require_HalfEdge();
2920
2920
  var VISIBLE = 0;
2921
2921
  var NON_CONVEX = 1;
@@ -2949,14 +2949,14 @@ var require_Face = __commonJS({
2949
2949
  const e0 = this.edge;
2950
2950
  const e1 = e0.next;
2951
2951
  let e2 = e1.next;
2952
- const v2 = subtract4([], e1.head().point, e0.head().point);
2952
+ const v2 = subtract5([], e1.head().point, e0.head().point);
2953
2953
  const t = [];
2954
2954
  const v1 = [];
2955
2955
  this.nVertices = 2;
2956
2956
  this.normal = [0, 0, 0];
2957
2957
  while (e2 !== e0) {
2958
2958
  copy(v1, v2);
2959
- subtract4(v2, e2.head().point, e0.head().point);
2959
+ subtract5(v2, e2.head().point, e0.head().point);
2960
2960
  add(this.normal, this.normal, cross(t, v1, v2));
2961
2961
  e2 = e2.next;
2962
2962
  this.nVertices += 1;
@@ -2980,7 +2980,7 @@ var require_Face = __commonJS({
2980
2980
  } while (edge !== this.edge);
2981
2981
  const p1 = maxEdge.tail().point;
2982
2982
  const p2 = maxEdge.head().point;
2983
- const maxVector = subtract4([], p2, p1);
2983
+ const maxVector = subtract5([], p2, p1);
2984
2984
  const maxLength = Math.sqrt(maxSquaredLength);
2985
2985
  scale2(maxVector, maxVector, 1 / maxLength);
2986
2986
  const maxProjection = dot(this.normal, maxVector);
@@ -5426,7 +5426,7 @@ var require_colorize = __commonJS({
5426
5426
  newpoly.color = color;
5427
5427
  return newpoly;
5428
5428
  };
5429
- var colorize6 = (color, ...objects) => {
5429
+ var colorize7 = (color, ...objects) => {
5430
5430
  if (!Array.isArray(color)) throw new Error("color must be an array");
5431
5431
  if (color.length < 3) throw new Error("color must contain R, G and B values");
5432
5432
  if (color.length === 3) color = [color[0], color[1], color[2], 1];
@@ -5442,7 +5442,7 @@ var require_colorize = __commonJS({
5442
5442
  });
5443
5443
  return results.length === 1 ? results[0] : results;
5444
5444
  };
5445
- module.exports = colorize6;
5445
+ module.exports = colorize7;
5446
5446
  }
5447
5447
  });
5448
5448
 
@@ -8397,7 +8397,7 @@ var require_roundedRectangle = __commonJS({
8397
8397
  var geom2 = require_geom2();
8398
8398
  var { isGTE, isNumberArray } = require_commonChecks();
8399
8399
  var rectangle = require_rectangle();
8400
- var roundedRectangle3 = (options) => {
8400
+ var roundedRectangle4 = (options) => {
8401
8401
  const defaults = {
8402
8402
  center: [0, 0],
8403
8403
  size: [2, 2],
@@ -8437,7 +8437,7 @@ var require_roundedRectangle = __commonJS({
8437
8437
  }
8438
8438
  return geom2.fromPoints(corner0Points.concat(corner1Points, corner2Points, corner3Points));
8439
8439
  };
8440
- module.exports = roundedRectangle3;
8440
+ module.exports = roundedRectangle4;
8441
8441
  }
8442
8442
  });
8443
8443
 
@@ -9727,12 +9727,12 @@ var require_rotate3 = __commonJS({
9727
9727
  };
9728
9728
  var rotateX = (angle, ...objects) => rotate2([angle, 0, 0], objects);
9729
9729
  var rotateY = (angle, ...objects) => rotate2([0, angle, 0], objects);
9730
- var rotateZ2 = (angle, ...objects) => rotate2([0, 0, angle], objects);
9730
+ var rotateZ3 = (angle, ...objects) => rotate2([0, 0, angle], objects);
9731
9731
  module.exports = {
9732
9732
  rotate: rotate2,
9733
9733
  rotateX,
9734
9734
  rotateY,
9735
- rotateZ: rotateZ2
9735
+ rotateZ: rotateZ3
9736
9736
  };
9737
9737
  }
9738
9738
  });
@@ -9746,7 +9746,7 @@ var require_translate2 = __commonJS({
9746
9746
  var geom2 = require_geom2();
9747
9747
  var geom3 = require_geom3();
9748
9748
  var path2 = require_path2();
9749
- var translate7 = (offset4, ...objects) => {
9749
+ var translate8 = (offset4, ...objects) => {
9750
9750
  if (!Array.isArray(offset4)) throw new Error("offset must be an array");
9751
9751
  objects = flatten(objects);
9752
9752
  if (objects.length === 0) throw new Error("wrong number of arguments");
@@ -9761,11 +9761,11 @@ var require_translate2 = __commonJS({
9761
9761
  });
9762
9762
  return results.length === 1 ? results[0] : results;
9763
9763
  };
9764
- var translateX = (offset4, ...objects) => translate7([offset4, 0, 0], objects);
9765
- var translateY = (offset4, ...objects) => translate7([0, offset4, 0], objects);
9766
- var translateZ = (offset4, ...objects) => translate7([0, 0, offset4], objects);
9764
+ var translateX = (offset4, ...objects) => translate8([offset4, 0, 0], objects);
9765
+ var translateY = (offset4, ...objects) => translate8([0, offset4, 0], objects);
9766
+ var translateZ = (offset4, ...objects) => translate8([0, 0, offset4], objects);
9767
9767
  module.exports = {
9768
- translate: translate7,
9768
+ translate: translate8,
9769
9769
  translateX,
9770
9770
  translateY,
9771
9771
  translateZ
@@ -9780,7 +9780,7 @@ var require_torus = __commonJS({
9780
9780
  var { TAU } = require_constants();
9781
9781
  var extrudeRotate = require_extrudeRotate();
9782
9782
  var { rotate: rotate2 } = require_rotate3();
9783
- var { translate: translate7 } = require_translate2();
9783
+ var { translate: translate8 } = require_translate2();
9784
9784
  var circle = require_circle();
9785
9785
  var { isGT, isGTE } = require_commonChecks();
9786
9786
  var torus = (options) => {
@@ -9805,7 +9805,7 @@ var require_torus = __commonJS({
9805
9805
  if (innerRotation !== 0) {
9806
9806
  innerCircle = rotate2([0, 0, innerRotation], innerCircle);
9807
9807
  }
9808
- innerCircle = translate7([outerRadius, 0], innerCircle);
9808
+ innerCircle = translate8([outerRadius, 0], innerCircle);
9809
9809
  const extrudeOptions = {
9810
9810
  startAngle,
9811
9811
  angle: outerRotation,
@@ -11612,7 +11612,7 @@ var require_subtractGeom3 = __commonJS({
11612
11612
  var flatten = require_flatten();
11613
11613
  var retessellate = require_retessellate();
11614
11614
  var subtractSub = require_subtractGeom3Sub();
11615
- var subtract4 = (...geometries) => {
11615
+ var subtract5 = (...geometries) => {
11616
11616
  geometries = flatten(geometries);
11617
11617
  let newgeometry = geometries.shift();
11618
11618
  geometries.forEach((geometry) => {
@@ -11621,7 +11621,7 @@ var require_subtractGeom3 = __commonJS({
11621
11621
  newgeometry = retessellate(newgeometry);
11622
11622
  return newgeometry;
11623
11623
  };
11624
- module.exports = subtract4;
11624
+ module.exports = subtract5;
11625
11625
  }
11626
11626
  });
11627
11627
 
@@ -11635,14 +11635,14 @@ var require_subtractGeom2 = __commonJS({
11635
11635
  var fromFakePolygons = require_fromFakePolygons();
11636
11636
  var to3DWalls = require_to3DWalls();
11637
11637
  var subtractGeom3 = require_subtractGeom3();
11638
- var subtract4 = (...geometries) => {
11638
+ var subtract5 = (...geometries) => {
11639
11639
  geometries = flatten(geometries);
11640
11640
  const newgeometries = geometries.map((geometry) => to3DWalls({ z0: -1, z1: 1 }, geometry));
11641
11641
  const newgeom3 = subtractGeom3(newgeometries);
11642
11642
  const epsilon = measureEpsilon(newgeom3);
11643
11643
  return fromFakePolygons(epsilon, geom3.toPolygons(newgeom3));
11644
11644
  };
11645
- module.exports = subtract4;
11645
+ module.exports = subtract5;
11646
11646
  }
11647
11647
  });
11648
11648
 
@@ -11656,7 +11656,7 @@ var require_subtract4 = __commonJS({
11656
11656
  var geom3 = require_geom3();
11657
11657
  var subtractGeom2 = require_subtractGeom2();
11658
11658
  var subtractGeom3 = require_subtractGeom3();
11659
- var subtract4 = (...geometries) => {
11659
+ var subtract5 = (...geometries) => {
11660
11660
  geometries = flatten(geometries);
11661
11661
  if (geometries.length === 0) throw new Error("wrong number of arguments");
11662
11662
  if (!areAllShapesTheSameType(geometries)) {
@@ -11667,7 +11667,7 @@ var require_subtract4 = __commonJS({
11667
11667
  if (geom3.isA(geometry)) return subtractGeom3(geometries);
11668
11668
  return geometry;
11669
11669
  };
11670
- module.exports = subtract4;
11670
+ module.exports = subtract5;
11671
11671
  }
11672
11672
  });
11673
11673
 
@@ -11709,7 +11709,7 @@ var require_unionGeom3 = __commonJS({
11709
11709
  var flatten = require_flatten();
11710
11710
  var retessellate = require_retessellate();
11711
11711
  var unionSub = require_unionGeom3Sub();
11712
- var union3 = (...geometries) => {
11712
+ var union4 = (...geometries) => {
11713
11713
  geometries = flatten(geometries);
11714
11714
  let i;
11715
11715
  for (i = 1; i < geometries.length; i += 2) {
@@ -11719,7 +11719,7 @@ var require_unionGeom3 = __commonJS({
11719
11719
  newgeometry = retessellate(newgeometry);
11720
11720
  return newgeometry;
11721
11721
  };
11722
- module.exports = union3;
11722
+ module.exports = union4;
11723
11723
  }
11724
11724
  });
11725
11725
 
@@ -11733,14 +11733,14 @@ var require_unionGeom2 = __commonJS({
11733
11733
  var fromFakePolygons = require_fromFakePolygons();
11734
11734
  var to3DWalls = require_to3DWalls();
11735
11735
  var unionGeom3 = require_unionGeom3();
11736
- var union3 = (...geometries) => {
11736
+ var union4 = (...geometries) => {
11737
11737
  geometries = flatten(geometries);
11738
11738
  const newgeometries = geometries.map((geometry) => to3DWalls({ z0: -1, z1: 1 }, geometry));
11739
11739
  const newgeom3 = unionGeom3(newgeometries);
11740
11740
  const epsilon = measureEpsilon(newgeom3);
11741
11741
  return fromFakePolygons(epsilon, geom3.toPolygons(newgeom3));
11742
11742
  };
11743
- module.exports = union3;
11743
+ module.exports = union4;
11744
11744
  }
11745
11745
  });
11746
11746
 
@@ -11754,7 +11754,7 @@ var require_union = __commonJS({
11754
11754
  var geom3 = require_geom3();
11755
11755
  var unionGeom2 = require_unionGeom2();
11756
11756
  var unionGeom3 = require_unionGeom3();
11757
- var union3 = (...geometries) => {
11757
+ var union4 = (...geometries) => {
11758
11758
  geometries = flatten(geometries);
11759
11759
  if (geometries.length === 0) throw new Error("wrong number of arguments");
11760
11760
  if (!areAllShapesTheSameType(geometries)) {
@@ -11765,7 +11765,7 @@ var require_union = __commonJS({
11765
11765
  if (geom3.isA(geometry)) return unionGeom3(geometries);
11766
11766
  return geometry;
11767
11767
  };
11768
- module.exports = union3;
11768
+ module.exports = union4;
11769
11769
  }
11770
11770
  });
11771
11771
 
@@ -12155,7 +12155,7 @@ var require_expandGeom3 = __commonJS({
12155
12155
  "node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(exports, module) {
12156
12156
  "use strict";
12157
12157
  var geom3 = require_geom3();
12158
- var union3 = require_union();
12158
+ var union4 = require_union();
12159
12159
  var expandShell = require_expandShell();
12160
12160
  var expandGeom3 = (options, geometry) => {
12161
12161
  const defaults = {
@@ -12171,7 +12171,7 @@ var require_expandGeom3 = __commonJS({
12171
12171
  if (polygons.length === 0) throw new Error("the given geometry cannot be empty");
12172
12172
  options = { delta, corners, segments };
12173
12173
  const expanded = expandShell(options, geometry);
12174
- return union3(geometry, expanded);
12174
+ return union4(geometry, expanded);
12175
12175
  };
12176
12176
  module.exports = expandGeom3;
12177
12177
  }
@@ -12451,7 +12451,7 @@ var require_extrudeLinear = __commonJS({
12451
12451
  var path2 = require_path2();
12452
12452
  var extrudeLinearGeom2 = require_extrudeLinearGeom2();
12453
12453
  var extrudeLinearPath2 = require_extrudeLinearPath2();
12454
- var extrudeLinear6 = (options, ...objects) => {
12454
+ var extrudeLinear7 = (options, ...objects) => {
12455
12455
  const defaults = {
12456
12456
  height: 1,
12457
12457
  twistAngle: 0,
@@ -12469,7 +12469,7 @@ var require_extrudeLinear = __commonJS({
12469
12469
  });
12470
12470
  return results.length === 1 ? results[0] : results;
12471
12471
  };
12472
- module.exports = extrudeLinear6;
12472
+ module.exports = extrudeLinear7;
12473
12473
  }
12474
12474
  });
12475
12475
 
@@ -12886,7 +12886,7 @@ var require_hullChain = __commonJS({
12886
12886
  "node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(exports, module) {
12887
12887
  "use strict";
12888
12888
  var flatten = require_flatten();
12889
- var union3 = require_union();
12889
+ var union4 = require_union();
12890
12890
  var hull = require_hull();
12891
12891
  var hullChain = (...geometries) => {
12892
12892
  geometries = flatten(geometries);
@@ -12895,7 +12895,7 @@ var require_hullChain = __commonJS({
12895
12895
  for (let i = 1; i < geometries.length; i++) {
12896
12896
  hulls.push(hull(geometries[i - 1], geometries[i]));
12897
12897
  }
12898
- return union3(hulls);
12898
+ return union4(hulls);
12899
12899
  };
12900
12900
  module.exports = hullChain;
12901
12901
  }
@@ -13528,7 +13528,7 @@ var require_align = __commonJS({
13528
13528
  var flatten = require_flatten();
13529
13529
  var padArrayToLength = require_padArrayToLength();
13530
13530
  var measureAggregateBoundingBox = require_measureAggregateBoundingBox();
13531
- var { translate: translate7 } = require_translate2();
13531
+ var { translate: translate8 } = require_translate2();
13532
13532
  var validateOptions = (options) => {
13533
13533
  if (!Array.isArray(options.modes) || options.modes.length > 3) throw new Error("align(): modes must be an array of length <= 3");
13534
13534
  options.modes = padArrayToLength(options.modes, "none", 3);
@@ -13565,7 +13565,7 @@ var require_align = __commonJS({
13565
13565
  translation[i] = relativeTo[i] - bounds[0][i];
13566
13566
  }
13567
13567
  }
13568
- return translate7(translation, geometry);
13568
+ return translate8(translation, geometry);
13569
13569
  };
13570
13570
  var align = (options, ...geometries) => {
13571
13571
  const defaults = {
@@ -13602,7 +13602,7 @@ var require_center = __commonJS({
13602
13602
  var geom3 = require_geom3();
13603
13603
  var path2 = require_path2();
13604
13604
  var measureBoundingBox = require_measureBoundingBox2();
13605
- var { translate: translate7 } = require_translate2();
13605
+ var { translate: translate8 } = require_translate2();
13606
13606
  var centerGeometry = (options, object) => {
13607
13607
  const defaults = {
13608
13608
  axes: [true, true, true],
@@ -13614,7 +13614,7 @@ var require_center = __commonJS({
13614
13614
  if (axes[0]) offset4[0] = relativeTo[0] - (bounds[0][0] + (bounds[1][0] - bounds[0][0]) / 2);
13615
13615
  if (axes[1]) offset4[1] = relativeTo[1] - (bounds[0][1] + (bounds[1][1] - bounds[0][1]) / 2);
13616
13616
  if (axes[2]) offset4[2] = relativeTo[2] - (bounds[0][2] + (bounds[1][2] - bounds[0][2]) / 2);
13617
- return translate7(offset4, object);
13617
+ return translate8(offset4, object);
13618
13618
  };
13619
13619
  var center = (options, ...objects) => {
13620
13620
  const defaults = {
@@ -24177,7 +24177,7 @@ var m2host = (raw_params) => {
24177
24177
  }
24178
24178
  const centerX = (minX + maxX) / 2;
24179
24179
  const centerY = (minY + maxY) / 2;
24180
- const translate7 = (el) => {
24180
+ const translate8 = (el) => {
24181
24181
  if (typeof el.x === "number") el.x -= centerX;
24182
24182
  if (typeof el.y === "number") el.y -= centerY;
24183
24183
  if (el.center) {
@@ -24191,9 +24191,9 @@ var m2host = (raw_params) => {
24191
24191
  }));
24192
24192
  }
24193
24193
  };
24194
- for (const pad2 of pads) translate7(pad2);
24195
- translate7(cutout);
24196
- translate7(pin1Marker);
24194
+ for (const pad2 of pads) translate8(pad2);
24195
+ translate8(cutout);
24196
+ translate8(pin1Marker);
24197
24197
  return {
24198
24198
  circuitJson: [
24199
24199
  ...pads,
@@ -26647,7 +26647,7 @@ import * as THREE14 from "three";
26647
26647
  // package.json
26648
26648
  var package_default = {
26649
26649
  name: "@tscircuit/3d-viewer",
26650
- version: "0.0.422",
26650
+ version: "0.0.423",
26651
26651
  main: "./dist/index.js",
26652
26652
  module: "./dist/index.js",
26653
26653
  type: "module",
@@ -27810,10 +27810,10 @@ var createBoardGeomFromCircuitJson = (circuitJson, opts = {}) => {
27810
27810
  };
27811
27811
 
27812
27812
  // src/BoardGeomBuilder.ts
27813
- var import_transforms5 = __toESM(require_transforms(), 1);
27814
- var import_primitives7 = __toESM(require_primitives(), 1);
27815
- var import_colors5 = __toESM(require_colors(), 1);
27816
- var import_booleans3 = __toESM(require_booleans(), 1);
27813
+ var import_transforms6 = __toESM(require_transforms(), 1);
27814
+ var import_primitives8 = __toESM(require_primitives(), 1);
27815
+ var import_colors6 = __toESM(require_colors(), 1);
27816
+ var import_booleans4 = __toESM(require_booleans(), 1);
27817
27817
  import { su as su3 } from "@tscircuit/circuit-json-util";
27818
27818
 
27819
27819
  // src/geoms/plated-hole.ts
@@ -28196,7 +28196,7 @@ var platedHole = (plated_hole, ctx, options = {}) => {
28196
28196
  };
28197
28197
 
28198
28198
  // src/BoardGeomBuilder.ts
28199
- var import_extrusions5 = __toESM(require_extrusions(), 1);
28199
+ var import_extrusions6 = __toESM(require_extrusions(), 1);
28200
28200
  var import_expansions4 = __toESM(require_expansions(), 1);
28201
28201
 
28202
28202
  // src/geoms/create-geoms-for-silkscreen-text.ts
@@ -28608,9 +28608,71 @@ function createSilkscreenLineGeom(sl, ctx) {
28608
28608
  return lineGeom;
28609
28609
  }
28610
28610
 
28611
- // src/geoms/brep-converter.ts
28611
+ // src/geoms/create-geoms-for-silkscreen-rect.ts
28612
28612
  var import_primitives6 = __toESM(require_primitives(), 1);
28613
+ var import_extrusions5 = __toESM(require_extrusions(), 1);
28614
+ var import_transforms5 = __toESM(require_transforms(), 1);
28615
+ var import_colors5 = __toESM(require_colors(), 1);
28613
28616
  var import_booleans2 = __toESM(require_booleans(), 1);
28617
+ var RECT_SEGMENTS = 64;
28618
+ function createSilkscreenRectGeom(rect, ctx) {
28619
+ const width10 = coerceDimensionToMm(rect.width, 0);
28620
+ const height10 = coerceDimensionToMm(rect.height, 0);
28621
+ if (width10 <= 0 || height10 <= 0) return void 0;
28622
+ const centerX = parseDimensionToMm(rect.center?.x) ?? 0;
28623
+ const centerY = parseDimensionToMm(rect.center?.y) ?? 0;
28624
+ const rawBorderRadius = extractRectBorderRadius(rect);
28625
+ const borderRadius = clampRectBorderRadius(
28626
+ width10,
28627
+ height10,
28628
+ typeof rawBorderRadius === "string" ? parseDimensionToMm(rawBorderRadius) : rawBorderRadius
28629
+ );
28630
+ const createRectGeom = (rectWidth, rectHeight, radius) => (0, import_extrusions5.extrudeLinear)(
28631
+ { height: 0.012 },
28632
+ (0, import_primitives6.roundedRectangle)({
28633
+ size: [rectWidth, rectHeight],
28634
+ roundRadius: radius,
28635
+ segments: RECT_SEGMENTS
28636
+ })
28637
+ );
28638
+ const isFilled = rect.is_filled ?? true;
28639
+ const hasStroke = rect.has_stroke ?? false;
28640
+ const strokeWidth = hasStroke ? coerceDimensionToMm(rect.stroke_width, 0.1) : 0;
28641
+ let fillGeom;
28642
+ if (isFilled) {
28643
+ fillGeom = createRectGeom(width10, height10, borderRadius);
28644
+ }
28645
+ let strokeGeom;
28646
+ if (hasStroke && strokeWidth > 0) {
28647
+ const outerGeom = createRectGeom(width10, height10, borderRadius);
28648
+ const innerWidth = width10 - strokeWidth * 2;
28649
+ const innerHeight = height10 - strokeWidth * 2;
28650
+ if (innerWidth > 0 && innerHeight > 0) {
28651
+ const innerRadius = clampRectBorderRadius(
28652
+ innerWidth,
28653
+ innerHeight,
28654
+ Math.max(borderRadius - strokeWidth, 0)
28655
+ );
28656
+ const innerGeom = createRectGeom(innerWidth, innerHeight, innerRadius);
28657
+ strokeGeom = (0, import_booleans2.subtract)(outerGeom, innerGeom);
28658
+ } else {
28659
+ strokeGeom = outerGeom;
28660
+ }
28661
+ }
28662
+ let rectGeom = fillGeom;
28663
+ if (strokeGeom) {
28664
+ rectGeom = rectGeom ? (0, import_booleans2.union)(rectGeom, strokeGeom) : strokeGeom;
28665
+ }
28666
+ if (!rectGeom) return void 0;
28667
+ const layerSign = rect.layer === "bottom" ? -1 : 1;
28668
+ const zPos = layerSign * ctx.pcbThickness / 2 + layerSign * M * 1.5;
28669
+ rectGeom = (0, import_transforms5.translate)([centerX, centerY, zPos], rectGeom);
28670
+ return (0, import_colors5.colorize)([1, 1, 1], rectGeom);
28671
+ }
28672
+
28673
+ // src/geoms/brep-converter.ts
28674
+ var import_primitives7 = __toESM(require_primitives(), 1);
28675
+ var import_booleans3 = __toESM(require_booleans(), 1);
28614
28676
  function segmentToPoints(p1, p2, bulge, arcSegments) {
28615
28677
  if (!bulge || Math.abs(bulge) < 1e-9) {
28616
28678
  return [];
@@ -28678,7 +28740,7 @@ function createGeom2FromBRep(brep, arcSegments = 16) {
28678
28740
  if (arePointsClockwise2(outerPoints)) {
28679
28741
  outerPoints.reverse();
28680
28742
  }
28681
- const outerGeom = (0, import_primitives6.polygon)({ points: outerPoints });
28743
+ const outerGeom = (0, import_primitives7.polygon)({ points: outerPoints });
28682
28744
  if (!brep.inner_rings || brep.inner_rings.length === 0) {
28683
28745
  return outerGeom;
28684
28746
  }
@@ -28687,10 +28749,10 @@ function createGeom2FromBRep(brep, arcSegments = 16) {
28687
28749
  if (arePointsClockwise2(innerPoints)) {
28688
28750
  innerPoints.reverse();
28689
28751
  }
28690
- return (0, import_primitives6.polygon)({ points: innerPoints });
28752
+ return (0, import_primitives7.polygon)({ points: innerPoints });
28691
28753
  });
28692
28754
  if (innerGeoms.length === 0) return outerGeom;
28693
- return (0, import_booleans2.subtract)(outerGeom, innerGeoms);
28755
+ return (0, import_booleans3.subtract)(outerGeom, innerGeoms);
28694
28756
  }
28695
28757
 
28696
28758
  // src/BoardGeomBuilder.ts
@@ -28700,15 +28762,15 @@ var BOARD_CLIP_XY_OUTSET = 0.05;
28700
28762
  var createCenteredRectPadGeom = (width10, height10, thickness, rectBorderRadius) => {
28701
28763
  const clampedRadius = clampRectBorderRadius(width10, height10, rectBorderRadius);
28702
28764
  if (clampedRadius <= 0) {
28703
- return (0, import_primitives7.cuboid)({ center: [0, 0, 0], size: [width10, height10, thickness] });
28765
+ return (0, import_primitives8.cuboid)({ center: [0, 0, 0], size: [width10, height10, thickness] });
28704
28766
  }
28705
- const rect2d = (0, import_primitives7.roundedRectangle)({
28767
+ const rect2d = (0, import_primitives8.roundedRectangle)({
28706
28768
  size: [width10, height10],
28707
28769
  roundRadius: clampedRadius,
28708
28770
  segments: PAD_ROUNDED_SEGMENTS
28709
28771
  });
28710
- const extruded = (0, import_extrusions5.extrudeLinear)({ height: thickness }, rect2d);
28711
- return (0, import_transforms5.translate)([0, 0, -thickness / 2], extruded);
28772
+ const extruded = (0, import_extrusions6.extrudeLinear)({ height: thickness }, rect2d);
28773
+ return (0, import_transforms6.translate)([0, 0, -thickness / 2], extruded);
28712
28774
  };
28713
28775
  var buildStateOrder = [
28714
28776
  "initializing",
@@ -28721,6 +28783,7 @@ var buildStateOrder = [
28721
28783
  "processing_vias",
28722
28784
  "processing_silkscreen_text",
28723
28785
  "processing_silkscreen_lines",
28786
+ "processing_silkscreen_rects",
28724
28787
  "processing_silkscreen_paths",
28725
28788
  "finalizing",
28726
28789
  "done"
@@ -28736,6 +28799,7 @@ var BoardGeomBuilder = class {
28736
28799
  silkscreenTexts;
28737
28800
  silkscreenPaths;
28738
28801
  silkscreenLines;
28802
+ silkscreenRects;
28739
28803
  pcb_cutouts;
28740
28804
  pcb_copper_pours;
28741
28805
  boardGeom = null;
@@ -28749,6 +28813,7 @@ var BoardGeomBuilder = class {
28749
28813
  silkscreenTextGeoms = [];
28750
28814
  silkscreenPathGeoms = [];
28751
28815
  silkscreenLineGeoms = [];
28816
+ silkscreenRectGeoms = [];
28752
28817
  copperPourGeoms = [];
28753
28818
  boardClipGeom = null;
28754
28819
  state = "initializing";
@@ -28783,6 +28848,7 @@ var BoardGeomBuilder = class {
28783
28848
  this.silkscreenTexts = su3(circuitJson).pcb_silkscreen_text.list();
28784
28849
  this.silkscreenPaths = su3(circuitJson).pcb_silkscreen_path.list();
28785
28850
  this.silkscreenLines = su3(circuitJson).pcb_silkscreen_line.list();
28851
+ this.silkscreenRects = su3(circuitJson).pcb_silkscreen_rect.list();
28786
28852
  this.pcb_cutouts = su3(circuitJson).pcb_cutout.list();
28787
28853
  this.pcb_copper_pours = circuitJson.filter(
28788
28854
  (e) => e.type === "pcb_copper_pour"
@@ -28807,11 +28873,11 @@ var BoardGeomBuilder = class {
28807
28873
  { xyOutset: BOARD_CLIP_XY_OUTSET }
28808
28874
  );
28809
28875
  } else {
28810
- this.boardGeom = (0, import_primitives7.cuboid)({
28876
+ this.boardGeom = (0, import_primitives8.cuboid)({
28811
28877
  size: [this.board.width, this.board.height, this.ctx.pcbThickness],
28812
28878
  center: [this.board.center.x, this.board.center.y, 0]
28813
28879
  });
28814
- this.boardClipGeom = (0, import_primitives7.cuboid)({
28880
+ this.boardClipGeom = (0, import_primitives8.cuboid)({
28815
28881
  size: [
28816
28882
  this.board.width + 2 * BOARD_CLIP_XY_OUTSET,
28817
28883
  this.board.height + 2 * BOARD_CLIP_XY_OUTSET,
@@ -28891,6 +28957,14 @@ var BoardGeomBuilder = class {
28891
28957
  this.goToNextState();
28892
28958
  }
28893
28959
  break;
28960
+ case "processing_silkscreen_rects":
28961
+ if (this.currentIndex < this.silkscreenRects.length) {
28962
+ this.processSilkscreenRect(this.silkscreenRects[this.currentIndex]);
28963
+ this.currentIndex++;
28964
+ } else {
28965
+ this.goToNextState();
28966
+ }
28967
+ break;
28894
28968
  case "processing_silkscreen_paths":
28895
28969
  if (this.currentIndex < this.silkscreenPaths.length) {
28896
28970
  this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]);
@@ -28929,17 +29003,17 @@ var BoardGeomBuilder = class {
28929
29003
  const cutoutHeight = this.ctx.pcbThickness * 1.5;
28930
29004
  switch (cutout.shape) {
28931
29005
  case "rect":
28932
- cutoutGeom = (0, import_primitives7.cuboid)({
29006
+ cutoutGeom = (0, import_primitives8.cuboid)({
28933
29007
  center: [cutout.center.x, cutout.center.y, 0],
28934
29008
  size: [cutout.width, cutout.height, cutoutHeight]
28935
29009
  });
28936
29010
  if (cutout.rotation) {
28937
29011
  const rotationRadians = cutout.rotation * Math.PI / 180;
28938
- cutoutGeom = (0, import_transforms5.rotateZ)(rotationRadians, cutoutGeom);
29012
+ cutoutGeom = (0, import_transforms6.rotateZ)(rotationRadians, cutoutGeom);
28939
29013
  }
28940
29014
  break;
28941
29015
  case "circle":
28942
- cutoutGeom = (0, import_primitives7.cylinder)({
29016
+ cutoutGeom = (0, import_primitives8.cylinder)({
28943
29017
  center: [cutout.center.x, cutout.center.y, 0],
28944
29018
  radius: cutout.radius,
28945
29019
  height: cutoutHeight
@@ -28956,13 +29030,13 @@ var BoardGeomBuilder = class {
28956
29030
  if (arePointsClockwise(pointsVec2)) {
28957
29031
  pointsVec2 = pointsVec2.reverse();
28958
29032
  }
28959
- const polygon2d = (0, import_primitives7.polygon)({ points: pointsVec2 });
28960
- cutoutGeom = (0, import_extrusions5.extrudeLinear)({ height: cutoutHeight }, polygon2d);
28961
- cutoutGeom = (0, import_transforms5.translate)([0, 0, -cutoutHeight / 2], cutoutGeom);
29033
+ const polygon2d = (0, import_primitives8.polygon)({ points: pointsVec2 });
29034
+ cutoutGeom = (0, import_extrusions6.extrudeLinear)({ height: cutoutHeight }, polygon2d);
29035
+ cutoutGeom = (0, import_transforms6.translate)([0, 0, -cutoutHeight / 2], cutoutGeom);
28962
29036
  break;
28963
29037
  }
28964
29038
  if (cutoutGeom) {
28965
- this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cutoutGeom);
29039
+ this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, cutoutGeom);
28966
29040
  }
28967
29041
  }
28968
29042
  processCopperPour(pour) {
@@ -28970,22 +29044,22 @@ var BoardGeomBuilder = class {
28970
29044
  const zPos = layerSign * this.ctx.pcbThickness / 2 + layerSign * BOARD_SURFACE_OFFSET.copper;
28971
29045
  let pourGeom = null;
28972
29046
  if (pour.shape === "rect") {
28973
- let baseGeom = (0, import_primitives7.cuboid)({
29047
+ let baseGeom = (0, import_primitives8.cuboid)({
28974
29048
  center: [0, 0, 0],
28975
29049
  // Create at origin for rotation
28976
29050
  size: [pour.width, pour.height, M]
28977
29051
  });
28978
29052
  if ("rotation" in pour && pour.rotation) {
28979
29053
  const rotationRadians = pour.rotation * Math.PI / 180;
28980
- baseGeom = (0, import_transforms5.rotateZ)(rotationRadians, baseGeom);
29054
+ baseGeom = (0, import_transforms6.rotateZ)(rotationRadians, baseGeom);
28981
29055
  }
28982
- pourGeom = (0, import_transforms5.translate)([pour.center.x, pour.center.y, zPos], baseGeom);
29056
+ pourGeom = (0, import_transforms6.translate)([pour.center.x, pour.center.y, zPos], baseGeom);
28983
29057
  } else if (pour.shape === "brep") {
28984
29058
  const brepShape = pour.brep_shape;
28985
29059
  if (brepShape && brepShape.outer_ring) {
28986
29060
  const pourGeom2 = createGeom2FromBRep(brepShape);
28987
- pourGeom = (0, import_extrusions5.extrudeLinear)({ height: M }, pourGeom2);
28988
- pourGeom = (0, import_transforms5.translate)([0, 0, zPos], pourGeom);
29061
+ pourGeom = (0, import_extrusions6.extrudeLinear)({ height: M }, pourGeom2);
29062
+ pourGeom = (0, import_transforms6.translate)([0, 0, zPos], pourGeom);
28989
29063
  }
28990
29064
  } else if (pour.shape === "polygon") {
28991
29065
  let pointsVec2 = pour.points.map((p) => [p.x, p.y]);
@@ -28998,15 +29072,15 @@ var BoardGeomBuilder = class {
28998
29072
  if (arePointsClockwise(pointsVec2)) {
28999
29073
  pointsVec2 = pointsVec2.reverse();
29000
29074
  }
29001
- const polygon2d = (0, import_primitives7.polygon)({ points: pointsVec2 });
29002
- pourGeom = (0, import_extrusions5.extrudeLinear)({ height: M }, polygon2d);
29003
- pourGeom = (0, import_transforms5.translate)([0, 0, zPos], pourGeom);
29075
+ const polygon2d = (0, import_primitives8.polygon)({ points: pointsVec2 });
29076
+ pourGeom = (0, import_extrusions6.extrudeLinear)({ height: M }, polygon2d);
29077
+ pourGeom = (0, import_transforms6.translate)([0, 0, zPos], pourGeom);
29004
29078
  }
29005
29079
  if (pourGeom) {
29006
29080
  if (this.boardClipGeom) {
29007
- pourGeom = (0, import_booleans3.intersect)(this.boardClipGeom, pourGeom);
29081
+ pourGeom = (0, import_booleans4.intersect)(this.boardClipGeom, pourGeom);
29008
29082
  }
29009
- const coloredPourGeom = (0, import_colors5.colorize)(colors.copper, pourGeom);
29083
+ const coloredPourGeom = (0, import_colors6.colorize)(colors.copper, pourGeom);
29010
29084
  this.copperPourGeoms.push(coloredPourGeom);
29011
29085
  }
29012
29086
  }
@@ -29015,7 +29089,7 @@ var BoardGeomBuilder = class {
29015
29089
  if (ph.shape === "circle" || ph.shape === "circular_hole_with_rect_pad") {
29016
29090
  let cyGeom = null;
29017
29091
  if (ph.shape === "circular_hole_with_rect_pad") {
29018
- cyGeom = (0, import_primitives7.cylinder)({
29092
+ cyGeom = (0, import_primitives8.cylinder)({
29019
29093
  center: [
29020
29094
  ph.x + (ph.hole_offset_x || 0),
29021
29095
  ph.y + (ph.hole_offset_y || 0),
@@ -29027,7 +29101,7 @@ var BoardGeomBuilder = class {
29027
29101
  // Ensure it cuts through
29028
29102
  });
29029
29103
  } else {
29030
- cyGeom = (0, import_primitives7.cylinder)({
29104
+ cyGeom = (0, import_primitives8.cylinder)({
29031
29105
  center: [ph.x, ph.y, 0],
29032
29106
  radius: ph.hole_diameter / 2 + M,
29033
29107
  // Add margin for subtraction
@@ -29036,10 +29110,10 @@ var BoardGeomBuilder = class {
29036
29110
  });
29037
29111
  }
29038
29112
  if (!opts.dontCutBoard) {
29039
- this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cyGeom);
29113
+ this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, cyGeom);
29040
29114
  }
29041
29115
  this.padGeoms = this.padGeoms.map(
29042
- (pg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, cyGeom))
29116
+ (pg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, cyGeom))
29043
29117
  );
29044
29118
  const platedHoleGeom = platedHole(ph, this.ctx, {
29045
29119
  clipGeom: this.boardClipGeom
@@ -29053,8 +29127,8 @@ var BoardGeomBuilder = class {
29053
29127
  const rectLength = Math.abs(holeWidth - holeHeight);
29054
29128
  let pillHole;
29055
29129
  if (ph.shape === "pill_hole_with_rect_pad") {
29056
- pillHole = (0, import_booleans3.union)(
29057
- (0, import_primitives7.cuboid)({
29130
+ pillHole = (0, import_booleans4.union)(
29131
+ (0, import_primitives8.cuboid)({
29058
29132
  center: [
29059
29133
  ph.x + (ph.hole_offset_x || 0),
29060
29134
  ph.y + (ph.hole_offset_y || 0),
@@ -29062,7 +29136,7 @@ var BoardGeomBuilder = class {
29062
29136
  ],
29063
29137
  size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
29064
29138
  }),
29065
- (0, import_primitives7.cylinder)({
29139
+ (0, import_primitives8.cylinder)({
29066
29140
  center: shouldRotate ? [
29067
29141
  ph.x + (ph.hole_offset_x || 0),
29068
29142
  ph.y + (ph.hole_offset_y || 0) - rectLength / 2,
@@ -29075,7 +29149,7 @@ var BoardGeomBuilder = class {
29075
29149
  radius: holeRadius,
29076
29150
  height: this.ctx.pcbThickness * 1.5
29077
29151
  }),
29078
- (0, import_primitives7.cylinder)({
29152
+ (0, import_primitives8.cylinder)({
29079
29153
  center: shouldRotate ? [
29080
29154
  ph.x + (ph.hole_offset_x || 0),
29081
29155
  ph.y + (ph.hole_offset_y || 0) + rectLength / 2,
@@ -29090,17 +29164,17 @@ var BoardGeomBuilder = class {
29090
29164
  })
29091
29165
  );
29092
29166
  } else {
29093
- pillHole = (0, import_booleans3.union)(
29094
- (0, import_primitives7.cuboid)({
29167
+ pillHole = (0, import_booleans4.union)(
29168
+ (0, import_primitives8.cuboid)({
29095
29169
  center: [ph.x, ph.y, 0],
29096
29170
  size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
29097
29171
  }),
29098
- (0, import_primitives7.cylinder)({
29172
+ (0, import_primitives8.cylinder)({
29099
29173
  center: shouldRotate ? [ph.x, ph.y - rectLength / 2, 0] : [ph.x - rectLength / 2, ph.y, 0],
29100
29174
  radius: holeRadius,
29101
29175
  height: this.ctx.pcbThickness * 1.5
29102
29176
  }),
29103
- (0, import_primitives7.cylinder)({
29177
+ (0, import_primitives8.cylinder)({
29104
29178
  center: shouldRotate ? [ph.x, ph.y + rectLength / 2, 0] : [ph.x + rectLength / 2, ph.y, 0],
29105
29179
  radius: holeRadius,
29106
29180
  height: this.ctx.pcbThickness * 1.5
@@ -29108,10 +29182,10 @@ var BoardGeomBuilder = class {
29108
29182
  );
29109
29183
  }
29110
29184
  if (!opts.dontCutBoard) {
29111
- this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
29185
+ this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, pillHole);
29112
29186
  }
29113
29187
  this.padGeoms = this.padGeoms.map(
29114
- (pg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, pillHole))
29188
+ (pg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, pillHole))
29115
29189
  );
29116
29190
  const platedHoleGeom = platedHole(ph, this.ctx, {
29117
29191
  clipGeom: this.boardClipGeom
@@ -29124,22 +29198,22 @@ var BoardGeomBuilder = class {
29124
29198
  const holeDepth = this.ctx.pcbThickness * 1.5;
29125
29199
  const copperInset = 0.02;
29126
29200
  if (hole.hole_shape === "round" || hole.hole_shape === "circle") {
29127
- const cyGeom = (0, import_primitives7.cylinder)({
29201
+ const cyGeom = (0, import_primitives8.cylinder)({
29128
29202
  center: [hole.x, hole.y, 0],
29129
29203
  radius: hole.hole_diameter / 2 + M,
29130
29204
  height: holeDepth
29131
29205
  });
29132
- this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cyGeom);
29206
+ this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, cyGeom);
29133
29207
  this.padGeoms = this.padGeoms.map(
29134
- (pg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, cyGeom))
29208
+ (pg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, cyGeom))
29135
29209
  );
29136
- const copperCut = (0, import_primitives7.cylinder)({
29210
+ const copperCut = (0, import_primitives8.cylinder)({
29137
29211
  center: [hole.x, hole.y, 0],
29138
29212
  radius: hole.hole_diameter / 2 + M / 2,
29139
29213
  height: holeDepth
29140
29214
  });
29141
29215
  this.platedHoleGeoms = this.platedHoleGeoms.map(
29142
- (phg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(phg, copperCut))
29216
+ (phg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(phg, copperCut))
29143
29217
  );
29144
29218
  } else if (hole.hole_shape === "pill" || hole.hole_shape === "rotated_pill") {
29145
29219
  const holeWidth = hole.hole_width;
@@ -29149,34 +29223,34 @@ var BoardGeomBuilder = class {
29149
29223
  const isRotated = hole.hole_shape === "rotated_pill";
29150
29224
  let pillHole;
29151
29225
  if (holeWidth > holeHeight) {
29152
- pillHole = (0, import_booleans3.union)(
29153
- (0, import_primitives7.cuboid)({
29226
+ pillHole = (0, import_booleans4.union)(
29227
+ (0, import_primitives8.cuboid)({
29154
29228
  center: [hole.x, hole.y, 0],
29155
29229
  size: [rectLength, holeHeight, holeDepth]
29156
29230
  }),
29157
- (0, import_primitives7.cylinder)({
29231
+ (0, import_primitives8.cylinder)({
29158
29232
  center: [hole.x - rectLength / 2, hole.y, 0],
29159
29233
  radius: holeRadius,
29160
29234
  height: holeDepth
29161
29235
  }),
29162
- (0, import_primitives7.cylinder)({
29236
+ (0, import_primitives8.cylinder)({
29163
29237
  center: [hole.x + rectLength / 2, hole.y, 0],
29164
29238
  radius: holeRadius,
29165
29239
  height: holeDepth
29166
29240
  })
29167
29241
  );
29168
29242
  } else {
29169
- pillHole = (0, import_booleans3.union)(
29170
- (0, import_primitives7.cuboid)({
29243
+ pillHole = (0, import_booleans4.union)(
29244
+ (0, import_primitives8.cuboid)({
29171
29245
  center: [hole.x, hole.y, 0],
29172
29246
  size: [holeWidth, rectLength, holeDepth]
29173
29247
  }),
29174
- (0, import_primitives7.cylinder)({
29248
+ (0, import_primitives8.cylinder)({
29175
29249
  center: [hole.x, hole.y - rectLength / 2, 0],
29176
29250
  radius: holeRadius,
29177
29251
  height: holeDepth
29178
29252
  }),
29179
- (0, import_primitives7.cylinder)({
29253
+ (0, import_primitives8.cylinder)({
29180
29254
  center: [hole.x, hole.y + rectLength / 2, 0],
29181
29255
  radius: holeRadius,
29182
29256
  height: holeDepth
@@ -29185,15 +29259,15 @@ var BoardGeomBuilder = class {
29185
29259
  }
29186
29260
  if (isRotated) {
29187
29261
  const rotationRadians = hole.ccw_rotation * Math.PI / 180;
29188
- pillHole = (0, import_transforms5.rotateZ)(rotationRadians, pillHole);
29262
+ pillHole = (0, import_transforms6.rotateZ)(rotationRadians, pillHole);
29189
29263
  }
29190
- this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
29264
+ this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, pillHole);
29191
29265
  this.padGeoms = this.padGeoms.map(
29192
- (pg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, pillHole))
29266
+ (pg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, pillHole))
29193
29267
  );
29194
29268
  const copperPill = (0, import_expansions4.expand)({ delta: -copperInset }, pillHole);
29195
29269
  this.platedHoleGeoms = this.platedHoleGeoms.map(
29196
- (phg) => (0, import_colors5.colorize)(colors.copper, (0, import_booleans3.subtract)(phg, copperPill))
29270
+ (phg) => (0, import_colors6.colorize)(colors.copper, (0, import_booleans4.subtract)(phg, copperPill))
29197
29271
  );
29198
29272
  }
29199
29273
  }
@@ -29208,12 +29282,12 @@ var BoardGeomBuilder = class {
29208
29282
  M,
29209
29283
  rectBorderRadius
29210
29284
  );
29211
- const positionedPadGeom = (0, import_transforms5.translate)([pad2.x, pad2.y, zPos], basePadGeom);
29285
+ const positionedPadGeom = (0, import_transforms6.translate)([pad2.x, pad2.y, zPos], basePadGeom);
29212
29286
  let finalPadGeom = positionedPadGeom;
29213
29287
  if (this.boardClipGeom) {
29214
- finalPadGeom = (0, import_booleans3.intersect)(this.boardClipGeom, finalPadGeom);
29288
+ finalPadGeom = (0, import_booleans4.intersect)(this.boardClipGeom, finalPadGeom);
29215
29289
  }
29216
- finalPadGeom = (0, import_colors5.colorize)(colors.copper, finalPadGeom);
29290
+ finalPadGeom = (0, import_colors6.colorize)(colors.copper, finalPadGeom);
29217
29291
  this.padGeoms.push(finalPadGeom);
29218
29292
  } else if (pad2.shape === "rotated_rect") {
29219
29293
  let basePadGeom = createCenteredRectPadGeom(
@@ -29223,24 +29297,24 @@ var BoardGeomBuilder = class {
29223
29297
  rectBorderRadius
29224
29298
  );
29225
29299
  const rotationRadians = pad2.ccw_rotation * Math.PI / 180;
29226
- basePadGeom = (0, import_transforms5.rotateZ)(rotationRadians, basePadGeom);
29227
- const positionedPadGeom = (0, import_transforms5.translate)([pad2.x, pad2.y, zPos], basePadGeom);
29300
+ basePadGeom = (0, import_transforms6.rotateZ)(rotationRadians, basePadGeom);
29301
+ const positionedPadGeom = (0, import_transforms6.translate)([pad2.x, pad2.y, zPos], basePadGeom);
29228
29302
  let finalPadGeom = positionedPadGeom;
29229
29303
  if (this.boardClipGeom) {
29230
- finalPadGeom = (0, import_booleans3.intersect)(this.boardClipGeom, finalPadGeom);
29304
+ finalPadGeom = (0, import_booleans4.intersect)(this.boardClipGeom, finalPadGeom);
29231
29305
  }
29232
- finalPadGeom = (0, import_colors5.colorize)(colors.copper, finalPadGeom);
29306
+ finalPadGeom = (0, import_colors6.colorize)(colors.copper, finalPadGeom);
29233
29307
  this.padGeoms.push(finalPadGeom);
29234
29308
  } else if (pad2.shape === "circle") {
29235
- let padGeom = (0, import_primitives7.cylinder)({
29309
+ let padGeom = (0, import_primitives8.cylinder)({
29236
29310
  center: [pad2.x, pad2.y, zPos],
29237
29311
  radius: pad2.radius,
29238
29312
  height: M
29239
29313
  });
29240
29314
  if (this.boardClipGeom) {
29241
- padGeom = (0, import_booleans3.intersect)(this.boardClipGeom, padGeom);
29315
+ padGeom = (0, import_booleans4.intersect)(this.boardClipGeom, padGeom);
29242
29316
  }
29243
- padGeom = (0, import_colors5.colorize)(colors.copper, padGeom);
29317
+ padGeom = (0, import_colors6.colorize)(colors.copper, padGeom);
29244
29318
  this.padGeoms.push(padGeom);
29245
29319
  }
29246
29320
  }
@@ -29254,14 +29328,14 @@ var BoardGeomBuilder = class {
29254
29328
  if (currentSegmentPoints.length >= 2 && currentLayer) {
29255
29329
  const layerSign = currentLayer === "bottom" ? -1 : 1;
29256
29330
  const zCenter = layerSign * this.ctx.pcbThickness / 2 + layerSign * BOARD_SURFACE_OFFSET.traces;
29257
- const linePath = (0, import_primitives7.line)(currentSegmentPoints);
29331
+ const linePath = (0, import_primitives8.line)(currentSegmentPoints);
29258
29332
  const expandedPath = (0, import_expansions4.expand)(
29259
29333
  { delta: currentWidth / 2, corners: "round" },
29260
29334
  linePath
29261
29335
  );
29262
- let traceGeom = (0, import_transforms5.translate)(
29336
+ let traceGeom = (0, import_transforms6.translate)(
29263
29337
  [0, 0, zCenter - M / 2],
29264
- (0, import_extrusions5.extrudeLinear)({ height: M }, expandedPath)
29338
+ (0, import_extrusions6.extrudeLinear)({ height: M }, expandedPath)
29265
29339
  );
29266
29340
  const startPointCoords = currentSegmentPoints[0];
29267
29341
  const endPointCoords = currentSegmentPoints[currentSegmentPoints.length - 1];
@@ -29270,27 +29344,27 @@ var BoardGeomBuilder = class {
29270
29344
  startPointCoords[1]
29271
29345
  );
29272
29346
  if (startHole) {
29273
- const cuttingCylinder = (0, import_primitives7.cylinder)({
29347
+ const cuttingCylinder = (0, import_primitives8.cylinder)({
29274
29348
  center: [startPointCoords[0], startPointCoords[1], zCenter],
29275
29349
  radius: startHole.diameter / 2 + M,
29276
29350
  height: M
29277
29351
  });
29278
- traceGeom = (0, import_booleans3.subtract)(traceGeom, cuttingCylinder);
29352
+ traceGeom = (0, import_booleans4.subtract)(traceGeom, cuttingCylinder);
29279
29353
  }
29280
29354
  const endHole = this.getHoleToCut(endPointCoords[0], endPointCoords[1]);
29281
29355
  if (endHole) {
29282
- const cuttingCylinder = (0, import_primitives7.cylinder)({
29356
+ const cuttingCylinder = (0, import_primitives8.cylinder)({
29283
29357
  center: [endPointCoords[0], endPointCoords[1], zCenter],
29284
29358
  radius: endHole.diameter / 2 + M,
29285
29359
  height: M
29286
29360
  });
29287
- traceGeom = (0, import_booleans3.subtract)(traceGeom, cuttingCylinder);
29361
+ traceGeom = (0, import_booleans4.subtract)(traceGeom, cuttingCylinder);
29288
29362
  }
29289
29363
  const tracesMaterialColor = tracesMaterialColors[this.board.material] ?? colors.fr4GreenSolderWithMask;
29290
29364
  if (this.boardClipGeom) {
29291
- traceGeom = (0, import_booleans3.intersect)(this.boardClipGeom, traceGeom);
29365
+ traceGeom = (0, import_booleans4.intersect)(this.boardClipGeom, traceGeom);
29292
29366
  }
29293
- traceGeom = (0, import_colors5.colorize)(tracesMaterialColor, traceGeom);
29367
+ traceGeom = (0, import_colors6.colorize)(tracesMaterialColor, traceGeom);
29294
29368
  this.traceGeoms.push(traceGeom);
29295
29369
  }
29296
29370
  currentSegmentPoints = [];
@@ -29357,7 +29431,7 @@ var BoardGeomBuilder = class {
29357
29431
  point2[0] + xOffset + st.anchor_position.x,
29358
29432
  point2[1] + yOffset + st.anchor_position.y
29359
29433
  ]);
29360
- const textPath = (0, import_primitives7.line)(alignedOutline);
29434
+ const textPath = (0, import_primitives8.line)(alignedOutline);
29361
29435
  const fontSize = st.font_size || 0.25;
29362
29436
  const expansionDelta = Math.min(
29363
29437
  Math.max(0.01, fontSize * 0.1),
@@ -29369,19 +29443,19 @@ var BoardGeomBuilder = class {
29369
29443
  );
29370
29444
  let textGeom;
29371
29445
  if (st.layer === "bottom") {
29372
- textGeom = (0, import_transforms5.translate)(
29446
+ textGeom = (0, import_transforms6.translate)(
29373
29447
  [0, 0, -this.ctx.pcbThickness / 2 - M],
29374
29448
  // Position above board
29375
- (0, import_extrusions5.extrudeLinear)({ height: 0.012 }, expandedPath)
29449
+ (0, import_extrusions6.extrudeLinear)({ height: 0.012 }, expandedPath)
29376
29450
  );
29377
29451
  } else {
29378
- textGeom = (0, import_transforms5.translate)(
29452
+ textGeom = (0, import_transforms6.translate)(
29379
29453
  [0, 0, this.ctx.pcbThickness / 2 + M],
29380
29454
  // Position above board
29381
- (0, import_extrusions5.extrudeLinear)({ height: 0.012 }, expandedPath)
29455
+ (0, import_extrusions6.extrudeLinear)({ height: 0.012 }, expandedPath)
29382
29456
  );
29383
29457
  }
29384
- textGeom = (0, import_colors5.colorize)([1, 1, 1], textGeom);
29458
+ textGeom = (0, import_colors6.colorize)([1, 1, 1], textGeom);
29385
29459
  this.silkscreenTextGeoms.push(textGeom);
29386
29460
  }
29387
29461
  }
@@ -29397,10 +29471,16 @@ var BoardGeomBuilder = class {
29397
29471
  this.silkscreenLineGeoms.push(lineGeom);
29398
29472
  }
29399
29473
  }
29474
+ processSilkscreenRect(sr) {
29475
+ const rectGeom = createSilkscreenRectGeom(sr, this.ctx);
29476
+ if (rectGeom) {
29477
+ this.silkscreenRectGeoms.push(rectGeom);
29478
+ }
29479
+ }
29400
29480
  finalize() {
29401
29481
  if (!this.boardGeom) return;
29402
29482
  const boardMaterialColor = boardMaterialColors[this.board.material] ?? colors.fr4Green;
29403
- this.boardGeom = (0, import_colors5.colorize)(boardMaterialColor, this.boardGeom);
29483
+ this.boardGeom = (0, import_colors6.colorize)(boardMaterialColor, this.boardGeom);
29404
29484
  this.finalGeoms = [
29405
29485
  this.boardGeom,
29406
29486
  ...this.platedHoleGeoms,
@@ -29410,6 +29490,7 @@ var BoardGeomBuilder = class {
29410
29490
  ...this.copperPourGeoms,
29411
29491
  ...this.silkscreenTextGeoms,
29412
29492
  ...this.silkscreenLineGeoms,
29493
+ ...this.silkscreenRectGeoms,
29413
29494
  ...this.silkscreenPathGeoms
29414
29495
  ];
29415
29496
  if (this.onCompleteCallback) {
@@ -29927,10 +30008,12 @@ function createSilkscreenTextureForLayer({
29927
30008
  const pcbSilkscreenTexts = su6(circuitJson).pcb_silkscreen_text.list();
29928
30009
  const pcbSilkscreenPaths = su6(circuitJson).pcb_silkscreen_path.list();
29929
30010
  const pcbSilkscreenLines = su6(circuitJson).pcb_silkscreen_line.list();
30011
+ const pcbSilkscreenRects = su6(circuitJson).pcb_silkscreen_rect.list();
29930
30012
  const textsOnLayer = pcbSilkscreenTexts.filter((t) => t.layer === layer);
29931
30013
  const pathsOnLayer = pcbSilkscreenPaths.filter((p) => p.layer === layer);
29932
30014
  const linesOnLayer = pcbSilkscreenLines.filter((l) => l.layer === layer);
29933
- if (textsOnLayer.length === 0 && pathsOnLayer.length === 0 && linesOnLayer.length === 0) {
30015
+ const rectsOnLayer = pcbSilkscreenRects.filter((r) => r.layer === layer);
30016
+ if (textsOnLayer.length === 0 && pathsOnLayer.length === 0 && linesOnLayer.length === 0 && rectsOnLayer.length === 0) {
29934
30017
  return null;
29935
30018
  }
29936
30019
  const canvas = document.createElement("canvas");
@@ -29975,6 +30058,77 @@ function createSilkscreenTextureForLayer({
29975
30058
  });
29976
30059
  ctx.stroke();
29977
30060
  });
30061
+ rectsOnLayer.forEach((rect) => {
30062
+ const width10 = coerceDimensionToMm(rect.width, 0);
30063
+ const height10 = coerceDimensionToMm(rect.height, 0);
30064
+ if (width10 <= 0 || height10 <= 0) return;
30065
+ const centerXmm = parseDimensionToMm(rect.center?.x) ?? 0;
30066
+ const centerYmm = parseDimensionToMm(rect.center?.y) ?? 0;
30067
+ const canvasCenterX = canvasXFromPcb(centerXmm);
30068
+ const canvasCenterY = canvasYFromPcb(centerYmm);
30069
+ const rawRadius = extractRectBorderRadius(rect);
30070
+ const borderRadiusInput = typeof rawRadius === "string" ? parseDimensionToMm(rawRadius) : rawRadius;
30071
+ const borderRadiusMm = clampRectBorderRadius(
30072
+ width10,
30073
+ height10,
30074
+ borderRadiusInput
30075
+ );
30076
+ ctx.save();
30077
+ ctx.translate(canvasCenterX, canvasCenterY);
30078
+ const halfWidthPx = width10 / 2 * traceTextureResolution;
30079
+ const halfHeightPx = height10 / 2 * traceTextureResolution;
30080
+ const borderRadiusPx = Math.min(
30081
+ borderRadiusMm * traceTextureResolution,
30082
+ halfWidthPx,
30083
+ halfHeightPx
30084
+ );
30085
+ const hasStroke = rect.has_stroke ?? false;
30086
+ const isFilled = rect.is_filled ?? true;
30087
+ const isDashed = rect.is_stroke_dashed ?? false;
30088
+ const strokeWidthPx = hasStroke ? coerceDimensionToMm(rect.stroke_width, 0.1) * traceTextureResolution : 0;
30089
+ const drawRoundedRectPath = (x, y, rectWidth, rectHeight, radius) => {
30090
+ ctx.beginPath();
30091
+ if (radius <= 0) {
30092
+ ctx.rect(x, y, rectWidth, rectHeight);
30093
+ } else {
30094
+ const r = radius;
30095
+ const right = x + rectWidth;
30096
+ const bottom = y + rectHeight;
30097
+ ctx.moveTo(x + r, y);
30098
+ ctx.lineTo(right - r, y);
30099
+ ctx.quadraticCurveTo(right, y, right, y + r);
30100
+ ctx.lineTo(right, bottom - r);
30101
+ ctx.quadraticCurveTo(right, bottom, right - r, bottom);
30102
+ ctx.lineTo(x + r, bottom);
30103
+ ctx.quadraticCurveTo(x, bottom, x, bottom - r);
30104
+ ctx.lineTo(x, y + r);
30105
+ ctx.quadraticCurveTo(x, y, x + r, y);
30106
+ ctx.closePath();
30107
+ }
30108
+ };
30109
+ drawRoundedRectPath(
30110
+ -halfWidthPx,
30111
+ -halfHeightPx,
30112
+ halfWidthPx * 2,
30113
+ halfHeightPx * 2,
30114
+ borderRadiusPx
30115
+ );
30116
+ if (isFilled) {
30117
+ ctx.fill();
30118
+ }
30119
+ if (hasStroke && strokeWidthPx > 0) {
30120
+ ctx.lineWidth = strokeWidthPx;
30121
+ if (isDashed) {
30122
+ const dashLength = Math.max(strokeWidthPx * 2, 1);
30123
+ ctx.setLineDash([dashLength, dashLength]);
30124
+ }
30125
+ ctx.stroke();
30126
+ if (isDashed) {
30127
+ ctx.setLineDash([]);
30128
+ }
30129
+ }
30130
+ ctx.restore();
30131
+ });
29978
30132
  textsOnLayer.forEach((textS) => {
29979
30133
  const fontSize = textS.font_size || 0.25;
29980
30134
  const textStrokeWidth = Math.min(Math.max(0.01, fontSize * 0.1), fontSize * 0.05) * traceTextureResolution;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.423",
3
+ "version": "0.0.424",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",