From f5f5d3ec8641214b700ee292b7d4b5ca7c92635e Mon Sep 17 00:00:00 2001 From: Original-Recipe Date: Mon, 24 Jun 2024 19:22:26 +0800 Subject: [PATCH] feat: Perspective of the 3D view only when the selectedBox's ID changed --- .../src/components/pointCloudView/PointCloud3DView.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/lb-components/src/components/pointCloudView/PointCloud3DView.tsx b/packages/lb-components/src/components/pointCloudView/PointCloud3DView.tsx index adcc1901c..db2fb87c7 100644 --- a/packages/lb-components/src/components/pointCloudView/PointCloud3DView.tsx +++ b/packages/lb-components/src/components/pointCloudView/PointCloud3DView.tsx @@ -218,7 +218,13 @@ const PointCloud3D: React.FC = ({ currentData, config, highlig * Observe selectedID and reset camera to target top-view */ useEffect(() => { - if (selectedBox) { + /** + * When the selected rectangle is switched, it is necessary to update the 3D view perspective and zoom size of the currently selected rectangle. Other rendering logic remains unchanged. + * Originally, the perspective was updated whenever any property changed; now it is updated only when the Id changes. + */ + const selectedId = selectedBox?.info?.id; + + if (selectedId !== undefined) { setTarget3DView(EPerspectiveView.Top); /** @@ -227,7 +233,7 @@ const PointCloud3D: React.FC = ({ currentData, config, highlig const zoom = ptCtx.topViewInstance?.pointCloudInstance?.camera.zoom ?? 1; ptCtx.mainViewInstance?.updateCameraZoom(zoom); } - }, [selectedBox]); + }, [selectedBox?.info?.id]); useEffect(() => { if (selectedSphere) {