@tscircuit/3d-viewer 0.0.345 → 0.0.346
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 +47 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25582,7 +25582,7 @@ import * as THREE10 from "three";
|
|
|
25582
25582
|
// package.json
|
|
25583
25583
|
var package_default = {
|
|
25584
25584
|
name: "@tscircuit/3d-viewer",
|
|
25585
|
-
version: "0.0.
|
|
25585
|
+
version: "0.0.345",
|
|
25586
25586
|
main: "./dist/index.js",
|
|
25587
25587
|
module: "./dist/index.js",
|
|
25588
25588
|
type: "module",
|
|
@@ -28863,7 +28863,7 @@ var BoardMeshes = ({
|
|
|
28863
28863
|
}, [rootObject, geometryMeshes, textureMeshes]);
|
|
28864
28864
|
return null;
|
|
28865
28865
|
};
|
|
28866
|
-
var MANIFOLD_CDN_BASE_URL = "https://cdn.jsdelivr.net/npm/manifold-3d@3.
|
|
28866
|
+
var MANIFOLD_CDN_BASE_URL = "https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1";
|
|
28867
28867
|
var CadViewerManifold = ({
|
|
28868
28868
|
circuitJson: circuitJsonProp,
|
|
28869
28869
|
autoRotateDisabled,
|
|
@@ -28878,32 +28878,57 @@ var CadViewerManifold = ({
|
|
|
28878
28878
|
const [manifoldJSModule, setManifoldJSModule] = useState13(null);
|
|
28879
28879
|
const [manifoldLoadingError, setManifoldLoadingError] = useState13(null);
|
|
28880
28880
|
useEffect20(() => {
|
|
28881
|
-
const
|
|
28881
|
+
const initManifold = async (ManifoldModule) => {
|
|
28882
28882
|
try {
|
|
28883
|
-
const
|
|
28884
|
-
|
|
28885
|
-
|
|
28886
|
-
manifoldURL
|
|
28887
|
-
);
|
|
28888
|
-
if (ManifoldModule) {
|
|
28889
|
-
const loadedModule = await ManifoldModule({
|
|
28890
|
-
locateFile: () => `${MANIFOLD_CDN_BASE_URL}/manifold.wasm`
|
|
28891
|
-
});
|
|
28892
|
-
loadedModule.setup();
|
|
28893
|
-
setManifoldJSModule(loadedModule);
|
|
28894
|
-
} else {
|
|
28895
|
-
throw new Error(
|
|
28896
|
-
"ManifoldModule not found in dynamically imported module"
|
|
28897
|
-
);
|
|
28898
|
-
}
|
|
28883
|
+
const loadedModule = await ManifoldModule();
|
|
28884
|
+
loadedModule.setup();
|
|
28885
|
+
setManifoldJSModule(loadedModule);
|
|
28899
28886
|
} catch (error) {
|
|
28900
|
-
console.error("Failed to
|
|
28887
|
+
console.error("Failed to initialize Manifold:", error);
|
|
28901
28888
|
setManifoldLoadingError(
|
|
28902
|
-
`Failed to
|
|
28889
|
+
`Failed to initialize Manifold: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
28903
28890
|
);
|
|
28904
28891
|
}
|
|
28905
28892
|
};
|
|
28906
|
-
|
|
28893
|
+
if (window.ManifoldModule) {
|
|
28894
|
+
initManifold(window.ManifoldModule);
|
|
28895
|
+
return;
|
|
28896
|
+
}
|
|
28897
|
+
const eventName = "manifoldLoaded";
|
|
28898
|
+
const handleLoad = () => {
|
|
28899
|
+
if (window.ManifoldModule) {
|
|
28900
|
+
initManifold(window.ManifoldModule);
|
|
28901
|
+
} else {
|
|
28902
|
+
const errText = "ManifoldModule not found on window after script load.";
|
|
28903
|
+
console.error(errText);
|
|
28904
|
+
setManifoldLoadingError(errText);
|
|
28905
|
+
}
|
|
28906
|
+
};
|
|
28907
|
+
window.addEventListener(eventName, handleLoad, { once: true });
|
|
28908
|
+
const script = document.createElement("script");
|
|
28909
|
+
script.type = "module";
|
|
28910
|
+
script.innerHTML = `
|
|
28911
|
+
try {
|
|
28912
|
+
const { default: ManifoldModule } = await import('${MANIFOLD_CDN_BASE_URL}/manifold.js');
|
|
28913
|
+
window.ManifoldModule = ManifoldModule;
|
|
28914
|
+
} catch (e) {
|
|
28915
|
+
console.error('Error importing manifold in dynamic script:', e);
|
|
28916
|
+
} finally {
|
|
28917
|
+
window.dispatchEvent(new CustomEvent('${eventName}'));
|
|
28918
|
+
}
|
|
28919
|
+
`.trim();
|
|
28920
|
+
const scriptError = (err) => {
|
|
28921
|
+
const errText = "Failed to load Manifold loader script.";
|
|
28922
|
+
console.error(errText, err);
|
|
28923
|
+
setManifoldLoadingError(errText);
|
|
28924
|
+
window.removeEventListener(eventName, handleLoad);
|
|
28925
|
+
};
|
|
28926
|
+
script.addEventListener("error", scriptError);
|
|
28927
|
+
document.body.appendChild(script);
|
|
28928
|
+
return () => {
|
|
28929
|
+
window.removeEventListener(eventName, handleLoad);
|
|
28930
|
+
script.removeEventListener("error", scriptError);
|
|
28931
|
+
};
|
|
28907
28932
|
}, []);
|
|
28908
28933
|
const {
|
|
28909
28934
|
geoms,
|