circuit-json-to-gltf 0.0.113 → 0.0.114

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/README.md CHANGED
@@ -70,8 +70,12 @@ convertCircuitJsonToGltf(circuitJson: CircuitJson, options?: ConversionOptions):
70
70
  - `drawFauxBoard`: Draw a fallback board if no `pcb_board` or `pcb_panel` is present - default: false
71
71
  - `includeModels`: Whether to load external 3D models - default: true
72
72
  - `modelCache`: Map for caching loaded models
73
- - `backgroundColor`: Background color for board rendering
74
- - `showBoundingBoxes`: Show bounding boxes for debugging
73
+ - `backgroundColor`: Board texture background color
74
+ - `copperColor`: Exposed copper color in board textures
75
+ - `silkscreenColor`: Silkscreen color in board textures
76
+ - `solderMaskWithCopperColor`: Color of traces and copper covered by solder mask
77
+ - `drillColor`: Drill opening color in board textures
78
+ - `showBoundingBoxes`: Show bounding boxes for debugging (default: `false`)
75
79
  - `projectBaseUrl`: Optional base URL used to resolve `node_modules` model assets via `/package_files/download`
76
80
  - `authHeaders`: Optional auth headers for model downloads, e.g. `{ Authorization: "Bearer ..." }`
77
81
 
package/dist/index.d.ts CHANGED
@@ -12,6 +12,10 @@ interface ConversionOptions {
12
12
  includeModels?: boolean;
13
13
  modelCache?: Map<string, STLMesh | OBJMesh>;
14
14
  backgroundColor?: string;
15
+ copperColor?: string;
16
+ silkscreenColor?: string;
17
+ solderMaskWithCopperColor?: string;
18
+ drillColor?: string;
15
19
  showBoundingBoxes?: boolean;
16
20
  coordinateTransform?: CoordinateTransformConfig;
17
21
  projectBaseUrl?: string;
@@ -123,6 +127,9 @@ interface CircuitTo3DOptions {
123
127
  pcbColor?: Color;
124
128
  componentColor?: Color;
125
129
  copperColor?: Color;
130
+ silkscreenColor?: string;
131
+ solderMaskWithCopperColor?: string;
132
+ drillColor?: string;
126
133
  boardThickness?: number;
127
134
  boardDrillQuality?: "high" | "fast";
128
135
  drawFauxBoard?: boolean;
@@ -141,16 +148,14 @@ interface BoardRenderOptions {
141
148
  backgroundColor?: string;
142
149
  copperColor?: string;
143
150
  silkscreenColor?: string;
151
+ solderMaskWithCopperColor?: string;
144
152
  padColor?: string;
145
153
  drillColor?: string;
146
154
  showPcbNotes?: boolean;
147
155
  }
148
156
 
149
157
  declare function renderBoardLayer(circuitJson: CircuitJson, options: BoardRenderOptions): Promise<string>;
150
- declare function renderBoardTextures(circuitJson: CircuitJson, { resolution, showPcbNotes }: {
151
- resolution?: number | undefined;
152
- showPcbNotes?: boolean | undefined;
153
- }): Promise<{
158
+ declare function renderBoardTextures(circuitJson: CircuitJson, { resolution, backgroundColor, copperColor, silkscreenColor, solderMaskWithCopperColor, drillColor, showPcbNotes, }: Omit<BoardRenderOptions, "layer">): Promise<{
154
159
  top: string;
155
160
  bottom: string;
156
161
  }>;
package/dist/index.js CHANGED
@@ -16530,6 +16530,7 @@ async function renderBoardLayer(circuitJson, options) {
16530
16530
  backgroundColor = "transparent",
16531
16531
  copperColor = "#ffe066",
16532
16532
  silkscreenColor = "#ffffff",
16533
+ solderMaskWithCopperColor = "#69e778ff",
16533
16534
  drillColor = "rgba(0,0,0,0.5)",
16534
16535
  showPcbNotes = false
16535
16536
  } = options;
@@ -16550,8 +16551,8 @@ async function renderBoardLayer(circuitJson, options) {
16550
16551
  bottom: silkscreenColor
16551
16552
  },
16552
16553
  soldermaskWithCopperUnderneath: {
16553
- top: "#69e778ff",
16554
- bottom: "#69e778ff"
16554
+ top: solderMaskWithCopperColor,
16555
+ bottom: solderMaskWithCopperColor
16555
16556
  },
16556
16557
  drill: drillColor
16557
16558
  }
@@ -16607,19 +16608,33 @@ async function convertSvgToCanvasBrowser(svgString, resolution, backgroundColor)
16607
16608
  img.src = svgDataUrl;
16608
16609
  });
16609
16610
  }
16610
- async function renderBoardTextures(circuitJson, { resolution = 1024, showPcbNotes = false }) {
16611
+ async function renderBoardTextures(circuitJson, {
16612
+ resolution = 1024,
16613
+ backgroundColor = "#0F3812",
16614
+ copperColor,
16615
+ silkscreenColor,
16616
+ solderMaskWithCopperColor,
16617
+ drillColor,
16618
+ showPcbNotes = false
16619
+ }) {
16611
16620
  const top = await renderBoardLayer(circuitJson, {
16612
16621
  layer: "top",
16613
16622
  resolution,
16614
- backgroundColor: "#0F3812",
16615
- // Green PCB background
16623
+ backgroundColor,
16624
+ copperColor,
16625
+ silkscreenColor,
16626
+ solderMaskWithCopperColor,
16627
+ drillColor,
16616
16628
  showPcbNotes
16617
16629
  });
16618
16630
  const bottom = await renderBoardLayer(circuitJson, {
16619
16631
  layer: "bottom",
16620
16632
  resolution,
16621
- backgroundColor: "#0F3812",
16622
- // Darker green for bottom layer
16633
+ backgroundColor,
16634
+ copperColor,
16635
+ silkscreenColor,
16636
+ solderMaskWithCopperColor,
16637
+ drillColor,
16623
16638
  showPcbNotes
16624
16639
  });
16625
16640
  return { top, bottom };
@@ -16649,6 +16664,9 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
16649
16664
  pcbColor = "rgba(0,140,0,0.8)",
16650
16665
  componentColor = "rgba(128,128,128,0.5)",
16651
16666
  copperColor = "#C87B4B",
16667
+ silkscreenColor,
16668
+ solderMaskWithCopperColor,
16669
+ drillColor,
16652
16670
  boardThickness = DEFAULT_BOARD_THICKNESS,
16653
16671
  boardDrillQuality = "fast",
16654
16672
  drawFauxBoard = false,
@@ -16657,12 +16675,19 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
16657
16675
  textureResolution = 1024,
16658
16676
  showPcbNotes = false,
16659
16677
  coordinateTransform,
16660
- showBoundingBoxes = true,
16678
+ showBoundingBoxes = false,
16661
16679
  projectBaseUrl,
16662
16680
  authHeaders
16663
16681
  } = options;
16664
16682
  const db = cju(circuitJson);
16665
16683
  const boxes = [];
16684
+ const boardTextureColors = {
16685
+ ...typeof options.pcbColor === "string" ? { backgroundColor: options.pcbColor } : {},
16686
+ ...typeof options.copperColor === "string" ? { copperColor: options.copperColor } : {},
16687
+ silkscreenColor,
16688
+ solderMaskWithCopperColor,
16689
+ drillColor
16690
+ };
16666
16691
  const pcbPanel = db.pcb_panel?.list?.()[0];
16667
16692
  const pcbBoard = db.pcb_board?.list?.()[0];
16668
16693
  const pcbComponents = db.pcb_component?.list?.() ?? [];
@@ -16699,7 +16724,8 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
16699
16724
  try {
16700
16725
  const textures = await renderBoardTextures(circuitJson, {
16701
16726
  resolution: textureResolution,
16702
- showPcbNotes
16727
+ showPcbNotes,
16728
+ ...boardTextureColors
16703
16729
  });
16704
16730
  panelBox.texture = {
16705
16731
  top: textures.top,
@@ -16745,7 +16771,8 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
16745
16771
  try {
16746
16772
  const textures = await renderBoardTextures(circuitJson, {
16747
16773
  resolution: textureResolution,
16748
- showPcbNotes
16774
+ showPcbNotes,
16775
+ ...boardTextureColors
16749
16776
  });
16750
16777
  boardBox.texture = {
16751
16778
  top: textures.top,
@@ -16803,7 +16830,8 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
16803
16830
  ];
16804
16831
  const textures = await renderBoardTextures(fauxBoardCircuitJson, {
16805
16832
  resolution: textureResolution,
16806
- showPcbNotes
16833
+ showPcbNotes,
16834
+ ...boardTextureColors
16807
16835
  });
16808
16836
  fauxBoardBox.texture = {
16809
16837
  top: textures.top,
@@ -18636,6 +18664,10 @@ async function convertCircuitJsonToGltf(circuitJson, options = {}) {
18636
18664
  includeModels = true,
18637
18665
  modelCache,
18638
18666
  backgroundColor,
18667
+ copperColor,
18668
+ silkscreenColor,
18669
+ solderMaskWithCopperColor,
18670
+ drillColor,
18639
18671
  showBoundingBoxes = false
18640
18672
  } = options;
18641
18673
  const scene3D = await convertCircuitJsonTo3D(circuitJson, {
@@ -18644,6 +18676,11 @@ async function convertCircuitJsonToGltf(circuitJson, options = {}) {
18644
18676
  showPcbNotes,
18645
18677
  boardDrillQuality,
18646
18678
  drawFauxBoard,
18679
+ pcbColor: backgroundColor,
18680
+ copperColor,
18681
+ silkscreenColor,
18682
+ solderMaskWithCopperColor,
18683
+ drillColor,
18647
18684
  coordinateTransform: options.coordinateTransform,
18648
18685
  showBoundingBoxes,
18649
18686
  projectBaseUrl: options.projectBaseUrl,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "circuit-json-to-gltf",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.113",
5
+ "version": "0.0.114",
6
6
  "scripts": {
7
7
  "test": "bun test tests/",
8
8
  "test:playwright": "playwright test",