@tscircuit/3d-viewer 0.0.114 → 0.0.115
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 +39 -0
- package/dist/{index.d.ts → index.d.mts} +34 -9
- package/dist/index.mjs +5152 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -29
- package/dist/index.js +0 -1328
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -70,6 +70,45 @@ const MyPCBViewer = () => {
|
|
|
70
70
|
export default MyPCBViewer
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
### Converting to SVG (Node.js)
|
|
74
|
+
|
|
75
|
+
When using the SVG converter in Node.js environments, you'll need to provide JSDOM:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { JSDOM } from 'jsdom'
|
|
79
|
+
import { convert3dCircuitToSvg } from '@tscircuit/3d-viewer/3d'
|
|
80
|
+
import { applyJsdomShim } from '@tscircuit/3d-viewer/utils'
|
|
81
|
+
|
|
82
|
+
// Setup JSDOM environment
|
|
83
|
+
const dom = new JSDOM()
|
|
84
|
+
applyJsdomShim(dom)
|
|
85
|
+
|
|
86
|
+
// Convert circuit to SVG
|
|
87
|
+
const options = {
|
|
88
|
+
width: 800,
|
|
89
|
+
height: 600,
|
|
90
|
+
backgroundColor: "#ffffff",
|
|
91
|
+
padding: 20,
|
|
92
|
+
zoom: 50,
|
|
93
|
+
camera: {
|
|
94
|
+
position: { x: 0, y: 0, z: 100 },
|
|
95
|
+
lookAt: { x: 0, y: 0, z: 0 }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const svgString = await convert3dCircuitToSvg(circuitJson, options)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The `convert3dCircuitToSvg` function accepts the following options:
|
|
103
|
+
- `width`: Width of the output SVG (default: 800)
|
|
104
|
+
- `height`: Height of the output SVG (default: 600)
|
|
105
|
+
- `backgroundColor`: Background color in hex format (default: "#ffffff")
|
|
106
|
+
- `padding`: Padding around the board (default: 20)
|
|
107
|
+
- `zoom`: Zoom level (default: 1.5)
|
|
108
|
+
- `camera`: Camera position and lookAt configuration
|
|
109
|
+
- `position`: {x, y, z} coordinates for camera position
|
|
110
|
+
- `lookAt`: {x, y, z} coordinates for camera target
|
|
111
|
+
|
|
73
112
|
## API Reference
|
|
74
113
|
|
|
75
114
|
### `<CadViewer>`
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
+
import { AnySoupElement } from '@tscircuit/soup';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import * as THREE from 'three';
|
|
3
4
|
import { GLTFExporterOptions } from 'three-stdlib';
|
|
4
|
-
import {
|
|
5
|
+
import { JSDOM } from 'jsdom';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
soup?: AnySoupElement[];
|
|
9
|
+
autoRotateDisabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const CadViewer: React.ForwardRefExoticComponent<Props & {
|
|
12
|
+
children?: React.ReactNode | undefined;
|
|
13
|
+
} & React.RefAttributes<THREE.Object3D<THREE.Object3DEventMap>>>;
|
|
14
|
+
|
|
15
|
+
interface CircuitToSvgOptions {
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
viewAngle?: "top" | "isometric" | "front" | "side";
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
padding?: number;
|
|
21
|
+
zoom?: number;
|
|
22
|
+
camera?: {
|
|
23
|
+
position: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
z: number;
|
|
27
|
+
};
|
|
28
|
+
lookAt?: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
z: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
declare function convertCircuitJsonTo3dSvg(circuitJson: AnySoupElement[], options?: CircuitToSvgOptions): Promise<string>;
|
|
5
36
|
|
|
6
37
|
type Options = Omit<GLTFExporterOptions, "animations" | "includeCustomExtensions">;
|
|
7
38
|
declare function useSaveGltfAs(options?: Options & {
|
|
@@ -16,12 +47,6 @@ declare function useExportGltfUrl(options?: Options): [
|
|
|
16
47
|
error: ErrorEvent | undefined
|
|
17
48
|
];
|
|
18
49
|
|
|
19
|
-
|
|
20
|
-
soup?: AnySoupElement[];
|
|
21
|
-
autoRotateDisabled?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare const CadViewer: React.ForwardRefExoticComponent<Props & {
|
|
24
|
-
children?: React.ReactNode | undefined;
|
|
25
|
-
} & React.RefAttributes<THREE.Object3D<THREE.Object3DEventMap>>>;
|
|
50
|
+
declare function applyJsdomShim(jsdom: JSDOM): void;
|
|
26
51
|
|
|
27
|
-
export { CadViewer, useExportGltfUrl, useSaveGltfAs };
|
|
52
|
+
export { CadViewer, applyJsdomShim, convertCircuitJsonTo3dSvg, useExportGltfUrl, useSaveGltfAs };
|