@tscircuit/3d-viewer 0.0.602 → 0.0.604
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/dist/index.js +133 -102
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14436,7 +14436,7 @@ import { useCallback as useCallback24, useEffect as useEffect49, useRef as useRe
|
|
|
14436
14436
|
import * as THREE51 from "three";
|
|
14437
14437
|
|
|
14438
14438
|
// src/CadViewerJscad.tsx
|
|
14439
|
-
import { su as
|
|
14439
|
+
import { su as su12 } from "@tscircuit/circuit-json-util";
|
|
14440
14440
|
import { forwardRef as forwardRef3, useMemo as useMemo22 } from "react";
|
|
14441
14441
|
|
|
14442
14442
|
// src/utils/get-cad-pcb-context.ts
|
|
@@ -39204,7 +39204,7 @@ import * as THREE23 from "three";
|
|
|
39204
39204
|
// package.json
|
|
39205
39205
|
var package_default = {
|
|
39206
39206
|
name: "@tscircuit/3d-viewer",
|
|
39207
|
-
version: "0.0.
|
|
39207
|
+
version: "0.0.602",
|
|
39208
39208
|
repository: {
|
|
39209
39209
|
type: "git",
|
|
39210
39210
|
url: "https://github.com/tscircuit/3d-viewer"
|
|
@@ -39243,7 +39243,7 @@ var package_default = {
|
|
|
39243
39243
|
"@jscad/regl-renderer": "^2.6.12",
|
|
39244
39244
|
"@jscad/stl-serializer": "^2.1.20",
|
|
39245
39245
|
"circuit-json": "^0.0.497",
|
|
39246
|
-
"circuit-to-canvas": "^0.0.
|
|
39246
|
+
"circuit-to-canvas": "^0.0.131",
|
|
39247
39247
|
"react-hot-toast": "^2.6.0",
|
|
39248
39248
|
three: "^0.165.0",
|
|
39249
39249
|
"three-stdlib": "^2.36.0",
|
|
@@ -39291,7 +39291,7 @@ var package_default = {
|
|
|
39291
39291
|
"vite-tsconfig-paths": "^4.3.2",
|
|
39292
39292
|
"@tscircuit/core": "^0.0.1955",
|
|
39293
39293
|
"@tscircuit/props": "^0.0.664",
|
|
39294
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
39294
|
+
"@tscircuit/circuit-json-util": "^0.0.116"
|
|
39295
39295
|
},
|
|
39296
39296
|
patchedDependencies: {
|
|
39297
39297
|
"@tscircuit/fanout-solver@0.0.78": "patches/@tscircuit%2Ffanout-solver@0.0.78.patch"
|
|
@@ -41273,7 +41273,7 @@ var import_booleans4 = __toESM(require_booleans(), 1);
|
|
|
41273
41273
|
var import_extrusions4 = __toESM(require_extrusions(), 1);
|
|
41274
41274
|
var import_transforms6 = __toESM(require_transforms(), 1);
|
|
41275
41275
|
var import_primitives6 = __toESM(require_primitives(), 1);
|
|
41276
|
-
import { su as
|
|
41276
|
+
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
41277
41277
|
|
|
41278
41278
|
// src/geoms/create-hole-with-polygon-pad.ts
|
|
41279
41279
|
var import_primitives3 = __toESM(require_primitives(), 1);
|
|
@@ -41933,6 +41933,51 @@ function createViaBoardDrill({
|
|
|
41933
41933
|
return drill;
|
|
41934
41934
|
}
|
|
41935
41935
|
|
|
41936
|
+
// src/utils/get-pcb-vias.ts
|
|
41937
|
+
import { createBoardOwnerMap, su as su4 } from "@tscircuit/circuit-json-util";
|
|
41938
|
+
function getPcbVias(circuitJson) {
|
|
41939
|
+
const boardOwnerMap = createBoardOwnerMap(circuitJson);
|
|
41940
|
+
const vias = [...su4(circuitJson).pcb_via.list()];
|
|
41941
|
+
const viasByPosition = /* @__PURE__ */ new Map();
|
|
41942
|
+
for (const via of vias) {
|
|
41943
|
+
const board = boardOwnerMap.get(via.pcb_via_id);
|
|
41944
|
+
const positionKey = `${board?.pcb_board_id ?? ""}:${via.x}:${via.y}`;
|
|
41945
|
+
const viasAtPosition = viasByPosition.get(positionKey) ?? [];
|
|
41946
|
+
viasAtPosition.push(via);
|
|
41947
|
+
viasByPosition.set(positionKey, viasAtPosition);
|
|
41948
|
+
}
|
|
41949
|
+
for (const trace of su4(circuitJson).pcb_trace.list()) {
|
|
41950
|
+
const board = boardOwnerMap.get(trace.pcb_trace_id);
|
|
41951
|
+
for (const [index2, point] of trace.route.entries()) {
|
|
41952
|
+
if (point.route_type !== "via") continue;
|
|
41953
|
+
const positionKey = `${board?.pcb_board_id ?? ""}:${point.x}:${point.y}`;
|
|
41954
|
+
const viasAtPosition = viasByPosition.get(positionKey) ?? [];
|
|
41955
|
+
const hasMatchingVia = viasAtPosition.some(
|
|
41956
|
+
(via2) => via2.layers.includes(point.from_layer) && via2.layers.includes(point.to_layer)
|
|
41957
|
+
);
|
|
41958
|
+
if (hasMatchingVia) continue;
|
|
41959
|
+
const via = {
|
|
41960
|
+
type: "pcb_via",
|
|
41961
|
+
pcb_via_id: `${trace.pcb_trace_id}_route_via_${index2}`,
|
|
41962
|
+
pcb_trace_id: trace.pcb_trace_id,
|
|
41963
|
+
subcircuit_id: trace.subcircuit_id,
|
|
41964
|
+
pcb_group_id: trace.pcb_group_id,
|
|
41965
|
+
x: point.x,
|
|
41966
|
+
y: point.y,
|
|
41967
|
+
layers: [point.from_layer, point.to_layer],
|
|
41968
|
+
hole_diameter: point.hole_diameter ?? board?.min_via_hole_diameter ?? 0.25,
|
|
41969
|
+
outer_diameter: point.outer_diameter ?? board?.min_via_pad_diameter ?? 0.6,
|
|
41970
|
+
tented_on_top: point.tented_on_top,
|
|
41971
|
+
tented_on_bottom: point.tented_on_bottom
|
|
41972
|
+
};
|
|
41973
|
+
vias.push(via);
|
|
41974
|
+
viasAtPosition.push(via);
|
|
41975
|
+
viasByPosition.set(positionKey, viasAtPosition);
|
|
41976
|
+
}
|
|
41977
|
+
}
|
|
41978
|
+
return vias;
|
|
41979
|
+
}
|
|
41980
|
+
|
|
41936
41981
|
// src/BoardGeomBuilder.ts
|
|
41937
41982
|
var PAD_ROUNDED_SEGMENTS = 64;
|
|
41938
41983
|
var BOARD_CLIP_Z_MARGIN = 1;
|
|
@@ -41967,7 +42012,7 @@ var BoardGeomBuilder = class {
|
|
|
41967
42012
|
const panels = circuitJson.filter(
|
|
41968
42013
|
(e) => e.type === "pcb_panel"
|
|
41969
42014
|
);
|
|
41970
|
-
const boards =
|
|
42015
|
+
const boards = su5(circuitJson).pcb_board.list();
|
|
41971
42016
|
if (panels.length > 0) {
|
|
41972
42017
|
const panel = panels[0];
|
|
41973
42018
|
const firstBoardInPanel = boards.find(
|
|
@@ -41988,10 +42033,10 @@ var BoardGeomBuilder = class {
|
|
|
41988
42033
|
const boardsNotInPanel = boards.filter((b) => !b.pcb_panel_id);
|
|
41989
42034
|
this.board = boardsNotInPanel[0];
|
|
41990
42035
|
}
|
|
41991
|
-
this.plated_holes =
|
|
41992
|
-
this.holes =
|
|
41993
|
-
this.pcb_vias =
|
|
41994
|
-
this.pcb_cutouts =
|
|
42036
|
+
this.plated_holes = su5(circuitJson).pcb_plated_hole.list();
|
|
42037
|
+
this.holes = su5(circuitJson).pcb_hole.list();
|
|
42038
|
+
this.pcb_vias = getPcbVias(circuitJson);
|
|
42039
|
+
this.pcb_cutouts = su5(circuitJson).pcb_cutout.list();
|
|
41995
42040
|
this.ctx = { pcbThickness: this.board.thickness ?? 1.2 };
|
|
41996
42041
|
this.initializeBoard();
|
|
41997
42042
|
}
|
|
@@ -42693,7 +42738,7 @@ var ErrorBox = ({ parent }) => {
|
|
|
42693
42738
|
};
|
|
42694
42739
|
|
|
42695
42740
|
// src/three-components/JscadBoardTextures.tsx
|
|
42696
|
-
import { su as
|
|
42741
|
+
import { su as su9 } from "@tscircuit/circuit-json-util";
|
|
42697
42742
|
import { useEffect as useEffect25, useMemo as useMemo20 } from "react";
|
|
42698
42743
|
|
|
42699
42744
|
// src/textures/create-combined-board-textures.ts
|
|
@@ -42750,7 +42795,7 @@ function calculateOutlineBounds(boardData) {
|
|
|
42750
42795
|
}
|
|
42751
42796
|
|
|
42752
42797
|
// src/utils/pad-texture.ts
|
|
42753
|
-
import { su as
|
|
42798
|
+
import { su as su6 } from "@tscircuit/circuit-json-util";
|
|
42754
42799
|
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
42755
42800
|
import * as THREE27 from "three";
|
|
42756
42801
|
function createPadTextureForLayer({
|
|
@@ -42760,13 +42805,13 @@ function createPadTextureForLayer({
|
|
|
42760
42805
|
copperColor,
|
|
42761
42806
|
traceTextureResolution
|
|
42762
42807
|
}) {
|
|
42763
|
-
const pcbSmtPads =
|
|
42808
|
+
const pcbSmtPads = su6(circuitJson).pcb_smtpad.list();
|
|
42764
42809
|
const smtPadsOnLayer = pcbSmtPads.filter((pad2) => pad2.layer === layer);
|
|
42765
42810
|
if (smtPadsOnLayer.length === 0) return null;
|
|
42766
|
-
const holes =
|
|
42767
|
-
const platedHolesOnLayer =
|
|
42768
|
-
const viasOnLayer =
|
|
42769
|
-
const cutouts =
|
|
42811
|
+
const holes = su6(circuitJson).pcb_hole.list();
|
|
42812
|
+
const platedHolesOnLayer = su6(circuitJson).pcb_plated_hole.list().filter((e) => !Array.isArray(e.layers) || e.layers.includes(layer));
|
|
42813
|
+
const viasOnLayer = su6(circuitJson).pcb_via.list().filter((e) => !Array.isArray(e.layers) || e.layers.includes(layer));
|
|
42814
|
+
const cutouts = su6(circuitJson).pcb_cutout.list();
|
|
42770
42815
|
const drillElements = [...holes, ...platedHolesOnLayer, ...viasOnLayer];
|
|
42771
42816
|
const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
42772
42817
|
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
@@ -42842,7 +42887,7 @@ function createPadTextureForLayer({
|
|
|
42842
42887
|
}
|
|
42843
42888
|
|
|
42844
42889
|
// src/utils/panel-outline-texture.ts
|
|
42845
|
-
import { su as
|
|
42890
|
+
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
42846
42891
|
import * as THREE28 from "three";
|
|
42847
42892
|
var resolvePanelIdForTexture = (circuitJson) => {
|
|
42848
42893
|
const panels = circuitJson.filter(
|
|
@@ -42861,7 +42906,7 @@ function createPanelOutlineTextureForLayer({
|
|
|
42861
42906
|
}) {
|
|
42862
42907
|
const panelId = resolvePanelIdForTexture(circuitJson);
|
|
42863
42908
|
if (!panelId) return null;
|
|
42864
|
-
const allBoards =
|
|
42909
|
+
const allBoards = su7(circuitJson).pcb_board.list();
|
|
42865
42910
|
const boardsInPanel = allBoards.filter(
|
|
42866
42911
|
(b) => b.pcb_panel_id === panelId || b.position_mode === "relative_to_panel_anchor" && !b.pcb_panel_id
|
|
42867
42912
|
);
|
|
@@ -42923,43 +42968,7 @@ function createPanelOutlineTextureForLayer({
|
|
|
42923
42968
|
// src/utils/trace-texture.ts
|
|
42924
42969
|
import * as THREE29 from "three";
|
|
42925
42970
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
|
|
42926
|
-
import { getElementRenderLayers, su as
|
|
42927
|
-
|
|
42928
|
-
// src/utils/trace-layer-segments.ts
|
|
42929
|
-
function isWireRoutePoint(point) {
|
|
42930
|
-
return point && point.route_type === "wire" && typeof point.layer === "string" && typeof point.width === "number";
|
|
42931
|
-
}
|
|
42932
|
-
function splitTraceIntoLayerSegments(trace, layer) {
|
|
42933
|
-
const segments = [];
|
|
42934
|
-
let currentRoute = [];
|
|
42935
|
-
const pushCurrentSegment = () => {
|
|
42936
|
-
if (currentRoute.length < 2) {
|
|
42937
|
-
currentRoute = [];
|
|
42938
|
-
return;
|
|
42939
|
-
}
|
|
42940
|
-
segments.push({
|
|
42941
|
-
...trace,
|
|
42942
|
-
pcb_trace_id: `${trace.pcb_trace_id}_${layer}_${segments.length}`,
|
|
42943
|
-
route: currentRoute
|
|
42944
|
-
});
|
|
42945
|
-
currentRoute = [];
|
|
42946
|
-
};
|
|
42947
|
-
for (const point of trace.route) {
|
|
42948
|
-
if (!isWireRoutePoint(point)) {
|
|
42949
|
-
pushCurrentSegment();
|
|
42950
|
-
continue;
|
|
42951
|
-
}
|
|
42952
|
-
if (point.layer !== layer) {
|
|
42953
|
-
pushCurrentSegment();
|
|
42954
|
-
continue;
|
|
42955
|
-
}
|
|
42956
|
-
currentRoute.push(point);
|
|
42957
|
-
}
|
|
42958
|
-
pushCurrentSegment();
|
|
42959
|
-
return segments;
|
|
42960
|
-
}
|
|
42961
|
-
|
|
42962
|
-
// src/utils/trace-texture.ts
|
|
42971
|
+
import { getElementRenderLayers, su as su8 } from "@tscircuit/circuit-json-util";
|
|
42963
42972
|
function createTraceTextureForLayer({
|
|
42964
42973
|
layer,
|
|
42965
42974
|
circuitJson,
|
|
@@ -42967,11 +42976,13 @@ function createTraceTextureForLayer({
|
|
|
42967
42976
|
traceColor,
|
|
42968
42977
|
traceTextureResolution
|
|
42969
42978
|
}) {
|
|
42970
|
-
const pcbTraces =
|
|
42971
|
-
const pcbVias =
|
|
42972
|
-
const pcbPlatedHoles =
|
|
42979
|
+
const pcbTraces = su8(circuitJson).pcb_trace.list();
|
|
42980
|
+
const pcbVias = su8(circuitJson).pcb_via.list();
|
|
42981
|
+
const pcbPlatedHoles = su8(circuitJson).pcb_plated_hole.list();
|
|
42973
42982
|
const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
42974
|
-
const tracesOnLayer = pcbTraces.filter(
|
|
42983
|
+
const tracesOnLayer = pcbTraces.filter(
|
|
42984
|
+
(trace) => getElementRenderLayers(trace).includes(pcbRenderLayer)
|
|
42985
|
+
);
|
|
42975
42986
|
if (tracesOnLayer.length === 0) return null;
|
|
42976
42987
|
const platedHolesOnLayer = pcbPlatedHoles.filter(
|
|
42977
42988
|
(hole) => hole.layers.includes(layer)
|
|
@@ -43805,6 +43816,22 @@ import * as THREE35 from "three";
|
|
|
43805
43816
|
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
|
|
43806
43817
|
var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
|
|
43807
43818
|
var TRANSPARENT3 = "rgba(0,0,0,0)";
|
|
43819
|
+
var isViaTented = (via, layer, board) => {
|
|
43820
|
+
const viaTenting = layer === "top" ? via.tented_on_top : via.tented_on_bottom;
|
|
43821
|
+
const legacyTenting = "is_tented" in via ? via.is_tented : void 0;
|
|
43822
|
+
const boardDefault = layer === "top" ? board?.default_via_tented_on_top : board?.default_via_tented_on_bottom;
|
|
43823
|
+
return viaTenting ?? legacyTenting ?? boardDefault ?? false;
|
|
43824
|
+
};
|
|
43825
|
+
var isOpenSurfaceAperture = (element, layer, board, soldermaskVisible) => {
|
|
43826
|
+
if (element.type === "pcb_cutout") return true;
|
|
43827
|
+
if (element.type === "pcb_via") {
|
|
43828
|
+
return !soldermaskVisible || !isViaTented(element, layer, board);
|
|
43829
|
+
}
|
|
43830
|
+
if (element.type === "pcb_hole" || element.type === "pcb_plated_hole") {
|
|
43831
|
+
return !soldermaskVisible || element.is_covered_with_solder_mask !== true;
|
|
43832
|
+
}
|
|
43833
|
+
return false;
|
|
43834
|
+
};
|
|
43808
43835
|
var setDrawerBounds5 = (drawer, bounds) => {
|
|
43809
43836
|
drawer.setCameraBounds({
|
|
43810
43837
|
minX: bounds.minX,
|
|
@@ -43818,8 +43845,9 @@ var drawSilkscreenLayer = ({
|
|
|
43818
43845
|
layer,
|
|
43819
43846
|
bounds,
|
|
43820
43847
|
elements,
|
|
43821
|
-
|
|
43822
|
-
silkscreenColor
|
|
43848
|
+
circuitJson,
|
|
43849
|
+
silkscreenColor,
|
|
43850
|
+
soldermaskVisible
|
|
43823
43851
|
}) => {
|
|
43824
43852
|
const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
|
|
43825
43853
|
const drawer = new CircuitToCanvasDrawer8(ctx);
|
|
@@ -43869,8 +43897,26 @@ var drawSilkscreenLayer = ({
|
|
|
43869
43897
|
}
|
|
43870
43898
|
});
|
|
43871
43899
|
setDrawerBounds5(drawer, bounds);
|
|
43872
|
-
drawer.drawElements(
|
|
43900
|
+
drawer.drawElements(elements, {
|
|
43873
43901
|
layers: [renderLayer],
|
|
43902
|
+
clipContextElements: circuitJson
|
|
43903
|
+
});
|
|
43904
|
+
const apertureElements = circuitJson.flatMap(
|
|
43905
|
+
(element) => {
|
|
43906
|
+
if (element.type === "pcb_trace") {
|
|
43907
|
+
const board2 = ctx.boardOwnerMap?.get(element.pcb_trace_id);
|
|
43908
|
+
const route = element.route.filter(
|
|
43909
|
+
(point) => point.route_type === "via" && (!soldermaskVisible || !isViaTented(point, layer, board2))
|
|
43910
|
+
);
|
|
43911
|
+
return route.length ? [{ ...element, route }] : [];
|
|
43912
|
+
}
|
|
43913
|
+
const board = element.type === "pcb_via" ? ctx.boardOwnerMap?.get(element.pcb_via_id) : void 0;
|
|
43914
|
+
return isOpenSurfaceAperture(element, layer, board, soldermaskVisible) ? [element] : [];
|
|
43915
|
+
}
|
|
43916
|
+
);
|
|
43917
|
+
drawer.drawElements(apertureElements, {
|
|
43918
|
+
layers: [renderLayer],
|
|
43919
|
+
clipContextElements: circuitJson,
|
|
43874
43920
|
clearDrillHoles: true
|
|
43875
43921
|
});
|
|
43876
43922
|
};
|
|
@@ -43881,18 +43927,6 @@ var isSilkscreenElement = (element, layer) => {
|
|
|
43881
43927
|
const elementType = element.type;
|
|
43882
43928
|
return elementType.startsWith("pcb_silkscreen_");
|
|
43883
43929
|
};
|
|
43884
|
-
var isOpenSurfaceAperture = (element, soldermaskVisible, layer) => {
|
|
43885
|
-
if (element.type === "pcb_cutout") return true;
|
|
43886
|
-
if (element.type === "pcb_via") {
|
|
43887
|
-
const legacyTented = element.is_tented;
|
|
43888
|
-
const tented = (layer === "top" ? element.tented_on_top : element.tented_on_bottom) ?? legacyTented;
|
|
43889
|
-
return !soldermaskVisible || tented !== true;
|
|
43890
|
-
}
|
|
43891
|
-
if (element.type === "pcb_hole" || element.type === "pcb_plated_hole") {
|
|
43892
|
-
return !soldermaskVisible || element.is_covered_with_solder_mask !== true;
|
|
43893
|
-
}
|
|
43894
|
-
return false;
|
|
43895
|
-
};
|
|
43896
43930
|
function createSilkscreenTextureForLayer({
|
|
43897
43931
|
layer,
|
|
43898
43932
|
circuitJson,
|
|
@@ -43905,9 +43939,6 @@ function createSilkscreenTextureForLayer({
|
|
|
43905
43939
|
(element) => isSilkscreenElement(element, layer)
|
|
43906
43940
|
);
|
|
43907
43941
|
if (elements.length === 0) return null;
|
|
43908
|
-
const apertureElements = circuitJson.filter(
|
|
43909
|
-
(element) => isOpenSurfaceAperture(element, soldermaskVisible, layer)
|
|
43910
|
-
);
|
|
43911
43942
|
const bounds = getSoldermaskRenderBounds(circuitJson, boardData);
|
|
43912
43943
|
const canvasWidth = Math.floor(bounds.width * traceTextureResolution);
|
|
43913
43944
|
const canvasHeight = Math.floor(bounds.height * traceTextureResolution);
|
|
@@ -43926,8 +43957,9 @@ function createSilkscreenTextureForLayer({
|
|
|
43926
43957
|
layer,
|
|
43927
43958
|
bounds,
|
|
43928
43959
|
elements,
|
|
43929
|
-
|
|
43930
|
-
silkscreenColor
|
|
43960
|
+
circuitJson,
|
|
43961
|
+
silkscreenColor,
|
|
43962
|
+
soldermaskVisible
|
|
43931
43963
|
});
|
|
43932
43964
|
const texture = new THREE35.CanvasTexture(canvas);
|
|
43933
43965
|
texture.generateMipmaps = true;
|
|
@@ -44870,7 +44902,7 @@ function JscadBoardTextures({
|
|
|
44870
44902
|
const panels = circuitJson.filter(
|
|
44871
44903
|
(e) => e.type === "pcb_panel"
|
|
44872
44904
|
);
|
|
44873
|
-
const boards =
|
|
44905
|
+
const boards = su9(circuitJson).pcb_board.list();
|
|
44874
44906
|
if (panels.length > 0) {
|
|
44875
44907
|
const panel = panels[0];
|
|
44876
44908
|
const firstBoardInPanel = boards.find(
|
|
@@ -45146,16 +45178,16 @@ function VisibleSTLModel({
|
|
|
45146
45178
|
}
|
|
45147
45179
|
|
|
45148
45180
|
// src/utils/preprocess-circuit-json.ts
|
|
45149
|
-
import { su as
|
|
45181
|
+
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
45150
45182
|
|
|
45151
45183
|
// src/utils/create-faux-board.ts
|
|
45152
|
-
import { su as
|
|
45184
|
+
import { su as su10, getBoundsOfPcbElements } from "@tscircuit/circuit-json-util";
|
|
45153
45185
|
function createFauxBoard(circuitJson) {
|
|
45154
|
-
const cadComponents =
|
|
45155
|
-
const pads =
|
|
45156
|
-
const holes =
|
|
45157
|
-
const platedHoles =
|
|
45158
|
-
const vias =
|
|
45186
|
+
const cadComponents = su10(circuitJson).cad_component.list().filter((cad) => cad.pcb_component_id);
|
|
45187
|
+
const pads = su10(circuitJson).pcb_smtpad.list();
|
|
45188
|
+
const holes = su10(circuitJson).pcb_hole.list();
|
|
45189
|
+
const platedHoles = su10(circuitJson).pcb_plated_hole.list();
|
|
45190
|
+
const vias = su10(circuitJson).pcb_via.list();
|
|
45159
45191
|
if (cadComponents.length === 0 && pads.length === 0 && holes.length === 0 && platedHoles.length === 0 && vias.length === 0) {
|
|
45160
45192
|
return null;
|
|
45161
45193
|
}
|
|
@@ -45204,7 +45236,7 @@ function createFauxBoard(circuitJson) {
|
|
|
45204
45236
|
|
|
45205
45237
|
// src/utils/preprocess-circuit-json.ts
|
|
45206
45238
|
function addFauxBoardIfNeeded(circuitJson) {
|
|
45207
|
-
const boards =
|
|
45239
|
+
const boards = su11(circuitJson).pcb_board.list();
|
|
45208
45240
|
if (boards.length > 0) {
|
|
45209
45241
|
return circuitJson;
|
|
45210
45242
|
}
|
|
@@ -45256,7 +45288,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
45256
45288
|
const initialCameraPosition = useMemo22(() => {
|
|
45257
45289
|
if (!internalCircuitJson) return [5, -5, 5];
|
|
45258
45290
|
try {
|
|
45259
|
-
const board =
|
|
45291
|
+
const board = su12(internalCircuitJson).pcb_board.list()[0];
|
|
45260
45292
|
if (!board) return [5, -5, 5];
|
|
45261
45293
|
const { width: width10, height: height10 } = board;
|
|
45262
45294
|
if (!width10 && !height10) {
|
|
@@ -45282,7 +45314,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
45282
45314
|
const isFauxBoard = useMemo22(() => {
|
|
45283
45315
|
if (!internalCircuitJson) return false;
|
|
45284
45316
|
try {
|
|
45285
|
-
const board =
|
|
45317
|
+
const board = su12(internalCircuitJson).pcb_board.list()[0];
|
|
45286
45318
|
return !!board && board.pcb_board_id === "faux-board";
|
|
45287
45319
|
} catch (e) {
|
|
45288
45320
|
return false;
|
|
@@ -45291,7 +45323,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
45291
45323
|
const boardDimensions = useMemo22(() => {
|
|
45292
45324
|
if (!internalCircuitJson) return void 0;
|
|
45293
45325
|
try {
|
|
45294
|
-
const board =
|
|
45326
|
+
const board = su12(internalCircuitJson).pcb_board.list()[0];
|
|
45295
45327
|
if (!board) return void 0;
|
|
45296
45328
|
const bounds = calculateOutlineBounds(board);
|
|
45297
45329
|
return { width: bounds.width, height: bounds.height };
|
|
@@ -45303,7 +45335,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
45303
45335
|
const boardCenter = useMemo22(() => {
|
|
45304
45336
|
if (!internalCircuitJson) return void 0;
|
|
45305
45337
|
try {
|
|
45306
|
-
const board =
|
|
45338
|
+
const board = su12(internalCircuitJson).pcb_board.list()[0];
|
|
45307
45339
|
if (!board) return void 0;
|
|
45308
45340
|
const bounds = calculateOutlineBounds(board);
|
|
45309
45341
|
return { x: bounds.centerX, y: bounds.centerY };
|
|
@@ -45314,7 +45346,7 @@ var CadViewerJscad = forwardRef3(
|
|
|
45314
45346
|
}, [internalCircuitJson]);
|
|
45315
45347
|
const pcbThickness = usePcbThickness(internalCircuitJson);
|
|
45316
45348
|
const { stls: boardStls, loading } = useStlsFromGeom(boardGeom);
|
|
45317
|
-
const cad_components =
|
|
45349
|
+
const cad_components = su12(internalCircuitJson).cad_component.list();
|
|
45318
45350
|
return /* @__PURE__ */ jsxs5(
|
|
45319
45351
|
CadViewerContainer,
|
|
45320
45352
|
{
|
|
@@ -45437,7 +45469,7 @@ function createManifoldBoard(Manifold, CrossSection, boardData, pcbThickness, ma
|
|
|
45437
45469
|
}
|
|
45438
45470
|
|
|
45439
45471
|
// src/utils/manifold/process-cutouts.ts
|
|
45440
|
-
import { su as
|
|
45472
|
+
import { su as su13 } from "@tscircuit/circuit-json-util";
|
|
45441
45473
|
|
|
45442
45474
|
// src/utils/pad-geoms.ts
|
|
45443
45475
|
var RECT_PAD_SEGMENTS2 = 64;
|
|
@@ -45496,7 +45528,7 @@ var arePointsClockwise3 = (points) => {
|
|
|
45496
45528
|
};
|
|
45497
45529
|
function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
45498
45530
|
const cutoutOps = [];
|
|
45499
|
-
const pcbCutouts =
|
|
45531
|
+
const pcbCutouts = su13(circuitJson).pcb_cutout.list();
|
|
45500
45532
|
for (const cutout of pcbCutouts) {
|
|
45501
45533
|
let cutoutOp;
|
|
45502
45534
|
const cutoutHeight = pcbThickness * 1.5;
|
|
@@ -45591,7 +45623,7 @@ function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThick
|
|
|
45591
45623
|
}
|
|
45592
45624
|
|
|
45593
45625
|
// src/utils/manifold/process-non-plated-holes.ts
|
|
45594
|
-
import { su as
|
|
45626
|
+
import { su as su14 } from "@tscircuit/circuit-json-util";
|
|
45595
45627
|
|
|
45596
45628
|
// src/utils/hole-geoms.ts
|
|
45597
45629
|
function createCircleHoleDrill({
|
|
@@ -45634,7 +45666,7 @@ function createPlatedHoleDrill({
|
|
|
45634
45666
|
// src/utils/manifold/process-non-plated-holes.ts
|
|
45635
45667
|
function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup) {
|
|
45636
45668
|
const nonPlatedHoleBoardDrills = [];
|
|
45637
|
-
const pcbHoles =
|
|
45669
|
+
const pcbHoles = su14(circuitJson).pcb_hole.list();
|
|
45638
45670
|
const createPillOp = (width10, height10, depth) => {
|
|
45639
45671
|
const pillOp = createRoundedRectPrism({
|
|
45640
45672
|
Manifold,
|
|
@@ -45724,7 +45756,7 @@ function processNonPlatedHolesForManifold(Manifold, CrossSection, circuitJson, p
|
|
|
45724
45756
|
}
|
|
45725
45757
|
|
|
45726
45758
|
// src/utils/manifold/process-plated-holes.ts
|
|
45727
|
-
import { su as
|
|
45759
|
+
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
45728
45760
|
import * as THREE45 from "three";
|
|
45729
45761
|
|
|
45730
45762
|
// src/utils/manifold-mesh-to-three-geometry.ts
|
|
@@ -45776,7 +45808,7 @@ var PLATED_HOLE_SURFACE_CLEARANCE = 5e-4;
|
|
|
45776
45808
|
var PLATED_HOLE_FILL_CLEARANCE = 4e-3;
|
|
45777
45809
|
function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
45778
45810
|
const platedHoleBoardDrills = [];
|
|
45779
|
-
const pcbPlatedHoles =
|
|
45811
|
+
const pcbPlatedHoles = su15(circuitJson).pcb_plated_hole.list();
|
|
45780
45812
|
const platedHoleCopperGeoms = [];
|
|
45781
45813
|
const platedHoleCopperOpsForSubtract = [];
|
|
45782
45814
|
const createPillOp = (width10, height10, depth) => {
|
|
@@ -46399,7 +46431,6 @@ function processPlatedHolesForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
46399
46431
|
}
|
|
46400
46432
|
|
|
46401
46433
|
// src/utils/manifold/process-vias.ts
|
|
46402
|
-
import { su as su15 } from "@tscircuit/circuit-json-util";
|
|
46403
46434
|
import * as THREE46 from "three";
|
|
46404
46435
|
|
|
46405
46436
|
// src/utils/via-geoms.ts
|
|
@@ -46441,7 +46472,7 @@ function createViaCopper2({
|
|
|
46441
46472
|
var COPPER_COLOR2 = new THREE46.Color(...colors.copper);
|
|
46442
46473
|
function processViasForManifold(Manifold, circuitJson, pcbThickness, manifoldInstancesForCleanup, boardClipVolume) {
|
|
46443
46474
|
const viaBoardDrills = [];
|
|
46444
|
-
const pcbVias =
|
|
46475
|
+
const pcbVias = getPcbVias(circuitJson);
|
|
46445
46476
|
const viaCopperGeoms = [];
|
|
46446
46477
|
pcbVias.forEach((via, index2) => {
|
|
46447
46478
|
if (typeof via.hole_diameter === "number") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.604",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/3d-viewer"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@jscad/regl-renderer": "^2.6.12",
|
|
40
40
|
"@jscad/stl-serializer": "^2.1.20",
|
|
41
41
|
"circuit-json": "^0.0.497",
|
|
42
|
-
"circuit-to-canvas": "^0.0.
|
|
42
|
+
"circuit-to-canvas": "^0.0.131",
|
|
43
43
|
"react-hot-toast": "^2.6.0",
|
|
44
44
|
"three": "^0.165.0",
|
|
45
45
|
"three-stdlib": "^2.36.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"vite-tsconfig-paths": "^4.3.2",
|
|
88
88
|
"@tscircuit/core": "^0.0.1955",
|
|
89
89
|
"@tscircuit/props": "^0.0.664",
|
|
90
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
90
|
+
"@tscircuit/circuit-json-util": "^0.0.116"
|
|
91
91
|
},
|
|
92
92
|
"patchedDependencies": {
|
|
93
93
|
"@tscircuit/fanout-solver@0.0.78": "patches/@tscircuit%2Ffanout-solver@0.0.78.patch"
|