Skip to content

Commit

Permalink
Merge pull request #496 from Original-Recipe/fixed-3d-view-perspective
Browse files Browse the repository at this point in the history
feat: Perspective of the 3D view only when the selectedBox's ID changed
  • Loading branch information
lihqi authored Jun 26, 2024
2 parents e810f7d + f5f5d3e commit 8c7d5da
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ const PointCloud3D: React.FC<IA2MapStateProps> = ({ 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);

/**
Expand All @@ -227,7 +233,7 @@ const PointCloud3D: React.FC<IA2MapStateProps> = ({ currentData, config, highlig
const zoom = ptCtx.topViewInstance?.pointCloudInstance?.camera.zoom ?? 1;
ptCtx.mainViewInstance?.updateCameraZoom(zoom);
}
}, [selectedBox]);
}, [selectedBox?.info?.id]);

useEffect(() => {
if (selectedSphere) {
Expand Down

0 comments on commit 8c7d5da

Please sign in to comment.