@tscircuit/3d-viewer 0.0.475 → 0.0.477

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 +248 -167
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -805,13 +805,13 @@ var require_cross = __commonJS({
805
805
  var require_distance = __commonJS({
806
806
  "node_modules/@jscad/modeling/src/maths/vec3/distance.js"(exports, module) {
807
807
  "use strict";
808
- var distance2 = (a, b) => {
808
+ var distance3 = (a, b) => {
809
809
  const x = b[0] - a[0];
810
810
  const y = b[1] - a[1];
811
811
  const z138 = b[2] - a[2];
812
812
  return Math.sqrt(x * x + y * y + z138 * z138);
813
813
  };
814
- module.exports = distance2;
814
+ module.exports = distance3;
815
815
  }
816
816
  });
817
817
 
@@ -1933,12 +1933,12 @@ var require_cross2 = __commonJS({
1933
1933
  var require_distance2 = __commonJS({
1934
1934
  "node_modules/@jscad/modeling/src/maths/vec2/distance.js"(exports, module) {
1935
1935
  "use strict";
1936
- var distance2 = (a, b) => {
1936
+ var distance3 = (a, b) => {
1937
1937
  const x = b[0] - a[0];
1938
1938
  const y = b[1] - a[1];
1939
1939
  return Math.sqrt(x * x + y * y);
1940
1940
  };
1941
- module.exports = distance2;
1941
+ module.exports = distance3;
1942
1942
  }
1943
1943
  });
1944
1944
 
@@ -2861,7 +2861,7 @@ var require_Vertex = __commonJS({
2861
2861
  var require_HalfEdge = __commonJS({
2862
2862
  "node_modules/@jscad/modeling/src/operations/hulls/quickhull/HalfEdge.js"(exports, module) {
2863
2863
  "use strict";
2864
- var distance2 = require_distance();
2864
+ var distance3 = require_distance();
2865
2865
  var squaredDistance = require_squaredDistance();
2866
2866
  var HalfEdge = class {
2867
2867
  constructor(vertex, face) {
@@ -2879,7 +2879,7 @@ var require_HalfEdge = __commonJS({
2879
2879
  }
2880
2880
  length() {
2881
2881
  if (this.tail()) {
2882
- return distance2(
2882
+ return distance3(
2883
2883
  this.tail().point,
2884
2884
  this.head().point
2885
2885
  );
@@ -3216,8 +3216,8 @@ var require_QuickHull = __commonJS({
3216
3216
  let nextVertex;
3217
3217
  for (let vertex = faceVertices; vertex; vertex = nextVertex) {
3218
3218
  nextVertex = vertex.next;
3219
- const distance2 = absorbingFace.distanceToPlane(vertex.point);
3220
- if (distance2 > this.tolerance) {
3219
+ const distance3 = absorbingFace.distanceToPlane(vertex.point);
3220
+ if (distance3 > this.tolerance) {
3221
3221
  this.addVertexToFace(vertex, absorbingFace);
3222
3222
  } else {
3223
3223
  this.unclaimed.add(vertex);
@@ -3304,9 +3304,9 @@ var require_QuickHull = __commonJS({
3304
3304
  let maxDistance = 0;
3305
3305
  let indexMax = 0;
3306
3306
  for (i = 0; i < 3; i += 1) {
3307
- const distance2 = max2[i].point[i] - min2[i].point[i];
3308
- if (distance2 > maxDistance) {
3309
- maxDistance = distance2;
3307
+ const distance3 = max2[i].point[i] - min2[i].point[i];
3308
+ if (distance3 > maxDistance) {
3309
+ maxDistance = distance3;
3310
3310
  indexMax = i;
3311
3311
  }
3312
3312
  }
@@ -3316,13 +3316,13 @@ var require_QuickHull = __commonJS({
3316
3316
  for (i = 0; i < this.vertices.length; i += 1) {
3317
3317
  const vertex = this.vertices[i];
3318
3318
  if (vertex !== v0 && vertex !== v1) {
3319
- const distance2 = pointLineDistance(
3319
+ const distance3 = pointLineDistance(
3320
3320
  vertex.point,
3321
3321
  v0.point,
3322
3322
  v1.point
3323
3323
  );
3324
- if (distance2 > maxDistance) {
3325
- maxDistance = distance2;
3324
+ if (distance3 > maxDistance) {
3325
+ maxDistance = distance3;
3326
3326
  v2 = vertex;
3327
3327
  }
3328
3328
  }
@@ -3333,9 +3333,9 @@ var require_QuickHull = __commonJS({
3333
3333
  for (i = 0; i < this.vertices.length; i += 1) {
3334
3334
  const vertex = this.vertices[i];
3335
3335
  if (vertex !== v0 && vertex !== v1 && vertex !== v2) {
3336
- const distance2 = Math.abs(dot(normal, vertex.point) - distPO);
3337
- if (distance2 > maxDistance) {
3338
- maxDistance = distance2;
3336
+ const distance3 = Math.abs(dot(normal, vertex.point) - distPO);
3337
+ if (distance3 > maxDistance) {
3338
+ maxDistance = distance3;
3339
3339
  v3 = vertex;
3340
3340
  }
3341
3341
  }
@@ -3375,9 +3375,9 @@ var require_QuickHull = __commonJS({
3375
3375
  maxDistance = this.tolerance;
3376
3376
  let maxFace;
3377
3377
  for (j = 0; j < 4; j += 1) {
3378
- const distance2 = faces[j].distanceToPlane(vertex.point);
3379
- if (distance2 > maxDistance) {
3380
- maxDistance = distance2;
3378
+ const distance3 = faces[j].distanceToPlane(vertex.point);
3379
+ if (distance3 > maxDistance) {
3380
+ maxDistance = distance3;
3381
3381
  maxFace = faces[j];
3382
3382
  }
3383
3383
  }
@@ -3433,9 +3433,9 @@ var require_QuickHull = __commonJS({
3433
3433
  let maxDistance = 0;
3434
3434
  const eyeFace = this.claimed.first().face;
3435
3435
  for (vertex = eyeFace.outside; vertex && vertex.face === eyeFace; vertex = vertex.next) {
3436
- const distance2 = eyeFace.distanceToPlane(vertex.point);
3437
- if (distance2 > maxDistance) {
3438
- maxDistance = distance2;
3436
+ const distance3 = eyeFace.distanceToPlane(vertex.point);
3437
+ if (distance3 > maxDistance) {
3438
+ maxDistance = distance3;
3439
3439
  eyeVertex = vertex;
3440
3440
  }
3441
3441
  }
@@ -6069,13 +6069,13 @@ var require_arcLengthToT = __commonJS({
6069
6069
  distance: 0,
6070
6070
  segments: 100
6071
6071
  };
6072
- const { distance: distance2, segments } = Object.assign({}, defaults, options);
6072
+ const { distance: distance3, segments } = Object.assign({}, defaults, options);
6073
6073
  const arcLengths = lengths(segments, bezier);
6074
6074
  let startIndex = 0;
6075
6075
  let endIndex = segments;
6076
6076
  while (startIndex <= endIndex) {
6077
6077
  const middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
6078
- const diff = arcLengths[middleIndex] - distance2;
6078
+ const diff = arcLengths[middleIndex] - distance3;
6079
6079
  if (diff < 0) {
6080
6080
  startIndex = middleIndex + 1;
6081
6081
  } else if (diff > 0) {
@@ -6086,13 +6086,13 @@ var require_arcLengthToT = __commonJS({
6086
6086
  }
6087
6087
  }
6088
6088
  const targetIndex = endIndex;
6089
- if (arcLengths[targetIndex] === distance2) {
6089
+ if (arcLengths[targetIndex] === distance3) {
6090
6090
  return targetIndex / segments;
6091
6091
  }
6092
6092
  const lengthBefore = arcLengths[targetIndex];
6093
6093
  const lengthAfter = arcLengths[targetIndex + 1];
6094
6094
  const segmentLength = lengthAfter - lengthBefore;
6095
- const segmentFraction = (distance2 - lengthBefore) / segmentLength;
6095
+ const segmentFraction = (distance3 - lengthBefore) / segmentLength;
6096
6096
  return (targetIndex + segmentFraction) / segments;
6097
6097
  };
6098
6098
  module.exports = arcLengthToT;
@@ -6342,9 +6342,9 @@ var require_distanceToPoint = __commonJS({
6342
6342
  "use strict";
6343
6343
  var vec2 = require_vec2();
6344
6344
  var distanceToPoint = (line2, point2) => {
6345
- let distance2 = vec2.dot(point2, line2);
6346
- distance2 = Math.abs(distance2 - line2[2]);
6347
- return distance2;
6345
+ let distance3 = vec2.dot(point2, line2);
6346
+ distance3 = Math.abs(distance3 - line2[2]);
6347
+ return distance3;
6348
6348
  };
6349
6349
  module.exports = distanceToPoint;
6350
6350
  }
@@ -6368,10 +6368,10 @@ var require_fromPoints6 = __commonJS({
6368
6368
  const vector = vec2.subtract(vec2.create(), point2, point1);
6369
6369
  vec2.normal(vector, vector);
6370
6370
  vec2.normalize(vector, vector);
6371
- const distance2 = vec2.dot(point1, vector);
6371
+ const distance3 = vec2.dot(point1, vector);
6372
6372
  out[0] = vector[0];
6373
6373
  out[1] = vector[1];
6374
- out[2] = distance2;
6374
+ out[2] = distance3;
6375
6375
  return out;
6376
6376
  };
6377
6377
  module.exports = fromPoints;
@@ -6513,8 +6513,8 @@ var require_reverse3 = __commonJS({
6513
6513
  var fromValues = require_fromValues5();
6514
6514
  var reverse = (out, line2) => {
6515
6515
  const normal = vec2.negate(vec2.create(), line2);
6516
- const distance2 = -line2[2];
6517
- return copy(out, fromValues(normal[0], normal[1], distance2));
6516
+ const distance3 = -line2[2];
6517
+ return copy(out, fromValues(normal[0], normal[1], distance3));
6518
6518
  };
6519
6519
  module.exports = reverse;
6520
6520
  }
@@ -7862,7 +7862,7 @@ var require_polyhedron = __commonJS({
7862
7862
  colors: void 0,
7863
7863
  orientation: "outward"
7864
7864
  };
7865
- const { points, faces, colors: colors2, orientation } = Object.assign({}, defaults, options);
7865
+ const { points, faces, colors: colors2, orientation: orientation2 } = Object.assign({}, defaults, options);
7866
7866
  if (!(Array.isArray(points) && Array.isArray(faces))) {
7867
7867
  throw new Error("points and faces must be arrays");
7868
7868
  }
@@ -7887,7 +7887,7 @@ var require_polyhedron = __commonJS({
7887
7887
  if (face.length < 3) throw new Error(`face ${i} must contain 3 or more indexes`);
7888
7888
  if (!isNumberArray(face, face.length)) throw new Error(`face ${i} must be an array of numbers`);
7889
7889
  });
7890
- if (orientation !== "outward") {
7890
+ if (orientation2 !== "outward") {
7891
7891
  faces.forEach((face) => face.reverse());
7892
7892
  }
7893
7893
  const polygons = faces.map((face, findex) => {
@@ -8052,7 +8052,7 @@ var require_polygon = __commonJS({
8052
8052
  paths: [],
8053
8053
  orientation: "counterclockwise"
8054
8054
  };
8055
- const { points, paths, orientation } = Object.assign({}, defaults, options);
8055
+ const { points, paths, orientation: orientation2 } = Object.assign({}, defaults, options);
8056
8056
  if (!(Array.isArray(points) && Array.isArray(paths))) throw new Error("points and paths must be arrays");
8057
8057
  let listofpolys = points;
8058
8058
  if (Array.isArray(points[0])) {
@@ -8082,7 +8082,7 @@ var require_polygon = __commonJS({
8082
8082
  sides2 = sides2.concat(geom2.toSides(geometry2));
8083
8083
  });
8084
8084
  let geometry = geom2.create(sides2);
8085
- if (orientation === "clockwise") {
8085
+ if (orientation2 === "clockwise") {
8086
8086
  geometry = geom2.reverse(geometry);
8087
8087
  }
8088
8088
  return geometry;
@@ -8597,16 +8597,16 @@ var require_calculatePlane = __commonJS({
8597
8597
  var calculatePlane = (slice) => {
8598
8598
  const edges = slice.edges;
8599
8599
  if (edges.length < 3) throw new Error("slices must have 3 or more edges to calculate a plane");
8600
- const midpoint = edges.reduce((point2, edge) => vec3.add(vec3.create(), point2, edge[0]), vec3.create());
8601
- vec3.scale(midpoint, midpoint, 1 / edges.length);
8600
+ const midpoint2 = edges.reduce((point2, edge) => vec3.add(vec3.create(), point2, edge[0]), vec3.create());
8601
+ vec3.scale(midpoint2, midpoint2, 1 / edges.length);
8602
8602
  let farthestEdge;
8603
- let distance2 = 0;
8603
+ let distance3 = 0;
8604
8604
  edges.forEach((edge) => {
8605
8605
  if (!vec3.equals(edge[0], edge[1])) {
8606
- const d = vec3.squaredDistance(midpoint, edge[0]);
8607
- if (d > distance2) {
8606
+ const d = vec3.squaredDistance(midpoint2, edge[0]);
8607
+ if (d > distance3) {
8608
8608
  farthestEdge = edge;
8609
- distance2 = d;
8609
+ distance3 = d;
8610
8610
  }
8611
8611
  }
8612
8612
  });
@@ -8969,13 +8969,13 @@ var require_linkedPolygon = __commonJS({
8969
8969
  const o3 = Math.sign(area(p2, q2, p1));
8970
8970
  const o4 = Math.sign(area(p2, q2, q1));
8971
8971
  if (o1 !== o2 && o3 !== o4) return true;
8972
- if (o1 === 0 && onSegment(p1, p2, q1)) return true;
8973
- if (o2 === 0 && onSegment(p1, q2, q1)) return true;
8974
- if (o3 === 0 && onSegment(p2, p1, q2)) return true;
8975
- if (o4 === 0 && onSegment(p2, q1, q2)) return true;
8972
+ if (o1 === 0 && onSegment2(p1, p2, q1)) return true;
8973
+ if (o2 === 0 && onSegment2(p1, q2, q1)) return true;
8974
+ if (o3 === 0 && onSegment2(p2, p1, q2)) return true;
8975
+ if (o4 === 0 && onSegment2(p2, q1, q2)) return true;
8976
8976
  return false;
8977
8977
  };
8978
- var onSegment = (p, q, r) => q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
8978
+ var onSegment2 = (p, q, r) => q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
8979
8979
  var signedArea = (data, start, end, dim) => {
8980
8980
  let sum = 0;
8981
8981
  for (let i = start, j = end - dim; i < end; i += dim) {
@@ -9454,9 +9454,9 @@ var require_repair = __commonJS({
9454
9454
  let bestReplacement;
9455
9455
  missingOut.forEach((key2) => {
9456
9456
  const v2 = vertexMap.get(key2);
9457
- const distance2 = vec3.distance(v1, v2);
9458
- if (distance2 < bestDistance) {
9459
- bestDistance = distance2;
9457
+ const distance3 = vec3.distance(v1, v2);
9458
+ if (distance3 < bestDistance) {
9459
+ bestDistance = distance3;
9460
9460
  bestReplacement = v2;
9461
9461
  }
9462
9462
  });
@@ -11802,7 +11802,7 @@ var require_offsetFromPoints = __commonJS({
11802
11802
  if (Math.abs(delta) < EPS) return points;
11803
11803
  let rotation2 = options.closed ? area(points) : 1;
11804
11804
  if (rotation2 === 0) rotation2 = 1;
11805
- const orientation = rotation2 > 0 && delta >= 0 || rotation2 < 0 && delta < 0;
11805
+ const orientation2 = rotation2 > 0 && delta >= 0 || rotation2 < 0 && delta < 0;
11806
11806
  delta = Math.abs(delta);
11807
11807
  let previousSegment = null;
11808
11808
  let newPoints = [];
@@ -11813,7 +11813,7 @@ var require_offsetFromPoints = __commonJS({
11813
11813
  const j = (i + 1) % n;
11814
11814
  const p0 = points[i];
11815
11815
  const p1 = points[j];
11816
- orientation ? vec2.subtract(of, p0, p1) : vec2.subtract(of, p1, p0);
11816
+ orientation2 ? vec2.subtract(of, p0, p1) : vec2.subtract(of, p1, p0);
11817
11817
  vec2.normal(of, of);
11818
11818
  vec2.normalize(of, of);
11819
11819
  vec2.scale(of, of, delta);
@@ -11877,11 +11877,11 @@ var require_offsetFromPoints = __commonJS({
11877
11877
  newCorners.forEach((corner) => {
11878
11878
  let rotation3 = vec2.angle(vec2.subtract(v0, corner.s1[0], corner.c));
11879
11879
  rotation3 -= vec2.angle(vec2.subtract(v0, corner.s0[1], corner.c));
11880
- if (orientation && rotation3 < 0) {
11880
+ if (orientation2 && rotation3 < 0) {
11881
11881
  rotation3 = rotation3 + Math.PI;
11882
11882
  if (rotation3 < 0) rotation3 = rotation3 + Math.PI;
11883
11883
  }
11884
- if (!orientation && rotation3 > 0) {
11884
+ if (!orientation2 && rotation3 > 0) {
11885
11885
  rotation3 = rotation3 - Math.PI;
11886
11886
  if (rotation3 > 0) rotation3 = rotation3 - Math.PI;
11887
11887
  }
@@ -12563,31 +12563,29 @@ var require_extrudeHelical = __commonJS({
12563
12563
  "node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(exports, module) {
12564
12564
  "use strict";
12565
12565
  var { TAU } = require_constants();
12566
- var slice = require_slice();
12567
12566
  var mat4 = require_mat4();
12568
- var extrudeFromSlices = require_extrudeFromSlices();
12569
12567
  var geom2 = require_geom2();
12568
+ var extrudeFromSlices = require_extrudeFromSlices();
12569
+ var slice = require_slice();
12570
12570
  var extrudeHelical = (options, geometry) => {
12571
12571
  const defaults = {
12572
12572
  angle: TAU,
12573
12573
  startAngle: 0,
12574
12574
  pitch: 10,
12575
+ height: 0,
12575
12576
  endOffset: 0,
12576
12577
  segmentsPerRotation: 32
12577
12578
  };
12578
- const { angle, endOffset, segmentsPerRotation, startAngle } = Object.assign({}, defaults, options);
12579
- let pitch;
12580
- if (!options.pitch && options.height) {
12581
- pitch = options.height / (angle / TAU);
12582
- } else {
12583
- pitch = options.pitch ? options.pitch : defaults.pitch;
12579
+ let { angle, startAngle, pitch, height: height10, endOffset, segmentsPerRotation } = Object.assign({}, defaults, options);
12580
+ if (height10 != 0) {
12581
+ pitch = height10 / (angle / TAU);
12584
12582
  }
12585
12583
  const minNumberOfSegments = 3;
12586
12584
  if (segmentsPerRotation < minNumberOfSegments) {
12587
12585
  throw new Error("The number of segments per rotation needs to be at least 3.");
12588
12586
  }
12589
12587
  const shapeSides = geom2.toSides(geometry);
12590
- if (shapeSides.length === 0) throw new Error("the given geometry cannot be empty");
12588
+ if (shapeSides.length === 0) throw new Error("The given geometry cannot be empty");
12591
12589
  const pointsWithPositiveX = shapeSides.filter((s) => s[0][0] >= 0);
12592
12590
  let baseSlice = slice.fromSides(shapeSides);
12593
12591
  if (pointsWithPositiveX.length === 0) {
@@ -12596,7 +12594,7 @@ var require_extrudeHelical = __commonJS({
12596
12594
  const calculatedSegments = Math.round(segmentsPerRotation / TAU * Math.abs(angle));
12597
12595
  const segments = calculatedSegments >= 2 ? calculatedSegments : 2;
12598
12596
  const step1 = mat4.create();
12599
- let matrix;
12597
+ const step2 = mat4.create();
12600
12598
  const sliceCallback = (progress, index2, base) => {
12601
12599
  const zRotation = startAngle + angle / segments * index2;
12602
12600
  const xOffset = endOffset / segments * index2;
@@ -12609,14 +12607,13 @@ var require_extrudeHelical = __commonJS({
12609
12607
  mat4.fromXRotation(mat4.create(), -TAU / 4 * Math.sign(angle))
12610
12608
  // rotate the slice correctly to not create inside-out polygon
12611
12609
  );
12612
- matrix = mat4.create();
12613
12610
  mat4.multiply(
12614
- matrix,
12611
+ step2,
12615
12612
  // finally rotate around Z axis
12616
12613
  mat4.fromZRotation(mat4.create(), zRotation),
12617
12614
  step1
12618
12615
  );
12619
- return slice.transform(matrix, base);
12616
+ return slice.transform(step2, base);
12620
12617
  };
12621
12618
  return extrudeFromSlices(
12622
12619
  {
@@ -12721,8 +12718,8 @@ var require_hullPoints2 = __commonJS({
12721
12718
  const points = [];
12722
12719
  uniquePoints.forEach((point2) => {
12723
12720
  const angle = fakeAtan2(point2[1] - min2[1], point2[0] - min2[0]);
12724
- const distSq = vec2.squaredDistance(point2, min2);
12725
- points.push({ point: point2, angle, distSq });
12721
+ const distSq2 = vec2.squaredDistance(point2, min2);
12722
+ points.push({ point: point2, angle, distSq: distSq2 });
12726
12723
  });
12727
12724
  points.sort((pt1, pt2) => pt1.angle !== pt2.angle ? pt1.angle - pt2.angle : pt1.distSq - pt2.distSq);
12728
12725
  const stack = [];
@@ -13364,11 +13361,11 @@ var require_triangulatePolygons = __commonJS({
13364
13361
  const nv = polygon3.vertices.length;
13365
13362
  if (nv > 3) {
13366
13363
  if (nv > 4) {
13367
- const midpoint = [0, 0, 0];
13368
- polygon3.vertices.forEach((vertice) => vec3.add(midpoint, midpoint, vertice));
13369
- vec3.snap(midpoint, vec3.divide(midpoint, midpoint, [nv, nv, nv]), epsilon);
13364
+ const midpoint2 = [0, 0, 0];
13365
+ polygon3.vertices.forEach((vertice) => vec3.add(midpoint2, midpoint2, vertice));
13366
+ vec3.snap(midpoint2, vec3.divide(midpoint2, midpoint2, [nv, nv, nv]), epsilon);
13370
13367
  for (let i = 0; i < nv; i++) {
13371
- const poly = poly3.create([midpoint, polygon3.vertices[i], polygon3.vertices[(i + 1) % nv]]);
13368
+ const poly = poly3.create([midpoint2, polygon3.vertices[i], polygon3.vertices[(i + 1) % nv]]);
13372
13369
  if (polygon3.color) poly.color = polygon3.color;
13373
13370
  triangles.push(poly);
13374
13371
  }
@@ -18228,12 +18225,12 @@ var bga_def = z510.object({
18228
18225
  });
18229
18226
  var bga = (raw_params) => {
18230
18227
  const parameters = bga_def.parse(raw_params);
18231
- let { num_pins, grid, p, w, h: h2, ball, pad: pad2, missing } = parameters;
18228
+ let { num_pins, grid: grid2, p, w, h: h2, ball, pad: pad2, missing } = parameters;
18232
18229
  ball ??= 0.75 / 1.27 * p;
18233
18230
  pad2 ??= ball * 0.8;
18234
18231
  const pads = [];
18235
18232
  const missing_pin_nums = (missing ?? []).filter((a) => typeof a === "number");
18236
- const num_pins_missing = grid.x * grid.y - num_pins;
18233
+ const num_pins_missing = grid2.x * grid2.y - num_pins;
18237
18234
  if (missing.length === 0 && num_pins_missing > 0) {
18238
18235
  if (Math.sqrt(num_pins_missing) % 1 === 0) {
18239
18236
  missing.push("center");
@@ -18243,11 +18240,11 @@ var bga = (raw_params) => {
18243
18240
  }
18244
18241
  if (missing?.includes("center")) {
18245
18242
  const square_size = Math.floor(Math.sqrt(num_pins_missing));
18246
- const inner_square_x = Math.floor((grid.x - square_size) / 2);
18247
- const inner_square_y = Math.floor((grid.y - square_size) / 2);
18243
+ const inner_square_x = Math.floor((grid2.x - square_size) / 2);
18244
+ const inner_square_y = Math.floor((grid2.y - square_size) / 2);
18248
18245
  for (let y = inner_square_y; y < inner_square_y + square_size; y++) {
18249
18246
  for (let x = inner_square_x; x < inner_square_x + square_size; x++) {
18250
- missing_pin_nums.push(y * grid.x + x + 1);
18247
+ missing_pin_nums.push(y * grid2.x + x + 1);
18251
18248
  }
18252
18249
  }
18253
18250
  }
@@ -18256,30 +18253,30 @@ var bga = (raw_params) => {
18256
18253
  }
18257
18254
  const missing_pin_nums_set = new Set(missing_pin_nums);
18258
18255
  let missing_pins_passed = 0;
18259
- for (let y = 0; y < grid.y; y++) {
18260
- for (let x = 0; x < grid.x; x++) {
18261
- const pad_x = (x - (grid.x - 1) / 2) * p;
18262
- const pad_y = (y - (grid.y - 1) / 2) * p;
18256
+ for (let y = 0; y < grid2.y; y++) {
18257
+ for (let x = 0; x < grid2.x; x++) {
18258
+ const pad_x = (x - (grid2.x - 1) / 2) * p;
18259
+ const pad_y = (y - (grid2.y - 1) / 2) * p;
18263
18260
  let pin_x = x;
18264
18261
  let pin_y = y;
18265
18262
  switch (parameters.origin) {
18266
18263
  case "bl":
18267
18264
  pin_x = x;
18268
- pin_y = grid.y - 1 - y;
18265
+ pin_y = grid2.y - 1 - y;
18269
18266
  break;
18270
18267
  case "br":
18271
- pin_x = grid.x - 1 - x;
18272
- pin_y = grid.y - 1 - y;
18268
+ pin_x = grid2.x - 1 - x;
18269
+ pin_y = grid2.y - 1 - y;
18273
18270
  break;
18274
18271
  case "tr":
18275
- pin_x = grid.x - 1 - x;
18272
+ pin_x = grid2.x - 1 - x;
18276
18273
  pin_y = y;
18277
18274
  break;
18278
18275
  case "tl":
18279
18276
  default:
18280
18277
  break;
18281
18278
  }
18282
- let pin_num = pin_y * grid.x + pin_x + 1;
18279
+ let pin_num = pin_y * grid2.x + pin_x + 1;
18283
18280
  if (missing_pin_nums_set.has(pin_num)) {
18284
18281
  missing_pins_passed++;
18285
18282
  continue;
@@ -18297,13 +18294,13 @@ var bga = (raw_params) => {
18297
18294
  }
18298
18295
  const silkscreenRefText = silkscreenRef(
18299
18296
  0,
18300
- grid.y * p / 2,
18297
+ grid2.y * p / 2,
18301
18298
  0.2
18302
18299
  );
18303
18300
  const pin1MarkerSize = p / 6;
18304
18301
  let markerRoute;
18305
- const edgeX = grid.x * p / 2;
18306
- const edgeY = grid.y * p / 2;
18302
+ const edgeX = grid2.x * p / 2;
18303
+ const edgeY = grid2.y * p / 2;
18307
18304
  switch (parameters.origin) {
18308
18305
  case "bl":
18309
18306
  markerRoute = [
@@ -18617,7 +18614,7 @@ var quad = (raw_params) => {
18617
18614
  const {
18618
18615
  x,
18619
18616
  y,
18620
- o: orientation
18617
+ o: orientation2
18621
18618
  } = getQuadCoords({
18622
18619
  pin_count: parameters.num_pins,
18623
18620
  pn: i + 1,
@@ -18629,7 +18626,7 @@ var quad = (raw_params) => {
18629
18626
  });
18630
18627
  let pw = parameters.pw;
18631
18628
  let pl = parameters.pl;
18632
- if (orientation === "vert") {
18629
+ if (orientation2 === "vert") {
18633
18630
  ;
18634
18631
  [pw, pl] = [pl, pw];
18635
18632
  }
@@ -24792,7 +24789,7 @@ import {
24792
24789
  BufferGeometry,
24793
24790
  Matrix4
24794
24791
  } from "three";
24795
- var Fragment2 = Symbol("Fragment");
24792
+ var Fragment2 = /* @__PURE__ */ Symbol("Fragment");
24796
24793
  function h(type, props, ...restChildren) {
24797
24794
  const provided = restChildren.length ? restChildren : props?.children !== void 0 ? [props.children] : [];
24798
24795
  const flatChildren = [];
@@ -24810,20 +24807,20 @@ function h(type, props, ...restChildren) {
24810
24807
  children: flatChildren
24811
24808
  };
24812
24809
  }
24813
- var Cuboid = Symbol("Cuboid");
24814
- var Cube = Symbol("Cube");
24815
- var Cylinder = Symbol("Cylinder");
24816
- var Sphere = Symbol("Sphere");
24817
- var RoundedCuboid = Symbol("RoundedCuboid");
24818
- var Translate = Symbol("Translate");
24819
- var Rotate = Symbol("Rotate");
24820
- var Union = Symbol("Union");
24821
- var Subtract = Symbol("Subtract");
24822
- var Hull = Symbol("Hull");
24823
- var Colorize = Symbol("Colorize");
24824
- var Polygon = Symbol("Polygon");
24825
- var ExtrudeLinear = Symbol("ExtrudeLinear");
24826
- var RoundedCylinder = Symbol("RoundedCylinder");
24810
+ var Cuboid = /* @__PURE__ */ Symbol("Cuboid");
24811
+ var Cube = /* @__PURE__ */ Symbol("Cube");
24812
+ var Cylinder = /* @__PURE__ */ Symbol("Cylinder");
24813
+ var Sphere = /* @__PURE__ */ Symbol("Sphere");
24814
+ var RoundedCuboid = /* @__PURE__ */ Symbol("RoundedCuboid");
24815
+ var Translate = /* @__PURE__ */ Symbol("Translate");
24816
+ var Rotate = /* @__PURE__ */ Symbol("Rotate");
24817
+ var Union = /* @__PURE__ */ Symbol("Union");
24818
+ var Subtract = /* @__PURE__ */ Symbol("Subtract");
24819
+ var Hull = /* @__PURE__ */ Symbol("Hull");
24820
+ var Colorize = /* @__PURE__ */ Symbol("Colorize");
24821
+ var Polygon = /* @__PURE__ */ Symbol("Polygon");
24822
+ var ExtrudeLinear = /* @__PURE__ */ Symbol("ExtrudeLinear");
24823
+ var RoundedCylinder = /* @__PURE__ */ Symbol("RoundedCylinder");
24827
24824
  var Fragment22 = Fragment2;
24828
24825
  var jsx5 = (type, props, _key) => h(type, props);
24829
24826
  var jsxs = (type, props, _key) => h(type, props);
@@ -25625,7 +25622,7 @@ var QFN = ({
25625
25622
  const {
25626
25623
  x,
25627
25624
  y,
25628
- o: orientation
25625
+ o: orientation2
25629
25626
  } = getQuadCoords2({
25630
25627
  pin_count: num_pins,
25631
25628
  pn: i + 1,
@@ -25637,7 +25634,7 @@ var QFN = ({
25637
25634
  });
25638
25635
  let pw = padWidth;
25639
25636
  let pl = padLength;
25640
- if (orientation === "vert") {
25637
+ if (orientation2 === "vert") {
25641
25638
  ;
25642
25639
  [pw, pl] = [pl, pw];
25643
25640
  }
@@ -29495,7 +29492,7 @@ import * as THREE15 from "three";
29495
29492
  // package.json
29496
29493
  var package_default = {
29497
29494
  name: "@tscircuit/3d-viewer",
29498
- version: "0.0.474",
29495
+ version: "0.0.476",
29499
29496
  main: "./dist/index.js",
29500
29497
  module: "./dist/index.js",
29501
29498
  type: "module",
@@ -29655,12 +29652,12 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29655
29652
  );
29656
29653
  const baseDistance = useMemo8(() => {
29657
29654
  const [x, y, z138] = initialCameraPosition ?? [5, -5, 5];
29658
- const distance2 = Math.hypot(
29655
+ const distance3 = Math.hypot(
29659
29656
  x - defaultTarget.x,
29660
29657
  y - defaultTarget.y,
29661
29658
  z138 - defaultTarget.z
29662
29659
  );
29663
- return distance2 > 0 ? distance2 : 5;
29660
+ return distance3 > 0 ? distance3 : 5;
29664
29661
  }, [initialCameraPosition, defaultTarget]);
29665
29662
  const getPresetConfig = useCallback4(
29666
29663
  (preset) => {
@@ -29671,13 +29668,13 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29671
29668
  ];
29672
29669
  const camera = mainCameraRef.current;
29673
29670
  const controls = controlsRef.current;
29674
- let distance2 = baseDistance;
29671
+ let distance3 = baseDistance;
29675
29672
  if (camera && controls) {
29676
- distance2 = camera.position.distanceTo(controls.target);
29673
+ distance3 = camera.position.distanceTo(controls.target);
29677
29674
  }
29678
29675
  switch (preset) {
29679
29676
  case "Top Center Angled": {
29680
- const angledOffset = distance2 / Math.sqrt(2);
29677
+ const angledOffset = distance3 / Math.sqrt(2);
29681
29678
  return {
29682
29679
  position: [
29683
29680
  defaultTarget.x,
@@ -29693,7 +29690,7 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29693
29690
  position: [
29694
29691
  defaultTarget.x,
29695
29692
  defaultTarget.y,
29696
- defaultTarget.z + distance2
29693
+ defaultTarget.z + distance3
29697
29694
  ],
29698
29695
  target: targetVector,
29699
29696
  up: [0, 0, 1]
@@ -29701,9 +29698,9 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29701
29698
  case "Top Left Corner":
29702
29699
  return {
29703
29700
  position: [
29704
- defaultTarget.x - distance2 * 0.6,
29705
- defaultTarget.y - distance2 * 0.6,
29706
- defaultTarget.z + distance2 * 0.6
29701
+ defaultTarget.x - distance3 * 0.6,
29702
+ defaultTarget.y - distance3 * 0.6,
29703
+ defaultTarget.z + distance3 * 0.6
29707
29704
  ],
29708
29705
  target: targetVector,
29709
29706
  up: [0, 0, 1]
@@ -29711,9 +29708,9 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29711
29708
  case "Top Right Corner":
29712
29709
  return {
29713
29710
  position: [
29714
- defaultTarget.x + distance2 * 0.6,
29715
- defaultTarget.y - distance2 * 0.6,
29716
- defaultTarget.z + distance2 * 0.6
29711
+ defaultTarget.x + distance3 * 0.6,
29712
+ defaultTarget.y - distance3 * 0.6,
29713
+ defaultTarget.z + distance3 * 0.6
29717
29714
  ],
29718
29715
  target: targetVector,
29719
29716
  up: [0, 0, 1]
@@ -29721,7 +29718,7 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29721
29718
  case "Left Sideview":
29722
29719
  return {
29723
29720
  position: [
29724
- defaultTarget.x - distance2,
29721
+ defaultTarget.x - distance3,
29725
29722
  defaultTarget.y,
29726
29723
  defaultTarget.z
29727
29724
  ],
@@ -29731,7 +29728,7 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29731
29728
  case "Right Sideview":
29732
29729
  return {
29733
29730
  position: [
29734
- defaultTarget.x + distance2,
29731
+ defaultTarget.x + distance3,
29735
29732
  defaultTarget.y,
29736
29733
  defaultTarget.z
29737
29734
  ],
@@ -29742,7 +29739,7 @@ var CameraControllerProvider = ({ children, defaultTarget, initialCameraPosition
29742
29739
  return {
29743
29740
  position: [
29744
29741
  defaultTarget.x,
29745
- defaultTarget.y - distance2,
29742
+ defaultTarget.y - distance3,
29746
29743
  defaultTarget.z
29747
29744
  ],
29748
29745
  target: targetVector,
@@ -30324,13 +30321,13 @@ import { useEffect as useEffect15, useRef as useRef7 } from "react";
30324
30321
  import * as THREE14 from "three";
30325
30322
  import { Text as TroikaText } from "troika-three-text";
30326
30323
  import { jsx as jsx12 } from "react/jsx-runtime";
30327
- function computePointInFront(rotationVector, distance2) {
30324
+ function computePointInFront(rotationVector, distance3) {
30328
30325
  const quaternion = new THREE14.Quaternion().setFromEuler(
30329
30326
  new THREE14.Euler(rotationVector.x, rotationVector.y, rotationVector.z)
30330
30327
  );
30331
30328
  const forwardVector = new THREE14.Vector3(0, 0, 1);
30332
30329
  forwardVector.applyQuaternion(quaternion);
30333
- const result = forwardVector.multiplyScalar(distance2);
30330
+ const result = forwardVector.multiplyScalar(distance3);
30334
30331
  return result;
30335
30332
  }
30336
30333
  var OrientationCubeCanvas = () => {
@@ -32610,6 +32607,58 @@ import { su as su9 } from "@tscircuit/circuit-json-util";
32610
32607
  // src/utils/soldermask-texture.ts
32611
32608
  import * as THREE18 from "three";
32612
32609
  import { su as su5 } from "@tscircuit/circuit-json-util";
32610
+
32611
+ // node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
32612
+ var getBoundsFromPoints = (points) => {
32613
+ if (points.length === 0) {
32614
+ return null;
32615
+ }
32616
+ let minX = points[0].x;
32617
+ let minY = points[0].y;
32618
+ let maxX = points[0].x;
32619
+ let maxY = points[0].y;
32620
+ for (let i = 1; i < points.length; i++) {
32621
+ const point2 = points[i];
32622
+ if (point2.x < minX) minX = point2.x;
32623
+ if (point2.y < minY) minY = point2.y;
32624
+ if (point2.x > maxX) maxX = point2.x;
32625
+ if (point2.y > maxY) maxY = point2.y;
32626
+ }
32627
+ return { minX, minY, maxX, maxY };
32628
+ };
32629
+
32630
+ // src/utils/outline-bounds.ts
32631
+ function calculateOutlineBounds(boardData) {
32632
+ if (boardData.outline && boardData.outline.length >= 3) {
32633
+ const bounds2 = getBoundsFromPoints(boardData.outline);
32634
+ return {
32635
+ ...bounds2,
32636
+ width: bounds2.maxX - bounds2.minX,
32637
+ height: bounds2.maxY - bounds2.minY,
32638
+ centerX: (bounds2.minX + bounds2.maxX) / 2,
32639
+ centerY: (bounds2.minY + bounds2.maxY) / 2
32640
+ };
32641
+ }
32642
+ const boardWidth = boardData.width ?? 0;
32643
+ const boardHeight = boardData.height ?? 0;
32644
+ const boardCenterX = boardData.center?.x ?? 0;
32645
+ const boardCenterY = boardData.center?.y ?? 0;
32646
+ const bounds = {
32647
+ minX: boardCenterX - boardWidth / 2,
32648
+ maxX: boardCenterX + boardWidth / 2,
32649
+ minY: boardCenterY - boardHeight / 2,
32650
+ maxY: boardCenterY + boardHeight / 2
32651
+ };
32652
+ return {
32653
+ ...bounds,
32654
+ width: boardWidth,
32655
+ height: boardHeight,
32656
+ centerX: boardCenterX,
32657
+ centerY: boardCenterY
32658
+ };
32659
+ }
32660
+
32661
+ // src/utils/soldermask-texture.ts
32613
32662
  function createSoldermaskTextureForLayer({
32614
32663
  layer,
32615
32664
  circuitJson,
@@ -32617,9 +32666,14 @@ function createSoldermaskTextureForLayer({
32617
32666
  soldermaskColor,
32618
32667
  traceTextureResolution
32619
32668
  }) {
32669
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
32620
32670
  const canvas = document.createElement("canvas");
32621
- const canvasWidth = Math.floor(boardData.width * traceTextureResolution);
32622
- const canvasHeight = Math.floor(boardData.height * traceTextureResolution);
32671
+ const canvasWidth = Math.floor(
32672
+ boardOutlineBounds.width * traceTextureResolution
32673
+ );
32674
+ const canvasHeight = Math.floor(
32675
+ boardOutlineBounds.height * traceTextureResolution
32676
+ );
32623
32677
  canvas.width = canvasWidth;
32624
32678
  canvas.height = canvasHeight;
32625
32679
  const ctx = canvas.getContext("2d");
@@ -32628,8 +32682,8 @@ function createSoldermaskTextureForLayer({
32628
32682
  ctx.translate(0, canvasHeight);
32629
32683
  ctx.scale(1, -1);
32630
32684
  }
32631
- const canvasXFromPcb = (pcbX) => (pcbX - boardData.center.x + boardData.width / 2) * traceTextureResolution;
32632
- const canvasYFromPcb = (pcbY) => (-(pcbY - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
32685
+ const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
32686
+ const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
32633
32687
  ctx.fillStyle = soldermaskColor;
32634
32688
  if (boardData.outline && boardData.outline.length >= 3) {
32635
32689
  ctx.beginPath();
@@ -33412,9 +33466,14 @@ function createSilkscreenTextureForLayer({
33412
33466
  if (textsOnLayer.length === 0 && pathsOnLayer.length === 0 && linesOnLayer.length === 0 && rectsOnLayer.length === 0 && circlesOnLayer.length === 0 && fabricationNoteRectsOnLayer.length === 0 && noteLinesOnLayer.length === 0) {
33413
33467
  return null;
33414
33468
  }
33469
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
33415
33470
  const canvas = document.createElement("canvas");
33416
- const canvasWidth = Math.floor(boardData.width * traceTextureResolution);
33417
- const canvasHeight = Math.floor(boardData.height * traceTextureResolution);
33471
+ const canvasWidth = Math.floor(
33472
+ boardOutlineBounds.width * traceTextureResolution
33473
+ );
33474
+ const canvasHeight = Math.floor(
33475
+ boardOutlineBounds.height * traceTextureResolution
33476
+ );
33418
33477
  canvas.width = canvasWidth;
33419
33478
  canvas.height = canvasHeight;
33420
33479
  const ctx = canvas.getContext("2d");
@@ -33425,8 +33484,8 @@ function createSilkscreenTextureForLayer({
33425
33484
  }
33426
33485
  ctx.strokeStyle = silkscreenColor;
33427
33486
  ctx.fillStyle = silkscreenColor;
33428
- const canvasXFromPcb = (pcbX) => (pcbX - boardData.center.x + boardData.width / 2) * traceTextureResolution;
33429
- const canvasYFromPcb = (pcbY) => (-(pcbY - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
33487
+ const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
33488
+ const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
33430
33489
  linesOnLayer.forEach((lineEl) => {
33431
33490
  const startXmm = parseDimensionToMm(lineEl.x1) ?? 0;
33432
33491
  const startYmm = parseDimensionToMm(lineEl.y1) ?? 0;
@@ -33792,9 +33851,14 @@ function createTraceTextureForLayer({
33792
33851
  (t) => t.route.some((p) => isWireRoutePoint(p) && p.layer === layer)
33793
33852
  );
33794
33853
  if (tracesOnLayer.length === 0) return null;
33854
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
33795
33855
  const canvas = document.createElement("canvas");
33796
- const canvasWidth = Math.floor(boardData.width * traceTextureResolution);
33797
- const canvasHeight = Math.floor(boardData.height * traceTextureResolution);
33856
+ const canvasWidth = Math.floor(
33857
+ boardOutlineBounds.width * traceTextureResolution
33858
+ );
33859
+ const canvasHeight = Math.floor(
33860
+ boardOutlineBounds.height * traceTextureResolution
33861
+ );
33798
33862
  canvas.width = canvasWidth;
33799
33863
  canvas.height = canvasHeight;
33800
33864
  const ctx = canvas.getContext("2d");
@@ -33820,8 +33884,8 @@ function createTraceTextureForLayer({
33820
33884
  const pcbY = point2.y;
33821
33885
  currentLineWidth = point2.width * traceTextureResolution;
33822
33886
  ctx.lineWidth = currentLineWidth;
33823
- const canvasX = (pcbX - boardData.center.x + boardData.width / 2) * traceTextureResolution;
33824
- const canvasY = (-(pcbY - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
33887
+ const canvasX = (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
33888
+ const canvasY = (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
33825
33889
  if (firstPoint) {
33826
33890
  ctx.moveTo(canvasX, canvasY);
33827
33891
  firstPoint = false;
@@ -33836,8 +33900,8 @@ function createTraceTextureForLayer({
33836
33900
  ctx.globalCompositeOperation = "destination-out";
33837
33901
  ctx.fillStyle = "black";
33838
33902
  allPcbVias.forEach((via) => {
33839
- const canvasX = (via.x - boardData.center.x + boardData.width / 2) * traceTextureResolution;
33840
- const canvasY = (-(via.y - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
33903
+ const canvasX = (via.x - boardOutlineBounds.minX) * traceTextureResolution;
33904
+ const canvasY = (boardOutlineBounds.maxY - via.y) * traceTextureResolution;
33841
33905
  const canvasRadius = via.outer_diameter / 2 * traceTextureResolution;
33842
33906
  ctx.beginPath();
33843
33907
  ctx.arc(canvasX, canvasY, canvasRadius, 0, 2 * Math.PI, false);
@@ -33845,8 +33909,8 @@ function createTraceTextureForLayer({
33845
33909
  });
33846
33910
  allPcbPlatedHoles.forEach((ph) => {
33847
33911
  if (ph.layers.includes(layer) && ph.shape === "circle") {
33848
- const canvasX = (ph.x - boardData.center.x + boardData.width / 2) * traceTextureResolution;
33849
- const canvasY = (-(ph.y - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
33912
+ const canvasX = (ph.x - boardOutlineBounds.minX) * traceTextureResolution;
33913
+ const canvasY = (boardOutlineBounds.maxY - ph.y) * traceTextureResolution;
33850
33914
  const canvasRadius = ph.outer_diameter / 2 * traceTextureResolution;
33851
33915
  ctx.beginPath();
33852
33916
  ctx.arc(canvasX, canvasY, canvasRadius, 0, 2 * Math.PI, false);
@@ -34041,9 +34105,14 @@ function createCopperTextTextureForLayer({
34041
34105
  if (textsOnLayer.length === 0) {
34042
34106
  return null;
34043
34107
  }
34108
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
34044
34109
  const canvas = document.createElement("canvas");
34045
- const canvasWidth = Math.floor(boardData.width * traceTextureResolution);
34046
- const canvasHeight = Math.floor(boardData.height * traceTextureResolution);
34110
+ const canvasWidth = Math.floor(
34111
+ boardOutlineBounds.width * traceTextureResolution
34112
+ );
34113
+ const canvasHeight = Math.floor(
34114
+ boardOutlineBounds.height * traceTextureResolution
34115
+ );
34047
34116
  canvas.width = canvasWidth;
34048
34117
  canvas.height = canvasHeight;
34049
34118
  const ctx = canvas.getContext("2d");
@@ -34054,8 +34123,8 @@ function createCopperTextTextureForLayer({
34054
34123
  }
34055
34124
  ctx.strokeStyle = copperColor;
34056
34125
  ctx.fillStyle = copperColor;
34057
- const canvasXFromPcb = (pcbX) => (pcbX - boardData.center.x + boardData.width / 2) * traceTextureResolution;
34058
- const canvasYFromPcb = (pcbY) => (-(pcbY - boardData.center.y) + boardData.height / 2) * traceTextureResolution;
34126
+ const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
34127
+ const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
34059
34128
  textsOnLayer.forEach((textS) => {
34060
34129
  const fontSize = typeof textS.font_size === "number" ? textS.font_size : 0.2;
34061
34130
  const textStrokeWidth = Math.max(0.02, fontSize * 0.08) * traceTextureResolution;
@@ -34290,9 +34359,10 @@ function JscadBoardTextures({
34290
34359
  const meshes = [];
34291
34360
  const createTexturePlane = (texture, zOffset, isBottomLayer, name, usePolygonOffset = false, depthWrite = false) => {
34292
34361
  if (!texture) return null;
34362
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
34293
34363
  const planeGeom = new THREE23.PlaneGeometry(
34294
- boardData.width,
34295
- boardData.height
34364
+ boardOutlineBounds.width,
34365
+ boardOutlineBounds.height
34296
34366
  );
34297
34367
  const material = new THREE23.MeshBasicMaterial({
34298
34368
  map: texture,
@@ -34304,7 +34374,11 @@ function JscadBoardTextures({
34304
34374
  polygonOffsetUnits: usePolygonOffset ? -1 : 0
34305
34375
  });
34306
34376
  const mesh = new THREE23.Mesh(planeGeom, material);
34307
- mesh.position.set(boardData.center.x, boardData.center.y, zOffset);
34377
+ mesh.position.set(
34378
+ boardOutlineBounds.centerX,
34379
+ boardOutlineBounds.centerY,
34380
+ zOffset
34381
+ );
34308
34382
  if (isBottomLayer) {
34309
34383
  mesh.rotation.set(Math.PI, 0, 0);
34310
34384
  }
@@ -36396,7 +36470,11 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
36396
36470
  if (!textures || !boardData || pcbThickness === null) return meshes;
36397
36471
  const createTexturePlane = (texture, yOffset, isBottomLayer, keySuffix, usePolygonOffset = false, renderOrder = 0) => {
36398
36472
  if (!texture) return null;
36399
- const planeGeom = new THREE32.PlaneGeometry(boardData.width, boardData.height);
36473
+ const boardOutlineBounds = calculateOutlineBounds(boardData);
36474
+ const planeGeom = new THREE32.PlaneGeometry(
36475
+ boardOutlineBounds.width,
36476
+ boardOutlineBounds.height
36477
+ );
36400
36478
  const material = new THREE32.MeshBasicMaterial({
36401
36479
  map: texture,
36402
36480
  transparent: true,
@@ -36408,7 +36486,11 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
36408
36486
  polygonOffsetUnits: usePolygonOffset ? -4 : 0
36409
36487
  });
36410
36488
  const mesh = new THREE32.Mesh(planeGeom, material);
36411
- mesh.position.set(boardData.center.x, boardData.center.y, yOffset);
36489
+ mesh.position.set(
36490
+ boardOutlineBounds.centerX,
36491
+ boardOutlineBounds.centerY,
36492
+ yOffset
36493
+ );
36412
36494
  if (isBottomLayer) {
36413
36495
  mesh.rotation.set(Math.PI, 0, 0);
36414
36496
  }
@@ -37402,7 +37484,6 @@ function useUncontrolledState({
37402
37484
  function isFunction(value) {
37403
37485
  return typeof value === "function";
37404
37486
  }
37405
- var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
37406
37487
 
37407
37488
  // node_modules/@radix-ui/react-primitive/dist/index.mjs
37408
37489
  import * as React17 from "react";
@@ -37452,7 +37533,7 @@ function createSlotClone(ownerName) {
37452
37533
  SlotClone.displayName = `${ownerName}.SlotClone`;
37453
37534
  return SlotClone;
37454
37535
  }
37455
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
37536
+ var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
37456
37537
  function isSlottable(child) {
37457
37538
  return React16.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
37458
37539
  }
@@ -37521,7 +37602,7 @@ var Primitive = NODES.reduce((primitive, node) => {
37521
37602
  const { asChild, ...primitiveProps } = props;
37522
37603
  const Comp = asChild ? Slot2 : node;
37523
37604
  if (typeof window !== "undefined") {
37524
- window[Symbol.for("radix-ui")] = true;
37605
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
37525
37606
  }
37526
37607
  return /* @__PURE__ */ jsx21(Comp, { ...primitiveProps, ref: forwardedRef });
37527
37608
  });
@@ -38112,7 +38193,7 @@ var oppositeAlignmentMap = {
38112
38193
  start: "end",
38113
38194
  end: "start"
38114
38195
  };
38115
- function clamp(start, value, end) {
38196
+ function clamp2(start, value, end) {
38116
38197
  return max(start, min(value, end));
38117
38198
  }
38118
38199
  function evaluate(value, param) {
@@ -38465,7 +38546,7 @@ var arrow = (options) => ({
38465
38546
  const min$1 = minPadding;
38466
38547
  const max2 = clientSize - arrowDimensions[length2] - maxPadding;
38467
38548
  const center = clientSize / 2 - arrowDimensions[length2] / 2 + centerToReference;
38468
- const offset4 = clamp(min$1, center, max2);
38549
+ const offset4 = clamp2(min$1, center, max2);
38469
38550
  const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length2] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length2] / 2 < 0;
38470
38551
  const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
38471
38552
  return {
@@ -38762,14 +38843,14 @@ var shift = function(options) {
38762
38843
  const maxSide = mainAxis === "y" ? "bottom" : "right";
38763
38844
  const min2 = mainAxisCoord + overflow[minSide];
38764
38845
  const max2 = mainAxisCoord - overflow[maxSide];
38765
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
38846
+ mainAxisCoord = clamp2(min2, mainAxisCoord, max2);
38766
38847
  }
38767
38848
  if (checkCrossAxis) {
38768
38849
  const minSide = crossAxis === "y" ? "top" : "left";
38769
38850
  const maxSide = crossAxis === "y" ? "bottom" : "right";
38770
38851
  const min2 = crossAxisCoord + overflow[minSide];
38771
38852
  const max2 = crossAxisCoord - overflow[maxSide];
38772
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
38853
+ crossAxisCoord = clamp2(min2, crossAxisCoord, max2);
38773
38854
  }
38774
38855
  const limitedCoords = limiter.fn({
38775
38856
  ...state,
@@ -40474,7 +40555,7 @@ RovingFocusGroup.displayName = GROUP_NAME;
40474
40555
  var RovingFocusGroupImpl = React34.forwardRef((props, forwardedRef) => {
40475
40556
  const {
40476
40557
  __scopeRovingFocusGroup,
40477
- orientation,
40558
+ orientation: orientation2,
40478
40559
  loop = false,
40479
40560
  dir,
40480
40561
  currentTabStopId: currentTabStopIdProp,
@@ -40509,7 +40590,7 @@ var RovingFocusGroupImpl = React34.forwardRef((props, forwardedRef) => {
40509
40590
  RovingFocusProvider,
40510
40591
  {
40511
40592
  scope: __scopeRovingFocusGroup,
40512
- orientation,
40593
+ orientation: orientation2,
40513
40594
  dir: direction,
40514
40595
  loop,
40515
40596
  currentTabStopId,
@@ -40530,7 +40611,7 @@ var RovingFocusGroupImpl = React34.forwardRef((props, forwardedRef) => {
40530
40611
  Primitive.div,
40531
40612
  {
40532
40613
  tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
40533
- "data-orientation": orientation,
40614
+ "data-orientation": orientation2,
40534
40615
  ...groupProps,
40535
40616
  ref: composedRefs,
40536
40617
  style: { outline: "none", ...props.style },
@@ -40646,10 +40727,10 @@ function getDirectionAwareKey(key, dir) {
40646
40727
  if (dir !== "rtl") return key;
40647
40728
  return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
40648
40729
  }
40649
- function getFocusIntent(event, orientation, dir) {
40730
+ function getFocusIntent(event, orientation2, dir) {
40650
40731
  const key = getDirectionAwareKey(event.key, dir);
40651
- if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
40652
- if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
40732
+ if (orientation2 === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
40733
+ if (orientation2 === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
40653
40734
  return MAP_KEY_TO_FOCUS_INTENT[key];
40654
40735
  }
40655
40736
  function focusFirst2(candidates, preventScroll = false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.475",
3
+ "version": "0.0.477",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",