Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/Crystal.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { Crystal } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<Crystal />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/DPAK.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { DPAK } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<DPAK />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/ElectrolyticCapacitor.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { ElectrolyticCapacitor } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<ElectrolyticCapacitor />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/JST-PH.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { JST } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<JST numPins={4} series="ph" />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/JST-SH.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { JST } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<JST numPins={4} series="sh" />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/JST-ZH.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { JST } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<JST numPins={4} series="zh" />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/LED2835.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { LED2835 } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<LED2835 />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/LED5050.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { LED5050 } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<LED5050 />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/M2Host.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { M2Host } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<M2Host />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/Potentiometer.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { Potentiometer } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<Potentiometer />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/SOT343.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { SOT343 } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<SOT343 />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/SOT89.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { SOT89 } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<SOT89 />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/SmdDiode.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { SmdDiode } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<SmdDiode />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/SmdPushButton.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { SmdPushButton } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<SmdPushButton />
</JsCadView>
)
}
10 changes: 10 additions & 0 deletions examples/SolderJumper.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JsCadView } from "jscad-fiber"
import { SolderJumper } from "../lib"

export default function Example() {
return (
<JsCadView zAxisUp showGrid>
<SolderJumper />
</JsCadView>
)
}
60 changes: 60 additions & 0 deletions lib/Crystal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Colorize, Cuboid } from "jscad-fiber"

interface CrystalProps {
/** pad pitch X (footprinter px) */
padPitchX?: number
/** pad pitch Y (footprinter py) */
padPitchY?: number
padWidth?: number
padLength?: number
bodyWidth?: number
bodyLength?: number
bodyHeight?: number
}

/**
* 4-pad SMD quartz crystal: metal can over a dark base.
*/
export const Crystal = ({
padPitchX = 2.2,
padPitchY = 1.7,
padWidth = 1.4,
padLength = 1.2,
bodyWidth = 3.2,
bodyLength = 2.5,
bodyHeight = 0.8,
}: CrystalProps) => {
return (
<>
{/* Corner pads */}
{[-1, 1].map((sx) =>
[-1, 1].map((sy) => (
<Colorize key={`${sx}${sy}`} color="#c0c0c0">
<Cuboid
size={[padWidth, padLength, 0.05]}
center={[(sx * padPitchX) / 2, (sy * padPitchY) / 2, 0.025]}
/>
</Colorize>
)),
)}

{/* Dark base */}
<Colorize color="#3a3a3a">
<Cuboid
size={[bodyWidth, bodyLength, bodyHeight * 0.4]}
center={[0, 0, bodyHeight * 0.2 + 0.05]}
/>
</Colorize>

{/* Metal can */}
<Colorize color="#d8d8d8">
<Cuboid
size={[bodyWidth * 0.94, bodyLength * 0.94, bodyHeight * 0.6]}
center={[0, 0, bodyHeight * 0.4 + bodyHeight * 0.3 + 0.05]}
/>
</Colorize>
</>
)
}

export default Crystal
92 changes: 92 additions & 0 deletions lib/DPAK.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { ChipBody } from "./ChipBody"
import { SmdChipLead } from "./SmdChipLead"

interface DPAKProps {
/** number of gull-wing leads (tab side excluded), default 3 */
numPins?: number
/** package width across leads (footprint w) */
bodyWidth?: number
/** package length (footprint h) */
bodyLength?: number
bodyHeight?: number
/** pitch between gull-wing leads */
pitch?: number
leadWidth?: number
leadThickness?: number
leadHeight?: number
padContactLength?: number
/** heatsink tab width (footprint tabw) */
tabWidth?: number
/** heatsink tab length (footprint tabh) */
tabLength?: number
}

/**
* Parametric DPAK-family package: DPAK / TO-252, D2PAK / TO-263.
* Gull-wing leads on one side, wide heatsink tab on the other.
*/
export const DPAK = ({
numPins = 3,
bodyWidth = 6.6,
bodyLength = 6.5,
bodyHeight = 2.3,
pitch = 2.29,
leadWidth = 0.9,
leadThickness = 0.25,
leadHeight = 1.15,
padContactLength = 0.6,
tabWidth = 6.2,
tabLength = 2.5,
}: DPAKProps) => {
const leadSpan = (numPins - 1) * pitch
const startY = -leadSpan / 2

return (
<>
{/* Gull-wing leads on the left side */}
{Array.from({ length: numPins }).map((_, i) => (
<SmdChipLead
key={i}
position={{
x: -bodyWidth / 2 - padContactLength / 2,
y: startY + i * pitch,
z: leadThickness / 2,
}}
width={leadWidth}
thickness={leadThickness}
padContactLength={padContactLength}
bodyDistance={1.2}
height={leadHeight}
/>
))}

{/* Heatsink tab on the right side */}
<SmdChipLead
rotation={Math.PI}
position={{
x: bodyWidth / 2 + tabLength / 2,
y: 0,
z: leadThickness / 2,
}}
width={tabWidth}
thickness={leadThickness}
padContactLength={tabLength}
bodyDistance={0.6}
height={leadHeight}
/>

{/* Package body */}
<ChipBody
center={{ x: 0, y: 0, z: 0 }}
width={bodyWidth}
length={bodyLength}
height={bodyHeight}
includeNotch={false}
taperRatio={0.06}
straightHeightRatio={0.4}
/>
</>
)
}

export default DPAK
69 changes: 69 additions & 0 deletions lib/ElectrolyticCapacitor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Colorize, Cylinder, Subtract, Cuboid, Translate } from "jscad-fiber"

interface ElectrolyticCapacitorProps {
/** can diameter in mm (footprinter `d`) */
diameter?: number
height?: number
pitch?: number
bodyColor?: string
topColor?: string
}

/**
* Radial aluminum electrolytic capacitor (vertical can).
*/
export const ElectrolyticCapacitor = ({
diameter = 10.5,
height = 12.5,
pitch = 7.5,
bodyColor = "#1a1a5e",
topColor = "#c0c0c0",
}: ElectrolyticCapacitorProps) => {
const radius = diameter / 2
const legRadius = 0.25

return (
<>
{/* Can body */}
<Colorize color={bodyColor}>
<Cylinder
radius={radius}
height={height}
center={[0, 0, height / 2 + 0.4]}
/>
</Colorize>

{/* Metal top with score lines */}
<Colorize color={topColor}>
<Cylinder
radius={radius - 0.1}
height={0.3}
center={[0, 0, height + 0.4]}
/>
</Colorize>
<Colorize color="#808080">
<Cuboid
size={[diameter * 0.6, 0.15, 0.05]}
center={[0, 0, height + 0.56]}
/>
<Cuboid
size={[0.15, diameter * 0.6, 0.05]}
center={[0, 0, height + 0.56]}
/>
</Colorize>

{/* Black base ring */}
<Colorize color="#111">
<Cylinder radius={radius} height={0.4} center={[0, 0, 0.2]} />
</Colorize>

{/* Leads */}
<Colorize color="#c0c0c0">
<Cylinder radius={legRadius} height={3} center={[-pitch / 2, 0, -1]} />
<Cylinder radius={legRadius} height={3} center={[pitch / 2, 0, -1]} />
</Colorize>
</>
)
}

export default ElectrolyticCapacitor
Loading
Loading