-
Notifications
You must be signed in to change notification settings - Fork 69
feat(viewer): add showPcbNotes toggle to 3D renderer & SVG export (hidden by default)
#720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ interface CircuitToSvgOptions { | |
| backgroundColor?: string | ||
| padding?: number | ||
| zoom?: number | ||
| showPcbNotes?: boolean | ||
| camera?: { | ||
| position: { | ||
| x: number | ||
|
|
@@ -42,8 +43,15 @@ export async function convertCircuitJsonTo3dSvg( | |
| backgroundColor = "#ffffff", | ||
| padding = 20, | ||
| zoom = 1.5, | ||
| showPcbNotes = false, | ||
| } = options | ||
|
|
||
| const filteredCircuitJson = showPcbNotes | ||
| ? circuitJson | ||
| : circuitJson.filter( | ||
| (element) => !(element.type as string).startsWith("pcb_note_"), | ||
| ) | ||
|
|
||
|
Comment on lines
+49
to
+54
|
||
| // Initialize scene and renderer | ||
| const scene = new THREE.Scene() | ||
| const renderer = new SVGRenderer() | ||
|
|
@@ -88,15 +96,15 @@ export async function convertCircuitJsonTo3dSvg( | |
| scene.add(pointLight) | ||
|
|
||
| // Add components | ||
| const components = su(circuitJson).cad_component.list() | ||
| const components = su(filteredCircuitJson).cad_component.list() | ||
| for (const component of components) { | ||
| await renderComponent(component, scene) | ||
| } | ||
|
|
||
| const boardData = su(circuitJson).pcb_board.list()[0] | ||
| const boardData = su(filteredCircuitJson).pcb_board.list()[0] | ||
|
|
||
| // Add board geometry after components | ||
| const boardGeom = createBoardGeomFromCircuitJson(circuitJson) | ||
| const boardGeom = createBoardGeomFromCircuitJson(filteredCircuitJson) | ||
| if (boardGeom) { | ||
| // Use green solder mask color for the board | ||
| const solderMaskColor = colors.fr4SolderMaskGreen | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ export const useManifoldBoardBuilder = ( | |
| manifoldJSModule: ManifoldToplevel | null, | ||
| circuitJson: AnyCircuitElement[], | ||
| visibility: LayerVisibilityState, | ||
| showPcbNotes = false, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use opts |
||
| ): UseManifoldBoardBuilderResult => { | ||
| const [geoms, setGeoms] = useState<ManifoldGeoms | null>(null) | ||
| const [pcbThickness, setPcbThickness] = useState<number | null>(null) | ||
|
|
@@ -354,8 +355,9 @@ export const useManifoldBoardBuilder = ( | |
| boardData, | ||
| traceTextureResolution, | ||
| visibility, | ||
| showPcbNotes, | ||
| }) | ||
| }, [circuitJson, boardData, traceTextureResolution, visibility]) | ||
| }, [circuitJson, boardData, traceTextureResolution, visibility, showPcbNotes]) | ||
|
|
||
| return { | ||
| geoms, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||
| import { expect, test } from "bun:test" | ||||||
| import type { AnyCircuitElement, PcbBoard } from "circuit-json" | ||||||
| import { JSDOM } from "jsdom" | ||||||
| import { createCombinedBoardTextures } from "../src/textures" | ||||||
| import { applyJsdomShim } from "../src/utils/jsdom-shim" | ||||||
|
||||||
| import { applyJsdomShim } from "../src/utils/jsdom-shim" | |
| import { applyJsdomShim } from "../src/utils/jsdom-shim.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation line adds
showPcbNotestoconvert3dCircuitToSvg, but the codebase appears to exportconvertCircuitJsonTo3dSvg(seesrc/index.tsx) and tests import that name. Please update the README function name/import path (or add an alias export) so the documented API matches what consumers can actually call, including the newshowPcbNotesoption.