@tscircuit/3d-viewer 0.0.121 → 0.0.122
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 +5 -5
- package/dist/index.d.ts +7 -3
- package/dist/index.js +24 -19
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -59,15 +59,15 @@ const MyPCBViewer = () => {
|
|
|
59
59
|
export default MyPCBViewer
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
### Using with
|
|
62
|
+
### Using with circuitJson Data
|
|
63
63
|
|
|
64
64
|
```jsx
|
|
65
65
|
import React from "react"
|
|
66
66
|
import { CadViewer } from "@tscircuit/3d-viewer"
|
|
67
|
-
import
|
|
67
|
+
import mycircuitJsonData from "./mycircuitJsonpData.json"
|
|
68
68
|
|
|
69
69
|
const MyPCBViewer = () => {
|
|
70
|
-
return <CadViewer
|
|
70
|
+
return <CadViewer circuitJson={mycircuitJsonData} />
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export default MyPCBViewer
|
|
@@ -120,8 +120,8 @@ Main component for rendering the 3D PCB viewer.
|
|
|
120
120
|
|
|
121
121
|
Props:
|
|
122
122
|
|
|
123
|
-
- `
|
|
124
|
-
- `children`: (optional) React children elements describing the PCB layout (alternative to using `
|
|
123
|
+
- `circuit-json`: (optional) An array of AnyCircuitElement objects representing the PCB layout.
|
|
124
|
+
- `children`: (optional) React children elements describing the PCB layout (alternative to using `circuit-json`).
|
|
125
125
|
|
|
126
126
|
### `<board>`
|
|
127
127
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyCircuitElement } from 'circuit-json';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { GLTFExporterOptions } from 'three-stdlib';
|
|
5
5
|
import { JSDOM } from 'jsdom';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use circuitJson instead.
|
|
10
|
+
*/
|
|
11
|
+
soup?: AnyCircuitElement[];
|
|
12
|
+
circuitJson?: AnyCircuitElement[];
|
|
9
13
|
autoRotateDisabled?: boolean;
|
|
10
14
|
}
|
|
11
15
|
declare const CadViewer: React.ForwardRefExoticComponent<Props & {
|
|
@@ -32,7 +36,7 @@ interface CircuitToSvgOptions {
|
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
declare function convertCircuitJsonTo3dSvg(circuitJson:
|
|
39
|
+
declare function convertCircuitJsonTo3dSvg(circuitJson: AnyCircuitElement[], options?: CircuitToSvgOptions): Promise<string>;
|
|
36
40
|
|
|
37
41
|
type Options = Omit<GLTFExporterOptions, "animations" | "includeCustomExtensions">;
|
|
38
42
|
declare function useSaveGltfAs(options?: Options & {
|
package/dist/index.js
CHANGED
|
@@ -14220,17 +14220,20 @@ function createSilkscreenTextGeoms(silkscreenText) {
|
|
|
14220
14220
|
}
|
|
14221
14221
|
|
|
14222
14222
|
// src/soup-to-3d/index.ts
|
|
14223
|
-
var createBoardGeomFromSoup = (soup) => {
|
|
14224
|
-
|
|
14223
|
+
var createBoardGeomFromSoup = (soup, circuitJson) => {
|
|
14224
|
+
if (!circuitJson) {
|
|
14225
|
+
throw new Error("circuitJson is required but was not provided");
|
|
14226
|
+
}
|
|
14227
|
+
const board = su(circuitJson).pcb_board.list()[0];
|
|
14225
14228
|
if (!board) {
|
|
14226
14229
|
throw new Error("No pcb_board found");
|
|
14227
14230
|
}
|
|
14228
|
-
const plated_holes = su(
|
|
14229
|
-
const holes = su(
|
|
14230
|
-
const pads = su(
|
|
14231
|
-
const traces = su(
|
|
14232
|
-
const pcb_vias = su(
|
|
14233
|
-
const silkscreenTexts = su(
|
|
14231
|
+
const plated_holes = su(circuitJson).pcb_plated_hole.list();
|
|
14232
|
+
const holes = su(circuitJson).pcb_hole.list();
|
|
14233
|
+
const pads = su(circuitJson).pcb_smtpad.list();
|
|
14234
|
+
const traces = su(circuitJson).pcb_trace.list();
|
|
14235
|
+
const pcb_vias = su(circuitJson).pcb_via.list();
|
|
14236
|
+
const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list();
|
|
14234
14237
|
let boardGeom;
|
|
14235
14238
|
if (board.outline && board.outline.length > 0)
|
|
14236
14239
|
boardGeom = createBoardWithOutline(board.outline, 1.2);
|
|
@@ -17407,7 +17410,7 @@ import { Canvas, useFrame as useFrame2 } from "@react-three/fiber";
|
|
|
17407
17410
|
// package.json
|
|
17408
17411
|
var package_default = {
|
|
17409
17412
|
name: "@tscircuit/3d-viewer",
|
|
17410
|
-
version: "0.0.
|
|
17413
|
+
version: "0.0.121",
|
|
17411
17414
|
main: "./dist/index.js",
|
|
17412
17415
|
module: "./dist/index.js",
|
|
17413
17416
|
type: "module",
|
|
@@ -17441,8 +17444,7 @@ var package_default = {
|
|
|
17441
17444
|
"@tscircuit/core": "^0.0.299",
|
|
17442
17445
|
"@tscircuit/props": "^0.0.138",
|
|
17443
17446
|
"@tscircuit/react-fiber": "^1.2.0",
|
|
17444
|
-
"@tscircuit/soup": "^0.0.
|
|
17445
|
-
"@tscircuit/soup-util": "^0.0.26",
|
|
17447
|
+
"@tscircuit/soup-util": "^0.0.41",
|
|
17446
17448
|
"jscad-electronics": "^0.0.23",
|
|
17447
17449
|
"jscad-fiber": "^0.0.77",
|
|
17448
17450
|
"jscad-planner": "^0.0.12",
|
|
@@ -18069,16 +18071,17 @@ var Error3d = ({
|
|
|
18069
18071
|
|
|
18070
18072
|
// src/CadViewer.tsx
|
|
18071
18073
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
18072
|
-
var CadViewer = forwardRef2(({ soup, children, autoRotateDisabled }, ref) => {
|
|
18074
|
+
var CadViewer = forwardRef2(({ soup, circuitJson, children, autoRotateDisabled }, ref) => {
|
|
18075
|
+
circuitJson ??= soup;
|
|
18073
18076
|
const [hoveredComponent, setHoveredComponent] = useState3(null);
|
|
18074
|
-
|
|
18075
|
-
if (!
|
|
18077
|
+
circuitJson ??= useConvertChildrenToSoup(children, circuitJson);
|
|
18078
|
+
if (!circuitJson) return null;
|
|
18076
18079
|
const boardGeom = useMemo4(() => {
|
|
18077
|
-
if (!
|
|
18078
|
-
return createBoardGeomFromSoup(
|
|
18079
|
-
}, [
|
|
18080
|
+
if (!circuitJson.some((e) => e.type === "pcb_board")) return null;
|
|
18081
|
+
return createBoardGeomFromSoup(circuitJson);
|
|
18082
|
+
}, [circuitJson]);
|
|
18080
18083
|
const { stls: boardStls, loading } = useStlsFromGeom(boardGeom);
|
|
18081
|
-
const cad_components = su2(
|
|
18084
|
+
const cad_components = su2(circuitJson).cad_component.list();
|
|
18082
18085
|
return /* @__PURE__ */ jsxs6(
|
|
18083
18086
|
CadViewerContainer,
|
|
18084
18087
|
{
|
|
@@ -18107,7 +18110,9 @@ var CadViewer = forwardRef2(({ soup, children, autoRotateDisabled }, ref) => {
|
|
|
18107
18110
|
setHoveredComponent(null);
|
|
18108
18111
|
}
|
|
18109
18112
|
if (!e.mousePosition) return;
|
|
18110
|
-
const componentName = su2(
|
|
18113
|
+
const componentName = su2(
|
|
18114
|
+
circuitJson
|
|
18115
|
+
).source_component.getUsing({
|
|
18111
18116
|
source_component_id: cad_component.source_component_id
|
|
18112
18117
|
})?.name;
|
|
18113
18118
|
setHoveredComponent({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.122",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
"@tscircuit/core": "^0.0.299",
|
|
35
35
|
"@tscircuit/props": "^0.0.138",
|
|
36
36
|
"@tscircuit/react-fiber": "^1.2.0",
|
|
37
|
-
"@tscircuit/soup": "^0.0.
|
|
38
|
-
"@tscircuit/soup-util": "^0.0.26",
|
|
37
|
+
"@tscircuit/soup-util": "^0.0.41",
|
|
39
38
|
"jscad-electronics": "^0.0.23",
|
|
40
39
|
"jscad-fiber": "^0.0.77",
|
|
41
40
|
"jscad-planner": "^0.0.12",
|