Skip to content

feat(viewer): add showPcbNotes toggle to 3D renderer & SVG export (hidden by default)#720

Open
rushabhcodes wants to merge 1 commit intotscircuit:mainfrom
rushabhcodes:feat/show-pcb-note
Open

feat(viewer): add showPcbNotes toggle to 3D renderer & SVG export (hidden by default)#720
rushabhcodes wants to merge 1 commit intotscircuit:mainfrom
rushabhcodes:feat/show-pcb-note

Conversation

@rushabhcodes
Copy link
Copy Markdown
Contributor

This pull request introduces support for optionally rendering pcb_note_* elements (such as annotation lines or notes) in 3D PCB visualizations, controlled by a new showPcbNotes option. By default, these note elements are hidden unless explicitly enabled. The change is integrated across the rendering pipeline, React components, and documentation, and is validated by new tests.

Default (false)

image

true

image

https://linear.app/tscircuit/issue/TSC-407/pcb-notes-shouldnt-show-in-3d-view-3d-snapshot-from-circuit-json-to

Feature: PCB Notes Visibility Control

  • Added a showPcbNotes option to the convertCircuitJsonTo3dSvg function and related APIs, allowing users to toggle the rendering of pcb_note_* elements in SVG/3D outputs. This option defaults to false to preserve existing behavior. [1] [2] [3] [4]
  • Updated React component props (CadViewerJscad, CadViewerManifold, and JscadBoardTextures) and hooks (useManifoldBoardBuilder) to accept and propagate the showPcbNotes flag throughout the rendering stack. [1] [2] [3] [4] [5] [6] [7] [8]
  • Modified the board texture creation logic to use the showPcbNotes flag, ensuring that note elements are only rendered in board textures when this option is enabled. [1] [2]

Documentation & Storybook

  • Updated the README.md and Storybook stories to document the new showPcbNotes prop and demonstrate its usage and default behavior. [1] [2] [3]

Testing

  • Added a new test to verify that pcb_note_* elements are hidden by default in board textures and only rendered when showPcbNotes is explicitly enabled.

Code Quality

  • Minor refactoring to improve resource disposal in JscadBoardTextures, replacing forEach with for...of loops for clarity and consistency.

Copilot AI review requested due to automatic review settings March 4, 2026 18:10
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment Mar 4, 2026 6:11pm

Request Review

manifoldJSModule: ManifoldToplevel | null,
circuitJson: AnyCircuitElement[],
visibility: LayerVisibilityState,
showPcbNotes = false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use opts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a showPcbNotes flag to control whether pcb_note_* annotation elements are rendered in the 3D board textures (default off), and propagates this option through the viewer components and Manifold/JSCAD texture pipelines.

Changes:

  • Introduce showPcbNotes (default false) and propagate it through CadViewer → renderers → board texture creation.
  • Update combined board texture generation to conditionally include pcb note textures.
  • Add a Bun test and Storybook controls/docs updates for the new toggle.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/pcb-notes-visibility.test.ts Adds test coverage for pcb note visibility default/override behavior.
stories/PcbNoteLine.stories.tsx Updates Storybook story to expose showPcbNotes as a controllable arg.
src/three-components/JscadBoardTextures.tsx Passes showPcbNotes into texture generation and refactors cleanup loops.
src/textures/create-combined-board-textures.ts Adds showPcbNotes option and gates pcb note texture generation.
src/hooks/useManifoldBoardBuilder.ts Threads showPcbNotes into Manifold board texture creation.
src/convert-circuit-json-to-3d-svg.ts Adds showPcbNotes option and filters pcb note elements when disabled.
src/CadViewerManifold.tsx Adds prop and passes it down into Manifold builder hook.
src/CadViewerJscad.tsx Adds prop and passes it down into JscadBoardTextures.
README.md Documents the new showPcbNotes option/prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- `backgroundColor`: Background color in hex format (default: "#ffffff")
- `padding`: Padding around the board (default: 20)
- `zoom`: Zoom level (default: 1.5)
- `showPcbNotes`: Whether to render `pcb_note_*` elements (default: `false`)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation line adds showPcbNotes to convert3dCircuitToSvg, but the codebase appears to export convertCircuitJsonTo3dSvg (see src/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 new showPcbNotes option.

Copilot uses AI. Check for mistakes.
import type { AnyCircuitElement, PcbBoard } from "circuit-json"
import { JSDOM } from "jsdom"
import { createCombinedBoardTextures } from "../src/textures"
import { applyJsdomShim } from "../src/utils/jsdom-shim"
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this repo's other Bun tests, imports of internal TS modules include the .ts extension (e.g. ../src/utils/jsdom-shim.ts). This test uses an extensionless import, which can break under stricter ESM resolution/tooling and is inconsistent with the existing test suite style. Align the import with the other tests for consistency.

Suggested change
import { applyJsdomShim } from "../src/utils/jsdom-shim"
import { applyJsdomShim } from "../src/utils/jsdom-shim.ts"

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +54
const filteredCircuitJson = showPcbNotes
? circuitJson
: circuitJson.filter(
(element) => !(element.type as string).startsWith("pcb_note_"),
)

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertCircuitJsonTo3dSvg now accepts showPcbNotes, but enabling it doesn't actually render pcb_note_* elements in the SVG output (the code only filters them out when false). This makes the new option effectively a no-op for SVG export and doesn't match the stated behavior. Consider either implementing note rendering in the SVG scene when showPcbNotes is true, or removing/renaming the option from this converter to avoid misleading API surface.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circuit-to-canvas should have this option, the number of hacks in this pr isn't good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants