jscad-electronics 0.0.108 → 0.0.110

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/vanilla.js CHANGED
@@ -678,81 +678,84 @@ var PinRow = ({
678
678
  pitch = 2.54,
679
679
  longSidePinLength = 6,
680
680
  invert,
681
- faceup
681
+ faceup,
682
+ rows = 1
682
683
  }) => {
683
684
  const pinThickness = 0.63;
684
685
  const bodyHeight = 2;
685
- const bodyWidth = numberOfPins * pitch;
686
+ const pinsPerRow = Math.ceil(numberOfPins / rows);
687
+ const rowSpacing = 2.54;
688
+ const bodyWidth = pinsPerRow * pitch;
689
+ const bodyDepth = rows > 1 ? (rows - 1) * rowSpacing + pinThickness * 3 : pinThickness * 3;
686
690
  const shortSidePinLength = 3;
687
- const xoff = -((numberOfPins - 1) / 2) * pitch;
691
+ const xoff = -((pinsPerRow - 1) / 2) * pitch;
692
+ const bodyCenterY = rows > 1 ? -((rows - 1) * rowSpacing) / 2 : 0;
688
693
  const flipZ = (z) => invert || faceup ? -z + bodyHeight : z;
689
694
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
690
695
  /* @__PURE__ */ jsx(
691
696
  Cuboid,
692
697
  {
693
698
  color: "#222",
694
- size: [bodyWidth, pinThickness * 3, bodyHeight],
695
- center: [0, 0, flipZ(bodyHeight / 2)]
699
+ size: [bodyWidth, bodyDepth, bodyHeight],
700
+ center: [0, bodyCenterY, flipZ(bodyHeight / 2)]
696
701
  }
697
702
  ),
698
- Array.from({ length: numberOfPins }, (_, i) => /* @__PURE__ */ jsxs(Fragment2, { children: [
699
- !faceup && /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
700
- /* @__PURE__ */ jsx(
701
- Cuboid,
702
- {
703
- color: "gold",
704
- size: [pinThickness, pinThickness, shortSidePinLength * 0.9],
705
- center: [
706
- xoff + i * pitch,
707
- 0,
708
- flipZ(bodyHeight * 0.9 + bodyHeight / 2)
709
- ]
710
- }
711
- ),
712
- /* @__PURE__ */ jsx(
713
- Cuboid,
714
- {
715
- color: "gold",
716
- size: [
717
- pinThickness / 1.8,
718
- pinThickness / 1.8,
719
- shortSidePinLength
720
- ],
721
- center: [
722
- xoff + i * pitch,
723
- 0,
724
- flipZ(bodyHeight + bodyHeight / 2)
725
- ]
726
- }
727
- )
728
- ] }) }),
729
- /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
730
- /* @__PURE__ */ jsx(
731
- Cuboid,
732
- {
733
- color: "gold",
734
- size: [pinThickness, pinThickness, longSidePinLength * 0.9],
735
- center: [
736
- xoff + i * pitch,
737
- 0,
738
- flipZ(-longSidePinLength / 2 * 0.9)
739
- ]
740
- }
741
- ),
742
- /* @__PURE__ */ jsx(
743
- Cuboid,
744
- {
745
- color: "gold",
746
- size: [
747
- pinThickness / 1.8,
748
- pinThickness / 1.8,
749
- longSidePinLength
750
- ],
751
- center: [xoff + i * pitch, 0, flipZ(-longSidePinLength / 2)]
752
- }
753
- )
754
- ] }) })
755
- ] }))
703
+ Array.from({ length: numberOfPins }, (_, i) => {
704
+ const row = Math.floor(i / pinsPerRow);
705
+ const col = i % pinsPerRow;
706
+ const x = xoff + col * pitch;
707
+ const y = -row * rowSpacing;
708
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
709
+ !faceup && /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
710
+ /* @__PURE__ */ jsx(
711
+ Cuboid,
712
+ {
713
+ color: "gold",
714
+ size: [
715
+ pinThickness,
716
+ pinThickness,
717
+ shortSidePinLength * 0.9
718
+ ],
719
+ center: [x, y, flipZ(bodyHeight * 0.9 + bodyHeight / 2)]
720
+ }
721
+ ),
722
+ /* @__PURE__ */ jsx(
723
+ Cuboid,
724
+ {
725
+ color: "gold",
726
+ size: [
727
+ pinThickness / 1.8,
728
+ pinThickness / 1.8,
729
+ shortSidePinLength
730
+ ],
731
+ center: [x, y, flipZ(bodyHeight + bodyHeight / 2)]
732
+ }
733
+ )
734
+ ] }) }, `short-${i}`),
735
+ /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsxs(Hull, { children: [
736
+ /* @__PURE__ */ jsx(
737
+ Cuboid,
738
+ {
739
+ color: "gold",
740
+ size: [pinThickness, pinThickness, longSidePinLength * 0.9],
741
+ center: [x, y, flipZ(-longSidePinLength / 2 * 0.9)]
742
+ }
743
+ ),
744
+ /* @__PURE__ */ jsx(
745
+ Cuboid,
746
+ {
747
+ color: "gold",
748
+ size: [
749
+ pinThickness / 1.8,
750
+ pinThickness / 1.8,
751
+ longSidePinLength
752
+ ],
753
+ center: [x, y, flipZ(-longSidePinLength / 2)]
754
+ }
755
+ )
756
+ ] }) }, `long-${i}`)
757
+ ] });
758
+ })
756
759
  ] });
757
760
  };
758
761
 
@@ -1315,31 +1318,39 @@ var FemaleHeader = ({
1315
1318
  pitch = 2.54,
1316
1319
  legsLength = 3,
1317
1320
  outerDiameter = 0.945,
1318
- innerDiameter = 0.945
1321
+ innerDiameter = 0.945,
1322
+ rows = 1
1319
1323
  }) => {
1320
1324
  const pinThickness = innerDiameter / 1.5;
1321
1325
  const bodyDepth = pinThickness * 2 + outerDiameter;
1322
1326
  const bodyHeight = 5;
1323
- const bodyWidth = (numberOfPins - 1) * pitch + outerDiameter + pitch / 2;
1327
+ const pinsPerRow = Math.ceil(numberOfPins / rows);
1328
+ const rowSpacing = 2.54;
1329
+ const bodyWidth = (pinsPerRow - 1) * pitch + outerDiameter + pitch / 2;
1330
+ const bodyDepthTotal = rows > 1 ? (rows - 1) * rowSpacing + bodyDepth : bodyDepth;
1324
1331
  const gapWidth = pinThickness * 1.6;
1325
- const xoff = -((numberOfPins - 1) / 2) * pitch;
1332
+ const xoff = -((pinsPerRow - 1) / 2) * pitch;
1333
+ const bodyCenterY = rows > 1 ? -((rows - 1) * rowSpacing) / 2 : 0;
1326
1334
  const Body = /* @__PURE__ */ jsx(Colorize, { color: "#1a1a1a", children: /* @__PURE__ */ jsxs(Subtract, { children: [
1327
1335
  /* @__PURE__ */ jsx(
1328
1336
  Cuboid,
1329
1337
  {
1330
1338
  color: "#000",
1331
- size: [bodyWidth, bodyDepth, bodyHeight],
1332
- center: [0, 0, bodyHeight / 2]
1339
+ size: [bodyWidth, bodyDepthTotal, bodyHeight],
1340
+ center: [0, bodyCenterY, bodyHeight / 2]
1333
1341
  }
1334
1342
  ),
1335
- Array.from(
1336
- { length: numberOfPins },
1337
- (_, i) => innerDiameter ? /* @__PURE__ */ jsx(
1343
+ Array.from({ length: numberOfPins }, (_, i) => {
1344
+ const row = Math.floor(i / pinsPerRow);
1345
+ const col = i % pinsPerRow;
1346
+ const x = xoff + col * pitch;
1347
+ const y = -row * rowSpacing;
1348
+ return innerDiameter ? /* @__PURE__ */ jsx(
1338
1349
  Cylinder,
1339
1350
  {
1340
1351
  height: bodyHeight + 0.1,
1341
1352
  radius: innerDiameter / 2,
1342
- center: [xoff + i * pitch, 0, bodyHeight / 2],
1353
+ center: [x, y, bodyHeight / 2],
1343
1354
  color: "#222"
1344
1355
  },
1345
1356
  i
@@ -1347,42 +1358,48 @@ var FemaleHeader = ({
1347
1358
  Cuboid,
1348
1359
  {
1349
1360
  size: [gapWidth, gapWidth, bodyHeight],
1350
- center: [xoff + i * pitch, 0, bodyHeight / 2]
1361
+ center: [x, y, bodyHeight / 2]
1351
1362
  },
1352
1363
  i
1353
- )
1354
- )
1364
+ );
1365
+ })
1355
1366
  ] }) });
1356
1367
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
1357
1368
  Body,
1358
- Array.from({ length: numberOfPins }, (_, i) => /* @__PURE__ */ jsxs(Colorize, { color: "silver", children: [
1359
- /* @__PURE__ */ jsxs(Hull, { children: [
1360
- /* @__PURE__ */ jsx(
1361
- Cuboid,
1362
- {
1363
- color: "silver",
1364
- size: [pinThickness, pinThickness, legsLength * 0.9],
1365
- center: [xoff + i * pitch, 0, -legsLength / 2 * 0.9]
1366
- }
1367
- ),
1369
+ Array.from({ length: numberOfPins }, (_, i) => {
1370
+ const row = Math.floor(i / pinsPerRow);
1371
+ const col = i % pinsPerRow;
1372
+ const x = xoff + col * pitch;
1373
+ const y = -row * rowSpacing;
1374
+ return /* @__PURE__ */ jsxs(Colorize, { color: "silver", children: [
1375
+ /* @__PURE__ */ jsxs(Hull, { children: [
1376
+ /* @__PURE__ */ jsx(
1377
+ Cuboid,
1378
+ {
1379
+ color: "silver",
1380
+ size: [pinThickness, pinThickness, legsLength * 0.9],
1381
+ center: [x, y, -legsLength / 2 * 0.9]
1382
+ }
1383
+ ),
1384
+ /* @__PURE__ */ jsx(
1385
+ Cuboid,
1386
+ {
1387
+ color: "silver",
1388
+ size: [pinThickness / 1.8, pinThickness / 1.8, legsLength],
1389
+ center: [x, y, -legsLength / 2]
1390
+ }
1391
+ )
1392
+ ] }),
1368
1393
  /* @__PURE__ */ jsx(
1369
1394
  Cuboid,
1370
1395
  {
1371
1396
  color: "silver",
1372
- size: [pinThickness / 1.8, pinThickness / 1.8, legsLength],
1373
- center: [xoff + i * pitch, 0, -legsLength / 2]
1397
+ size: [gapWidth, gapWidth, gapWidth * 0.5],
1398
+ center: [x, y, gapWidth / 2 * 0.5]
1374
1399
  }
1375
1400
  )
1376
- ] }),
1377
- /* @__PURE__ */ jsx(
1378
- Cuboid,
1379
- {
1380
- color: "silver",
1381
- size: [gapWidth, gapWidth, gapWidth * 0.5],
1382
- center: [xoff + i * pitch, 0, gapWidth / 2 * 0.5]
1383
- }
1384
- )
1385
- ] }, i))
1401
+ ] }, i);
1402
+ })
1386
1403
  ] });
1387
1404
  };
1388
1405
 
@@ -3978,7 +3995,9 @@ var Footprinter3d = ({ footprint }) => {
3978
3995
  }
3979
3996
  );
3980
3997
  }
3981
- case "pinrow":
3998
+ case "pinrow": {
3999
+ const rowsMatch = footprint.match(/_rows(\d+)/);
4000
+ const rows = rowsMatch && rowsMatch[1] ? parseInt(rowsMatch[1], 10) : 1;
3982
4001
  if (fpJson.male)
3983
4002
  return /* @__PURE__ */ jsx(
3984
4003
  PinRow,
@@ -3986,11 +4005,20 @@ var Footprinter3d = ({ footprint }) => {
3986
4005
  numberOfPins: fpJson.num_pins,
3987
4006
  pitch: fpJson.p,
3988
4007
  invert: fpJson.invert,
3989
- faceup: fpJson.faceup
4008
+ faceup: fpJson.faceup,
4009
+ rows
3990
4010
  }
3991
4011
  );
3992
4012
  if (fpJson.female)
3993
- return /* @__PURE__ */ jsx(FemaleHeader, { numberOfPins: fpJson.num_pins, pitch: fpJson.p });
4013
+ return /* @__PURE__ */ jsx(
4014
+ FemaleHeader,
4015
+ {
4016
+ numberOfPins: fpJson.num_pins,
4017
+ pitch: fpJson.p,
4018
+ rows
4019
+ }
4020
+ );
4021
+ }
3994
4022
  case "cap": {
3995
4023
  switch (fpJson.imperial) {
3996
4024
  case "0402":