jscad-electronics 0.0.152 → 0.0.154
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/README.md +35 -0
- package/dist/index.d.ts +106 -1
- package/dist/index.js +554 -7
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +7 -6
- package/dist/vanilla.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1263,6 +1263,7 @@ var getLeadWidth = (pinCount, width10) => {
|
|
|
1263
1263
|
// lib/PinHeader.tsx
|
|
1264
1264
|
import { Colorize as Colorize7, Cuboid as Cuboid14, Hull as Hull4, Rotate as Rotate5, Translate as Translate8 } from "jscad-fiber";
|
|
1265
1265
|
import { Fragment as Fragment17, jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1266
|
+
var PIN_METAL_COLOR = "#c0c0c0";
|
|
1266
1267
|
var PinHeader = ({
|
|
1267
1268
|
x,
|
|
1268
1269
|
y,
|
|
@@ -1286,7 +1287,7 @@ var PinHeader = ({
|
|
|
1286
1287
|
center: [x, y, flipZ(bodyHeight / 2)]
|
|
1287
1288
|
}
|
|
1288
1289
|
) }),
|
|
1289
|
-
!faceup && /* @__PURE__ */ jsx21(Colorize7, { color:
|
|
1290
|
+
!faceup && /* @__PURE__ */ jsx21(Colorize7, { color: PIN_METAL_COLOR, children: smd ? /* @__PURE__ */ jsx21(
|
|
1290
1291
|
SmdChipLead,
|
|
1291
1292
|
{
|
|
1292
1293
|
rotation: -Math.PI / 2,
|
|
@@ -1305,7 +1306,7 @@ var PinHeader = ({
|
|
|
1305
1306
|
/* @__PURE__ */ jsx21(
|
|
1306
1307
|
Cuboid14,
|
|
1307
1308
|
{
|
|
1308
|
-
color:
|
|
1309
|
+
color: PIN_METAL_COLOR,
|
|
1309
1310
|
size: [pinThickness, pinThickness, shortSidePinLength * 0.9],
|
|
1310
1311
|
center: [x, y, flipZ(bodyHeight * 0.9 + bodyHeight / 2)]
|
|
1311
1312
|
}
|
|
@@ -1313,7 +1314,7 @@ var PinHeader = ({
|
|
|
1313
1314
|
/* @__PURE__ */ jsx21(
|
|
1314
1315
|
Cuboid14,
|
|
1315
1316
|
{
|
|
1316
|
-
color:
|
|
1317
|
+
color: PIN_METAL_COLOR,
|
|
1317
1318
|
size: [
|
|
1318
1319
|
pinThickness / 1.8,
|
|
1319
1320
|
pinThickness / 1.8,
|
|
@@ -1323,11 +1324,11 @@ var PinHeader = ({
|
|
|
1323
1324
|
}
|
|
1324
1325
|
)
|
|
1325
1326
|
] }) }),
|
|
1326
|
-
/* @__PURE__ */ jsx21(Colorize7, { color:
|
|
1327
|
+
/* @__PURE__ */ jsx21(Colorize7, { color: PIN_METAL_COLOR, children: /* @__PURE__ */ jsx21(Translate8, { y: rightangle ? -3.9 : 0, z: rightangle ? 1 : 0, children: /* @__PURE__ */ jsx21(Rotate5, { rotation: rightangle ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: /* @__PURE__ */ jsxs19(Hull4, { children: [
|
|
1327
1328
|
/* @__PURE__ */ jsx21(
|
|
1328
1329
|
Cuboid14,
|
|
1329
1330
|
{
|
|
1330
|
-
color:
|
|
1331
|
+
color: PIN_METAL_COLOR,
|
|
1331
1332
|
size: [pinThickness, pinThickness, longSidePinLength * 0.9],
|
|
1332
1333
|
center: [x, y, flipZ(-longSidePinLength / 2 * 0.9)]
|
|
1333
1334
|
}
|
|
@@ -1335,7 +1336,7 @@ var PinHeader = ({
|
|
|
1335
1336
|
/* @__PURE__ */ jsx21(
|
|
1336
1337
|
Cuboid14,
|
|
1337
1338
|
{
|
|
1338
|
-
color:
|
|
1339
|
+
color: PIN_METAL_COLOR,
|
|
1339
1340
|
size: [
|
|
1340
1341
|
pinThickness / 1.8,
|
|
1341
1342
|
pinThickness / 1.8,
|
|
@@ -7308,6 +7309,550 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
7308
7309
|
}
|
|
7309
7310
|
return null;
|
|
7310
7311
|
};
|
|
7312
|
+
|
|
7313
|
+
// lib/FlexScreen.tsx
|
|
7314
|
+
import { Colorize as Colorize49, Rotate as Rotate19, RoundedCuboid as RoundedCuboid5, Translate as Translate39 } from "jscad-fiber";
|
|
7315
|
+
import { Fragment as Fragment80 } from "react";
|
|
7316
|
+
import { Fragment as Fragment81, jsx as jsx85, jsxs as jsxs80 } from "react/jsx-runtime";
|
|
7317
|
+
var DEFAULT_ASPECT_RATIO = 16 / 9;
|
|
7318
|
+
var DEFAULT_DIAGONAL = 40;
|
|
7319
|
+
var EPSILON = 1e-6;
|
|
7320
|
+
var assertPositive = (name, value) => {
|
|
7321
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
7322
|
+
throw new Error(`${name} must be a finite number greater than zero`);
|
|
7323
|
+
}
|
|
7324
|
+
};
|
|
7325
|
+
var resolveAspectRatio = (value) => {
|
|
7326
|
+
if (value === void 0) return DEFAULT_ASPECT_RATIO;
|
|
7327
|
+
if (typeof value === "number") {
|
|
7328
|
+
assertPositive("aspectRatio", value);
|
|
7329
|
+
return value;
|
|
7330
|
+
}
|
|
7331
|
+
if (typeof value !== "string") {
|
|
7332
|
+
const [ratioWidth2, ratioHeight2] = value;
|
|
7333
|
+
assertPositive("aspectRatio width", ratioWidth2);
|
|
7334
|
+
assertPositive("aspectRatio height", ratioHeight2);
|
|
7335
|
+
return ratioWidth2 / ratioHeight2;
|
|
7336
|
+
}
|
|
7337
|
+
const parts = value.split(":");
|
|
7338
|
+
if (parts.length !== 2) {
|
|
7339
|
+
throw new Error('aspectRatio must look like "16:9"');
|
|
7340
|
+
}
|
|
7341
|
+
const ratioWidth = Number(parts[0]);
|
|
7342
|
+
const ratioHeight = Number(parts[1]);
|
|
7343
|
+
assertPositive("aspectRatio width", ratioWidth);
|
|
7344
|
+
assertPositive("aspectRatio height", ratioHeight);
|
|
7345
|
+
return ratioWidth / ratioHeight;
|
|
7346
|
+
};
|
|
7347
|
+
var resolveFlexScreenSize = ({
|
|
7348
|
+
width: width10,
|
|
7349
|
+
height: height10,
|
|
7350
|
+
diagonal,
|
|
7351
|
+
aspectRatio,
|
|
7352
|
+
ratio,
|
|
7353
|
+
defaultDiagonal = DEFAULT_DIAGONAL
|
|
7354
|
+
}) => {
|
|
7355
|
+
const resolvedRatio = resolveAspectRatio(aspectRatio ?? ratio);
|
|
7356
|
+
if (width10 !== void 0) assertPositive("width", width10);
|
|
7357
|
+
if (height10 !== void 0) assertPositive("height", height10);
|
|
7358
|
+
if (diagonal !== void 0) assertPositive("diagonal", diagonal);
|
|
7359
|
+
assertPositive("defaultDiagonal", defaultDiagonal);
|
|
7360
|
+
let resolvedWidth;
|
|
7361
|
+
let resolvedHeight;
|
|
7362
|
+
if (width10 !== void 0 && height10 !== void 0) {
|
|
7363
|
+
resolvedWidth = width10;
|
|
7364
|
+
resolvedHeight = height10;
|
|
7365
|
+
} else if (diagonal !== void 0 && width10 !== void 0) {
|
|
7366
|
+
if (width10 >= diagonal) {
|
|
7367
|
+
throw new Error("width must be smaller than diagonal");
|
|
7368
|
+
}
|
|
7369
|
+
resolvedWidth = width10;
|
|
7370
|
+
resolvedHeight = Math.sqrt(diagonal ** 2 - width10 ** 2);
|
|
7371
|
+
} else if (diagonal !== void 0 && height10 !== void 0) {
|
|
7372
|
+
if (height10 >= diagonal) {
|
|
7373
|
+
throw new Error("height must be smaller than diagonal");
|
|
7374
|
+
}
|
|
7375
|
+
resolvedWidth = Math.sqrt(diagonal ** 2 - height10 ** 2);
|
|
7376
|
+
resolvedHeight = height10;
|
|
7377
|
+
} else if (width10 !== void 0) {
|
|
7378
|
+
resolvedWidth = width10;
|
|
7379
|
+
resolvedHeight = width10 / resolvedRatio;
|
|
7380
|
+
} else if (height10 !== void 0) {
|
|
7381
|
+
resolvedWidth = height10 * resolvedRatio;
|
|
7382
|
+
resolvedHeight = height10;
|
|
7383
|
+
} else {
|
|
7384
|
+
const resolvedDiagonal = diagonal ?? defaultDiagonal;
|
|
7385
|
+
resolvedHeight = resolvedDiagonal / Math.sqrt(resolvedRatio ** 2 + 1);
|
|
7386
|
+
resolvedWidth = resolvedHeight * resolvedRatio;
|
|
7387
|
+
}
|
|
7388
|
+
return {
|
|
7389
|
+
width: resolvedWidth,
|
|
7390
|
+
height: resolvedHeight,
|
|
7391
|
+
diagonal: Math.hypot(resolvedWidth, resolvedHeight),
|
|
7392
|
+
aspectRatio: resolvedWidth / resolvedHeight
|
|
7393
|
+
};
|
|
7394
|
+
};
|
|
7395
|
+
var resolveOrientation = (props) => {
|
|
7396
|
+
const shortcuts = [
|
|
7397
|
+
["sitsFlat", props.sitsFlat],
|
|
7398
|
+
["sitsFlatBelowBoard", props.sitsFlatBelowBoard],
|
|
7399
|
+
["foldedToFaceAboveBoard", props.foldedToFaceAboveBoard],
|
|
7400
|
+
["foldedToFaceBelowBoard", props.foldedToFaceBelowBoard],
|
|
7401
|
+
["foldedToFaceAboveBoard", props.foldsAboveBoard],
|
|
7402
|
+
["foldedToFaceBelowBoard", props.foldsBelowBoard],
|
|
7403
|
+
["foldedToRightAngleAboveBoard", props.foldedToRightAngleAboveBoard],
|
|
7404
|
+
["foldedToRightAngleBelowBoard", props.foldedToRightAngleBelowBoard]
|
|
7405
|
+
].filter((entry) => entry[1]);
|
|
7406
|
+
if (shortcuts.length > 1) {
|
|
7407
|
+
throw new Error(
|
|
7408
|
+
"Only one FlexScreen boolean orientation shortcut can be true"
|
|
7409
|
+
);
|
|
7410
|
+
}
|
|
7411
|
+
return shortcuts[0]?.[0] ?? props.orientation ?? "sitsFlat";
|
|
7412
|
+
};
|
|
7413
|
+
var distance = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
7414
|
+
var interpolate = (a, b, progress) => [
|
|
7415
|
+
a[0] + (b[0] - a[0]) * progress,
|
|
7416
|
+
a[1] + (b[1] - a[1]) * progress,
|
|
7417
|
+
a[2] + (b[2] - a[2]) * progress
|
|
7418
|
+
];
|
|
7419
|
+
var getPathDistances = (points) => {
|
|
7420
|
+
const distances = [0];
|
|
7421
|
+
for (let index = 1; index < points.length; index += 1) {
|
|
7422
|
+
distances.push(
|
|
7423
|
+
distances[index - 1] + distance(points[index - 1], points[index])
|
|
7424
|
+
);
|
|
7425
|
+
}
|
|
7426
|
+
return distances;
|
|
7427
|
+
};
|
|
7428
|
+
var pointAtDistance = (points, distances, targetDistance) => {
|
|
7429
|
+
if (targetDistance <= 0) return points[0];
|
|
7430
|
+
const totalLength = distances.at(-1);
|
|
7431
|
+
if (targetDistance >= totalLength) return points.at(-1);
|
|
7432
|
+
for (let index = 1; index < points.length; index += 1) {
|
|
7433
|
+
if (distances[index] >= targetDistance) {
|
|
7434
|
+
const segmentStart = distances[index - 1];
|
|
7435
|
+
const segmentLength = distances[index] - segmentStart;
|
|
7436
|
+
return interpolate(
|
|
7437
|
+
points[index - 1],
|
|
7438
|
+
points[index],
|
|
7439
|
+
(targetDistance - segmentStart) / segmentLength
|
|
7440
|
+
);
|
|
7441
|
+
}
|
|
7442
|
+
}
|
|
7443
|
+
return points.at(-1);
|
|
7444
|
+
};
|
|
7445
|
+
var slicePath = (points, startDistance, endDistance) => {
|
|
7446
|
+
const distances = getPathDistances(points);
|
|
7447
|
+
const totalLength = distances.at(-1);
|
|
7448
|
+
const safeStart = Math.max(0, Math.min(startDistance, totalLength));
|
|
7449
|
+
const safeEnd = Math.max(safeStart, Math.min(endDistance, totalLength));
|
|
7450
|
+
const result = [pointAtDistance(points, distances, safeStart)];
|
|
7451
|
+
for (let index = 1; index < points.length - 1; index += 1) {
|
|
7452
|
+
if (distances[index] > safeStart && distances[index] < safeEnd) {
|
|
7453
|
+
result.push(points[index]);
|
|
7454
|
+
}
|
|
7455
|
+
}
|
|
7456
|
+
result.push(pointAtDistance(points, distances, safeEnd));
|
|
7457
|
+
return result;
|
|
7458
|
+
};
|
|
7459
|
+
var createFlatPath = (start, flexCableLength) => [
|
|
7460
|
+
start,
|
|
7461
|
+
[start[0], start[1] + flexCableLength, start[2]]
|
|
7462
|
+
];
|
|
7463
|
+
var createFoldedPath = ({
|
|
7464
|
+
start,
|
|
7465
|
+
endZ,
|
|
7466
|
+
flexCableLength,
|
|
7467
|
+
foldDistanceFromConnector,
|
|
7468
|
+
foldOutset,
|
|
7469
|
+
foldSegments
|
|
7470
|
+
}) => {
|
|
7471
|
+
const points = [start];
|
|
7472
|
+
const foldStart = [
|
|
7473
|
+
start[0],
|
|
7474
|
+
start[1] + foldDistanceFromConnector,
|
|
7475
|
+
start[2]
|
|
7476
|
+
];
|
|
7477
|
+
if (foldDistanceFromConnector > EPSILON) points.push(foldStart);
|
|
7478
|
+
for (let index = 1; index <= foldSegments; index += 1) {
|
|
7479
|
+
const angle = Math.PI * index / foldSegments;
|
|
7480
|
+
points.push([
|
|
7481
|
+
start[0],
|
|
7482
|
+
foldStart[1] + foldOutset * Math.sin(angle),
|
|
7483
|
+
start[2] + (endZ - start[2]) * (1 - Math.cos(angle)) / 2
|
|
7484
|
+
]);
|
|
7485
|
+
}
|
|
7486
|
+
const minimumLength = getPathDistances(points).at(-1);
|
|
7487
|
+
if (minimumLength > flexCableLength + EPSILON) {
|
|
7488
|
+
throw new Error(
|
|
7489
|
+
`flexCableLength must be at least ${minimumLength.toFixed(2)} for this 180-degree fold`
|
|
7490
|
+
);
|
|
7491
|
+
}
|
|
7492
|
+
const tailLength = Math.max(0, flexCableLength - minimumLength);
|
|
7493
|
+
if (tailLength > EPSILON) {
|
|
7494
|
+
const foldEnd = points.at(-1);
|
|
7495
|
+
points.push([foldEnd[0], foldEnd[1] - tailLength, foldEnd[2]]);
|
|
7496
|
+
}
|
|
7497
|
+
return points;
|
|
7498
|
+
};
|
|
7499
|
+
var createRightAnglePath = ({
|
|
7500
|
+
start,
|
|
7501
|
+
flexCableLength,
|
|
7502
|
+
bendRadius,
|
|
7503
|
+
bendSegments,
|
|
7504
|
+
verticalLead,
|
|
7505
|
+
direction
|
|
7506
|
+
}) => {
|
|
7507
|
+
const bendLengthPerRadius = 2 * bendSegments * Math.sin(Math.PI / (4 * bendSegments));
|
|
7508
|
+
const resolvedRadius = Math.min(
|
|
7509
|
+
bendRadius,
|
|
7510
|
+
flexCableLength / bendLengthPerRadius
|
|
7511
|
+
);
|
|
7512
|
+
const bendLength = resolvedRadius * bendLengthPerRadius;
|
|
7513
|
+
const remainingLength = Math.max(0, flexCableLength - bendLength);
|
|
7514
|
+
const resolvedVerticalLead = Math.min(verticalLead, remainingLength * 0.45);
|
|
7515
|
+
const horizontalLength = remainingLength - resolvedVerticalLead;
|
|
7516
|
+
const points = [start];
|
|
7517
|
+
if (horizontalLength > EPSILON) {
|
|
7518
|
+
points.push([start[0], start[1] + horizontalLength, start[2]]);
|
|
7519
|
+
}
|
|
7520
|
+
for (let index = 1; index <= bendSegments; index += 1) {
|
|
7521
|
+
const angle = Math.PI / 2 * index / bendSegments;
|
|
7522
|
+
points.push([
|
|
7523
|
+
start[0],
|
|
7524
|
+
start[1] + horizontalLength + resolvedRadius * Math.sin(angle),
|
|
7525
|
+
start[2] + direction * resolvedRadius * (1 - Math.cos(angle))
|
|
7526
|
+
]);
|
|
7527
|
+
}
|
|
7528
|
+
if (resolvedVerticalLead > EPSILON) {
|
|
7529
|
+
const arcEnd = points.at(-1);
|
|
7530
|
+
points.push([
|
|
7531
|
+
arcEnd[0],
|
|
7532
|
+
arcEnd[1],
|
|
7533
|
+
arcEnd[2] + direction * resolvedVerticalLead
|
|
7534
|
+
]);
|
|
7535
|
+
}
|
|
7536
|
+
return points;
|
|
7537
|
+
};
|
|
7538
|
+
var CableStrip = ({
|
|
7539
|
+
points,
|
|
7540
|
+
width: width10,
|
|
7541
|
+
thickness,
|
|
7542
|
+
color,
|
|
7543
|
+
acrossOffset = 0,
|
|
7544
|
+
normalOffset = 0,
|
|
7545
|
+
overlap = 0.03
|
|
7546
|
+
}) => /* @__PURE__ */ jsx85(Colorize49, { color, children: points.slice(1).map((point, index) => {
|
|
7547
|
+
const previous = points[index];
|
|
7548
|
+
const dx = point[0] - previous[0];
|
|
7549
|
+
const dy = point[1] - previous[1];
|
|
7550
|
+
const dz = point[2] - previous[2];
|
|
7551
|
+
const segmentLength = Math.hypot(dx, dy, dz);
|
|
7552
|
+
if (segmentLength < EPSILON) return null;
|
|
7553
|
+
const pitch = Math.asin(dz / segmentLength);
|
|
7554
|
+
const yaw = Math.atan2(-dx, dy);
|
|
7555
|
+
const midpoint = [
|
|
7556
|
+
(previous[0] + point[0]) / 2,
|
|
7557
|
+
(previous[1] + point[1]) / 2,
|
|
7558
|
+
(previous[2] + point[2]) / 2
|
|
7559
|
+
];
|
|
7560
|
+
const roundRadius = Math.max(
|
|
7561
|
+
1e-3,
|
|
7562
|
+
Math.min(width10, thickness, segmentLength) / 2 - 1e-3
|
|
7563
|
+
);
|
|
7564
|
+
return /* @__PURE__ */ jsx85(Translate39, { offset: midpoint, children: /* @__PURE__ */ jsx85(Rotate19, { rotation: [pitch, 0, yaw], children: /* @__PURE__ */ jsx85(
|
|
7565
|
+
RoundedCuboid5,
|
|
7566
|
+
{
|
|
7567
|
+
size: [width10, segmentLength + overlap, thickness],
|
|
7568
|
+
center: [acrossOffset, 0, normalOffset],
|
|
7569
|
+
roundRadius
|
|
7570
|
+
}
|
|
7571
|
+
) }) }, `${index}:${midpoint.join(":")}`);
|
|
7572
|
+
}) });
|
|
7573
|
+
var FlexScreen = (props) => {
|
|
7574
|
+
const {
|
|
7575
|
+
width: width10,
|
|
7576
|
+
height: height10,
|
|
7577
|
+
diagonal,
|
|
7578
|
+
aspectRatio,
|
|
7579
|
+
ratio,
|
|
7580
|
+
defaultDiagonal,
|
|
7581
|
+
screenThickness = 1.2,
|
|
7582
|
+
bezelInset = 2,
|
|
7583
|
+
bezelDepth = 0.65,
|
|
7584
|
+
activeAreaWidth,
|
|
7585
|
+
activeAreaHeight,
|
|
7586
|
+
screenColor = "#071b24",
|
|
7587
|
+
bezelColor = "#15181d",
|
|
7588
|
+
showScreen = true,
|
|
7589
|
+
flexCableLength = 28,
|
|
7590
|
+
flexCableThickness = 0.18,
|
|
7591
|
+
flexCableColor = "#d79528",
|
|
7592
|
+
conductorCount = 8,
|
|
7593
|
+
conductorPitch,
|
|
7594
|
+
conductorWidth,
|
|
7595
|
+
conductorThickness = 0.035,
|
|
7596
|
+
conductorColor = "#8c4a18",
|
|
7597
|
+
cableEdgeMargin = 0.6,
|
|
7598
|
+
exposedContactLength = 2.4,
|
|
7599
|
+
showConductors = true,
|
|
7600
|
+
showFlexCable = true,
|
|
7601
|
+
showStiffeners = true,
|
|
7602
|
+
stiffenerLength = 3,
|
|
7603
|
+
stiffenerThickness = 0.16,
|
|
7604
|
+
stiffenerColor = "#416bb3",
|
|
7605
|
+
bendRadius = 3,
|
|
7606
|
+
bendSegments = 10,
|
|
7607
|
+
rightAngleVerticalLead = 3,
|
|
7608
|
+
distanceAboveBoard = 7,
|
|
7609
|
+
distanceBelowBoard = 7,
|
|
7610
|
+
foldDistanceFromConnector = 7,
|
|
7611
|
+
foldOutset = 4,
|
|
7612
|
+
foldSegments = 18,
|
|
7613
|
+
screenGap = 0.08,
|
|
7614
|
+
boardTopZ = 0,
|
|
7615
|
+
boardThickness = 1.6,
|
|
7616
|
+
boardClearance = 0.15,
|
|
7617
|
+
cableStartX = 0,
|
|
7618
|
+
cableStartY = 0,
|
|
7619
|
+
cableStartZ,
|
|
7620
|
+
cableLateralOffset = 0,
|
|
7621
|
+
screenOffset,
|
|
7622
|
+
screenRotation,
|
|
7623
|
+
rotation = [0, 0, 0],
|
|
7624
|
+
offset
|
|
7625
|
+
} = props;
|
|
7626
|
+
const size = resolveFlexScreenSize({
|
|
7627
|
+
width: width10,
|
|
7628
|
+
height: height10,
|
|
7629
|
+
diagonal,
|
|
7630
|
+
aspectRatio,
|
|
7631
|
+
ratio,
|
|
7632
|
+
defaultDiagonal
|
|
7633
|
+
});
|
|
7634
|
+
const orientation = resolveOrientation(props);
|
|
7635
|
+
const belowBoard = orientation === "sitsFlatBelowBoard" || orientation === "foldedToFaceBelowBoard" || orientation === "foldedToRightAngleBelowBoard";
|
|
7636
|
+
const foldedFace = orientation === "foldedToFaceAboveBoard" || orientation === "foldedToFaceBelowBoard";
|
|
7637
|
+
const rightAngle = orientation === "foldedToRightAngleAboveBoard" || orientation === "foldedToRightAngleBelowBoard";
|
|
7638
|
+
assertPositive("screenThickness", screenThickness);
|
|
7639
|
+
assertPositive("flexCableLength", flexCableLength);
|
|
7640
|
+
assertPositive("flexCableThickness", flexCableThickness);
|
|
7641
|
+
assertPositive("conductorThickness", conductorThickness);
|
|
7642
|
+
assertPositive("bendRadius", bendRadius);
|
|
7643
|
+
assertPositive("foldOutset", foldOutset);
|
|
7644
|
+
assertPositive("boardThickness", boardThickness);
|
|
7645
|
+
if (showStiffeners) assertPositive("stiffenerThickness", stiffenerThickness);
|
|
7646
|
+
if (!Number.isInteger(conductorCount) || conductorCount < 1) {
|
|
7647
|
+
throw new Error("conductorCount must be a positive integer");
|
|
7648
|
+
}
|
|
7649
|
+
if (!Number.isInteger(bendSegments) || bendSegments < 2) {
|
|
7650
|
+
throw new Error("bendSegments must be an integer of at least 2");
|
|
7651
|
+
}
|
|
7652
|
+
if (!Number.isInteger(foldSegments) || foldSegments < 4) {
|
|
7653
|
+
throw new Error("foldSegments must be an integer of at least 4");
|
|
7654
|
+
}
|
|
7655
|
+
if (boardClearance < 0 || screenGap < 0 || cableEdgeMargin < 0 || exposedContactLength < 0 || stiffenerLength < 0 || rightAngleVerticalLead < 0 || distanceAboveBoard < 0 || distanceBelowBoard < 0 || foldDistanceFromConnector < 0) {
|
|
7656
|
+
throw new Error(
|
|
7657
|
+
"clearances, margins, contact lengths, and lead lengths cannot be negative"
|
|
7658
|
+
);
|
|
7659
|
+
}
|
|
7660
|
+
const resolvedCableWidth = props.flexCableWidth ?? Math.min(12, Math.max(5, size.width * 0.3));
|
|
7661
|
+
assertPositive("flexCableWidth", resolvedCableWidth);
|
|
7662
|
+
const usableCableWidth = resolvedCableWidth - cableEdgeMargin * 2;
|
|
7663
|
+
if (usableCableWidth <= 0) {
|
|
7664
|
+
throw new Error("cableEdgeMargin leaves no usable flex cable width");
|
|
7665
|
+
}
|
|
7666
|
+
const resolvedConductorPitch = conductorPitch ?? (conductorCount === 1 ? 0 : usableCableWidth / conductorCount);
|
|
7667
|
+
if (conductorCount > 1 && (!Number.isFinite(resolvedConductorPitch) || resolvedConductorPitch <= 0)) {
|
|
7668
|
+
throw new Error("conductorPitch must be greater than zero");
|
|
7669
|
+
}
|
|
7670
|
+
const resolvedConductorWidth = conductorWidth ?? (conductorCount === 1 ? Math.min(usableCableWidth, resolvedCableWidth * 0.45) : resolvedConductorPitch * 0.48);
|
|
7671
|
+
assertPositive("conductorWidth", resolvedConductorWidth);
|
|
7672
|
+
const conductorSpan = (conductorCount - 1) * resolvedConductorPitch + resolvedConductorWidth;
|
|
7673
|
+
if (conductorSpan > usableCableWidth + EPSILON) {
|
|
7674
|
+
throw new Error(
|
|
7675
|
+
"conductorPitch and conductorWidth do not fit inside the flex cable margins"
|
|
7676
|
+
);
|
|
7677
|
+
}
|
|
7678
|
+
const cableStartsBelowBoard = belowBoard && !foldedFace;
|
|
7679
|
+
const defaultCableZ = cableStartsBelowBoard ? boardTopZ - boardThickness - boardClearance - flexCableThickness / 2 : boardTopZ + boardClearance + flexCableThickness / 2;
|
|
7680
|
+
const start = [
|
|
7681
|
+
cableStartX + cableLateralOffset,
|
|
7682
|
+
cableStartY,
|
|
7683
|
+
cableStartZ ?? defaultCableZ
|
|
7684
|
+
];
|
|
7685
|
+
const direction = belowBoard ? -1 : 1;
|
|
7686
|
+
const foldedScreenBackZ = orientation === "foldedToFaceAboveBoard" ? boardTopZ + distanceAboveBoard : boardTopZ - boardThickness - distanceBelowBoard;
|
|
7687
|
+
const foldedCableEndZ = orientation === "foldedToFaceAboveBoard" ? foldedScreenBackZ - screenGap - flexCableThickness / 2 : foldedScreenBackZ + screenGap + flexCableThickness / 2;
|
|
7688
|
+
const path = foldedFace ? createFoldedPath({
|
|
7689
|
+
start,
|
|
7690
|
+
endZ: foldedCableEndZ,
|
|
7691
|
+
flexCableLength,
|
|
7692
|
+
foldDistanceFromConnector,
|
|
7693
|
+
foldOutset,
|
|
7694
|
+
foldSegments
|
|
7695
|
+
}) : rightAngle ? createRightAnglePath({
|
|
7696
|
+
start,
|
|
7697
|
+
flexCableLength,
|
|
7698
|
+
bendRadius,
|
|
7699
|
+
bendSegments,
|
|
7700
|
+
verticalLead: rightAngleVerticalLead,
|
|
7701
|
+
direction
|
|
7702
|
+
}) : createFlatPath(start, flexCableLength);
|
|
7703
|
+
const totalCableLength = getPathDistances(path).at(-1);
|
|
7704
|
+
const contactLength = Math.min(
|
|
7705
|
+
Math.max(0, exposedContactLength),
|
|
7706
|
+
totalCableLength / 2
|
|
7707
|
+
);
|
|
7708
|
+
const resolvedStiffenerLength = Math.min(
|
|
7709
|
+
Math.max(0, stiffenerLength),
|
|
7710
|
+
totalCableLength / 2
|
|
7711
|
+
);
|
|
7712
|
+
const startContacts = slicePath(path, 0, contactLength);
|
|
7713
|
+
const endContacts = slicePath(
|
|
7714
|
+
path,
|
|
7715
|
+
totalCableLength - contactLength,
|
|
7716
|
+
totalCableLength
|
|
7717
|
+
);
|
|
7718
|
+
const startStiffener = slicePath(path, 0, resolvedStiffenerLength);
|
|
7719
|
+
const endStiffener = slicePath(
|
|
7720
|
+
path,
|
|
7721
|
+
totalCableLength - resolvedStiffenerLength,
|
|
7722
|
+
totalCableLength
|
|
7723
|
+
);
|
|
7724
|
+
const pathEnd = path.at(-1);
|
|
7725
|
+
let presetScreenRotation;
|
|
7726
|
+
let screenCenter;
|
|
7727
|
+
if (orientation === "sitsFlat") {
|
|
7728
|
+
presetScreenRotation = [0, 0, 0];
|
|
7729
|
+
screenCenter = [
|
|
7730
|
+
pathEnd[0],
|
|
7731
|
+
pathEnd[1] + size.height / 2,
|
|
7732
|
+
pathEnd[2] + flexCableThickness / 2 + screenGap
|
|
7733
|
+
];
|
|
7734
|
+
} else if (orientation === "sitsFlatBelowBoard") {
|
|
7735
|
+
presetScreenRotation = [0, Math.PI, 0];
|
|
7736
|
+
screenCenter = [
|
|
7737
|
+
pathEnd[0],
|
|
7738
|
+
pathEnd[1] + size.height / 2,
|
|
7739
|
+
pathEnd[2] - flexCableThickness / 2 - screenGap
|
|
7740
|
+
];
|
|
7741
|
+
} else if (orientation === "foldedToFaceAboveBoard") {
|
|
7742
|
+
presetScreenRotation = [0, 0, 0];
|
|
7743
|
+
screenCenter = [pathEnd[0], pathEnd[1] - size.height / 2, foldedScreenBackZ];
|
|
7744
|
+
} else if (orientation === "foldedToFaceBelowBoard") {
|
|
7745
|
+
presetScreenRotation = [0, Math.PI, 0];
|
|
7746
|
+
screenCenter = [pathEnd[0], pathEnd[1] - size.height / 2, foldedScreenBackZ];
|
|
7747
|
+
} else if (orientation === "foldedToRightAngleAboveBoard") {
|
|
7748
|
+
presetScreenRotation = [Math.PI / 2, 0, 0];
|
|
7749
|
+
screenCenter = [
|
|
7750
|
+
pathEnd[0],
|
|
7751
|
+
pathEnd[1] - flexCableThickness / 2 - screenGap,
|
|
7752
|
+
pathEnd[2] + size.height / 2
|
|
7753
|
+
];
|
|
7754
|
+
} else {
|
|
7755
|
+
presetScreenRotation = [-Math.PI / 2, 0, 0];
|
|
7756
|
+
screenCenter = [
|
|
7757
|
+
pathEnd[0],
|
|
7758
|
+
pathEnd[1] + flexCableThickness / 2 + screenGap,
|
|
7759
|
+
pathEnd[2] - size.height / 2
|
|
7760
|
+
];
|
|
7761
|
+
}
|
|
7762
|
+
screenCenter = [
|
|
7763
|
+
screenCenter[0] + (screenOffset?.x ?? 0),
|
|
7764
|
+
screenCenter[1] + (screenOffset?.y ?? 0),
|
|
7765
|
+
screenCenter[2] + (screenOffset?.z ?? 0)
|
|
7766
|
+
];
|
|
7767
|
+
const conductorOffsets = Array.from(
|
|
7768
|
+
{ length: conductorCount },
|
|
7769
|
+
(_, index) => conductorCount === 1 ? 0 : (index - (conductorCount - 1) / 2) * resolvedConductorPitch
|
|
7770
|
+
);
|
|
7771
|
+
const conductorNormalOffset = (flexCableThickness + conductorThickness) / 2;
|
|
7772
|
+
const stiffenerNormalOffset = -(flexCableThickness + stiffenerThickness) / 2;
|
|
7773
|
+
const assembly = /* @__PURE__ */ jsxs80(Fragment81, { children: [
|
|
7774
|
+
showFlexCable && /* @__PURE__ */ jsx85(
|
|
7775
|
+
CableStrip,
|
|
7776
|
+
{
|
|
7777
|
+
points: path,
|
|
7778
|
+
width: resolvedCableWidth,
|
|
7779
|
+
thickness: flexCableThickness,
|
|
7780
|
+
color: flexCableColor
|
|
7781
|
+
}
|
|
7782
|
+
),
|
|
7783
|
+
showFlexCable && showStiffeners && resolvedStiffenerLength > EPSILON && /* @__PURE__ */ jsxs80(Fragment81, { children: [
|
|
7784
|
+
/* @__PURE__ */ jsx85(
|
|
7785
|
+
CableStrip,
|
|
7786
|
+
{
|
|
7787
|
+
points: startStiffener,
|
|
7788
|
+
width: resolvedCableWidth,
|
|
7789
|
+
thickness: stiffenerThickness,
|
|
7790
|
+
color: stiffenerColor,
|
|
7791
|
+
normalOffset: stiffenerNormalOffset
|
|
7792
|
+
}
|
|
7793
|
+
),
|
|
7794
|
+
/* @__PURE__ */ jsx85(
|
|
7795
|
+
CableStrip,
|
|
7796
|
+
{
|
|
7797
|
+
points: endStiffener,
|
|
7798
|
+
width: resolvedCableWidth,
|
|
7799
|
+
thickness: stiffenerThickness,
|
|
7800
|
+
color: stiffenerColor,
|
|
7801
|
+
normalOffset: stiffenerNormalOffset
|
|
7802
|
+
}
|
|
7803
|
+
)
|
|
7804
|
+
] }),
|
|
7805
|
+
showFlexCable && showConductors && contactLength > EPSILON && conductorOffsets.map((acrossOffset, index) => /* @__PURE__ */ jsxs80(Fragment80, { children: [
|
|
7806
|
+
/* @__PURE__ */ jsx85(
|
|
7807
|
+
CableStrip,
|
|
7808
|
+
{
|
|
7809
|
+
points: startContacts,
|
|
7810
|
+
width: resolvedConductorWidth,
|
|
7811
|
+
thickness: conductorThickness,
|
|
7812
|
+
color: conductorColor,
|
|
7813
|
+
acrossOffset,
|
|
7814
|
+
normalOffset: conductorNormalOffset
|
|
7815
|
+
}
|
|
7816
|
+
),
|
|
7817
|
+
/* @__PURE__ */ jsx85(
|
|
7818
|
+
CableStrip,
|
|
7819
|
+
{
|
|
7820
|
+
points: endContacts,
|
|
7821
|
+
width: resolvedConductorWidth,
|
|
7822
|
+
thickness: conductorThickness,
|
|
7823
|
+
color: conductorColor,
|
|
7824
|
+
acrossOffset,
|
|
7825
|
+
normalOffset: conductorNormalOffset
|
|
7826
|
+
}
|
|
7827
|
+
)
|
|
7828
|
+
] }, `conductor:${index}`)),
|
|
7829
|
+
showScreen && /* @__PURE__ */ jsx85(Translate39, { offset: screenCenter, children: /* @__PURE__ */ jsx85(Rotate19, { rotation: screenRotation ?? presetScreenRotation, children: /* @__PURE__ */ jsx85(
|
|
7830
|
+
Screen,
|
|
7831
|
+
{
|
|
7832
|
+
width: size.width,
|
|
7833
|
+
height: size.height,
|
|
7834
|
+
thickness: screenThickness,
|
|
7835
|
+
bezelInset,
|
|
7836
|
+
bezelDepth,
|
|
7837
|
+
screenWidth: activeAreaWidth,
|
|
7838
|
+
screenHeight: activeAreaHeight,
|
|
7839
|
+
screenColor,
|
|
7840
|
+
bezelColor
|
|
7841
|
+
}
|
|
7842
|
+
) }) })
|
|
7843
|
+
] });
|
|
7844
|
+
return /* @__PURE__ */ jsx85(
|
|
7845
|
+
Translate39,
|
|
7846
|
+
{
|
|
7847
|
+
offset: {
|
|
7848
|
+
x: offset?.x ?? 0,
|
|
7849
|
+
y: offset?.y ?? 0,
|
|
7850
|
+
z: offset?.z ?? 0
|
|
7851
|
+
},
|
|
7852
|
+
children: /* @__PURE__ */ jsx85(Translate39, { offset: start, children: /* @__PURE__ */ jsx85(Rotate19, { rotation, children: /* @__PURE__ */ jsx85(Translate39, { offset: [-start[0], -start[1], -start[2]], children: assembly }) }) })
|
|
7853
|
+
}
|
|
7854
|
+
);
|
|
7855
|
+
};
|
|
7311
7856
|
export {
|
|
7312
7857
|
A01005,
|
|
7313
7858
|
A0201,
|
|
@@ -7330,6 +7875,7 @@ export {
|
|
|
7330
7875
|
FPC,
|
|
7331
7876
|
FemaleHeader,
|
|
7332
7877
|
FemaleHeaderRow,
|
|
7878
|
+
FlexScreen,
|
|
7333
7879
|
FootprintPad,
|
|
7334
7880
|
FootprintPlatedHole,
|
|
7335
7881
|
Footprinter3d,
|
|
@@ -7388,6 +7934,7 @@ export {
|
|
|
7388
7934
|
TO92,
|
|
7389
7935
|
TQFP,
|
|
7390
7936
|
Tssop,
|
|
7391
|
-
VSSOP
|
|
7937
|
+
VSSOP,
|
|
7938
|
+
resolveFlexScreenSize
|
|
7392
7939
|
};
|
|
7393
7940
|
//# sourceMappingURL=index.js.map
|