@tscircuit/3d-viewer 0.0.532 → 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 +65 -118
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28674,13 +28674,9 @@ var AnyCadComponent = ({
28674
28674
  }, [cad_component.rotation, layer]);
28675
28675
  const adjustedPosition = useMemo8(() => {
28676
28676
  if (!cad_component.position) return void 0;
28677
- let z18;
28678
- if (layer === "top") {
28679
- z18 = cad_component.position.z;
28680
- } else if (layer === "bottom") {
28681
- z18 = -(cad_component.position.z + pcbThickness);
28682
- } else {
28683
- z18 = cad_component.position.z;
28677
+ let z18 = cad_component.position.z + pcbThickness / 2;
28678
+ if (layer === "bottom") {
28679
+ z18 = -cad_component.position.z - pcbThickness / 2;
28684
28680
  }
28685
28681
  return [cad_component.position.x, cad_component.position.y, z18];
28686
28682
  }, [cad_component.position, layer, pcbThickness]);
@@ -28856,7 +28852,7 @@ import * as THREE16 from "three";
28856
28852
  // package.json
28857
28853
  var package_default = {
28858
28854
  name: "@tscircuit/3d-viewer",
28859
- version: "0.0.531",
28855
+ version: "0.0.533",
28860
28856
  main: "./dist/index.js",
28861
28857
  module: "./dist/index.js",
28862
28858
  type: "module",
@@ -31771,6 +31767,7 @@ function calculateOutlineBounds(boardData) {
31771
31767
 
31772
31768
  // src/utils/pad-texture.ts
31773
31769
  import { su as su5 } from "@tscircuit/circuit-json-util";
31770
+ import { CircuitToCanvasDrawer } from "circuit-to-canvas";
31774
31771
  import * as THREE19 from "three";
31775
31772
  function createPadTextureForLayer({
31776
31773
  layer,
@@ -31782,6 +31779,7 @@ function createPadTextureForLayer({
31782
31779
  const pcbSmtPads = su5(circuitJson).pcb_smtpad.list();
31783
31780
  const smtPadsOnLayer = pcbSmtPads.filter((pad2) => pad2.layer === layer);
31784
31781
  if (smtPadsOnLayer.length === 0) return null;
31782
+ const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
31785
31783
  const boardOutlineBounds = calculateOutlineBounds(boardData);
31786
31784
  const canvas = document.createElement("canvas");
31787
31785
  const canvasWidth = Math.floor(
@@ -31798,102 +31796,51 @@ function createPadTextureForLayer({
31798
31796
  ctx.translate(0, canvasHeight);
31799
31797
  ctx.scale(1, -1);
31800
31798
  }
31801
- const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
31802
- const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
31803
- ctx.fillStyle = copperColor;
31804
- smtPadsOnLayer.forEach((pad2) => {
31805
- if (pad2.shape === "polygon" && pad2.points) {
31806
- ctx.beginPath();
31807
- pad2.points.forEach((point, index2) => {
31808
- const px = canvasXFromPcb(point.x);
31809
- const py = canvasYFromPcb(point.y);
31810
- if (index2 === 0) {
31811
- ctx.moveTo(px, py);
31812
- } else {
31813
- ctx.lineTo(px, py);
31814
- }
31815
- });
31816
- ctx.closePath();
31817
- ctx.fill();
31818
- return;
31819
- }
31820
- if (pad2.x === void 0 || pad2.y === void 0) return;
31821
- const x = pad2.x;
31822
- const y = pad2.y;
31823
- const canvasX = canvasXFromPcb(x);
31824
- const canvasY = canvasYFromPcb(y);
31825
- if (pad2.shape === "rect") {
31826
- const width10 = pad2.width * traceTextureResolution;
31827
- const height10 = pad2.height * traceTextureResolution;
31828
- const rawRadius = extractRectBorderRadius(pad2);
31829
- const borderRadius = clampRectBorderRadius(
31830
- pad2.width,
31831
- pad2.height,
31832
- rawRadius
31833
- ) * traceTextureResolution;
31834
- if (borderRadius > 0) {
31835
- ctx.beginPath();
31836
- ctx.roundRect(
31837
- canvasX - width10 / 2,
31838
- canvasY - height10 / 2,
31839
- width10,
31840
- height10,
31841
- borderRadius
31842
- );
31843
- ctx.fill();
31844
- } else {
31845
- 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
31846
31829
  }
31847
- } else if (pad2.shape === "circle") {
31848
- const radius = (pad2.radius ?? pad2.width / 2) * traceTextureResolution;
31849
- ctx.beginPath();
31850
- ctx.arc(canvasX, canvasY, radius, 0, 2 * Math.PI);
31851
- ctx.fill();
31852
- } else if (pad2.shape === "pill" || pad2.shape === "rotated_pill") {
31853
- const width10 = pad2.width * traceTextureResolution;
31854
- const height10 = pad2.height * traceTextureResolution;
31855
- const borderRadius = Math.min(width10, height10) / 2;
31856
- const ccwRotation = pad2.ccw_rotation || 0;
31857
- const rotation = -ccwRotation * (Math.PI / 180);
31858
- if (rotation) {
31859
- ctx.save();
31860
- ctx.translate(canvasX, canvasY);
31861
- ctx.rotate(rotation);
31862
- ctx.beginPath();
31863
- ctx.roundRect(-width10 / 2, -height10 / 2, width10, height10, borderRadius);
31864
- ctx.fill();
31865
- ctx.restore();
31866
- } else {
31867
- ctx.beginPath();
31868
- ctx.roundRect(
31869
- canvasX - width10 / 2,
31870
- canvasY - height10 / 2,
31871
- width10,
31872
- height10,
31873
- borderRadius
31874
- );
31875
- ctx.fill();
31876
- }
31877
- } else if (pad2.shape === "rotated_rect") {
31878
- const width10 = pad2.width * traceTextureResolution;
31879
- const height10 = pad2.height * traceTextureResolution;
31880
- const rawRadius = extractRectBorderRadius(pad2);
31881
- const borderRadius = clampRectBorderRadius(
31882
- pad2.width,
31883
- pad2.height,
31884
- rawRadius
31885
- ) * traceTextureResolution;
31886
- const ccwRotation = pad2.ccw_rotation || 0;
31887
- const rotation = -ccwRotation * (Math.PI / 180);
31888
- ctx.save();
31889
- ctx.translate(canvasX, canvasY);
31890
- ctx.rotate(rotation);
31891
- ctx.beginPath();
31892
- ctx.roundRect(-width10 / 2, -height10 / 2, width10, height10, borderRadius);
31893
- ctx.fill();
31894
- ctx.restore();
31895
31830
  }
31896
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
+ });
31897
31844
  const texture = new THREE19.CanvasTexture(canvas);
31898
31845
  texture.generateMipmaps = true;
31899
31846
  texture.minFilter = THREE19.LinearMipmapLinearFilter;
@@ -31984,7 +31931,7 @@ function createPanelOutlineTextureForLayer({
31984
31931
 
31985
31932
  // src/utils/trace-texture.ts
31986
31933
  import * as THREE21 from "three";
31987
- import { CircuitToCanvasDrawer } from "circuit-to-canvas";
31934
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
31988
31935
  import { getElementRenderLayers, su as su7 } from "@tscircuit/circuit-json-util";
31989
31936
 
31990
31937
  // src/utils/trace-layer-segments.ts
@@ -32056,7 +32003,7 @@ function createTraceTextureForLayer({
32056
32003
  ctx.scale(1, -1);
32057
32004
  }
32058
32005
  const transparent = "rgba(0,0,0,0)";
32059
- const drawer = new CircuitToCanvasDrawer(ctx);
32006
+ const drawer = new CircuitToCanvasDrawer2(ctx);
32060
32007
  drawer.configure({
32061
32008
  colorOverrides: {
32062
32009
  copper: {
@@ -32113,7 +32060,7 @@ function createTraceTextureForLayer({
32113
32060
  import * as THREE22 from "three";
32114
32061
 
32115
32062
  // src/textures/copper-text/copper-text-drawing.ts
32116
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
32063
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32117
32064
  var setDrawerBounds = (drawer, bounds) => {
32118
32065
  drawer.setCameraBounds({
32119
32066
  minX: bounds.minX,
@@ -32130,7 +32077,7 @@ var drawCopperTextLayer = ({
32130
32077
  copperColor
32131
32078
  }) => {
32132
32079
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32133
- const drawer = new CircuitToCanvasDrawer2(ctx);
32080
+ const drawer = new CircuitToCanvasDrawer3(ctx);
32134
32081
  drawer.configure({
32135
32082
  colorOverrides: {
32136
32083
  copper: {
@@ -32158,7 +32105,7 @@ var drawCopperTextLayer = ({
32158
32105
  maskCanvas.height = ctx.canvas.height;
32159
32106
  const maskCtx = maskCanvas.getContext("2d");
32160
32107
  if (!maskCtx) return;
32161
- const knockoutCutoutDrawer = new CircuitToCanvasDrawer2(maskCtx);
32108
+ const knockoutCutoutDrawer = new CircuitToCanvasDrawer3(maskCtx);
32162
32109
  knockoutCutoutDrawer.configure({
32163
32110
  colorOverrides: {
32164
32111
  copper: {
@@ -32234,7 +32181,7 @@ function createCopperTextTextureForLayer({
32234
32181
  import * as THREE23 from "three";
32235
32182
 
32236
32183
  // src/textures/fabrication-note/fabrication-note-drawing.ts
32237
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
32184
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32238
32185
 
32239
32186
  // src/utils/units.ts
32240
32187
  var MM_PER_INCH = 25.4;
@@ -32332,7 +32279,7 @@ var drawFabricationNoteLayer = ({
32332
32279
  }) => {
32333
32280
  const renderLayer = `${layer}_fabrication_note`;
32334
32281
  const normalizedElements = elements.map(normalizeFabricationElement);
32335
- const drawer = new CircuitToCanvasDrawer3(ctx);
32282
+ const drawer = new CircuitToCanvasDrawer4(ctx);
32336
32283
  drawer.configure({
32337
32284
  colorOverrides: {
32338
32285
  copper: {
@@ -32471,7 +32418,7 @@ function createFabricationNoteTextureForLayer({
32471
32418
  import * as THREE24 from "three";
32472
32419
 
32473
32420
  // src/textures/pcb-note/pcb-note-drawing.ts
32474
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
32421
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32475
32422
  var TRANSPARENT2 = "rgba(0,0,0,0)";
32476
32423
  var setDrawerBounds3 = (drawer, bounds) => {
32477
32424
  drawer.setCameraBounds({
@@ -32550,7 +32497,7 @@ var drawPcbNoteLayer = ({
32550
32497
  elements
32551
32498
  }) => {
32552
32499
  const normalizedElements = elements.map(normalizePcbNoteElement);
32553
- const drawer = new CircuitToCanvasDrawer4(ctx);
32500
+ const drawer = new CircuitToCanvasDrawer5(ctx);
32554
32501
  drawer.configure({
32555
32502
  colorOverrides: {
32556
32503
  copper: {
@@ -32632,7 +32579,7 @@ function createPcbNoteTextureForLayer({
32632
32579
  import * as THREE25 from "three";
32633
32580
 
32634
32581
  // src/textures/silkscreen/silkscreen-drawing.ts
32635
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
32582
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32636
32583
  var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
32637
32584
  var TRANSPARENT3 = "rgba(0,0,0,0)";
32638
32585
  var setDrawerBounds4 = (drawer, bounds) => {
@@ -32651,7 +32598,7 @@ var drawSilkscreenLayer = ({
32651
32598
  silkscreenColor
32652
32599
  }) => {
32653
32600
  const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
32654
- const drawer = new CircuitToCanvasDrawer5(ctx);
32601
+ const drawer = new CircuitToCanvasDrawer6(ctx);
32655
32602
  drawer.configure({
32656
32603
  colorOverrides: {
32657
32604
  copper: {
@@ -32751,7 +32698,7 @@ function createSilkscreenTextureForLayer({
32751
32698
  import * as THREE26 from "three";
32752
32699
 
32753
32700
  // src/textures/soldermask/soldermask-drawing.ts
32754
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
32701
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
32755
32702
  var toRgb = (colorArr) => {
32756
32703
  const [r = 0, g = 0, b = 0] = colorArr;
32757
32704
  return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
@@ -32787,7 +32734,7 @@ var drawSoldermaskLayer = ({
32787
32734
  }) => {
32788
32735
  const palette = getSoldermaskPalette(boardMaterial);
32789
32736
  const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32790
- const drawer = new CircuitToCanvasDrawer6(ctx);
32737
+ const drawer = new CircuitToCanvasDrawer7(ctx);
32791
32738
  drawer.configure({
32792
32739
  colorOverrides: {
32793
32740
  copper: {
@@ -32831,7 +32778,7 @@ var drawSoldermaskLayer = ({
32831
32778
  if (uncoveredPours.length > 0) {
32832
32779
  ctx.save();
32833
32780
  ctx.globalCompositeOperation = "destination-out";
32834
- const cutoutDrawer = new CircuitToCanvasDrawer6(ctx);
32781
+ const cutoutDrawer = new CircuitToCanvasDrawer7(ctx);
32835
32782
  cutoutDrawer.configure({
32836
32783
  colorOverrides: {
32837
32784
  copper: {
@@ -32893,7 +32840,7 @@ function createSoldermaskTextureForLayer({
32893
32840
  import * as THREE27 from "three";
32894
32841
 
32895
32842
  // src/textures/through-hole/through-hole-drawing.ts
32896
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
32843
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
32897
32844
  var setDrawerBounds6 = (drawer, bounds) => {
32898
32845
  drawer.setCameraBounds({
32899
32846
  minX: bounds.minX,
@@ -32911,7 +32858,7 @@ var drawThroughHoleLayer = ({
32911
32858
  }) => {
32912
32859
  const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
32913
32860
  const transparent = "rgba(0,0,0,0)";
32914
- const drawer = new CircuitToCanvasDrawer7(ctx);
32861
+ const drawer = new CircuitToCanvasDrawer8(ctx);
32915
32862
  drawer.configure({
32916
32863
  colorOverrides: {
32917
32864
  copper: {
@@ -33132,7 +33079,7 @@ function createCombinedBoardTextures({
33132
33079
 
33133
33080
  // src/textures/create-copper-pour-texture-for-layer.ts
33134
33081
  import * as THREE29 from "three";
33135
- import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
33082
+ import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
33136
33083
 
33137
33084
  // src/geoms/brep-converter.ts
33138
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.532",
3
+ "version": "0.0.534",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",