From 5da6c347587be57b020befcc5fab34d007ee4169 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Wed, 26 Aug 2026 18:29:15 +0800 Subject: [PATCH] feat(installation): auto-explode unnamed assemblies --- .../InstallationDemoWorkbenchClient.tsx | 43 +- .../components/ExplosionEditorPanel.tsx | 2 +- ...eInstallationModelUploadController.test.ts | 79 +++ .../useInstallationModelUploadController.ts | 62 +-- .../hooks/useInstallationPartCatalog.ts | 11 +- .../installationAssemblyContactGraph.test.ts | 55 +++ .../lib/installationAssemblyContactGraph.ts | 185 +++++++ .../lib/installationAssemblyExplodeLayout.ts | 231 +++------ .../installationAutoExplodeTemplateStorage.ts | 8 + ...ionConnectedPanelSeparationPlanner.test.ts | 60 +++ ...allationConnectedPanelSeparationPlanner.ts | 102 ++++ .../installationDrawerAssemblyPlanner.test.ts | 167 +++++++ .../lib/installationDrawerAssemblyPlanner.ts | 286 +++++++++++ .../lib/installationHardwareExplodePlanner.ts | 251 ++++++++++ ...ionLocalHorizontalPartitionPlanner.test.ts | 58 +++ ...allationLocalHorizontalPartitionPlanner.ts | 192 ++++++++ ...tallationLocalVerticalLayerPlanner.test.ts | 68 +++ .../installationLocalVerticalLayerPlanner.ts | 162 +++++++ .../lib/installationModelGeometry.test.ts | 32 ++ .../lib/installationModelGeometry.ts | 21 + ...nstallationOrientationLayerPlanner.test.ts | 144 ++++++ .../installationOrientationLayerPlanner.ts | 402 +++++++++++++++ .../installationPartCatalogHelpers.test.ts | 102 ++++ .../lib/installationPartCatalogHelpers.ts | 50 ++ .../installationUnnamedCabinetShelfPlanner.ts | 92 ++++ ...allationUnnamedCabinetVisibilityPlanner.ts | 186 +++++++ ...tionUnnamedProductStructurePlanner.test.ts | 94 ++++ ...tallationUnnamedProductStructurePlanner.ts | 18 + ...tionUnnamedStructureExplodePlanner.test.ts | 429 ++++++++++++++++ ...tallationUnnamedStructureExplodePlanner.ts | 456 ++++++++++++++++++ 30 files changed, 3852 insertions(+), 196 deletions(-) create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/hooks/useInstallationModelUploadController.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationAssemblyContactGraph.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationAssemblyContactGraph.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationConnectedPanelSeparationPlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationConnectedPanelSeparationPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationDrawerAssemblyPlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationDrawerAssemblyPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationHardwareExplodePlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationLocalHorizontalPartitionPlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationLocalHorizontalPartitionPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationLocalVerticalLayerPlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationLocalVerticalLayerPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationModelGeometry.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationOrientationLayerPlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationOrientationLayerPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationPartCatalogHelpers.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedCabinetShelfPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedCabinetVisibilityPlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedProductStructurePlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedProductStructurePlanner.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedStructureExplodePlanner.test.ts create mode 100644 furniture-3d-system/src/app/installation-demo-workbench/lib/installationUnnamedStructureExplodePlanner.ts 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({