diff --git a/furniture-3d-system/src/app/installation-demo-workbench/InstallationDemoWorkbenchClient.tsx b/furniture-3d-system/src/app/installation-demo-workbench/InstallationDemoWorkbenchClient.tsx index 59913664..e8884121 100644 --- a/furniture-3d-system/src/app/installation-demo-workbench/InstallationDemoWorkbenchClient.tsx +++ b/furniture-3d-system/src/app/installation-demo-workbench/InstallationDemoWorkbenchClient.tsx @@ -23,7 +23,10 @@ import { buildInstallationCameraViewKey, captureInstallationCameraView, } from "./lib/installationCameraView"; -import { collectInstallationModelNodeSnapshots } from "./lib/installationModelGeometry"; +import { + collectInstallationModelNodeSnapshots, + resetInstallationModelGeometry, +} from "./lib/installationModelGeometry"; import { normalizeInstallationStepDrafts } from "./lib/installationStepDraftBuilder"; import { buildInstallationStepMaterialShareSnapshotsByStepId } from "./lib/installationStepMaterialShareSnapshots"; import { @@ -1141,6 +1144,29 @@ export default function InstallationDemoWorkbenchClient({ [], ); + const resetExplosionGeometry = useCallback(() => { + partCatalog.resetAllPartTransforms(); + + const engine = previewEngineRef.current ?? previewEngine; + if (!engine) { + setModelNodeSnapshots([]); + return; + } + + const nodeNames = resetInstallationModelGeometry(engine); + syncModelGeometry(engine, nodeNames); + }, [partCatalog, previewEngine, syncModelGeometry]); + + const prepareModelReplacement = useCallback(async () => { + resetExplosionGeometry(); + previewEngineRef.current = null; + setPreviewEngine(null); + setModelNodeNames([]); + setModelNodeSnapshots([]); + + await new Promise((resolve) => window.setTimeout(resolve, 0)); + }, [resetExplosionGeometry]); + const selectNumberingPart = useCallback( (partId: string) => { numberingCatalog.setSelectedPartId(partId); @@ -1665,9 +1691,13 @@ export default function InstallationDemoWorkbenchClient({ const handleUploadModel = useCallback( (file: File) => { if (!catalog.access.canEdit || !selectedDrawing) return; - void upload.uploadModelForDrawing(selectedDrawing.id, file); + void upload.uploadModelForDrawing( + selectedDrawing.id, + file, + prepareModelReplacement, + ); }, - [catalog.access.canEdit, selectedDrawing, upload], + [catalog.access.canEdit, prepareModelReplacement, selectedDrawing, upload], ); const prepareNumberingSnapshotBatchForShare = useCallback(async ( @@ -2567,11 +2597,6 @@ export default function InstallationDemoWorkbenchClient({ numberingCatalog.setSelectedPartId(null); }} onModelNodesChange={(nextNodeNames) => { - const previewEngine = previewEngineRef.current; - if (previewEngine) { - syncModelGeometry(previewEngine, nextNodeNames); - return; - } setModelNodeNames(nextNodeNames); setModelNodeSnapshots([]); }} @@ -2972,7 +2997,7 @@ export default function InstallationDemoWorkbenchClient({ explosionSelectedNodeNames, ); }} - onResetAllParts={partCatalog.resetAllPartTransforms} + onResetAllParts={resetExplosionGeometry} onSelectNumberingPart={selectNumberingPart} onNumberingCategoryChange={(nextCategory) => { setNumberingCategory(nextCategory); diff --git a/furniture-3d-system/src/app/installation-demo-workbench/components/ExplosionEditorPanel.tsx b/furniture-3d-system/src/app/installation-demo-workbench/components/ExplosionEditorPanel.tsx index 3bd2b17c..e745354e 100644 --- a/furniture-3d-system/src/app/installation-demo-workbench/components/ExplosionEditorPanel.tsx +++ b/furniture-3d-system/src/app/installation-demo-workbench/components/ExplosionEditorPanel.tsx @@ -61,7 +61,7 @@ export function ExplosionEditorPanel({