@tscircuit/3d-viewer 0.0.529 → 0.0.530

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.
Files changed (2) hide show
  1. package/dist/index.js +67 -95
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -28769,7 +28769,7 @@ import * as THREE16 from "three";
28769
28769
  // package.json
28770
28770
  var package_default = {
28771
28771
  name: "@tscircuit/3d-viewer",
28772
- version: "0.0.528",
28772
+ version: "0.0.529",
28773
28773
  main: "./dist/index.js",
28774
28774
  module: "./dist/index.js",
28775
28775
  type: "module",
@@ -28799,7 +28799,7 @@ var package_default = {
28799
28799
  "@jscad/regl-renderer": "^2.6.12",
28800
28800
  "@jscad/stl-serializer": "^2.1.20",
28801
28801
  "circuit-json": "^0.0.391",
28802
- "circuit-to-canvas": "^0.0.89",
28802
+ "circuit-to-canvas": "^0.0.90",
28803
28803
  "react-hot-toast": "^2.6.0",
28804
28804
  three: "^0.165.0",
28805
28805
  "three-stdlib": "^2.36.0",
@@ -31915,6 +31915,7 @@ function createPanelOutlineTextureForLayer({
31915
31915
 
31916
31916
  // src/utils/trace-texture.ts
31917
31917
  import * as THREE21 from "three";
31918
+ import { CircuitToCanvasDrawer } from "circuit-to-canvas";
31918
31919
  import { su as su7 } from "@tscircuit/circuit-json-util";
31919
31920
  function isWireRoutePoint(point) {
31920
31921
  return point && point.route_type === "wire" && typeof point.layer === "string" && typeof point.width === "number";
@@ -31927,14 +31928,17 @@ function createTraceTextureForLayer({
31927
31928
  traceTextureResolution
31928
31929
  }) {
31929
31930
  const pcbTraces = su7(circuitJson).pcb_trace.list();
31930
- const allPcbVias = su7(circuitJson).pcb_via.list();
31931
- const allPcbPlatedHoles = su7(
31932
- circuitJson
31933
- ).pcb_plated_hole.list();
31931
+ const pcbVias = su7(circuitJson).pcb_via.list();
31932
+ const pcbPlatedHoles = su7(circuitJson).pcb_plated_hole.list();
31933
+ const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
31934
31934
  const tracesOnLayer = pcbTraces.filter(
31935
31935
  (t) => t.route.some((p) => isWireRoutePoint(p) && p.layer === layer)
31936
31936
  );
31937
31937
  if (tracesOnLayer.length === 0) return null;
31938
+ const platedHolesOnLayer = pcbPlatedHoles.filter(
31939
+ (hole) => hole.layers.includes(layer)
31940
+ );
31941
+ const elementsToDraw = [...tracesOnLayer, ...pcbVias, ...platedHolesOnLayer];
31938
31942
  const boardOutlineBounds = calculateOutlineBounds(boardData);
31939
31943
  const canvas = document.createElement("canvas");
31940
31944
  const canvasWidth = Math.floor(
@@ -31951,82 +31955,51 @@ function createTraceTextureForLayer({
31951
31955
  ctx.translate(0, canvasHeight);
31952
31956
  ctx.scale(1, -1);
31953
31957
  }
31954
- tracesOnLayer.forEach((trace) => {
31955
- let firstPoint = true;
31956
- ctx.beginPath();
31957
- ctx.strokeStyle = traceColor;
31958
- ctx.lineCap = "round";
31959
- ctx.lineJoin = "round";
31960
- let currentLineWidth = 0;
31961
- for (const point of trace.route) {
31962
- if (!isWireRoutePoint(point) || point.layer !== layer) {
31963
- if (!firstPoint) ctx.stroke();
31964
- firstPoint = true;
31965
- continue;
31966
- }
31967
- const pcbX = point.x;
31968
- const pcbY = point.y;
31969
- currentLineWidth = point.width * traceTextureResolution;
31970
- ctx.lineWidth = currentLineWidth;
31971
- const canvasX = (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
31972
- const canvasY = (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
31973
- if (firstPoint) {
31974
- ctx.moveTo(canvasX, canvasY);
31975
- firstPoint = false;
31976
- } else {
31977
- ctx.lineTo(canvasX, canvasY);
31958
+ const transparent = "rgba(0,0,0,0)";
31959
+ const drawer = new CircuitToCanvasDrawer(ctx);
31960
+ drawer.configure({
31961
+ colorOverrides: {
31962
+ copper: {
31963
+ top: traceColor,
31964
+ bottom: traceColor,
31965
+ inner1: traceColor,
31966
+ inner2: traceColor,
31967
+ inner3: traceColor,
31968
+ inner4: traceColor,
31969
+ inner5: traceColor,
31970
+ inner6: traceColor
31971
+ },
31972
+ copperPour: { top: transparent, bottom: transparent },
31973
+ drill: transparent,
31974
+ boardOutline: transparent,
31975
+ substrate: transparent,
31976
+ keepout: transparent,
31977
+ fabricationNote: transparent,
31978
+ courtyard: { top: transparent, bottom: transparent },
31979
+ silkscreen: { top: transparent, bottom: transparent },
31980
+ soldermask: { top: transparent, bottom: transparent },
31981
+ soldermaskWithCopperUnderneath: {
31982
+ top: transparent,
31983
+ bottom: transparent
31984
+ },
31985
+ soldermaskOverCopper: {
31986
+ top: transparent,
31987
+ bottom: transparent
31978
31988
  }
31979
31989
  }
31980
- if (!firstPoint) {
31981
- ctx.stroke();
31982
- }
31983
31990
  });
31984
- ctx.globalCompositeOperation = "destination-out";
31985
- ctx.fillStyle = "black";
31986
- allPcbVias.forEach((via) => {
31987
- const canvasX = (via.x - boardOutlineBounds.minX) * traceTextureResolution;
31988
- const canvasY = (boardOutlineBounds.maxY - via.y) * traceTextureResolution;
31989
- const canvasRadius = via.outer_diameter / 2 * traceTextureResolution;
31990
- ctx.beginPath();
31991
- ctx.arc(canvasX, canvasY, canvasRadius, 0, 2 * Math.PI, false);
31992
- ctx.fill();
31991
+ drawer.setCameraBounds({
31992
+ minX: boardOutlineBounds.minX,
31993
+ maxX: boardOutlineBounds.maxX,
31994
+ minY: boardOutlineBounds.minY,
31995
+ maxY: boardOutlineBounds.maxY
31993
31996
  });
31994
- allPcbPlatedHoles.forEach((ph) => {
31995
- if (ph.layers.includes(layer) && ph.shape === "circle") {
31996
- const canvasX = (ph.x - boardOutlineBounds.minX) * traceTextureResolution;
31997
- const canvasY = (boardOutlineBounds.maxY - ph.y) * traceTextureResolution;
31998
- const canvasRadius = ph.outer_diameter / 2 * traceTextureResolution;
31999
- ctx.beginPath();
32000
- ctx.arc(canvasX, canvasY, canvasRadius, 0, 2 * Math.PI, false);
32001
- ctx.fill();
32002
- } else if (ph.layers.includes(layer) && ph.shape === "rotated_pill_hole_with_rect_pad") {
32003
- const canvasX = (ph.x - boardOutlineBounds.minX) * traceTextureResolution;
32004
- const canvasY = (boardOutlineBounds.maxY - ph.y) * traceTextureResolution;
32005
- const padWidth = (ph.rect_pad_width ?? ph.hole_width ?? 0) * traceTextureResolution;
32006
- const padHeight = (ph.rect_pad_height ?? ph.hole_height ?? 0) * traceTextureResolution;
32007
- const rectCcwRotationDeg = ph.rect_ccw_rotation || 0;
32008
- const rectRotation = -rectCcwRotationDeg;
32009
- if (rectRotation) {
32010
- ctx.save();
32011
- ctx.translate(canvasX, canvasY);
32012
- ctx.rotate(rectRotation * Math.PI / 180);
32013
- ctx.beginPath();
32014
- ctx.rect(-padWidth / 2, -padHeight / 2, padWidth, padHeight);
32015
- ctx.fill();
32016
- ctx.restore();
32017
- } else {
32018
- ctx.beginPath();
32019
- ctx.rect(
32020
- canvasX - padWidth / 2,
32021
- canvasY - padHeight / 2,
32022
- padWidth,
32023
- padHeight
32024
- );
32025
- ctx.fill();
32026
- }
32027
- }
31997
+ drawer.drawElements(elementsToDraw, {
31998
+ layers: [pcbRenderLayer],
31999
+ drawSoldermask: false,
32000
+ drawSoldermaskTop: false,
32001
+ drawSoldermaskBottom: false
32028
32002
  });
32029
- ctx.globalCompositeOperation = "source-over";
32030
32003
  const texture = new THREE21.CanvasTexture(canvas);
32031
32004
  texture.generateMipmaps = true;
32032
32005
  texture.minFilter = THREE21.LinearMipmapLinearFilter;
@@ -32040,7 +32013,7 @@ function createTraceTextureForLayer({
32040
32013
  import * as THREE22 from "three";
32041
32014
 
32042
32015
  // src/textures/copper-text/copper-text-drawing.ts
32043
- import { CircuitToCanvasDrawer } from "circuit-to-canvas";
32016
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
32044
32017
  var setDrawerBounds = (drawer, bounds) => {
32045
32018
  drawer.setCameraBounds({
32046
32019
  minX: bounds.minX,
@@ -32057,7 +32030,7 @@ var drawCopperTextLayer = ({
32057
32030
  copperColor
32058
32031
  }) => {
32059
32032
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32060
- const drawer = new CircuitToCanvasDrawer(ctx);
32033
+ const drawer = new CircuitToCanvasDrawer2(ctx);
32061
32034
  drawer.configure({
32062
32035
  colorOverrides: {
32063
32036
  copper: {
@@ -32085,7 +32058,7 @@ var drawCopperTextLayer = ({
32085
32058
  maskCanvas.height = ctx.canvas.height;
32086
32059
  const maskCtx = maskCanvas.getContext("2d");
32087
32060
  if (!maskCtx) return;
32088
- const knockoutCutoutDrawer = new CircuitToCanvasDrawer(maskCtx);
32061
+ const knockoutCutoutDrawer = new CircuitToCanvasDrawer2(maskCtx);
32089
32062
  knockoutCutoutDrawer.configure({
32090
32063
  colorOverrides: {
32091
32064
  copper: {
@@ -32161,7 +32134,7 @@ function createCopperTextTextureForLayer({
32161
32134
  import * as THREE23 from "three";
32162
32135
 
32163
32136
  // src/textures/fabrication-note/fabrication-note-drawing.ts
32164
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
32137
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32165
32138
 
32166
32139
  // src/utils/units.ts
32167
32140
  var MM_PER_INCH = 25.4;
@@ -32259,7 +32232,7 @@ var drawFabricationNoteLayer = ({
32259
32232
  }) => {
32260
32233
  const renderLayer = `${layer}_fabrication_note`;
32261
32234
  const normalizedElements = elements.map(normalizeFabricationElement);
32262
- const drawer = new CircuitToCanvasDrawer2(ctx);
32235
+ const drawer = new CircuitToCanvasDrawer3(ctx);
32263
32236
  drawer.configure({
32264
32237
  colorOverrides: {
32265
32238
  copper: {
@@ -32398,7 +32371,7 @@ function createFabricationNoteTextureForLayer({
32398
32371
  import * as THREE24 from "three";
32399
32372
 
32400
32373
  // src/textures/pcb-note/pcb-note-drawing.ts
32401
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32374
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32402
32375
  var TRANSPARENT2 = "rgba(0,0,0,0)";
32403
32376
  var setDrawerBounds3 = (drawer, bounds) => {
32404
32377
  drawer.setCameraBounds({
@@ -32477,7 +32450,7 @@ var drawPcbNoteLayer = ({
32477
32450
  elements
32478
32451
  }) => {
32479
32452
  const normalizedElements = elements.map(normalizePcbNoteElement);
32480
- const drawer = new CircuitToCanvasDrawer3(ctx);
32453
+ const drawer = new CircuitToCanvasDrawer4(ctx);
32481
32454
  drawer.configure({
32482
32455
  colorOverrides: {
32483
32456
  copper: {
@@ -32559,7 +32532,7 @@ function createPcbNoteTextureForLayer({
32559
32532
  import * as THREE25 from "three";
32560
32533
 
32561
32534
  // src/textures/silkscreen/silkscreen-drawing.ts
32562
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32535
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32563
32536
  var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
32564
32537
  var TRANSPARENT3 = "rgba(0,0,0,0)";
32565
32538
  var setDrawerBounds4 = (drawer, bounds) => {
@@ -32578,7 +32551,7 @@ var drawSilkscreenLayer = ({
32578
32551
  silkscreenColor
32579
32552
  }) => {
32580
32553
  const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
32581
- const drawer = new CircuitToCanvasDrawer4(ctx);
32554
+ const drawer = new CircuitToCanvasDrawer5(ctx);
32582
32555
  drawer.configure({
32583
32556
  colorOverrides: {
32584
32557
  copper: {
@@ -32678,7 +32651,7 @@ function createSilkscreenTextureForLayer({
32678
32651
  import * as THREE26 from "three";
32679
32652
 
32680
32653
  // src/textures/soldermask/soldermask-drawing.ts
32681
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32654
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32682
32655
  var toRgb = (colorArr) => {
32683
32656
  const [r = 0, g = 0, b = 0] = colorArr;
32684
32657
  return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
@@ -32714,7 +32687,7 @@ var drawSoldermaskLayer = ({
32714
32687
  }) => {
32715
32688
  const palette = getSoldermaskPalette(boardMaterial);
32716
32689
  const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32717
- const drawer = new CircuitToCanvasDrawer5(ctx);
32690
+ const drawer = new CircuitToCanvasDrawer6(ctx);
32718
32691
  drawer.configure({
32719
32692
  colorOverrides: {
32720
32693
  copper: {
@@ -32758,7 +32731,7 @@ var drawSoldermaskLayer = ({
32758
32731
  if (uncoveredPours.length > 0) {
32759
32732
  ctx.save();
32760
32733
  ctx.globalCompositeOperation = "destination-out";
32761
- const cutoutDrawer = new CircuitToCanvasDrawer5(ctx);
32734
+ const cutoutDrawer = new CircuitToCanvasDrawer6(ctx);
32762
32735
  cutoutDrawer.configure({
32763
32736
  colorOverrides: {
32764
32737
  copper: {
@@ -32820,7 +32793,7 @@ function createSoldermaskTextureForLayer({
32820
32793
  import * as THREE27 from "three";
32821
32794
 
32822
32795
  // src/textures/through-hole/through-hole-drawing.ts
32823
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32796
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
32824
32797
  var setDrawerBounds6 = (drawer, bounds) => {
32825
32798
  drawer.setCameraBounds({
32826
32799
  minX: bounds.minX,
@@ -32838,7 +32811,7 @@ var drawThroughHoleLayer = ({
32838
32811
  }) => {
32839
32812
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32840
32813
  const transparent = "rgba(0,0,0,0)";
32841
- const drawer = new CircuitToCanvasDrawer6(ctx);
32814
+ const drawer = new CircuitToCanvasDrawer7(ctx);
32842
32815
  drawer.configure({
32843
32816
  colorOverrides: {
32844
32817
  copper: {
@@ -32966,8 +32939,7 @@ function createCombinedBoardTextures({
32966
32939
  traceTextureResolution,
32967
32940
  visibility
32968
32941
  }) {
32969
- const traceColorWithMask = toRgb2(colors.fr4TracesWithMaskGreen);
32970
- const traceColorWithoutMask = toRgb2(colors.fr4TracesWithoutMaskTan);
32942
+ const traceColor = toRgb2(colors.copper);
32971
32943
  const silkscreenColor = "rgb(255,255,255)";
32972
32944
  const copperColor = toRgb2(colors.copper);
32973
32945
  const showBoardBody = visibility?.boardBody ?? true;
@@ -32985,7 +32957,7 @@ function createCombinedBoardTextures({
32985
32957
  layer,
32986
32958
  circuitJson,
32987
32959
  boardData,
32988
- traceColor: showMask ? traceColorWithMask : traceColorWithoutMask,
32960
+ traceColor,
32989
32961
  traceTextureResolution
32990
32962
  }) : null;
32991
32963
  const copperTextTexture = showCopper ? createCopperTextTextureForLayer({
@@ -33060,7 +33032,7 @@ function createCombinedBoardTextures({
33060
33032
 
33061
33033
  // src/textures/create-copper-pour-texture-for-layer.ts
33062
33034
  import * as THREE29 from "three";
33063
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
33035
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
33064
33036
 
33065
33037
  // src/geoms/brep-converter.ts
33066
33038
  var import_primitives7 = __toESM(require_primitives(), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.529",
3
+ "version": "0.0.530",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "@jscad/regl-renderer": "^2.6.12",
31
31
  "@jscad/stl-serializer": "^2.1.20",
32
32
  "circuit-json": "^0.0.391",
33
- "circuit-to-canvas": "^0.0.89",
33
+ "circuit-to-canvas": "^0.0.90",
34
34
  "react-hot-toast": "^2.6.0",
35
35
  "three": "^0.165.0",
36
36
  "three-stdlib": "^2.36.0",