@tscircuit/3d-viewer 0.0.514 → 0.0.516
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.
- package/dist/index.d.ts +0 -5
- package/dist/index.js +313 -385
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6019,11 +6019,11 @@ var require_clone9 = __commonJS({
|
|
|
6019
6019
|
"node_modules/@jscad/modeling/src/maths/line2/clone.js"(exports, module) {
|
|
6020
6020
|
"use strict";
|
|
6021
6021
|
var create = require_create11();
|
|
6022
|
-
var clone = (
|
|
6022
|
+
var clone = (line) => {
|
|
6023
6023
|
const out = create();
|
|
6024
|
-
out[0] =
|
|
6025
|
-
out[1] =
|
|
6026
|
-
out[2] =
|
|
6024
|
+
out[0] = line[0];
|
|
6025
|
+
out[1] = line[1];
|
|
6026
|
+
out[2] = line[2];
|
|
6027
6027
|
return out;
|
|
6028
6028
|
};
|
|
6029
6029
|
module.exports = clone;
|
|
@@ -6035,8 +6035,8 @@ var require_direction = __commonJS({
|
|
|
6035
6035
|
"node_modules/@jscad/modeling/src/maths/line2/direction.js"(exports, module) {
|
|
6036
6036
|
"use strict";
|
|
6037
6037
|
var vec2 = require_vec2();
|
|
6038
|
-
var direction = (
|
|
6039
|
-
const vector = vec2.normal(vec2.create(),
|
|
6038
|
+
var direction = (line) => {
|
|
6039
|
+
const vector = vec2.normal(vec2.create(), line);
|
|
6040
6040
|
vec2.negate(vector, vector);
|
|
6041
6041
|
return vector;
|
|
6042
6042
|
};
|
|
@@ -6049,7 +6049,7 @@ var require_origin = __commonJS({
|
|
|
6049
6049
|
"node_modules/@jscad/modeling/src/maths/line2/origin.js"(exports, module) {
|
|
6050
6050
|
"use strict";
|
|
6051
6051
|
var vec2 = require_vec2();
|
|
6052
|
-
var origin = (
|
|
6052
|
+
var origin = (line) => vec2.scale(vec2.create(), line, line[2]);
|
|
6053
6053
|
module.exports = origin;
|
|
6054
6054
|
}
|
|
6055
6055
|
});
|
|
@@ -6061,9 +6061,9 @@ var require_closestPoint = __commonJS({
|
|
|
6061
6061
|
var vec2 = require_vec2();
|
|
6062
6062
|
var direction = require_direction();
|
|
6063
6063
|
var origin = require_origin();
|
|
6064
|
-
var closestPoint = (
|
|
6065
|
-
const orig = origin(
|
|
6066
|
-
const dir = direction(
|
|
6064
|
+
var closestPoint = (line, point) => {
|
|
6065
|
+
const orig = origin(line);
|
|
6066
|
+
const dir = direction(line);
|
|
6067
6067
|
const v = vec2.subtract(vec2.create(), point, orig);
|
|
6068
6068
|
const dist = vec2.dot(v, dir);
|
|
6069
6069
|
vec2.scale(v, dir, dist);
|
|
@@ -6078,10 +6078,10 @@ var require_closestPoint = __commonJS({
|
|
|
6078
6078
|
var require_copy5 = __commonJS({
|
|
6079
6079
|
"node_modules/@jscad/modeling/src/maths/line2/copy.js"(exports, module) {
|
|
6080
6080
|
"use strict";
|
|
6081
|
-
var copy = (out,
|
|
6082
|
-
out[0] =
|
|
6083
|
-
out[1] =
|
|
6084
|
-
out[2] =
|
|
6081
|
+
var copy = (out, line) => {
|
|
6082
|
+
out[0] = line[0];
|
|
6083
|
+
out[1] = line[1];
|
|
6084
|
+
out[2] = line[2];
|
|
6085
6085
|
return out;
|
|
6086
6086
|
};
|
|
6087
6087
|
module.exports = copy;
|
|
@@ -6093,9 +6093,9 @@ var require_distanceToPoint = __commonJS({
|
|
|
6093
6093
|
"node_modules/@jscad/modeling/src/maths/line2/distanceToPoint.js"(exports, module) {
|
|
6094
6094
|
"use strict";
|
|
6095
6095
|
var vec2 = require_vec2();
|
|
6096
|
-
var distanceToPoint = (
|
|
6097
|
-
let distance4 = vec2.dot(point,
|
|
6098
|
-
distance4 = Math.abs(distance4 -
|
|
6096
|
+
var distanceToPoint = (line, point) => {
|
|
6097
|
+
let distance4 = vec2.dot(point, line);
|
|
6098
|
+
distance4 = Math.abs(distance4 - line[2]);
|
|
6099
6099
|
return distance4;
|
|
6100
6100
|
};
|
|
6101
6101
|
module.exports = distanceToPoint;
|
|
@@ -6263,9 +6263,9 @@ var require_reverse3 = __commonJS({
|
|
|
6263
6263
|
var vec2 = require_vec2();
|
|
6264
6264
|
var copy = require_copy5();
|
|
6265
6265
|
var fromValues = require_fromValues5();
|
|
6266
|
-
var reverse = (out,
|
|
6267
|
-
const normal = vec2.negate(vec2.create(),
|
|
6268
|
-
const distance4 = -
|
|
6266
|
+
var reverse = (out, line) => {
|
|
6267
|
+
const normal = vec2.negate(vec2.create(), line);
|
|
6268
|
+
const distance4 = -line[2];
|
|
6269
6269
|
return copy(out, fromValues(normal[0], normal[1], distance4));
|
|
6270
6270
|
};
|
|
6271
6271
|
module.exports = reverse;
|
|
@@ -6276,7 +6276,7 @@ var require_reverse3 = __commonJS({
|
|
|
6276
6276
|
var require_toString9 = __commonJS({
|
|
6277
6277
|
"node_modules/@jscad/modeling/src/maths/line2/toString.js"(exports, module) {
|
|
6278
6278
|
"use strict";
|
|
6279
|
-
var toString = (
|
|
6279
|
+
var toString = (line) => `line2: (${line[0].toFixed(7)}, ${line[1].toFixed(7)}, ${line[2].toFixed(7)})`;
|
|
6280
6280
|
module.exports = toString;
|
|
6281
6281
|
}
|
|
6282
6282
|
});
|
|
@@ -6289,9 +6289,9 @@ var require_transform9 = __commonJS({
|
|
|
6289
6289
|
var fromPoints = require_fromPoints6();
|
|
6290
6290
|
var origin = require_origin();
|
|
6291
6291
|
var direction = require_direction();
|
|
6292
|
-
var transform2 = (out,
|
|
6293
|
-
const org = origin(
|
|
6294
|
-
const dir = direction(
|
|
6292
|
+
var transform2 = (out, line, matrix) => {
|
|
6293
|
+
const org = origin(line);
|
|
6294
|
+
const dir = direction(line);
|
|
6295
6295
|
vec2.transform(org, org, matrix);
|
|
6296
6296
|
vec2.transform(dir, dir, matrix);
|
|
6297
6297
|
return fromPoints(out, org, dir);
|
|
@@ -6305,10 +6305,10 @@ var require_xAtY = __commonJS({
|
|
|
6305
6305
|
"node_modules/@jscad/modeling/src/maths/line2/xAtY.js"(exports, module) {
|
|
6306
6306
|
"use strict";
|
|
6307
6307
|
var origin = require_origin();
|
|
6308
|
-
var xAtY = (
|
|
6309
|
-
let x = (
|
|
6308
|
+
var xAtY = (line, y) => {
|
|
6309
|
+
let x = (line[2] - line[1] * y) / line[0];
|
|
6310
6310
|
if (Number.isNaN(x)) {
|
|
6311
|
-
const org = origin(
|
|
6311
|
+
const org = origin(line);
|
|
6312
6312
|
x = org[0];
|
|
6313
6313
|
}
|
|
6314
6314
|
return x;
|
|
@@ -6362,10 +6362,10 @@ var require_clone10 = __commonJS({
|
|
|
6362
6362
|
"use strict";
|
|
6363
6363
|
var vec3 = require_vec3();
|
|
6364
6364
|
var create = require_create12();
|
|
6365
|
-
var clone = (
|
|
6365
|
+
var clone = (line) => {
|
|
6366
6366
|
const out = create();
|
|
6367
|
-
vec3.copy(out[0],
|
|
6368
|
-
vec3.copy(out[1],
|
|
6367
|
+
vec3.copy(out[0], line[0]);
|
|
6368
|
+
vec3.copy(out[1], line[1]);
|
|
6369
6369
|
return out;
|
|
6370
6370
|
};
|
|
6371
6371
|
module.exports = clone;
|
|
@@ -6377,9 +6377,9 @@ var require_closestPoint2 = __commonJS({
|
|
|
6377
6377
|
"node_modules/@jscad/modeling/src/maths/line3/closestPoint.js"(exports, module) {
|
|
6378
6378
|
"use strict";
|
|
6379
6379
|
var vec3 = require_vec3();
|
|
6380
|
-
var closestPoint = (
|
|
6381
|
-
const lpoint =
|
|
6382
|
-
const ldirection =
|
|
6380
|
+
var closestPoint = (line, point) => {
|
|
6381
|
+
const lpoint = line[0];
|
|
6382
|
+
const ldirection = line[1];
|
|
6383
6383
|
const a = vec3.dot(vec3.subtract(vec3.create(), point, lpoint), ldirection);
|
|
6384
6384
|
const b = vec3.dot(ldirection, ldirection);
|
|
6385
6385
|
const t = a / b;
|
|
@@ -6396,9 +6396,9 @@ var require_copy6 = __commonJS({
|
|
|
6396
6396
|
"node_modules/@jscad/modeling/src/maths/line3/copy.js"(exports, module) {
|
|
6397
6397
|
"use strict";
|
|
6398
6398
|
var vec3 = require_vec3();
|
|
6399
|
-
var copy = (out,
|
|
6400
|
-
vec3.copy(out[0],
|
|
6401
|
-
vec3.copy(out[1],
|
|
6399
|
+
var copy = (out, line) => {
|
|
6400
|
+
vec3.copy(out[0], line[0]);
|
|
6401
|
+
vec3.copy(out[1], line[1]);
|
|
6402
6402
|
return out;
|
|
6403
6403
|
};
|
|
6404
6404
|
module.exports = copy;
|
|
@@ -6409,7 +6409,7 @@ var require_copy6 = __commonJS({
|
|
|
6409
6409
|
var require_direction2 = __commonJS({
|
|
6410
6410
|
"node_modules/@jscad/modeling/src/maths/line3/direction.js"(exports, module) {
|
|
6411
6411
|
"use strict";
|
|
6412
|
-
var direction = (
|
|
6412
|
+
var direction = (line) => line[1];
|
|
6413
6413
|
module.exports = direction;
|
|
6414
6414
|
}
|
|
6415
6415
|
});
|
|
@@ -6420,8 +6420,8 @@ var require_distanceToPoint2 = __commonJS({
|
|
|
6420
6420
|
"use strict";
|
|
6421
6421
|
var vec3 = require_vec3();
|
|
6422
6422
|
var closestPoint = require_closestPoint2();
|
|
6423
|
-
var distanceToPoint = (
|
|
6424
|
-
const closest = closestPoint(
|
|
6423
|
+
var distanceToPoint = (line, point) => {
|
|
6424
|
+
const closest = closestPoint(line, point);
|
|
6425
6425
|
const distancevector = vec3.subtract(vec3.create(), point, closest);
|
|
6426
6426
|
return vec3.length(distancevector);
|
|
6427
6427
|
};
|
|
@@ -6514,11 +6514,11 @@ var require_intersectPointOfLineAndPlane = __commonJS({
|
|
|
6514
6514
|
"node_modules/@jscad/modeling/src/maths/line3/intersectPointOfLineAndPlane.js"(exports, module) {
|
|
6515
6515
|
"use strict";
|
|
6516
6516
|
var vec3 = require_vec3();
|
|
6517
|
-
var intersectToPlane = (
|
|
6517
|
+
var intersectToPlane = (line, plane) => {
|
|
6518
6518
|
const pnormal = plane;
|
|
6519
6519
|
const pw = plane[3];
|
|
6520
|
-
const lpoint =
|
|
6521
|
-
const ldirection =
|
|
6520
|
+
const lpoint = line[0];
|
|
6521
|
+
const ldirection = line[1];
|
|
6522
6522
|
const labda = (pw - vec3.dot(pnormal, lpoint)) / vec3.dot(pnormal, ldirection);
|
|
6523
6523
|
const point = vec3.add(vec3.create(), lpoint, vec3.scale(vec3.create(), ldirection, labda));
|
|
6524
6524
|
return point;
|
|
@@ -6531,7 +6531,7 @@ var require_intersectPointOfLineAndPlane = __commonJS({
|
|
|
6531
6531
|
var require_origin2 = __commonJS({
|
|
6532
6532
|
"node_modules/@jscad/modeling/src/maths/line3/origin.js"(exports, module) {
|
|
6533
6533
|
"use strict";
|
|
6534
|
-
var origin = (
|
|
6534
|
+
var origin = (line) => line[0];
|
|
6535
6535
|
module.exports = origin;
|
|
6536
6536
|
}
|
|
6537
6537
|
});
|
|
@@ -6542,9 +6542,9 @@ var require_reverse4 = __commonJS({
|
|
|
6542
6542
|
"use strict";
|
|
6543
6543
|
var vec3 = require_vec3();
|
|
6544
6544
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6545
|
-
var reverse = (out,
|
|
6546
|
-
const point = vec3.clone(
|
|
6547
|
-
const direction = vec3.negate(vec3.create(),
|
|
6545
|
+
var reverse = (out, line) => {
|
|
6546
|
+
const point = vec3.clone(line[0]);
|
|
6547
|
+
const direction = vec3.negate(vec3.create(), line[1]);
|
|
6548
6548
|
return fromPointAndDirection(out, point, direction);
|
|
6549
6549
|
};
|
|
6550
6550
|
module.exports = reverse;
|
|
@@ -6555,9 +6555,9 @@ var require_reverse4 = __commonJS({
|
|
|
6555
6555
|
var require_toString10 = __commonJS({
|
|
6556
6556
|
"node_modules/@jscad/modeling/src/maths/line3/toString.js"(exports, module) {
|
|
6557
6557
|
"use strict";
|
|
6558
|
-
var toString = (
|
|
6559
|
-
const point =
|
|
6560
|
-
const direction =
|
|
6558
|
+
var toString = (line) => {
|
|
6559
|
+
const point = line[0];
|
|
6560
|
+
const direction = line[1];
|
|
6561
6561
|
return `line3: point: (${point[0].toFixed(7)}, ${point[1].toFixed(7)}, ${point[2].toFixed(7)}) direction: (${direction[0].toFixed(7)}, ${direction[1].toFixed(7)}, ${direction[2].toFixed(7)})`;
|
|
6562
6562
|
};
|
|
6563
6563
|
module.exports = toString;
|
|
@@ -6570,9 +6570,9 @@ var require_transform10 = __commonJS({
|
|
|
6570
6570
|
"use strict";
|
|
6571
6571
|
var vec3 = require_vec3();
|
|
6572
6572
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6573
|
-
var transform2 = (out,
|
|
6574
|
-
const point =
|
|
6575
|
-
const direction =
|
|
6573
|
+
var transform2 = (out, line, matrix) => {
|
|
6574
|
+
const point = line[0];
|
|
6575
|
+
const direction = line[1];
|
|
6576
6576
|
const pointPlusDirection = vec3.add(vec3.create(), point, direction);
|
|
6577
6577
|
const newpoint = vec3.transform(vec3.create(), point, matrix);
|
|
6578
6578
|
const newPointPlusDirection = vec3.transform(pointPlusDirection, pointPlusDirection, matrix);
|
|
@@ -7785,11 +7785,11 @@ var require_line = __commonJS({
|
|
|
7785
7785
|
"node_modules/@jscad/modeling/src/primitives/line.js"(exports, module) {
|
|
7786
7786
|
"use strict";
|
|
7787
7787
|
var path2 = require_path2();
|
|
7788
|
-
var
|
|
7788
|
+
var line = (points) => {
|
|
7789
7789
|
if (!Array.isArray(points)) throw new Error("points must be an array");
|
|
7790
7790
|
return path2.fromPoints({}, points);
|
|
7791
7791
|
};
|
|
7792
|
-
module.exports =
|
|
7792
|
+
module.exports = line;
|
|
7793
7793
|
}
|
|
7794
7794
|
});
|
|
7795
7795
|
|
|
@@ -9914,9 +9914,9 @@ var require_vectorText = __commonJS({
|
|
|
9914
9914
|
"use strict";
|
|
9915
9915
|
var vectorChar = require_vectorChar();
|
|
9916
9916
|
var vectorParams = require_vectorParams();
|
|
9917
|
-
var translateLine = (options,
|
|
9917
|
+
var translateLine = (options, line) => {
|
|
9918
9918
|
const { x, y } = Object.assign({ x: 0, y: 0 }, options || {});
|
|
9919
|
-
const segments =
|
|
9919
|
+
const segments = line.segments;
|
|
9920
9920
|
let segment = null;
|
|
9921
9921
|
let point = null;
|
|
9922
9922
|
for (let i = 0, il = segments.length; i < il; i++) {
|
|
@@ -9926,7 +9926,7 @@ var require_vectorText = __commonJS({
|
|
|
9926
9926
|
segment[j] = [point[0] + x, point[1] + y];
|
|
9927
9927
|
}
|
|
9928
9928
|
}
|
|
9929
|
-
return
|
|
9929
|
+
return line;
|
|
9930
9930
|
};
|
|
9931
9931
|
var vectorText3 = (options, text) => {
|
|
9932
9932
|
const {
|
|
@@ -9942,15 +9942,15 @@ var require_vectorText = __commonJS({
|
|
|
9942
9942
|
} = vectorParams(options, text);
|
|
9943
9943
|
let [x, y] = [xOffset, yOffset];
|
|
9944
9944
|
let i, il, char, vect, width10, diff;
|
|
9945
|
-
let
|
|
9945
|
+
let line = { width: 0, segments: [] };
|
|
9946
9946
|
const lines = [];
|
|
9947
9947
|
let output = [];
|
|
9948
9948
|
let maxWidth = 0;
|
|
9949
9949
|
const lineStart = x;
|
|
9950
9950
|
const pushLine = () => {
|
|
9951
|
-
lines.push(
|
|
9952
|
-
maxWidth = Math.max(maxWidth,
|
|
9953
|
-
|
|
9951
|
+
lines.push(line);
|
|
9952
|
+
maxWidth = Math.max(maxWidth, line.width);
|
|
9953
|
+
line = { width: 0, segments: [] };
|
|
9954
9954
|
};
|
|
9955
9955
|
for (i = 0, il = input.length; i < il; i++) {
|
|
9956
9956
|
char = input[i];
|
|
@@ -9962,26 +9962,26 @@ var require_vectorText = __commonJS({
|
|
|
9962
9962
|
continue;
|
|
9963
9963
|
}
|
|
9964
9964
|
width10 = vect.width * letterSpacing;
|
|
9965
|
-
|
|
9965
|
+
line.width += width10;
|
|
9966
9966
|
x += width10;
|
|
9967
9967
|
if (char !== " ") {
|
|
9968
|
-
|
|
9968
|
+
line.segments = line.segments.concat(vect.segments);
|
|
9969
9969
|
}
|
|
9970
9970
|
}
|
|
9971
|
-
if (
|
|
9971
|
+
if (line.segments.length) {
|
|
9972
9972
|
pushLine();
|
|
9973
9973
|
}
|
|
9974
9974
|
for (i = 0, il = lines.length; i < il; i++) {
|
|
9975
|
-
|
|
9976
|
-
if (maxWidth >
|
|
9977
|
-
diff = maxWidth -
|
|
9975
|
+
line = lines[i];
|
|
9976
|
+
if (maxWidth > line.width) {
|
|
9977
|
+
diff = maxWidth - line.width;
|
|
9978
9978
|
if (align === "right") {
|
|
9979
|
-
|
|
9979
|
+
line = translateLine({ x: diff }, line);
|
|
9980
9980
|
} else if (align === "center") {
|
|
9981
|
-
|
|
9981
|
+
line = translateLine({ x: diff / 2 }, line);
|
|
9982
9982
|
}
|
|
9983
9983
|
}
|
|
9984
|
-
output = output.concat(
|
|
9984
|
+
output = output.concat(line.segments);
|
|
9985
9985
|
}
|
|
9986
9986
|
return output;
|
|
9987
9987
|
};
|
|
@@ -14248,7 +14248,7 @@ import { useState as useState36, useCallback as useCallback21, useRef as useRef2
|
|
|
14248
14248
|
import * as THREE36 from "three";
|
|
14249
14249
|
|
|
14250
14250
|
// src/CadViewerJscad.tsx
|
|
14251
|
-
import { su as
|
|
14251
|
+
import { su as su13 } from "@tscircuit/circuit-json-util";
|
|
14252
14252
|
import { forwardRef as forwardRef3, useMemo as useMemo20 } from "react";
|
|
14253
14253
|
|
|
14254
14254
|
// src/AnyCadComponent.tsx
|
|
@@ -28483,7 +28483,7 @@ import * as THREE16 from "three";
|
|
|
28483
28483
|
// package.json
|
|
28484
28484
|
var package_default = {
|
|
28485
28485
|
name: "@tscircuit/3d-viewer",
|
|
28486
|
-
version: "0.0.
|
|
28486
|
+
version: "0.0.515",
|
|
28487
28487
|
main: "./dist/index.js",
|
|
28488
28488
|
module: "./dist/index.js",
|
|
28489
28489
|
type: "module",
|
|
@@ -29806,39 +29806,13 @@ var createBoardGeomFromCircuitJson = (circuitJson, opts = {}) => {
|
|
|
29806
29806
|
};
|
|
29807
29807
|
|
|
29808
29808
|
// src/BoardGeomBuilder.ts
|
|
29809
|
-
var import_transforms6 = __toESM(require_transforms(), 1);
|
|
29810
|
-
var import_primitives6 = __toESM(require_primitives(), 1);
|
|
29811
29809
|
var import_colors3 = __toESM(require_colors(), 1);
|
|
29812
29810
|
var import_booleans4 = __toESM(require_booleans(), 1);
|
|
29811
|
+
var import_extrusions4 = __toESM(require_extrusions(), 1);
|
|
29812
|
+
var import_transforms6 = __toESM(require_transforms(), 1);
|
|
29813
|
+
var import_primitives6 = __toESM(require_primitives(), 1);
|
|
29813
29814
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
29814
29815
|
|
|
29815
|
-
// src/geoms/plated-hole.ts
|
|
29816
|
-
var import_primitives4 = __toESM(require_primitives(), 1);
|
|
29817
|
-
var import_colors2 = __toESM(require_colors(), 1);
|
|
29818
|
-
var import_booleans2 = __toESM(require_booleans(), 1);
|
|
29819
|
-
var import_transforms3 = __toESM(require_transforms(), 1);
|
|
29820
|
-
var import_extrusions3 = __toESM(require_extrusions(), 1);
|
|
29821
|
-
var import_transforms4 = __toESM(require_transforms(), 1);
|
|
29822
|
-
|
|
29823
|
-
// src/utils/rect-border-radius.ts
|
|
29824
|
-
var JSCAD_EPS = 1e-5;
|
|
29825
|
-
function clampRectBorderRadius(width10, height10, rawRadius) {
|
|
29826
|
-
if (typeof rawRadius !== "number" || !Number.isFinite(rawRadius)) {
|
|
29827
|
-
return 0;
|
|
29828
|
-
}
|
|
29829
|
-
if (rawRadius <= 0) {
|
|
29830
|
-
return 0;
|
|
29831
|
-
}
|
|
29832
|
-
const halfWidth = width10 / 2;
|
|
29833
|
-
const halfHeight = height10 / 2;
|
|
29834
|
-
const maxRadius = Math.min(halfWidth, halfHeight) - 2 * JSCAD_EPS;
|
|
29835
|
-
return Math.max(0, Math.min(rawRadius, maxRadius));
|
|
29836
|
-
}
|
|
29837
|
-
function extractRectBorderRadius(source) {
|
|
29838
|
-
if (!source || typeof source !== "object") return void 0;
|
|
29839
|
-
return source.corner_radius ?? source.cornerRadius ?? source.rect_pad_border_radius ?? source.rectPadBorderRadius ?? source.rect_border_radius ?? source.rectBorderRadius ?? void 0;
|
|
29840
|
-
}
|
|
29841
|
-
|
|
29842
29816
|
// src/geoms/create-hole-with-polygon-pad.ts
|
|
29843
29817
|
var import_primitives3 = __toESM(require_primitives(), 1);
|
|
29844
29818
|
var import_extrusions2 = __toESM(require_extrusions(), 1);
|
|
@@ -29930,6 +29904,33 @@ var createHoleWithPolygonPadHoleGeom = (hole, height10, options = {}) => {
|
|
|
29930
29904
|
return (0, import_primitives3.cylinder)({ center, radius: fallbackDiameter / 2, height: height10 });
|
|
29931
29905
|
};
|
|
29932
29906
|
|
|
29907
|
+
// src/geoms/plated-hole.ts
|
|
29908
|
+
var import_primitives4 = __toESM(require_primitives(), 1);
|
|
29909
|
+
var import_colors2 = __toESM(require_colors(), 1);
|
|
29910
|
+
var import_booleans2 = __toESM(require_booleans(), 1);
|
|
29911
|
+
var import_transforms3 = __toESM(require_transforms(), 1);
|
|
29912
|
+
var import_extrusions3 = __toESM(require_extrusions(), 1);
|
|
29913
|
+
var import_transforms4 = __toESM(require_transforms(), 1);
|
|
29914
|
+
|
|
29915
|
+
// src/utils/rect-border-radius.ts
|
|
29916
|
+
var JSCAD_EPS = 1e-5;
|
|
29917
|
+
function clampRectBorderRadius(width10, height10, rawRadius) {
|
|
29918
|
+
if (typeof rawRadius !== "number" || !Number.isFinite(rawRadius)) {
|
|
29919
|
+
return 0;
|
|
29920
|
+
}
|
|
29921
|
+
if (rawRadius <= 0) {
|
|
29922
|
+
return 0;
|
|
29923
|
+
}
|
|
29924
|
+
const halfWidth = width10 / 2;
|
|
29925
|
+
const halfHeight = height10 / 2;
|
|
29926
|
+
const maxRadius = Math.min(halfWidth, halfHeight) - 2 * JSCAD_EPS;
|
|
29927
|
+
return Math.max(0, Math.min(rawRadius, maxRadius));
|
|
29928
|
+
}
|
|
29929
|
+
function extractRectBorderRadius(source) {
|
|
29930
|
+
if (!source || typeof source !== "object") return void 0;
|
|
29931
|
+
return source.corner_radius ?? source.cornerRadius ?? source.rect_pad_border_radius ?? source.rectPadBorderRadius ?? source.rect_border_radius ?? source.rectBorderRadius ?? void 0;
|
|
29932
|
+
}
|
|
29933
|
+
|
|
29933
29934
|
// src/geoms/plated-hole.ts
|
|
29934
29935
|
var platedHoleLipHeight = 0.02;
|
|
29935
29936
|
var RECT_PAD_SEGMENTS = 64;
|
|
@@ -30513,9 +30514,6 @@ var platedHole = (plated_hole, ctx, options = {}) => {
|
|
|
30513
30514
|
}
|
|
30514
30515
|
};
|
|
30515
30516
|
|
|
30516
|
-
// src/BoardGeomBuilder.ts
|
|
30517
|
-
var import_extrusions4 = __toESM(require_extrusions(), 1);
|
|
30518
|
-
|
|
30519
30517
|
// src/geoms/via-geoms.ts
|
|
30520
30518
|
var import_booleans3 = __toESM(require_booleans(), 1);
|
|
30521
30519
|
var import_transforms5 = __toESM(require_transforms(), 1);
|
|
@@ -30589,22 +30587,8 @@ function createViaBoardDrill({
|
|
|
30589
30587
|
var PAD_ROUNDED_SEGMENTS = 64;
|
|
30590
30588
|
var BOARD_CLIP_Z_MARGIN = 1;
|
|
30591
30589
|
var BOARD_CLIP_XY_OUTSET = 0.05;
|
|
30592
|
-
var createCenteredRectPadGeom = (width10, height10, thickness, rectBorderRadius) => {
|
|
30593
|
-
const clampedRadius = clampRectBorderRadius(width10, height10, rectBorderRadius);
|
|
30594
|
-
if (clampedRadius <= 0) {
|
|
30595
|
-
return (0, import_primitives6.cuboid)({ center: [0, 0, 0], size: [width10, height10, thickness] });
|
|
30596
|
-
}
|
|
30597
|
-
const rect2d = (0, import_primitives6.roundedRectangle)({
|
|
30598
|
-
size: [width10, height10],
|
|
30599
|
-
roundRadius: clampedRadius,
|
|
30600
|
-
segments: PAD_ROUNDED_SEGMENTS
|
|
30601
|
-
});
|
|
30602
|
-
const extruded = (0, import_extrusions4.extrudeLinear)({ height: thickness }, rect2d);
|
|
30603
|
-
return (0, import_transforms6.translate)([0, 0, -thickness / 2], extruded);
|
|
30604
|
-
};
|
|
30605
30590
|
var buildStateOrder = [
|
|
30606
30591
|
"initializing",
|
|
30607
|
-
"processing_pads",
|
|
30608
30592
|
"processing_copper_pours",
|
|
30609
30593
|
"processing_plated_holes",
|
|
30610
30594
|
"processing_holes",
|
|
@@ -30618,13 +30602,11 @@ var BoardGeomBuilder = class {
|
|
|
30618
30602
|
board;
|
|
30619
30603
|
plated_holes;
|
|
30620
30604
|
holes;
|
|
30621
|
-
pads;
|
|
30622
30605
|
traces;
|
|
30623
30606
|
pcb_vias;
|
|
30624
30607
|
pcb_cutouts;
|
|
30625
30608
|
boardGeom = null;
|
|
30626
30609
|
platedHoleGeoms = [];
|
|
30627
|
-
padGeoms = [];
|
|
30628
30610
|
viaGeoms = [];
|
|
30629
30611
|
// Combined with platedHoleGeoms
|
|
30630
30612
|
copperPourGeoms = [];
|
|
@@ -30677,7 +30659,6 @@ var BoardGeomBuilder = class {
|
|
|
30677
30659
|
}
|
|
30678
30660
|
this.plated_holes = su4(circuitJson).pcb_plated_hole.list();
|
|
30679
30661
|
this.holes = su4(circuitJson).pcb_hole.list();
|
|
30680
|
-
this.pads = su4(circuitJson).pcb_smtpad.list();
|
|
30681
30662
|
this.traces = su4(circuitJson).pcb_trace.list();
|
|
30682
30663
|
this.pcb_vias = su4(circuitJson).pcb_via.list();
|
|
30683
30664
|
this.pcb_cutouts = su4(circuitJson).pcb_cutout.list();
|
|
@@ -30714,7 +30695,7 @@ var BoardGeomBuilder = class {
|
|
|
30714
30695
|
center: [this.board.center.x, this.board.center.y, 0]
|
|
30715
30696
|
});
|
|
30716
30697
|
}
|
|
30717
|
-
this.state = "
|
|
30698
|
+
this.state = "processing_copper_pours";
|
|
30718
30699
|
this.currentIndex = 0;
|
|
30719
30700
|
}
|
|
30720
30701
|
goToNextState() {
|
|
@@ -30745,14 +30726,6 @@ var BoardGeomBuilder = class {
|
|
|
30745
30726
|
this.goToNextState();
|
|
30746
30727
|
}
|
|
30747
30728
|
break;
|
|
30748
|
-
case "processing_pads":
|
|
30749
|
-
if (this.currentIndex < this.pads.length) {
|
|
30750
|
-
this.processPad(this.pads[this.currentIndex]);
|
|
30751
|
-
this.currentIndex++;
|
|
30752
|
-
} else {
|
|
30753
|
-
this.goToNextState();
|
|
30754
|
-
}
|
|
30755
|
-
break;
|
|
30756
30729
|
case "processing_copper_pours":
|
|
30757
30730
|
this.goToNextState();
|
|
30758
30731
|
break;
|
|
@@ -30874,9 +30847,6 @@ var BoardGeomBuilder = class {
|
|
|
30874
30847
|
if (!opts.dontCutBoard) {
|
|
30875
30848
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, cyGeom);
|
|
30876
30849
|
}
|
|
30877
|
-
this.padGeoms = this.padGeoms.map(
|
|
30878
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, cyGeom))
|
|
30879
|
-
);
|
|
30880
30850
|
const platedHoleGeom = platedHole(ph, this.ctx, {
|
|
30881
30851
|
clipGeom: this.boardClipGeom
|
|
30882
30852
|
});
|
|
@@ -30914,9 +30884,6 @@ var BoardGeomBuilder = class {
|
|
|
30914
30884
|
if (!opts.dontCutBoard) {
|
|
30915
30885
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, pillHole);
|
|
30916
30886
|
}
|
|
30917
|
-
this.padGeoms = this.padGeoms.map(
|
|
30918
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, pillHole))
|
|
30919
|
-
);
|
|
30920
30887
|
const platedHoleGeom = platedHole(ph, this.ctx, {
|
|
30921
30888
|
clipGeom: this.boardClipGeom
|
|
30922
30889
|
});
|
|
@@ -30970,9 +30937,6 @@ var BoardGeomBuilder = class {
|
|
|
30970
30937
|
if (!opts.dontCutBoard) {
|
|
30971
30938
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, pillHole);
|
|
30972
30939
|
}
|
|
30973
|
-
this.padGeoms = this.padGeoms.map(
|
|
30974
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, pillHole))
|
|
30975
|
-
);
|
|
30976
30940
|
const platedHoleGeom = platedHole(ph, this.ctx, {
|
|
30977
30941
|
clipGeom: this.boardClipGeom
|
|
30978
30942
|
});
|
|
@@ -31017,9 +30981,6 @@ var BoardGeomBuilder = class {
|
|
|
31017
30981
|
if (!opts.dontCutBoard) {
|
|
31018
30982
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, pillHole);
|
|
31019
30983
|
}
|
|
31020
|
-
this.padGeoms = this.padGeoms.map(
|
|
31021
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, pillHole))
|
|
31022
|
-
);
|
|
31023
30984
|
const platedHoleGeom = platedHole(ph, this.ctx, {
|
|
31024
30985
|
clipGeom: this.boardClipGeom
|
|
31025
30986
|
});
|
|
@@ -31040,9 +31001,6 @@ var BoardGeomBuilder = class {
|
|
|
31040
31001
|
if (!opts.dontCutBoard) {
|
|
31041
31002
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, boardHole);
|
|
31042
31003
|
}
|
|
31043
|
-
this.padGeoms = this.padGeoms.map(
|
|
31044
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, boardHole))
|
|
31045
|
-
);
|
|
31046
31004
|
this.platedHoleGeoms = this.platedHoleGeoms.map(
|
|
31047
31005
|
(phg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(phg, copperHole))
|
|
31048
31006
|
);
|
|
@@ -31063,9 +31021,6 @@ var BoardGeomBuilder = class {
|
|
|
31063
31021
|
height: holeDepth
|
|
31064
31022
|
});
|
|
31065
31023
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, cyGeom);
|
|
31066
|
-
this.padGeoms = this.padGeoms.map(
|
|
31067
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, cyGeom))
|
|
31068
|
-
);
|
|
31069
31024
|
const copperCut = (0, import_primitives6.cylinder)({
|
|
31070
31025
|
center: [hole.x, hole.y, 0],
|
|
31071
31026
|
radius: hole.hole_diameter / 2 + M / 2,
|
|
@@ -31126,9 +31081,6 @@ var BoardGeomBuilder = class {
|
|
|
31126
31081
|
if (boardHole) {
|
|
31127
31082
|
const positionedBoardHole = (0, import_transforms6.translate)([hole.x, hole.y, 0], boardHole);
|
|
31128
31083
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, positionedBoardHole);
|
|
31129
|
-
this.padGeoms = this.padGeoms.map(
|
|
31130
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, positionedBoardHole))
|
|
31131
|
-
);
|
|
31132
31084
|
}
|
|
31133
31085
|
if (copperCut) {
|
|
31134
31086
|
const positionedCopperCut = (0, import_transforms6.translate)([hole.x, hole.y, 0], copperCut);
|
|
@@ -31138,53 +31090,6 @@ var BoardGeomBuilder = class {
|
|
|
31138
31090
|
}
|
|
31139
31091
|
}
|
|
31140
31092
|
}
|
|
31141
|
-
processPad(pad2) {
|
|
31142
|
-
const layerSign = pad2.layer === "bottom" ? -1 : 1;
|
|
31143
|
-
const zPos = layerSign * this.ctx.pcbThickness / 2 + layerSign * BOARD_SURFACE_OFFSET.copper;
|
|
31144
|
-
const rectBorderRadius = extractRectBorderRadius(pad2);
|
|
31145
|
-
if (pad2.shape === "rect") {
|
|
31146
|
-
const basePadGeom = createCenteredRectPadGeom(
|
|
31147
|
-
pad2.width,
|
|
31148
|
-
pad2.height,
|
|
31149
|
-
M,
|
|
31150
|
-
rectBorderRadius
|
|
31151
|
-
);
|
|
31152
|
-
const positionedPadGeom = (0, import_transforms6.translate)([pad2.x, pad2.y, zPos], basePadGeom);
|
|
31153
|
-
let finalPadGeom = positionedPadGeom;
|
|
31154
|
-
if (this.boardClipGeom) {
|
|
31155
|
-
finalPadGeom = (0, import_booleans4.intersect)(this.boardClipGeom, finalPadGeom);
|
|
31156
|
-
}
|
|
31157
|
-
finalPadGeom = (0, import_colors3.colorize)(colors.copper, finalPadGeom);
|
|
31158
|
-
this.padGeoms.push(finalPadGeom);
|
|
31159
|
-
} else if (pad2.shape === "rotated_rect") {
|
|
31160
|
-
let basePadGeom = createCenteredRectPadGeom(
|
|
31161
|
-
pad2.width,
|
|
31162
|
-
pad2.height,
|
|
31163
|
-
M,
|
|
31164
|
-
rectBorderRadius
|
|
31165
|
-
);
|
|
31166
|
-
const rotationRadians = pad2.ccw_rotation * Math.PI / 180;
|
|
31167
|
-
basePadGeom = (0, import_transforms6.rotateZ)(rotationRadians, basePadGeom);
|
|
31168
|
-
const positionedPadGeom = (0, import_transforms6.translate)([pad2.x, pad2.y, zPos], basePadGeom);
|
|
31169
|
-
let finalPadGeom = positionedPadGeom;
|
|
31170
|
-
if (this.boardClipGeom) {
|
|
31171
|
-
finalPadGeom = (0, import_booleans4.intersect)(this.boardClipGeom, finalPadGeom);
|
|
31172
|
-
}
|
|
31173
|
-
finalPadGeom = (0, import_colors3.colorize)(colors.copper, finalPadGeom);
|
|
31174
|
-
this.padGeoms.push(finalPadGeom);
|
|
31175
|
-
} else if (pad2.shape === "circle") {
|
|
31176
|
-
let padGeom = (0, import_primitives6.cylinder)({
|
|
31177
|
-
center: [pad2.x, pad2.y, zPos],
|
|
31178
|
-
radius: pad2.radius,
|
|
31179
|
-
height: M
|
|
31180
|
-
});
|
|
31181
|
-
if (this.boardClipGeom) {
|
|
31182
|
-
padGeom = (0, import_booleans4.intersect)(this.boardClipGeom, padGeom);
|
|
31183
|
-
}
|
|
31184
|
-
padGeom = (0, import_colors3.colorize)(colors.copper, padGeom);
|
|
31185
|
-
this.padGeoms.push(padGeom);
|
|
31186
|
-
}
|
|
31187
|
-
}
|
|
31188
31093
|
processVia(via) {
|
|
31189
31094
|
if (!this.boardGeom) return;
|
|
31190
31095
|
if (typeof via.outer_diameter === "number" && typeof via.hole_diameter === "number") {
|
|
@@ -31210,9 +31115,6 @@ var BoardGeomBuilder = class {
|
|
|
31210
31115
|
thickness: this.ctx.pcbThickness
|
|
31211
31116
|
});
|
|
31212
31117
|
this.boardGeom = (0, import_booleans4.subtract)(this.boardGeom, viaDrill);
|
|
31213
|
-
this.padGeoms = this.padGeoms.map(
|
|
31214
|
-
(pg) => (0, import_colors3.colorize)(colors.copper, (0, import_booleans4.subtract)(pg, viaDrill))
|
|
31215
|
-
);
|
|
31216
31118
|
}
|
|
31217
31119
|
}
|
|
31218
31120
|
finalize() {
|
|
@@ -31222,7 +31124,6 @@ var BoardGeomBuilder = class {
|
|
|
31222
31124
|
this.finalGeoms = [
|
|
31223
31125
|
this.boardGeom,
|
|
31224
31126
|
...this.platedHoleGeoms,
|
|
31225
|
-
...this.padGeoms,
|
|
31226
31127
|
...this.viaGeoms,
|
|
31227
31128
|
...this.copperPourGeoms
|
|
31228
31129
|
];
|
|
@@ -31559,11 +31460,11 @@ var ThreeErrorBoundary = class extends React11.Component {
|
|
|
31559
31460
|
};
|
|
31560
31461
|
|
|
31561
31462
|
// src/three-components/JscadBoardTextures.tsx
|
|
31562
|
-
import { su as
|
|
31463
|
+
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
31563
31464
|
import { useEffect as useEffect23, useMemo as useMemo19 } from "react";
|
|
31564
31465
|
|
|
31565
31466
|
// src/textures/create-combined-board-textures.ts
|
|
31566
|
-
import * as
|
|
31467
|
+
import * as THREE26 from "three";
|
|
31567
31468
|
|
|
31568
31469
|
// src/utils/copper-text-texture.ts
|
|
31569
31470
|
var import_text = __toESM(require_text(), 1);
|
|
@@ -31700,10 +31601,10 @@ peg$SyntaxError.prototype.format = function(sources) {
|
|
|
31700
31601
|
if (src) {
|
|
31701
31602
|
var e = this.location.end;
|
|
31702
31603
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
31703
|
-
var
|
|
31704
|
-
var last = s.line === e.line ? e.column :
|
|
31604
|
+
var line = src[s.line - 1];
|
|
31605
|
+
var last = s.line === e.line ? e.column : line.length + 1;
|
|
31705
31606
|
var hatLen = last - s.column || 1;
|
|
31706
|
-
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " +
|
|
31607
|
+
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
31707
31608
|
} else {
|
|
31708
31609
|
str += "\n at " + loc;
|
|
31709
31610
|
}
|
|
@@ -32077,9 +31978,118 @@ function createCopperTextTextureForLayer({
|
|
|
32077
31978
|
return texture;
|
|
32078
31979
|
}
|
|
32079
31980
|
|
|
32080
|
-
// src/utils/
|
|
32081
|
-
import * as THREE20 from "three";
|
|
31981
|
+
// src/utils/pad-texture.ts
|
|
32082
31982
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
31983
|
+
import * as THREE20 from "three";
|
|
31984
|
+
function createPadTextureForLayer({
|
|
31985
|
+
layer,
|
|
31986
|
+
circuitJson,
|
|
31987
|
+
boardData,
|
|
31988
|
+
copperColor,
|
|
31989
|
+
traceTextureResolution
|
|
31990
|
+
}) {
|
|
31991
|
+
const pcbSmtPads = su5(circuitJson).pcb_smtpad.list();
|
|
31992
|
+
const smtPadsOnLayer = pcbSmtPads.filter((pad2) => pad2.layer === layer);
|
|
31993
|
+
if (smtPadsOnLayer.length === 0) return null;
|
|
31994
|
+
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
31995
|
+
const canvas = document.createElement("canvas");
|
|
31996
|
+
const canvasWidth = Math.floor(
|
|
31997
|
+
boardOutlineBounds.width * traceTextureResolution
|
|
31998
|
+
);
|
|
31999
|
+
const canvasHeight = Math.floor(
|
|
32000
|
+
boardOutlineBounds.height * traceTextureResolution
|
|
32001
|
+
);
|
|
32002
|
+
canvas.width = canvasWidth;
|
|
32003
|
+
canvas.height = canvasHeight;
|
|
32004
|
+
const ctx = canvas.getContext("2d");
|
|
32005
|
+
if (!ctx) return null;
|
|
32006
|
+
if (layer === "bottom") {
|
|
32007
|
+
ctx.translate(0, canvasHeight);
|
|
32008
|
+
ctx.scale(1, -1);
|
|
32009
|
+
}
|
|
32010
|
+
const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
|
|
32011
|
+
const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
|
|
32012
|
+
ctx.fillStyle = copperColor;
|
|
32013
|
+
smtPadsOnLayer.forEach((pad2) => {
|
|
32014
|
+
if (pad2.shape === "polygon" && pad2.points) {
|
|
32015
|
+
ctx.beginPath();
|
|
32016
|
+
pad2.points.forEach((point, index2) => {
|
|
32017
|
+
const px = canvasXFromPcb(point.x);
|
|
32018
|
+
const py = canvasYFromPcb(point.y);
|
|
32019
|
+
if (index2 === 0) {
|
|
32020
|
+
ctx.moveTo(px, py);
|
|
32021
|
+
} else {
|
|
32022
|
+
ctx.lineTo(px, py);
|
|
32023
|
+
}
|
|
32024
|
+
});
|
|
32025
|
+
ctx.closePath();
|
|
32026
|
+
ctx.fill();
|
|
32027
|
+
return;
|
|
32028
|
+
}
|
|
32029
|
+
if (pad2.x === void 0 || pad2.y === void 0) return;
|
|
32030
|
+
const x = pad2.x;
|
|
32031
|
+
const y = pad2.y;
|
|
32032
|
+
const canvasX = canvasXFromPcb(x);
|
|
32033
|
+
const canvasY = canvasYFromPcb(y);
|
|
32034
|
+
if (pad2.shape === "rect") {
|
|
32035
|
+
const width10 = pad2.width * traceTextureResolution;
|
|
32036
|
+
const height10 = pad2.height * traceTextureResolution;
|
|
32037
|
+
const rawRadius = extractRectBorderRadius(pad2);
|
|
32038
|
+
const borderRadius = clampRectBorderRadius(
|
|
32039
|
+
pad2.width,
|
|
32040
|
+
pad2.height,
|
|
32041
|
+
rawRadius
|
|
32042
|
+
) * traceTextureResolution;
|
|
32043
|
+
if (borderRadius > 0) {
|
|
32044
|
+
ctx.beginPath();
|
|
32045
|
+
ctx.roundRect(
|
|
32046
|
+
canvasX - width10 / 2,
|
|
32047
|
+
canvasY - height10 / 2,
|
|
32048
|
+
width10,
|
|
32049
|
+
height10,
|
|
32050
|
+
borderRadius
|
|
32051
|
+
);
|
|
32052
|
+
ctx.fill();
|
|
32053
|
+
} else {
|
|
32054
|
+
ctx.fillRect(canvasX - width10 / 2, canvasY - height10 / 2, width10, height10);
|
|
32055
|
+
}
|
|
32056
|
+
} else if (pad2.shape === "circle") {
|
|
32057
|
+
const radius = (pad2.radius ?? pad2.width / 2) * traceTextureResolution;
|
|
32058
|
+
ctx.beginPath();
|
|
32059
|
+
ctx.arc(canvasX, canvasY, radius, 0, 2 * Math.PI);
|
|
32060
|
+
ctx.fill();
|
|
32061
|
+
} else if (pad2.shape === "rotated_rect") {
|
|
32062
|
+
const width10 = pad2.width * traceTextureResolution;
|
|
32063
|
+
const height10 = pad2.height * traceTextureResolution;
|
|
32064
|
+
const rawRadius = extractRectBorderRadius(pad2);
|
|
32065
|
+
const borderRadius = clampRectBorderRadius(
|
|
32066
|
+
pad2.width,
|
|
32067
|
+
pad2.height,
|
|
32068
|
+
rawRadius
|
|
32069
|
+
) * traceTextureResolution;
|
|
32070
|
+
const ccwRotation = pad2.ccw_rotation || 0;
|
|
32071
|
+
const rotation = -ccwRotation * (Math.PI / 180);
|
|
32072
|
+
ctx.save();
|
|
32073
|
+
ctx.translate(canvasX, canvasY);
|
|
32074
|
+
ctx.rotate(rotation);
|
|
32075
|
+
ctx.beginPath();
|
|
32076
|
+
ctx.roundRect(-width10 / 2, -height10 / 2, width10, height10, borderRadius);
|
|
32077
|
+
ctx.fill();
|
|
32078
|
+
ctx.restore();
|
|
32079
|
+
}
|
|
32080
|
+
});
|
|
32081
|
+
const texture = new THREE20.CanvasTexture(canvas);
|
|
32082
|
+
texture.generateMipmaps = true;
|
|
32083
|
+
texture.minFilter = THREE20.LinearMipmapLinearFilter;
|
|
32084
|
+
texture.magFilter = THREE20.LinearFilter;
|
|
32085
|
+
texture.anisotropy = 16;
|
|
32086
|
+
texture.needsUpdate = true;
|
|
32087
|
+
return texture;
|
|
32088
|
+
}
|
|
32089
|
+
|
|
32090
|
+
// src/utils/panel-outline-texture.ts
|
|
32091
|
+
import * as THREE21 from "three";
|
|
32092
|
+
import { su as su6 } from "@tscircuit/circuit-json-util";
|
|
32083
32093
|
function createPanelOutlineTextureForLayer({
|
|
32084
32094
|
layer,
|
|
32085
32095
|
circuitJson,
|
|
@@ -32087,7 +32097,7 @@ function createPanelOutlineTextureForLayer({
|
|
|
32087
32097
|
outlineColor = "black",
|
|
32088
32098
|
traceTextureResolution
|
|
32089
32099
|
}) {
|
|
32090
|
-
const boardsInPanel =
|
|
32100
|
+
const boardsInPanel = su6(circuitJson).pcb_board.list().filter((b) => b.pcb_panel_id === panelData.pcb_board_id);
|
|
32091
32101
|
if (boardsInPanel.length === 0) {
|
|
32092
32102
|
return null;
|
|
32093
32103
|
}
|
|
@@ -32134,10 +32144,10 @@ function createPanelOutlineTextureForLayer({
|
|
|
32134
32144
|
);
|
|
32135
32145
|
}
|
|
32136
32146
|
});
|
|
32137
|
-
const texture = new
|
|
32147
|
+
const texture = new THREE21.CanvasTexture(canvas);
|
|
32138
32148
|
texture.generateMipmaps = true;
|
|
32139
|
-
texture.minFilter =
|
|
32140
|
-
texture.magFilter =
|
|
32149
|
+
texture.minFilter = THREE21.LinearMipmapLinearFilter;
|
|
32150
|
+
texture.magFilter = THREE21.LinearFilter;
|
|
32141
32151
|
texture.anisotropy = 16;
|
|
32142
32152
|
texture.needsUpdate = true;
|
|
32143
32153
|
return texture;
|
|
@@ -32145,8 +32155,8 @@ function createPanelOutlineTextureForLayer({
|
|
|
32145
32155
|
|
|
32146
32156
|
// src/utils/silkscreen-texture.ts
|
|
32147
32157
|
var import_text2 = __toESM(require_text(), 1);
|
|
32148
|
-
import * as
|
|
32149
|
-
import { su as
|
|
32158
|
+
import * as THREE22 from "three";
|
|
32159
|
+
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
32150
32160
|
|
|
32151
32161
|
// src/utils/units.ts
|
|
32152
32162
|
var MM_PER_INCH = 25.4;
|
|
@@ -32217,13 +32227,13 @@ function createSilkscreenTextureForLayer({
|
|
|
32217
32227
|
silkscreenColor = "rgb(255,255,255)",
|
|
32218
32228
|
traceTextureResolution
|
|
32219
32229
|
}) {
|
|
32220
|
-
const pcbSilkscreenTexts =
|
|
32221
|
-
const pcbSilkscreenPaths =
|
|
32222
|
-
const pcbSilkscreenLines =
|
|
32223
|
-
const pcbSilkscreenRects =
|
|
32224
|
-
const pcbSilkscreenCircles =
|
|
32225
|
-
const pcbFabricationNoteRects =
|
|
32226
|
-
const pcbNoteLines =
|
|
32230
|
+
const pcbSilkscreenTexts = su7(circuitJson).pcb_silkscreen_text.list();
|
|
32231
|
+
const pcbSilkscreenPaths = su7(circuitJson).pcb_silkscreen_path.list();
|
|
32232
|
+
const pcbSilkscreenLines = su7(circuitJson).pcb_silkscreen_line.list();
|
|
32233
|
+
const pcbSilkscreenRects = su7(circuitJson).pcb_silkscreen_rect.list();
|
|
32234
|
+
const pcbSilkscreenCircles = su7(circuitJson).pcb_silkscreen_circle.list();
|
|
32235
|
+
const pcbFabricationNoteRects = su7(circuitJson).pcb_fabrication_note_rect.list();
|
|
32236
|
+
const pcbNoteLines = su7(circuitJson).pcb_note_line.list();
|
|
32227
32237
|
const textsOnLayer = pcbSilkscreenTexts.filter((t) => t.layer === layer);
|
|
32228
32238
|
const pathsOnLayer = pcbSilkscreenPaths.filter((p) => p.layer === layer);
|
|
32229
32239
|
const linesOnLayer = pcbSilkscreenLines.filter((l) => l.layer === layer);
|
|
@@ -32592,18 +32602,18 @@ function createSilkscreenTextureForLayer({
|
|
|
32592
32602
|
ctx.stroke();
|
|
32593
32603
|
});
|
|
32594
32604
|
});
|
|
32595
|
-
const texture = new
|
|
32605
|
+
const texture = new THREE22.CanvasTexture(canvas);
|
|
32596
32606
|
texture.generateMipmaps = true;
|
|
32597
|
-
texture.minFilter =
|
|
32598
|
-
texture.magFilter =
|
|
32607
|
+
texture.minFilter = THREE22.LinearMipmapLinearFilter;
|
|
32608
|
+
texture.magFilter = THREE22.LinearFilter;
|
|
32599
32609
|
texture.anisotropy = 16;
|
|
32600
32610
|
texture.needsUpdate = true;
|
|
32601
32611
|
return texture;
|
|
32602
32612
|
}
|
|
32603
32613
|
|
|
32604
32614
|
// src/utils/soldermask-texture.ts
|
|
32605
|
-
import { su as
|
|
32606
|
-
import * as
|
|
32615
|
+
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
32616
|
+
import * as THREE23 from "three";
|
|
32607
32617
|
function createSoldermaskTextureForLayer({
|
|
32608
32618
|
layer,
|
|
32609
32619
|
circuitJson,
|
|
@@ -32645,7 +32655,7 @@ function createSoldermaskTextureForLayer({
|
|
|
32645
32655
|
}
|
|
32646
32656
|
ctx.globalCompositeOperation = "destination-out";
|
|
32647
32657
|
ctx.fillStyle = "black";
|
|
32648
|
-
const pcbSmtPads =
|
|
32658
|
+
const pcbSmtPads = su8(circuitJson).pcb_smtpad.list();
|
|
32649
32659
|
const smtPadsOnLayer = pcbSmtPads.filter((pad2) => pad2.layer === layer);
|
|
32650
32660
|
smtPadsOnLayer.forEach((pad2) => {
|
|
32651
32661
|
if (pad2.shape === "polygon" && pad2.points) {
|
|
@@ -32739,7 +32749,7 @@ function createSoldermaskTextureForLayer({
|
|
|
32739
32749
|
ctx.restore();
|
|
32740
32750
|
}
|
|
32741
32751
|
});
|
|
32742
|
-
const pcbVias =
|
|
32752
|
+
const pcbVias = su8(circuitJson).pcb_via.list();
|
|
32743
32753
|
pcbVias.forEach((via) => {
|
|
32744
32754
|
const canvasX = canvasXFromPcb(via.x);
|
|
32745
32755
|
const canvasY = canvasYFromPcb(via.y);
|
|
@@ -32748,7 +32758,7 @@ function createSoldermaskTextureForLayer({
|
|
|
32748
32758
|
ctx.arc(canvasX, canvasY, canvasRadius, 0, 2 * Math.PI);
|
|
32749
32759
|
ctx.fill();
|
|
32750
32760
|
});
|
|
32751
|
-
const pcbPlatedHoles =
|
|
32761
|
+
const pcbPlatedHoles = su8(circuitJson).pcb_plated_hole.list();
|
|
32752
32762
|
pcbPlatedHoles.forEach((hole) => {
|
|
32753
32763
|
if (!hole.layers?.includes(layer)) return;
|
|
32754
32764
|
const x = hole.x;
|
|
@@ -32989,7 +32999,7 @@ function createSoldermaskTextureForLayer({
|
|
|
32989
32999
|
}
|
|
32990
33000
|
}
|
|
32991
33001
|
});
|
|
32992
|
-
const pcbHoles =
|
|
33002
|
+
const pcbHoles = su8(circuitJson).pcb_hole.list();
|
|
32993
33003
|
pcbHoles.forEach((hole) => {
|
|
32994
33004
|
const x = hole.x;
|
|
32995
33005
|
const y = hole.y;
|
|
@@ -33049,7 +33059,7 @@ function createSoldermaskTextureForLayer({
|
|
|
33049
33059
|
ctx.fill();
|
|
33050
33060
|
}
|
|
33051
33061
|
});
|
|
33052
|
-
const pcbCopperPours =
|
|
33062
|
+
const pcbCopperPours = su8(circuitJson).pcb_copper_pour.list();
|
|
33053
33063
|
pcbCopperPours.forEach((pour) => {
|
|
33054
33064
|
if (pour.layer !== layer) return;
|
|
33055
33065
|
if (pour.covered_with_solder_mask !== false) return;
|
|
@@ -33074,7 +33084,7 @@ function createSoldermaskTextureForLayer({
|
|
|
33074
33084
|
ctx.fill();
|
|
33075
33085
|
}
|
|
33076
33086
|
});
|
|
33077
|
-
const pcbCutouts =
|
|
33087
|
+
const pcbCutouts = su8(circuitJson).pcb_cutout.list();
|
|
33078
33088
|
pcbCutouts.forEach((cutout) => {
|
|
33079
33089
|
switch (cutout.shape) {
|
|
33080
33090
|
case "rect": {
|
|
@@ -33168,18 +33178,18 @@ function createSoldermaskTextureForLayer({
|
|
|
33168
33178
|
}
|
|
33169
33179
|
});
|
|
33170
33180
|
ctx.globalCompositeOperation = "source-over";
|
|
33171
|
-
const texture = new
|
|
33181
|
+
const texture = new THREE23.CanvasTexture(canvas);
|
|
33172
33182
|
texture.generateMipmaps = true;
|
|
33173
|
-
texture.minFilter =
|
|
33174
|
-
texture.magFilter =
|
|
33183
|
+
texture.minFilter = THREE23.LinearMipmapLinearFilter;
|
|
33184
|
+
texture.magFilter = THREE23.LinearFilter;
|
|
33175
33185
|
texture.anisotropy = 16;
|
|
33176
33186
|
texture.needsUpdate = true;
|
|
33177
33187
|
return texture;
|
|
33178
33188
|
}
|
|
33179
33189
|
|
|
33180
33190
|
// src/utils/trace-texture.ts
|
|
33181
|
-
import * as
|
|
33182
|
-
import { su as
|
|
33191
|
+
import * as THREE24 from "three";
|
|
33192
|
+
import { su as su9 } from "@tscircuit/circuit-json-util";
|
|
33183
33193
|
function isWireRoutePoint(point) {
|
|
33184
33194
|
return point && point.route_type === "wire" && typeof point.layer === "string" && typeof point.width === "number";
|
|
33185
33195
|
}
|
|
@@ -33190,9 +33200,9 @@ function createTraceTextureForLayer({
|
|
|
33190
33200
|
traceColor,
|
|
33191
33201
|
traceTextureResolution
|
|
33192
33202
|
}) {
|
|
33193
|
-
const pcbTraces =
|
|
33194
|
-
const allPcbVias =
|
|
33195
|
-
const allPcbPlatedHoles =
|
|
33203
|
+
const pcbTraces = su9(circuitJson).pcb_trace.list();
|
|
33204
|
+
const allPcbVias = su9(circuitJson).pcb_via.list();
|
|
33205
|
+
const allPcbPlatedHoles = su9(
|
|
33196
33206
|
circuitJson
|
|
33197
33207
|
).pcb_plated_hole.list();
|
|
33198
33208
|
const tracesOnLayer = pcbTraces.filter(
|
|
@@ -33291,17 +33301,17 @@ function createTraceTextureForLayer({
|
|
|
33291
33301
|
}
|
|
33292
33302
|
});
|
|
33293
33303
|
ctx.globalCompositeOperation = "source-over";
|
|
33294
|
-
const texture = new
|
|
33304
|
+
const texture = new THREE24.CanvasTexture(canvas);
|
|
33295
33305
|
texture.generateMipmaps = true;
|
|
33296
|
-
texture.minFilter =
|
|
33297
|
-
texture.magFilter =
|
|
33306
|
+
texture.minFilter = THREE24.LinearMipmapLinearFilter;
|
|
33307
|
+
texture.magFilter = THREE24.LinearFilter;
|
|
33298
33308
|
texture.anisotropy = 16;
|
|
33299
33309
|
texture.needsUpdate = true;
|
|
33300
33310
|
return texture;
|
|
33301
33311
|
}
|
|
33302
33312
|
|
|
33303
33313
|
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
33304
|
-
import * as
|
|
33314
|
+
import * as THREE25 from "three";
|
|
33305
33315
|
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
33306
33316
|
|
|
33307
33317
|
// src/geoms/brep-converter.ts
|
|
@@ -33507,10 +33517,10 @@ function createCopperPourTextureForLayer({
|
|
|
33507
33517
|
ctx.fillStyle = copperColor;
|
|
33508
33518
|
drawBrepShape({ ctx, pour, canvasXFromPcb, canvasYFromPcb });
|
|
33509
33519
|
}
|
|
33510
|
-
const texture = new
|
|
33520
|
+
const texture = new THREE25.CanvasTexture(canvas);
|
|
33511
33521
|
texture.generateMipmaps = true;
|
|
33512
|
-
texture.minFilter =
|
|
33513
|
-
texture.magFilter =
|
|
33522
|
+
texture.minFilter = THREE25.LinearMipmapLinearFilter;
|
|
33523
|
+
texture.magFilter = THREE25.LinearFilter;
|
|
33514
33524
|
texture.anisotropy = 16;
|
|
33515
33525
|
texture.needsUpdate = true;
|
|
33516
33526
|
return texture;
|
|
@@ -33548,10 +33558,10 @@ var createCombinedTexture = ({
|
|
|
33548
33558
|
const image = texture.image;
|
|
33549
33559
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
33550
33560
|
});
|
|
33551
|
-
const combinedTexture = new
|
|
33561
|
+
const combinedTexture = new THREE26.CanvasTexture(canvas);
|
|
33552
33562
|
combinedTexture.generateMipmaps = true;
|
|
33553
|
-
combinedTexture.minFilter =
|
|
33554
|
-
combinedTexture.magFilter =
|
|
33563
|
+
combinedTexture.minFilter = THREE26.LinearMipmapLinearFilter;
|
|
33564
|
+
combinedTexture.magFilter = THREE26.LinearFilter;
|
|
33555
33565
|
combinedTexture.anisotropy = 16;
|
|
33556
33566
|
combinedTexture.needsUpdate = true;
|
|
33557
33567
|
return combinedTexture;
|
|
@@ -33601,6 +33611,13 @@ function createCombinedBoardTextures({
|
|
|
33601
33611
|
boardData,
|
|
33602
33612
|
traceTextureResolution
|
|
33603
33613
|
}) : null;
|
|
33614
|
+
const padTexture = showCopper ? createPadTextureForLayer({
|
|
33615
|
+
layer,
|
|
33616
|
+
circuitJson,
|
|
33617
|
+
boardData,
|
|
33618
|
+
copperColor,
|
|
33619
|
+
traceTextureResolution
|
|
33620
|
+
}) : null;
|
|
33604
33621
|
const silkscreenTexture = showSilkscreen ? createSilkscreenTextureForLayer({
|
|
33605
33622
|
layer,
|
|
33606
33623
|
circuitJson,
|
|
@@ -33620,6 +33637,7 @@ function createCombinedBoardTextures({
|
|
|
33620
33637
|
copperPourTexture,
|
|
33621
33638
|
traceTexture,
|
|
33622
33639
|
copperTextTexture,
|
|
33640
|
+
padTexture,
|
|
33623
33641
|
silkscreenTexture,
|
|
33624
33642
|
panelOutlineTexture
|
|
33625
33643
|
],
|
|
@@ -33627,14 +33645,15 @@ function createCombinedBoardTextures({
|
|
|
33627
33645
|
traceTextureResolution
|
|
33628
33646
|
});
|
|
33629
33647
|
};
|
|
33648
|
+
const numLayers = boardData.num_layers ?? 2;
|
|
33630
33649
|
return {
|
|
33631
33650
|
topBoard: buildForLayer("top"),
|
|
33632
|
-
bottomBoard: buildForLayer("bottom")
|
|
33651
|
+
bottomBoard: numLayers < 2 ? null : buildForLayer("bottom")
|
|
33633
33652
|
};
|
|
33634
33653
|
}
|
|
33635
33654
|
|
|
33636
33655
|
// src/textures/create-three-texture-meshes.ts
|
|
33637
|
-
import * as
|
|
33656
|
+
import * as THREE27 from "three";
|
|
33638
33657
|
function createTexturePlane(config, boardData) {
|
|
33639
33658
|
const {
|
|
33640
33659
|
texture,
|
|
@@ -33646,14 +33665,14 @@ function createTexturePlane(config, boardData) {
|
|
|
33646
33665
|
} = config;
|
|
33647
33666
|
if (!texture) return null;
|
|
33648
33667
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
33649
|
-
const planeGeom = new
|
|
33668
|
+
const planeGeom = new THREE27.PlaneGeometry(
|
|
33650
33669
|
boardOutlineBounds.width,
|
|
33651
33670
|
boardOutlineBounds.height
|
|
33652
33671
|
);
|
|
33653
|
-
const material = new
|
|
33672
|
+
const material = new THREE27.MeshBasicMaterial({
|
|
33654
33673
|
map: texture,
|
|
33655
33674
|
transparent: true,
|
|
33656
|
-
side:
|
|
33675
|
+
side: THREE27.DoubleSide,
|
|
33657
33676
|
depthWrite: false,
|
|
33658
33677
|
polygonOffset: usePolygonOffset,
|
|
33659
33678
|
polygonOffsetFactor: usePolygonOffset ? -4 : 0,
|
|
@@ -33661,7 +33680,7 @@ function createTexturePlane(config, boardData) {
|
|
|
33661
33680
|
polygonOffsetUnits: usePolygonOffset ? -4 : 0,
|
|
33662
33681
|
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
33663
33682
|
});
|
|
33664
|
-
const mesh = new
|
|
33683
|
+
const mesh = new THREE27.Mesh(planeGeom, material);
|
|
33665
33684
|
mesh.position.set(
|
|
33666
33685
|
boardOutlineBounds.centerX,
|
|
33667
33686
|
boardOutlineBounds.centerY,
|
|
@@ -33705,7 +33724,7 @@ function createTextureMeshes(textures, boardData, pcbThickness, isFaux = false)
|
|
|
33705
33724
|
}
|
|
33706
33725
|
|
|
33707
33726
|
// src/three-components/JscadBoardTextures.tsx
|
|
33708
|
-
import * as
|
|
33727
|
+
import * as THREE28 from "three";
|
|
33709
33728
|
|
|
33710
33729
|
// src/utils/layer-texture-resolution.ts
|
|
33711
33730
|
var DEFAULT_MAX_TEXTURE_PIXELS = 4e6;
|
|
@@ -33746,7 +33765,7 @@ function JscadBoardTextures({
|
|
|
33746
33765
|
const panels = circuitJson.filter(
|
|
33747
33766
|
(e) => e.type === "pcb_panel"
|
|
33748
33767
|
);
|
|
33749
|
-
const boards =
|
|
33768
|
+
const boards = su10(circuitJson).pcb_board.list();
|
|
33750
33769
|
if (panels.length > 0) {
|
|
33751
33770
|
const panel = panels[0];
|
|
33752
33771
|
const firstBoardInPanel = boards.find(
|
|
@@ -33801,7 +33820,7 @@ function JscadBoardTextures({
|
|
|
33801
33820
|
const typedMaterial = material;
|
|
33802
33821
|
for (const prop of textureProps) {
|
|
33803
33822
|
const texture = typedMaterial[prop];
|
|
33804
|
-
if (texture && texture instanceof
|
|
33823
|
+
if (texture && texture instanceof THREE28.Texture) {
|
|
33805
33824
|
texture.dispose();
|
|
33806
33825
|
typedMaterial[prop] = null;
|
|
33807
33826
|
}
|
|
@@ -33811,20 +33830,20 @@ function JscadBoardTextures({
|
|
|
33811
33830
|
const createTexturePlane2 = (texture, zOffset, isBottomLayer, name, usePolygonOffset = false, depthWrite = false, renderOrder = 1) => {
|
|
33812
33831
|
if (!texture) return null;
|
|
33813
33832
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
33814
|
-
const planeGeom = new
|
|
33833
|
+
const planeGeom = new THREE28.PlaneGeometry(
|
|
33815
33834
|
boardOutlineBounds.width,
|
|
33816
33835
|
boardOutlineBounds.height
|
|
33817
33836
|
);
|
|
33818
|
-
const material = new
|
|
33837
|
+
const material = new THREE28.MeshBasicMaterial({
|
|
33819
33838
|
map: texture,
|
|
33820
33839
|
transparent: true,
|
|
33821
|
-
side:
|
|
33840
|
+
side: THREE28.DoubleSide,
|
|
33822
33841
|
depthWrite,
|
|
33823
33842
|
polygonOffset: usePolygonOffset,
|
|
33824
33843
|
polygonOffsetUnits: usePolygonOffset ? -4 : 0,
|
|
33825
33844
|
opacity: isFaux ? FAUX_BOARD_OPACITY : 1
|
|
33826
33845
|
});
|
|
33827
|
-
const mesh = new
|
|
33846
|
+
const mesh = new THREE28.Mesh(planeGeom, material);
|
|
33828
33847
|
mesh.position.set(
|
|
33829
33848
|
boardOutlineBounds.centerX,
|
|
33830
33849
|
boardOutlineBounds.centerY,
|
|
@@ -33869,7 +33888,7 @@ function JscadBoardTextures({
|
|
|
33869
33888
|
mesh.geometry.dispose();
|
|
33870
33889
|
if (Array.isArray(mesh.material)) {
|
|
33871
33890
|
mesh.material.forEach((material) => disposeTextureMaterial(material));
|
|
33872
|
-
} else if (mesh.material instanceof
|
|
33891
|
+
} else if (mesh.material instanceof THREE28.Material) {
|
|
33873
33892
|
disposeTextureMaterial(mesh.material);
|
|
33874
33893
|
}
|
|
33875
33894
|
});
|
|
@@ -33881,16 +33900,16 @@ function JscadBoardTextures({
|
|
|
33881
33900
|
}
|
|
33882
33901
|
|
|
33883
33902
|
// src/utils/preprocess-circuit-json.ts
|
|
33884
|
-
import { su as
|
|
33903
|
+
import { su as su12 } from "@tscircuit/circuit-json-util";
|
|
33885
33904
|
|
|
33886
33905
|
// src/utils/create-faux-board.ts
|
|
33887
|
-
import { su as
|
|
33906
|
+
import { su as su11, getBoundsOfPcbElements } from "@tscircuit/circuit-json-util";
|
|
33888
33907
|
function createFauxBoard(circuitJson) {
|
|
33889
|
-
const cadComponents =
|
|
33890
|
-
const pads =
|
|
33891
|
-
const holes =
|
|
33892
|
-
const platedHoles =
|
|
33893
|
-
const vias =
|
|
33908
|
+
const cadComponents = su11(circuitJson).cad_component.list();
|
|
33909
|
+
const pads = su11(circuitJson).pcb_smtpad.list();
|
|
33910
|
+
const holes = su11(circuitJson).pcb_hole.list();
|
|
33911
|
+
const platedHoles = su11(circuitJson).pcb_plated_hole.list();
|
|
33912
|
+
const vias = su11(circuitJson).pcb_via.list();
|
|
33894
33913
|
if (cadComponents.length === 0 && pads.length === 0 && holes.length === 0 && platedHoles.length === 0 && vias.length === 0) {
|
|
33895
33914
|
return null;
|
|
33896
33915
|
}
|
|
@@ -33939,7 +33958,7 @@ function createFauxBoard(circuitJson) {
|
|
|
33939
33958
|
|
|
33940
33959
|
// src/utils/preprocess-circuit-json.ts
|
|
33941
33960
|
function addFauxBoardIfNeeded(circuitJson) {
|
|
33942
|
-
const boards =
|
|
33961
|
+
const boards = su12(circuitJson).pcb_board.list();
|
|
33943
33962
|
if (boards.length > 0) {
|
|
33944
33963
|
return circuitJson;
|
|
33945
33964
|
}
|
|
@@ -33990,7 +34009,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
33990
34009
|
const initialCameraPosition = useMemo20(() => {
|
|
33991
34010
|
if (!internalCircuitJson) return [5, -5, 5];
|
|
33992
34011
|
try {
|
|
33993
|
-
const board =
|
|
34012
|
+
const board = su13(internalCircuitJson).pcb_board.list()[0];
|
|
33994
34013
|
if (!board) return [5, -5, 5];
|
|
33995
34014
|
const { width: width10, height: height10 } = board;
|
|
33996
34015
|
if (!width10 && !height10) {
|
|
@@ -34016,7 +34035,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
34016
34035
|
const isFauxBoard = useMemo20(() => {
|
|
34017
34036
|
if (!internalCircuitJson) return false;
|
|
34018
34037
|
try {
|
|
34019
|
-
const board =
|
|
34038
|
+
const board = su13(internalCircuitJson).pcb_board.list()[0];
|
|
34020
34039
|
return !!board && board.pcb_board_id === "faux-board";
|
|
34021
34040
|
} catch (e) {
|
|
34022
34041
|
return false;
|
|
@@ -34025,7 +34044,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
34025
34044
|
const boardDimensions = useMemo20(() => {
|
|
34026
34045
|
if (!internalCircuitJson) return void 0;
|
|
34027
34046
|
try {
|
|
34028
|
-
const board =
|
|
34047
|
+
const board = su13(internalCircuitJson).pcb_board.list()[0];
|
|
34029
34048
|
if (!board) return void 0;
|
|
34030
34049
|
return { width: board.width ?? 0, height: board.height ?? 0 };
|
|
34031
34050
|
} catch (e) {
|
|
@@ -34036,7 +34055,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
34036
34055
|
const boardCenter = useMemo20(() => {
|
|
34037
34056
|
if (!internalCircuitJson) return void 0;
|
|
34038
34057
|
try {
|
|
34039
|
-
const board =
|
|
34058
|
+
const board = su13(internalCircuitJson).pcb_board.list()[0];
|
|
34040
34059
|
if (!board || !board.center) return void 0;
|
|
34041
34060
|
return { x: board.center.x, y: board.center.y };
|
|
34042
34061
|
} catch (e) {
|
|
@@ -34046,7 +34065,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
34046
34065
|
}, [internalCircuitJson]);
|
|
34047
34066
|
const pcbThickness = usePcbThickness(internalCircuitJson);
|
|
34048
34067
|
const { stls: boardStls, loading } = useStlsFromGeom(boardGeom);
|
|
34049
|
-
const cad_components =
|
|
34068
|
+
const cad_components = su13(internalCircuitJson).cad_component.list();
|
|
34050
34069
|
return /* @__PURE__ */ jsxs5(
|
|
34051
34070
|
CadViewerContainer,
|
|
34052
34071
|
{
|
|
@@ -34105,8 +34124,8 @@ import { useEffect as useEffect25, useMemo as useMemo22, useState as useState16
|
|
|
34105
34124
|
import * as THREE35 from "three";
|
|
34106
34125
|
|
|
34107
34126
|
// src/hooks/useManifoldBoardBuilder.ts
|
|
34108
|
-
import { useState as useState15, useEffect as useEffect24, useMemo as useMemo21, useRef as useRef9 } from "react";
|
|
34109
34127
|
import { su as su18 } from "@tscircuit/circuit-json-util";
|
|
34128
|
+
import { useEffect as useEffect24, useMemo as useMemo21, useRef as useRef9, useState as useState15 } from "react";
|
|
34110
34129
|
import * as THREE32 from "three";
|
|
34111
34130
|
|
|
34112
34131
|
// src/utils/manifold/create-manifold-board.ts
|
|
@@ -34168,7 +34187,7 @@ function createManifoldBoard(Manifold, CrossSection, boardData, pcbThickness, ma
|
|
|
34168
34187
|
}
|
|
34169
34188
|
|
|
34170
34189
|
// src/utils/manifold/process-cutouts.ts
|
|
34171
|
-
import { su as
|
|
34190
|
+
import { su as su14 } from "@tscircuit/circuit-json-util";
|
|
34172
34191
|
|
|
34173
34192
|
// src/utils/pad-geoms.ts
|
|
34174
34193
|
var RECT_PAD_SEGMENTS2 = 64;
|
|
@@ -34211,39 +34230,6 @@ function createRoundedRectPrism({
|
|
|
34211
34230
|
});
|
|
34212
34231
|
return Manifold.union(shapes);
|
|
34213
34232
|
}
|
|
34214
|
-
function createPadManifoldOp({
|
|
34215
|
-
Manifold,
|
|
34216
|
-
pad: pad2,
|
|
34217
|
-
padBaseThickness
|
|
34218
|
-
}) {
|
|
34219
|
-
if (pad2.shape === "rect") {
|
|
34220
|
-
const rectBorderRadius = extractRectBorderRadius(pad2);
|
|
34221
|
-
return createRoundedRectPrism({
|
|
34222
|
-
Manifold,
|
|
34223
|
-
width: pad2.width,
|
|
34224
|
-
height: pad2.height,
|
|
34225
|
-
thickness: padBaseThickness,
|
|
34226
|
-
borderRadius: rectBorderRadius
|
|
34227
|
-
});
|
|
34228
|
-
} else if (pad2.shape === "rotated_rect") {
|
|
34229
|
-
const rectBorderRadius = extractRectBorderRadius(pad2);
|
|
34230
|
-
let padOp = createRoundedRectPrism({
|
|
34231
|
-
Manifold,
|
|
34232
|
-
width: pad2.width,
|
|
34233
|
-
height: pad2.height,
|
|
34234
|
-
thickness: padBaseThickness,
|
|
34235
|
-
borderRadius: rectBorderRadius
|
|
34236
|
-
});
|
|
34237
|
-
const rotation = pad2.ccw_rotation ?? 0;
|
|
34238
|
-
if (rotation) {
|
|
34239
|
-
padOp = padOp.rotate([0, 0, rotation]);
|
|
34240
|
-
}
|
|
34241
|
-
return padOp;
|
|
34242
|
-
} else if (pad2.shape === "circle" && pad2.radius) {
|
|
34243
|
-
return Manifold.cylinder(padBaseThickness, pad2.radius, -1, 32, true);
|
|
34244
|
-
}
|
|
34245
|
-
return null;
|
|
34246
|
-
}
|
|
34247
34233
|
|
|
34248
34234
|
// src/utils/manifold/process-cutouts.ts
|
|
34249
34235
|
var arePointsClockwise3 = (points) => {
|
|
@@ -34260,7 +34246,7 @@ var arePointsClockwise3 = (points) => {
|
|
|
34260
34246
|
};
|
|
34261
34247
|
function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
34262
34248
|
const cutoutOps = [];
|
|
34263
|
-
const pcbCutouts =
|
|
34249
|
+
const pcbCutouts = su14(circuitJson).pcb_cutout.list();
|
|
34264
34250
|
for (const cutout of pcbCutouts) {
|
|
34265
34251
|
let cutoutOp;
|
|
34266
34252
|
const cutoutHeight = pcbThickness * 1.5;
|
|
@@ -34355,7 +34341,7 @@ function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThick
|
|
|
34355
34341
|
}
|
|
34356
34342
|
|
|
34357
34343
|
// src/utils/manifold/process-non-plated-holes.ts
|
|
34358
|
-
import { su as
|
|
34344
|
+
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
34359
34345
|
|
|
34360
34346
|
// src/utils/hole-geoms.ts
|
|
34361
34347
|
function createCircleHoleDrill({
|
|
@@ -34398,7 +34384,7 @@ function createPlatedHoleDrill({
|
|
|
34398
34384
|
// src/utils/manifold/process-non-plated-holes.ts
|
|
34399
34385
|
function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
34400
34386
|
const nonPlatedHoleBoardDrills = [];
|
|
34401
|
-
const pcbHoles =
|
|
34387
|
+
const pcbHoles = su15(circuitJson).pcb_hole.list();
|
|
34402
34388
|
const createPillOp = (width10, height10, depth) => {
|
|
34403
34389
|
const pillOp = createRoundedRectPrism({
|
|
34404
34390
|
Manifold,
|
|
@@ -34481,18 +34467,18 @@ function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, p
|
|
|
34481
34467
|
}
|
|
34482
34468
|
|
|
34483
34469
|
// src/utils/manifold/process-plated-holes.ts
|
|
34484
|
-
import { su as
|
|
34485
|
-
import * as
|
|
34470
|
+
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
34471
|
+
import * as THREE30 from "three";
|
|
34486
34472
|
|
|
34487
34473
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
34488
|
-
import * as
|
|
34474
|
+
import * as THREE29 from "three";
|
|
34489
34475
|
function manifoldMeshToThreeGeometry(manifoldMesh) {
|
|
34490
|
-
const geometry = new
|
|
34476
|
+
const geometry = new THREE29.BufferGeometry();
|
|
34491
34477
|
geometry.setAttribute(
|
|
34492
34478
|
"position",
|
|
34493
|
-
new
|
|
34479
|
+
new THREE29.Float32BufferAttribute(manifoldMesh.vertProperties, 3)
|
|
34494
34480
|
);
|
|
34495
|
-
geometry.setIndex(new
|
|
34481
|
+
geometry.setIndex(new THREE29.Uint32BufferAttribute(manifoldMesh.triVerts, 1));
|
|
34496
34482
|
if (manifoldMesh.runIndex && manifoldMesh.runIndex.length > 1 && manifoldMesh.runOriginalID) {
|
|
34497
34483
|
for (let i = 0; i < manifoldMesh.runIndex.length - 1; i++) {
|
|
34498
34484
|
const start = manifoldMesh.runIndex[i];
|
|
@@ -34526,11 +34512,11 @@ var createEllipsePoints = (width10, height10, segments) => {
|
|
|
34526
34512
|
}
|
|
34527
34513
|
return points;
|
|
34528
34514
|
};
|
|
34529
|
-
var COPPER_COLOR = new
|
|
34515
|
+
var COPPER_COLOR = new THREE30.Color(...colors.copper);
|
|
34530
34516
|
var PLATED_HOLE_LIP_HEIGHT = 0.05;
|
|
34531
34517
|
function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
34532
34518
|
const platedHoleBoardDrills = [];
|
|
34533
|
-
const pcbPlatedHoles =
|
|
34519
|
+
const pcbPlatedHoles = su16(circuitJson).pcb_plated_hole.list();
|
|
34534
34520
|
const platedHoleCopperGeoms = [];
|
|
34535
34521
|
const platedHoleCopperOpsForSubtract = [];
|
|
34536
34522
|
const createPillOp = (width10, height10, depth) => {
|
|
@@ -35230,46 +35216,6 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
35230
35216
|
return { platedHoleBoardDrills, platedHoleCopperGeoms, platedHoleSubtractOp };
|
|
35231
35217
|
}
|
|
35232
35218
|
|
|
35233
|
-
// src/utils/manifold/process-smt-pads.ts
|
|
35234
|
-
import { su as su16 } from "@tscircuit/circuit-json-util";
|
|
35235
|
-
import * as THREE30 from "three";
|
|
35236
|
-
var COPPER_COLOR2 = new THREE30.Color(...colors.copper);
|
|
35237
|
-
function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, holeUnion, boardClipVolume) {
|
|
35238
|
-
const smtPadGeoms = [];
|
|
35239
|
-
const smtPads = su16(circuitJson).pcb_smtpad.list();
|
|
35240
|
-
smtPads.forEach((pad2, index2) => {
|
|
35241
|
-
const padBaseThickness = DEFAULT_SMT_PAD_THICKNESS;
|
|
35242
|
-
const zPos = pad2.layer === "bottom" ? -pcbThickness / 2 - BOARD_SURFACE_OFFSET.copper : pcbThickness / 2 + BOARD_SURFACE_OFFSET.copper;
|
|
35243
|
-
let padManifoldOp = createPadManifoldOp({
|
|
35244
|
-
Manifold,
|
|
35245
|
-
pad: pad2,
|
|
35246
|
-
padBaseThickness
|
|
35247
|
-
});
|
|
35248
|
-
if (padManifoldOp) {
|
|
35249
|
-
manifoldInstancesForCleanup.push(padManifoldOp);
|
|
35250
|
-
const translatedPad = padManifoldOp.translate([pad2.x, pad2.y, zPos]);
|
|
35251
|
-
manifoldInstancesForCleanup.push(translatedPad);
|
|
35252
|
-
let finalPadOp = translatedPad;
|
|
35253
|
-
if (holeUnion) {
|
|
35254
|
-
finalPadOp = translatedPad.subtract(holeUnion);
|
|
35255
|
-
manifoldInstancesForCleanup.push(finalPadOp);
|
|
35256
|
-
}
|
|
35257
|
-
if (boardClipVolume) {
|
|
35258
|
-
const clipped = Manifold.intersection([finalPadOp, boardClipVolume]);
|
|
35259
|
-
manifoldInstancesForCleanup.push(clipped);
|
|
35260
|
-
finalPadOp = clipped;
|
|
35261
|
-
}
|
|
35262
|
-
const threeGeom = manifoldMeshToThreeGeometry(finalPadOp.getMesh());
|
|
35263
|
-
smtPadGeoms.push({
|
|
35264
|
-
key: `smt_pad-${pad2.layer || "top"}-${pad2.pcb_smtpad_id || index2}`,
|
|
35265
|
-
geometry: threeGeom,
|
|
35266
|
-
color: COPPER_COLOR2
|
|
35267
|
-
});
|
|
35268
|
-
}
|
|
35269
|
-
});
|
|
35270
|
-
return { smtPadGeoms };
|
|
35271
|
-
}
|
|
35272
|
-
|
|
35273
35219
|
// src/utils/manifold/process-vias.ts
|
|
35274
35220
|
import { su as su17 } from "@tscircuit/circuit-json-util";
|
|
35275
35221
|
import * as THREE31 from "three";
|
|
@@ -35325,7 +35271,7 @@ function createViaCopper2({
|
|
|
35325
35271
|
}
|
|
35326
35272
|
|
|
35327
35273
|
// src/utils/manifold/process-vias.ts
|
|
35328
|
-
var
|
|
35274
|
+
var COPPER_COLOR2 = new THREE31.Color(...colors.copper);
|
|
35329
35275
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
35330
35276
|
const viaBoardDrills = [];
|
|
35331
35277
|
const pcbVias = su17(circuitJson).pcb_via.list();
|
|
@@ -35369,7 +35315,7 @@ function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldIns
|
|
|
35369
35315
|
viaCopperGeoms.push({
|
|
35370
35316
|
key: `via-${via.pcb_via_id || index2}`,
|
|
35371
35317
|
geometry: threeGeom,
|
|
35372
|
-
color:
|
|
35318
|
+
color: COPPER_COLOR2
|
|
35373
35319
|
});
|
|
35374
35320
|
}
|
|
35375
35321
|
});
|
|
@@ -35423,7 +35369,7 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
35423
35369
|
return;
|
|
35424
35370
|
}
|
|
35425
35371
|
if ((boardData.width === 0 || !boardData.width) && (boardData.height === 0 || !boardData.height) && (!boardData.outline || boardData.outline.length < 3)) {
|
|
35426
|
-
setGeoms({ platedHoles: [],
|
|
35372
|
+
setGeoms({ platedHoles: [], vias: [] });
|
|
35427
35373
|
setPcbThickness(boardData.thickness ?? 0);
|
|
35428
35374
|
setIsLoading(false);
|
|
35429
35375
|
return;
|
|
@@ -35584,15 +35530,6 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson, visibility) => {
|
|
|
35584
35530
|
isFaux: isFauxBoard
|
|
35585
35531
|
};
|
|
35586
35532
|
}
|
|
35587
|
-
const { smtPadGeoms } = processSmtPadsForManifold(
|
|
35588
|
-
Manifold,
|
|
35589
|
-
circuitJson,
|
|
35590
|
-
currentPcbThickness,
|
|
35591
|
-
manifoldInstancesForCleanup.current,
|
|
35592
|
-
holeUnion,
|
|
35593
|
-
boardClipVolume
|
|
35594
|
-
);
|
|
35595
|
-
currentGeoms.smtPads = smtPadGeoms;
|
|
35596
35533
|
setGeoms(currentGeoms);
|
|
35597
35534
|
} catch (e) {
|
|
35598
35535
|
console.error("Error processing geometry with Manifold in hook:", e);
|
|
@@ -35704,7 +35641,6 @@ function createGeometryMeshes(geoms) {
|
|
|
35704
35641
|
}
|
|
35705
35642
|
};
|
|
35706
35643
|
createMeshesFromArray(geoms.platedHoles);
|
|
35707
|
-
createMeshesFromArray(geoms.smtPads);
|
|
35708
35644
|
createMeshesFromArray(geoms.vias);
|
|
35709
35645
|
return meshes;
|
|
35710
35646
|
}
|
|
@@ -35752,14 +35688,6 @@ var BoardMeshes = ({
|
|
|
35752
35688
|
let shouldShow = true;
|
|
35753
35689
|
if (mesh.name === "board-geom") {
|
|
35754
35690
|
shouldShow = visibility.boardBody;
|
|
35755
|
-
} else if (mesh.name.includes("smt_pad")) {
|
|
35756
|
-
if (mesh.name.includes("smt_pad-top")) {
|
|
35757
|
-
shouldShow = visibility.topCopper;
|
|
35758
|
-
} else if (mesh.name.includes("smt_pad-bottom")) {
|
|
35759
|
-
shouldShow = visibility.bottomCopper;
|
|
35760
|
-
} else {
|
|
35761
|
-
shouldShow = visibility.topCopper || visibility.bottomCopper;
|
|
35762
|
-
}
|
|
35763
35691
|
} else if (mesh.name.includes("plated_hole") || mesh.name.includes("via")) {
|
|
35764
35692
|
shouldShow = visibility.topCopper || visibility.bottomCopper;
|
|
35765
35693
|
}
|