@tscircuit/3d-viewer 0.0.289 → 0.0.291
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.d.ts +1 -1
- package/dist/index.js +20 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ interface UseManifoldBoardBuilderResult {
|
|
|
78
78
|
isLoading: boolean;
|
|
79
79
|
boardData: PcbBoard | null;
|
|
80
80
|
}
|
|
81
|
-
declare const useManifoldBoardBuilder: (manifoldJSModule: ManifoldToplevel | null, circuitJson: AnyCircuitElement[]
|
|
81
|
+
declare const useManifoldBoardBuilder: (manifoldJSModule: ManifoldToplevel | null, circuitJson: AnyCircuitElement[]) => UseManifoldBoardBuilderResult;
|
|
82
82
|
|
|
83
83
|
declare function applyJsdomShim(jsdom: JSDOM): void;
|
|
84
84
|
|
package/dist/index.js
CHANGED
|
@@ -17282,7 +17282,7 @@ import {
|
|
|
17282
17282
|
// package.json
|
|
17283
17283
|
var package_default = {
|
|
17284
17284
|
name: "@tscircuit/3d-viewer",
|
|
17285
|
-
version: "0.0.
|
|
17285
|
+
version: "0.0.290",
|
|
17286
17286
|
main: "./dist/index.js",
|
|
17287
17287
|
module: "./dist/index.js",
|
|
17288
17288
|
type: "module",
|
|
@@ -17610,7 +17610,7 @@ import { Circuit } from "@tscircuit/core";
|
|
|
17610
17610
|
import { useMemo as useMemo5 } from "react";
|
|
17611
17611
|
var useConvertChildrenToSoup = (children) => {
|
|
17612
17612
|
return useMemo5(() => {
|
|
17613
|
-
if (!children) return
|
|
17613
|
+
if (!children) return [];
|
|
17614
17614
|
const circuit = new Circuit();
|
|
17615
17615
|
circuit.add(children);
|
|
17616
17616
|
circuit.render();
|
|
@@ -19014,7 +19014,6 @@ var CadViewerJscad = forwardRef2(
|
|
|
19014
19014
|
}
|
|
19015
19015
|
}, [internalCircuitJson]);
|
|
19016
19016
|
const { stls: boardStls, loading } = useStlsFromGeom(boardGeom);
|
|
19017
|
-
if (!internalCircuitJson) return null;
|
|
19018
19017
|
const cad_components = su4(internalCircuitJson).cad_component.list();
|
|
19019
19018
|
return /* @__PURE__ */ jsxs7(
|
|
19020
19019
|
CadViewerContainer,
|
|
@@ -19822,7 +19821,6 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
19822
19821
|
const [isLoading, setIsLoading] = useState8(true);
|
|
19823
19822
|
const manifoldInstancesForCleanup = useRef6([]);
|
|
19824
19823
|
const boardData = useMemo7(() => {
|
|
19825
|
-
if (!circuitJson) return null;
|
|
19826
19824
|
const boards = su12(circuitJson).pcb_board.list();
|
|
19827
19825
|
if (boards.length === 0) {
|
|
19828
19826
|
return null;
|
|
@@ -19830,16 +19828,23 @@ var useManifoldBoardBuilder = (manifoldJSModule, circuitJson) => {
|
|
|
19830
19828
|
return boards[0];
|
|
19831
19829
|
}, [circuitJson]);
|
|
19832
19830
|
useEffect5(() => {
|
|
19833
|
-
if (!manifoldJSModule || !
|
|
19831
|
+
if (!manifoldJSModule || !boardData) {
|
|
19834
19832
|
setGeoms(null);
|
|
19835
19833
|
setTextures(null);
|
|
19836
19834
|
setPcbThickness(null);
|
|
19837
|
-
if (
|
|
19835
|
+
if (su12(circuitJson).pcb_board.list().length === 0) {
|
|
19838
19836
|
setError("No pcb_board found in circuitJson.");
|
|
19839
19837
|
}
|
|
19840
19838
|
setIsLoading(false);
|
|
19841
19839
|
return;
|
|
19842
19840
|
}
|
|
19841
|
+
if ((boardData.width === 0 || !boardData.width) && (boardData.height === 0 || !boardData.height) && (!boardData.outline || boardData.outline.length < 3)) {
|
|
19842
|
+
setGeoms({ platedHoles: [], smtPads: [], vias: [] });
|
|
19843
|
+
setTextures({});
|
|
19844
|
+
setPcbThickness(boardData.thickness ?? 0);
|
|
19845
|
+
setIsLoading(false);
|
|
19846
|
+
return;
|
|
19847
|
+
}
|
|
19843
19848
|
setIsLoading(true);
|
|
19844
19849
|
setError(null);
|
|
19845
19850
|
const Manifold = manifoldJSModule.Manifold;
|
|
@@ -20083,10 +20088,15 @@ function createTextureMeshes(textures, boardData, pcbThickness) {
|
|
|
20083
20088
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
20084
20089
|
var MANIFOLD_CDN_BASE_URL = "https://cdn.jsdelivr.net/npm/manifold-3d@3.1.1";
|
|
20085
20090
|
var CadViewerManifold = ({
|
|
20086
|
-
circuitJson,
|
|
20091
|
+
circuitJson: circuitJsonProp,
|
|
20087
20092
|
autoRotateDisabled,
|
|
20088
|
-
clickToInteractEnabled
|
|
20093
|
+
clickToInteractEnabled,
|
|
20094
|
+
children
|
|
20089
20095
|
}) => {
|
|
20096
|
+
const childrenCircuitJson = useConvertChildrenToSoup(children);
|
|
20097
|
+
const circuitJson = useMemo8(() => {
|
|
20098
|
+
return circuitJsonProp ?? childrenCircuitJson;
|
|
20099
|
+
}, [circuitJsonProp, childrenCircuitJson]);
|
|
20090
20100
|
const [manifoldJSModule, setManifoldJSModule] = useState9(null);
|
|
20091
20101
|
const [manifoldLoadingError, setManifoldLoadingError] = useState9(null);
|
|
20092
20102
|
useEffect6(() => {
|
|
@@ -20129,7 +20139,7 @@ var CadViewerManifold = ({
|
|
|
20129
20139
|
[textures, boardData, pcbThickness]
|
|
20130
20140
|
);
|
|
20131
20141
|
const cadComponents = useMemo8(
|
|
20132
|
-
() =>
|
|
20142
|
+
() => su13(circuitJson).cad_component.list(),
|
|
20133
20143
|
[circuitJson]
|
|
20134
20144
|
);
|
|
20135
20145
|
const boardDimensions = useMemo8(() => {
|
|
@@ -20182,7 +20192,7 @@ var CadViewerManifold = ({
|
|
|
20182
20192
|
}
|
|
20183
20193
|
);
|
|
20184
20194
|
}
|
|
20185
|
-
if (builderIsLoading
|
|
20195
|
+
if (builderIsLoading) {
|
|
20186
20196
|
return /* @__PURE__ */ jsx11("div", { style: { padding: "1em" }, children: "Processing board geometry..." });
|
|
20187
20197
|
}
|
|
20188
20198
|
return /* @__PURE__ */ jsxs8(
|