@tscircuit/3d-viewer 0.0.607 → 0.0.608

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 CHANGED
@@ -73,6 +73,24 @@ const MyPCBViewer = () => {
73
73
  export default MyPCBViewer
74
74
  ```
75
75
 
76
+ ### Navigate to a schematic component
77
+
78
+ Pass `onViewSchematicComponent` to enable **Show on schematic** when a user
79
+ right-clicks a component model (or long-presses it on touch devices). The callback
80
+ receives `{ source_component_id, pcb_component_id, refdes }`, matching the PCB
81
+ viewer. The host can switch tabs and focus the schematic using the source ID.
82
+ Omit the callback when schematic navigation is unavailable.
83
+
84
+ ```tsx
85
+ <CadViewer
86
+ circuitJson={circuitJson}
87
+ onViewSchematicComponent={({ source_component_id }) => {
88
+ // Find the schematic component with this source ID and focus it.
89
+ showSchematicComponent(source_component_id)
90
+ }}
91
+ />
92
+ ```
93
+
76
94
  ### Converting to SVG (Node.js)
77
95
 
78
96
  When using the SVG converter in Node.js environments, you'll need to provide JSDOM:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React$1 from 'react';
2
2
  import { AnyCircuitElement, PcbBoard } from 'circuit-json';
3
3
  import * as THREE from 'three';
4
4
  import { GLTFExporterOptions } from 'three-stdlib';
@@ -6,7 +6,53 @@ import { ManifoldToplevel } from 'manifold-3d';
6
6
  import { JSDOM } from 'jsdom';
7
7
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
8
8
 
9
- declare const CadViewer: (props: any) => React.JSX.Element;
9
+ /** Same component identity contract as the PCB viewer. */
10
+ interface ViewSchematicComponentEvent {
11
+ source_component_id: string;
12
+ pcb_component_id: string;
13
+ refdes: string;
14
+ }
15
+
16
+ type CameraPreset = "Custom" | "Top Down" | "Top Left Corner" | "Top Right Corner" | "Left Sideview" | "Right Sideview" | "Front" | "Top Center Angled";
17
+ interface CameraAnimationConfig {
18
+ position: readonly [number, number, number];
19
+ target?: readonly [number, number, number];
20
+ up?: readonly [number, number, number];
21
+ durationMs?: number;
22
+ }
23
+ interface CameraController {
24
+ animateTo: (config: CameraAnimationConfig) => void;
25
+ animateToPreset: (preset: CameraPreset) => void;
26
+ }
27
+ declare const CameraAnimatorWithContext: React$1.FC;
28
+
29
+ type ReferenceObjectType = "banana" | "credit-card" | "14in-macbook";
30
+
31
+ interface Props {
32
+ /**
33
+ * @deprecated Use circuitJson instead.
34
+ */
35
+ soup?: AnyCircuitElement[];
36
+ circuitJson?: AnyCircuitElement[];
37
+ autoRotateDisabled?: boolean;
38
+ clickToInteractEnabled?: boolean;
39
+ cameraType?: "orthographic" | "perspective";
40
+ onUserInteraction?: () => void;
41
+ onCameraControllerReady?: (controller: CameraController | null) => void;
42
+ resolveStaticAsset?: (modelUrl: string) => string;
43
+ referenceObject?: ReferenceObjectType | null;
44
+ }
45
+ declare const CadViewerJscad: React$1.ForwardRefExoticComponent<Props & {
46
+ children?: React$1.ReactNode | undefined;
47
+ } & React$1.RefAttributes<THREE.Object3D<THREE.Object3DEventMap>>>;
48
+
49
+ type CadViewerProps = Omit<React.ComponentProps<typeof CadViewerJscad>, "circuitJson"> & {
50
+ circuitJson?: any[];
51
+ foldPcbs?: boolean;
52
+ /** Enable right-click navigation using the same identity as the PCB viewer. */
53
+ onViewSchematicComponent?: (event: ViewSchematicComponentEvent) => void;
54
+ };
55
+ declare const CadViewer: (props: CadViewerProps) => React$1.JSX.Element;
10
56
 
11
57
  interface CircuitToSvgOptions {
12
58
  width?: number;
@@ -34,11 +80,11 @@ type Options = Omit<GLTFExporterOptions, "animations" | "includeCustomExtensions
34
80
  declare function useSaveGltfAs(options?: Options & {
35
81
  filename?: string;
36
82
  }): [
37
- ref3D: React.ForwardedRef<THREE.Object3D>,
83
+ ref3D: React$1.ForwardedRef<THREE.Object3D>,
38
84
  saveAs: (filename?: string) => Promise<void>
39
85
  ];
40
86
  declare function useExportGltfUrl(options?: Options): [
41
- ref3D: React.ForwardedRef<THREE.Object3D>,
87
+ ref3D: React$1.ForwardedRef<THREE.Object3D>,
42
88
  url: string | undefined,
43
89
  error: ErrorEvent | undefined
44
90
  ];
@@ -112,24 +158,11 @@ declare const useManifoldBoardBuilder: (manifoldJSModule: ManifoldToplevel | nul
112
158
 
113
159
  declare function applyJsdomShim(jsdom: JSDOM): void;
114
160
 
115
- type CameraPreset = "Custom" | "Top Down" | "Top Left Corner" | "Top Right Corner" | "Left Sideview" | "Right Sideview" | "Front" | "Top Center Angled";
116
- interface CameraAnimationConfig {
117
- position: readonly [number, number, number];
118
- target?: readonly [number, number, number];
119
- up?: readonly [number, number, number];
120
- durationMs?: number;
121
- }
122
- interface CameraController {
123
- animateTo: (config: CameraAnimationConfig) => void;
124
- animateToPreset: (preset: CameraPreset) => void;
125
- }
126
- declare const CameraAnimatorWithContext: React.FC;
127
-
128
161
  declare const saveCameraToSession: (camera: THREE.Camera, controls: any) => void;
129
162
  declare const loadCameraFromSession: (camera: THREE.Camera, controls: any) => boolean;
130
163
  interface CameraControllerContextValue {
131
- controlsRef: React.MutableRefObject<OrbitControls | null>;
132
- mainCameraRef: React.MutableRefObject<THREE.Camera | null>;
164
+ controlsRef: React$1.MutableRefObject<OrbitControls | null>;
165
+ mainCameraRef: React$1.MutableRefObject<THREE.Camera | null>;
133
166
  defaultTarget: THREE.Vector3;
134
167
  baseDistance: number;
135
168
  controller: CameraController | null;
@@ -146,12 +179,12 @@ interface CameraControllerContextValue {
146
179
  loadCameraFromSession: (camera: THREE.Camera, controls: any) => boolean;
147
180
  }
148
181
  interface CameraControllerProviderProps {
149
- children: React.ReactNode;
182
+ children: React$1.ReactNode;
150
183
  defaultTarget: THREE.Vector3;
151
184
  initialCameraPosition?: readonly [number, number, number];
152
185
  initialCameraType?: "perspective" | "orthographic";
153
186
  }
154
- declare const CameraControllerProvider: React.FC<CameraControllerProviderProps>;
187
+ declare const CameraControllerProvider: React$1.FC<CameraControllerProviderProps>;
155
188
  declare const useCameraController: () => CameraControllerContextValue;
156
189
 
157
190
  declare const useCameraSession: () => {
@@ -159,4 +192,4 @@ declare const useCameraSession: () => {
159
192
  handleControlsChange: () => void;
160
193
  };
161
194
 
162
- export { CadViewer, CameraAnimatorWithContext, CameraControllerProvider, type ManifoldGeoms, applyJsdomShim, convertCircuitJsonTo3dSvg, loadCameraFromSession, saveCameraToSession, useCameraController, useCameraSession, useExportGltfUrl, useManifoldBoardBuilder, useSaveGltfAs };
195
+ export { CadViewer, type CadViewerProps, CameraAnimatorWithContext, CameraControllerProvider, type ManifoldGeoms, type ViewSchematicComponentEvent, applyJsdomShim, convertCircuitJsonTo3dSvg, loadCameraFromSession, saveCameraToSession, useCameraController, useCameraSession, useExportGltfUrl, useManifoldBoardBuilder, useSaveGltfAs };