jscad-electronics 0.0.115 → 0.0.117
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 +32 -1
- package/dist/index.js +709 -507
- package/dist/index.js.map +1 -1
- package/dist/vanilla.js +293 -96
- package/dist/vanilla.js.map +1 -1
- package/package.json +2 -2
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__ */
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
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,164 @@ 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
|
+
nopin
|
|
4219
|
+
}) => {
|
|
4220
|
+
const boardCenterZ = boardThickness / 2;
|
|
4221
|
+
const numPinsPerRow = Math.ceil(numPins / rows);
|
|
4222
|
+
let calculatedWidth;
|
|
4223
|
+
let calculatedHeight;
|
|
4224
|
+
if (pinRowSide === "left" || pinRowSide === "right") {
|
|
4225
|
+
calculatedWidth = (rows - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
|
|
4226
|
+
calculatedHeight = (numPinsPerRow - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
|
|
4227
|
+
} else {
|
|
4228
|
+
calculatedHeight = (rows - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
|
|
4229
|
+
calculatedWidth = (numPinsPerRow - 1) * p + 2 * pinRowHoleEdgeToEdgeDist;
|
|
4230
|
+
}
|
|
4231
|
+
if (numPins === 0) {
|
|
4232
|
+
calculatedWidth = 10;
|
|
4233
|
+
calculatedHeight = 10;
|
|
4234
|
+
}
|
|
4235
|
+
const finalWidth = Number(width10 ?? calculatedWidth);
|
|
4236
|
+
const finalHeight = Number(height10 ?? calculatedHeight);
|
|
4237
|
+
const pins = [];
|
|
4238
|
+
let pinStartX = 0;
|
|
4239
|
+
let pinStartY = 0;
|
|
4240
|
+
let pinDirectionX = 0;
|
|
4241
|
+
let pinDirectionY = 0;
|
|
4242
|
+
let rowDirectionX = 0;
|
|
4243
|
+
let rowDirectionY = 0;
|
|
4244
|
+
if (pinRowSide === "left" || pinRowSide === "right") {
|
|
4245
|
+
pinStartX = pinRowSide === "left" ? -finalWidth / 2 + pinRowHoleEdgeToEdgeDist : finalWidth / 2 - pinRowHoleEdgeToEdgeDist;
|
|
4246
|
+
pinStartY = -((numPinsPerRow - 1) / 2) * p;
|
|
4247
|
+
pinDirectionX = 0;
|
|
4248
|
+
pinDirectionY = p;
|
|
4249
|
+
rowDirectionX = pinRowSide === "left" ? p : -p;
|
|
4250
|
+
rowDirectionY = 0;
|
|
4251
|
+
} else {
|
|
4252
|
+
pinStartX = -((numPinsPerRow - 1) / 2) * p;
|
|
4253
|
+
pinStartY = pinRowSide === "top" ? finalHeight / 2 - pinRowHoleEdgeToEdgeDist : -finalHeight / 2 + pinRowHoleEdgeToEdgeDist;
|
|
4254
|
+
pinDirectionX = p;
|
|
4255
|
+
pinDirectionY = 0;
|
|
4256
|
+
rowDirectionX = 0;
|
|
4257
|
+
rowDirectionY = pinRowSide === "top" ? -p : p;
|
|
4258
|
+
}
|
|
4259
|
+
let pinNumber = 0;
|
|
4260
|
+
for (let row = 0; row < rows && pinNumber < numPins; row++) {
|
|
4261
|
+
for (let col = 0; col < numPinsPerRow && pinNumber < numPins; col++) {
|
|
4262
|
+
const x = pinStartX + col * pinDirectionX + row * rowDirectionX;
|
|
4263
|
+
const y = pinStartY + col * pinDirectionY + row * rowDirectionY;
|
|
4264
|
+
pins.push({ x, y });
|
|
4265
|
+
pinNumber++;
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
const holePositions = [];
|
|
4269
|
+
if (holes) {
|
|
4270
|
+
for (const pos of holes) {
|
|
4271
|
+
let hx = 0;
|
|
4272
|
+
let hy = 0;
|
|
4273
|
+
if (pos === "topleft") {
|
|
4274
|
+
hx = -finalWidth / 2 + holeInset;
|
|
4275
|
+
hy = finalHeight / 2 - holeInset;
|
|
4276
|
+
} else if (pos === "topright") {
|
|
4277
|
+
hx = finalWidth / 2 - holeInset;
|
|
4278
|
+
hy = finalHeight / 2 - holeInset;
|
|
4279
|
+
} else if (pos === "bottomleft") {
|
|
4280
|
+
hx = -finalWidth / 2 + holeInset;
|
|
4281
|
+
hy = -finalHeight / 2 + holeInset;
|
|
4282
|
+
} else if (pos === "bottomright") {
|
|
4283
|
+
hx = finalWidth / 2 - holeInset;
|
|
4284
|
+
hy = -finalHeight / 2 + holeInset;
|
|
4285
|
+
} else if (pos === "center") {
|
|
4286
|
+
hx = 0;
|
|
4287
|
+
hy = 0;
|
|
4288
|
+
}
|
|
4289
|
+
holePositions.push({ x: hx, y: hy });
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
const pinThickness = 0.63;
|
|
4293
|
+
const pinBodyHeight = 2;
|
|
4294
|
+
const longSidePinLength = 6;
|
|
4295
|
+
const shortSidePinLength = 3;
|
|
4296
|
+
const boardOffsetZ = nopin ? 0 : pinBodyHeight;
|
|
4297
|
+
const boardBody = /* @__PURE__ */ jsx(Colorize, { color: "#008080", children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
4298
|
+
/* @__PURE__ */ jsx(
|
|
4299
|
+
Cuboid,
|
|
4300
|
+
{
|
|
4301
|
+
center: [0, 0, boardCenterZ + boardOffsetZ],
|
|
4302
|
+
size: [finalWidth, finalHeight, boardThickness]
|
|
4303
|
+
}
|
|
4304
|
+
),
|
|
4305
|
+
holePositions.map((hole, index) => /* @__PURE__ */ jsx(
|
|
4306
|
+
Cylinder,
|
|
4307
|
+
{
|
|
4308
|
+
center: [hole.x, hole.y, boardCenterZ + boardOffsetZ],
|
|
4309
|
+
radius: od / 2,
|
|
4310
|
+
height: boardThickness
|
|
4311
|
+
},
|
|
4312
|
+
`hole-${index}`
|
|
4313
|
+
)),
|
|
4314
|
+
pins.map((pin, index) => /* @__PURE__ */ jsx(
|
|
4315
|
+
Cylinder,
|
|
4316
|
+
{
|
|
4317
|
+
center: [pin.x, pin.y, boardCenterZ + boardOffsetZ],
|
|
4318
|
+
radius: od / 2,
|
|
4319
|
+
height: boardThickness
|
|
4320
|
+
},
|
|
4321
|
+
`pin-hole-${index}`
|
|
4322
|
+
))
|
|
4323
|
+
] }) });
|
|
4324
|
+
const platedHoles = pins.map((pin, index) => /* @__PURE__ */ jsx(Colorize, { color: "#FFD700", children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
4325
|
+
/* @__PURE__ */ jsx(
|
|
4326
|
+
Cylinder,
|
|
4327
|
+
{
|
|
4328
|
+
center: [pin.x, pin.y, boardThickness / 2 + boardOffsetZ],
|
|
4329
|
+
radius: od / 2,
|
|
4330
|
+
height: boardThickness
|
|
4331
|
+
}
|
|
4332
|
+
),
|
|
4333
|
+
/* @__PURE__ */ jsx(
|
|
4334
|
+
Cylinder,
|
|
4335
|
+
{
|
|
4336
|
+
center: [pin.x, pin.y, boardThickness / 2 + boardOffsetZ],
|
|
4337
|
+
radius: id / 2,
|
|
4338
|
+
height: boardThickness
|
|
4339
|
+
}
|
|
4340
|
+
)
|
|
4341
|
+
] }) }, `pin-${index}`));
|
|
4342
|
+
const headerPins = pins.map((pin, index) => /* @__PURE__ */ jsx(
|
|
4343
|
+
PinHeader,
|
|
4344
|
+
{
|
|
4345
|
+
x: pin.x,
|
|
4346
|
+
y: pin.y,
|
|
4347
|
+
pinThickness,
|
|
4348
|
+
shortSidePinLength,
|
|
4349
|
+
longSidePinLength,
|
|
4350
|
+
bodyHeight: pinBodyHeight,
|
|
4351
|
+
flipZ: (z) => z
|
|
4352
|
+
},
|
|
4353
|
+
`pin-3d-${index}`
|
|
4354
|
+
));
|
|
4355
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
4356
|
+
boardBody,
|
|
4357
|
+
platedHoles,
|
|
4358
|
+
!nopin && headerPins
|
|
4359
|
+
] });
|
|
4360
|
+
};
|
|
4361
|
+
|
|
4192
4362
|
// lib/Footprinter3d.tsx
|
|
4193
4363
|
var Footprinter3d = ({ footprint }) => {
|
|
4194
4364
|
const fpJson = fp2.string(footprint).json();
|
|
@@ -4445,6 +4615,33 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
4445
4615
|
innerHoleEdgeDistance: fpJson.innerholeedgedistance
|
|
4446
4616
|
}
|
|
4447
4617
|
);
|
|
4618
|
+
case "mountedpcbmodule": {
|
|
4619
|
+
const rows = fpJson.rows ?? 1;
|
|
4620
|
+
const pinRowSide = fpJson.pinRowSide ?? "left";
|
|
4621
|
+
const holeInset = fpJson.holeInset;
|
|
4622
|
+
const width10 = fpJson.width;
|
|
4623
|
+
const height10 = fpJson.height;
|
|
4624
|
+
const pinRow = fpJson.pinrow;
|
|
4625
|
+
const pinRowHoleEdgeToEdgeDist = fpJson.pinRowHoleEdgeToEdgeDist;
|
|
4626
|
+
const holes = Array.isArray(fpJson.holes) ? fpJson.holes : [];
|
|
4627
|
+
return /* @__PURE__ */ jsx(
|
|
4628
|
+
MountedPcbModule,
|
|
4629
|
+
{
|
|
4630
|
+
numPins: pinRow,
|
|
4631
|
+
rows,
|
|
4632
|
+
p: fpJson.p,
|
|
4633
|
+
id: fpJson.id,
|
|
4634
|
+
od: fpJson.od,
|
|
4635
|
+
width: width10,
|
|
4636
|
+
height: height10,
|
|
4637
|
+
pinRowSide,
|
|
4638
|
+
holes,
|
|
4639
|
+
holeInset,
|
|
4640
|
+
pinRowHoleEdgeToEdgeDist,
|
|
4641
|
+
nopin: fpJson.nopin
|
|
4642
|
+
}
|
|
4643
|
+
);
|
|
4644
|
+
}
|
|
4448
4645
|
}
|
|
4449
4646
|
const colorMatch = footprint.match(/_color\(([^)]+)\)/);
|
|
4450
4647
|
const color = colorMatch ? colorMatch[1] : void 0;
|