jscad-electronics 0.0.113 → 0.0.115
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.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/vanilla.d.ts +2 -1
- package/dist/vanilla.js +85 -3
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.d.ts
CHANGED
|
@@ -22,10 +22,11 @@ type RenderResult = {
|
|
|
22
22
|
declare function convertCSGToThreeGeom(csg: any): BufferGeometry;
|
|
23
23
|
|
|
24
24
|
declare function getJscadModelForFootprint(footprint: string, jscad: typeof jscadModeling): RenderResult;
|
|
25
|
+
declare function getJscadModelForFootprintWithPads(footprint: string, jscad: typeof jscadModeling): RenderResult;
|
|
25
26
|
declare function createJSCADRenderer(jscad: typeof jscadModeling): {
|
|
26
27
|
createJSCADRoot: (container: ColoredGeom[]) => {
|
|
27
28
|
render(element: VNode): void;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export { type ColoredGeom, Fragment, type RenderResult, type VNode, convertCSGToThreeGeom, createJSCADRenderer, getJscadModelForFootprint, h };
|
|
32
|
+
export { type ColoredGeom, Fragment, type RenderResult, type VNode, convertCSGToThreeGeom, createJSCADRenderer, getJscadModelForFootprint, getJscadModelForFootprintWithPads, h };
|
package/dist/vanilla.js
CHANGED
|
@@ -18,7 +18,7 @@ function h(type, props, ...restChildren) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// lib/
|
|
21
|
+
// lib/ExtrudedPads.tsx
|
|
22
22
|
import { fp } from "@tscircuit/footprinter";
|
|
23
23
|
|
|
24
24
|
// lib/vanilla/primitives.ts
|
|
@@ -42,6 +42,77 @@ var Fragment2 = Fragment;
|
|
|
42
42
|
var jsx = (type, props, _key) => h(type, props);
|
|
43
43
|
var jsxs = (type, props, _key) => h(type, props);
|
|
44
44
|
|
|
45
|
+
// lib/FootprintPad.tsx
|
|
46
|
+
var FootprintPad = ({
|
|
47
|
+
pad,
|
|
48
|
+
isPin1
|
|
49
|
+
}) => {
|
|
50
|
+
if (pad.shape === "rect") {
|
|
51
|
+
const color = isPin1 ? [0, 255, 0] : [255, 0, 0];
|
|
52
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Translate, { offset: [pad.x, pad.y, -5e-3], children: /* @__PURE__ */ jsx(Cuboid, { size: [pad.width, pad.height, 0.01] }) }) });
|
|
53
|
+
} else {
|
|
54
|
+
throw new Error("Shape not supported: " + pad.shape);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// lib/FootprintPlatedHole.tsx
|
|
59
|
+
var FootprintPlatedHole = ({
|
|
60
|
+
hole,
|
|
61
|
+
isPin1
|
|
62
|
+
}) => {
|
|
63
|
+
const color = isPin1 ? "#00ff00" : "#b87333";
|
|
64
|
+
if (hole.shape === "circle") {
|
|
65
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Translate, { offset: [hole.x, hole.y, -5e-3], children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
66
|
+
/* @__PURE__ */ jsx(Cylinder, { radius: hole.outer_diameter / 2, height: 0.01 }),
|
|
67
|
+
/* @__PURE__ */ jsx(Cylinder, { radius: hole.hole_diameter / 2, height: 0.01 })
|
|
68
|
+
] }) }) });
|
|
69
|
+
}
|
|
70
|
+
if (hole.shape === "circular_hole_with_rect_pad") {
|
|
71
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Translate, { offset: [hole.x, hole.y, 0], children: /* @__PURE__ */ jsxs(Subtract, { children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
Cuboid,
|
|
74
|
+
{
|
|
75
|
+
size: [hole.rect_pad_width, hole.rect_pad_width, 0.01],
|
|
76
|
+
center: [0, 0, 0]
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsx(Cylinder, { radius: hole.hole_diameter / 2, height: 0.01 })
|
|
80
|
+
] }) }) });
|
|
81
|
+
}
|
|
82
|
+
throw new Error("Shape not supported: " + hole.shape);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// lib/ExtrudedPads.tsx
|
|
86
|
+
var ExtrudedPads = ({
|
|
87
|
+
circuitJson,
|
|
88
|
+
footprint
|
|
89
|
+
}) => {
|
|
90
|
+
if (!circuitJson && footprint) {
|
|
91
|
+
circuitJson = fp.string(footprint).circuitJson();
|
|
92
|
+
}
|
|
93
|
+
if (!circuitJson)
|
|
94
|
+
throw new Error("No circuit json or footprint provided to ExtrudedPads");
|
|
95
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
96
|
+
circuitJson.filter((s) => s.type === "pcb_smtpad").map((pad, i) => {
|
|
97
|
+
const isPin1 = pad.port_hints?.includes("1");
|
|
98
|
+
return (
|
|
99
|
+
// biome-ignore lint/suspicious/noArrayIndexKey:
|
|
100
|
+
/* @__PURE__ */ jsx(FootprintPad, { pad, isPin1 }, i)
|
|
101
|
+
);
|
|
102
|
+
}),
|
|
103
|
+
circuitJson.filter((s) => s.type === "pcb_plated_hole").map((hole, i) => {
|
|
104
|
+
const isPin1 = hole.port_hints?.includes("1");
|
|
105
|
+
return (
|
|
106
|
+
// biome-ignore lint/suspicious/noArrayIndexKey:
|
|
107
|
+
/* @__PURE__ */ jsx(FootprintPlatedHole, { hole, isPin1 }, i)
|
|
108
|
+
);
|
|
109
|
+
})
|
|
110
|
+
] });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// lib/Footprinter3d.tsx
|
|
114
|
+
import { fp as fp2 } from "@tscircuit/footprinter";
|
|
115
|
+
|
|
45
116
|
// lib/ChipBody.tsx
|
|
46
117
|
var ChipBody = ({
|
|
47
118
|
center,
|
|
@@ -692,7 +763,8 @@ var PinRow = ({
|
|
|
692
763
|
const shortSidePinLength = 3;
|
|
693
764
|
const xoff = -((pinsPerRow - 1) / 2) * pitch;
|
|
694
765
|
const bodyCenterY = rows > 1 ? -((rows - 1) * rowSpacing) / 2 : 0;
|
|
695
|
-
const
|
|
766
|
+
const zOffset = !smd && !rightangle ? -bodyHeight - 1.6 : 0;
|
|
767
|
+
const flipZ = (z) => (invert || faceup ? -z + bodyHeight : z) + zOffset;
|
|
696
768
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
697
769
|
/* @__PURE__ */ jsx(Translate, { y: rightangle ? -3 : 0, children: /* @__PURE__ */ jsx(
|
|
698
770
|
Cuboid,
|
|
@@ -4119,7 +4191,7 @@ var StampBoard = ({
|
|
|
4119
4191
|
|
|
4120
4192
|
// lib/Footprinter3d.tsx
|
|
4121
4193
|
var Footprinter3d = ({ footprint }) => {
|
|
4122
|
-
const fpJson =
|
|
4194
|
+
const fpJson = fp2.string(footprint).json();
|
|
4123
4195
|
switch (fpJson.fn) {
|
|
4124
4196
|
case "dip":
|
|
4125
4197
|
return /* @__PURE__ */ jsx(Dip, { numPins: fpJson.num_pins, pitch: fpJson.p, bodyWidth: fpJson.w });
|
|
@@ -4632,6 +4704,15 @@ function getJscadModelForFootprint(footprint, jscad) {
|
|
|
4632
4704
|
const vnode = h(Footprinter3d, { footprint });
|
|
4633
4705
|
return render(vnode, jscad);
|
|
4634
4706
|
}
|
|
4707
|
+
function getJscadModelForFootprintWithPads(footprint, jscad) {
|
|
4708
|
+
const vnode = h(
|
|
4709
|
+
Fragment,
|
|
4710
|
+
{},
|
|
4711
|
+
h(Footprinter3d, { footprint }),
|
|
4712
|
+
h(ExtrudedPads, { footprint })
|
|
4713
|
+
);
|
|
4714
|
+
return render(vnode, jscad);
|
|
4715
|
+
}
|
|
4635
4716
|
function createJSCADRenderer(jscad) {
|
|
4636
4717
|
function createJSCADRoot(container) {
|
|
4637
4718
|
return {
|
|
@@ -4648,6 +4729,7 @@ export {
|
|
|
4648
4729
|
convertCSGToThreeGeom,
|
|
4649
4730
|
createJSCADRenderer,
|
|
4650
4731
|
getJscadModelForFootprint,
|
|
4732
|
+
getJscadModelForFootprintWithPads,
|
|
4651
4733
|
h
|
|
4652
4734
|
};
|
|
4653
4735
|
//# sourceMappingURL=vanilla.js.map
|