jscad-electronics 0.0.115 → 0.0.116

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
@@ -743,6 +743,92 @@ var getLeadWidth = (pinCount, width10) => {
743
743
  }
744
744
  };
745
745
 
746
+ // lib/PinHeader.tsx
747
+ var PinHeader = ({
748
+ x,
749
+ y,
750
+ pinThickness,
751
+ shortSidePinLength,
752
+ longSidePinLength,
753
+ bodyHeight,
754
+ bodyLength: bodyLength10 = 2.54,
755
+ bodyWidth = 2.54,
756
+ flipZ,
757
+ faceup,
758
+ smd,
759
+ rightangle
760
+ }) => {
761
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
762
+ /* @__PURE__ */ jsx(Translate, { y: rightangle ? -3 : 0, children: /* @__PURE__ */ jsx(
763
+ Cuboid,
764
+ {
765
+ color: "#222",
766
+ size: [bodyLength10, bodyWidth, bodyHeight],
767
+ center: [x, y, flipZ(bodyHeight / 2)]
768
+ }
769
+ ) }),
770
+ !faceup && /* @__PURE__ */ jsx(Colorize, { color: "gold", children: smd ? /* @__PURE__ */ jsx(
771
+ SmdChipLead,
772
+ {
773
+ rotation: -Math.PI / 2,
774
+ position: {
775
+ x,
776
+ y: y + 1,
777
+ z: pinThickness / 2
778
+ },
779
+ thickness: pinThickness,
780
+ width: pinThickness,
781
+ height: pinThickness,
782
+ padContactLength: 2,
783
+ bodyDistance: 3
784
+ }
785
+ ) : /* @__PURE__ */ jsxs(Hull, { children: [
786
+ /* @__PURE__ */ jsx(
787
+ Cuboid,
788
+ {
789
+ color: "gold",
790
+ size: [pinThickness, pinThickness, shortSidePinLength * 0.9],
791
+ center: [x, y, flipZ(bodyHeight * 0.9 + bodyHeight / 2)]
792
+ }
793
+ ),
794
+ /* @__PURE__ */ jsx(
795
+ Cuboid,
796
+ {
797
+ color: "gold",
798
+ size: [
799
+ pinThickness / 1.8,
800
+ pinThickness / 1.8,
801
+ shortSidePinLength
802
+ ],
803
+ center: [x, y, flipZ(bodyHeight + bodyHeight / 2)]
804
+ }
805
+ )
806
+ ] }) }),
807
+ /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsx(Translate, { y: rightangle ? -3.9 : 0, z: rightangle ? 1 : 0, children: /* @__PURE__ */ jsx(Rotate, { rotation: rightangle ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: /* @__PURE__ */ jsxs(Hull, { children: [
808
+ /* @__PURE__ */ jsx(
809
+ Cuboid,
810
+ {
811
+ color: "gold",
812
+ size: [pinThickness, pinThickness, longSidePinLength * 0.9],
813
+ center: [x, y, flipZ(-longSidePinLength / 2 * 0.9)]
814
+ }
815
+ ),
816
+ /* @__PURE__ */ jsx(
817
+ Cuboid,
818
+ {
819
+ color: "gold",
820
+ size: [
821
+ pinThickness / 1.8,
822
+ pinThickness / 1.8,
823
+ longSidePinLength
824
+ ],
825
+ center: [x, y, flipZ(-longSidePinLength / 2)]
826
+ }
827
+ )
828
+ ] }) }) }) })
829
+ ] });
830
+ };
831
+
746
832
  // lib/PinRow.tsx
747
833
  var PinRow = ({
748
834
  numberOfPins,
@@ -758,106 +844,32 @@ var PinRow = ({
758
844
  const bodyHeight = 2;
759
845
  const pinsPerRow = Math.ceil(numberOfPins / rows);
760
846
  const rowSpacing = 2.54;
761
- const bodyWidth = pinsPerRow * pitch;
762
- const bodyDepth = rows > 1 ? (rows - 1) * rowSpacing + pinThickness * 3 : pinThickness * 3;
763
847
  const shortSidePinLength = 3;
764
848
  const xoff = -((pinsPerRow - 1) / 2) * pitch;
765
- const bodyCenterY = rows > 1 ? -((rows - 1) * rowSpacing) / 2 : 0;
766
849
  const zOffset = !smd && !rightangle ? -bodyHeight - 1.6 : 0;
767
850
  const flipZ = (z) => (invert || faceup ? -z + bodyHeight : z) + zOffset;
768
- return /* @__PURE__ */ jsxs(Fragment2, { children: [
769
- /* @__PURE__ */ jsx(Translate, { y: rightangle ? -3 : 0, children: /* @__PURE__ */ jsx(
770
- Cuboid,
771
- {
772
- color: "#222",
773
- size: [bodyWidth, bodyDepth, bodyHeight],
774
- center: [0, bodyCenterY, flipZ(bodyHeight / 2)]
775
- }
776
- ) }),
777
- Array.from({ length: numberOfPins }, (_, i) => {
778
- const row = Math.floor(i / pinsPerRow);
779
- const col = i % pinsPerRow;
780
- const x = xoff + col * pitch;
781
- const y = -row * rowSpacing;
782
- return /* @__PURE__ */ jsxs(Fragment2, { children: [
783
- !faceup && /* @__PURE__ */ jsx(Colorize, { color: "gold", children: smd ? /* @__PURE__ */ jsx(
784
- SmdChipLead,
785
- {
786
- rotation: -Math.PI / 2,
787
- position: {
788
- x,
789
- y: y + 1,
790
- z: pinThickness / 2
791
- },
792
- thickness: pinThickness,
793
- width: pinThickness,
794
- height: pinThickness,
795
- padContactLength: 2,
796
- bodyDistance: 3
797
- },
798
- `short-smd-${i}`
799
- ) : /* @__PURE__ */ jsxs(Hull, { children: [
800
- /* @__PURE__ */ jsx(
801
- Cuboid,
802
- {
803
- color: "gold",
804
- size: [
805
- pinThickness,
806
- pinThickness,
807
- shortSidePinLength * 0.9
808
- ],
809
- center: [x, y, flipZ(bodyHeight * 0.9 + bodyHeight / 2)]
810
- }
811
- ),
812
- /* @__PURE__ */ jsx(
813
- Cuboid,
814
- {
815
- color: "gold",
816
- size: [
817
- pinThickness / 1.8,
818
- pinThickness / 1.8,
819
- shortSidePinLength
820
- ],
821
- center: [x, y, flipZ(bodyHeight + bodyHeight / 2)]
822
- }
823
- )
824
- ] }) }, `short-${i}`),
825
- /* @__PURE__ */ jsx(Colorize, { color: "gold", children: /* @__PURE__ */ jsx(Translate, { y: rightangle ? -3.9 : 0, z: rightangle ? 1 : 0, children: /* @__PURE__ */ jsx(
826
- Rotate,
827
- {
828
- rotation: rightangle ? [-Math.PI / 2, 0, 0] : [0, 0, 0],
829
- children: /* @__PURE__ */ jsxs(Hull, { children: [
830
- /* @__PURE__ */ jsx(
831
- Cuboid,
832
- {
833
- color: "gold",
834
- size: [
835
- pinThickness,
836
- pinThickness,
837
- longSidePinLength * 0.9
838
- ],
839
- center: [x, y, flipZ(-longSidePinLength / 2 * 0.9)]
840
- }
841
- ),
842
- /* @__PURE__ */ jsx(
843
- Cuboid,
844
- {
845
- color: "gold",
846
- size: [
847
- pinThickness / 1.8,
848
- pinThickness / 1.8,
849
- longSidePinLength
850
- ],
851
- center: [x, y, flipZ(-longSidePinLength / 2)]
852
- }
853
- )
854
- ] })
855
- },
856
- `rotate-${i}`
857
- ) }) }, `long-${i}`)
858
- ] });
859
- })
860
- ] });
851
+ return /* @__PURE__ */ jsx(Fragment2, { children: Array.from({ length: numberOfPins }, (_, i) => {
852
+ const row = Math.floor(i / pinsPerRow);
853
+ const col = i % pinsPerRow;
854
+ const x = xoff + col * pitch;
855
+ const y = -row * rowSpacing;
856
+ return /* @__PURE__ */ jsx(
857
+ PinHeader,
858
+ {
859
+ x,
860
+ y,
861
+ pinThickness,
862
+ shortSidePinLength,
863
+ longSidePinLength,
864
+ bodyHeight,
865
+ flipZ,
866
+ faceup,
867
+ smd,
868
+ rightangle
869
+ },
870
+ i
871
+ );
872
+ }) });
861
873
  };
862
874
 
863
875
  // lib/utils/getQuadCoords.ts
@@ -4189,6 +4201,162 @@ var StampBoard = ({
4189
4201
  ] });
4190
4202
  };
4191
4203
 
4204
+ // lib/MountedPcbModule.tsx
4205
+ var MountedPcbModule = ({
4206
+ numPins = 5,
4207
+ rows = 1,
4208
+ p = 2.54,
4209
+ id = 1,
4210
+ od = 1.5,
4211
+ boardThickness = 1.6,
4212
+ width: width10,
4213
+ height: height10,
4214
+ pinRowSide = "left",
4215
+ holes = [],
4216
+ holeInset = 1,
4217
+ pinRowHoleEdgeToEdgeDist = 2
4218
+ }) => {
4219
+ const boardCenterZ = boardThickness / 2;
4220
+ const numPinsPerRow = Math.ceil(numPins / rows);
4221
+ let calculatedWidth;
4222
+ let calculatedHeight;
4223
+ if (pinRowSide === "left" || pinRowSide === "right") {
4224
+ calculatedWidth = (rows - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
4225
+ calculatedHeight = (numPinsPerRow - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
4226
+ } else {
4227
+ calculatedHeight = (rows - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
4228
+ calculatedWidth = (numPinsPerRow - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
4229
+ }
4230
+ if (numPins === 0) {
4231
+ calculatedWidth = 10;
4232
+ calculatedHeight = 10;
4233
+ }
4234
+ const finalWidth = Number(width10 ?? calculatedWidth);
4235
+ const finalHeight = Number(height10 ?? calculatedHeight);
4236
+ const pins = [];
4237
+ let pinStartX = 0;
4238
+ let pinStartY = 0;
4239
+ let pinDirectionX = 0;
4240
+ let pinDirectionY = 0;
4241
+ let rowDirectionX = 0;
4242
+ let rowDirectionY = 0;
4243
+ if (pinRowSide === "left" || pinRowSide === "right") {
4244
+ pinStartX = pinRowSide === "left" ? -finalWidth / 2 + pinRowHoleEdgeToEdgeDist : finalWidth / 2 - pinRowHoleEdgeToEdgeDist;
4245
+ pinStartY = -((numPinsPerRow - 1) / 2) * p;
4246
+ pinDirectionX = 0;
4247
+ pinDirectionY = p;
4248
+ rowDirectionX = pinRowSide === "left" ? p : -p;
4249
+ rowDirectionY = 0;
4250
+ } else {
4251
+ pinStartX = -((numPinsPerRow - 1) / 2) * p;
4252
+ pinStartY = pinRowSide === "top" ? finalHeight / 2 - pinRowHoleEdgeToEdgeDist : -finalHeight / 2 + pinRowHoleEdgeToEdgeDist;
4253
+ pinDirectionX = p;
4254
+ pinDirectionY = 0;
4255
+ rowDirectionX = 0;
4256
+ rowDirectionY = pinRowSide === "top" ? -p : p;
4257
+ }
4258
+ let pinNumber = 0;
4259
+ for (let row = 0; row < rows && pinNumber < numPins; row++) {
4260
+ for (let col = 0; col < numPinsPerRow && pinNumber < numPins; col++) {
4261
+ const x = pinStartX + col * pinDirectionX + row * rowDirectionX;
4262
+ const y = pinStartY + col * pinDirectionY + row * rowDirectionY;
4263
+ pins.push({ x, y });
4264
+ pinNumber++;
4265
+ }
4266
+ }
4267
+ const holePositions = [];
4268
+ if (holes) {
4269
+ for (const pos of holes) {
4270
+ let hx = 0;
4271
+ let hy = 0;
4272
+ if (pos === "topleft") {
4273
+ hx = -finalWidth / 2 + holeInset;
4274
+ hy = finalHeight / 2 - holeInset;
4275
+ } else if (pos === "topright") {
4276
+ hx = finalWidth / 2 - holeInset;
4277
+ hy = finalHeight / 2 - holeInset;
4278
+ } else if (pos === "bottomleft") {
4279
+ hx = -finalWidth / 2 + holeInset;
4280
+ hy = -finalHeight / 2 + holeInset;
4281
+ } else if (pos === "bottomright") {
4282
+ hx = finalWidth / 2 - holeInset;
4283
+ hy = -finalHeight / 2 + holeInset;
4284
+ } else if (pos === "center") {
4285
+ hx = 0;
4286
+ hy = 0;
4287
+ }
4288
+ holePositions.push({ x: hx, y: hy });
4289
+ }
4290
+ }
4291
+ const pinThickness = 0.63;
4292
+ const pinBodyHeight = 2;
4293
+ const longSidePinLength = 6;
4294
+ const shortSidePinLength = 3;
4295
+ const boardBody = /* @__PURE__ */ jsx(Colorize, { color: "#008080", children: /* @__PURE__ */ jsxs(Subtract, { children: [
4296
+ /* @__PURE__ */ jsx(
4297
+ Cuboid,
4298
+ {
4299
+ center: [0, 0, boardCenterZ + pinBodyHeight],
4300
+ size: [finalWidth, finalHeight, boardThickness]
4301
+ }
4302
+ ),
4303
+ holePositions.map((hole, index) => /* @__PURE__ */ jsx(
4304
+ Cylinder,
4305
+ {
4306
+ center: [hole.x, hole.y, boardCenterZ + pinBodyHeight],
4307
+ radius: od / 2,
4308
+ height: boardThickness
4309
+ },
4310
+ `hole-${index}`
4311
+ )),
4312
+ pins.map((pin, index) => /* @__PURE__ */ jsx(
4313
+ Cylinder,
4314
+ {
4315
+ center: [pin.x, pin.y, boardCenterZ + pinBodyHeight],
4316
+ radius: od / 2,
4317
+ height: boardThickness
4318
+ },
4319
+ `pin-hole-${index}`
4320
+ ))
4321
+ ] }) });
4322
+ const platedHoles = pins.map((pin, index) => /* @__PURE__ */ jsx(Colorize, { color: "#FFD700", children: /* @__PURE__ */ jsxs(Subtract, { children: [
4323
+ /* @__PURE__ */ jsx(
4324
+ Cylinder,
4325
+ {
4326
+ center: [pin.x, pin.y, boardThickness / 2 + pinBodyHeight],
4327
+ radius: od / 2,
4328
+ height: boardThickness
4329
+ }
4330
+ ),
4331
+ /* @__PURE__ */ jsx(
4332
+ Cylinder,
4333
+ {
4334
+ center: [pin.x, pin.y, boardThickness / 2 + pinBodyHeight],
4335
+ radius: id / 2,
4336
+ height: boardThickness
4337
+ }
4338
+ )
4339
+ ] }) }, `pin-${index}`));
4340
+ const headerPins = pins.map((pin, index) => /* @__PURE__ */ jsx(
4341
+ PinHeader,
4342
+ {
4343
+ x: pin.x,
4344
+ y: pin.y,
4345
+ pinThickness,
4346
+ shortSidePinLength,
4347
+ longSidePinLength,
4348
+ bodyHeight: pinBodyHeight,
4349
+ flipZ: (z) => z
4350
+ },
4351
+ `pin-3d-${index}`
4352
+ ));
4353
+ return /* @__PURE__ */ jsxs(Fragment2, { children: [
4354
+ boardBody,
4355
+ platedHoles,
4356
+ headerPins
4357
+ ] });
4358
+ };
4359
+
4192
4360
  // lib/Footprinter3d.tsx
4193
4361
  var Footprinter3d = ({ footprint }) => {
4194
4362
  const fpJson = fp2.string(footprint).json();
@@ -4445,6 +4613,32 @@ var Footprinter3d = ({ footprint }) => {
4445
4613
  innerHoleEdgeDistance: fpJson.innerholeedgedistance
4446
4614
  }
4447
4615
  );
4616
+ case "mountedpcbmodule": {
4617
+ const rows = fpJson.rows ?? 1;
4618
+ const pinRowSide = fpJson.pinRowSide ?? "left";
4619
+ const holeInset = fpJson.holeInset;
4620
+ const width10 = fpJson.width;
4621
+ const height10 = fpJson.height;
4622
+ const pinRow = fpJson.pinrow;
4623
+ const pinRowHoleEdgeToEdgeDist = fpJson.pinRowHoleEdgeToEdgeDist;
4624
+ const holes = Array.isArray(fpJson.holes) ? fpJson.holes : [];
4625
+ return /* @__PURE__ */ jsx(
4626
+ MountedPcbModule,
4627
+ {
4628
+ numPins: pinRow,
4629
+ rows,
4630
+ p: fpJson.p,
4631
+ id: fpJson.id,
4632
+ od: fpJson.od,
4633
+ width: width10,
4634
+ height: height10,
4635
+ pinRowSide,
4636
+ holes,
4637
+ holeInset,
4638
+ pinRowHoleEdgeToEdgeDist
4639
+ }
4640
+ );
4641
+ }
4448
4642
  }
4449
4643
  const colorMatch = footprint.match(/_color\(([^)]+)\)/);
4450
4644
  const color = colorMatch ? colorMatch[1] : void 0;