@tscircuit/3d-viewer 0.0.533 → 0.0.534

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 +62 -111
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28852,7 +28852,7 @@ import * as THREE16 from "three";
28852
28852
  // package.json
28853
28853
  var package_default = {
28854
28854
  name: "@tscircuit/3d-viewer",
28855
- version: "0.0.532",
28855
+ version: "0.0.533",
28856
28856
  main: "./dist/index.js",
28857
28857
  module: "./dist/index.js",
28858
28858
  type: "module",
@@ -31767,6 +31767,7 @@ function calculateOutlineBounds(boardData) {
31767
31767
 
31768
31768
  // src/utils/pad-texture.ts
31769
31769
  import { su as su5 } from "@tscircuit/circuit-json-util";
31770
+ import { CircuitToCanvasDrawer } from "circuit-to-canvas";
31770
31771
  import * as THREE19 from "three";
31771
31772
  function createPadTextureForLayer({
31772
31773
  layer,
@@ -31778,6 +31779,7 @@ function createPadTextureForLayer({
31778
31779
  const pcbSmtPads = su5(circuitJson).pcb_smtpad.list();
31779
31780
  const smtPadsOnLayer = pcbSmtPads.filter((pad2) => pad2.layer === layer);
31780
31781
  if (smtPadsOnLayer.length === 0) return null;
31782
+ const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
31781
31783
  const boardOutlineBounds = calculateOutlineBounds(boardData);
31782
31784
  const canvas = document.createElement("canvas");
31783
31785
  const canvasWidth = Math.floor(
@@ -31794,102 +31796,51 @@ function createPadTextureForLayer({
31794
31796
  ctx.translate(0, canvasHeight);
31795
31797
  ctx.scale(1, -1);
31796
31798
  }
31797
- const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
31798
- const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
31799
- ctx.fillStyle = copperColor;
31800
- smtPadsOnLayer.forEach((pad2) => {
31801
- if (pad2.shape === "polygon" && pad2.points) {
31802
- ctx.beginPath();
31803
- pad2.points.forEach((point, index2) => {
31804
- const px = canvasXFromPcb(point.x);
31805
- const py = canvasYFromPcb(point.y);
31806
- if (index2 === 0) {
31807
- ctx.moveTo(px, py);
31808
- } else {
31809
- ctx.lineTo(px, py);
31810
- }
31811
- });
31812
- ctx.closePath();
31813
- ctx.fill();
31814
- return;
31815
- }
31816
- if (pad2.x === void 0 || pad2.y === void 0) return;
31817
- const x = pad2.x;
31818
- const y = pad2.y;
31819
- const canvasX = canvasXFromPcb(x);
31820
- const canvasY = canvasYFromPcb(y);
31821
- if (pad2.shape === "rect") {
31822
- const width10 = pad2.width * traceTextureResolution;
31823
- const height10 = pad2.height * traceTextureResolution;
31824
- const rawRadius = extractRectBorderRadius(pad2);
31825
- const borderRadius = clampRectBorderRadius(
31826
- pad2.width,
31827
- pad2.height,
31828
- rawRadius
31829
- ) * traceTextureResolution;
31830
- if (borderRadius > 0) {
31831
- ctx.beginPath();
31832
- ctx.roundRect(
31833
- canvasX - width10 / 2,
31834
- canvasY - height10 / 2,
31835
- width10,
31836
- height10,
31837
- borderRadius
31838
- );
31839
- ctx.fill();
31840
- } else {
31841
- ctx.fillRect(canvasX - width10 / 2, canvasY - height10 / 2, width10, height10);
31799
+ const transparent = "rgba(0,0,0,0)";
31800
+ const drawer = new CircuitToCanvasDrawer(ctx);
31801
+ drawer.configure({
31802
+ colorOverrides: {
31803
+ copper: {
31804
+ top: copperColor,
31805
+ bottom: copperColor,
31806
+ inner1: copperColor,
31807
+ inner2: copperColor,
31808
+ inner3: copperColor,
31809
+ inner4: copperColor,
31810
+ inner5: copperColor,
31811
+ inner6: copperColor
31812
+ },
31813
+ copperPour: { top: transparent, bottom: transparent },
31814
+ drill: transparent,
31815
+ boardOutline: transparent,
31816
+ substrate: transparent,
31817
+ keepout: transparent,
31818
+ fabricationNote: transparent,
31819
+ courtyard: { top: transparent, bottom: transparent },
31820
+ silkscreen: { top: transparent, bottom: transparent },
31821
+ soldermask: { top: transparent, bottom: transparent },
31822
+ soldermaskWithCopperUnderneath: {
31823
+ top: transparent,
31824
+ bottom: transparent
31825
+ },
31826
+ soldermaskOverCopper: {
31827
+ top: transparent,
31828
+ bottom: transparent
31842
31829
  }
31843
- } else if (pad2.shape === "circle") {
31844
- const radius = (pad2.radius ?? pad2.width / 2) * traceTextureResolution;
31845
- ctx.beginPath();
31846
- ctx.arc(canvasX, canvasY, radius, 0, 2 * Math.PI);
31847
- ctx.fill();
31848
- } else if (pad2.shape === "pill" || pad2.shape === "rotated_pill") {
31849
- const width10 = pad2.width * traceTextureResolution;
31850
- const height10 = pad2.height * traceTextureResolution;
31851
- const borderRadius = Math.min(width10, height10) / 2;
31852
- const ccwRotation = pad2.ccw_rotation || 0;
31853
- const rotation = -ccwRotation * (Math.PI / 180);
31854
- if (rotation) {
31855
- ctx.save();
31856
- ctx.translate(canvasX, canvasY);
31857
- ctx.rotate(rotation);
31858
- ctx.beginPath();
31859
- ctx.roundRect(-width10 / 2, -height10 / 2, width10, height10, borderRadius);
31860
- ctx.fill();
31861
- ctx.restore();
31862
- } else {
31863
- ctx.beginPath();
31864
- ctx.roundRect(
31865
- canvasX - width10 / 2,
31866
- canvasY - height10 / 2,
31867
- width10,
31868
- height10,
31869
- borderRadius
31870
- );
31871
- ctx.fill();
31872
- }
31873
- } else if (pad2.shape === "rotated_rect") {
31874
- const width10 = pad2.width * traceTextureResolution;
31875
- const height10 = pad2.height * traceTextureResolution;
31876
- const rawRadius = extractRectBorderRadius(pad2);
31877
- const borderRadius = clampRectBorderRadius(
31878
- pad2.width,
31879
- pad2.height,
31880
- rawRadius
31881
- ) * traceTextureResolution;
31882
- const ccwRotation = pad2.ccw_rotation || 0;
31883
- const rotation = -ccwRotation * (Math.PI / 180);
31884
- ctx.save();
31885
- ctx.translate(canvasX, canvasY);
31886
- ctx.rotate(rotation);
31887
- ctx.beginPath();
31888
- ctx.roundRect(-width10 / 2, -height10 / 2, width10, height10, borderRadius);
31889
- ctx.fill();
31890
- ctx.restore();
31891
31830
  }
31892
31831
  });
31832
+ drawer.setCameraBounds({
31833
+ minX: boardOutlineBounds.minX,
31834
+ maxX: boardOutlineBounds.maxX,
31835
+ minY: boardOutlineBounds.minY,
31836
+ maxY: boardOutlineBounds.maxY
31837
+ });
31838
+ drawer.drawElements(smtPadsOnLayer, {
31839
+ layers: [pcbRenderLayer],
31840
+ drawSoldermask: false,
31841
+ drawSoldermaskTop: false,
31842
+ drawSoldermaskBottom: false
31843
+ });
31893
31844
  const texture = new THREE19.CanvasTexture(canvas);
31894
31845
  texture.generateMipmaps = true;
31895
31846
  texture.minFilter = THREE19.LinearMipmapLinearFilter;
@@ -31980,7 +31931,7 @@ function createPanelOutlineTextureForLayer({
31980
31931
 
31981
31932
  // src/utils/trace-texture.ts
31982
31933
  import * as THREE21 from "three";
31983
- import { CircuitToCanvasDrawer } from "circuit-to-canvas";
31934
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
31984
31935
  import { getElementRenderLayers, su as su7 } from "@tscircuit/circuit-json-util";
31985
31936
 
31986
31937
  // src/utils/trace-layer-segments.ts
@@ -32052,7 +32003,7 @@ function createTraceTextureForLayer({
32052
32003
  ctx.scale(1, -1);
32053
32004
  }
32054
32005
  const transparent = "rgba(0,0,0,0)";
32055
- const drawer = new CircuitToCanvasDrawer(ctx);
32006
+ const drawer = new CircuitToCanvasDrawer2(ctx);
32056
32007
  drawer.configure({
32057
32008
  colorOverrides: {
32058
32009
  copper: {
@@ -32109,7 +32060,7 @@ function createTraceTextureForLayer({
32109
32060
  import * as THREE22 from "three";
32110
32061
 
32111
32062
  // src/textures/copper-text/copper-text-drawing.ts
32112
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
32063
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32113
32064
  var setDrawerBounds = (drawer, bounds) => {
32114
32065
  drawer.setCameraBounds({
32115
32066
  minX: bounds.minX,
@@ -32126,7 +32077,7 @@ var drawCopperTextLayer = ({
32126
32077
  copperColor
32127
32078
  }) => {
32128
32079
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32129
- const drawer = new CircuitToCanvasDrawer2(ctx);
32080
+ const drawer = new CircuitToCanvasDrawer3(ctx);
32130
32081
  drawer.configure({
32131
32082
  colorOverrides: {
32132
32083
  copper: {
@@ -32154,7 +32105,7 @@ var drawCopperTextLayer = ({
32154
32105
  maskCanvas.height = ctx.canvas.height;
32155
32106
  const maskCtx = maskCanvas.getContext("2d");
32156
32107
  if (!maskCtx) return;
32157
- const knockoutCutoutDrawer = new CircuitToCanvasDrawer2(maskCtx);
32108
+ const knockoutCutoutDrawer = new CircuitToCanvasDrawer3(maskCtx);
32158
32109
  knockoutCutoutDrawer.configure({
32159
32110
  colorOverrides: {
32160
32111
  copper: {
@@ -32230,7 +32181,7 @@ function createCopperTextTextureForLayer({
32230
32181
  import * as THREE23 from "three";
32231
32182
 
32232
32183
  // src/textures/fabrication-note/fabrication-note-drawing.ts
32233
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32184
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32234
32185
 
32235
32186
  // src/utils/units.ts
32236
32187
  var MM_PER_INCH = 25.4;
@@ -32328,7 +32279,7 @@ var drawFabricationNoteLayer = ({
32328
32279
  }) => {
32329
32280
  const renderLayer = `${layer}_fabrication_note`;
32330
32281
  const normalizedElements = elements.map(normalizeFabricationElement);
32331
- const drawer = new CircuitToCanvasDrawer3(ctx);
32282
+ const drawer = new CircuitToCanvasDrawer4(ctx);
32332
32283
  drawer.configure({
32333
32284
  colorOverrides: {
32334
32285
  copper: {
@@ -32467,7 +32418,7 @@ function createFabricationNoteTextureForLayer({
32467
32418
  import * as THREE24 from "three";
32468
32419
 
32469
32420
  // src/textures/pcb-note/pcb-note-drawing.ts
32470
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32421
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32471
32422
  var TRANSPARENT2 = "rgba(0,0,0,0)";
32472
32423
  var setDrawerBounds3 = (drawer, bounds) => {
32473
32424
  drawer.setCameraBounds({
@@ -32546,7 +32497,7 @@ var drawPcbNoteLayer = ({
32546
32497
  elements
32547
32498
  }) => {
32548
32499
  const normalizedElements = elements.map(normalizePcbNoteElement);
32549
- const drawer = new CircuitToCanvasDrawer4(ctx);
32500
+ const drawer = new CircuitToCanvasDrawer5(ctx);
32550
32501
  drawer.configure({
32551
32502
  colorOverrides: {
32552
32503
  copper: {
@@ -32628,7 +32579,7 @@ function createPcbNoteTextureForLayer({
32628
32579
  import * as THREE25 from "three";
32629
32580
 
32630
32581
  // src/textures/silkscreen/silkscreen-drawing.ts
32631
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32582
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32632
32583
  var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
32633
32584
  var TRANSPARENT3 = "rgba(0,0,0,0)";
32634
32585
  var setDrawerBounds4 = (drawer, bounds) => {
@@ -32647,7 +32598,7 @@ var drawSilkscreenLayer = ({
32647
32598
  silkscreenColor
32648
32599
  }) => {
32649
32600
  const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
32650
- const drawer = new CircuitToCanvasDrawer5(ctx);
32601
+ const drawer = new CircuitToCanvasDrawer6(ctx);
32651
32602
  drawer.configure({
32652
32603
  colorOverrides: {
32653
32604
  copper: {
@@ -32747,7 +32698,7 @@ function createSilkscreenTextureForLayer({
32747
32698
  import * as THREE26 from "three";
32748
32699
 
32749
32700
  // src/textures/soldermask/soldermask-drawing.ts
32750
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32701
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
32751
32702
  var toRgb = (colorArr) => {
32752
32703
  const [r = 0, g = 0, b = 0] = colorArr;
32753
32704
  return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
@@ -32783,7 +32734,7 @@ var drawSoldermaskLayer = ({
32783
32734
  }) => {
32784
32735
  const palette = getSoldermaskPalette(boardMaterial);
32785
32736
  const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32786
- const drawer = new CircuitToCanvasDrawer6(ctx);
32737
+ const drawer = new CircuitToCanvasDrawer7(ctx);
32787
32738
  drawer.configure({
32788
32739
  colorOverrides: {
32789
32740
  copper: {
@@ -32827,7 +32778,7 @@ var drawSoldermaskLayer = ({
32827
32778
  if (uncoveredPours.length > 0) {
32828
32779
  ctx.save();
32829
32780
  ctx.globalCompositeOperation = "destination-out";
32830
- const cutoutDrawer = new CircuitToCanvasDrawer6(ctx);
32781
+ const cutoutDrawer = new CircuitToCanvasDrawer7(ctx);
32831
32782
  cutoutDrawer.configure({
32832
32783
  colorOverrides: {
32833
32784
  copper: {
@@ -32889,7 +32840,7 @@ function createSoldermaskTextureForLayer({
32889
32840
  import * as THREE27 from "three";
32890
32841
 
32891
32842
  // src/textures/through-hole/through-hole-drawing.ts
32892
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
32843
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
32893
32844
  var setDrawerBounds6 = (drawer, bounds) => {
32894
32845
  drawer.setCameraBounds({
32895
32846
  minX: bounds.minX,
@@ -32907,7 +32858,7 @@ var drawThroughHoleLayer = ({
32907
32858
  }) => {
32908
32859
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32909
32860
  const transparent = "rgba(0,0,0,0)";
32910
- const drawer = new CircuitToCanvasDrawer7(ctx);
32861
+ const drawer = new CircuitToCanvasDrawer8(ctx);
32911
32862
  drawer.configure({
32912
32863
  colorOverrides: {
32913
32864
  copper: {
@@ -33128,7 +33079,7 @@ function createCombinedBoardTextures({
33128
33079
 
33129
33080
  // src/textures/create-copper-pour-texture-for-layer.ts
33130
33081
  import * as THREE29 from "three";
33131
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
33082
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
33132
33083
 
33133
33084
  // src/geoms/brep-converter.ts
33134
33085
  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.533",
3
+ "version": "0.0.534",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",